debuggers.hg

view netbsd-2.0-xen-sparse/sys/arch/xen/include/ctrl_if.h @ 2630:654b2df93458

bitkeeper revision 1.1159.99.2 (41614eedRuLOjlI5-39Ib0z3OZYFgA)

g/c kthread code.
author cl349@freefall.cl.cam.ac.uk
date Mon Oct 04 13:23:57 2004 +0000 (2004-10-04)
parents 309c1fb27f87
children a4fbb98f00cb
line source
1 /******************************************************************************
2 * ctrl_if.h
3 *
4 * Management functions for special interface to the domain controller.
5 *
6 * Copyright (c) 2004, K A Fraser
7 */
9 #ifndef __ASM_XEN__CTRL_IF_H__
10 #define __ASM_XEN__CTRL_IF_H__
12 typedef control_msg_t ctrl_msg_t;
14 /*
15 * Callback function type. Called for asynchronous processing of received
16 * request messages, and responses to previously-transmitted request messages.
17 * The parameters are (@msg, @id).
18 * @msg: Original request/response message (not a copy). The message can be
19 * modified in-place by the handler (e.g., a response callback can
20 * turn a request message into a response message in place). The message
21 * is no longer accessible after the callback handler returns -- if the
22 * message is required to persist for longer then it must be copied.
23 * @id: (Response callbacks only) The 'id' that was specified when the
24 * original request message was queued for transmission.
25 */
26 typedef void (*ctrl_msg_handler_t)(ctrl_msg_t *, unsigned long);
28 /*
29 * Send @msg to the domain controller. Execute @hnd when a response is
30 * received, passing the response message and the specified @id. This
31 * operation will not block: it will return -EAGAIN if there is no space.
32 * Notes:
33 * 1. The @msg is copied if it is transmitted and so can be freed after this
34 * function returns.
35 * 2. If @hnd is NULL then no callback is executed.
36 */
37 int
38 ctrl_if_send_message_noblock(
39 ctrl_msg_t *msg,
40 ctrl_msg_handler_t hnd,
41 unsigned long id);
43 /*
44 * Send @msg to the domain controller. Execute @hnd when a response is
45 * received, passing the response message and the specified @id. This
46 * operation will block until the message is sent, or a signal is received
47 * for the calling process (unless @wait_state is TASK_UNINTERRUPTIBLE).
48 * Notes:
49 * 1. The @msg is copied if it is transmitted and so can be freed after this
50 * function returns.
51 * 2. If @hnd is NULL then no callback is executed.
52 */
53 int
54 ctrl_if_send_message_block(
55 ctrl_msg_t *msg,
56 ctrl_msg_handler_t hnd,
57 unsigned long id,
58 long wait_state);
60 /*
61 * Send @msg to the domain controller. Block until the response is received,
62 * and then copy it into the provided buffer, @rmsg.
63 */
64 int
65 ctrl_if_send_message_and_get_response(
66 ctrl_msg_t *msg,
67 ctrl_msg_t *rmsg,
68 long wait_state);
70 #ifdef notyet
71 /*
72 * Request a callback when there is /possibly/ space to immediately send a
73 * message to the domain controller. This function returns 0 if there is
74 * already space to trasnmit a message --- in this case the callback task /may/
75 * still be executed. If this function returns 1 then the callback /will/ be
76 * executed when space becomes available.
77 */
78 int
79 ctrl_if_enqueue_space_callback(
80 struct tq_struct *task);
81 #endif
83 /*
84 * Send a response (@msg) to a message from the domain controller. This will
85 * never block.
86 * Notes:
87 * 1. The @msg is copied and so can be freed after this function returns.
88 * 2. The @msg may be the original request message, modified in-place.
89 */
90 void
91 ctrl_if_send_response(
92 ctrl_msg_t *msg);
94 /*
95 * Register a receiver for typed messages from the domain controller. The
96 * handler (@hnd) is called for every received message of specified @type.
97 * Returns TRUE (non-zero) if the handler was successfully registered.
98 * If CALLBACK_IN_BLOCKING CONTEXT is specified in @flags then callbacks will
99 * occur in a context in which it is safe to yield (i.e., process context).
100 */
101 #define CALLBACK_IN_BLOCKING_CONTEXT 1
102 int ctrl_if_register_receiver(
103 uint8_t type,
104 ctrl_msg_handler_t hnd,
105 unsigned int flags);
107 /*
108 * Unregister a receiver for typed messages from the domain controller. The
109 * handler (@hnd) will not be executed after this function returns.
110 */
111 void
112 ctrl_if_unregister_receiver(
113 uint8_t type, ctrl_msg_handler_t hnd);
115 /* Suspend/resume notifications. */
116 void ctrl_if_suspend(void);
117 void ctrl_if_resume(void);
119 /* Start-of-day setup. */
120 void ctrl_if_early_init(void);
121 void ctrl_if_init(void);
123 /*
124 * Returns TRUE if there are no outstanding message requests at the domain
125 * controller. This can be used to ensure that messages have really flushed
126 * through when it is not possible to use the response-callback interface.
127 * WARNING: If other subsystems are using the control interface then this
128 * function might never return TRUE!
129 */
130 int ctrl_if_transmitter_empty(void); /* !! DANGEROUS FUNCTION !! */
132 /*
133 * Manually discard response messages from the domain controller.
134 * WARNING: This is usually done automatically -- this function should only
135 * be called when normal interrupt mechanisms are disabled!
136 */
137 void ctrl_if_discard_responses(void); /* !! DANGEROUS FUNCTION !! */
139 #endif /* __ASM_XEN__CONTROL_IF_H__ */