- Update selector names to official names and define/use the MODE and
RPL masks for more portable/clean code.
Modified: trunk/reactos/hal/halx86/mp/apic.c
Modified: trunk/reactos/hal/halx86/mp/mps.S
Modified: trunk/reactos/include/ndk/asm.h
Modified: trunk/reactos/lib/kernel32/misc/utils.c
Modified: trunk/reactos/lib/kernel32/thread/i386/fiber.S
Modified: trunk/reactos/lib/rtl/thread.c
Modified: trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c
Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
Modified: trunk/reactos/ntoskrnl/ke/i386/fpu.c
Modified: trunk/reactos/ntoskrnl/ke/i386/gdt.c
Modified: trunk/reactos/ntoskrnl/ke/i386/irq.c
Modified: trunk/reactos/ntoskrnl/ke/i386/irqhand.s
Modified: trunk/reactos/ntoskrnl/ke/i386/kernel.c
Modified: trunk/reactos/ntoskrnl/ke/i386/ldt.c
Modified: trunk/reactos/ntoskrnl/ke/i386/main_asm.S
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
Modified: trunk/reactos/ntoskrnl/ke/i386/tss.c
Modified: trunk/reactos/ntoskrnl/ps/debug.c
Modified: trunk/reactos/tools/nci/ncitool.c
_____
Modified: trunk/reactos/hal/halx86/mp/apic.c
--- trunk/reactos/hal/halx86/mp/apic.c 2005-11-27 03:07:22 UTC (rev
19667)
+++ trunk/reactos/hal/halx86/mp/apic.c 2005-11-27 03:08:35 UTC (rev
19668)
@@ -919,7 +919,7 @@
idt = (KIDTENTRY*)((ULONG)KeGetCurrentKPCR()->IDT + index *
sizeof(KIDTENTRY));
idt->Offset = address & 0xffff;
- idt->Selector = KERNEL_CS;
+ idt->Selector = KGDT_R0_CODE;
idt->Access = Access.Value;
idt->ExtendedOffset = address >> 16;
}
_____
Modified: trunk/reactos/hal/halx86/mp/mps.S
--- trunk/reactos/hal/halx86/mp/mps.S 2005-11-27 03:07:22 UTC (rev
19667)
+++ trunk/reactos/hal/halx86/mp/mps.S 2005-11-27 03:08:35 UTC (rev
19668)
@@ -22,11 +22,11 @@
pushl %es; \
pushl %fs; \
pushl %gs; \
- movl $(KERNEL_DS), %eax; \
+ movl $(KGDT_R0_DATA), %eax; \
movl %eax, %ds; \
movl %eax, %es; \
movl %eax, %gs; \
- movl $(PCR_SELECTOR), %eax; \
+ movl $(KGDT_R0_PCR), %eax; \
movl %eax, %fs;
#define AFTER \
@@ -85,11 +85,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movl $(KERNEL_DS),%eax
+ movl $(KGDT_R0_DATA),%eax
movl %eax,%ds
movl %eax,%es
movl %eax,%gs
- movl $(PCR_SELECTOR),%eax
+ movl $(KGDT_R0_PCR),%eax
movl %eax,%fs
pushl %esp
pushl %ebx
_____
Modified: trunk/reactos/include/ndk/asm.h
--- trunk/reactos/include/ndk/asm.h 2005-11-27 03:07:22 UTC (rev
19667)
+++ trunk/reactos/include/ndk/asm.h 2005-11-27 03:08:35 UTC (rev
19668)
@@ -20,17 +20,19 @@
#define _ASM_H
//
-// FIXME: Use real names.
+// Selector Names
//
-#define KERNEL_CS (0x8)
-#define KERNEL_DS (0x10)
-#define USER_CS (0x18 + 0x3)
-#define USER_DS (0x20 + 0x3)
-#define TSS_SELECTOR (0x28)
-#define PCR_SELECTOR (0x30)
-#define TEB_SELECTOR (0x38 + 0x3)
-#define LDT_SELECTOR (0x48)
-#define TRAP_TSS_SELECTOR (0x50)
+#define RPL_MASK 0x0003
+#define MODE_MASK 0x0001
+#define KGDT_R0_CODE (0x8)
+#define KGDT_R0_DATA (0x10)
+#define KGDT_R3_CODE (0x18)
+#define KGDT_R3_DATA (0x20)
+#define KGDT_TSS (0x28)
+#define KGDT_R0_PCR (0x30)
+#define KGDT_R3_TEB (0x38)
+#define KGDT_LDT (0x48)
+#define KGDT_DF_TSS (0x50)
//
// KV86M_REGISTERS Offsets
@@ -173,7 +175,6 @@
#define KUSER_SHARED_SYSCALL_RET KERNEL_USER_SHARED_DATA
+ 0x304
#define PROCESSOR_FEATURE_FXSR
KUSER_SHARED_PROCESSOR_FEATURES + 0x4
-
//
// CONTEXT Offsets
//
_____
Modified: trunk/reactos/lib/kernel32/misc/utils.c
--- trunk/reactos/lib/kernel32/misc/utils.c 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/lib/kernel32/misc/utils.c 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -351,11 +351,11 @@
/* The other registers are undefined */
/* Setup the Segments */
- Context->SegCs = USER_CS;
- Context->SegDs = USER_DS;
- Context->SegEs = USER_DS;
- Context->SegFs = TEB_SELECTOR;
- Context->SegSs = USER_DS;
+ Context->SegFs = KGDT_R3_TEB | RPL_MASK;
+ Context->SegEs = KGDT_R3_DATA | RPL_MASK;
+ Context->SegDs = KGDT_R3_DATA | RPL_MASK;
+ Context->SegCs = KGDT_R3_CODE | RPL_MASK;
+ Context->SegSs = KGDT_R3_DATA | RPL_MASK;
Context->SegGs = 0;
/* Set the EFLAGS */
_____
Modified: trunk/reactos/lib/kernel32/thread/i386/fiber.S
--- trunk/reactos/lib/kernel32/thread/i386/fiber.S 2005-11-27
03:07:22 UTC (rev 19667)
+++ trunk/reactos/lib/kernel32/thread/i386/fiber.S 2005-11-27
03:08:35 UTC (rev 19668)
@@ -17,7 +17,7 @@
_SwitchToFiber@4:
/* Get the TEB */
- mov edx, fs:[TEB_SELECTOR]
+ mov edx, fs:[KGDT_R3_TEB]
/* Get the Fiber */
mov eax, [edx+TEB_FIBER_DATA]
_____
Modified: trunk/reactos/lib/rtl/thread.c
--- trunk/reactos/lib/rtl/thread.c 2005-11-27 03:07:22 UTC (rev
19667)
+++ trunk/reactos/lib/rtl/thread.c 2005-11-27 03:08:35 UTC (rev
19668)
@@ -278,11 +278,11 @@
/* Set the Selectors */
ThreadContext->SegGs = 0;
- ThreadContext->SegFs = TEB_SELECTOR;
- ThreadContext->SegEs = USER_DS;
- ThreadContext->SegDs = USER_DS;
- ThreadContext->SegCs = USER_CS;
- ThreadContext->SegSs = USER_DS;
+ ThreadContext->SegFs = KGDT_R3_TEB | RPL_MASK;
+ ThreadContext->SegEs = KGDT_R3_DATA | RPL_MASK;
+ ThreadContext->SegDs = KGDT_R3_DATA | RPL_MASK;
+ ThreadContext->SegCs = KGDT_R3_CODE | RPL_MASK;
+ ThreadContext->SegSs = KGDT_R3_DATA | RPL_MASK;
/* Enable Interrupts */
ThreadContext->EFlags = 0x200; /*X86_EFLAGS_IF */
_____
Modified: trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c
--- trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c 2005-11-27
03:07:22 UTC (rev 19667)
+++ trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c 2005-11-27
03:08:35 UTC (rev 19668)
@@ -614,10 +614,10 @@
Value = (ULONG_PTR) (KernelStack + 8);
break;
case CS:
- Value = KERNEL_CS;
+ Value = KGDT_R0_CODE;
break;
case DS:
- Value = KERNEL_DS;
+ Value = KGDT_R0_DATA;
break;
default:
Value = 0;
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
--- trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -196,12 +196,12 @@
/* Write the LDT Selector */
mov ebp, [ebx+KPCR_GDT]
mov eax, [edi+KPROCESS_LDT_DESCRIPTOR0]
- mov [ebp+LDT_SELECTOR], eax
+ mov [ebp+KGDT_LDT], eax
mov eax, [edi+KPROCESS_LDT_DESCRIPTOR1]
- mov [ebp+LDT_SELECTOR+4], eax
+ mov [ebp+KGDT_LDT+4], eax
/* Save LDT Selector */
- mov eax, LDT_SELECTOR
+ mov eax, KGDT_LDT
NoLdt:
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
--- trunk/reactos/ntoskrnl/ke/i386/exp.c 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/exp.c 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -274,7 +274,7 @@
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x\nESP: %.8x ",
OldTss->Edx,
OldTss->Ebp, OldTss->Esi, Esp0);
DbgPrint("EDI: %.8x EFLAGS: %.8x ", OldTss->Edi, OldTss->Eflags);
- if (OldTss->Cs == KERNEL_CS)
+ if (OldTss->Cs == KGDT_R0_CODE)
{
DbgPrint("kESP %.8x ", Esp0);
if (PsGetCurrentThread() != NULL)
@@ -288,7 +288,7 @@
{
DbgPrint("User ESP %.8x\n", OldTss->Esp);
}
- if ((OldTss->Cs & 0xffff) == KERNEL_CS)
+ if ((OldTss->Cs & 0xffff) == KGDT_R0_CODE)
{
if (PsGetCurrentThread() != NULL)
{
@@ -448,7 +448,7 @@
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x ESP: %.8x\n", Tf->Edx,
Tf->Ebp, Tf->Esi, Esp0);
DbgPrint("EDI: %.8x EFLAGS: %.8x ", Tf->Edi, Tf->Eflags);
- if ((Tf->Cs&0xffff) == KERNEL_CS)
+ if ((Tf->Cs&0xffff) == KGDT_R0_CODE)
{
DbgPrint("kESP %.8x ", Esp0);
if (PsGetCurrentThread() != NULL)
@@ -561,7 +561,7 @@
/*
* Handle user exceptions differently
*/
- if ((Tf->Cs & 0xFFFF) == USER_CS)
+ if ((Tf->Cs & 0xFFFF) == (KGDT_R3_CODE | RPL_MASK))
{
return(KiUserTrapHandler(Tf, ExceptionNr, (PVOID)cr2));
}
@@ -605,7 +605,7 @@
ULONG Previous = KiEspFromTrapFrame(TrapFrame);
/* Check if this is user-mode or V86 */
- if ((TrapFrame->Cs & 1) || (TrapFrame->Eflags & X86_EFLAGS_VM))
+ if ((TrapFrame->Cs & MODE_MASK) || (TrapFrame->Eflags &
X86_EFLAGS_VM))
{
/* Write it directly */
TrapFrame->Esp = Esp;
@@ -650,15 +650,15 @@
/* Just return it */
return TrapFrame->Ss;
}
- else if (TrapFrame->Cs & 1)
+ else if (TrapFrame->Cs & MODE_MASK)
{
/* Usermode, return the User SS */
- return TrapFrame->Ss | 3;
+ return TrapFrame->Ss | RPL_MASK;
}
else
{
/* Kernel mode */
- return KERNEL_DS;
+ return KGDT_R0_DATA;
}
}
@@ -676,10 +676,10 @@
/* Just write it */
TrapFrame->Ss = Ss;
}
- else if (TrapFrame->Cs & 1)
+ else if (TrapFrame->Cs & MODE_MASK)
{
/* Usermode, save the User SS */
- TrapFrame->Ss = Ss | 3;
+ TrapFrame->Ss = Ss | RPL_MASK;
}
}
@@ -722,10 +722,10 @@
TrapFrame->Cs = Context->SegCs;
/* Don't let it under 8, that's invalid */
- if ((PreviousMode !=KernelMode) && (TrapFrame->Cs < 8))
+ if ((PreviousMode != KernelMode) && (TrapFrame->Cs < 8))
{
/* Force it to User CS */
- TrapFrame->Cs = USER_CS;
+ TrapFrame->Cs = (KGDT_R3_CODE | RPL_MASK);
}
}
@@ -762,11 +762,11 @@
TrapFrame->V86_Fs = Context->SegFs;
TrapFrame->V86_Gs = Context->SegGs;
}
- else if (!(TrapFrame->Cs & 1))
+ else if (!(TrapFrame->Cs & MODE_MASK))
{
/* For user mode, write the values directly */
- TrapFrame->Ds = USER_DS;
- TrapFrame->Es = USER_DS;
+ TrapFrame->Ds = KGDT_R3_DATA | RPL_MASK;
+ TrapFrame->Es = KGDT_R3_DATA | RPL_MASK;
TrapFrame->Fs = Context->SegFs;
TrapFrame->Gs = 0;
}
@@ -778,7 +778,7 @@
TrapFrame->Fs = Context->SegFs;
/* Handle GS specially */
- if (TrapFrame->Cs == USER_CS)
+ if (TrapFrame->Cs == (KGDT_R3_CODE | RPL_MASK))
{
/* Don't use it, if user */
TrapFrame->Gs = 0;
@@ -863,13 +863,13 @@
else
{
/* Check if this was a Kernel Trap */
- if (TrapFrame->Cs == KERNEL_CS)
+ if (TrapFrame->Cs == KGDT_R0_CODE)
{
/* Set valid selectors */
TrapFrame->Gs = 0;
- TrapFrame->Fs = PCR_SELECTOR;
- TrapFrame->Es = USER_DS;
- TrapFrame->Ds = USER_DS;
+ TrapFrame->Fs = KGDT_R0_PCR;
+ TrapFrame->Es = KGDT_R3_DATA | RPL_MASK;
+ TrapFrame->Ds = KGDT_R3_DATA | RPL_MASK;
}
/* Return the segments */
@@ -1083,7 +1083,7 @@
{
DPRINT("sel %x %d\n",sel,sel);
KiIdt[sel].a = (((int)func)&0xffff) +
- (KERNEL_CS << 16);
+ (KGDT_R0_CODE << 16);
KiIdt[sel].b = 0xef00 + (((int)func)&0xffff0000);
DPRINT("idt[sel].b %x\n",KiIdt[sel].b);
}
@@ -1092,7 +1092,7 @@
{
DPRINT("set_interrupt_gate(sel %d, func %x)\n",sel,func);
KiIdt[sel].a = (((int)func)&0xffff) +
- (KERNEL_CS << 16);
+ (KGDT_R0_CODE << 16);
KiIdt[sel].b = 0x8e00 + (((int)func)&0xffff0000);
}
@@ -1101,7 +1101,7 @@
DPRINT("set_trap_gate(sel %d, func %x, dpl %d)\n",sel, func, dpl);
ASSERT(dpl <= 3);
KiIdt[sel].a = (((int)func)&0xffff) +
- (KERNEL_CS << 16);
+ (KGDT_R0_CODE << 16);
KiIdt[sel].b = 0x8f00 + (dpl << 13) + (((int)func)&0xffff0000);
}
@@ -1135,7 +1135,7 @@
set_trap_gate(5, (ULONG)KiTrap5, 0);
set_trap_gate(6, (ULONG)KiTrap6, 0);
set_trap_gate(7, (ULONG)KiTrap7, 0);
- set_task_gate(8, TRAP_TSS_SELECTOR);
+ set_task_gate(8, KGDT_DF_TSS);
set_trap_gate(9, (ULONG)KiTrap9, 0);
set_trap_gate(10, (ULONG)KiTrap10, 0);
set_trap_gate(11, (ULONG)KiTrap11, 0);
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/fpu.c
--- trunk/reactos/ntoskrnl/ke/i386/fpu.c 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/fpu.c 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -485,7 +485,7 @@
}
KeLowerIrql(OldIrql);
- PreviousMode = ((Tf->Cs & 0xffff) == USER_CS) ? (UserMode) :
(KernelMode);
+ PreviousMode = ((Tf->Cs & 0xffff) == (KGDT_R3_CODE | RPL_MASK))
? (UserMode) : (KernelMode);
DPRINT("Math/Xmm fault happened! (PreviousMode = %s)\n",
(PreviousMode != KernelMode) ? ("UserMode") :
("KernelMode"));
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/gdt.c
--- trunk/reactos/ntoskrnl/ke/i386/gdt.c 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/gdt.c 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -92,7 +92,7 @@
* Set the base address of the PCR
*/
Base = (ULONG)Pcr;
- Entry = PCR_SELECTOR / 2;
+ Entry = KGDT_R0_PCR / 2;
Gdt[Entry + 1] = (USHORT)(((ULONG)Base) & 0xffff);
Gdt[Entry + 2] = Gdt[Entry + 2] & ~(0xff);
@@ -117,24 +117,24 @@
"movl %1, %%fs\n\t"
"movl %0, %%gs\n\t"
: /* no output */
- : "a" (KERNEL_DS), "d" (PCR_SELECTOR));
+ : "a" (KGDT_R0_DATA), "d" (KGDT_R0_PCR));
__asm__ ("pushl %0\n\t"
"pushl $.l4\n\t"
"lret\n\t"
".l4:\n\t"
: /* no output */
- : "a" (KERNEL_CS));
+ : "a" (KGDT_R0_CODE));
#elif defined(_MSC_VER)
__asm
{
lgdt Descriptor;
- mov ax, KERNEL_DS;
- mov dx, PCR_SELECTOR;
+ mov ax, KGDT_R0_DATA;
+ mov dx, KGDT_R0_PCR;
mov ds, ax;
mov es, ax;
mov fs, dx;
mov gs, ax;
- push KERNEL_CS;
+ push KGDT_R0_CODE;
push offset l4 ;
retf
l4:
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/irq.c
--- trunk/reactos/ntoskrnl/ke/i386/irq.c 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/irq.c 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -150,7 +150,7 @@
*/
for (i=0;i<NR_IRQS;i++)
{
- KiIdt[IRQ_BASE+i].a=(irq_handler[i]&0xffff)+(KERNEL_CS<<16);
+ KiIdt[IRQ_BASE+i].a=(irq_handler[i]&0xffff)+(KGDT_R0_CODE<<16);
KiIdt[IRQ_BASE+i].b=(irq_handler[i]&0xffff0000)+PRESENT+
I486_INTERRUPT_GATE;
#ifdef CONFIG_SMP
@@ -308,7 +308,7 @@
*/
Ke386DisableInterrupts();
- if (old_level==PASSIVE_LEVEL && Trapframe->Cs != KERNEL_CS)
+ if (old_level==PASSIVE_LEVEL && Trapframe->Cs != KGDT_R0_CODE)
{
HalEndSystemInterrupt (APC_LEVEL, 0);
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/irqhand.s
--- trunk/reactos/ntoskrnl/ke/i386/irqhand.s 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/irqhand.s 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -29,11 +29,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movl $KERNEL_DS,%eax
+ movl $KGDT_R0_DATA,%eax
movl %eax,%ds
movl %eax,%es
movl %eax,%gs
- movl $PCR_SELECTOR,%eax
+ movl $KGDT_R0_PCR,%eax
movl %eax,%fs
pushl %esp
pushl %ebx
@@ -66,11 +66,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 0)
@@ -93,11 +93,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 1)
@@ -120,11 +120,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 2)
@@ -147,11 +147,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 3)
@@ -174,11 +174,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 4)
@@ -201,11 +201,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 5)
@@ -228,11 +228,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 6)
@@ -255,11 +255,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 7)
@@ -282,11 +282,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 8)
@@ -309,11 +309,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 9)
@@ -336,11 +336,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 10)
@@ -363,11 +363,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 11)
@@ -390,11 +390,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 12)
@@ -417,11 +417,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 13)
@@ -444,11 +444,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 14)
@@ -471,11 +471,11 @@
pushl %gs
movl $0xceafbeef,%eax
pushl %eax
- movw $KERNEL_DS,%ax
+ movw $KGDT_R0_DATA,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%gs
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
pushl %esp
pushl $(IRQ_BASE + 15)
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/kernel.c
--- trunk/reactos/ntoskrnl/ke/i386/kernel.c 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/kernel.c 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -244,7 +244,7 @@
extern void KiFastCallEntry(void);
/* CS Selector of the target segment. */
- Ke386Wrmsr(0x174, KERNEL_CS, 0);
+ Ke386Wrmsr(0x174, KGDT_R0_CODE, 0);
/* Target ESP. */
Ke386Wrmsr(0x175, 0, 0);
/* Target EIP. */
@@ -400,7 +400,7 @@
extern void KiFastCallEntry(void);
/* CS Selector of the target segment. */
- Ke386Wrmsr(0x174, KERNEL_CS, 0);
+ Ke386Wrmsr(0x174, KGDT_R0_CODE, 0);
/* Target ESP. */
Ke386Wrmsr(0x175, 0, 0);
/* Target EIP. */
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/ldt.c
--- trunk/reactos/ntoskrnl/ke/i386/ldt.c 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/ldt.c 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -119,16 +119,16 @@
LdtDescriptor[3] = (USHORT)(((NewLdtSize & 0xf0000) >> 16) |
((NewLdtBase & 0xff000000) >> 16));
- KeSetGdtSelector(LDT_SELECTOR,
+ KeSetGdtSelector(KGDT_LDT,
((PULONG) LdtDescriptor)[0],
((PULONG) LdtDescriptor)[1]);
#if defined(__GNUC__)
__asm__("lldtw %%ax"
: /* no output */
- : "a" (LDT_SELECTOR));
+ : "a" (KGDT_LDT));
#elif defined(_MSC_VER)
- __asm mov ax, LDT_SELECTOR
+ __asm mov ax, KGDT_LDT
__asm lldt ax
#else
#error Unknown compiler for inline assembler
@@ -171,9 +171,9 @@
*/
base = length = 0;
- Gdt[(LDT_SELECTOR / 2) + 0] = (length & 0xFFFF);
- Gdt[(LDT_SELECTOR / 2) + 1] = (base & 0xFFFF);
- Gdt[(LDT_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200;
- Gdt[(LDT_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
+ Gdt[(KGDT_LDT / 2) + 0] = (length & 0xFFFF);
+ Gdt[(KGDT_LDT / 2) + 1] = (base & 0xFFFF);
+ Gdt[(KGDT_LDT / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200;
+ Gdt[(KGDT_LDT / 2) + 3] = ((length & 0xF0000) >> 16) |
((base & 0xFF000000) >> 16);
}
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/main_asm.S
--- trunk/reactos/ntoskrnl/ke/i386/main_asm.S 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/main_asm.S 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -12,7 +12,7 @@
lidt _KiIdtDescriptor
/* Load the PCR selector */
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
cmpl $AP_MAGIC, %ecx
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
--- trunk/reactos/ntoskrnl/ke/i386/syscall.S 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/syscall.S 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -102,10 +102,10 @@
push 0
/* Generate interrupt stack for Trap 6 */
- push USER_DS
+ push KGDT_R3_DATA + RPL_MASK
push 0
push 0x20202
- push USER_CS
+ push KGDT_R3_CODE + RPL_MASK
push 0
jmp _KiTrap6
@@ -113,11 +113,11 @@
// ==================== UNIQUE SYSENTER STUB. DO NOT DUPLICATE
============//
/* Set FS to PCR */
- mov ecx, PCR_SELECTOR
+ mov ecx, KGDT_R0_PCR
mov fs, cx
/* Set DS/ES to Kernel Selector */
- mov ecx, KERNEL_DS
+ mov ecx, KGDT_R0_DATA
mov ds, cx
mov es, cx
@@ -126,14 +126,14 @@
mov esp, ss:[ecx+KTSS_ESP0]
/* Set up a fake INT Stack. */
- push USER_DS
+ push KGDT_R3_DATA + RPL_MASK
push edx /* Ring 3 SS:ESP */
pushf /* Ring 3 EFLAGS */
push 2 /* Ring 0 EFLAGS */
add edx, 8 /* Skip user parameter list */
popf /* Set our EFLAGS */
or dword ptr [esp], X86_EFLAGS_IF /* Re-enable IRQs in EFLAGS, to
fake INT */
- push USER_CS
+ push KGDT_R3_CODE + RPL_MASK
push KUSER_SHARED_SYSCALL_RET
/* Setup the Trap Frame stack */
@@ -142,7 +142,7 @@
push ebx
push esi
push edi
- push TEB_SELECTOR
+ push KGDT_R3_TEB + RPL_MASK
/* Save pointer to our PCR */
mov ebx, [fs:KPCR_SELF]
@@ -163,10 +163,10 @@
.att_syntax
/* Save other registers */
sub $0xC, %esp
// + 0x70
- pushl $USER_DS
// + 0x40
- pushl $USER_DS
// + 0x44
+ pushl $KGDT_R3_DATA + RPL_MASK
// + 0x40
+ pushl $KGDT_R3_DATA + RPL_MASK
// + 0x44
pushl $0
// + 0x48
- sub $0x30, %esp
// + 0x70
+ sub $0x30, %esp
// + 0x70
.intel_syntax noprefix
/* Make space for us on the stack */
@@ -201,7 +201,7 @@
push fs
/* Load PCR Selector into fs */
- mov ebx, PCR_SELECTOR
+ mov ebx, KGDT_R0_PCR
mov fs, bx
/* Get a pointer to the current thread */
@@ -410,9 +410,9 @@
// ================= PRESENT ONLY IF VOLATILES NEEDED ============//
/* Save some stuff that raising IRQL will kill */
mov [ebx+KTRAP_FRAME_EAX], eax
- mov dword ptr [ebx+KTRAP_FRAME_FS], TEB_SELECTOR
- mov dword ptr [ebx+KTRAP_FRAME_DS], USER_DS
- mov dword ptr [ebx+KTRAP_FRAME_ES], USER_DS
+ mov dword ptr [ebx+KTRAP_FRAME_FS], KGDT_R3_TEB + RPL_MASK
+ mov dword ptr [ebx+KTRAP_FRAME_DS], KGDT_R3_DATA + RPL_MASK
+ mov dword ptr [ebx+KTRAP_FRAME_ES], KGDT_R3_DATA + RPL_MASK
mov dword ptr [ebx+KTRAP_FRAME_GS], 0
// ============= END PRESENT ONLY IF VOLATILES NEEDED ============//
@@ -464,7 +464,7 @@
// ==================== ONLY IF FULL RESTORE NEEDED
===================//
/* Check the old mode */
- cmp word ptr [esp+KTRAP_FRAME_CS], USER_CS
+ cmp word ptr [esp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK
bt word ptr [esp+KTRAP_FRAME_CS], 0
cmc
ja RestoreAll
@@ -524,7 +524,7 @@
jnz IntRet
/* Restore FS to TIB */
- mov ecx, TEB_SELECTOR
+ mov ecx, KGDT_R3_TEB + RPL_MASK
mov fs, ecx
/* We will be cleaning up the stack ourselves */
@@ -702,7 +702,7 @@
mov eax, [esp+KTRAP_FRAME_EAX]
/* Check if it was kernel */
- cmp word ptr [ebp+KTRAP_FRAME_CS], KERNEL_CS
+ cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R0_CODE
jz CommonStackClean2
/* Skip registers */
@@ -787,7 +787,7 @@
push fs
/* Switch to correct FS */
- mov bx, PCR_SELECTOR
+ mov bx, KGDT_R0_PCR
mov fs, bx
/* Save Exception List */
@@ -806,7 +806,7 @@
sub esp, 0x30
/* Switch Segments to Kernel */
- mov ax, KERNEL_DS
+ mov ax, KGDT_R0_DATA
mov ds, ax
mov es, ax
@@ -853,7 +853,7 @@
/* Check if this is kernel or user-mode */
test byte ptr [ebp+KTRAP_FRAME_CS], 1
jz CallDispatch
- cmp word ptr [ebp+KTRAP_FRAME_CS], USER_CS
+ cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK
jnz NotUserMode
/* Re-enable interrupts */
@@ -952,7 +952,7 @@
mov eax, [esp+KTRAP_FRAME_EAX]
/* Check if it was kernel */
- cmp word ptr [ebp+KTRAP_FRAME_CS], KERNEL_CS
+ cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R0_CODE
jz CommonStackClean3
/* Skip registers */
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
--- trunk/reactos/ntoskrnl/ke/i386/trap.s 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -104,7 +104,7 @@
pushl %ebp /* XXX: DebugEBP */
/* Load the segment registers */
- movl $KERNEL_DS, %eax
+ movl $KGDT_R0_DATA, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %gs
@@ -113,7 +113,7 @@
movl %esp, %ebp
/* Load the PCR selector into fs */
- movl $PCR_SELECTOR, %eax
+ movl $KGDT_R0_PCR, %eax
movl %eax, %fs
/* Save the old exception list */
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/tss.c
--- trunk/reactos/ntoskrnl/ke/i386/tss.c 2005-11-27 03:07:22 UTC
(rev 19667)
+++ trunk/reactos/ntoskrnl/ke/i386/tss.c 2005-11-27 03:08:35 UTC
(rev 19668)
@@ -119,7 +119,7 @@
/* Initialize the boot TSS. */
Tss->Esp0 = (ULONG)Ki386InitialStackArray[Id] + MM_STACK_SIZE; /*
FIXME: - sizeof(FX_SAVE_AREA)? */
- Tss->Ss0 = KERNEL_DS;
+ Tss->Ss0 = KGDT_R0_DATA;
Tss->IoMapBase = 0xFFFF; /* No i/o bitmap */
Tss->IoBitmap[8192] = 0xFF;
Tss->Ldt = 0;
@@ -130,23 +130,23 @@
base = (ULONG)Tss;
length = sizeof(KTSS) - 1;
- Gdt[(TSS_SELECTOR / 2) + 0] = (USHORT)(length & 0xFFFF);
- Gdt[(TSS_SELECTOR / 2) + 1] = (USHORT)(base & 0xFFFF);
- Gdt[(TSS_SELECTOR / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16) |
0x8900);
- Gdt[(TSS_SELECTOR / 2) + 3] = (USHORT)(((length & 0xF0000) >> 16) |
+ Gdt[(KGDT_TSS / 2) + 0] = (USHORT)(length & 0xFFFF);
+ Gdt[(KGDT_TSS / 2) + 1] = (USHORT)(base & 0xFFFF);
+ Gdt[(KGDT_TSS / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16) |
0x8900);
+ Gdt[(KGDT_TSS / 2) + 3] = (USHORT)(((length & 0xF0000) >> 16) |
((base & 0xFF000000) >> 16));
/* Initialize the TSS used for handling double faults. */
TrapTss->Eflags = 0;
TrapTss->Esp0 = ((ULONG)TrapStack + MM_STACK_SIZE); /* FIXME: -
sizeof(FX_SAVE_AREA)? */
- TrapTss->Ss0 = KERNEL_DS;
+ TrapTss->Ss0 = KGDT_R0_DATA;
TrapTss->Esp = ((ULONG)TrapStack + MM_STACK_SIZE); /* FIXME: -
sizeof(FX_SAVE_AREA)? */
- TrapTss->Cs = KERNEL_CS;
+ TrapTss->Cs = KGDT_R0_CODE;
TrapTss->Eip = (ULONG)KiTrap8;
- TrapTss->Ss = KERNEL_DS;
- TrapTss->Ds = KERNEL_DS;
- TrapTss->Es = KERNEL_DS;
- TrapTss->Fs = PCR_SELECTOR;
+ TrapTss->Ss = KGDT_R0_DATA;
+ TrapTss->Ds = KGDT_R0_DATA;
+ TrapTss->Es = KGDT_R0_DATA;
+ TrapTss->Fs = KGDT_R0_PCR;
TrapTss->IoMapBase = 0xFFFF; /* No i/o bitmap */
TrapTss->IoBitmap[0] = 0xFF;
TrapTss->Ldt = 0;
@@ -158,10 +158,10 @@
base = (ULONG)TrapTss;
length = sizeof(KTSSNOIOPM) - 1;
- Gdt[(TRAP_TSS_SELECTOR / 2) + 0] = (USHORT)(length & 0xFFFF);
- Gdt[(TRAP_TSS_SELECTOR / 2) + 1] = (USHORT)(base & 0xFFFF);
- Gdt[(TRAP_TSS_SELECTOR / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16)
| 0x8900);
- Gdt[(TRAP_TSS_SELECTOR / 2) + 3] = (USHORT)(((length & 0xF0000) >>
16) |
+ Gdt[(KGDT_DF_TSS / 2) + 0] = (USHORT)(length & 0xFFFF);
+ Gdt[(KGDT_DF_TSS / 2) + 1] = (USHORT)(base & 0xFFFF);
+ Gdt[(KGDT_DF_TSS / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16) |
0x8900);
+ Gdt[(KGDT_DF_TSS / 2) + 3] = (USHORT)(((length & 0xF0000) >> 16) |
((base & 0xFF000000) >> 16));
/*
@@ -170,9 +170,9 @@
#if defined(__GNUC__)
__asm__("ltr %%ax"
: /* no output */
- : "a" (TSS_SELECTOR));
+ : "a" (KGDT_TSS));
#elif defined(_MSC_VER)
- __asm mov ax, TSS_SELECTOR
+ __asm mov ax, KGDT_TSS
__asm ltr ax
#else
#error Unknown compiler for inline assembler
@@ -195,11 +195,11 @@
/* Initialize the boot TSS. */
KiBootTss.Esp0 = (ULONG)init_stack_top - sizeof(FX_SAVE_AREA);
[truncated at 1000 lines; 106 more skipped]