From 16ab5c9a07438dd51c0e2649aaa4751db2ea73b1 Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Fri, 22 Aug 2008 14:29:01 +0000 Subject: [PATCH] - Add EFLAGS_IOPL to asm.h and make use of it in assembly - Fix a potential 64-bit warning in handle.c - Comment fixes svn path=/trunk/; revision=35529 --- reactos/include/ndk/asm.h | 1 + reactos/ntoskrnl/ex/handle.c | 4 ++-- reactos/ntoskrnl/ex/locale.c | 2 +- reactos/ntoskrnl/ke/i386/boot.S | 2 +- reactos/ntoskrnl/ke/i386/exp.c | 10 +++++----- reactos/ntoskrnl/ke/i386/thrdini.c | 2 +- reactos/ntoskrnl/ke/i386/trap.s | 2 +- reactos/ntoskrnl/ke/i386/v86m_sup.S | 8 ++++---- reactos/ntoskrnl/ps/kill.c | 4 ++-- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/reactos/include/ndk/asm.h b/reactos/include/ndk/asm.h index 771fa8242ad..dc7b3b22829 100644 --- a/reactos/include/ndk/asm.h +++ b/reactos/include/ndk/asm.h @@ -450,6 +450,7 @@ Author: #ifdef __ASM__ #define EFLAGS_TF 0x100 #define EFLAGS_INTERRUPT_MASK 0x200 +#define EFLAGS_IOPL 0x3000 #define EFLAGS_NESTED_TASK 0x4000 #define EFLAGS_V86_MASK 0x20000 #define EFLAGS_ALIGN_CHECK 0x40000 diff --git a/reactos/ntoskrnl/ex/handle.c b/reactos/ntoskrnl/ex/handle.c index 70d181edd42..0cea474313e 100644 --- a/reactos/ntoskrnl/ex/handle.c +++ b/reactos/ntoskrnl/ex/handle.c @@ -59,7 +59,7 @@ ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, /* Direct index */ case 0: - /* Use level 1 and just get the entry directlry */ + /* Use level 1 and just get the entry directly */ Level1 = (PUCHAR)TableBase; Entry = (PVOID)&Level1[Handle.Value * (sizeof(HANDLE_TABLE_ENTRY) / @@ -210,8 +210,8 @@ ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable) PEPROCESS Process = HandleTable->QuotaProcess; ULONG i, j; ULONG_PTR TableCode = HandleTable->TableCode; - ULONG TableLevel = TableCode & 3; ULONG_PTR TableBase = TableCode & ~3; + ULONG TableLevel = (ULONG)(TableCode & 3); PHANDLE_TABLE_ENTRY Level1, *Level2, **Level3; PAGED_CODE(); diff --git a/reactos/ntoskrnl/ex/locale.c b/reactos/ntoskrnl/ex/locale.c index b8589dd3a29..b50eef2a396 100644 --- a/reactos/ntoskrnl/ex/locale.c +++ b/reactos/ntoskrnl/ex/locale.c @@ -74,7 +74,7 @@ ExpGetCurrentUserUILanguage(IN PWSTR MuiName, /* Success, is the value the right type? */ if (ValueInfo->Type == REG_SZ) { - /* It is. Initailize the data and convert it */ + /* It is. Initialize the data and convert it */ RtlInitUnicodeString(&ValueString, (PWSTR)ValueInfo->Data); Status = RtlUnicodeStringToInteger(&ValueString, 16, &Value); if (NT_SUCCESS(Status)) diff --git a/reactos/ntoskrnl/ke/i386/boot.S b/reactos/ntoskrnl/ke/i386/boot.S index 24dd19cde4b..1cf68a52f36 100644 --- a/reactos/ntoskrnl/ke/i386/boot.S +++ b/reactos/ntoskrnl/ke/i386/boot.S @@ -36,7 +36,7 @@ _KiSystemStartup: test dword ptr [esp+4], 0x80000000 jnz _KiSystemStartupReal@4 - /* FREELDR Boot: Cal the FreeLDR wrapper */ + /* FREELDR Boot: Call the FreeLDR wrapper */ jmp @KiRosPrepareForSystemStartup@8 .endfunc diff --git a/reactos/ntoskrnl/ke/i386/exp.c b/reactos/ntoskrnl/ke/i386/exp.c index 0af453bffb0..5bddfd7fa12 100644 --- a/reactos/ntoskrnl/ke/i386/exp.c +++ b/reactos/ntoskrnl/ke/i386/exp.c @@ -72,7 +72,7 @@ KeInitExceptions(VOID) extern KIDTENTRY KiIdt[MAXIMUM_IDTVECTOR]; /* Loop the IDT */ - for (i = 0; i <= MAXIMUM_IDTVECTOR; i ++) + for (i = 0; i <= MAXIMUM_IDTVECTOR; i++) { /* Save the current Selector */ FlippedSelector = KiIdt[i].Selector; @@ -113,7 +113,7 @@ KiRecordDr7(OUT PULONG Dr7Ptr, /* Check if the caller gave us a mask */ if (!DrMask) { - /* He didn't use the one from the thread */ + /* He didn't, use the one from the thread */ Mask = KeGetCurrentThread()->DispatcherHeader.DebugActive; } else @@ -266,7 +266,7 @@ ULONG NTAPI KiSsFromTrapFrame(IN PKTRAP_FRAME TrapFrame) { - /* If this was V86 Mode */ + /* Check if this was V86 Mode */ if (TrapFrame->EFlags & EFLAGS_V86_MASK) { /* Just return it */ @@ -274,7 +274,7 @@ KiSsFromTrapFrame(IN PKTRAP_FRAME TrapFrame) } else if (TrapFrame->SegCs & MODE_MASK) { - /* Usermode, return the User SS */ + /* User mode, return the User SS */ return TrapFrame->HardwareSegSs | RPL_MASK; } else @@ -599,7 +599,7 @@ KeContextToTrapFrame(IN PCONTEXT Context, } /* Check if thread has IOPL and force it enabled if so */ - if (KeGetCurrentThread()->Iopl) TrapFrame->EFlags |= 0x3000; + if (KeGetCurrentThread()->Iopl) TrapFrame->EFlags |= EFLAGS_IOPL; /* Restore IRQL */ if (OldIrql < APC_LEVEL) KeLowerIrql(OldIrql); diff --git a/reactos/ntoskrnl/ke/i386/thrdini.c b/reactos/ntoskrnl/ke/i386/thrdini.c index ec4043980a2..9428d6a0a8a 100644 --- a/reactos/ntoskrnl/ke/i386/thrdini.c +++ b/reactos/ntoskrnl/ke/i386/thrdini.c @@ -132,7 +132,7 @@ Ke386InitThreadWithContext(IN PKTHREAD Thread, Thread->NpxState = NPX_STATE_NOT_LOADED &~ CR0_MP; } - /* Disable any debug regiseters */ + /* Disable any debug registers */ Context->ContextFlags &= ~CONTEXT_DEBUG_REGISTERS; /* Setup the Trap Frame */ diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index 65ecc781906..2f3aec94e87 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -1836,7 +1836,7 @@ NotGdt: CheckRing3Io: /* Get EFLAGS and IOPL */ mov ebx, [ebp+KTRAP_FRAME_EFLAGS] - and ebx, 0x3000 + and ebx, EFLAGS_IOPL shr ebx, 12 /* Check the CS's RPL mask */ diff --git a/reactos/ntoskrnl/ke/i386/v86m_sup.S b/reactos/ntoskrnl/ke/i386/v86m_sup.S index 8db3c4c7cc3..fe64aef0dc7 100644 --- a/reactos/ntoskrnl/ke/i386/v86m_sup.S +++ b/reactos/ntoskrnl/ke/i386/v86m_sup.S @@ -215,7 +215,7 @@ _OpcodePUSHFV86: or eax, edx /* Add IOPL Mask */ - or eax, 0x3000 + or eax, EFLAGS_IOPL /* Get flat ESP */ movzx ecx, word ptr [ebp+KTRAP_FRAME_SS] @@ -277,7 +277,7 @@ NoPrefix: mov [ebp+KTRAP_FRAME_ESP], edx /* Mask out EFLAGS */ - and eax, ~0x3000 + and eax, ~EFLAGS_IOPL mov ebx, ebx and ebx, ~0x4000 and ecx, EFLAGS_ALIGN_CHECK + 0x4000 + EFLAGS_INTERRUPT_MASK @@ -353,7 +353,7 @@ _OpcodeINTnnV86: mov [ebp+KTRAP_FRAME_EFLAGS], edx /* Set the IOPL Mask */ - or eax, 0x3000 + or eax, EFLAGS_IOPL /* Get stack flat address */ movzx ecx, word ptr [ebp+KTRAP_FRAME_SS] @@ -450,7 +450,7 @@ _OpcodeIRETV86: MaskEFlags: /* Mask out EFLAGS */ - and ebx, ~(0x3000 + EFLAGS_VIF + 0x4000 + EFLAGS_VIP) + and ebx, ~(EFLAGS_IOPL + EFLAGS_VIF + 0x4000 + EFLAGS_VIP) mov ecx, ebx /* FIXME: Check for VME support */ diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index 042b0c987d0..a6ec97faea4 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -1142,7 +1142,7 @@ NtTerminateProcess(IN HANDLE ProcessHandle OPTIONAL, /* Lock the Process */ if (!ExAcquireRundownProtection(&Process->RundownProtect)) { - /* Failed to lock, fal */ + /* Failed to lock, fail */ ObDereferenceObject (Process); return STATUS_PROCESS_IS_TERMINATING; } @@ -1182,7 +1182,7 @@ NtTerminateProcess(IN HANDLE ProcessHandle OPTIONAL, /* Also make sure the caller gave us our handle */ if (KillByHandle) { - /* Dereference the project */ + /* Dereference the process */ ObDereferenceObject(Process); /* Terminate ourselves */