gemini_ipm.h revision 1.1.10.2 1 1.1.10.2 yamt /* $NetBSD: gemini_ipm.h,v 1.1.10.2 2009/05/04 08:10:41 yamt Exp $ */
2 1.1.10.2 yamt
3 1.1.10.2 yamt #ifndef _GEMINI_IPM_H_
4 1.1.10.2 yamt #define _GEMINI_IPM_H_
5 1.1.10.2 yamt
6 1.1.10.2 yamt /*
7 1.1.10.2 yamt * generic/non-specific Messages
8 1.1.10.2 yamt */
9 1.1.10.2 yamt #define IPM_TAG_NONE 0
10 1.1.10.2 yamt #define IPM_TAG_GPN 1
11 1.1.10.2 yamt #define IPM_TAG_WDOG 2
12 1.1.10.2 yamt #define IPM_NTAGS (IPM_TAG_WDOG + 1) /* bump when you add new ones */
13 1.1.10.2 yamt
14 1.1.10.2 yamt typedef struct ipm_desc {
15 1.1.10.2 yamt uint8_t tag;
16 1.1.10.2 yamt uint8_t blob[15];
17 1.1.10.2 yamt } ipm_desc_t;
18 1.1.10.2 yamt
19 1.1.10.2 yamt
20 1.1.10.2 yamt /*
21 1.1.10.2 yamt * void *gemini_ipm_register(uint8_t tag, unsigned int ipl, size_t quota,
22 1.1.10.2 yamt * void (*consume)(void *arg, const void *desc),
23 1.1.10.2 yamt * void (*counter)(void *arg, size_t n),
24 1.1.10.2 yamt * void *arg);
25 1.1.10.2 yamt *
26 1.1.10.2 yamt * - register an IPM service, identified by 'tag'
27 1.1.10.2 yamt * - callback functions may be dispatched using softint at indicated 'ipl'
28 1.1.10.2 yamt * using softint_establish(), softint_disestablish()
29 1.1.10.2 yamt * for now they are called directly at IPL_NET
30 1.1.10.2 yamt * - reserve 'quota' descriptors; minimum is 1.
31 1.1.10.2 yamt * - 'consume' function is called for each message received
32 1.1.10.2 yamt * - 'counter' function is called to update count of
33 1.1.10.2 yamt * of completed produced (sent) descriptors since last update
34 1.1.10.2 yamt * - 'arg' is private to the service
35 1.1.10.2 yamt * - return value is an IPM handle ('ipmh') that can be used
36 1.1.10.2 yamt * e.g. to de-register
37 1.1.10.2 yamt * - if the 'tag' is already in use, or if 'quota' descriptors are not available,
38 1.1.10.2 yamt * then NULL is returned.
39 1.1.10.2 yamt */
40 1.1.10.2 yamt void *gemini_ipm_register(uint8_t, unsigned int, size_t,
41 1.1.10.2 yamt void (*)(void *, const void *),
42 1.1.10.2 yamt void (*)(void *, size_t),
43 1.1.10.2 yamt void *);
44 1.1.10.2 yamt
45 1.1.10.2 yamt /*
46 1.1.10.2 yamt * void gemini_ipm_deregister(void *ipmh);
47 1.1.10.2 yamt *
48 1.1.10.2 yamt * - tear down a service
49 1.1.10.2 yamt * - 'ipmh' is handle returned from priot call to gemini_ipm_register()
50 1.1.10.2 yamt */
51 1.1.10.2 yamt void gemini_ipm_deregister(void *);
52 1.1.10.2 yamt
53 1.1.10.2 yamt /*
54 1.1.10.2 yamt * void gemini_ipm_produce(const void *desc, unsigned size_t ndesc);
55 1.1.10.2 yamt *
56 1.1.10.2 yamt * - service produces (sends) 'ndesc' messages described by the array of
57 1.1.10.2 yamt * descriptors 'desc'.
58 1.1.10.2 yamt * - if not all messages can be sent due to lack of descriptor queue resources,
59 1.1.10.2 yamt * then the calling service has exceeded it's quota and the system will panic.
60 1.1.10.2 yamt * - after return the descriptors at 'desc' revert to the caller
61 1.1.10.2 yamt * caller can recycle or free as he likes.
62 1.1.10.2 yamt */
63 1.1.10.2 yamt int gemini_ipm_produce(const void *, size_t);
64 1.1.10.2 yamt
65 1.1.10.2 yamt /*
66 1.1.10.2 yamt * void gemini_ipm_copyin(void *dest, bus_addr_t ba, size_t len);
67 1.1.10.2 yamt *
68 1.1.10.2 yamt * - service copies in (receives) message 'len' bytes of data to be copied
69 1.1.10.2 yamt * from bus address 'ba' to virtual address 'dest'
70 1.1.10.2 yamt * - this function is meant to be called from the service's registered
71 1.1.10.2 yamt * 'consume' callback function
72 1.1.10.2 yamt */
73 1.1.10.2 yamt void gemini_ipm_copyin(void *, bus_addr_t, size_t);
74 1.1.10.2 yamt
75 1.1.10.2 yamt
76 1.1.10.2 yamt #endif /* _GEMINI_IPM_H_ */
77