mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
- Replaced some common sequences of inline assembly with macros. Avoid
having compiler checks scattered all over the place. - Added some disabled code to KiDumpTrapFrame that dumps every address on the stack that could be a return address. This is quite handy for debugging crashes in modules compiled with fpo. svn path=/trunk/; revision=8615
This commit is contained in:
parent
e04ce16d15
commit
1fbda72a7a
10 changed files with 79 additions and 172 deletions
|
@ -53,13 +53,7 @@ NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
|||
#else
|
||||
PopSetSystemPowerState(PowerSystemShutdown);
|
||||
|
||||
#if defined(__GNUC__)
|
||||
__asm__("cli\n");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm cli
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386DisableInterrupts();
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
|
|
|
@ -135,6 +135,30 @@ VOID KeFreeGdtSelector(ULONG Entry);
|
|||
VOID
|
||||
NtEarlyInitVdm(VOID);
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define Ke386DisableInterrupts() __asm__("cli\n\t");
|
||||
#define Ke386EnableInterrupts() __asm__("sti\n\t");
|
||||
#define Ke386HaltProcessor() __asm__("hlt\n\t");
|
||||
#define Ke386GetPageTableDirectory(X) \
|
||||
__asm__("movl %%cr3,%0\n\t" : "=d" (X));
|
||||
#define Ke386SetPageTableDirectory(X) \
|
||||
__asm__("movl %0,%%cr3\n\t" \
|
||||
: /* no outputs */ \
|
||||
: "r" (X));
|
||||
#elif defined(_MSC_VER)
|
||||
#define Ke386DisableInterrupts() __asm cli
|
||||
#define Ke386EnableInterrupts() __asm sti
|
||||
#define Ke386HaltProcessor() __asm hlt
|
||||
#define Ke386GetPageTableDirectory(X) \
|
||||
__asm mov eax, cr3; \
|
||||
__asm mov X, eax;
|
||||
#define Ke386GetPageTableDirectory(X) \
|
||||
__asm mov eax, X; \
|
||||
__asm mov cr3, eax;
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
|
||||
#endif /* __ASM__ */
|
||||
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_KE_H */
|
||||
|
|
|
@ -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: bug.c,v 1.42 2004/03/06 22:24:13 dwelch Exp $
|
||||
/* $Id: bug.c,v 1.43 2004/03/09 21:49:53 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/bug.c
|
||||
|
@ -103,13 +103,7 @@ KeBugCheckWithTf(ULONG BugCheckCode,
|
|||
KdDebugState |= KD_DEBUG_SCREEN;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
__asm__("cli\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm cli
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386DisableInterrupts();
|
||||
|
||||
if (KeGetCurrentIrql() < DISPATCH_LEVEL)
|
||||
{
|
||||
|
@ -142,16 +136,7 @@ KeBugCheckWithTf(ULONG BugCheckCode,
|
|||
if (InBugCheck == 1)
|
||||
{
|
||||
DbgPrint("Recursive bug check halting now\n");
|
||||
for (;;)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
__asm__("hlt\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm hlt
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
}
|
||||
Ke386HaltProcessor();
|
||||
}
|
||||
InBugCheck = 1;
|
||||
KiDumpTrapFrame(Tf, BugCheckParameter1, BugCheckParameter2);
|
||||
|
@ -161,28 +146,14 @@ KeBugCheckWithTf(ULONG BugCheckCode,
|
|||
|
||||
if (KdDebuggerEnabled)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
__asm__("sti\n\t");
|
||||
Ke386EnableInterrupts();
|
||||
DbgBreakPointNoBugCheck();
|
||||
__asm__("cli\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm sti
|
||||
DbgBreakPointNoBugCheck();
|
||||
__asm cli
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386DisableInterrupts();
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
__asm__("hlt\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm hlt
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386HaltProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,13 +186,8 @@ KeBugCheckEx(ULONG BugCheckCode,
|
|||
KdDebugState |= KD_DEBUG_SCREEN;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
__asm__("cli\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm cli
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386DisableInterrupts();
|
||||
|
||||
if (KeGetCurrentIrql() < DISPATCH_LEVEL)
|
||||
{
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
|
||||
|
@ -253,16 +219,7 @@ KeBugCheckEx(ULONG BugCheckCode,
|
|||
if (InBugCheck == 1)
|
||||
{
|
||||
DbgPrint("Recursive bug check halting now\n");
|
||||
for (;;)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
__asm__("hlt\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm hlt
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
}
|
||||
Ke386HaltProcessor();
|
||||
}
|
||||
InBugCheck = 1;
|
||||
if (PsGetCurrentProcess() != NULL)
|
||||
|
@ -291,28 +248,14 @@ KeBugCheckEx(ULONG BugCheckCode,
|
|||
|
||||
if (KdDebuggerEnabled)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
__asm__("sti\n\t");
|
||||
Ke386EnableInterrupts();
|
||||
DbgBreakPointNoBugCheck();
|
||||
__asm__("cli\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm sti
|
||||
DbgBreakPointNoBugCheck();
|
||||
__asm cli
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386DisableInterrupts();
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
__asm__("hlt\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm hlt
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386HaltProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -318,6 +318,7 @@ KiDoubleFaultHandler(VOID)
|
|||
StackBase = (ULONG)&init_stack;
|
||||
}
|
||||
|
||||
/* Change to an #if 0 if no frames are printed because of fpo. */
|
||||
#if 1
|
||||
DbgPrint("Frames: ");
|
||||
Frame = (PULONG)OldTss->Ebp;
|
||||
|
@ -442,14 +443,7 @@ KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
|
|||
Tf->Cs&0xffff, Tf->Eip);
|
||||
print_address((PVOID)Tf->Eip);
|
||||
DbgPrint("\n");
|
||||
#if defined(__GNUC__)
|
||||
__asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
|
||||
#elif defined(_MSC_VER)
|
||||
__asm mov eax, cr3;
|
||||
__asm mov cr3_, eax;
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386GetPageTableDirectory(cr3_);
|
||||
DbgPrint("cr2 %x cr3 %x ", cr2, cr3_);
|
||||
DbgPrint("Proc: %x ",PsGetCurrentProcess());
|
||||
if (PsGetCurrentProcess() != NULL)
|
||||
|
@ -494,6 +488,7 @@ KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
|
|||
* Dump the stack frames
|
||||
*/
|
||||
DbgPrint("Frames: ");
|
||||
#if 0
|
||||
i = 1;
|
||||
Frame = (PULONG)Tf->Ebp;
|
||||
while (Frame != NULL)
|
||||
|
@ -506,7 +501,11 @@ KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
|
|||
DbgPrint("<INVALID>");
|
||||
break;
|
||||
}
|
||||
print_address(Eip);
|
||||
if (!print_address(Eip))
|
||||
{
|
||||
DbgPrint("<%X>", Eip);
|
||||
break;
|
||||
}
|
||||
Status = MmSafeCopyFromUser(&Frame, Frame, sizeof(Frame));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -515,6 +514,19 @@ KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
|
|||
i++;
|
||||
DbgPrint(" ");
|
||||
}
|
||||
#else
|
||||
i = 1;
|
||||
Frame = (PULONG)((ULONG_PTR)Esp0 + KTRAP_FRAME_EFLAGS);
|
||||
while (Frame < (PULONG)PsGetCurrentThread()->Tcb.StackBase && i < 50)
|
||||
{
|
||||
ULONG Address = *Frame;
|
||||
if (print_address((PVOID)Address))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
Frame++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ULONG
|
||||
|
@ -573,13 +585,7 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
|
|||
{
|
||||
if (Tf->Eflags & FLAG_IF)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
__asm__("sti\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm sti
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386EnableInterrupts();
|
||||
}
|
||||
Status = MmPageFault(Tf->Cs&0xffff,
|
||||
&Tf->Eip,
|
||||
|
@ -626,10 +632,13 @@ KeDumpStackFrames(PULONG Frame)
|
|||
i = 1;
|
||||
while (Frame != NULL)
|
||||
{
|
||||
print_address((PVOID)Frame[1]);
|
||||
if (!print_address((PVOID)Frame[1]))
|
||||
{
|
||||
DbgPrint("<%X>", (PVOID)Frame[1]);
|
||||
}
|
||||
Frame = (PULONG)Frame[0];
|
||||
i++;
|
||||
DbgPrint("\n");
|
||||
DbgPrint(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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: irq.c,v 1.40 2004/01/18 22:58:10 gdalsnes Exp $
|
||||
/* $Id: irq.c,v 1.41 2004/03/09 21:49:53 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/i386/irq.c
|
||||
|
@ -391,7 +391,7 @@ KiInterruptDispatch (ULONG Vector, PKIRQ_TRAPFRAME Trapframe)
|
|||
* Enable interrupts
|
||||
* NOTE: Only higher priority interrupts will get through
|
||||
*/
|
||||
__asm__("sti\n\t");
|
||||
Ke386EnableInterrupts();
|
||||
|
||||
/*
|
||||
* Actually call the ISR.
|
||||
|
@ -401,7 +401,7 @@ KiInterruptDispatch (ULONG Vector, PKIRQ_TRAPFRAME Trapframe)
|
|||
/*
|
||||
* Disable interrupts
|
||||
*/
|
||||
__asm__("cli\n\t");
|
||||
Ke386DisableInterrupts();
|
||||
|
||||
/*
|
||||
* Unmask the related irq
|
||||
|
@ -491,13 +491,7 @@ KiInterruptDispatch (ULONG irq, PKIRQ_TRAPFRAME Trapframe)
|
|||
* Enable interrupts
|
||||
* NOTE: Only higher priority interrupts will get through
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
__asm__("sti\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm sti
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386EnableInterrupts();
|
||||
|
||||
/*
|
||||
* Actually call the ISR.
|
||||
|
@ -523,13 +517,7 @@ KiInterruptDispatch (ULONG irq, PKIRQ_TRAPFRAME Trapframe)
|
|||
/*
|
||||
* End the system interrupt.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
__asm__("cli\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm cli
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386DisableInterrupts();
|
||||
|
||||
HalEndSystemInterrupt (old_level, 0);
|
||||
|
||||
|
|
|
@ -93,13 +93,8 @@ KeApplicationProcessorInit(VOID)
|
|||
*/
|
||||
Ki386InitializeLdt();
|
||||
|
||||
#if defined(__GNUC__)
|
||||
__asm__ __volatile__ ("sti\n\t");
|
||||
#elif defined(_MSC_VER)
|
||||
__asm sti
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
/* Now we can enable interrupts. */
|
||||
Ke386EnableInterrupts();
|
||||
}
|
||||
|
||||
VOID INIT_FUNCTION
|
||||
|
|
|
@ -126,14 +126,7 @@ Ki386ApplicationProcessorInitializeTSS(VOID)
|
|||
Id = KeGetCurrentProcessorNumber();
|
||||
Gdt = KeGetCurrentKPCR()->GDT;
|
||||
|
||||
#if defined(__GNUC__)
|
||||
__asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
|
||||
#elif defined(_MSC_VER)
|
||||
__asm mov eax, cr3;
|
||||
__asm mov cr3_, eax;
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386GetPageTableDirectory(cr3_);
|
||||
|
||||
Tss = ExAllocatePool(NonPagedPool, sizeof(KTSS));
|
||||
TrapTss = ExAllocatePool(NonPagedPool, sizeof(KTSSNOIOPM));
|
||||
|
@ -214,14 +207,7 @@ Ki386BootInitializeTSS(VOID)
|
|||
extern unsigned int trap_stack, trap_stack_top;
|
||||
unsigned int base, length;
|
||||
|
||||
#if defined(__GNUC__)
|
||||
__asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
|
||||
#elif defined(_MSC_VER)
|
||||
__asm mov eax, cr3;
|
||||
__asm mov cr3_, eax;
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386GetPageTableDirectory(cr3_);
|
||||
|
||||
Ki386TssArray[0] = &KiBootTss;
|
||||
Ki386TrapTssArray[0] = &KiBootTrapTss;
|
||||
|
|
|
@ -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: process.c,v 1.18 2003/12/30 18:52:04 fireball Exp $
|
||||
/* $Id: process.c,v 1.19 2004/03/09 21:49:53 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/process.c
|
||||
|
@ -81,16 +81,7 @@ KeAttachProcess (PEPROCESS Process)
|
|||
CurrentThread->ThreadsProcess = Process;
|
||||
PageDir = Process->Pcb.DirectoryTableBase.u.LowPart;
|
||||
DPRINT("Switching process context to %x\n",PageDir);
|
||||
#if defined(__GNUC__)
|
||||
__asm__("movl %0,%%cr3\n\t"
|
||||
: /* no outputs */
|
||||
: "r" (PageDir));
|
||||
#elif defined(_MSC_VER)
|
||||
__asm mov eax, PageDir;
|
||||
__asm mov cr3, eax;
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386SetPageTableDirectory(PageDir);
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
|
||||
|
@ -121,16 +112,7 @@ KeDetachProcess (VOID)
|
|||
CurrentThread->ThreadsProcess = CurrentThread->OldProcess;
|
||||
CurrentThread->OldProcess = NULL;
|
||||
PageDir = CurrentThread->ThreadsProcess->Pcb.DirectoryTableBase.u.LowPart;
|
||||
#if defined(__GNUC__)
|
||||
__asm__("movl %0,%%cr3\n\t"
|
||||
: /* no inputs */
|
||||
: "r" (PageDir));
|
||||
#elif defined(_MSC_VER)
|
||||
__asm mov eax, PageDir;
|
||||
__asm mov cr3, eax;
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386SetPageTableDirectory(PageDir);
|
||||
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
|
|
|
@ -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: page.c,v 1.62 2004/01/05 14:28:21 weiden Exp $
|
||||
/* $Id: page.c,v 1.63 2004/03/09 21:49:53 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/i386/page.c
|
||||
|
@ -78,15 +78,7 @@ PULONG
|
|||
MmGetPageDirectory(VOID)
|
||||
{
|
||||
unsigned int page_dir=0;
|
||||
#if defined(__GNUC__)
|
||||
__asm__("movl %%cr3,%0\n\t"
|
||||
: "=r" (page_dir));
|
||||
#elif defined(_MSC_VER)
|
||||
__asm mov eax, cr3;
|
||||
__asm mov page_dir, eax;
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386GetPageTableDirectory(page_dir);
|
||||
return((PULONG)page_dir);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,13 +40,7 @@ PsIdleThreadMain(PVOID Context)
|
|||
}
|
||||
NtYieldExecution();
|
||||
|
||||
#if defined(__GNUC__)
|
||||
__asm__( "hlt" );
|
||||
#elif defined(_MSC_VER)
|
||||
__asm hlt
|
||||
#else
|
||||
#error Unknown compiler for inline assembler
|
||||
#endif
|
||||
Ke386HaltProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue