2 #include <internal/ntoskrnl.h>
3 #include <internal/ke.h>
4 #include <internal/symbol.h>
5 #include <internal/i386/segment.h>
6 #include <internal/mmhal.h>
9 #include <internal/debug.h>
10 #include <internal/service.h>
12 /* The service dispatcher will take the service number passed in
13 * by the user mode process, logical and it with ServiceNumberMask
14 * and compare the resulting value with ServiceNumberValue. If the
15 * value matches, The passed service number will be and'ed with the
16 * inverse of ServiceNumberMask to obtain the index into the ServiceTable
17 * for the service to call
19 typedef struct _HAL_DISPATCH_TABLE_ENTRY
21 DWORD ServiceNumberMask
;
22 DWORD ServiceNumberValue
;
23 PSERVICE_TABLE ServiceTable
;
25 } HAL_DISPATCH_TABLE_ENTRY
, *PHAL_DISPATCH_TABLE_ENTRY
;
27 static KSPIN_LOCK DispatchTableLock
= {0,};
28 static DWORD DispatchTableCount
= 0;
29 static HAL_DISPATCH_TABLE_ENTRY DispatchTables
[16];
31 NTSTATUS
HalRegisterServiceTable(DWORD Mask
,
39 KeAcquireSpinLock(&DispatchTableLock
, &OldLvl
);
41 Status
= STATUS_SUCCESS
;
43 /* FIXME: should check for invalid/overlapping service tables */
44 DispatchTables
[DispatchTableCount
].ServiceNumberMask
= Mask
;
45 DispatchTables
[DispatchTableCount
].ServiceNumberValue
= Value
;
46 DispatchTables
[DispatchTableCount
].ServiceTable
= Table
;
47 DispatchTables
[DispatchTableCount
].TableCount
= Count
;
50 KeReleaseSpinLock(&DispatchTableLock
, OldLvl
);
56 #define STR(x) _STR(x)
58 void PsBeginThreadWithContextInternal(void);
60 "\n\t.global _PsBeginThreadWithContextInternal\n\t"
61 "_PsBeginThreadWithContextInternal:\n\t"
63 "call _KeLowerIrql\n\t"
86 void interrupt_handler2e(void);
87 __asm__("\n\t.global _interrupt_handler2e\n\t"
88 "_interrupt_handler2e:\n\t"
90 /* Save the users context */
98 /* Set ES to kernel segment */
99 "movw $"STR(KERNEL_DS
)",%bx\n\t"
102 /* Allocate new Kernel stack frame */
105 /* Users's current stack frame pointer is source */
108 /* FIXME: determine system service table to use */
109 /* FIXME: chech to see if SS is valid/inrange */
111 /* Allocate room for argument list from kernel stack */
112 "movl %es:__SystemServiceTable(,%eax,8),%ecx\n\t"
115 /* Copy the arguments from the user stack to the kernel stack */
119 /* DS is now also kernel segment */
122 /* Make the system service call */
123 "movl %ds:__SystemServiceTable+4(,%eax,8),%eax\n\t"
126 /* Deallocate the kernel stack frame */
129 /* Restore the user context */