From 367fbb2a1f4a3a2e2f66d0b9a9b869b123f57aaf Mon Sep 17 00:00:00 2001 From: Rex Jolliff Date: Mon, 12 Jul 1999 23:32:30 +0000 Subject: [PATCH] Added a service table registration function svn path=/trunk/; revision=590 --- reactos/iface/native/.cvsignore | 2 + reactos/include/internal/i386/hal.h | 6 ++ reactos/include/internal/service.h | 14 +++- reactos/lib/gdi32/.cvsignore | 2 + reactos/ntoskrnl/.cvsignore | 2 + reactos/ntoskrnl/hal/x86/usercall.c | 121 +++++++++++++++++++++------- reactos/ntoskrnl/ntoskrnl.def | 1 + reactos/subsys/win32k/.cvsignore | 3 + 8 files changed, 121 insertions(+), 30 deletions(-) create mode 100644 reactos/iface/native/.cvsignore create mode 100644 reactos/lib/gdi32/.cvsignore diff --git a/reactos/iface/native/.cvsignore b/reactos/iface/native/.cvsignore new file mode 100644 index 00000000000..6abf3b2bf51 --- /dev/null +++ b/reactos/iface/native/.cvsignore @@ -0,0 +1,2 @@ +genntdll +genntdll.exe diff --git a/reactos/include/internal/i386/hal.h b/reactos/include/internal/i386/hal.h index 953424d63a7..75684e5a239 100644 --- a/reactos/include/internal/i386/hal.h +++ b/reactos/include/internal/i386/hal.h @@ -5,6 +5,8 @@ #ifndef __INTERNAL_HAL_HAL_H #define __INTERNAL_HAL_HAL_H +#include + 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 */ diff --git a/reactos/include/internal/service.h b/reactos/include/internal/service.h index 357773ee845..627ee35209d 100644 --- a/reactos/include/internal/service.h +++ b/reactos/include/internal/service.h @@ -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 index 00000000000..bac9e278f09 --- /dev/null +++ b/reactos/lib/gdi32/.cvsignore @@ -0,0 +1,2 @@ +gdi32.coff +gdi32.dll diff --git a/reactos/ntoskrnl/.cvsignore b/reactos/ntoskrnl/.cvsignore index 2e5d5e24473..1cc73994741 100644 --- a/reactos/ntoskrnl/.cvsignore +++ b/reactos/ntoskrnl/.cvsignore @@ -1,3 +1,5 @@ base.tmp junk.tmp +ntoskrnl.coff +objects temp.exp diff --git a/reactos/ntoskrnl/hal/x86/usercall.c b/reactos/ntoskrnl/hal/x86/usercall.c index 731c636d3c0..d13010e7979 100644 --- a/reactos/ntoskrnl/hal/x86/usercall.c +++ b/reactos/ntoskrnl/hal/x86/usercall.c @@ -7,13 +7,57 @@ #define NDEBUG #include +#include +/* 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"); diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index 54a9751dc10..dc9f1673e32 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -66,6 +66,7 @@ ExSystemTimeToLocalTime ExTryToAcquireFastMutex ExTryToAcquireResourceExclusiveLite HalGetInterruptVector +HalRegisterServiceTable KeBugCheck KeBugCheckEx KeFlushIoBuffers diff --git a/reactos/subsys/win32k/.cvsignore b/reactos/subsys/win32k/.cvsignore index ed769264e3e..f88f0aff3a0 100644 --- a/reactos/subsys/win32k/.cvsignore +++ b/reactos/subsys/win32k/.cvsignore @@ -1,2 +1,5 @@ +base.tmp +junk.tmp +temp.exp win32k.coff win32k.sys