Author: ros-arm-bringup
Date: Tue Feb 12 20:45:58 2008
New Revision: 32327
URL:
http://svn.reactos.org/svn/reactos?rev=32327&view=rev
Log:
Added arm_kprintf() for early kernel debugging (ARM bringup).
Freeldr maps the "Versatile"'s serial port into virtual
memory now, and C code can just use arm_kprintf().
This is not code that is supposed to remain in the kernel,
it's only needed for bringup, until enough is working so
that standard serial DbgPrint() works through the original
code path.
Added:
trunk/reactos/drivers/base/kdcom/kdcom_arm.def (with props)
trunk/reactos/drivers/base/kdcom/kdcom_i386.def
- copied unchanged from r32324, trunk/reactos/drivers/base/kdcom/kdcom.def
trunk/reactos/ntoskrnl/ke/arm/arm_kprintf.c (with props)
Removed:
trunk/reactos/drivers/base/kdcom/kdcom.def
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c
trunk/reactos/drivers/base/kdcom/kdbg.c
trunk/reactos/drivers/base/kdcom/kdcom.rbuild
trunk/reactos/ntoskrnl/ke/arm/kiinit.c
trunk/reactos/ntoskrnl/ntoskrnl.rbuild
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c Tue Feb 12 20:45:58 2008
@@ -46,6 +46,11 @@
-1, // INVALID
8 // 8 words per line (32 bytes)
};
+
+//
+// Where to map the serial port
+//
+#define UART_VIRTUAL 0xC0000000
/* FUNCTIONS ******************************************************************/
@@ -116,6 +121,12 @@
//
Pte.L1.Section.BaseAddress = 0;
TranslationTable->Pte[0] = Pte;
+
+ //
+ // Map the page in MMIO space that contains the serial port into virtual memory
+ //
+ Pte.L1.Section.BaseAddress = ArmBoardBlock->UartRegisterBase >> TTB_SHIFT;
+ TranslationTable->Pte[UART_VIRTUAL >> TTB_SHIFT] = Pte;
}
VOID
@@ -132,6 +143,9 @@
ControlRegister.DCacheEnabled = TRUE;
KeArmControlRegisterSet(ControlRegister);
+ ArmBoardBlock->UartRegisterBase = UART_VIRTUAL | (ArmBoardBlock->UartRegisterBase
& ((1<<TTB_SHIFT)-1));
+ TuiPrintf("Mapped serial port to 0x%x\n",
ArmBoardBlock->UartRegisterBase);
+
//
// Jump to Kernel
//
Modified: trunk/reactos/drivers/base/kdcom/kdbg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdcom/kdbg.c?…
==============================================================================
--- trunk/reactos/drivers/base/kdcom/kdbg.c (original)
+++ trunk/reactos/drivers/base/kdcom/kdbg.c Tue Feb 12 20:45:58 2008
@@ -18,6 +18,7 @@
#include "arc/arc.h"
#include "windbgkd.h"
#include <kddll.h>
+#include <ioaccess.h> /* port intrinsics */
typedef struct _KD_PORT_INFORMATION
{
Removed: trunk/reactos/drivers/base/kdcom/kdcom.def
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdcom/kdcom.d…
==============================================================================
--- trunk/reactos/drivers/base/kdcom/kdcom.def (original)
+++ trunk/reactos/drivers/base/kdcom/kdcom.def (removed)
@@ -1,24 +1,0 @@
-LIBRARY kdcom.dll
-EXPORTS
-
-; Old KD
-KdPortGetByte@4
-KdPortGetByteEx@8
-KdPortInitialize@12
-KdPortInitializeEx@12
-KdPortPollByte@4
-KdPortPollByteEx@8
-KdPortPutByte@4
-KdPortPutByteEx@8
-KdPortRestore@0
-KdPortSave@0
-KdPortDisableInterrupts@0
-KdPortEnableInterrupts@0
-
-; New KD
-KdDebuggerInitialize0@4
-KdDebuggerInitialize1@4
-KdSave@4
-KdRestore@4
-KdReceivePacket@20
-KdSendPacket@16
Modified: trunk/reactos/drivers/base/kdcom/kdcom.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdcom/kdcom.r…
==============================================================================
--- trunk/reactos/drivers/base/kdcom/kdcom.rbuild (original)
+++ trunk/reactos/drivers/base/kdcom/kdcom.rbuild Tue Feb 12 20:45:58 2008
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="kdcom" type="kernelmodedll"
entrypoint="DriverEntry@8" installbase="system32/drivers"
installname="kdcom.dll">
- <importlibrary definition="kdcom.def"></importlibrary>
+ <importlibrary definition="kdcom_$(ARCH).def"></importlibrary>
<bootstrap installbase="$(CDOUTPUT)" nameoncd="kdcom.dll" />
<include base="kdcom">.</include>
<library>ntoskrnl</library>
Added: trunk/reactos/drivers/base/kdcom/kdcom_arm.def
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdcom/kdcom_a…
==============================================================================
--- trunk/reactos/drivers/base/kdcom/kdcom_arm.def (added)
+++ trunk/reactos/drivers/base/kdcom/kdcom_arm.def Tue Feb 12 20:45:58 2008
@@ -1,0 +1,24 @@
+LIBRARY kdcom.dll
+EXPORTS
+
+; Old KD
+KdPortGetByte
+KdPortGetByteEx
+KdPortInitialize
+KdPortInitializeEx
+KdPortPollByte
+KdPortPollByteEx
+KdPortPutByte
+KdPortPutByteEx
+KdPortRestore
+KdPortSave
+KdPortDisableInterrupts
+KdPortEnableInterrupts
+
+; New KD
+KdDebuggerInitialize0
+KdDebuggerInitialize1
+KdSave
+KdRestore
+KdReceivePacket
+KdSendPacket
Propchange: trunk/reactos/drivers/base/kdcom/kdcom_arm.def
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/drivers/base/kdcom/kdcom_arm.def
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: trunk/reactos/ntoskrnl/ke/arm/arm_kprintf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/arm_kprint…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/arm_kprintf.c (added)
+++ trunk/reactos/ntoskrnl/ke/arm/arm_kprintf.c Tue Feb 12 20:45:58 2008
@@ -1,0 +1,84 @@
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/ke/arm/arm_kprintf.c
+ * PURPOSE: Early serial printf-style kernel debugging (ARM bringup)
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+//
+// UART Registers
+//
+#define UART_BASE (void*)0xc00f1000 /* HACK: freeldr mapped it here */
+
+#define UART_PL01x_DR (UART_BASE + 0x00)
+#define UART_PL01x_RSR (UART_BASE + 0x04)
+#define UART_PL01x_ECR (UART_BASE + 0x04)
+#define UART_PL01x_FR (UART_BASE + 0x18)
+#define UART_PL011_IBRD (UART_BASE + 0x24)
+#define UART_PL011_FBRD (UART_BASE + 0x28)
+#define UART_PL011_LCRH (UART_BASE + 0x2C)
+#define UART_PL011_CR (UART_BASE + 0x30)
+#define UART_PL011_IMSC (UART_BASE + 0x38)
+
+//
+// LCR Values
+//
+#define UART_PL011_LCRH_WLEN_8 0x60
+#define UART_PL011_LCRH_FEN 0x10
+
+//
+// FCR Values
+//
+#define UART_PL011_CR_UARTEN 0x01
+#define UART_PL011_CR_TXE 0x100
+#define UART_PL011_CR_RXE 0x200
+
+//
+// LSR Values
+//
+#define UART_PL01x_FR_RXFE 0x10
+#define UART_PL01x_FR_TXFF 0x20
+
+#define READ_REGISTER_ULONG(r) (*(volatile ULONG * const)(r))
+#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG *)(r) = (v))
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+ArmVersaPutChar(IN INT Char)
+{
+ //
+ // Properly support new-lines
+ //
+ if (Char == '\n') ArmVersaPutChar('\r');
+
+ //
+ // Wait for ready
+ //
+ while ((READ_REGISTER_ULONG(UART_PL01x_FR) & UART_PL01x_FR_TXFF) != 0);
+
+ //
+ // Send the character
+ //
+ WRITE_REGISTER_ULONG(UART_PL01x_DR, Char);
+}
+
+void arm_kprintf(const char *fmt, ...) {
+ char buf[1024], *s;
+ va_list args;
+
+ va_start(args, fmt);
+ _vsnprintf(buf,sizeof(buf),fmt,args);
+ va_end(args);
+ for (s = buf; *s; s++)
+ ArmVersaPutChar(*s);
+}
Propchange: trunk/reactos/ntoskrnl/ke/arm/arm_kprintf.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/ntoskrnl/ke/arm/arm_kprintf.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: trunk/reactos/ntoskrnl/ke/arm/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/kiinit.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/kiinit.c (original)
+++ trunk/reactos/ntoskrnl/ke/arm/kiinit.c Tue Feb 12 20:45:58 2008
@@ -11,6 +11,8 @@
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
+
+void arm_kprintf(const char *fmt, ...);
/* GLOBALS ********************************************************************/
@@ -91,6 +93,7 @@
KiInitializeSystem(IN ULONG Magic,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
+ arm_kprintf("%s:%i\n", __func__, __LINE__);
//
// Detect ARM version (Architecture 6 is the ARMv5TE-J, go figure!)
//
Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?r…
==============================================================================
--- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Tue Feb 12 20:45:58 2008
@@ -60,6 +60,7 @@
<if property="ARCH" value="arm">
<directory name="arm">
<file first="true">boot.s</file>
+ <file>arm_kprintf.c</file>
<file>kiinit.c</file>
<file>stubs_asm.s</file>
<file>stubs.c</file>