Author: ros-arm-bringup
Date: Wed Feb 6 10:32:47 2008
New Revision: 32151
URL:
http://svn.reactos.org/svn/reactos?rev=32151&view=rev
Log:
We implemented console support (through serial port), for the current board types
supported (Feroceon, using UART 16550).
We added a new ClockRate member to the ARM Board Block structure.
We now print out the FreeLDR header after initialization to give some output to the user
that we are alive.
Started putting shared stuff in headers.
Fixed copy/paste leftovers from file headers (wrong file names, implementation details,
author).
Added:
trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c (with props)
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/arm/boot.s
trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c
trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c
trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c
trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild
trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h
trunk/reactos/boot/freeldr/freeldr/include/ramdisk.h
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/boot.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/boot.s (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/boot.s Wed Feb 6 10:32:47 2008
@@ -3,7 +3,7 @@
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/arch/arm/boot.s
* PURPOSE: Implements the entry point for ARM machines
- * PROGRAMMERS: alex(a)winsiderss.com
+ * PROGRAMMERS: ReactOS Portable Systems Group
*/
/* INCLUDES *******************************************************************/
Added: trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c (added)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c Wed Feb 6 10:32:47 2008
@@ -1,0 +1,130 @@
+/*
+ * PROJECT: ReactOS Boot Loader
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: boot/freeldr/arch/arm/ferouart.c
+ * PURPOSE: Implements code for Feroceon boards using the 16550 UART
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <freeldr.h>
+
+/* GLOBALS ********************************************************************/
+
+//
+// UART Registers
+//
+#define UART0_RBR (ArmBoardBlock->UartRegisterBase + 0x00)
+#define UART0_THR UART0_RBR
+#define UART0_IER (ArmBoardBlock->UartRegisterBase + 0x04)
+#define UART0_FCR (ArmBoardBlock->UartRegisterBase + 0x08)
+#define UART0_LCR (ArmBoardBlock->UartRegisterBase + 0x0C)
+#define UART0_MCR (ArmBoardBlock->UartRegisterBase + 0x10)
+#define UART0_LSR (ArmBoardBlock->UartRegisterBase + 0x14)
+#define UART0_MSR (ArmBoardBlock->UartRegisterBase + 0x18)
+#define UART0_SCR (ArmBoardBlock->UartRegisterBase + 0x1C)
+
+//
+// When we enable the divisor latch
+//
+#define UART0_DLL UART0_RBR
+#define UART0_DLM UART0_IER
+
+//
+// FCR Values
+//
+#define FCR_FIFO_EN 0x01
+#define FCR_RXSR 0x02
+#define FCR_TXSR 0x04
+
+//
+// LCR Values
+//
+#define LCR_WLS_8 0x03
+#define LCR_1_STB 0x00
+#define LCR_DIVL_EN 0x80
+#define LCR_NO_PAR 0x00
+
+//
+// LSR Values
+//
+#define LSR_DR 0x01
+#define LSR_THRE 0x20
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+ArmFeroSerialInit(IN ULONG Baudrate)
+{
+ ULONG BaudClock;
+
+ //
+ // Calculate baudrate clock divider to set the baud rate
+ //
+ BaudClock = (ArmBoardBlock->ClockRate / 16) / Baudrate;
+
+ //
+ // Disable interrupts
+ //
+ WRITE_REGISTER_UCHAR(UART0_IER, 0);
+
+ //
+ // Set the baud rate to 115200 bps
+ //
+ WRITE_REGISTER_UCHAR(UART0_LCR, LCR_DIVL_EN);
+ WRITE_REGISTER_UCHAR(UART0_DLL, BaudClock);
+ WRITE_REGISTER_UCHAR(UART0_DLM, (BaudClock >> 8) & 0xFF);
+
+ //
+ // Set 8 bits for data, 1 stop bit, no parity
+ //
+ WRITE_REGISTER_UCHAR(UART0_LCR, LCR_WLS_8 | LCR_1_STB | LCR_NO_PAR);
+
+ //
+ // Clear and enable FIFO
+ //
+ WRITE_REGISTER_UCHAR(UART0_FCR, FCR_FIFO_EN | FCR_RXSR | FCR_TXSR);
+}
+
+VOID
+ArmFeroPutChar(IN INT Char)
+{
+ //
+ // Properly support new-lines
+ //
+ if (Char == '\n') ArmFeroPutChar('\r');
+
+ //
+ // Wait for ready
+ //
+ while ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_THRE) == 0);
+
+ //
+ // Send the character
+ //
+ WRITE_REGISTER_UCHAR(UART0_THR, Char);
+}
+
+INT
+ArmFeroGetCh(VOID)
+{
+ //
+ // Wait for ready
+ //
+ while ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_DR) == 0);
+
+ //
+ // Read the character
+ //
+ return READ_REGISTER_UCHAR(UART0_RBR);
+}
+
+BOOLEAN
+ArmFeroKbHit(VOID)
+{
+ //
+ // Return if something is ready
+ //
+ return ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_DR) != 0);
+}
Propchange: trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c Wed Feb 6 10:32:47 2008
@@ -2,8 +2,8 @@
* PROJECT: ReactOS Boot Loader
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/arch/arm/marcharm.c
- * PURPOSE: Implements ARM-specific machine initialization
- * PROGRAMMERS: alex(a)winsiderss.com
+ * PURPOSE: Provides abstraction between the ARM Boot Loader and FreeLDR
+ * PROGRAMMERS: ReactOS Portable Systems Group
*/
/* INCLUDES *******************************************************************/
@@ -12,37 +12,9 @@
/* GLOBALS ********************************************************************/
-//
-// The only things we support
-//
-typedef enum _ARM_BOARD_TYPE
-{
- //
- // Marvell Feroceon-based SoC:
- // Buffalo Linkstation, KuroBox Pro, D-Link DS323 and others
- //
- ARM_FEROCEON = 1,
-} ARM_BOARD_TYPE;
-
-//
-// Compatible boot-loaders should return us this information
-//
-#define ARM_BOARD_CONFIGURATION_MAJOR_VERSION 1
-#define ARM_BOARD_CONFIGURATION_MINOR_VERSION 1
-typedef struct _ARM_BOARD_CONFIGURATION_BLOCK
-{
- ULONG MajorVersion;
- ULONG MinorVersion;
- ARM_BOARD_TYPE BoardType;
- ULONG TimerRegisterBase;
- ULONG UartRegisterBase;
- PBIOS_MEMORY_MAP MemoryMap;
- CHAR CommandLine[256];
-} ARM_BOARD_CONFIGURATION_BLOCK, *PARM_BOARD_CONFIGURATION_BLOCK;
+PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
/* FUNCTIONS ******************************************************************/
-
-PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
VOID
ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c Wed Feb 6 10:32:47 2008
@@ -3,7 +3,7 @@
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/arch/arm/stubs.c
* PURPOSE: Non-completed ARM hardware-specific routines
- * PROGRAMMERS: alex(a)winsiderss.com
+ * PROGRAMMERS: ReactOS Portable Systems Group
*/
/* INCLUDES *******************************************************************/
@@ -22,26 +22,6 @@
//
// Start the OS
//
-}
-
-VOID
-ArmConsPutChar(INT Char)
-{
- while (TRUE);
-}
-
-BOOLEAN
-ArmConsKbHit(VOID)
-{
- while (TRUE);
- return FALSE;
-}
-
-INT
-ArmConsGetCh(VOID)
-{
- while (TRUE);
- return FALSE;
}
BOOLEAN
@@ -155,11 +135,31 @@
MachInit(IN PCCH CommandLine)
{
//
- // Setup ARM routines
+ // Setup board-specific ARM routines
//
- MachVtbl.ConsPutChar = ArmConsPutChar;
- MachVtbl.ConsKbHit = ArmConsKbHit;
- MachVtbl.ConsGetCh = ArmConsGetCh;
+ switch (ArmBoardBlock->BoardType)
+ {
+ //
+ // Check for Feroceon-base boards
+ //
+ case ARM_FEROCEON:
+
+ //
+ // These boards use a UART16550. Set us up for 115200 bps
+ //
+ ArmFeroSerialInit(115200);
+ MachVtbl.ConsPutChar = ArmFeroPutChar;
+ MachVtbl.ConsKbHit = ArmFeroKbHit;
+ MachVtbl.ConsGetCh = ArmFeroGetCh;
+ break;
+
+ default:
+ ASSERT(FALSE);
+ }
+
+ //
+ // Setup generic ARM routines
+ //
MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
MachVtbl.DiskGetBootVolume = ArmDiskGetBootVolume;
@@ -173,4 +173,9 @@
MachVtbl.DiskGetDriveGeometry = ArmDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = ArmDiskGetCacheableBlockCount;
MachVtbl.HwDetect = ArmHwDetect;
+
+ //
+ // We can now print to the console
+ //
+ TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
}
Modified: trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c Wed Feb 6 10:32:47 2008
@@ -3,7 +3,7 @@
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/arch/i386/ramdisk.c
* PURPOSE: Implements routines to support booting from a RAM Disk
- * PROGRAMMERS: alex(a)winsiderss.com
+ * PROGRAMMERS: ReactOS Portable Systems Group
*/
/* INCLUDES *******************************************************************/
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild (original)
+++ trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild Wed Feb 6 10:32:47 2008
@@ -101,6 +101,7 @@
<define name="DEBUG" />
<define name="_NTHAL_" />
<file>boot.s</file>
+ <file>ferouart.c</file>
<file>macharm.c</file>
<file>stubs.c</file>
</module>
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h Wed Feb 6 10:32:47
2008
@@ -2,8 +2,8 @@
* PROJECT: ReactOS Boot Loader
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/include/arch/arm/hardware.h
- * PURPOSE: Implements routines to support booting from a RAM Disk
- * PROGRAMMERS: alex(a)winsiderss.com
+ * PURPOSE: Header for ARC definitions (to be cleaned up)
+ * PROGRAMMERS: ReactOS Portable Systems Group
*/
#ifndef _ARM_HARDWARE_
@@ -12,6 +12,35 @@
#ifndef __REGISTRY_H
#include "../../reactos/registry.h"
#endif
+
+//
+// The only things we support
+//
+typedef enum _ARM_BOARD_TYPE
+{
+ //
+ // Marvell Feroceon-based SoC:
+ // Buffalo Linkstation, KuroBox Pro, D-Link DS323 and others
+ //
+ ARM_FEROCEON = 1,
+} ARM_BOARD_TYPE;
+
+//
+// Compatible boot-loaders should return us this information
+//
+#define ARM_BOARD_CONFIGURATION_MAJOR_VERSION 1
+#define ARM_BOARD_CONFIGURATION_MINOR_VERSION 1
+typedef struct _ARM_BOARD_CONFIGURATION_BLOCK
+{
+ ULONG MajorVersion;
+ ULONG MinorVersion;
+ ARM_BOARD_TYPE BoardType;
+ ULONG ClockRate;
+ ULONG TimerRegisterBase;
+ ULONG UartRegisterBase;
+ PBIOS_MEMORY_MAP MemoryMap;
+ CHAR CommandLine[256];
+} ARM_BOARD_CONFIGURATION_BLOCK, *PARM_BOARD_CONFIGURATION_BLOCK;
//
// Static heap for ARC Hardware Component Tree
@@ -63,4 +92,18 @@
IN ULONG Size
);
+VOID
+ArmFeroSerialInit(IN ULONG Baudrate);
+
+VOID
+ArmFeroPutChar(IN INT Char);
+
+INT
+ArmFeroGetCh(VOID);
+
+BOOLEAN
+ArmFeroKbHit(VOID);
+
+extern PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
+
#endif
Modified: trunk/reactos/boot/freeldr/freeldr/include/ramdisk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/ramdisk.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/ramdisk.h Wed Feb 6 10:32:47 2008
@@ -3,7 +3,7 @@
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/include/ramdisk.h
* PURPOSE: Header file for ramdisk support
- * PROGRAMMERS: alex(a)winsiderss.com
+ * PROGRAMMERS: ReactOS Portable Systems Group
*/
#ifndef _RAMDISK_