Added a service table registration function

svn path=/trunk/; revision=590
This commit is contained in:
Rex Jolliff 1999-07-12 23:32:30 +00:00
parent 932d4770ec
commit 367fbb2a1f
8 changed files with 121 additions and 30 deletions

View file

@ -0,0 +1,2 @@
genntdll
genntdll.exe

View 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 */

View 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

View file

@ -0,0 +1,2 @@
gdi32.coff
gdi32.dll

View file

@ -1,3 +1,5 @@
base.tmp
junk.tmp
ntoskrnl.coff
objects
temp.exp

View 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");

View file

@ -66,6 +66,7 @@ ExSystemTimeToLocalTime
ExTryToAcquireFastMutex
ExTryToAcquireResourceExclusiveLite
HalGetInterruptVector
HalRegisterServiceTable
KeBugCheck
KeBugCheckEx
KeFlushIoBuffers

View file

@ -1,2 +1,5 @@
base.tmp
junk.tmp
temp.exp
win32k.coff
win32k.sys