From 74ff8524ad620fd06a263551f7f6790d5f89bf96 Mon Sep 17 00:00:00 2001 From: Rex Jolliff Date: Tue, 20 Oct 1998 05:54:29 +0000 Subject: [PATCH] Added serial debugging support svn path=/trunk/; revision=73 --- reactos/ntoskrnl/hal/x86/printk.c | 58 ++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/hal/x86/printk.c b/reactos/ntoskrnl/hal/x86/printk.c index 76c2240e735..59554f29d83 100644 --- a/reactos/ntoskrnl/hal/x86/printk.c +++ b/reactos/ntoskrnl/hal/x86/printk.c @@ -16,11 +16,48 @@ #include #include +//#define BOCHS_DEBUGGING 1 +//#define SERIAL_DEBUGGING +#define SERIAL_PORT 0x03f8 +#define SERIAL_BAUD_RATE 19200 +#define SERIAL_LINE_CONTROL (SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO) +//#define NDEBUG #include /* GLOBALS ******************************************************************/ +#ifdef BOCHS_DEBUGGING #define BOCHS_LOGGER_PORT (0x3ed) +#endif + +#ifdef SERIAL_DEBUGGING +#define SER_RBR SERIAL_PORT + 0 +#define SER_THR SERIAL_PORT + 0 +#define SER_DLL SERIAL_PORT + 0 +#define SER_IER SERIAL_PORT + 1 +#define SER_DLM SERIAL_PORT + 1 +#define SER_IIR SERIAL_PORT + 2 +#define SER_LCR SERIAL_PORT + 3 +#define SR_LCR_CS5 0x00 +#define SR_LCR_CS6 0x01 +#define SR_LCR_CS7 0x02 +#define SR_LCR_CS8 0x03 +#define SR_LCR_ST1 0x00 +#define SR_LCR_ST2 0x04 +#define SR_LCR_PNO 0x00 +#define SR_LCR_POD 0x08 +#define SR_LCR_PEV 0x18 +#define SR_LCR_PMK 0x28 +#define SR_LCR_PSP 0x38 +#define SR_LCR_BRK 0x40 +#define SR_LCR_DLAB 0x80 +#define SER_MCR SERIAL_PORT + 4 +#define SR_MCR_DTR 0x01 +#define SR_MCR_RTS 0x02 +#define SER_LSR SERIAL_PORT + 5 +#define SR_LSR_TBE 0x20 +#define SER_MSR SERIAL_PORT + 6 +#endif /* * PURPOSE: Current cursor position @@ -132,8 +169,16 @@ static void putchar(char c) int offset; int i; +#ifdef BOCHS_DEBUGGING outb_p(BOCHS_LOGGER_PORT,c); - +#endif + +#ifdef SERIAL_DEBUGGING + while ((inb_p(SER_LSR) & SR_LSR_TBE) == 0) + ; + outb_p(SER_THR, c); +#endif + switch(c) { case '\n': @@ -288,6 +333,17 @@ void HalInitConsole(boot_param* bp) * bp = Parameters setup by the boot loader */ { + +#ifdef SERIAL_DEBUGGING + /* turn on DTR and RTS */ + outb_p(SER_MCR, SR_MCR_DTR | SR_MCR_RTS); + /* set baud rate, line control */ + outb_p(SER_LCR, SERIAL_LINE_CONTROL | SR_LCR_DLAB); + outb_p(SER_DLL, (115200 / SERIAL_BAUD_RATE) & 0xff); + outb_p(SER_DLM, ((115200 / SERIAL_BAUD_RATE) >> 8) & 0xff); + outb_p(SER_LCR, SERIAL_LINE_CONTROL); +#endif + cursorx=bp->cursorx; cursory=bp->cursory; }