mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
Catch stack over/underflows
svn path=/trunk/; revision=1743
This commit is contained in:
parent
bde0898ab5
commit
d9925196f3
7 changed files with 269 additions and 126 deletions
|
@ -41,6 +41,7 @@
|
|||
#define RESERVED_SELECTOR (0x40)
|
||||
/* Local Descriptor Table */
|
||||
#define LDT_SELECTOR (0x48)
|
||||
#define TRAP_TSS_SELECTOR (0x50)
|
||||
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_SEGMENT_H */
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ extern VOID KiTrapUnknown(VOID);
|
|||
extern ULONG init_stack;
|
||||
extern ULONG init_stack_top;
|
||||
|
||||
static char KiNullLdt[8] = {0,};
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
extern unsigned int _text_start__, _text_end__;
|
||||
|
@ -157,6 +159,145 @@ KiUserTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr, PVOID Cr2)
|
|||
return(0);
|
||||
}
|
||||
|
||||
ULONG
|
||||
KiDoubleFaultHandler(VOID)
|
||||
{
|
||||
unsigned int cr2;
|
||||
unsigned int i;
|
||||
PULONG stack;
|
||||
ULONG StackLimit;
|
||||
ULONG Esp0;
|
||||
ULONG ExceptionNr = 8;
|
||||
extern KTSS KiTss;
|
||||
static char *TypeStrings[] =
|
||||
{
|
||||
"Divide Error",
|
||||
"Debug Trap",
|
||||
"NMI",
|
||||
"Breakpoint",
|
||||
"Overflow",
|
||||
"BOUND range exceeded",
|
||||
"Invalid Opcode",
|
||||
"No Math Coprocessor",
|
||||
"Double Fault",
|
||||
"Unknown(9)",
|
||||
"Invalid TSS",
|
||||
"Segment Not Present",
|
||||
"Stack Segment Fault",
|
||||
"General Protection",
|
||||
"Page Fault",
|
||||
"Math Fault",
|
||||
"Alignment Check",
|
||||
"Machine Check"
|
||||
};
|
||||
|
||||
/* Use the address of the trap frame as approximation to the ring0 esp */
|
||||
Esp0 = KiTss.Esp0;
|
||||
|
||||
/* Get CR2 */
|
||||
__asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
|
||||
|
||||
/*
|
||||
* Check for stack underflow
|
||||
*/
|
||||
if (PsGetCurrentThread() != NULL &&
|
||||
Esp0 < (ULONG)PsGetCurrentThread()->Tcb.StackLimit)
|
||||
{
|
||||
DbgPrint("Stack underflow (tf->esp %x Limit %x)\n",
|
||||
Esp0, (ULONG)PsGetCurrentThread()->Tcb.StackLimit);
|
||||
ExceptionNr = 12;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out the CPU registers
|
||||
*/
|
||||
if (ExceptionNr < 19)
|
||||
{
|
||||
DbgPrint("%s Exception: %d(%x)\n",TypeStrings[ExceptionNr],
|
||||
ExceptionNr, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint("Exception: %d(%x)\n", ExceptionNr, 0);
|
||||
}
|
||||
DbgPrint("CS:EIP %x:%x ", KiTss.Cs, KiTss.Eip);
|
||||
print_address((PVOID)KiTss.Eip);
|
||||
DbgPrint("\n");
|
||||
DbgPrint("cr2 %x cr3 %x ", cr2, KiTss.Cr3);
|
||||
DbgPrint("Proc: %x ",PsGetCurrentProcess());
|
||||
if (PsGetCurrentProcess() != NULL)
|
||||
{
|
||||
DbgPrint("Pid: %x <", PsGetCurrentProcess()->UniqueProcessId);
|
||||
DbgPrint("%.8s> ", PsGetCurrentProcess()->ImageFileName);
|
||||
}
|
||||
if (PsGetCurrentThread() != NULL)
|
||||
{
|
||||
DbgPrint("Thrd: %x Tid: %x",
|
||||
PsGetCurrentThread(),
|
||||
PsGetCurrentThread()->Cid.UniqueThread);
|
||||
}
|
||||
DbgPrint("\n");
|
||||
DbgPrint("DS %x ES %x FS %x GS %x\n", KiTss.Ds, KiTss.Es,
|
||||
KiTss.Fs, KiTss.Gs);
|
||||
DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n", KiTss.Eax, KiTss.Ebx,
|
||||
KiTss.Ecx);
|
||||
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x\n", KiTss.Edx, KiTss.Ebp,
|
||||
KiTss.Esi);
|
||||
DbgPrint("EDI: %.8x EFLAGS: %.8x ", KiTss.Edi, KiTss.Eflags);
|
||||
if (KiTss.Cs == KERNEL_CS)
|
||||
{
|
||||
DbgPrint("kESP %.8x ", Esp0);
|
||||
if (PsGetCurrentThread() != NULL)
|
||||
{
|
||||
DbgPrint("kernel stack base %x\n",
|
||||
PsGetCurrentThread()->Tcb.StackLimit);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint("User ESP %.8x\n", KiTss.Esp);
|
||||
}
|
||||
if ((KiTss.Cs & 0xffff) == KERNEL_CS)
|
||||
{
|
||||
DbgPrint("ESP %x\n", Esp0);
|
||||
stack = (PULONG) (Esp0 + 24);
|
||||
stack = (PULONG)(((ULONG)stack) & (~0x3));
|
||||
if (PsGetCurrentThread() != NULL)
|
||||
{
|
||||
StackLimit = (ULONG)PsGetCurrentThread()->Tcb.StackBase;
|
||||
}
|
||||
else
|
||||
{
|
||||
StackLimit = (ULONG)&init_stack_top;
|
||||
}
|
||||
|
||||
DbgPrint("stack<%p>: ", stack);
|
||||
|
||||
for (i = 0; i < 18 && (((ULONG)&stack[i+5]) < StackLimit); i = i + 6)
|
||||
{
|
||||
DbgPrint("%.8x %.8x %.8x %.8x\n",
|
||||
stack[i], stack[i+1],
|
||||
stack[i+2], stack[i+3],
|
||||
stack[i+4], stack[i+5]);
|
||||
}
|
||||
DbgPrint("Frames:\n");
|
||||
for (i = 0; i < 32 && (((ULONG)&stack[i]) < StackLimit); i++)
|
||||
{
|
||||
if (stack[i] > ((unsigned int) &_text_start__) &&
|
||||
!(stack[i] >= ((ULONG)&init_stack) &&
|
||||
stack[i] <= ((ULONG)&init_stack_top)))
|
||||
{
|
||||
print_address((PVOID)stack[i]);
|
||||
DbgPrint(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DbgPrint("\n");
|
||||
for(;;);
|
||||
}
|
||||
|
||||
ULONG
|
||||
KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
|
||||
/*
|
||||
|
@ -415,15 +556,104 @@ static void set_interrupt_gate(unsigned int sel, unsigned int func)
|
|||
KiIdt[sel].b = 0x8f00 + (((int)func)&0xffff0000);
|
||||
}
|
||||
|
||||
static void
|
||||
set_task_gate(unsigned int sel, unsigned task_sel)
|
||||
{
|
||||
KiIdt[sel].a = task_sel << 16;
|
||||
KiIdt[sel].b = 0x8500;
|
||||
}
|
||||
|
||||
void KeInitExceptions(void)
|
||||
/*
|
||||
* FUNCTION: Initalize CPU exception handling
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
ULONG base, length;
|
||||
extern USHORT KiGdt[];
|
||||
extern unsigned int trap_stack_top;
|
||||
extern KTSS KiTss;
|
||||
extern KTSS KiTrapTss;
|
||||
ULONG cr3;
|
||||
|
||||
DPRINT("KeInitExceptions()\n",0);
|
||||
|
||||
__asm__("movl %%cr3,%0\n\t" : "=d" (cr3));
|
||||
|
||||
/*
|
||||
* Set up an a descriptor for the LDT
|
||||
*/
|
||||
memset(KiNullLdt, 0, sizeof(KiNullLdt));
|
||||
base = (unsigned int)&KiNullLdt;
|
||||
length = sizeof(KiNullLdt) - 1;
|
||||
|
||||
KiGdt[(LDT_SELECTOR / 2) + 0] = (length & 0xFFFF);
|
||||
KiGdt[(LDT_SELECTOR / 2) + 1] = (base & 0xFFFF);
|
||||
KiGdt[(LDT_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200;
|
||||
KiGdt[(LDT_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
|
||||
((base & 0xFF000000) >> 16);
|
||||
|
||||
/*
|
||||
* Set up a descriptor for the TSS
|
||||
*/
|
||||
memset(&KiTss, 0, sizeof(KiTss));
|
||||
base = (unsigned int)&KiTss;
|
||||
length = sizeof(KiTss) - 1;
|
||||
|
||||
KiGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
|
||||
KiGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
|
||||
KiGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
|
||||
KiGdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
|
||||
((base & 0xFF000000) >> 16);
|
||||
|
||||
/*
|
||||
* Initialize the TSS
|
||||
*/
|
||||
KiTss.Esp0 = (ULONG)&init_stack_top;
|
||||
KiTss.Ss0 = KERNEL_DS;
|
||||
// KiTss.IoMapBase = FIELD_OFFSET(KTSS, IoBitmap);
|
||||
KiTss.IoMapBase = 0xFFFF; /* No i/o bitmap */
|
||||
KiTss.IoBitmap[0] = 0xFF;
|
||||
KiTss.Ldt = LDT_SELECTOR;
|
||||
|
||||
/*
|
||||
* Load the task register
|
||||
*/
|
||||
__asm__("ltr %%ax"
|
||||
: /* no output */
|
||||
: "a" (TSS_SELECTOR));
|
||||
|
||||
/*
|
||||
* Set up the TSS for handling double faults
|
||||
*/
|
||||
memset(&KiTrapTss, 0, sizeof(KiTrapTss));
|
||||
base = (unsigned int)&KiTrapTss;
|
||||
length = sizeof(KiTrapTss) - 1;
|
||||
|
||||
KiGdt[(TRAP_TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
|
||||
KiGdt[(TRAP_TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
|
||||
KiGdt[(TRAP_TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
|
||||
KiGdt[(TRAP_TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
|
||||
((base & 0xFF000000) >> 16);
|
||||
|
||||
KiTrapTss.Eflags = 0;
|
||||
KiTrapTss.Esp0 = (ULONG)&trap_stack_top;
|
||||
KiTrapTss.Ss0 = KERNEL_DS;
|
||||
KiTrapTss.Esp = (ULONG)&trap_stack_top;
|
||||
KiTrapTss.Cs = KERNEL_CS;
|
||||
KiTrapTss.Eip = (ULONG)KiTrap8;
|
||||
KiTrapTss.Ss = KERNEL_DS;
|
||||
KiTrapTss.Ds = KERNEL_DS;
|
||||
KiTrapTss.Es = KERNEL_DS;
|
||||
KiTrapTss.Fs = PCR_SELECTOR;
|
||||
KiTrapTss.IoMapBase = 0xFFFF; /* No i/o bitmap */
|
||||
KiTrapTss.IoBitmap[0] = 0xFF;
|
||||
KiTrapTss.Ldt = LDT_SELECTOR;
|
||||
KiTrapTss.Cr3 = cr3;
|
||||
|
||||
/*
|
||||
* Set up the other gates
|
||||
*/
|
||||
set_interrupt_gate(0, (ULONG)KiTrap0);
|
||||
set_interrupt_gate(1, (ULONG)KiTrap1);
|
||||
set_interrupt_gate(2, (ULONG)KiTrap2);
|
||||
|
@ -432,7 +662,7 @@ void KeInitExceptions(void)
|
|||
set_interrupt_gate(5, (ULONG)KiTrap5);
|
||||
set_interrupt_gate(6, (ULONG)KiTrap6);
|
||||
set_interrupt_gate(7, (ULONG)KiTrap7);
|
||||
set_interrupt_gate(8, (ULONG)KiTrap8);
|
||||
set_task_gate(8, TRAP_TSS_SELECTOR);
|
||||
set_interrupt_gate(9, (ULONG)KiTrap9);
|
||||
set_interrupt_gate(10, (ULONG)KiTrap10);
|
||||
set_interrupt_gate(11, (ULONG)KiTrap11);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
USHORT KiGdt[10 * 4] =
|
||||
USHORT KiGdt[11 * 4] =
|
||||
{
|
||||
0x0, 0x0, 0x0, 0x0, /* Null */
|
||||
0xffff, 0x0, 0x9a00, 0xcf, /* Kernel CS */
|
||||
|
@ -45,7 +45,9 @@ USHORT KiGdt[10 * 4] =
|
|||
0x1000, 0xf000, 0x92df, 0xff00, /* PCR */
|
||||
0x1000, 0x0, 0xf200, 0x0, /* TEB */
|
||||
0x0, 0x0, 0x0, 0x0, /* Reserved */
|
||||
0x0, 0x0, 0x0, 0x0}; /* LDT */
|
||||
0x0, 0x0, 0x0, 0x0, /* LDT */
|
||||
0x0, 0x0, 0x0, 0x0 /* Trap TSS */
|
||||
};
|
||||
|
||||
static KSPIN_LOCK GdtLock;
|
||||
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
.globl _start
|
||||
.globl _init_stack
|
||||
.globl _init_stack_top
|
||||
.globl _trap_stack
|
||||
.globl _trap_stack_top
|
||||
.globl _unmap_me
|
||||
.globl _unmap_me2
|
||||
.globl _unmap_me3
|
||||
|
||||
/*
|
||||
* This is called by the realmode loader, with protected mode
|
||||
|
@ -641,77 +646,26 @@ lowmem_pagetable:
|
|||
.long 0x3e8007,0x3e9007,0x3ea007,0x3eb007,0x3ec007,0x3ed007,0x3ee007,0x3ef007
|
||||
.long 0x3f0007,0x3f1007,0x3f2007,0x3f3007,0x3f4007,0x3f5007,0x3f6007,0x3f7007
|
||||
.long 0x3f8007,0x3f9007,0x3fa007,0x3fb007,0x3fc007,0x3fd007,0x3fe007,0x3ff007
|
||||
.long 0x200007,0x201007,0x202007,0x203007,0x204007,0x205007,0x206007,0x207007
|
||||
.long 0x208007,0x209007,0x20a007,0x20b007,0x20c007,0x20d007,0x20e007,0x20f007
|
||||
.long 0x210007,0x211007,0x212007,0x213007,0x214007,0x215007,0x216007,0x217007
|
||||
.long 0x218007,0x219007,0x21a007,0x21b007,0x21c007,0x21d007,0x21e007,0x21f007
|
||||
.long 0x220007,0x221007,0x222007,0x223007,0x224007,0x225007,0x226007,0x227007
|
||||
.long 0x228007,0x229007,0x22a007,0x22b007,0x22c007,0x22d007,0x22e007,0x22f007
|
||||
.long 0x230007,0x231007,0x232007,0x233007,0x234007,0x235007,0x236007,0x237007
|
||||
.long 0x238007,0x239007,0x23a007,0x23b007,0x23c007,0x23d007,0x23e007,0x23f007
|
||||
.long 0x240007,0x241007,0x242007,0x243007,0x244007,0x245007,0x246007,0x247007
|
||||
.long 0x248007,0x249007,0x24a007,0x24b007,0x24c007,0x24d007,0x24e007,0x24f007
|
||||
.long 0x250007,0x251007,0x252007,0x253007,0x254007,0x255007,0x256007,0x257007
|
||||
.long 0x258007,0x259007,0x25a007,0x25b007,0x25c007,0x25d007,0x25e007,0x25f007
|
||||
.long 0x260007,0x261007,0x262007,0x263007,0x264007,0x265007,0x266007,0x267007
|
||||
.long 0x268007,0x269007,0x26a007,0x26b007,0x26c007,0x26d007,0x26e007,0x26f007
|
||||
.long 0x270007,0x271007,0x272007,0x273007,0x274007,0x275007,0x276007,0x277007
|
||||
.long 0x278007,0x279007,0x27a007,0x27b007,0x27c007,0x27d007,0x27e007,0x27f007
|
||||
.long 0x280007,0x281007,0x282007,0x283007,0x284007,0x285007,0x286007,0x287007
|
||||
.long 0x288007,0x289007,0x28a007,0x28b007,0x28c007,0x28d007,0x28e007,0x28f007
|
||||
.long 0x290007,0x291007,0x292007,0x293007,0x294007,0x295007,0x296007,0x297007
|
||||
.long 0x298007,0x299007,0x29a007,0x29b007,0x29c007,0x29d007,0x29e007,0x29f007
|
||||
.long 0x2a0007,0x2a1007,0x2a2007,0x2a3007,0x2a4007,0x2a5007,0x2a6007,0x2a7007
|
||||
.long 0x2a8007,0x2a9007,0x2aa007,0x2ab007,0x2ac007,0x2ad007,0x2ae007,0x2af007
|
||||
.long 0x2b0007,0x2b1007,0x2b2007,0x2b3007,0x2b4007,0x2b5007,0x2b6007,0x2b7007
|
||||
.long 0x2b8007,0x2b9007,0x2ba007,0x2bb007,0x2bc007,0x2bd007,0x2be007,0x2bf007
|
||||
.long 0x2c0007,0x2c1007,0x2c2007,0x2c3007,0x2c4007,0x2c5007,0x2c6007,0x2c7007
|
||||
.long 0x2c8007,0x2c9007,0x2ca007,0x2cb007,0x2cc007,0x2cd007,0x2ce007,0x2cf007
|
||||
.long 0x2d0007,0x2d1007,0x2d2007,0x2d3007,0x2d4007,0x2d5007,0x2d6007,0x2d7007
|
||||
.long 0x2d8007,0x2d9007,0x2da007,0x2db007,0x2dc007,0x2dd007,0x2de007,0x2df007
|
||||
.long 0x2e0007,0x2e1007,0x2e2007,0x2e3007,0x2e4007,0x2e5007,0x2e6007,0x2e7007
|
||||
.long 0x2e8007,0x2e9007,0x2ea007,0x2eb007,0x2ec007,0x2ed007,0x2ee007,0x2ef007
|
||||
.long 0x2f0007,0x2f1007,0x2f2007,0x2f3007,0x2f4007,0x2f5007,0x2f6007,0x2f7007
|
||||
.long 0x2f8007,0x2f9007,0x2fa007,0x2fb007,0x2fc007,0x2fd007,0x2fe007,0x2ff007
|
||||
.long 0x300007,0x301007,0x302007,0x303007,0x304007,0x305007,0x306007,0x307007
|
||||
.long 0x308007,0x309007,0x30a007,0x30b007,0x30c007,0x30d007,0x30e007,0x30f007
|
||||
.long 0x310007,0x311007,0x312007,0x313007,0x314007,0x315007,0x316007,0x317007
|
||||
.long 0x318007,0x319007,0x31a007,0x31b007,0x31c007,0x31d007,0x31e007,0x31f007
|
||||
.long 0x320007,0x321007,0x322007,0x323007,0x324007,0x325007,0x326007,0x327007
|
||||
.long 0x328007,0x329007,0x32a007,0x32b007,0x32c007,0x32d007,0x32e007,0x32f007
|
||||
.long 0x330007,0x331007,0x332007,0x333007,0x334007,0x335007,0x336007,0x337007
|
||||
.long 0x338007,0x339007,0x33a007,0x33b007,0x33c007,0x33d007,0x33e007,0x33f007
|
||||
.long 0x340007,0x341007,0x342007,0x343007,0x344007,0x345007,0x346007,0x347007
|
||||
.long 0x348007,0x349007,0x34a007,0x34b007,0x34c007,0x34d007,0x34e007,0x34f007
|
||||
.long 0x350007,0x351007,0x352007,0x353007,0x354007,0x355007,0x356007,0x357007
|
||||
.long 0x358007,0x359007,0x35a007,0x35b007,0x35c007,0x35d007,0x35e007,0x35f007
|
||||
.long 0x360007,0x361007,0x362007,0x363007,0x364007,0x365007,0x366007,0x367007
|
||||
.long 0x368007,0x369007,0x36a007,0x36b007,0x36c007,0x36d007,0x36e007,0x36f007
|
||||
.long 0x370007,0x371007,0x372007,0x373007,0x374007,0x375007,0x376007,0x377007
|
||||
.long 0x378007,0x379007,0x37a007,0x37b007,0x37c007,0x37d007,0x37e007,0x37f007
|
||||
.long 0x380007,0x381007,0x382007,0x383007,0x384007,0x385007,0x386007,0x387007
|
||||
.long 0x388007,0x389007,0x38a007,0x38b007,0x38c007,0x38d007,0x38e007,0x38f007
|
||||
.long 0x390007,0x391007,0x392007,0x393007,0x394007,0x395007,0x396007,0x397007
|
||||
.long 0x398007,0x399007,0x39a007,0x39b007,0x39c007,0x39d007,0x39e007,0x39f007
|
||||
.long 0x3a0007,0x3a1007,0x3a2007,0x3a3007,0x3a4007,0x3a5007,0x3a6007,0x3a7007
|
||||
.long 0x3a8007,0x3a9007,0x3aa007,0x3ab007,0x3ac007,0x3ad007,0x3ae007,0x3af007
|
||||
.long 0x3b0007,0x3b1007,0x3b2007,0x3b3007,0x3b4007,0x3b5007,0x3b6007,0x3b7007
|
||||
.long 0x3b8007,0x3b9007,0x3ba007,0x3bb007,0x3bc007,0x3bd007,0x3be007,0x3bf007
|
||||
.long 0x3c0007,0x3c1007,0x3c2007,0x3c3007,0x3c4007,0x3c5007,0x3c6007,0x3c7007
|
||||
.long 0x3c8007,0x3c9007,0x3ca007,0x3cb007,0x3cc007,0x3cd007,0x3ce007,0x3cf007
|
||||
.long 0x3d0007,0x3d1007,0x3d2007,0x3d3007,0x3d4007,0x3d5007,0x3d6007,0x3d7007
|
||||
.long 0x3d8007,0x3d9007,0x3da007,0x3db007,0x3dc007,0x3dd007,0x3de007,0x3df007
|
||||
.long 0x3e0007,0x3e1007,0x3e2007,0x3e3007,0x3e4007,0x3e5007,0x3e6007,0x3e7007
|
||||
.long 0x3e8007,0x3e9007,0x3ea007,0x3eb007,0x3ec007,0x3ed007,0x3ee007,0x3ef007
|
||||
.long 0x3f0007,0x3f1007,0x3f2007,0x3f3007,0x3f4007,0x3f5007,0x3f6007,0x3f7007
|
||||
.long 0x3f8007,0x3f9007,0x3fa007,0x3fb007,0x3fc007,0x3fd007,0x3fe007,0x3ff007
|
||||
|
||||
_unmap_me:
|
||||
.fill 4096, 1, 0
|
||||
|
||||
_init_stack:
|
||||
.fill 3*4096,1,0
|
||||
.fill 3*4096, 1, 0
|
||||
_init_stack_top:
|
||||
|
||||
_unmap_me2:
|
||||
.fill 4096, 1, 0
|
||||
|
||||
_trap_stack:
|
||||
.fill 3*4096, 1, 0
|
||||
_trap_stack_top:
|
||||
|
||||
_unmap_me3:
|
||||
.fill 4096, 1, 0
|
||||
|
||||
_gdt_descr:
|
||||
.word (10*8)-1
|
||||
.word (11*8)-1
|
||||
.long _KiGdt
|
||||
|
||||
_idt_descr:
|
||||
|
|
|
@ -39,9 +39,8 @@
|
|||
|
||||
/* GLOBALS ***************************************************************/
|
||||
|
||||
static char KiNullLdt[8] = {0,};
|
||||
|
||||
KTSS KiTss;
|
||||
KTSS KiTrapTss;
|
||||
|
||||
extern USHORT KiGdt[];
|
||||
|
||||
|
@ -161,51 +160,6 @@ HalInitFirstTask(PETHREAD thread)
|
|||
* initial thread
|
||||
*/
|
||||
{
|
||||
ULONG base;
|
||||
ULONG length;
|
||||
|
||||
/*
|
||||
* Set up an a descriptor for the LDT
|
||||
*/
|
||||
memset(KiNullLdt, 0, sizeof(KiNullLdt));
|
||||
base = (unsigned int)&KiNullLdt;
|
||||
length = sizeof(KiNullLdt) - 1;
|
||||
|
||||
KiGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
|
||||
KiGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
|
||||
KiGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200;
|
||||
KiGdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
|
||||
((base & 0xFF000000) >> 16);
|
||||
|
||||
/*
|
||||
* Set up a descriptor for the TSS
|
||||
*/
|
||||
memset(&KiTss, 0, sizeof(KiTss));
|
||||
base = (unsigned int)&KiTss;
|
||||
length = sizeof(KiTss) - 1;
|
||||
|
||||
KiGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
|
||||
KiGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
|
||||
KiGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
|
||||
KiGdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
|
||||
((base & 0xFF000000) >> 16);
|
||||
|
||||
/*
|
||||
* Initialize the TSS
|
||||
*/
|
||||
KiTss.Esp0 = (ULONG)&init_stack_top;
|
||||
KiTss.Ss0 = KERNEL_DS;
|
||||
// KiTss.IoMapBase = FIELD_OFFSET(KTSS, IoBitmap);
|
||||
KiTss.IoMapBase = 0xFFFF; /* No i/o bitmap */
|
||||
KiTss.IoBitmap[0] = 0xFF;
|
||||
KiTss.Ldt = LDT_SELECTOR;
|
||||
|
||||
/*
|
||||
* Load the task register
|
||||
*/
|
||||
__asm__("ltr %%ax"
|
||||
: /* no output */
|
||||
: "a" (TSS_SELECTOR));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: trap.s,v 1.9 2001/03/25 02:34:28 dwelch Exp $
|
||||
/* $Id: trap.s,v 1.10 2001/03/28 14:24:05 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/i386/trap.s
|
||||
|
@ -245,11 +245,8 @@ _KiTrap7:
|
|||
|
||||
.globl _KiTrap8
|
||||
_KiTrap8:
|
||||
pushl %ebp
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
movl $8, %esi
|
||||
jmp _KiTrapProlog
|
||||
call _KiDoubleFaultHandler
|
||||
iret
|
||||
|
||||
.globl _KiTrap9
|
||||
_KiTrap9:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: mminit.c,v 1.16 2001/03/26 20:46:53 dwelch Exp $
|
||||
/* $Id: mminit.c,v 1.17 2001/03/28 14:24:05 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -176,6 +176,7 @@ VOID MmInit1(ULONG FirstKrnlPhysAddr,
|
|||
{
|
||||
ULONG i;
|
||||
ULONG kernel_len;
|
||||
extern unsigned int unmap_me, unmap_me2, unmap_me3;
|
||||
|
||||
DPRINT("MmInit1(bp %x, LastKernelAddress %x)\n", bp,
|
||||
LastKernelAddress);
|
||||
|
@ -266,6 +267,10 @@ VOID MmInit1(ULONG FirstKrnlPhysAddr,
|
|||
}
|
||||
DPRINT("Almost done MmInit()\n");
|
||||
|
||||
MmDeleteVirtualMapping(NULL, (PVOID)&unmap_me, FALSE, NULL, NULL);
|
||||
MmDeleteVirtualMapping(NULL, (PVOID)&unmap_me2, FALSE, NULL, NULL);
|
||||
MmDeleteVirtualMapping(NULL, (PVOID)&unmap_me3, FALSE, NULL, NULL);
|
||||
|
||||
/*
|
||||
* Intialize memory areas
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue