Support multiple debug targets at the same time.

E.g. to use both serial logging on COM1 and GDB remote debugging on COM2 use:
/DEBUGPORT=COM1 /COM2 /DEBUGPORT=GDB
Made PICE compile with GCC 3.2.

svn path=/trunk/; revision=2944
This commit is contained in:
Casper Hornstrup 2002-05-08 17:05:32 +00:00
parent f82f2801bb
commit e37bad87b8
23 changed files with 833 additions and 609 deletions

View file

@ -226,9 +226,11 @@ void process_stabs(
SymbolFileHeader.ulOffsetToSrcFiles = sizeof(PICE_SYMBOLFILE_HEADER)+sectionHeadersSize+nGlobalLen+nGlobalStrLen+nStabLen+nStrLen;
SymbolFileHeader.ulNumberOfSrcFiles = ulCurrentSrcFile;
printf("sectionHeaderSize: %ld, nGlobalLen: %ld, nGlobalStrLen: %ld, nStabLen: %ld,
nStrLen: %ld, ulCurrentSrcFile: %ld, ulOffsetToStabs: %ld \n", sectionHeadersSize, nGlobalLen, nGlobalStrLen,
printf("sectionHeaderSize: %ld, nGlobalLen: %ld, nGlobalStrLen: %ld, nStabLen: %ld, "
"nStrLen: %ld, ulCurrentSrcFile: %ld, ulOffsetToStabs: %ld\n",
sectionHeadersSize, nGlobalLen, nGlobalStrLen,
nStabLen, nStrLen, ulCurrentSrcFile, SymbolFileHeader.ulOffsetToStabs);
WriteFile(fileout,&SymbolFileHeader,sizeof(PICE_SYMBOLFILE_HEADER),&wrote, NULL);
WriteFile(fileout,section,sectionHeadersSize,&wrote, NULL);
WriteFile(fileout,pGlobals,nGlobalLen,&wrote, NULL);

View file

@ -694,11 +694,11 @@ void RevirtualizeBreakpointsForModule(PDEBUG_MODULE pMod)
// NewInt3Handler()
//
//*************************************************************************
__asm__ ("
NewInt3Handler:
pushl $" STR(REASON_INT3) "
// call debugger loop
jmp NewInt31Handler
__asm__ ("\n\t \
NewInt3Handler:\n\t \
pushl $" STR(REASON_INT3) "\n\t \
// call debugger loop\n\t \
jmp NewInt31Handler\n\t \
");

View file

@ -59,31 +59,31 @@ void HandleDoubleFault(FRAME* ptr)
// NewDblFltHandler()
//
//*************************************************************************
__asm__ ("
NewDblFltHandler:
pushfl
cli
cld
pushal
pushl %ds
// setup default data selectors
movw %ss,%ax
movw %ax,%ds
// get frame ptr
lea 40(%esp),%eax
pushl %eax
call _HandleDoubleFault
addl $4,%esp
popl %ds
popal
popfl
// remove error code from stack and replace with reason code
movl $" STR(REASON_DOUBLE_FAULT) ",(%esp)
// call debugger loop
jmp NewInt31Handler");
__asm__ (" \
NewDblFltHandler:\n\t \
pushfl\n\t \
cli;\n\t \
cld;\n\t \
pushal;\n\t \
pushl %ds;\n\t \
\n\t \
// setup default data selectors\n\t \
movw %ss,%ax\n\t \
movw %ax,%ds\n\t \
\n\t \
// get frame ptr\n\t \
lea 40(%esp),%eax\n\t \
pushl %eax\n\t \
call _HandleDoubleFault\n\t \
addl $4,%esp\n\t \
\n\t \
popl %ds\n\t \
popal\n\t \
popfl\n\t \
// remove error code from stack and replace with reason code\n\t \
movl $" STR(REASON_DOUBLE_FAULT) ",(%esp)\n\t \
// call debugger loop\n\t \
jmp NewInt31Handler\n\t");
//*************************************************************************

View file

@ -59,30 +59,30 @@ void HandleGPFault(FRAME* ptr)
// NewGPFaultHandler()
//
//*************************************************************************
__asm__ ("
NewGPFaultHandler:
pushfl
cli
cld
pushal
pushl %ds
// setup default data selectors
movw %ss,%ax
movw %ax,%ds
// get frame ptr
lea 40(%esp),%eax
pushl %eax
call _HandleGPFault
addl $4,%esp
popl %ds
popal
popfl
// remove error code from stack and replace with reason code
movl $" STR(REASON_GP_FAULT) ",(%esp)
// call debugger loop
__asm__ ("\n\t \
NewGPFaultHandler:\n\t \
pushfl\n\t \
cli\n\t \
cld\n\t \
pushal\n\t \
pushl %ds\n\t \
\n\t \
// setup default data selectors\n\t \
movw %ss,%ax\n\t \
movw %ax,%ds\n\t \
\n\t \
// get frame ptr\n\t \
lea 40(%esp),%eax\n\t \
pushl %eax\n\t \
call _HandleGPFault\n\t \
addl $4,%esp\n\t \
\n\t \
popl %ds\n\t \
popal\n\t \
popfl\n\t \
// remove error code from stack and replace with reason code\n\t \
movl $" STR(REASON_GP_FAULT) ",(%esp)\n\t \
// call debugger loop\n\t \
jmp NewInt31Handler");

View file

@ -249,9 +249,9 @@ BOOLEAN InitPICE(void)
CurrentEIP = (ULONG)RealIsr;
CurrentDS = CurrentSS = GLOBAL_DATA_SEGMENT;
__asm__("
mov %%esp,%%eax
mov %%eax,_CurrentESP
__asm__("\n\t \
mov %%esp,%%eax\n\t \
mov %%eax,_CurrentESP\n\t \
":::"eax");
@ -259,13 +259,13 @@ BOOLEAN InitPICE(void)
Ver(NULL);
// disable HW breakpoints
__asm__("
xorl %%eax,%%eax
mov %%eax,%%dr6
mov %%eax,%%dr7
mov %%dr0,%%eax
mov %%dr1,%%eax
mov %%dr2,%%eax
__asm__("\n\t \
xorl %%eax,%%eax\n\t \
mov %%eax,%%dr6\n\t \
mov %%eax,%%dr7\n\t \
mov %%dr0,%%eax\n\t \
mov %%dr1,%%eax\n\t \
mov %%dr2,%%eax\n\t \
mov %%dr3,%%eax"
:::"eax"
);
@ -290,12 +290,12 @@ BOOLEAN InitPICE(void)
DPRINT((0,"about to do initial break...\n"));
// simulate an initial break
__asm__("
pushfl
pushl %cs
pushl $initialreturnpoint
pushl $" STR(REASON_CTRLF) "
jmp NewInt31Handler
__asm__("\n\t \
pushfl\n\t \
pushl %cs\n\t \
pushl $initialreturnpoint\n\t \
pushl $" STR(REASON_CTRLF) "\n\t \
jmp NewInt31Handler\n\t \
initialreturnpoint:");
}
else

View file

@ -2029,8 +2029,8 @@ COMMAND_PROTOTYPE(Ver)
COMMAND_PROTOTYPE(Hboot)
{
// nudge the reset line through keyboard controller
__asm__("
movb $0xFE,%al
__asm__("\n\t \
movb $0xFE,%al\n\t \
outb %al,$0x64");
// never gets here
return TRUE;

View file

@ -101,12 +101,12 @@ BOOLEAN PiceKbdIsr (
bEnterNow=TRUE;
bControl=FALSE;
// simulate an initial break
__asm__("
pushfl
pushl %cs
pushl $returnpoint
pushl $" STR(REASON_CTRLF) "
jmp NewInt31Handler
__asm__("\n\t \
pushfl\n\t \
pushl %cs\n\t \
pushl $returnpoint\n\t \
pushl $" STR(REASON_CTRLF) "\n\t \
jmp NewInt31Handler\n\t \
returnpoint:");
*pByte = 0x1d | 0x80 | 0x7f;
bForward=TRUE;

View file

@ -290,71 +290,71 @@ ULONG HandlePageFault(FRAME* ptr)
// NewIntEHandler()
//
//*************************************************************************
__asm__ ("
NewIntEHandler:
pushfl
cli
cld
pushal
pushl %ds
// setup default data selectors
movw %ss,%ax
movw %ax,%ds
/*
* Load the PCR selector.
*/
movl %fs, %eax
movl %eax, _OLD_PCR
movl _PCR_SEL, %eax
movl %eax, %fs
// get frame ptr
lea 40(%esp),%eax
pushl %eax
call _HandlePageFault
addl $4,%esp
pushl %eax
movl _OLD_PCR, %eax
movl %eax, %fs
popl %eax
cmpl $0,%eax
je call_old_inte_handler
cmpl $2,%eax
je call_handler_unknown_reason
popl %ds
popal
popfl
// remove error code. will be restored later when we call
// original handler again.
addl $4,%esp
// call debugger loop
pushl $" STR(REASON_PAGEFAULT) "
jmp NewInt31Handler
call_old_inte_handler:
popl %ds
popal
popfl
// chain to old handler
.byte 0x2e
jmp *_OldIntEHandler
call_handler_unknown_reason:
popl %ds
popal
popfl
// remove error code. will be restored later when we call
// original handler again.
addl $4,%esp
// call debugger loop
pushl $" STR(REASON_INTERNAL_ERROR) "
jmp NewInt31Handler
__asm__ ("\n\t \
NewIntEHandler:\n\t \
pushfl\n\t \
cli\n\t \
cld\n\t \
pushal\n\t \
pushl %ds\n\t \
\n\t \
// setup default data selectors\n\t \
movw %ss,%ax\n\t \
movw %ax,%ds\n\t \
\n\t \
/*\n\t \
* Load the PCR selector.\n\t \
*/\n\t \
movl %fs, %eax\n\t \
movl %eax, _OLD_PCR\n\t \
movl _PCR_SEL, %eax\n\t \
movl %eax, %fs\n\t \
\n\t \
// get frame ptr\n\t \
lea 40(%esp),%eax\n\t \
pushl %eax\n\t \
call _HandlePageFault\n\t \
addl $4,%esp\n\t \
\n\t \
pushl %eax\n\t \
movl _OLD_PCR, %eax\n\t \
movl %eax, %fs\n\t \
popl %eax\n\t \
\n\t \
cmpl $0,%eax\n\t \
je call_old_inte_handler\n\t \
\n\t \
cmpl $2,%eax\n\t \
je call_handler_unknown_reason\n\t \
\n\t \
popl %ds\n\t \
popal\n\t \
popfl\n\t \
// remove error code. will be restored later when we call\n\t \
// original handler again.\n\t \
addl $4,%esp\n\t \
// call debugger loop\n\t \
pushl $" STR(REASON_PAGEFAULT) "\n\t \
jmp NewInt31Handler\n\t \
\n\t \
call_old_inte_handler:\n\t \
popl %ds\n\t \
popal\n\t \
popfl\n\t \
// chain to old handler\n\t \
.byte 0x2e\n\t \
jmp *_OldIntEHandler\n\t \
\n\t \
call_handler_unknown_reason:\n\t \
popl %ds\n\t \
popal\n\t \
popfl\n\t \
// remove error code. will be restored later when we call\n\t \
// original handler again.\n\t \
addl $4,%esp\n\t \
// call debugger loop\n\t \
pushl $" STR(REASON_INTERNAL_ERROR) "\n\t \
jmp NewInt31Handler\n\t \
");

View file

@ -439,17 +439,17 @@ void DebuggerShell(void)
ulLastLineDisplayedOffset = 0;
PrintRingBuffer(wWindow[OUTPUT_WINDOW].cy-1);
// setup a safe stack for parsing
__asm__ __volatile__("
movl %2,%%eax
movl %%esp,%%ebx
mov %%ebx,%0
leal _aulNewStack,%%ebx
addl $0x1FFF0,%%ebx
movl %%ebx,%%esp
pushl $0
pushl %%eax
call _Parse
movl %0,%%ebx
__asm__ __volatile__("\n\t \
movl %2,%%eax\n\t \
movl %%esp,%%ebx\n\t \
mov %%ebx,%0\n\t \
leal _aulNewStack,%%ebx\n\t \
addl $0x1FFF0,%%ebx\n\t \
movl %%ebx,%%esp\n\t \
pushl $0\n\t \
pushl %%eax\n\t \
call _Parse\n\t \
movl %0,%%ebx\n\t \
movl %%ebx,%%esp"
:"=m" (ulOldStack)
:"m" (ulOldStack),"m" (ucCommandBuffer)
@ -528,17 +528,17 @@ void DebuggerShell(void)
PrintRingBuffer(wWindow[OUTPUT_WINDOW].cy-1);
// setup a safe stack for parsing
__asm__ __volatile__("
movl %2,%%eax
movl %%esp,%%ebx
mov %%ebx,%0
leal _aulNewStack,%%ebx
addl $0x1FFF0,%%ebx
movl %%ebx,%%esp
pushl $1
pushl %%eax
call _Parse
movl %0,%%ebx
__asm__ __volatile__("\n\t \
movl %2,%%eax\n\t \
movl %%esp,%%ebx\n\t \
mov %%ebx,%0\n\t \
leal _aulNewStack,%%ebx\n\t \
addl $0x1FFF0,%%ebx\n\t \
movl %%ebx,%%esp\n\t \
pushl $1\n\t \
pushl %%eax\n\t \
call _Parse\n\t \
movl %0,%%ebx\n\t \
movl %%ebx,%%esp"
:"=m" (ulOldStack)
:"m" (ulOldStack),"m" (ucCommandBuffer)
@ -1138,11 +1138,11 @@ void RealIsr(ULONG dwReasonForBreak)
DPRINT((0,"REASON_HARDWARE_BP\n"));
// disable HW breakpoints
__asm__("
movl %%dr6,%%eax
movl %%eax,%0
xorl %%eax,%%eax
movl %%eax,%%dr6
__asm__("\n\t \
movl %%dr6,%%eax\n\t \
movl %%eax,%0\n\t \
xorl %%eax,%%eax\n\t \
movl %%eax,%%dr6\n\t \
movl %%eax,%%dr7"
:"=m" (ulReason)
:
@ -1399,32 +1399,32 @@ void RealIsr(ULONG dwReasonForBreak)
DPRINT((0,"RealIsr(): saving registers\n"));
// save the extended regs
__asm__ __volatile__
("
pushl %eax
movw %es,%ax
movw %ax,_CurrentES
//movw %fs,%ax
//movw %ax,_CurrentFS
movw %gs,%ax
movw %ax,_CurrentGS
movl %dr0,%eax
movl %eax,_CurrentDR0
movl %dr1,%eax
movl %eax,_CurrentDR1
movl %dr2,%eax
movl %eax,_CurrentDR2
movl %dr3,%eax
movl %eax,_CurrentDR3
movl %dr6,%eax
movl %eax,_CurrentDR6
movl %dr7,%eax
movl %eax,_CurrentDR7
movl %cr0,%eax
movl %eax,_CurrentCR0
movl %cr2,%eax
movl %eax,_CurrentCR2
movl %cr3,%eax
movl %eax,_CurrentCR3
("\n\t \
pushl %eax\n\t \
movw %es,%ax\n\t \
movw %ax,_CurrentES\n\t \
//movw %fs,%ax\n\t \
//movw %ax,_CurrentFS\n\t \
movw %gs,%ax\n\t \
movw %ax,_CurrentGS\n\t \
movl %dr0,%eax\n\t \
movl %eax,_CurrentDR0\n\t \
movl %dr1,%eax\n\t \
movl %eax,_CurrentDR1\n\t \
movl %dr2,%eax\n\t \
movl %eax,_CurrentDR2\n\t \
movl %dr3,%eax\n\t \
movl %eax,_CurrentDR3\n\t \
movl %dr6,%eax\n\t \
movl %eax,_CurrentDR6\n\t \
movl %dr7,%eax\n\t \
movl %eax,_CurrentDR7\n\t \
movl %cr0,%eax\n\t \
movl %eax,_CurrentCR0\n\t \
movl %cr2,%eax\n\t \
movl %eax,_CurrentCR2\n\t \
movl %cr3,%eax\n\t \
movl %eax,_CurrentCR3\n\t \
popl %eax"
);
@ -1464,174 +1464,174 @@ common_return_point:
}
__asm__(".global NewInt31Handler
NewInt31Handler:
cli
cld
pushl %eax
pushl %ds
movw %ss,%ax
mov %ax,%ds
mov 0x4(%esp),%eax
movl %eax,_CurrentEAX
movl %ebx,_CurrentEBX
movl %ecx,_CurrentECX
movl %edx,_CurrentEDX
movl %esi,_CurrentESI
movl %edi,_CurrentEDI
movl %ebp,_CurrentEBP
movl (%esp),%eax
movw %ax,_CurrentDS
// test for V86 mode
testl $0x20000,5*4(%esp)
jz notV86
int $0x03
notV86:
// test if stack switched (ring3->ring0 transition)
// stack is switched if orig. SS is not global kernel code segment
movl 4*4(%esp),%eax
cmpw $" STR(GLOBAL_CODE_SEGMENT) ",%ax
je notswitched
// switched stack
movl 6*4(%esp),%eax
mov %eax,_CurrentESP
mov 7*4(%esp),%eax
movzwl %ax,%eax
mov %ax,_CurrentSS
jmp afterswitch
notswitched:
// didn't switch stack
movl %esp,_CurrentESP
addl $24,_CurrentESP
movw %ss,%ax
movzwl %ax,%eax
mov %ax,_CurrentSS
afterswitch:
// save EIP
mov 3*4(%esp),%eax
mov %eax,_CurrentEIP
//save CS
mov 4*4(%esp),%eax
movzwl %ax,%eax
movw %ax,_CurrentCS
// save flags
movl 5*4(%esp),%eax
andl $0xFFFFFEFF,%eax
movl %eax,_CurrentEFL
pushal
// get reason code
mov 0x28(%esp),%ebx
/*
* Load the PCR selector.
*/
movl %fs, %eax
movl %eax, _OLD_PCR
movl _PCR_SEL, %eax
movl %eax, %fs
// setup a large work stack
movl %esp,%eax
movl %eax,_ulRealStackPtr
pushl %ebx
call _RealIsr
addl $4,%esp
pushl %eax
movl _OLD_PCR, %eax
movl %eax, %fs
popl %eax
// restore all regs
popal
// do an EOI to IRQ controller (because we definitely pressed some key)
// TODO: SMP APIC support
movb $0x20,%al
outb %al,$0x20
popl %ds
popl %eax
// remove reason code
addl $4,%esp
// make EAX available
pushl %eax
// modify or restore EFLAGS
.byte 0x2e
mov _CurrentEFL,%eax
mov %eax,3*4(%esp)
.byte 0x2e
movzwl _CurrentCS,%eax
mov %eax,2*4(%esp)
.byte 0x2e
mov _CurrentEIP,%eax
mov %eax,1*4(%esp)
// restore EAX
popl %eax
// do we need to call old INT1 handler
.byte 0x2e
cmp $0,_dwCallOldInt1Handler
je do_iret2
// call INT3 handler
.byte 0x2e
jmp *_OldInt1Handler
do_iret2:
// do we need to call old INT3 handler
.byte 0x2e
cmp $0,_dwCallOldInt3Handler
je do_iret1
// call INT3 handler
.byte 0x2e
jmp *_OldInt3Handler
do_iret1:
// do we need to call old pagefault handler
.byte 0x2e
cmp $0,_dwCallOldIntEHandler
je do_iret3
// call old pagefault handler
.byte 0x2e
pushl _error_code
.byte 0x2e
jmp *_OldIntEHandler
do_iret3:
// do we need to call old general protection fault handler
.byte 0x2e
cmp $0,_dwCallOldGPFaultHandler
je do_iret
// call old pagefault handler
.byte 0x2e
pushl _error_code
.byte 0x2e
jmp *_OldGPFaultHandler
do_iret:
//ei
//int3
__asm__(".global NewInt31Handler\n\t \
NewInt31Handler:\n\t \
cli\n\t \
cld\n\t \
\n\t \
pushl %eax\n\t \
pushl %ds\n\t \
\n\t \
movw %ss,%ax\n\t \
mov %ax,%ds\n\t \
\n\t \
mov 0x4(%esp),%eax\n\t \
movl %eax,_CurrentEAX\n\t \
movl %ebx,_CurrentEBX\n\t \
movl %ecx,_CurrentECX\n\t \
movl %edx,_CurrentEDX\n\t \
movl %esi,_CurrentESI\n\t \
movl %edi,_CurrentEDI\n\t \
movl %ebp,_CurrentEBP\n\t \
movl (%esp),%eax\n\t \
movw %ax,_CurrentDS\n\t \
\n\t \
// test for V86 mode\n\t \
testl $0x20000,5*4(%esp)\n\t \
jz notV86\n\t \
\n\t \
int $0x03\n\t \
\n\t \
notV86:\n\t \
// test if stack switched (ring3->ring0 transition)\n\t \
// stack is switched if orig. SS is not global kernel code segment\n\t \
movl 4*4(%esp),%eax\n\t \
cmpw $" STR(GLOBAL_CODE_SEGMENT) ",%ax\n\t \
je notswitched\n\t \
\n\t \
// switched stack\n\t \
movl 6*4(%esp),%eax\n\t \
mov %eax,_CurrentESP\n\t \
mov 7*4(%esp),%eax\n\t \
movzwl %ax,%eax\n\t \
mov %ax,_CurrentSS\n\t \
jmp afterswitch\n\t \
\n\t \
notswitched:\n\t \
// didn't switch stack\n\t \
movl %esp,_CurrentESP\n\t \
addl $24,_CurrentESP\n\t \
movw %ss,%ax\n\t \
movzwl %ax,%eax\n\t \
mov %ax,_CurrentSS\n\t \
\n\t \
afterswitch:\n\t \
// save EIP\n\t \
mov 3*4(%esp),%eax\n\t \
mov %eax,_CurrentEIP\n\t \
//save CS\n\t \
mov 4*4(%esp),%eax\n\t \
movzwl %ax,%eax\n\t \
movw %ax,_CurrentCS\n\t \
// save flags\n\t \
movl 5*4(%esp),%eax\n\t \
andl $0xFFFFFEFF,%eax\n\t \
movl %eax,_CurrentEFL\n\t \
\n\t \
pushal\n\t \
\n\t \
// get reason code\n\t \
mov 0x28(%esp),%ebx\n\t \
\n\t \
/*\n\t \
* Load the PCR selector.\n\t \
*/\n\t \
\n\t \
movl %fs, %eax\n\t \
movl %eax, _OLD_PCR\n\t \
movl _PCR_SEL, %eax\n\t \
movl %eax, %fs\n\t \
\n\t \
// setup a large work stack\n\t \
movl %esp,%eax\n\t \
movl %eax,_ulRealStackPtr\n\t \
\n\t \
pushl %ebx\n\t \
call _RealIsr\n\t \
addl $4,%esp\n\t \
\n\t \
pushl %eax\n\t \
movl _OLD_PCR, %eax\n\t \
movl %eax, %fs\n\t \
popl %eax\n\t \
\n\t \
// restore all regs\n\t \
popal\n\t \
\n\t \
// do an EOI to IRQ controller (because we definitely pressed some key)\n\t \
// TODO: SMP APIC support\n\t \
movb $0x20,%al\n\t \
outb %al,$0x20\n\t \
\n\t \
popl %ds\n\t \
popl %eax\n\t \
\n\t \
// remove reason code\n\t \
addl $4,%esp\n\t \
\n\t \
// make EAX available\n\t \
pushl %eax\n\t \
\n\t \
// modify or restore EFLAGS\n\t \
.byte 0x2e\n\t \
mov _CurrentEFL,%eax\n\t \
mov %eax,3*4(%esp)\n\t \
.byte 0x2e\n\t \
movzwl _CurrentCS,%eax\n\t \
mov %eax,2*4(%esp)\n\t \
.byte 0x2e\n\t \
mov _CurrentEIP,%eax\n\t \
mov %eax,1*4(%esp)\n\t \
\n\t \
// restore EAX\n\t \
popl %eax\n\t \
\n\t \
// do we need to call old INT1 handler\n\t \
.byte 0x2e\n\t \
cmp $0,_dwCallOldInt1Handler\n\t \
je do_iret2\n\t \
\n\t \
// call INT3 handler\n\t \
.byte 0x2e\n\t \
jmp *_OldInt1Handler\n\t \
\n\t \
do_iret2:\n\t \
// do we need to call old INT3 handler\n\t \
.byte 0x2e\n\t \
cmp $0,_dwCallOldInt3Handler\n\t \
je do_iret1\n\t \
\n\t \
// call INT3 handler\n\t \
.byte 0x2e\n\t \
jmp *_OldInt3Handler\n\t \
\n\t \
do_iret1:\n\t \
// do we need to call old pagefault handler\n\t \
.byte 0x2e\n\t \
cmp $0,_dwCallOldIntEHandler\n\t \
je do_iret3\n\t \
\n\t \
// call old pagefault handler\n\t \
.byte 0x2e\n\t \
pushl _error_code\n\t \
.byte 0x2e\n\t \
jmp *_OldIntEHandler\n\t \
\n\t \
do_iret3:\n\t \
// do we need to call old general protection fault handler\n\t \
.byte 0x2e\n\t \
cmp $0,_dwCallOldGPFaultHandler\n\t \
je do_iret\n\t \
\n\t \
// call old pagefault handler\n\t \
.byte 0x2e\n\t \
pushl _error_code\n\t \
.byte 0x2e\n\t \
jmp *_OldGPFaultHandler\n\t \
\n\t \
do_iret:\n\t \
//ei\n\t \
//int3\n\t \
iretl ");
//
@ -1639,18 +1639,18 @@ do_iret:
//
// IDTs keyboard IRQ points here
//
__asm__ ("
NewGlobalInt31Handler:
.byte 0x2e
cmpb $0,_bEnterNow
jne dotheenter
// chain to old handler
.byte 0x2e
jmp *_OldGlobalInt31Handler
dotheenter:
pushl $" STR(REASON_CTRLF) "
__asm__ ("\n\t \
NewGlobalInt31Handler:\n\t \
.byte 0x2e\n\t \
cmpb $0,_bEnterNow\n\t \
jne dotheenter\n\t \
\n\t \
// chain to old handler\n\t \
.byte 0x2e\n\t \
jmp *_OldGlobalInt31Handler\n\t \
\n\t \
dotheenter:\n\t \
pushl $" STR(REASON_CTRLF) "\n\t \
jmp NewInt31Handler "
);

View file

@ -156,39 +156,39 @@ void CSyscallHandler(FRAME_SYSCALL* ptr,ULONG ulSysCall,ULONG ebx)
*/
}
__asm__ ("
NewSyscallHandler:
// save used regs
pushfl
cli
cld
pushal
pushl %ds
// push the syscall number
pushl %ebx
pushl %eax
// frame ptr
lea 48(%esp),%eax
pushl %eax
// setup default data selectors
movw %ss,%ax
movw %ax,%ds
call _CSyscallHandler
// remove pushed params
add $12,%esp
// restore used regs
popl %ds
popal
popfl
// chain to old handler
.byte 0x2e
__asm__ ("\n\t \
NewSyscallHandler:\n\t \
// save used regs\n\t \
pushfl\n\t \
cli\n\t \
cld\n\t \
pushal\n\t \
pushl %ds\n\t \
\n\t \
// push the syscall number\n\t \
pushl %ebx\n\t \
pushl %eax\n\t \
\n\t \
// frame ptr\n\t \
lea 48(%esp),%eax\n\t \
pushl %eax\n\t \
\n\t \
// setup default data selectors\n\t \
movw %ss,%ax\n\t \
movw %ax,%ds\n\t \
\n\t \
call _CSyscallHandler\n\t \
\n\t \
// remove pushed params\n\t \
add $12,%esp\n\t \
\n\t \
// restore used regs\n\t \
popl %ds\n\t \
popal\n\t \
popfl\n\t \
\n\t \
// chain to old handler\n\t \
.byte 0x2e\n\t \
jmp *_OldSyscallHandler");
void InstallSyscallHook(void)

View file

@ -60,21 +60,21 @@ BOOLEAN InstallTraceHook(void)
//this asm function must be at least second in the file. otherwise gcc does not
//generate correct code.
__asm__("
NewInt1Handler:
pushl %eax
movl %dr6,%eax
testl $(1<<14),%eax
jz exceptionnotsinglestep
popl %eax
pushl $" STR(REASON_SINGLESTEP) "
jmp NewInt31Handler
exceptionnotsinglestep:
popl %eax
pushl $" STR(REASON_HARDWARE_BP) "
jmp NewInt31Handler
__asm__("\n\t \
NewInt1Handler:\n\t \
pushl %eax\n\t \
movl %dr6,%eax\n\t \
testl $(1<<14),%eax\n\t \
jz exceptionnotsinglestep\n\t \
\n\t \
popl %eax\n\t \
pushl $" STR(REASON_SINGLESTEP) "\n\t \
jmp NewInt31Handler\n\t \
\n\t \
exceptionnotsinglestep:\n\t \
popl %eax\n\t \
pushl $" STR(REASON_HARDWARE_BP) "\n\t \
jmp NewInt31Handler\n\t \
");
void DeInstallTraceHook(void)

View file

@ -812,8 +812,8 @@ ULONG GetLinearAddress(USHORT Segment,ULONG Offset)
{
DPRINT((0,"GetLinearAddress(): Segment is in LDT\n"));
// get LDT selector
__asm__("
sldt %%ax
__asm__("\n\t \
sldt %%ax\n\t \
mov %%ax,%0"
:"=m" (Segment));
if(Segment)
@ -900,12 +900,12 @@ void SetHardwareBreakPoint(ULONG ulAddress,ULONG ulReg)
DPRINT((0,"mask = %x\n",mask));
__asm__ __volatile__
("
xorl %%eax,%%eax
mov %%eax,%%dr6
mov %%dr7,%%eax
orl %0,%%eax
mov %%eax,%%dr7
("\n\t \
xorl %%eax,%%eax\n\t \
mov %%eax,%%dr6\n\t \
mov %%dr7,%%eax\n\t \
orl %0,%%eax\n\t \
mov %%eax,%%dr7\n\t \
"
:
:"m" (mask)
@ -915,9 +915,9 @@ void SetHardwareBreakPoint(ULONG ulAddress,ULONG ulReg)
{
case 0:
__asm__ __volatile__
("
mov %0,%%eax
mov %%eax,%%dr0
("\n\t \
mov %0,%%eax\n\t \
mov %%eax,%%dr0\n\t \
"
:
:"m" (ulAddress)
@ -925,9 +925,9 @@ void SetHardwareBreakPoint(ULONG ulAddress,ULONG ulReg)
break;
case 1:
__asm__ __volatile__
("
mov %0,%%eax
mov %%eax,%%dr1
("\n\t \
mov %0,%%eax\n\t \
mov %%eax,%%dr1\n\t \
"
:
:"m" (ulAddress)
@ -935,9 +935,9 @@ void SetHardwareBreakPoint(ULONG ulAddress,ULONG ulReg)
break;
case 2:
__asm__ __volatile__
("
mov %0,%%eax
mov %%eax,%%dr2
("\n\t \
mov %0,%%eax\n\t \
mov %%eax,%%dr2\n\t \
"
:
:"m" (ulAddress)
@ -945,9 +945,9 @@ void SetHardwareBreakPoint(ULONG ulAddress,ULONG ulReg)
break;
case 3:
__asm__ __volatile__
("
mov %0,%%eax
mov %%eax,%%dr3
("\n\t \
mov %0,%%eax\n\t \
mov %%eax,%%dr3\n\t \
"
:
:"m" (ulAddress)
@ -971,11 +971,11 @@ PULONG LinAddr[4]={&LinAddr0,&LinAddr1,&LinAddr2,&LinAddr3};
ENTER_FUNC();
// cancel all debug activity
__asm__("
pushl %eax
xorl %eax,%eax
mov %eax,%dr6
mov %eax,%dr7
__asm__("\n\t \
pushl %eax\n\t \
xorl %eax,%eax\n\t \
mov %eax,%dr6\n\t \
mov %eax,%dr7\n\t \
popl %eax");
// build DR7 mask
for(mask=0,i=0;i<4;i++)
@ -990,20 +990,20 @@ PULONG LinAddr[4]={&LinAddr0,&LinAddr1,&LinAddr2,&LinAddr3};
}
if(mask)
{
__asm__("
pushl %%eax
movl %0,%%eax
andl $0x000000FF,%%eax
orl $0x300,%%eax
mov %%eax,%%dr7
mov %1,%%eax
mov %%eax,%%dr0
mov %2,%%eax
mov %%eax,%%dr1
mov %3,%%eax
mov %%eax,%%dr2
mov %4,%%eax
mov %%eax,%%dr3
__asm__("\n\t \
pushl %%eax\n\t \
movl %0,%%eax\n\t \
andl $0x000000FF,%%eax\n\t \
orl $0x300,%%eax\n\t \
mov %%eax,%%dr7\n\t \
mov %1,%%eax\n\t \
mov %%eax,%%dr0\n\t \
mov %2,%%eax\n\t \
mov %%eax,%%dr1\n\t \
mov %3,%%eax\n\t \
mov %%eax,%%dr2\n\t \
mov %4,%%eax\n\t \
mov %%eax,%%dr3\n\t \
popl %%eax"
:
:"m" (mask),"m" (LinAddr0),"m" (LinAddr1),"m" (LinAddr2),"m" (LinAddr3));
@ -1630,8 +1630,8 @@ void InvalidateLB(void)
ENTER_FUNC();
__asm__ __volatile__
(
"wbinvd
mov %%cr3,%%ecx
"wbinvd\n\t \
mov %%cr3,%%ecx\n\t \
mov %%ecx,%%cr3"
:::"ecx"
);

View file

@ -1,4 +1,4 @@
/* $Id: hal.c,v 1.2 2002/01/23 23:39:24 chorns Exp $
/* $Id: hal.c,v 1.3 2002/05/08 17:05:31 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -596,6 +596,18 @@ KdPortGetByte(
}
BOOLEAN
STDCALL
KdPortGetByteEx(
PKD_PORT_INFORMATION PortInformation,
PUCHAR ByteRecieved)
{
UNIMPLEMENTED;
return TRUE;
}
BOOLEAN
STDCALL
KdPortInitialize(
@ -620,6 +632,18 @@ KdPortPollByte(
}
BOOLEAN
STDCALL
KdPortPollByteEx(
PKD_PORT_INFORMATION PortInformation,
PUCHAR ByteRecieved)
{
UNIMPLEMENTED;
return TRUE;
}
VOID
STDCALL
KdPortPutByte(
@ -629,6 +653,16 @@ KdPortPutByte(
}
VOID
STDCALL
KdPortPutByteEx(
PKD_PORT_INFORMATION PortInformation,
UCHAR ByteToSend)
{
UNIMPLEMENTED;
}
VOID
STDCALL
KdPortRestore(VOID)

View file

@ -60,9 +60,13 @@ IoFreeMapRegisters@12
IoMapTransfer@24
KdComPortInUse DATA
KdPortGetByte@4
KdPortGetByteEx@8
KdPortInitialize@12
KdPortInitializeEx@12
KdPortPollByte@4
KdPortPollByteEx@8
KdPortPutByte@4
KdPortPutByteEx@8
KdPortRestore@0
KdPortSave@0
KdPortDisableInterrupts@0

View file

@ -60,9 +60,13 @@ IoFreeMapRegisters=IoFreeMapRegisters@12
IoMapTransfer=IoMapTransfer@24
KdComPortInUse DATA
KdPortGetByte=KdPortGetByte@4
KdPortGetByteEx=KdPortGetByteEx@8
KdPortInitialize=KdPortInitialize@12
KdPortInitializeEx=KdPortInitializeEx@12
KdPortPollByte=KdPortPollByte@4
KdPortPollByteEx=KdPortPollByteEx@8
KdPortPutByte=KdPortPutByte@4
KdPortPutByteEx=KdPortPutByteEx@8
KdPortRestore=KdPortRestore@0
KdPortSave=KdPortSave@0
KdPortDisableInterrupts=KdPortDisableInterrupts@0

View file

@ -1,4 +1,4 @@
/* $Id: kdbg.c,v 1.3 2002/01/23 23:39:24 chorns Exp $
/* $Id: kdbg.c,v 1.4 2002/05/08 17:05:31 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -263,6 +263,95 @@ KdPortInitialize (
}
/* HAL.KdPortInitializeEx */
BOOLEAN
STDCALL
KdPortInitializeEx (
PKD_PORT_INFORMATION PortInformation,
DWORD Unknown1,
DWORD Unknown2
)
{
ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
PUCHAR ComPortBase;
char buffer[80];
ULONG divisor;
BYTE lcr;
if (PortInformation->BaudRate == 0)
{
PortInformation->BaudRate = DEFAULT_BAUD_RATE;
}
if (PortInformation->ComPort == 0)
{
return FALSE;
}
else
{
if (KdpDoesComPortExist ((PUCHAR)BaseArray[PortInformation->ComPort]))
{
ComPortBase = (PUCHAR)BaseArray[PortInformation->ComPort];
PortInformation->BaseAddress = (ULONG)ComPortBase;
#ifndef NDEBUG
sprintf (buffer,
"\nSerial port COM%ld found at 0x%lx\n",
PortInformation->ComPort,
(ULONG)ComPortBase];
HalDisplayString (buffer);
#endif /* NDEBUG */
}
else
{
sprintf (buffer,
"\nKernel Debugger: Serial port not found!!!\n\n");
HalDisplayString (buffer);
return FALSE;
}
}
/*
* set baud rate and data format (8N1)
*/
/* turn on DTR and RTS */
WRITE_PORT_UCHAR (SER_MCR(ComPortBase), SR_MCR_DTR | SR_MCR_RTS);
/* set DLAB */
lcr = READ_PORT_UCHAR (SER_LCR(ComPortBase)) | SR_LCR_DLAB;
WRITE_PORT_UCHAR (SER_LCR(ComPortBase), lcr);
/* set baud rate */
divisor = 115200 / PortInformation->BaudRate;
WRITE_PORT_UCHAR (SER_DLL(ComPortBase), divisor & 0xff);
WRITE_PORT_UCHAR (SER_DLM(ComPortBase), (divisor >> 8) & 0xff);
/* reset DLAB and set 8N1 format */
WRITE_PORT_UCHAR (SER_LCR(ComPortBase),
SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO);
/* read junk out of the RBR */
lcr = READ_PORT_UCHAR (SER_RBR(ComPortBase));
#ifndef NDEBUG
/*
* print message to blue screen
*/
sprintf (buffer,
"\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n",
PortInformation->ComPort,
(ULONG)ComPortBase,
PortInformation->BaudRate);
HalDisplayString (buffer);
#endif /* NDEBUG */
return TRUE;
}
/* HAL.KdPortGetByte */
BOOLEAN
STDCALL
@ -283,6 +372,26 @@ KdPortGetByte (
}
/* HAL.KdPortGetByteEx */
BOOLEAN
STDCALL
KdPortGetByteEx (
PKD_PORT_INFORMATION PortInformation,
PUCHAR ByteRecieved
)
{
PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
if ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_DR))
{
*ByteRecieved = READ_PORT_UCHAR (SER_RBR(ComPortBase));
return TRUE;
}
return FALSE;
}
/* HAL.KdPortPollByte */
BOOLEAN
STDCALL
@ -302,6 +411,27 @@ KdPortPollByte (
}
/* HAL.KdPortPollByteEx */
BOOLEAN
STDCALL
KdPortPollByteEx (
PKD_PORT_INFORMATION PortInformation,
PUCHAR ByteRecieved
)
{
PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
while ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_DR) == 0)
;
*ByteRecieved = READ_PORT_UCHAR (SER_RBR(ComPortBase));
return TRUE;
}
/* HAL.KdPortPutByte */
VOID
STDCALL
@ -318,6 +448,22 @@ KdPortPutByte (
WRITE_PORT_UCHAR (SER_THR(PortBase), ByteToSend);
}
/* HAL.KdPortPutByteEx */
VOID
STDCALL
KdPortPutByteEx (
PKD_PORT_INFORMATION PortInformation,
UCHAR ByteToSend
)
{
PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
while ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_TBE) == 0)
;
WRITE_PORT_UCHAR (SER_THR(ComPortBase), ByteToSend);
}
/* HAL.KdPortRestore */
VOID

View file

@ -1,6 +1,6 @@
#ifndef __INCLUDE_DDK_KDFUNCS_H
#define __INCLUDE_DDK_KDFUNCS_H
/* $Id: kdfuncs.h,v 1.5 2002/01/23 23:39:24 chorns Exp $ */
/* $Id: kdfuncs.h,v 1.6 2002/05/08 17:05:32 chorns Exp $ */
/* --- NTOSKRNL.EXE --- */
#if defined(__NTOSKRNL__)
@ -24,26 +24,60 @@ KdPortInitialize (
DWORD Unknown1,
DWORD Unknown2
);
BOOLEAN
STDCALL
KdPortInitializeEx (
PKD_PORT_INFORMATION PortInformation,
DWORD Unknown1,
DWORD Unknown2
);
BOOLEAN
STDCALL
KdPortGetByte (
PUCHAR ByteRecieved
);
BOOLEAN
STDCALL
KdPortGetByteEx (
PKD_PORT_INFORMATION PortInformation,
PUCHAR ByteRecieved
);
BOOLEAN
STDCALL
KdPortPollByte (
PUCHAR ByteRecieved
);
BOOLEAN
STDCALL
KdPortPollByteEx (
PKD_PORT_INFORMATION PortInformation,
PUCHAR ByteRecieved
);
VOID
STDCALL
KdPortPutByte (
UCHAR ByteToSend
);
VOID
STDCALL
KdPortPutByteEx (
PKD_PORT_INFORMATION PortInformation,
UCHAR ByteToSend
);
VOID
STDCALL
KdPortRestore (
VOID
);
VOID
STDCALL
KdPortSave (

View file

@ -1,4 +1,4 @@
/* $Id: kd.h,v 1.6 2002/02/09 18:41:23 chorns Exp $
/* $Id: kd.h,v 1.7 2002/05/08 17:05:32 chorns Exp $
*
* kernel debugger prototypes
*/
@ -8,18 +8,18 @@
#include <internal/ke.h>
typedef enum
{
NoDebug = 0,
GdbDebug,
PiceDebug,
ScreenDebug,
SerialDebug,
BochsDebug,
FileLogDebug
} DEBUG_TYPE;
#define KD_DEBUG_DISABLED 0x00
#define KD_DEBUG_GDB 0x01
#define KD_DEBUG_PICE 0x02
#define KD_DEBUG_SCREEN 0x04
#define KD_DEBUG_SERIAL 0x08
#define KD_DEBUG_BOCHS 0x10
#define KD_DEBUG_FILELOG 0x20
extern DEBUG_TYPE KdDebugType;
extern ULONG KdDebugState;
KD_PORT_INFORMATION GdbPortInfo;
KD_PORT_INFORMATION LogPortInfo;
typedef enum _KD_CONTINUE_TYPE
{

View file

@ -13,6 +13,11 @@
#include <ntdll/ldr.h>
#include <internal/module.h>
#define KERNEL_MODULE_NAME L"ntoskrnl.exe"
#define HAL_MODULE_NAME L"hal.dll"
#define MODULE_ROOT_NAME L"\\Modules\\"
#define FILESYSTEM_ROOT_NAME L"\\FileSystem\\"
NTSTATUS
LdrLoadDriver (
PUNICODE_STRING Filename,

View file

@ -87,6 +87,7 @@
#include <internal/kd.h>
#include <internal/ke.h>
#include <internal/ps.h>
#include <internal/ldr.h>
#define NDEBUG
#include <internal/debug.h>
@ -1205,7 +1206,7 @@ GspBreakIn(PKINTERRUPT Interrupt,
DPRINT ("Break In\n");
DoBreakIn = FALSE;
while (KdPortGetByte (&Value))
while (KdPortGetByteEx (&GdbPortInfo, &Value))
{
if (Value == 0x03)
DoBreakIn = TRUE;
@ -1243,6 +1244,8 @@ KdGdbStubInit(ULONG Phase)
if (Phase == 0)
{
DbgPrint("Module 'hal.dll' loaded at 0x%.08x.\n", LdrHalBase);
GspInitialized = TRUE;
GspRunThread = PsGetCurrentThread();
GspDbgThread = PsGetCurrentThread();

View file

@ -1,4 +1,4 @@
/* $Id: kdebug.c,v 1.35 2002/05/02 23:45:32 dwelch Exp $
/* $Id: kdebug.c,v 1.36 2002/05/08 17:05:32 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -37,9 +37,12 @@ KdDebuggerNotPresent = TRUE; /* EXPORTED */
static BOOLEAN KdpBreakPending = FALSE;
DEBUG_TYPE KdDebugType = NoDebug;
ULONG KdDebugState = KD_DEBUG_DISABLED;
ULONG KdpPortIrq = 0;
KD_PORT_INFORMATION GdbPortInfo;
KD_PORT_INFORMATION LogPortInfo;
/* PRIVATE FUNCTIONS ********************************************************/
static VOID
@ -69,14 +72,18 @@ KdInitSystem(ULONG Reserved,
DbgRDebugInit();
#endif
/* set debug port default values */
/* Set debug port default values */
PortInfo.ComPort = DEFAULT_DEBUG_PORT;
PortInfo.BaudRate = DEFAULT_DEBUG_BAUD_RATE;
KdpPortIrq = DEFAULT_DEBUG_COM2_IRQ;
/* parse kernel command line */
/* Set serial log port default values */
LogPortInfo.ComPort = DEFAULT_DEBUG_PORT;
LogPortInfo.BaudRate = DEFAULT_DEBUG_BAUD_RATE;
/* check for 'DEBUGPORT' */
/* Parse kernel command line */
/* Check for 'DEBUGPORT' */
p1 = (PCHAR)LoaderBlock->CommandLine;
while (p1 && (p2 = strchr(p1, '/')))
{
@ -91,25 +98,30 @@ KdInitSystem(ULONG Reserved,
{
p2 += 6;
KdDebuggerEnabled = TRUE;
KdDebugType = ScreenDebug;
KdDebugState |= KD_DEBUG_SCREEN;
}
else if (!_strnicmp(p2, "BOCHS", 5))
{
p2 += 5;
KdDebuggerEnabled = TRUE;
KdDebugType = BochsDebug;
KdDebugState |= KD_DEBUG_BOCHS;
}
else if (!_strnicmp(p2, "GDB", 3))
{
p2 += 3;
KdDebuggerEnabled = TRUE;
KdDebugType = GdbDebug;
KdDebugState |= KD_DEBUG_GDB;
/* Reset port information to defaults */
RtlMoveMemory(&GdbPortInfo, &PortInfo, sizeof(KD_PORT_INFORMATION));
PortInfo.ComPort = DEFAULT_DEBUG_PORT;
PortInfo.BaudRate = DEFAULT_DEBUG_BAUD_RATE;
}
else if (!_strnicmp(p2, "PICE", 4))
{
p2 += 4;
KdDebuggerEnabled = TRUE;
KdDebugType = PiceDebug;
KdDebugState |= KD_DEBUG_PICE;
}
else if (!_strnicmp(p2, "COM", 3))
{
@ -117,47 +129,55 @@ KdInitSystem(ULONG Reserved,
Value = (ULONG)atol(p2);
if (Value > 0 && Value < 5)
{
PrintString("\n COM2 found\n\n");
KdDebuggerEnabled = TRUE;
KdDebugType = SerialDebug;
PortInfo.ComPort = Value;
KdDebugState |= KD_DEBUG_SERIAL;
LogPortInfo.ComPort = Value;
}
}
else if (!_strnicmp(p2, "FILE", 4))
{
p2 += 4;
KdDebuggerEnabled = TRUE;
KdDebugType = FileLogDebug;
KdDebugState |= KD_DEBUG_FILELOG;
}
}
}
else if (!_strnicmp(p2, "DEBUG", 5))
{
p2 += 5;
/* Check that KdDebugType equals NoDebug so we don't override any set KdDebugType */
if (KdDebugType == NoDebug)
{
KdDebuggerEnabled = TRUE;
KdDebugType = SerialDebug;
}
KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_SERIAL;
}
else if (!_strnicmp(p2, "NODEBUG", 7))
{
p2 += 7;
KdDebuggerEnabled = FALSE;
KdDebugType = NoDebug;
KdDebugState = KD_DEBUG_DISABLED;
}
else if (!_strnicmp(p2, "CRASHDEBUG", 10))
{
p2 += 10;
KdDebuggerEnabled = FALSE;
KdDebugType = NoDebug;
KdDebugState = KD_DEBUG_DISABLED;
}
else if (!_strnicmp(p2, "BREAK", 5))
{
p2 += 5;
KdpBreakPending = TRUE;
}
else if (!_strnicmp(p2, "COM", 3))
{
p2 += 3;
if (*p2 != '=')
{
p2++;
Value = (ULONG)atol(p2);
if (Value > 0 && Value < 5)
{
PortInfo.ComPort = Value;
}
}
}
else if (!_strnicmp(p2, "BAUDRATE", 8))
{
p2 += 8;
@ -166,11 +186,9 @@ KdInitSystem(ULONG Reserved,
p2++;
Value = (ULONG)atol(p2);
if (Value > 0)
{
KdDebuggerEnabled = TRUE;
KdDebugType = SerialDebug;
PortInfo.BaudRate = Value;
}
{
PortInfo.BaudRate = Value;
}
}
else if (!_strnicmp(p2, "IRQ", 3))
{
@ -181,8 +199,6 @@ KdInitSystem(ULONG Reserved,
Value = (ULONG)atol(p2);
if (Value > 0)
{
KdDebuggerEnabled = TRUE;
KdDebugType = SerialDebug;
KdpPortIrq = Value;
}
}
@ -191,60 +207,41 @@ KdInitSystem(ULONG Reserved,
p1 = p2;
}
/* print some information */
/* Print some information */
if (KdDebuggerEnabled == TRUE)
{
switch (KdDebugType)
{
case NoDebug:
break;
case GdbDebug:
PrintString("\n GDB debugging enabled\n\n");
break;
case PiceDebug:
if (KdDebugState & KD_DEBUG_GDB)
PrintString("\n GDB debugging enabled. COM%ld %ld Baud\n\n",
GdbPortInfo.ComPort, GdbPortInfo.BaudRate);
if (KdDebugState & KD_DEBUG_PICE)
PrintString("\n Private ICE debugger enabled\n\n");
break;
case ScreenDebug:
//PrintString("\n Screen debugging enabled\n\n");
break;
if (KdDebugState & KD_DEBUG_SCREEN)
PrintString("\n Screen debugging enabled\n\n");
case BochsDebug:
if (KdDebugState & KD_DEBUG_BOCHS)
PrintString("\n Bochs debugging enabled\n\n");
break;
case SerialDebug:
PrintString("\n Serial debugging enabled: COM%ld %ld Baud\n\n",
PortInfo.ComPort, PortInfo.BaudRate);
break;
if (KdDebugState & KD_DEBUG_SERIAL)
PrintString("\n Serial debugging enabled. COM%ld %ld Baud\n\n",
LogPortInfo.ComPort, LogPortInfo.BaudRate);
case FileLogDebug:
if (KdDebugState & KD_DEBUG_FILELOG)
PrintString("\n File log debugging enabled\n\n");
break;
}
}
/* initialize debug port */
/* Perform any initialization nescessary */
if (KdDebuggerEnabled == TRUE)
{
switch (KdDebugType)
{
case SerialDebug:
case GdbDebug:
KdPortInitialize(&PortInfo,
0,
0);
break;
if (KdDebugState & KD_DEBUG_GDB)
KdPortInitializeEx(&GdbPortInfo, 0, 0);
case FileLogDebug:
if (KdDebugState & KD_DEBUG_SERIAL)
KdPortInitializeEx(&LogPortInfo, 0, 0);
if (KdDebugState & KD_DEBUG_FILELOG)
DebugLogInit();
break;
default:
break;
}
}
}
@ -252,9 +249,9 @@ KdInitSystem(ULONG Reserved,
VOID
KdInit1(VOID)
{
/* Initialize kernel debugger */
if (KdDebuggerEnabled == TRUE &&
KdDebugType == GdbDebug)
/* Initialize kernel debugger (phase 0) */
if ((KdDebuggerEnabled == TRUE) &&
(KdDebugState & KD_DEBUG_GDB))
{
KdGdbStubInit(0);
}
@ -263,15 +260,16 @@ KdInit1(VOID)
VOID KdInit2(VOID)
{
if (KdDebuggerEnabled == TRUE &&
KdDebugType == GdbDebug)
/* Initialize kernel debugger (phase 1) */
if ((KdDebuggerEnabled == TRUE) &&
(KdDebugState & KD_DEBUG_GDB))
{
KdGdbStubInit(1);
}
}
VOID
KdDebugPrint (LPSTR Message)
KdSerialDebugPrint (LPSTR Message)
{
PCHAR pch = (PCHAR) Message;
@ -279,56 +277,50 @@ KdDebugPrint (LPSTR Message)
{
if (*pch == '\n')
{
KdPortPutByte ('\r');
KdPortPutByteEx (&LogPortInfo, '\r');
}
KdPortPutByte (*pch);
KdPortPutByteEx (&LogPortInfo, *pch);
pch++;
}
}
ULONG
KdpPrintString(PANSI_STRING String)
VOID
KdBochsDebugPrint(IN LPSTR Message)
{
PCH pch = String->Buffer;
switch (KdDebugType)
{
case NoDebug:
break;
case GdbDebug:
KdGdbDebugPrint(pch);
break;
case PiceDebug:
break;
case ScreenDebug:
HalDisplayString(pch);
break;
case SerialDebug:
KdDebugPrint(pch);
break;
case BochsDebug:
while (*pch != 0)
while (*Message != 0)
{
if (*pch == '\n')
if (*Message == '\n')
{
WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, '\r');
}
WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, *pch);
pch++;
WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, *Message);
Message++;
}
break;
}
case FileLogDebug:
DebugLogWrite(pch);
break;
}
return((ULONG)String->Length);
ULONG
KdpPrintString(PANSI_STRING String)
{
PCH pch = String->Buffer;
if (KdDebugState & KD_DEBUG_GDB)
KdGdbDebugPrint(pch);
if (KdDebugState & KD_DEBUG_SCREEN)
HalDisplayString(pch);
if (KdDebugState & KD_DEBUG_SERIAL)
KdSerialDebugPrint(pch);
if (KdDebugState & KD_DEBUG_BOCHS)
KdBochsDebugPrint(pch);
if (KdDebugState & KD_DEBUG_FILELOG)
DebugLogWrite(pch);
return((ULONG)String->Length);
}
/* PUBLIC FUNCTIONS *********************************************************/
@ -338,7 +330,7 @@ KdpPrintString(PANSI_STRING String)
BOOLEAN STDCALL
KdPollBreakIn(VOID)
{
if ((!KdDebuggerEnabled) || (KdDebugType != SerialDebug))
if ((!KdDebuggerEnabled) || (!(KdDebugState & KD_DEBUG_SERIAL)))
return FALSE;
return KdpBreakPending;
}
@ -427,7 +419,7 @@ KdSystemDebugControl(ULONG Code)
VOID
KdPutChar(UCHAR Value)
{
KdPortPutByte (Value);
KdPortPutByteEx (&GdbPortInfo, Value);
}
@ -436,7 +428,7 @@ KdGetChar(VOID)
{
UCHAR Value;
while (!KdPortGetByte (&Value));
while (!KdPortGetByteEx (&GdbPortInfo, &Value));
return Value;
}

View file

@ -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: catch.c,v 1.19 2002/05/02 23:45:33 dwelch Exp $
/* $Id: catch.c,v 1.20 2002/05/08 17:05:32 chorns Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/catch.c
@ -271,7 +271,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
/* PreviousMode == KernelMode */
if (!KdDebuggerEnabled || KdDebugType != GdbDebug)
if ((!KdDebuggerEnabled) || (!(KdDebugState & KD_DEBUG_GDB)))
{
/* FIXME: Get ExceptionNr and CR2 */
KeBugCheckWithTf (KMODE_EXCEPTION_NOT_HANDLED, 0, 0, 0, 0, Tf);

View file

@ -1,4 +1,4 @@
/* $Id: loader.c,v 1.102 2002/05/02 23:45:33 dwelch Exp $
/* $Id: loader.c,v 1.103 2002/05/08 17:05:32 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -44,13 +44,6 @@
#define NDEBUG
#include <internal/debug.h>
/* MACROS ********************************************************************/
#define KERNEL_MODULE_NAME L"ntoskrnl.exe"
#define HAL_MODULE_NAME L"hal.dll"
#define MODULE_ROOT_NAME L"\\Modules\\"
#define FILESYSTEM_ROOT_NAME L"\\FileSystem\\"
/* GLOBALS *******************************************************************/
LIST_ENTRY ModuleListHead;
@ -896,7 +889,6 @@ VOID LdrLoadAutoConfigDrivers (VOID)
{
#ifdef KDBG
NTSTATUS Status;
UNICODE_STRING ModuleName;
PMODULE_OBJECT ModuleObject;
@ -930,7 +922,7 @@ VOID LdrLoadAutoConfigDrivers (VOID)
*/
LdrLoadAutoConfigDriver( L"keyboard.sys" );
if (KdDebugType == PiceDebug)
if ((KdDebuggerEnabled) && (KdDebugState & KD_DEBUG_PICE))
{
/*
* Private ICE debugger
@ -1167,7 +1159,7 @@ LdrLoadModule(PUNICODE_STRING Filename)
return NULL;
}
CHECKPOINT;
/* Load driver into memory chunk */
Status = NtReadFile(FileHandle,
0, 0, 0,
@ -1861,6 +1853,14 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
*ModuleObject = CreatedModuleObject;
DPRINT("Loading Module %wZ...\n", FileName);
if ((KdDebuggerEnabled == TRUE) && (KdDebugState & KD_DEBUG_GDB))
{
DbgPrint("Module %wZ loaded at 0x%.08x.\n",
FileName, CreatedModuleObject->Base);
}
return STATUS_SUCCESS;
}