mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Changed debug output to use INT 2D
svn path=/trunk/; revision=936
This commit is contained in:
parent
faac123528
commit
88cb154d19
8 changed files with 238 additions and 136 deletions
|
@ -52,7 +52,7 @@ Debugging kernel-mode code is tricky, these are some snippets
|
||||||
easier to see where output is coming from. DbgPrint can be used at any
|
easier to see where output is coming from. DbgPrint can be used at any
|
||||||
point including in interrupt handlers.
|
point including in interrupt handlers.
|
||||||
|
|
||||||
There are options in ntoskrnl/dbg/print.c for copying DbgPrint output
|
There are options in ntoskrnl/kd/kdebug.c for copying DbgPrint output
|
||||||
to a serial device or bochs logging port (parallel support should also
|
to a serial device or bochs logging port (parallel support should also
|
||||||
be added). This can be useful if a lot of output is being generated.
|
be added). This can be useful if a lot of output is being generated.
|
||||||
|
|
||||||
|
|
13
reactos/include/internal/kd.h
Normal file
13
reactos/include/internal/kd.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/* $Id: kd.h,v 1.1 2000/01/17 21:00:53 ekohl Exp $
|
||||||
|
*
|
||||||
|
* kernel debugger prototypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H
|
||||||
|
#define __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H
|
||||||
|
|
||||||
|
|
||||||
|
ULONG KdpPrintString (PANSI_STRING String);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */
|
|
@ -87,6 +87,6 @@ VOID TstBegin(VOID);
|
||||||
VOID KeInit(VOID);
|
VOID KeInit(VOID);
|
||||||
VOID CmInitializeRegistry(VOID);
|
VOID CmInitializeRegistry(VOID);
|
||||||
VOID CmImportHive(PCHAR);
|
VOID CmImportHive(PCHAR);
|
||||||
VOID DbgInit(VOID);
|
VOID KdInitSystem(VOID);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: print.c,v 1.5 1999/12/26 15:50:47 dwelch Exp $
|
/* $Id: print.c,v 1.6 2000/01/17 21:01:37 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -12,144 +12,38 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/hal/ddk.h>
|
|
||||||
#include <internal/ntoskrnl.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Uncomment one of the following symbols to select a debug output style.
|
|
||||||
*
|
|
||||||
* SCREEN_DEBUGGING:
|
|
||||||
* Debug information is printed on the screen.
|
|
||||||
*
|
|
||||||
* SERIAL_DEBUGGING:
|
|
||||||
* Debug information is printed to a serial device. Check the port
|
|
||||||
* address, the baud rate and the data format.
|
|
||||||
* Default: COM1 19200 Baud 8N1 (8 data bits, no parity, 1 stop bit)
|
|
||||||
*
|
|
||||||
* BOCHS_DEBUGGING: (not tested yet)
|
|
||||||
* Debug information is printed to the bochs logging port. Bochs
|
|
||||||
* writes the output to a log file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SCREEN_DEBUGGING /* debug info is printed on the screen */
|
|
||||||
/* #define SERIAL_DEBUGGING */ /* remote debugging */
|
|
||||||
/* #define BOCHS_DEBUGGING */ /* debug output using bochs */
|
|
||||||
|
|
||||||
|
|
||||||
#define SERIAL_DEBUG_PORT 0x03f8 /* COM 1 */
|
|
||||||
/* #define SERIAL_DEBUG_PORT 0x02f8 */ /* COM 2 */
|
|
||||||
#define SERIAL_DEBUG_BAUD_RATE 19200
|
|
||||||
|
|
||||||
|
|
||||||
#define BOCHS_DEBUGGING
|
|
||||||
#ifdef BOCHS_DEBUGGING
|
|
||||||
#define BOCHS_LOGGER_PORT (0xe9)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUGGING
|
ULONG DbgService (ULONG Service, PVOID Context1, PVOID Context2);
|
||||||
static VOID
|
__asm__ ("\n\t.global _DbgService\n\t"
|
||||||
DbgDisplaySerialString(PCH String)
|
"_DbgService:\n\t"
|
||||||
{
|
"mov 4(%esp), %eax\n\t"
|
||||||
PCH pch = String;
|
"mov 8(%esp), %ecx\n\t"
|
||||||
|
"mov 12(%esp), %edx\n\t"
|
||||||
while (*pch != 0)
|
"int $0x2D\n\t"
|
||||||
{
|
"ret\n\t");
|
||||||
if (*pch == '\n')
|
|
||||||
{
|
|
||||||
KdPortPutByte ('\r');
|
|
||||||
}
|
|
||||||
|
|
||||||
KdPortPutByte (*pch);
|
|
||||||
|
|
||||||
pch++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* SERIAL_DEBUGGING */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOCHS_DEBUGGING
|
|
||||||
static VOID
|
|
||||||
DbgDisplayBochsString(PCH String)
|
|
||||||
{
|
|
||||||
PCH pch = String;
|
|
||||||
|
|
||||||
while (*pch != 0)
|
|
||||||
{
|
|
||||||
if (*pch == '\n')
|
|
||||||
{
|
|
||||||
WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, '\r');
|
|
||||||
}
|
|
||||||
|
|
||||||
WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, *pch);
|
|
||||||
|
|
||||||
pch++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* BOCHS_DEBUGGING */
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
|
||||||
DbgInit (VOID)
|
|
||||||
{
|
|
||||||
#ifdef SERIAL_DEBUGGING
|
|
||||||
KD_PORT_INFORMATION PortInfo;
|
|
||||||
|
|
||||||
PortInfo.BaseAddress = SERIAL_DEBUG_PORT;
|
|
||||||
PortInfo.BaudRate = SERIAL_DEBUG_BAUD_RATE;
|
|
||||||
|
|
||||||
KdPortInitialize (&PortInfo,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
DbgPrint(PCH Format, ...)
|
DbgPrint(PCH Format, ...)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
ANSI_STRING DebugString;
|
||||||
|
CHAR Buffer[512];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
unsigned int eflags;
|
|
||||||
|
|
||||||
/*
|
/* init ansi string */
|
||||||
* Because this is used by alomost every subsystem including irqs it
|
DebugString.Buffer = Buffer;
|
||||||
* must be atomic. The following code sequence disables interrupts after
|
DebugString.MaximumLength = 512;
|
||||||
* saving the previous state of the interrupt flag
|
|
||||||
*/
|
|
||||||
__asm__("pushf\n\tpop %0\n\tcli\n\t"
|
|
||||||
: "=m" (eflags)
|
|
||||||
: /* */);
|
|
||||||
|
|
||||||
/*
|
va_start (ap, Format);
|
||||||
* Process the format string into a fixed length buffer using the
|
DebugString.Length = vsprintf (Buffer, Format, ap);
|
||||||
* standard C RTL function
|
va_end (ap);
|
||||||
*/
|
|
||||||
va_start(ap,Format);
|
|
||||||
vsprintf(buffer,Format,ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
#ifdef SCREEN_DEBUGGING
|
DbgService (1, &DebugString, NULL);
|
||||||
HalDisplayString (buffer);
|
|
||||||
#endif
|
|
||||||
#ifdef SERIAL_DEBUGGING
|
|
||||||
DbgDisplaySerialString (buffer);
|
|
||||||
#endif
|
|
||||||
#ifdef BOCHS_DEBUGGING
|
|
||||||
DbgDisplayBochsString (buffer);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
return (ULONG)DebugString.Length;
|
||||||
* Restore the interrupt flag
|
|
||||||
*/
|
|
||||||
__asm__("push %0\n\tpopf\n\t"
|
|
||||||
:
|
|
||||||
: "m" (eflags));
|
|
||||||
return(strlen(buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,10 +1,52 @@
|
||||||
/* $Id: kdebug.c,v 1.2 1999/10/21 11:13:38 ekohl Exp $
|
/* $Id: kdebug.c,v 1.3 2000/01/17 21:02:06 ekohl Exp $
|
||||||
*
|
|
||||||
* reactos/ntoskrnl/kd/kdebug.c
|
|
||||||
*
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/kd/kdebug.c
|
||||||
|
* PURPOSE: Kernel debugger
|
||||||
|
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* 21/10/99: Created
|
||||||
*/
|
*/
|
||||||
#include <ddk/ntddk.h>
|
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/ntoskrnl.h>
|
||||||
|
#include <internal/kd.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Uncomment one of the following symbols to select a debug output style.
|
||||||
|
*
|
||||||
|
* SCREEN_DEBUGGING:
|
||||||
|
* Debug information is printed on the screen.
|
||||||
|
*
|
||||||
|
* SERIAL_DEBUGGING:
|
||||||
|
* Debug information is printed to a serial device. Check the port
|
||||||
|
* address, the baud rate and the data format.
|
||||||
|
* Default: COM1 19200 Baud 8N1 (8 data bits, no parity, 1 stop bit)
|
||||||
|
*
|
||||||
|
* BOCHS_DEBUGGING: (not tested yet)
|
||||||
|
* Debug information is printed to the bochs logging port. Bochs
|
||||||
|
* writes the output to a log file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SCREEN_DEBUGGING /* debug info is printed on the screen */
|
||||||
|
//#define SERIAL_DEBUGGING /* remote debugging */
|
||||||
|
//#define BOCHS_DEBUGGING /* debug output using bochs */
|
||||||
|
|
||||||
|
|
||||||
|
#define SERIAL_DEBUG_PORT 0x03f8 /* COM 1 */
|
||||||
|
// #define SERIAL_DEBUG_PORT 0x02f8 /* COM 2 */
|
||||||
|
#define SERIAL_DEBUG_BAUD_RATE 19200
|
||||||
|
|
||||||
|
|
||||||
|
//#define BOCHS_DEBUGGING
|
||||||
|
#ifdef BOCHS_DEBUGGING
|
||||||
|
#define BOCHS_LOGGER_PORT (0xe9)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* VARIABLES ***************************************************************/
|
||||||
|
|
||||||
//BYTE STDCALL KdPortPollByte(VOID);
|
//BYTE STDCALL KdPortPollByte(VOID);
|
||||||
|
|
||||||
|
@ -24,7 +66,7 @@ KdDebuggerNotPresent = TRUE;
|
||||||
/* PRIVATE FUNCTIONS ********************************************************/
|
/* PRIVATE FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
KdInit (VOID)
|
KdInitSystem (VOID)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* FIXME: parse kernel command line */
|
/* FIXME: parse kernel command line */
|
||||||
|
@ -43,6 +85,48 @@ KdInit (VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
KdpPrintString (PANSI_STRING String)
|
||||||
|
{
|
||||||
|
#if defined(SERIAL_DEBUGGING) || defined(BOCHS_DEBUGGING)
|
||||||
|
PCH pch = String->Buffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SCREEN_DEBUGGING
|
||||||
|
HalDisplayString (String->Buffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SERIAL_DEBUGGING
|
||||||
|
while (*pch != 0)
|
||||||
|
{
|
||||||
|
if (*pch == '\n')
|
||||||
|
{
|
||||||
|
KdPortPutByte ('\r');
|
||||||
|
}
|
||||||
|
|
||||||
|
KdPortPutByte (*pch);
|
||||||
|
|
||||||
|
pch++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOCHS_DEBUGGING
|
||||||
|
while (*pch != 0)
|
||||||
|
{
|
||||||
|
if (*pch == '\n')
|
||||||
|
{
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, '\r');
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, *pch);
|
||||||
|
|
||||||
|
pch++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (ULONG)String->Length;
|
||||||
|
}
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS *********************************************************/
|
/* PUBLIC FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
/* NTOSKRNL.KdPollBreakIn */
|
/* NTOSKRNL.KdPollBreakIn */
|
||||||
|
|
111
reactos/ntoskrnl/kd/service.c
Normal file
111
reactos/ntoskrnl/kd/service.c
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
/* $Id: service.c,v 1.1 2000/01/17 21:02:06 ekohl Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/kd/service.c
|
||||||
|
* PURPOSE: Debug service dispatcher
|
||||||
|
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* 17/01/2000: Created
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/i386/segment.h>
|
||||||
|
#include <internal/kd.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
KdpServiceDispatcher (
|
||||||
|
ULONG Service,
|
||||||
|
PVOID Context1,
|
||||||
|
PVOID Context2)
|
||||||
|
{
|
||||||
|
ULONG Result = 0;
|
||||||
|
|
||||||
|
switch (Service)
|
||||||
|
{
|
||||||
|
case 1: /* DbgPrint */
|
||||||
|
Result = KdpPrintString ((PANSI_STRING)Context1);
|
||||||
|
// HalDisplayString (((PANSI_STRING)Context1)->Buffer);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
HalDisplayString ("Invalid debug service call!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define _STR(x) #x
|
||||||
|
#define STR(x) _STR(x)
|
||||||
|
|
||||||
|
void interrupt_handler2d(void);
|
||||||
|
__asm__("\n\t.global _interrupt_handler2d\n\t"
|
||||||
|
"_interrupt_handler2d:\n\t"
|
||||||
|
|
||||||
|
/* Save the user context */
|
||||||
|
"pushl %ebp\n\t" /* Ebp */
|
||||||
|
|
||||||
|
"pushl %eax\n\t" /* Eax */
|
||||||
|
"pushl %ecx\n\t" /* Ecx */
|
||||||
|
"pushl %edx\n\t" /* Edx */
|
||||||
|
"pushl %ebx\n\t" /* Ebx */
|
||||||
|
"pushl %esi\n\t" /* Esi */
|
||||||
|
"pushl %edi\n\t" /* Edi */
|
||||||
|
|
||||||
|
"pushl %ds\n\t" /* SegDs */
|
||||||
|
"pushl %es\n\t" /* SegEs */
|
||||||
|
"pushl %fs\n\t" /* SegFs */
|
||||||
|
"pushl %gs\n\t" /* SegGs */
|
||||||
|
|
||||||
|
"subl $112,%esp\n\t" /* FloatSave */
|
||||||
|
|
||||||
|
"pushl $0\n\t" /* Dr7 */
|
||||||
|
"pushl $0\n\t" /* Dr6 */
|
||||||
|
"pushl $0\n\t" /* Dr3 */
|
||||||
|
"pushl $0\n\t" /* Dr2 */
|
||||||
|
"pushl $0\n\t" /* Dr1 */
|
||||||
|
"pushl $0\n\t" /* Dr0 */
|
||||||
|
|
||||||
|
"pushl $0\n\t" /* ContextFlags */
|
||||||
|
|
||||||
|
/* Set ES to kernel segment */
|
||||||
|
"movw $"STR(KERNEL_DS)",%bx\n\t"
|
||||||
|
"movw %bx,%es\n\t"
|
||||||
|
|
||||||
|
/* FIXME: check to see if SS is valid/inrange */
|
||||||
|
|
||||||
|
/* DS is now also kernel segment */
|
||||||
|
"movw %bx,%ds\n\t"
|
||||||
|
|
||||||
|
/* Call debug service dispatcher */
|
||||||
|
"pushl %edx\n\t"
|
||||||
|
"pushl %ecx\n\t"
|
||||||
|
"pushl %eax\n\t"
|
||||||
|
"call _KdpServiceDispatcher\n\t"
|
||||||
|
"addl $12,%esp\n\t" /* restore stack pointer */
|
||||||
|
|
||||||
|
/* Restore the user context */
|
||||||
|
"addl $4,%esp\n\t" /* UserContext */
|
||||||
|
"addl $24,%esp\n\t" /* Dr[0-3,6-7] */
|
||||||
|
"addl $112,%esp\n\t" /* FloatingSave */
|
||||||
|
"popl %gs\n\t" /* SegGs */
|
||||||
|
"popl %fs\n\t" /* SegFs */
|
||||||
|
"popl %es\n\t" /* SegEs */
|
||||||
|
"popl %ds\n\t" /* SegDs */
|
||||||
|
|
||||||
|
"popl %edi\n\t" /* Edi */
|
||||||
|
"popl %esi\n\t" /* Esi */
|
||||||
|
"popl %ebx\n\t" /* Ebx */
|
||||||
|
"popl %edx\n\t" /* Edx */
|
||||||
|
"popl %ecx\n\t" /* Ecx */
|
||||||
|
"addl $4,%esp\n\t" /* Eax (Not restored) */
|
||||||
|
|
||||||
|
"popl %ebp\n\t" /* Ebp */
|
||||||
|
|
||||||
|
"iret\n\t");
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: main.c,v 1.33 1999/12/18 17:48:22 dwelch Exp $
|
/* $Id: main.c,v 1.34 2000/01/17 21:01:16 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -160,7 +160,7 @@ asmlinkage void _main(boot_param* _bp)
|
||||||
/*
|
/*
|
||||||
* Initialize the debug output
|
* Initialize the debug output
|
||||||
*/
|
*/
|
||||||
DbgInit ();
|
KdInitSystem ();
|
||||||
|
|
||||||
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
||||||
if (start < ((int)&end))
|
if (start < ((int)&end))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile_rex,v 1.46 2000/01/14 02:22:40 ekohl Exp $
|
# $Id: makefile_rex,v 1.47 2000/01/17 21:02:30 ekohl Exp $
|
||||||
#
|
#
|
||||||
# ReactOS Operating System
|
# ReactOS Operating System
|
||||||
#
|
#
|
||||||
|
@ -72,7 +72,7 @@ PO_OBJECTS = po/power.o
|
||||||
|
|
||||||
CC_OBJECTS = cc/cacheman.o cc/view.o
|
CC_OBJECTS = cc/cacheman.o cc/view.o
|
||||||
|
|
||||||
KD_OBJECTS = kd/kdebug.o
|
KD_OBJECTS = kd/kdebug.o kd/service.o
|
||||||
|
|
||||||
RESOURCE_OBJECT = $(TARGET).coff
|
RESOURCE_OBJECT = $(TARGET).coff
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue