1*4882a593Smuzhiyun /****************************************************************************** 2*4882a593Smuzhiyun * callback.h 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Register guest OS callbacks with Xen. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a copy 7*4882a593Smuzhiyun * of this software and associated documentation files (the "Software"), to 8*4882a593Smuzhiyun * deal in the Software without restriction, including without limitation the 9*4882a593Smuzhiyun * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10*4882a593Smuzhiyun * sell copies of the Software, and to permit persons to whom the Software is 11*4882a593Smuzhiyun * furnished to do so, subject to the following conditions: 12*4882a593Smuzhiyun * 13*4882a593Smuzhiyun * The above copyright notice and this permission notice shall be included in 14*4882a593Smuzhiyun * all copies or substantial portions of the Software. 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19*4882a593Smuzhiyun * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20*4882a593Smuzhiyun * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21*4882a593Smuzhiyun * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22*4882a593Smuzhiyun * DEALINGS IN THE SOFTWARE. 23*4882a593Smuzhiyun * 24*4882a593Smuzhiyun * Copyright (c) 2006, Ian Campbell 25*4882a593Smuzhiyun */ 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun #ifndef __XEN_PUBLIC_CALLBACK_H__ 28*4882a593Smuzhiyun #define __XEN_PUBLIC_CALLBACK_H__ 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun #include <xen/interface/xen.h> 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun /* 33*4882a593Smuzhiyun * Prototype for this hypercall is: 34*4882a593Smuzhiyun * long callback_op(int cmd, void *extra_args) 35*4882a593Smuzhiyun * @cmd == CALLBACKOP_??? (callback operation). 36*4882a593Smuzhiyun * @extra_args == Operation-specific extra arguments (NULL if none). 37*4882a593Smuzhiyun */ 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun /* x86: Callback for event delivery. */ 40*4882a593Smuzhiyun #define CALLBACKTYPE_event 0 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun /* x86: Failsafe callback when guest state cannot be restored by Xen. */ 43*4882a593Smuzhiyun #define CALLBACKTYPE_failsafe 1 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun /* x86/64 hypervisor: Syscall by 64-bit guest app ('64-on-64-on-64'). */ 46*4882a593Smuzhiyun #define CALLBACKTYPE_syscall 2 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun /* 49*4882a593Smuzhiyun * x86/32 hypervisor: Only available on x86/32 when supervisor_mode_kernel 50*4882a593Smuzhiyun * feature is enabled. Do not use this callback type in new code. 51*4882a593Smuzhiyun */ 52*4882a593Smuzhiyun #define CALLBACKTYPE_sysenter_deprecated 3 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun /* x86: Callback for NMI delivery. */ 55*4882a593Smuzhiyun #define CALLBACKTYPE_nmi 4 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun /* 58*4882a593Smuzhiyun * x86: sysenter is only available as follows: 59*4882a593Smuzhiyun * - 32-bit hypervisor: with the supervisor_mode_kernel feature enabled 60*4882a593Smuzhiyun * - 64-bit hypervisor: 32-bit guest applications on Intel CPUs 61*4882a593Smuzhiyun * ('32-on-32-on-64', '32-on-64-on-64') 62*4882a593Smuzhiyun * [nb. also 64-bit guest applications on Intel CPUs 63*4882a593Smuzhiyun * ('64-on-64-on-64'), but syscall is preferred] 64*4882a593Smuzhiyun */ 65*4882a593Smuzhiyun #define CALLBACKTYPE_sysenter 5 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun /* 68*4882a593Smuzhiyun * x86/64 hypervisor: Syscall by 32-bit guest app on AMD CPUs 69*4882a593Smuzhiyun * ('32-on-32-on-64', '32-on-64-on-64') 70*4882a593Smuzhiyun */ 71*4882a593Smuzhiyun #define CALLBACKTYPE_syscall32 7 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun /* 74*4882a593Smuzhiyun * Disable event deliver during callback? This flag is ignored for event and 75*4882a593Smuzhiyun * NMI callbacks: event delivery is unconditionally disabled. 76*4882a593Smuzhiyun */ 77*4882a593Smuzhiyun #define _CALLBACKF_mask_events 0 78*4882a593Smuzhiyun #define CALLBACKF_mask_events (1U << _CALLBACKF_mask_events) 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun /* 81*4882a593Smuzhiyun * Register a callback. 82*4882a593Smuzhiyun */ 83*4882a593Smuzhiyun #define CALLBACKOP_register 0 84*4882a593Smuzhiyun struct callback_register { 85*4882a593Smuzhiyun uint16_t type; 86*4882a593Smuzhiyun uint16_t flags; 87*4882a593Smuzhiyun xen_callback_t address; 88*4882a593Smuzhiyun }; 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun /* 91*4882a593Smuzhiyun * Unregister a callback. 92*4882a593Smuzhiyun * 93*4882a593Smuzhiyun * Not all callbacks can be unregistered. -EINVAL will be returned if 94*4882a593Smuzhiyun * you attempt to unregister such a callback. 95*4882a593Smuzhiyun */ 96*4882a593Smuzhiyun #define CALLBACKOP_unregister 1 97*4882a593Smuzhiyun struct callback_unregister { 98*4882a593Smuzhiyun uint16_t type; 99*4882a593Smuzhiyun uint16_t _unused; 100*4882a593Smuzhiyun }; 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun #endif /* __XEN_PUBLIC_CALLBACK_H__ */ 103