[FREELDR] Simplify code by using a AddReactOSArcDiskInfo() helper, and few extra...
[reactos.git] / boot / freeldr / freeldr / arch / arm / macharm.c
index 6df6dbd..8d4465f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PROJECT:         ReactOS Boot Loader
  * LICENSE:         BSD - See COPYING.ARM in the top level directory
- * FILE:            boot/freeldr/arch/arm/marcharm.c
+ * FILE:            boot/freeldr/freeldr/arch/arm/macharm.c
  * PURPOSE:         Provides abstraction between the ARM Boot Loader and FreeLDR
  * PROGRAMMERS:     ReactOS Portable Systems Group
  */
@@ -28,10 +28,8 @@ ULONG SecondLevelDcacheSize;
 ULONG SecondLevelDcacheFillSize;
 ULONG SecondLevelIcacheSize;
 ULONG SecondLevelIcacheFillSize;
-  
-ARC_DISK_SIGNATURE reactos_arc_disk_info;
-ULONG reactos_disk_count;
-CHAR reactos_arc_hardware_data[256];
+
+extern ULONG reactos_disk_count;
 
 ULONG SizeBits[] =
 {
@@ -61,16 +59,26 @@ ULONG LenBits[] =
 
 /* FUNCTIONS ******************************************************************/
 
+VOID DiskStopFloppyMotor(VOID)
+{
+}
+
+VOID
+FrLdrCheckCpuCompatibility(VOID)
+{
+    /* Nothing for now */
+}
+
 VOID
 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
 {
     /* Remember the pointer */
     ArmBoardBlock = BootContext;
-    
+
     /* Let's make sure we understand the LLB */
     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 == MACH_TYPE_FEROCEON) ||
            (ArmBoardBlock->BoardType == MACH_TYPE_VERSATILE_PB) ||
@@ -88,14 +96,13 @@ ArmPrepareForReactOS(IN BOOLEAN Setup)
 }
 
 BOOLEAN
-ArmDiskGetBootPath(OUT PCHAR BootPath,
-                   IN unsigned Size)
+ArmDiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size)
 {
     PCCH Path = "ramdisk(0)";
-    
+
     /* Make sure enough space exists */
     if (Size < sizeof(Path)) return FALSE;
-    
+
     /* On ARM platforms, the loader is always in RAM */
     strcpy(BootPath, Path);
     return TRUE;
@@ -105,20 +112,20 @@ PCONFIGURATION_COMPONENT_DATA
 ArmHwDetect(VOID)
 {
     ARM_CACHE_REGISTER CacheReg;
-    
+
     /* Create the root node */
     if (ArmHwDetectRan++) return RootNode;
     FldrCreateSystemKey(&RootNode);
-    
+
     /*
      * TODO:
      * There's no such thing as "PnP" on embedded hardware.
      * The boot loader will send us a device tree, similar to ACPI
      * or OpenFirmware device trees, and we will convert it to ARC.
      */
-    
+
     /* Get cache information */
-    CacheReg = KeArmCacheRegisterGet();   
+    CacheReg = KeArmCacheRegisterGet();
     FirstLevelDcacheSize = SizeBits[CacheReg.DSize];
     FirstLevelDcacheFillSize = LenBits[CacheReg.DLength];
     FirstLevelDcacheFillSize <<= 2;
@@ -129,25 +136,31 @@ ArmHwDetect(VOID)
     SecondLevelDcacheFillSize =
     SecondLevelIcacheSize =
     SecondLevelIcacheFillSize = 0;
-    
+
     /* Register RAMDISK Device */
     RamDiskInitialize();
-    
+
     /* Fill out the ARC disk block */
-    reactos_arc_disk_info.Signature = 0xBADAB00F;
-    reactos_arc_disk_info.CheckSum = 0xDEADBABE;
-    reactos_arc_disk_info.ArcName = "ramdisk(0)";
-    reactos_disk_count = 1;
-    
+    AddReactOSArcDiskInfo("ramdisk(0)", 0xBADAB00F, 0xDEADBABE, TRUE);
+    ASSERT(reactos_disk_count == 1);
+
     /* Return the root node */
     return RootNode;
 }
 
+BOOLEAN
+ArmInitializeBootDevices(VOID)
+{
+    /* Emulate old behavior */
+    return (ArmHwDetect() != NULL);
+}
+
 FREELDR_MEMORY_DESCRIPTOR ArmMemoryMap[32];
 
 PFREELDR_MEMORY_DESCRIPTOR
 ArmMemGetMemoryMap(OUT ULONG *MemoryMapSize)
 {
+    ULONG i;
     ASSERT(ArmBoardBlock->MemoryMapEntryCount <= 32);
 
     /* Return whatever the board returned to us (CS0 Base + Size and FLASH0) */
@@ -161,7 +174,16 @@ ArmMemGetMemoryMap(OUT ULONG *MemoryMapSize)
             ArmMemoryMap[i].MemoryType = MemoryFirmwarePermanent;
     }
 
-    return ArmBoardBlock->MemoryMapEntryCount;
+    *MemoryMapSize = ArmBoardBlock->MemoryMapEntryCount;
+
+    // FIXME
+    return NULL;
+}
+
+VOID
+ArmHwIdle(VOID)
+{
+    /* UNIMPLEMENTED */
 }
 
 VOID
@@ -176,7 +198,7 @@ MachInit(IN PCCH CommandLine)
     MachVtbl.VideoGetDisplaySize = ArmBoardBlock->VideoGetDisplaySize;
     MachVtbl.VideoPutChar = ArmBoardBlock->VideoPutChar;
     MachVtbl.GetTime = ArmBoardBlock->GetTime;
-    
+
     /* Setup board-specific ARM routines */
     switch (ArmBoardBlock->BoardType)
     {
@@ -188,33 +210,35 @@ MachInit(IN PCCH CommandLine)
 
         /* Check for TI OMAP3 ZOOM-II MDK */
         case MACH_TYPE_OMAP_ZOOM2:
-            
+
             /* Setup the disk and file system buffers */
             gDiskReadBuffer = 0x81094000;
             gFileSysBuffer = 0x81094000;
             break;
-            
+
         /* Check for ARM Versatile PB boards */
         case MACH_TYPE_VERSATILE_PB:
-            
+
             /* Setup the disk and file system buffers */
             gDiskReadBuffer = 0x00090000;
             gFileSysBuffer = 0x00090000;
             break;
-            
+
         /* Check for TI OMAP3 Beagleboard */
         case MACH_TYPE_OMAP3_BEAGLE:
             TuiPrintf("Not implemented\n");
             while (TRUE);
             break;
-            
+
         default:
             ASSERT(FALSE);
     }
-    
+
     /* Setup generic ARM routines for all boards */
     MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
     MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
+    MachVtbl.InitializeBootDevices = ArmInitializeBootDevices;
     MachVtbl.HwDetect = ArmHwDetect;
     MachVtbl.DiskGetBootPath = ArmDiskGetBootPath;
+    MachVtbl.HwIdle = ArmHwIdle;
 }