- Add support for Xen 2.0
- Rearrange some code
Modified: branches/xen/reactos/boot/freeldr/freeldr/Makefile
Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c
Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h
Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xencons.c
Added: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xenctrlif.c
Added: branches/xen/reactos/include/xen2/
Added: branches/xen/reactos/include/xen2/private/
Added: branches/xen/reactos/include/xen2/private/ctrl_if.h
Added: branches/xen/reactos/include/xen2/private/evtchn.h
Added: branches/xen/reactos/include/xen2/private/hypervisor.h
Added: branches/xen/reactos/include/xen2/public/
Added: branches/xen/reactos/include/xen2/public/COPYING
Added: branches/xen/reactos/include/xen2/public/arch-x86_32.h
Added: branches/xen/reactos/include/xen2/public/arch-x86_64.h
Added: branches/xen/reactos/include/xen2/public/dom0_ops.h
Added: branches/xen/reactos/include/xen2/public/event_channel.h
Added: branches/xen/reactos/include/xen2/public/grant_table.h
Added: branches/xen/reactos/include/xen2/public/io/
Added: branches/xen/reactos/include/xen2/public/io/blkif.h
Added: branches/xen/reactos/include/xen2/public/io/domain_controller.h
Added: branches/xen/reactos/include/xen2/public/io/netif.h
Added: branches/xen/reactos/include/xen2/public/physdev.h
Added: branches/xen/reactos/include/xen2/public/sched_ctl.h
Added: branches/xen/reactos/include/xen2/public/trace.h
Added: branches/xen/reactos/include/xen2/public/xen.h
Added: branches/xen/reactos/include/xen2/rosxen.h

Modified: branches/xen/reactos/boot/freeldr/freeldr/Makefile
--- branches/xen/reactos/boot/freeldr/freeldr/Makefile	2005-04-01 21:44:22 UTC (rev 14426)
+++ branches/xen/reactos/boot/freeldr/freeldr/Makefile	2005-04-01 22:39:20 UTC (rev 14427)
@@ -21,6 +21,8 @@
 
 include ../rules.mak
 
+include $(PATH_TO_TOP)/config
+
 CC = gcc
 LD = ld
 
@@ -99,17 +101,27 @@
 
 COMPILER_DEFINES = -D__$(TARGET)__ $(COMPILER_DEBUG_DEFINES)
 
+ifeq ($(XEN),2)
+XEN_CFLAGS = -I$(PATH_TO_TOP)/include/xen2 \
+             -I$(PATH_TO_TOP)/include/xen2/public \
+             -I$(PATH_TO_TOP)/include/xen2/private \
+             -DXEN_VER=2
+else
+XEN_CFLAGS = -I$(PATH_TO_TOP)/include/xen3 \
+             -I$(PATH_TO_TOP)/include/xen3/public \
+             -I$(PATH_TO_TOP)/include/xen3/private \
+             -DXEN_VER=3
+endif
+
 COMPILER_INCLUDES = -I$(SRCDIR)/include \
                     -I$(PATH_TO_TOP)/w32api/include \
                     -I$(PATH_TO_TOP)/include \
-                    -I$(PATH_TO_TOP)/ntoskrnl/include \
-                    -I$(PATH_TO_TOP)/include/xen3 \
-                    -I$(PATH_TO_TOP)/include/xen3/public \
-                    -I$(PATH_TO_TOP)/include/xen3/private
+                    -I$(PATH_TO_TOP)/ntoskrnl/include
 
 CFLAGS = $(COMPILER_OPTIONS) \
          $(COMPILER_DEFINES) \
-         $(COMPILER_INCLUDES)
+         $(COMPILER_INCLUDES) \
+         $(XEN_CFLAGS)
 
 LINKER_OPTIONS = -N -Ttext=0x8000
 
@@ -160,6 +172,7 @@
   xboxrtc.o	\
   xboxvideo.o	\
   xencons.o \
+  xenctrlif.o \
   xenmem.o \
   _alloca.o # For Mingw32 builds
 

Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c
--- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c	2005-04-01 21:44:22 UTC (rev 14426)
+++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c	2005-04-01 22:39:20 UTC (rev 14427)
@@ -1,5 +1,4 @@
-/* $Id: machpc.c 12672 2005-01-01 00:42:18Z chorns $
- *
+/*
  *  FreeLoader
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -28,8 +27,6 @@
 #include <hypervisor.h>
 
 BOOL XenActive = FALSE;
-ctrl_front_ring_t XenCtrlIfTxRing;
-ctrl_back_ring_t XenCtrlIfRxRing;
 int XenCtrlIfEvtchn;
 
 VOID
@@ -65,12 +62,10 @@
 /* _start is the default name ld will use as the entry point.  When xen
  * loads the domain, it will start execution at the elf entry point.  */
 
-void *dummy;
 void _start()
 {
   extern void *start;               /* Where is freeldr loaded? */
   start_info_t *StartInfo;
-  control_if_t *CtrlIf;
   void *OldStackPtr, *NewStackPtr;
   void *OldStackPage, *NewStackPage;
 
@@ -87,16 +82,8 @@
    */
   XenMemInit(StartInfo);
 
-  /*
-   * Setup control interface
-   */
-  XenCtrlIfEvtchn = XenStartInfo->domain_controller_evtchn;
-  CtrlIf = ((control_if_t *)((char *)XenSharedInfo + 2048));
+  XenCtrlIfInit();
 
-  /* Sync up with shared indexes. */
-  FRONT_RING_ATTACH(&XenCtrlIfTxRing, &CtrlIf->tx_ring);
-  BACK_RING_ATTACH(&XenCtrlIfRxRing, &CtrlIf->rx_ring);
-
   /* Now move the stack to low mem */
   /* Copy the stack page */
   __asm__ __volatile__("mov %%esp,%%eax\n" : "=a" (OldStackPtr));
@@ -110,6 +97,7 @@
 
   /* Start freeldr */
   XenActive = TRUE;
+  BootDrive = 0x80;
   BootMain(XenStartInfo->cmd_line);
 
   /* Shouldn't get here */
@@ -258,8 +246,15 @@
     XEN_UNIMPLEMENTED("XenHwDetect");
   }
 
-/* emit the elf segment Xen builder expects in kernel image */ asm(".section __xen_guest;"
-    ".ascii \"GUEST_OS=linux,GUEST_VER=2.6,XEN_VER=3.0,VIRT_BASE=0x00008000\";"
+/* emit the elf segment Xen builder expects in kernel image */
+asm(".section __xen_guest;"
+    ".ascii \"GUEST_OS=linux,GUEST_VER=2.6\";"
+#if XEN_VER == 2
+    ".ascii \",XEN_VER=2.0\";"
+#else
+    ".ascii \",XEN_VER=3.0\";"
+#endif
+    ".ascii \",VIRT_BASE=0x00008000\";"
     ".ascii \",LOADER=generic\";"
     ".ascii \",PT_MODE_WRITABLE\";"
     ".byte  0;"

Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h
--- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h	2005-04-01 21:44:22 UTC (rev 14426)
+++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h	2005-04-01 22:39:20 UTC (rev 14427)
@@ -27,18 +27,21 @@
 
 #include <rosxen.h>
 #include <xen.h>
+#include <ctrl_if.h>
 #include <io/domain_controller.h>
 
 extern BOOL XenActive;
-extern ctrl_front_ring_t XenCtrlIfTxRing;
-extern ctrl_back_ring_t XenCtrlIfRxRing;
-extern int XenCtrlIfEvtchn;
 extern start_info_t *XenStartInfo;
 extern shared_info_t *XenSharedInfo;
 
 VOID XenMachInit(VOID);
 VOID XenMemInit(start_info_t *StartInfo);
 
+VOID XenCtrlIfInit();
+BOOL XenCtrlIfSendMessageNoblock(ctrl_msg_t *Msg);
+VOID XenCtrlIfDiscardResponses();
+BOOL XenCtrlIfTransmitterEmpty();
+
 VOID XenConsPutChar(int Ch);
 BOOL XenConsKbHit();
 int XenConsGetCh();
@@ -68,6 +71,6 @@
 
 VOID XenHwDetect(VOID);
 
-#endif /* __I386_MACHPC_H_ */
+#endif /* __I386_MACHXEN_H_ */
 
 /* EOF */

Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xencons.c
--- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xencons.c	2005-04-01 21:44:22 UTC (rev 14426)
+++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xencons.c	2005-04-01 22:39:20 UTC (rev 14427)
@@ -1,5 +1,4 @@
-/* $Id: machpc.c 12672 2005-01-01 00:42:18Z chorns $
- *
+/*
  *  FreeLoader
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -34,37 +33,32 @@
         (_r)->rsp_cons = (_r)->sring->rsp_prod;                         \
     } while (0)
 
-#define OUTPUT_BUFFER_SIZE 128
+#define OUTPUT_BUFFER_SIZE sizeof(((ctrl_msg_t *) NULL)->msg)
 static char OutputBuffer[OUTPUT_BUFFER_SIZE];
 static unsigned OutputPtr = 0;
 
 static void
 FlushOutput()
 {
-  ctrl_msg_t *msg;
+  ctrl_msg_t Msg;
 
-  while (0 != OutputPtr)
+  while (0 != OutputPtr || ! XenCtrlIfTransmitterEmpty())
     {
-      RING_DROP_PENDING_RESPONSES(&XenCtrlIfTxRing);
+      XenCtrlIfDiscardResponses();
 
-      if (! RING_FULL(&XenCtrlIfTxRing))
+      if (0 == OutputPtr)
         {
-          /*
-           * Put message on the control interface ring and trigger virtual
-           * console writer.
-           */
-          msg = RING_GET_REQUEST(&XenCtrlIfTxRing,
-                                  XenCtrlIfTxRing.req_prod_pvt);
+          continue;
+        }
 
-          msg->type = CMSG_CONSOLE;
-          msg->subtype = CMSG_CONSOLE_DATA;
-          msg->length = OutputPtr;
-          memcpy(msg->msg, OutputBuffer, OutputPtr);
-          msg->id      = 0xff;
-          XenCtrlIfTxRing.req_prod_pvt++;
-          RING_PUSH_REQUESTS(&XenCtrlIfTxRing);
-          notify_via_evtchn(XenCtrlIfEvtchn);
+      Msg.type = CMSG_CONSOLE;
+      Msg.subtype = CMSG_CONSOLE_DATA;
+      Msg.length = OutputPtr;
+      memcpy(Msg.msg, OutputBuffer, OutputPtr);
+      Msg.id      = 0xff;
 
+      if (XenCtrlIfSendMessageNoblock(&Msg))
+        {
           OutputPtr = 0;
         }
     }

Added: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xenctrlif.c
--- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xenctrlif.c	2005-04-01 21:44:22 UTC (rev 14426)
+++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xenctrlif.c	2005-04-01 22:39:20 UTC (rev 14427)
@@ -0,0 +1,127 @@
+/*
+ *  FreeLoader
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "freeldr.h"
+#include "machxen.h"
+
+#include <rosxen.h>
+#include <xen.h>
+#include <ctrl_if.h>
+#include <evtchn.h>
+
+#if XEN_VER == 2
+#define TX_FULL(_c)   \
+    (((_c)->tx_req_prod - XenCtrlIfTxRespCons) == CONTROL_RING_SIZE)
+static control_if_t *XenCtrlIf;
+static CONTROL_RING_IDX XenCtrlIfTxRespCons;
+static CONTROL_RING_IDX XenCtrlIfRxReqCons;
+#else /* XEN_VER */
+/*
+ * Extra ring macros to sync a consumer index up to the public producer index.
+ * Generally UNSAFE, but we use it for recovery and shutdown in some cases.
+ */
+#define RING_DROP_PENDING_RESPONSES(_r)                                 \
+    do {                                                                \
+        (_r)->rsp_cons = (_r)->sring->rsp_prod;                         \
+    } while (0)
+
+static ctrl_front_ring_t XenCtrlIfTxRing;
+static ctrl_back_ring_t XenCtrlIfRxRing;
+#endif /* XEN_VER */
+static int XenCtrlIfEvtchn;
+
+void
+XenCtrlIfInit()
+{
+#if XEN_VER != 2
+  control_if_t *CtrlIf;
+#endif /* XEN_VER */
+
+  /*
+   * Setup control interface
+   */
+  XenCtrlIfEvtchn = XenStartInfo->domain_controller_evtchn;
+
+#if XEN_VER == 2
+  XenCtrlIf = ((control_if_t *)((char *)XenSharedInfo + 2048));
+
+  /* Sync up with shared indexes. */
+  XenCtrlIfTxRespCons = XenCtrlIf->tx_resp_prod;
+  XenCtrlIfRxReqCons  = XenCtrlIf->rx_resp_prod;
+#else /* XEN_VER */
+  CtrlIf = ((control_if_t *)((char *)XenSharedInfo + 2048));
+
+  /* Sync up with shared indexes. */
+  FRONT_RING_ATTACH(&XenCtrlIfTxRing, &CtrlIf->tx_ring);
+  BACK_RING_ATTACH(&XenCtrlIfRxRing, &CtrlIf->rx_ring);
+#endif /* XEN_VER */
+}
+
+BOOL
+XenCtrlIfSendMessageNoblock(ctrl_msg_t *Msg)
+{
+  ctrl_msg_t *Dest;
+
+#if XEN_VER == 2
+  if (TX_FULL(XenCtrlIf))
+#else /* XEN_VER */
+  if (RING_FULL(&XenCtrlIfTxRing))
+#endif /* XEN_VER */
+    {
+      return FALSE;
+    }
+
+#if XEN_VER == 2
+  Dest = XenCtrlIf->tx_ring + MASK_CONTROL_IDX(XenCtrlIf->tx_req_prod);
+#else /* XEN_VER */
+  Dest = RING_GET_REQUEST(&XenCtrlIfTxRing,
+                          XenCtrlIfTxRing.req_prod_pvt);
+#endif /* XEN_VER */
+  memcpy(Dest, Msg, sizeof(ctrl_msg_t));
+#if XEN_VER == 2
+  XenCtrlIf->tx_req_prod++;
+#else /* XEN_VER */
+  XenCtrlIfTxRing.req_prod_pvt++;
+  RING_PUSH_REQUESTS(&XenCtrlIfTxRing);
+#endif /* XEN_VER */
+  notify_via_evtchn(XenCtrlIfEvtchn);
+
+  return TRUE;
+}
+
+VOID
+XenCtrlIfDiscardResponses()
+{
+#if XEN_VER == 2
+  XenCtrlIfTxRespCons = XenCtrlIf->tx_resp_prod;
+#else /* XEN_VER */
+  RING_DROP_PENDING_RESPONSES(&XenCtrlIfTxRing);
+#endif /* XEN_VER */
+}
+
+BOOL
+XenCtrlIfTransmitterEmpty()
+{
+#if XEN_VER == 2
+  return (XenCtrlIf->tx_req_prod == XenCtrlIfTxRespCons);
+#else /* XEN_VER */
+  return XenCtrlIfTxRing.sring->req_prod == XenCtrlIfTxRing.rsp_cons;
+#endif /* XEN_VER */
+}
+
+/* EOF */
Property changes on: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xenctrlif.c
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: branches/xen/reactos/include/xen2/private/ctrl_if.h
--- branches/xen/reactos/include/xen2/private/ctrl_if.h	2005-04-01 21:44:22 UTC (rev 14426)
+++ branches/xen/reactos/include/xen2/private/ctrl_if.h	2005-04-01 22:39:20 UTC (rev 14427)
@@ -0,0 +1,161 @@
+/******************************************************************************
+ * ctrl_if.h
+ * 
+ * Management functions for special interface to the domain controller.
+ * 
+ * Copyright (c) 2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef __ASM_XEN__CTRL_IF_H__
+#define __ASM_XEN__CTRL_IF_H__
+
+#include <hypervisor.h>
+
+typedef control_msg_t ctrl_msg_t;
+
+/*
+ * Callback function type. Called for asynchronous processing of received
+ * request messages, and responses to previously-transmitted request messages.
+ * The parameters are (@msg, @id).
+ *  @msg: Original request/response message (not a copy). The message can be
+ *        modified in-place by the handler (e.g., a response callback can
+ *        turn a request message into a response message in place). The message
+ *        is no longer accessible after the callback handler returns -- if the
+ *        message is required to persist for longer then it must be copied.
+ *  @id:  (Response callbacks only) The 'id' that was specified when the
+ *        original request message was queued for transmission.
+ */
+typedef void (*ctrl_msg_handler_t)(ctrl_msg_t *, unsigned long);
+
+/*
+ * Send @msg to the domain controller. Execute @hnd when a response is
+ * received, passing the response message and the specified @id. This
+ * operation will not block: it will return -EAGAIN if there is no space.
+ * Notes:
+ *  1. The @msg is copied if it is transmitted and so can be freed after this
+ *     function returns.
+ *  2. If @hnd is NULL then no callback is executed.
+ */
+int
+ctrl_if_send_message_noblock(
+    ctrl_msg_t *msg, 
+    ctrl_msg_handler_t hnd,
+    unsigned long id);
+
+/*
+ * Send @msg to the domain controller. Execute @hnd when a response is
+ * received, passing the response message and the specified @id. This
+ * operation will block until the message is sent, or a signal is received
+ * for the calling process (unless @wait_state is TASK_UNINTERRUPTIBLE).
+ * Notes:
+ *  1. The @msg is copied if it is transmitted and so can be freed after this
+ *     function returns.
+ *  2. If @hnd is NULL then no callback is executed.
+ */
+int
+ctrl_if_send_message_block(
+    ctrl_msg_t *msg, 
+    ctrl_msg_handler_t hnd, 
+    unsigned long id, 
+    long wait_state);
+
+/*
+ * Send @msg to the domain controller. Block until the response is received,
+ * and then copy it into the provided buffer, @rmsg.
+ */
+int
+ctrl_if_send_message_and_get_response(
+    ctrl_msg_t *msg,
+    ctrl_msg_t *rmsg,
+    long wait_state);
+
+/*
+ * Request a callback when there is /possibly/ space to immediately send a
+ * message to the domain controller. This function returns 0 if there is
+ * already space to trasnmit a message --- in this case the callback task /may/
+ * still be executed. If this function returns 1 then the callback /will/ be
+ * executed when space becomes available.
+ */
+#ifdef TODO
+int
+ctrl_if_enqueue_space_callback(
+    struct tq_struct *task);
+#endif
+
+/*
+ * Send a response (@msg) to a message from the domain controller. This will 
+ * never block.
+ * Notes:
+ *  1. The @msg is copied and so can be freed after this function returns.
+ *  2. The @msg may be the original request message, modified in-place.
+ */
+void
+ctrl_if_send_response(
+    ctrl_msg_t *msg);
+
+/*
+ * Register a receiver for typed messages from the domain controller. The 
+ * handler (@hnd) is called for every received message of specified @type.
+ * Returns TRUE (non-zero) if the handler was successfully registered.
+ * If CALLBACK_IN_BLOCKING CONTEXT is specified in @flags then callbacks will
+ * occur in a context in which it is safe to yield (i.e., process context).
+ */
+#define CALLBACK_IN_BLOCKING_CONTEXT 1
+int ctrl_if_register_receiver(
+    u8 type, 
+    ctrl_msg_handler_t hnd,
+    unsigned int flags);
+
+/*
+ * Unregister a receiver for typed messages from the domain controller. The 
+ * handler (@hnd) will not be executed after this function returns.
+ */
+void
+ctrl_if_unregister_receiver(
+    u8 type, ctrl_msg_handler_t hnd);
+
+/* Suspend/resume notifications. */
+void ctrl_if_suspend(void);
+void ctrl_if_resume(void);
+
+/* Start-of-day setup. */
+void ctrl_if_init(void);
+
+/*
+ * Returns TRUE if there are no outstanding message requests at the domain
+ * controller. This can be used to ensure that messages have really flushed
+ * through when it is not possible to use the response-callback interface.
+ * WARNING: If other subsystems are using the control interface then this
+ * function might never return TRUE!
+ */
+int ctrl_if_transmitter_empty(void);  /* !! DANGEROUS FUNCTION !! */
+
+/*
+ * Manually discard response messages from the domain controller. 
+ * WARNING: This is usually done automatically -- this function should only
+ * be called when normal interrupt mechanisms are disabled!
+ */
+void ctrl_if_discard_responses(void); /* !! DANGEROUS FUNCTION !! */
+
+#endif /* __ASM_XEN__CONTROL_IF_H__ */
Property changes on: branches/xen/reactos/include/xen2/private/ctrl_if.h
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: branches/xen/reactos/include/xen2/private/evtchn.h
--- branches/xen/reactos/include/xen2/private/evtchn.h	2005-04-01 21:44:22 UTC (rev 14426)
+++ branches/xen/reactos/include/xen2/private/evtchn.h	2005-04-01 22:39:20 UTC (rev 14427)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * evtchn.h
+ * 
+ * Communication via Xen event channels.
+ * Also definitions for the device that demuxes notifications to userspace.
+ * 
+ * Copyright (c) 2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef __ASM_EVTCHN_H__
+#define __ASM_EVTCHN_H__
+
+#include <hypervisor.h>
+#include <event_channel.h>
+
+/*
+ * LOW-LEVEL DEFINITIONS
+ */
+
+static inline void notify_via_evtchn(int port)
+{
+    evtchn_op_t op;
+    op.cmd = EVTCHNOP_send;
+    op.u.send.local_port = port;
+    (void)HYPERVISOR_event_channel_op(&op);
+}
+
+/*
+ * CHARACTER-DEVICE DEFINITIONS
+ */
+
+/* /dev/xen/evtchn resides at device number major=10, minor=201 */
+#define EVTCHN_MINOR 201
+
+/* /dev/xen/evtchn ioctls: */
+/* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
+#define EVTCHN_RESET  _IO('E', 1)
+/* EVTCHN_BIND: Bind to teh specified event-channel port. */
+#define EVTCHN_BIND   _IO('E', 2)
+/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
+#define EVTCHN_UNBIND _IO('E', 3)
+
+#endif /* __ASM_EVTCHN_H__ */
Property changes on: branches/xen/reactos/include/xen2/private/evtchn.h
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: branches/xen/reactos/include/xen2/private/hypervisor.h
--- branches/xen/reactos/include/xen2/private/hypervisor.h	2005-04-01 21:44:22 UTC (rev 14426)
+++ branches/xen/reactos/include/xen2/private/hypervisor.h	2005-04-01 22:39:20 UTC (rev 14427)
@@ -0,0 +1,492 @@
+/******************************************************************************
+ * hypervisor.h
+ * 
+ * Linux-specific hypervisor handling.
+ * 
+ * Copyright (c) 2002-2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef __HYPERVISOR_H__
+#define __HYPERVISOR_H__
+
+#include <xen.h>
+#include <dom0_ops.h>
+#include <io/domain_controller.h>
+
+/*
+ * Assembler stubs for hyper-calls.
+ */
+
+static inline int
+HYPERVISOR_set_trap_table(
+    trap_info_t *table)
+{
+    int ret;
+    unsigned long ignore;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ignore)
+	: "0" (__HYPERVISOR_set_trap_table), "1" (table)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_mmu_update(
+    mmu_update_t *req, int count, int *success_count)
+{
+    int ret;
+    unsigned long ign1, ign2, ign3;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
+	: "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
+	  "3" (success_count)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_set_gdt(
+    unsigned long *frame_list, int entries)
+{
+    int ret;
+    unsigned long ign1, ign2;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2)
+	: "0" (__HYPERVISOR_set_gdt), "1" (frame_list), "2" (entries)
+	: "memory" );
+
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_stack_switch(
+    unsigned long ss, unsigned long esp)
+{
+    int ret;
+    unsigned long ign1, ign2;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2)
+	: "0" (__HYPERVISOR_stack_switch), "1" (ss), "2" (esp)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_set_callbacks(
+    unsigned long event_selector, unsigned long event_address,
+    unsigned long failsafe_selector, unsigned long failsafe_address)
+{
+    int ret;
+    unsigned long ign1, ign2, ign3, ign4;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
+	: "0" (__HYPERVISOR_set_callbacks), "1" (event_selector),
+	  "2" (event_address), "3" (failsafe_selector), "4" (failsafe_address)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_fpu_taskswitch(
+    int set)
+{
+    int ret;
+    unsigned long ign;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign)
+        : "0" (__HYPERVISOR_fpu_taskswitch), "1" (set)
+        : "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_yield(
+    void)
+{
+    int ret;
+    unsigned long ign;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign)
+	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_yield)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_block(
+    void)
+{
+    int ret;
+    unsigned long ign1;
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1)
+	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_block)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_shutdown(
+    void)
+{
+    int ret;
+    unsigned long ign1;
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1)
+	: "0" (__HYPERVISOR_sched_op),
+	  "1" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
+        : "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_reboot(
+    void)
+{
+    int ret;
+    unsigned long ign1;
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1)
+	: "0" (__HYPERVISOR_sched_op),
+	  "1" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
+        : "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_suspend(
+    unsigned long srec)
+{
+    int ret;
+    unsigned long ign1, ign2;
+
+    /* NB. On suspend, control software expects a suspend record in %esi. */
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=S" (ign2)
+	: "0" (__HYPERVISOR_sched_op),
+        "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
+        "S" (srec) : "memory");
+
+    return ret;
+}
+
+static inline long
+HYPERVISOR_set_timer_op(
+    u64 timeout)
+{
+    int ret;
+    unsigned long timeout_hi = (unsigned long)(timeout>>32);
+    unsigned long timeout_lo = (unsigned long)timeout;
+    unsigned long ign1, ign2;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2)
+	: "0" (__HYPERVISOR_set_timer_op), "b" (timeout_hi), "c" (timeout_lo)
+	: "memory");
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_dom0_op(
+    dom0_op_t *dom0_op)
+{
+    int ret;
+    unsigned long ign1;
+
+    dom0_op->interface_version = DOM0_INTERFACE_VERSION;
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1)
+	: "0" (__HYPERVISOR_dom0_op), "1" (dom0_op)
+	: "memory");
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_set_debugreg(
+    int reg, unsigned long value)
+{
+    int ret;
+    unsigned long ign1, ign2;
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2)
+	: "0" (__HYPERVISOR_set_debugreg), "1" (reg), "2" (value)
+	: "memory" );
+
+    return ret;
+}
+
+static inline unsigned long
+HYPERVISOR_get_debugreg(
+    int reg)
+{
+    unsigned long ret;
+    unsigned long ign;
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign)
+	: "0" (__HYPERVISOR_get_debugreg), "1" (reg)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_update_descriptor(
+    unsigned long ma, unsigned long word1, unsigned long word2)
+{
+    int ret;
+    unsigned long ign1, ign2, ign3;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
+	: "0" (__HYPERVISOR_update_descriptor), "1" (ma), "2" (word1),
+	  "3" (word2)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_set_fast_trap(
+    int idx)
+{
+    int ret;
+    unsigned long ign;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign)
+	: "0" (__HYPERVISOR_set_fast_trap), "1" (idx)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_dom_mem_op(
+    unsigned int op, unsigned long *extent_list,
+    unsigned long nr_extents, unsigned int extent_order)
+{
+    int ret;
+    unsigned long ign1, ign2, ign3, ign4, ign5;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4),
+	  "=D" (ign5)
+	: "0" (__HYPERVISOR_dom_mem_op), "1" (op), "2" (extent_list),
+	  "3" (nr_extents), "4" (extent_order), "5" (DOMID_SELF)
+        : "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_multicall(
+    void *call_list, int nr_calls)
+{
+    int ret;
+    unsigned long ign1, ign2;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2)
+	: "0" (__HYPERVISOR_multicall), "1" (call_list), "2" (nr_calls)
+	: "memory" );
+
+    return ret;
+}
+
+static inline int
+HYPERVISOR_update_va_mapping(
+    unsigned long va, pte_t new_val, unsigned long flags)
+{
+    int ret;
+    unsigned long ign1, ign2, ign3;
+
+    __asm__ __volatile__ (
+        TRAP_INSTR
+        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
+	: "0" (__HYPERVISOR_update_va_mapping), 
+          "1" (va), "2" ((new_val).pte_low), "3" (flags)
+	: "memory" );
+
+#ifdef TODO
+    if ( unlikely(ret < 0) )
+    {
+        printk(KERN_ALERT "Failed update VA mapping: %08lx, %08lx, %08lx\n",
+               va, (new_val).pte_low, flags);
+        BUG();
+    }
+#endif
+
+    return ret;
+}
[truncated at 1000 lines; 2890 more skipped]