Added a service table registration function
authorRex Jolliff <rex@lvcablemodem.com>
Mon, 12 Jul 1999 23:32:30 +0000 (23:32 +0000)
committerRex Jolliff <rex@lvcablemodem.com>
Mon, 12 Jul 1999 23:32:30 +0000 (23:32 +0000)
svn path=/trunk/; revision=590

reactos/iface/native/.cvsignore [new file with mode: 0644]
reactos/include/internal/i386/hal.h
reactos/include/internal/service.h
reactos/lib/gdi32/.cvsignore [new file with mode: 0644]
reactos/ntoskrnl/.cvsignore
reactos/ntoskrnl/hal/x86/usercall.c
reactos/ntoskrnl/ntoskrnl.def
reactos/subsys/win32k/.cvsignore

diff --git a/reactos/iface/native/.cvsignore b/reactos/iface/native/.cvsignore
new file mode 100644 (file)
index 0000000..6abf3b2
--- /dev/null
@@ -0,0 +1,2 @@
+genntdll
+genntdll.exe
index 953424d..75684e5 100644 (file)
@@ -5,6 +5,8 @@
 #ifndef __INTERNAL_HAL_HAL_H
 #define __INTERNAL_HAL_HAL_H
 
+#include <internal/service.h>
+
 typedef struct
 {
    unsigned short previous_task;
@@ -71,5 +73,9 @@ VOID Hal_bios32_probe(VOID);
  */
 BOOLEAN Hal_bios32_is_service_present(ULONG service);
 
+NTSTATUS HalRegisterServiceTable(DWORD  Mask, 
+                                 DWORD  Value, 
+                                 PSERVICE_TABLE  Table,
+                                 DWORD  Count);
 
 #endif /* __INTERNAL_HAL_HAL_H */
index 357773e..627ee35 100644 (file)
@@ -1,5 +1,13 @@
-typedef struct
+
+#ifndef __INTERNAL_SERVICE_H
+#define __INTERNAL_SERVICE_H
+
+
+typedef struct _SERVICE_TABLE
 {
-   ULONG ParametersSize;
-   ULONG Function;
+   unsigned long  ParametersSize;
+   unsigned long  Function;
 } SERVICE_TABLE, *PSERVICE_TABLE;
+
+#endif
+
diff --git a/reactos/lib/gdi32/.cvsignore b/reactos/lib/gdi32/.cvsignore
new file mode 100644 (file)
index 0000000..bac9e27
--- /dev/null
@@ -0,0 +1,2 @@
+gdi32.coff
+gdi32.dll
index 2e5d5e2..1cc7399 100644 (file)
@@ -1,3 +1,5 @@
 base.tmp
 junk.tmp
+ntoskrnl.coff
+objects
 temp.exp
index 731c636..d13010e 100644 (file)
@@ -7,13 +7,57 @@
 
 #define NDEBUG
 #include <internal/debug.h>
+#include <internal/service.h>
 
+/* The service dispatcher will take the service number passed in
+ * by the user mode process, logical and it with ServiceNumberMask
+ * and compare the resulting value with ServiceNumberValue.  If the
+ * value matches, The passed service number will be and'ed with the
+ * inverse of ServiceNumberMask to obtain the index into the ServiceTable
+ * for the service to call
+ */
+typedef struct _HAL_DISPATCH_TABLE_ENTRY
+{
+  DWORD  ServiceNumberMask;
+  DWORD  ServiceNumberValue;
+  PSERVICE_TABLE  ServiceTable;
+  DWORD  TableCount;
+} HAL_DISPATCH_TABLE_ENTRY, *PHAL_DISPATCH_TABLE_ENTRY;
+
+static KSPIN_LOCK DispatchTableLock = {0,};
+static DWORD DispatchTableCount = 0;
+static HAL_DISPATCH_TABLE_ENTRY DispatchTables[16];
+
+NTSTATUS HalRegisterServiceTable(DWORD  Mask, 
+                                 DWORD  Value, 
+                                 PSERVICE_TABLE  Table,
+                                 DWORD  Count)
+{
+  NTSTATUS  Status;
+  KIRQL  OldLvl;
+  
+  KeAcquireSpinLock(&DispatchTableLock, &OldLvl);
+
+  Status = STATUS_SUCCESS;
+
+  /* FIXME: should check for invalid/overlapping service tables  */
+  DispatchTables[DispatchTableCount].ServiceNumberMask = Mask;
+  DispatchTables[DispatchTableCount].ServiceNumberValue = Value;
+  DispatchTables[DispatchTableCount].ServiceTable = Table;
+  DispatchTables[DispatchTableCount].TableCount = Count;
+  DispatchTableCount++;
+  
+  KeReleaseSpinLock(&DispatchTableLock, OldLvl);
+
+  return  Status;
+}
 
 #define _STR(x) #x
 #define STR(x) _STR(x)
 
 void PsBeginThreadWithContextInternal(void);
-   __asm__("\n\t.global _PsBeginThreadWithContextInternal\n\t"
+   __asm__(
+     "\n\t.global _PsBeginThreadWithContextInternal\n\t"
      "_PsBeginThreadWithContextInternal:\n\t"
      "pushl $0\n\t"
      "call _KeLowerIrql\n\t"
@@ -41,31 +85,54 @@ void PsBeginThreadWithContextInternal(void);
 
 void interrupt_handler2e(void);
    __asm__("\n\t.global _interrupt_handler2e\n\t"
-     "_interrupt_handler2e:\n\t"
-     "pushl %ds\n\t"
-     "pushl %es\n\t"
-     "pushl %esi\n\t"
-     "pushl %edi\n\t"
-     "pushl %ebp\n\t"
-     "pushl %ebx\n\t"
-     "movw  $"STR(KERNEL_DS)",%bx\n\t"
-     "movw %bx,%es\n\t"
-     "movl %esp,%ebp\n\t"
-     "movl %edx,%esi\n\t"
-     "movl %es:__SystemServiceTable(,%eax,8),%ecx\n\t"
-     "subl %ecx,%esp\n\t"
-     "movl %esp,%edi\n\t"
-     "rep\n\tmovsb\n\t"
-     "movw %bx,%ds\n\t"
-     "movl %ds:__SystemServiceTable+4(,%eax,8),%eax\n\t"
-     "call *%eax\n\t"
-     "movl %ebp,%esp\n\t"
-     "popl %ebx\n\t"
-     "popl %ebp\n\t"
-     "popl %edi\n\t"
-     "popl %esi\n\t"
-     "popl %es\n\t"
-     "popl %ds\n\t"
-     "iret\n\t");
+           "_interrupt_handler2e:\n\t"
+           
+           /*  Save the users context  */
+           "pushl %ds\n\t"
+           "pushl %es\n\t"
+           "pushl %esi\n\t"
+           "pushl %edi\n\t"
+           "pushl %ebp\n\t"
+           "pushl %ebx\n\t"
+           
+           /*  Set ES to kernel segment  */
+           "movw  $"STR(KERNEL_DS)",%bx\n\t"
+           "movw %bx,%es\n\t"
+           
+           /*  Allocate new Kernel stack frame  */
+           "movl %esp,%ebp\n\t"
+           
+           /*  Users's current stack frame pointer is source  */
+           "movl %edx,%esi\n\t"
+
+           /* FIXME: determine system service table to use  */
+           /* FIXME: chech to see if SS is valid/inrange  */
+           
+           /*  Allocate room for argument list from kernel stack  */
+           "movl %es:__SystemServiceTable(,%eax,8),%ecx\n\t"
+           "subl %ecx,%esp\n\t"
+           
+           /*  Copy the arguments from the user stack to the kernel stack  */
+           "movl %esp,%edi\n\t"
+           "rep\n\tmovsb\n\t"
+           
+           /*  DS is now also kernel segment  */
+           "movw %bx,%ds\n\t"
+           
+           /*  Make the system service call  */
+           "movl %ds:__SystemServiceTable+4(,%eax,8),%eax\n\t"
+           "call *%eax\n\t"
+           
+           /*  Deallocate the kernel stack frame  */
+           "movl %ebp,%esp\n\t"
+           
+           /*  Restore the user context  */
+           "popl %ebx\n\t"
+           "popl %ebp\n\t"
+           "popl %edi\n\t"
+           "popl %esi\n\t"
+           "popl %es\n\t"
+           "popl %ds\n\t"
+           "iret\n\t");
 
 
index 54a9751..dc9f167 100644 (file)
@@ -66,6 +66,7 @@ ExSystemTimeToLocalTime
 ExTryToAcquireFastMutex
 ExTryToAcquireResourceExclusiveLite
 HalGetInterruptVector
+HalRegisterServiceTable
 KeBugCheck
 KeBugCheckEx
 KeFlushIoBuffers
index ed76926..f88f0af 100644 (file)
@@ -1,2 +1,5 @@
+base.tmp
+junk.tmp
+temp.exp
 win32k.coff
 win32k.sys