/*
* PROJECT: ReactOS Boot Loader
- * LICENSE: GPL - See COPYING in the top level directory
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
* FILE: boot/freeldr/arch/arm/marcharm.c
- * PURPOSE: Implements ARM-specific machine initialization
- * PROGRAMMERS: alex@winsiderss.com
+ * PURPOSE: Provides abstraction between the ARM Boot Loader and FreeLDR
+ * PROGRAMMERS: ReactOS Portable Systems Group
*/
/* INCLUDES *******************************************************************/
/* 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;
+UCHAR BootStack[0x4000];
+PUCHAR BootStackEnd = &BootStack[0x3FFF];
+PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
+ULONG BootDrive, BootPartition;
+VOID ArmPrepareForReactOS(IN BOOLEAN Setup);
+ADDRESS_RANGE ArmBoardMemoryMap[16];
+ULONG ArmBoardMemoryMapRangeCount;
/* FUNCTIONS ******************************************************************/
-PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
-
VOID
ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
{
+ ULONG i;
+
//
// Remember the pointer
//
//
// 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) ||
+ (ArmBoardBlock->BoardType == MACH_TYPE_OMAP3_BEAGLE));
+
+ //
+ // Save data required for memory initialization
+ //
+ ArmBoardMemoryMapRangeCount = ArmBoardBlock->MemoryMapEntryCount;
+ ASSERT(ArmBoardMemoryMapRangeCount != 0);
+ ASSERT(ArmBoardMemoryMapRangeCount < 16);
+ for (i = 0; i < ArmBoardMemoryMapRangeCount; i++)
+ {
+ //
+ // Copy each entry
+ //
+ RtlCopyMemory(&ArmBoardMemoryMap[i],
+ &ArmBoardBlock->MemoryMap[i],
+ sizeof(ADDRESS_RANGE));
+ }
//
// Call FreeLDR's portable entrypoint with our command-line
BootMain(ArmBoardBlock->CommandLine);
}
+BOOLEAN
+ArmDiskGetDriveGeometry(IN ULONG DriveNumber,
+ OUT PGEOMETRY Geometry)
+{
+ return FALSE;
+}
+
+BOOLEAN
+ArmDiskReadLogicalSectors(IN ULONG DriveNumber,
+ IN ULONGLONG SectorNumber,
+ IN ULONG SectorCount,
+ IN PVOID Buffer)
+{
+ return FALSE;
+}
+
+ULONG
+ArmDiskGetCacheableBlockCount(IN ULONG DriveNumber)
+{
+ return 0;
+}
+
+PCONFIGURATION_COMPONENT_DATA
+ArmHwDetect(VOID)
+{
+ PCONFIGURATION_COMPONENT_DATA RootNode;
+
+ //
+ // Create the root node
+ //
+ 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.
+ //
+
+ //
+ // Return the root node
+ //
+ return RootNode;
+}
+
+ULONG
+ArmMemGetMemoryMap(OUT PBIOS_MEMORY_MAP BiosMemoryMap,
+ IN ULONG MaxMemoryMapSize)
+{
+ //
+ // Return whatever the board returned to us (CS0 Base + Size and FLASH0)
+ //
+ RtlCopyMemory(BiosMemoryMap,
+ ArmBoardBlock->MemoryMap,
+ ArmBoardBlock->MemoryMapEntryCount * sizeof(BIOS_MEMORY_MAP));
+ return ArmBoardBlock->MemoryMapEntryCount;
+}
+
+VOID
+MachInit(IN PCCH CommandLine)
+{
+ //
+ // Setup board-specific ARM routines
+ //
+ switch (ArmBoardBlock->BoardType)
+ {
+ //
+ // Check for Feroceon-base boards
+ //
+ case MACH_TYPE_FEROCEON:
+
+ //
+ // These boards use a UART16550. Set us up for 115200 bps
+ //
+ ArmFeroSerialInit(115200);
+ 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;
+
+ //
+ // Check for TI OMAP3 boards
+ // For now that means only Beagle, but ZOOM and others should be ok too
+ //
+ case MACH_TYPE_OMAP3_BEAGLE:
+
+ //
+ // These boards use a UART16550
+ //
+ ArmOmap3SerialInit(115200);
+ MachVtbl.ConsPutChar = ArmOmap3PutChar;
+ MachVtbl.ConsKbHit = ArmOmap3KbHit;
+ MachVtbl.ConsGetCh = ArmOmap3GetCh;
+ break;
+
+ default:
+ ASSERT(FALSE);
+ }
+
+ //
+ // Setup generic ARM routines for all boards
+ //
+ MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
+ MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
+ MachVtbl.HwDetect = ArmHwDetect;
+
+ //
+ // Setup disk I/O routines
+ //
+ MachVtbl.DiskReadLogicalSectors = ArmDiskReadLogicalSectors;
+ MachVtbl.DiskGetDriveGeometry = ArmDiskGetDriveGeometry;
+ MachVtbl.DiskGetCacheableBlockCount = ArmDiskGetCacheableBlockCount;
+
+ //
+ // Now set default disk handling routines -- we don't need to override
+ //
+ MachVtbl.DiskGetBootPath = DiskGetBootPath;
+ MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
+
+ //
+ // We can now print to the console
+ //
+ TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
+ TuiPrintf("Bootargs: %s\n", CommandLine);
+}