[ros-diffs] [ros-arm-bringup] 32305: We now support the ARM Versatile/PB platform, which means qemu-system-arm -M versatilepb is now able to emulate the ARM build of ReactOS. We now support the PL011 UART, required for console output on the Versatile. We now define the ARM_LOADER_BLOCK structure, to be used later when FreeLDR passes control to the kernel.

ros-arm-bringup at svn.reactos.org ros-arm-bringup at svn.reactos.org
Mon Feb 11 21:15:16 CET 2008


Author: ros-arm-bringup
Date: Mon Feb 11 23:15:16 2008
New Revision: 32305

URL: http://svn.reactos.org/svn/reactos?rev=32305&view=rev
Log:
We now support the ARM Versatile/PB platform, which means qemu-system-arm -M versatilepb is now able to emulate the ARM build of ReactOS.
We now support the PL011 UART, required for console output on the Versatile.
We now define the ARM_LOADER_BLOCK structure, to be used later when FreeLDR passes control to the kernel.

Added:
    trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c   (with props)
Modified:
    trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c
    trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c
    trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild
    trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h
    trunk/reactos/include/reactos/arc/arc.h

Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c?rev=32305&r1=32304&r2=32305&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c Mon Feb 11 23:15:16 2008
@@ -34,7 +34,8 @@
     //
     // This should probably go away once we support more boards
     //
-    ASSERT(ArmBoardBlock->BoardType == ARM_FEROCEON);
+    ASSERT((ArmBoardBlock->BoardType == MACH_TYPE_FEROCEON) ||
+           (ArmBoardBlock->BoardType == MACH_TYPE_VERSATILE_PB));
 
     //
     // Call FreeLDR's portable entrypoint with our command-line

Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c?rev=32305&r1=32304&r2=32305&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c Mon Feb 11 23:15:16 2008
@@ -15,14 +15,6 @@
 ULONG PageDirectoryStart, PageDirectoryEnd;
 
 /* FUNCTIONS ******************************************************************/
-
-VOID
-FrLdrStartup(IN ULONG Magic)
-{
-    //
-    // Start the OS
-    //
-}
 
 BOOLEAN
 ArmDiskGetDriveGeometry(IN ULONG DriveNumber,
@@ -110,7 +102,7 @@
         //
         // Check for Feroceon-base boards
         //
-        case ARM_FEROCEON:
+        case MACH_TYPE_FEROCEON:
             
             //
             // These boards use a UART16550. Set us up for 115200 bps
@@ -119,6 +111,20 @@
             MachVtbl.ConsPutChar = ArmFeroPutChar;
             MachVtbl.ConsKbHit = ArmFeroKbHit;
             MachVtbl.ConsGetCh = ArmFeroGetCh;
+            break;
+            
+        //
+        // Check for ARM Versatile PB boards
+        //
+        case MACH_TYPE_VERSATILE_PB:
+            
+            //
+            // These boards use a PrimeCell UART (PL011)
+            //
+            ArmVersaSerialInit(115200);
+            MachVtbl.ConsPutChar = ArmVersaPutChar;
+            MachVtbl.ConsKbHit = ArmVersaKbHit;
+            MachVtbl.ConsGetCh = ArmVersaGetCh;
             break;
             
         default:
@@ -157,3 +163,9 @@
     TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
     TuiPrintf("Bootargs: %s\n", CommandLine);
 }
+
+VOID
+FrLdrStartup(IN ULONG Magic)
+{
+    while (TRUE);
+}

Added: trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c?rev=32305&view=auto
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c (added)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c Mon Feb 11 23:15:16 2008
@@ -1,0 +1,132 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            boot/freeldr/arch/arm/versuart.c
+ * PURPOSE:         Implements code for Versatile boards using the PL011 UART
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <freeldr.h>
+
+/* GLOBALS ********************************************************************/
+
+//
+// UART Registers
+//
+#define UART_PL01x_DR            (ArmBoardBlock->UartRegisterBase + 0x00)
+#define UART_PL01x_RSR           (ArmBoardBlock->UartRegisterBase + 0x04)
+#define UART_PL01x_ECR           (ArmBoardBlock->UartRegisterBase + 0x04)
+#define UART_PL01x_FR            (ArmBoardBlock->UartRegisterBase + 0x18)
+#define UART_PL011_IBRD          (ArmBoardBlock->UartRegisterBase + 0x24)
+#define UART_PL011_FBRD          (ArmBoardBlock->UartRegisterBase + 0x28)
+#define UART_PL011_LCRH          (ArmBoardBlock->UartRegisterBase + 0x2C)
+#define UART_PL011_CR            (ArmBoardBlock->UartRegisterBase + 0x30)
+#define UART_PL011_IMSC          (ArmBoardBlock->UartRegisterBase + 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
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+ArmVersaSerialInit(IN ULONG Baudrate)
+{
+    ULONG Divider, Remainder, Fraction;
+    
+    //
+    // Calculate baudrate clock divider and remainder
+    //
+    Divider   = ArmBoardBlock->ClockRate / (16 * Baudrate);
+    Remainder = ArmBoardBlock->ClockRate % (16 * Baudrate);
+    
+    //
+    // Calculate the fractional part
+    //
+    Fraction  = (8 * Remainder / Baudrate) >> 1;
+    Fraction += (8 * Remainder / Baudrate) & 1;
+    
+    //
+    // Disable interrupts
+    //
+    WRITE_REGISTER_ULONG(UART_PL011_CR, 0);
+    
+    //
+    // Set the baud rate to 115200 bps
+    //
+    WRITE_REGISTER_ULONG(UART_PL011_IBRD, Divider);
+    WRITE_REGISTER_ULONG(UART_PL011_FBRD, Fraction);
+    
+    //
+    // Set 8 bits for data, 1 stop bit, no parity, FIFO enabled
+    //
+    WRITE_REGISTER_ULONG(UART_PL011_LCRH,
+                         UART_PL011_LCRH_WLEN_8 | UART_PL011_LCRH_FEN);
+    
+    //
+    // Clear and enable FIFO
+    //
+    WRITE_REGISTER_ULONG(UART_PL011_CR,
+                         UART_PL011_CR_UARTEN |
+                         UART_PL011_CR_TXE |
+                         UART_PL011_CR_RXE);
+}
+
+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);
+}
+
+INT
+ArmVersaGetCh(VOID)
+{
+    //
+    // Wait for ready
+    //
+    while ((READ_REGISTER_ULONG(UART_PL01x_FR) & UART_PL01x_FR_RXFE) != 0);
+    
+    //
+    // Read the character
+    //
+    return READ_REGISTER_ULONG(UART_PL01x_DR);
+}
+
+BOOLEAN
+ArmVersaKbHit(VOID)
+{
+    //
+    // Return if something is ready
+    //
+    return ((READ_REGISTER_ULONG(UART_PL01x_FR) & UART_PL01x_FR_RXFE) == 0);
+}

Propchange: trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild?rev=32305&r1=32304&r2=32305&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild (original)
+++ trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild Mon Feb 11 23:15:16 2008
@@ -102,6 +102,7 @@
 				<define name="_NTHAL_" />
 				<file>boot.s</file>
 				<file>ferouart.c</file>
+				<file>versuart.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/include/arch/arm/hardware.h?rev=32305&r1=32304&r2=32305&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h Mon Feb 11 23:15:16 2008
@@ -14,16 +14,16 @@
 #endif
 
 //
-// The only things we support
+// Marvell Feroceon-based SoC:
+// Buffalo Linkstation, KuroBox Pro, D-Link DS323 and others
 //
-typedef enum _ARM_BOARD_TYPE
-{
-    //
-    // Marvell Feroceon-based SoC:
-    // Buffalo Linkstation, KuroBox Pro, D-Link DS323 and others
-    //
-    ARM_FEROCEON = 1,
-} ARM_BOARD_TYPE;
+#define MACH_TYPE_FEROCEON     526
+
+//
+// ARM Versatile PB:
+// qemu-system-arm -M versatilepb, RealView Development Boards and others
+//
+#define MACH_TYPE_VERSATILE_PB 387
 
 //
 // Compatible boot-loaders should return us this information
@@ -34,7 +34,7 @@
 {
     ULONG MajorVersion;
     ULONG MinorVersion;
-    ARM_BOARD_TYPE BoardType;
+    ULONG BoardType;
     ULONG ClockRate;
     ULONG TimerRegisterBase;
     ULONG UartRegisterBase;
@@ -105,6 +105,18 @@
 BOOLEAN
 ArmFeroKbHit(VOID);
 
+VOID
+ArmVersaSerialInit(IN ULONG Baudrate);
+
+VOID
+ArmVersaPutChar(IN INT Char);
+
+INT
+ArmVersaGetCh(VOID);
+
+BOOLEAN
+ArmVersaKbHit(VOID);
+
 extern PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
 
 #endif

Modified: trunk/reactos/include/reactos/arc/arc.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/arc/arc.h?rev=32305&r1=32304&r2=32305&view=diff
==============================================================================
--- trunk/reactos/include/reactos/arc/arc.h (original)
+++ trunk/reactos/include/reactos/arc/arc.h Mon Feb 11 23:15:16 2008
@@ -351,6 +351,28 @@
     ULONG MachineType;
 } PPC_LOADER_BLOCK, *PPPC_LOADER_BLOCK;
 
+typedef struct _ARM_LOADER_BLOCK
+{
+#ifdef _ARM_
+    ULONG InterruptStack;
+    ULONG FirstLevelDcacheSize;
+    ULONG FirstLevelDcacheFillSize;
+    ULONG FirstLevelIcacheSize;
+    ULONG FirstLevelIcacheFillSize;
+    ULONG GpBase;
+    ULONG PanicStack;
+    ULONG PcrPage;
+    ULONG PdrPage;
+    ULONG SecondLevelDcacheSize;
+    ULONG SecondLevelDcacheFillSize;
+    ULONG SecondLevelIcacheSize;
+    ULONG SecondLevelIcacheFillSize;
+    ULONG PcrPage2;
+#else
+    ULONG PlaceHolder;
+#endif
+} ARM_LOADER_BLOCK, *PARM_LOADER_BLOCK;
+
 //
 // Firmware information block (NT6+)
 //
@@ -426,7 +448,8 @@
         I386_LOADER_BLOCK I386;
         ALPHA_LOADER_BLOCK Alpha;
         IA64_LOADER_BLOCK Ia64;
-	PPC_LOADER_BLOCK PowerPC;
+        PPC_LOADER_BLOCK PowerPC;
+        ARM_LOADER_BLOCK Arm;
     } u;
     FIRMWARE_INFORMATION_LOADER_BLOCK FirmwareInformation;
 } LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK;




More information about the Ros-diffs mailing list