diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 4f140dc7b..2403ccb04 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -31,6 +31,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/hl/fbdev.cc ${XTOSKRNL_SOURCE_DIR}/hl/init.cc ${XTOSKRNL_SOURCE_DIR}/hl/ioreg.cc + ${XTOSKRNL_SOURCE_DIR}/kd/${ARCH}/debug.cc ${XTOSKRNL_SOURCE_DIR}/kd/data.cc ${XTOSKRNL_SOURCE_DIR}/kd/dbgio.cc ${XTOSKRNL_SOURCE_DIR}/kd/debug.cc diff --git a/xtoskrnl/kd/amd64/debug.cc b/xtoskrnl/kd/amd64/debug.cc new file mode 100644 index 000000000..bc372b8f2 --- /dev/null +++ b/xtoskrnl/kd/amd64/debug.cc @@ -0,0 +1,36 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/kd/amd64/debug.cc + * DESCRIPTION: Kernel Debugger + * DEVELOPERS: Aiken Harris + */ + +#include + + +/** + * Transfers active control to a previously frozen processor. + * + * @return This routine returns a value indicating how execution should proceed after the debugging session concludes. + * + * @since XT 1.0 + */ +XTAPI +KCONTINUE_STATUS +KD::Debugger::SwitchProcessor(VOID) +{ + EXCEPTION_RECORD ExceptionRecord; + PKPROCESSOR_CONTROL_BLOCK Prcb; + + /* Get processor control block */ + Prcb = KE::Processor::GetCurrentProcessorControlBlock(); + + /* Construct an exception record */ + ExceptionRecord.ExceptionAddress = (PVOID)&Prcb->ProcessorState.ContextFrame.Rip; + ExceptionRecord.ExceptionCode = STATUS_WAKE_SYSTEM_DEBUGGER; + ExceptionRecord.ExceptionRecord = &ExceptionRecord; + + /* Pass the synthetic exception and the processor context to the debugger */ + return (KCONTINUE_STATUS)ProcessCpuStateChange(&ExceptionRecord, &Prcb->ProcessorState.ContextFrame, FALSE); +} diff --git a/xtoskrnl/kd/debug.cc b/xtoskrnl/kd/debug.cc index c8a560118..7a06647f1 100644 --- a/xtoskrnl/kd/debug.cc +++ b/xtoskrnl/kd/debug.cc @@ -41,7 +41,7 @@ KD::Debugger::EnterDebugger(IN PKTRAP_FRAME TrapFrame) Active = TRUE; /* Print debug message and enter an infinite loop */ - DebugPrint(L"\n\n*** KDebugger Entered at RIP 0x%.16llX ***\n", TrapFrame->Rip); + DebugPrint(L"\n\n*** Entered KDebugger ***\n"); for(;;); /* Mark the debugger as inactive */ @@ -72,29 +72,3 @@ KD::Debugger::ProcessCpuStateChange(IN PEXCEPTION_RECORD ExceptionRecord, { return FALSE; } - -/** - * Transfers active control to a previously frozen processor. - * - * @return This routine returns a value indicating how execution should proceed after the debugging session concludes. - * - * @since XT 1.0 - */ -XTAPI -KCONTINUE_STATUS -KD::Debugger::SwitchProcessor(VOID) -{ - EXCEPTION_RECORD ExceptionRecord; - PKPROCESSOR_CONTROL_BLOCK Prcb; - - /* Get processor control block */ - Prcb = KE::Processor::GetCurrentProcessorControlBlock(); - - /* Construct an exception record */ - ExceptionRecord.ExceptionAddress = (PVOID)&Prcb->ProcessorState.ContextFrame.Rip; - ExceptionRecord.ExceptionCode = STATUS_WAKE_SYSTEM_DEBUGGER; - ExceptionRecord.ExceptionRecord = &ExceptionRecord; - - /* Pass the synthetic exception and the processor context to the debugger */ - return (KCONTINUE_STATUS)ProcessCpuStateChange(&ExceptionRecord, &Prcb->ProcessorState.ContextFrame, FALSE); -} diff --git a/xtoskrnl/kd/i686/debug.cc b/xtoskrnl/kd/i686/debug.cc new file mode 100644 index 000000000..8ce423379 --- /dev/null +++ b/xtoskrnl/kd/i686/debug.cc @@ -0,0 +1,36 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/kd/i686/debug.cc + * DESCRIPTION: Kernel Debugger + * DEVELOPERS: Aiken Harris + */ + +#include + + +/** + * Transfers active control to a previously frozen processor. + * + * @return This routine returns a value indicating how execution should proceed after the debugging session concludes. + * + * @since XT 1.0 + */ +XTAPI +KCONTINUE_STATUS +KD::Debugger::SwitchProcessor(VOID) +{ + EXCEPTION_RECORD ExceptionRecord; + PKPROCESSOR_CONTROL_BLOCK Prcb; + + /* Get processor control block */ + Prcb = KE::Processor::GetCurrentProcessorControlBlock(); + + /* Construct an exception record */ + ExceptionRecord.ExceptionAddress = (PVOID)&Prcb->ProcessorState.ContextFrame.Eip; + ExceptionRecord.ExceptionCode = STATUS_WAKE_SYSTEM_DEBUGGER; + ExceptionRecord.ExceptionRecord = &ExceptionRecord; + + /* Pass the synthetic exception and the processor context to the debugger */ + return (KCONTINUE_STATUS)ProcessCpuStateChange(&ExceptionRecord, &Prcb->ProcessorState.ContextFrame, FALSE); +}