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