1 /******************************************************************************
4 * Management functions for special interface to the domain controller.
6 * Copyright (c) 2004, K A Fraser
8 * This file may be distributed separately from the Linux kernel, or
9 * incorporated into other software packages, subject to the following license:
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this source file (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use, copy, modify,
14 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #ifndef __ASM_XEN__CTRL_IF_H__
31 #define __ASM_XEN__CTRL_IF_H__
33 #include <asm-xen/hypervisor.h>
34 #include <asm-xen/queues.h>
36 typedef control_msg_t ctrl_msg_t;
39 * Callback function type. Called for asynchronous processing of received
40 * request messages, and responses to previously-transmitted request messages.
41 * The parameters are (@msg, @id).
42 * @msg: Original request/response message (not a copy). The message can be
43 * modified in-place by the handler (e.g., a response callback can
44 * turn a request message into a response message in place). The message
45 * is no longer accessible after the callback handler returns -- if the
46 * message is required to persist for longer then it must be copied.
47 * @id: (Response callbacks only) The 'id' that was specified when the
48 * original request message was queued for transmission.
50 typedef void (*ctrl_msg_handler_t)(ctrl_msg_t *, unsigned long);
53 * Send @msg to the domain controller. Execute @hnd when a response is
54 * received, passing the response message and the specified @id. This
55 * operation will not block: it will return -EAGAIN if there is no space.
57 * 1. The @msg is copied if it is transmitted and so can be freed after this
59 * 2. If @hnd is NULL then no callback is executed.
62 ctrl_if_send_message_noblock(
64 ctrl_msg_handler_t hnd,
68 * Send @msg to the domain controller. Execute @hnd when a response is
69 * received, passing the response message and the specified @id. This
70 * operation will block until the message is sent, or a signal is received
71 * for the calling process (unless @wait_state is TASK_UNINTERRUPTIBLE).
73 * 1. The @msg is copied if it is transmitted and so can be freed after this
75 * 2. If @hnd is NULL then no callback is executed.
78 ctrl_if_send_message_block(
80 ctrl_msg_handler_t hnd,
85 * Send @msg to the domain controller. Block until the response is received,
86 * and then copy it into the provided buffer, @rmsg.
89 ctrl_if_send_message_and_get_response(
95 * Request a callback when there is /possibly/ space to immediately send a
96 * message to the domain controller. This function returns 0 if there is
97 * already space to trasnmit a message --- in this case the callback task /may/
98 * still be executed. If this function returns 1 then the callback /will/ be
99 * executed when space becomes available.
102 ctrl_if_enqueue_space_callback(
103 struct tq_struct *task);
106 * Send a response (@msg) to a message from the domain controller. This will
109 * 1. The @msg is copied and so can be freed after this function returns.
110 * 2. The @msg may be the original request message, modified in-place.
113 ctrl_if_send_response(
117 * Register a receiver for typed messages from the domain controller. The
118 * handler (@hnd) is called for every received message of specified @type.
119 * Returns TRUE (non-zero) if the handler was successfully registered.
120 * If CALLBACK_IN_BLOCKING CONTEXT is specified in @flags then callbacks will
121 * occur in a context in which it is safe to yield (i.e., process context).
123 #define CALLBACK_IN_BLOCKING_CONTEXT 1
124 int ctrl_if_register_receiver(
126 ctrl_msg_handler_t hnd,
130 * Unregister a receiver for typed messages from the domain controller. The
131 * handler (@hnd) will not be executed after this function returns.
134 ctrl_if_unregister_receiver(
135 u8 type, ctrl_msg_handler_t hnd);
137 /* Suspend/resume notifications. */
138 void ctrl_if_suspend(void);
139 void ctrl_if_resume(void);
141 /* Start-of-day setup. */
142 void ctrl_if_init(void);
145 * Returns TRUE if there are no outstanding message requests at the domain
146 * controller. This can be used to ensure that messages have really flushed
147 * through when it is not possible to use the response-callback interface.
148 * WARNING: If other subsystems are using the control interface then this
149 * function might never return TRUE!
151 int ctrl_if_transmitter_empty(void); /* !! DANGEROUS FUNCTION !! */
154 * Manually discard response messages from the domain controller.
155 * WARNING: This is usually done automatically -- this function should only
156 * be called when normal interrupt mechanisms are disabled!
158 void ctrl_if_discard_responses(void); /* !! DANGEROUS FUNCTION !! */
160 #endif /* __ASM_XEN__CONTROL_IF_H__ */