[ros-diffs] [ros-arm-bringup] 32148: Implement a proper ARM startup routine. We disable the FIQ and IRQ lines, then disable and flush D and I caches, set up a temporary boot stack, and call ArmInit. In ArmInit we define the structure that a compatible bootloader has to send us and currently make some assertions on it, before dropping into the common, portable, freeldr startup (BootMain). This would be the place where we would want to setup UART0 for serial support later on, as well as TIMER0. In MachInit, we now define the required ARM routines we'll need, all which simply loop for now. Also fix a bug in RamDiskInit, which could do reads from NULL pointers.

ros-arm-bringup at svn.reactos.org ros-arm-bringup at svn.reactos.org
Wed Feb 6 05:48:22 CET 2008


Author: ros-arm-bringup
Date: Wed Feb  6 07:48:22 2008
New Revision: 32148

URL: http://svn.reactos.org/svn/reactos?rev=32148&view=rev
Log:
Implement a proper ARM startup routine. We disable the FIQ and IRQ lines, then disable and flush D and I caches, set up a temporary boot stack, and call ArmInit.
In ArmInit we define the structure that a compatible bootloader has to send us and currently make some assertions on it, before dropping into the common, portable, freeldr startup (BootMain).
This would be the place where we would want to setup UART0 for serial support later on, as well as TIMER0.
In MachInit, we now define the required ARM routines we'll need, all which simply loop for now.
Also fix a bug in RamDiskInit, which could do reads from NULL pointers.


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

Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/boot.s
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/arm/boot.s?rev=32148&r1=32147&r2=32148&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/boot.s (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/boot.s Wed Feb  6 07:48:22 2008
@@ -10,12 +10,70 @@
 
 //#include <kxarm.h>
 
+#define CPSR_IRQ_DISABLE        0x80
+#define CPSR_FIQ_DISABLE        0x40
+#define CPSR_THUMB_ENABLE       0x20
+
+#define C1_MMU_CONTROL          0x01
+#define C1_ALIGNMENT_CONTROL    0x02
+#define C1_DCACHE_CONTROL       0x04
+#define C1_ICACHE_CONTROL       0x1000
+#define C1_VECTOR_CONTROL       0x2000
+
 /* GLOBALS ********************************************************************/
 
 .global _start
 .section startup
+   
+/* BOOT CODE ******************************************************************/
+   
+_start:
+    //
+    // C entrypoint
+    //
+    ldr lr, L_ArmInit
+
+    //
+    // Turn off FIQs and IRQs
+    // FreeLDR runs without interrupts, and without paging, just like on x86
+    //
+    mrs r1, cpsr
+    orr r1, r1, #CPSR_IRQ_DISABLE | CPSR_FIQ_DISABLE
+    msr cpsr, r1
     
-/* BOOT CODE ******************************************************************/
+    //
+    // Turn off caches
+    //
+    mrc p15, 0, r1, c1, c0, 0
+    bic r1, r1, #C1_DCACHE_CONTROL
+    bic r1, r1, #C1_ICACHE_CONTROL
+    mcr p15, 0, r1, c1, c0, 0
+    
+    //
+    // Flush everything away
+    //
+    mov r1, #0
+    mcr p15, 0, r1, c7, c7, 0
+    
+    //
+    // Okay, now give us a stack
+    //
+    ldr sp, L_BootStackEnd
 
-_start:
-	b .
+    //
+    // Go ahead and call the C initialization code
+    // r0 contains the ARM_BOARD_CONFIGURATION_DATA structure
+    //
+    bx lr
+
+L_BootStackEnd:
+    .long BootStackEnd
+
+L_ArmInit:
+    .long ArmInit
+
+	.align 4
+BootStack:
+	.space 0x4000
+BootStackEnd:
+    .long 0

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=32148&r1=32147&r2=32148&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c Wed Feb  6 07:48:22 2008
@@ -12,12 +12,60 @@
 
 /* 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;
+
 /* FUNCTIONS ******************************************************************/
 
+PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
+
 VOID
-MachInit(IN PCCH CommandLine)
+ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
 {
     //
-    // Setup ARM routines
+    // Remember the pointer
     //
+    ArmBoardBlock = BootContext;
+    
+    //
+    // Let's make sure we understand the boot-loader
+    //
+    ASSERT(ArmBoardBlock->MajorVersion == ARM_BOARD_CONFIGURATION_MAJOR_VERSION);
+    ASSERT(ArmBoardBlock->MinorVersion == ARM_BOARD_CONFIGURATION_MINOR_VERSION);
+    
+    //
+    // This should probably go away once we support more boards
+    //
+    ASSERT(ArmBoardBlock->BoardType == ARM_FEROCEON);
+
+    //
+    // Call FreeLDR's portable entrypoint with our command-line
+    //
+    BootMain(ArmBoardBlock->CommandLine);
 }
+

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=32148&r1=32147&r2=32148&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c Wed Feb  6 07:48:22 2008
@@ -23,3 +23,154 @@
     // Start the OS
     //
 }
+
+VOID
+ArmConsPutChar(INT Char)
+{
+    while (TRUE);
+}
+
+BOOLEAN
+ArmConsKbHit(VOID)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+INT
+ArmConsGetCh(VOID)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+BOOLEAN
+ArmDiskGetBootVolume(IN PULONG DriveNumber,
+                     IN PULONGLONG StartSector,
+                     IN PULONGLONG SectorCount, 
+                     OUT PINT FsType)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+VOID
+ArmDiskGetBootDevice(OUT PULONG BootDevice)
+{
+    while (TRUE);
+}
+
+BOOLEAN
+ArmDiskBootingFromFloppy(VOID)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+BOOLEAN
+ArmDiskGetSystemVolume(IN PCHAR SystemPath,
+                       OUT PCHAR RemainingPath,
+                       OUT PULONG Device,
+                       OUT PULONG DriveNumber,
+                       OUT PULONGLONG StartSector,
+                       OUT PULONGLONG SectorCount,
+                       OUT PINT FsType)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+BOOLEAN
+ArmDiskGetBootPath(IN PCHAR BootPath,
+                   IN unsigned Size)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+BOOLEAN
+ArmDiskNormalizeSystemPath(IN PCHAR SystemPath,
+                           IN unsigned Size)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+BOOLEAN
+ArmDiskGetDriveGeometry(IN ULONG DriveNumber,
+                        OUT PGEOMETRY Geometry)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+BOOLEAN
+ArmDiskGetPartitionEntry(IN ULONG DriveNumber,
+                         IN ULONG PartitionNumber,
+                         OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+BOOLEAN
+ArmDiskReadLogicalSectors(IN ULONG DriveNumber,
+                          IN ULONGLONG SectorNumber,
+                          IN ULONG SectorCount,
+                          IN PVOID Buffer)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+ULONG
+ArmDiskGetCacheableBlockCount(IN ULONG DriveNumber)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+VOID
+ArmPrepareForReactOS(IN BOOLEAN Setup)
+{
+    while (TRUE);
+}
+
+PCONFIGURATION_COMPONENT_DATA
+ArmHwDetect(VOID)
+{
+    while (TRUE);
+    return NULL;
+}
+
+ULONG
+ArmMemGetMemoryMap(OUT PBIOS_MEMORY_MAP BiosMemoryMap,
+                   IN ULONG MaxMemoryMapSize)
+{
+    while (TRUE);
+    return FALSE;
+}
+
+VOID
+MachInit(IN PCCH CommandLine)
+{
+    //
+    // Setup ARM routines
+    //
+    MachVtbl.ConsPutChar = ArmConsPutChar;
+    MachVtbl.ConsKbHit = ArmConsKbHit;
+    MachVtbl.ConsGetCh = ArmConsGetCh;
+    MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
+    MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
+    MachVtbl.DiskGetBootVolume = ArmDiskGetBootVolume;
+    MachVtbl.DiskGetSystemVolume = ArmDiskGetSystemVolume;
+    MachVtbl.DiskGetBootPath = ArmDiskGetBootPath;
+    MachVtbl.DiskGetBootDevice = ArmDiskGetBootDevice;
+    MachVtbl.DiskBootingFromFloppy = ArmDiskBootingFromFloppy;
+    MachVtbl.DiskNormalizeSystemPath = ArmDiskNormalizeSystemPath;
+    MachVtbl.DiskReadLogicalSectors = ArmDiskReadLogicalSectors;
+    MachVtbl.DiskGetPartitionEntry = ArmDiskGetPartitionEntry;
+    MachVtbl.DiskGetDriveGeometry = ArmDiskGetDriveGeometry;
+    MachVtbl.DiskGetCacheableBlockCount = ArmDiskGetCacheableBlockCount;
+    MachVtbl.HwDetect = ArmHwDetect;
+}

Modified: trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c?rev=32148&r1=32147&r2=32148&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c Wed Feb  6 07:48:22 2008
@@ -168,9 +168,13 @@
 NTAPI
 RamDiskInit(IN PCHAR CmdLine)
 {
+    PCHAR Setting;
+
     //
     // Get RAM disk parameters
     //
-    gRamDiskBase = (PVOID)atoi(strstr(CmdLine, "rdbase="));
-    gRamDiskSize = atoi(strstr(CmdLine, "rdsize="));
+    Setting = strstr(CmdLine, "rdbase=");
+    if (Setting) gRamDiskBase = (PVOID)atoi(Setting);
+    Setting = strstr(CmdLine, "rdsize=");
+    if (Setting) gRamDiskSize = atoi(Setting);
 }




More information about the Ros-diffs mailing list