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