mirror of
https://github.com/reactos/reactos.git
synced 2024-10-04 08:25:53 +00:00
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. svn path=/trunk/; revision=32327
This commit is contained in:
parent
0531986011
commit
b8a06afb8c
|
@ -47,6 +47,11 @@ ULONG LenBits[] =
|
|||
8 // 8 words per line (32 bytes)
|
||||
};
|
||||
|
||||
//
|
||||
// Where to map the serial port
|
||||
//
|
||||
#define UART_VIRTUAL 0xC0000000
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
VOID
|
||||
|
@ -116,6 +121,12 @@ ArmSetupPageDirectory(VOID)
|
|||
//
|
||||
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 @@ ArmSetupPagingAndJump(IN ULONG Magic)
|
|||
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
|
||||
//
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "arc/arc.h"
|
||||
#include "windbgkd.h"
|
||||
#include <kddll.h>
|
||||
#include <ioaccess.h> /* port intrinsics */
|
||||
|
||||
typedef struct _KD_PORT_INFORMATION
|
||||
{
|
||||
|
|
|
@ -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>
|
||||
|
|
24
reactos/drivers/base/kdcom/kdcom_arm.def
Normal file
24
reactos/drivers/base/kdcom/kdcom_arm.def
Normal file
|
@ -0,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
|
84
reactos/ntoskrnl/ke/arm/arm_kprintf.c
Normal file
84
reactos/ntoskrnl/ke/arm/arm_kprintf.c
Normal file
|
@ -0,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);
|
||||
}
|
|
@ -12,6 +12,8 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
void arm_kprintf(const char *fmt, ...);
|
||||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
BOOLEAN KeIsArmV6;
|
||||
|
@ -91,6 +93,7 @@ VOID
|
|||
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!)
|
||||
//
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue