2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/freeldr/arch/arm/marcharm.c
5 * PURPOSE: Provides abstraction between the ARM Boot Loader and FreeLDR
6 * PROGRAMMERS: ReactOS Portable Systems Group
9 /* INCLUDES *******************************************************************/
13 /* GLOBALS ********************************************************************/
15 UCHAR BootStack
[0x4000];
16 PUCHAR BootStackEnd
= &BootStack
[0x3FFF];
17 PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock
;
18 ULONG BootDrive
, BootPartition
;
19 VOID
ArmPrepareForReactOS(IN BOOLEAN Setup
);
20 ADDRESS_RANGE ArmBoardMemoryMap
[16];
21 ULONG ArmBoardMemoryMapRangeCount
;
23 /* FUNCTIONS ******************************************************************/
26 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext
)
31 // Remember the pointer
33 ArmBoardBlock
= BootContext
;
36 // Let's make sure we understand the boot-loader
38 ASSERT(ArmBoardBlock
->MajorVersion
== ARM_BOARD_CONFIGURATION_MAJOR_VERSION
);
39 ASSERT(ArmBoardBlock
->MinorVersion
== ARM_BOARD_CONFIGURATION_MINOR_VERSION
);
42 // This should probably go away once we support more boards
44 ASSERT((ArmBoardBlock
->BoardType
== MACH_TYPE_FEROCEON
) ||
45 (ArmBoardBlock
->BoardType
== MACH_TYPE_VERSATILE_PB
) ||
46 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP3_BEAGLE
));
49 // Save data required for memory initialization
51 ArmBoardMemoryMapRangeCount
= ArmBoardBlock
->MemoryMapEntryCount
;
52 ASSERT(ArmBoardMemoryMapRangeCount
!= 0);
53 ASSERT(ArmBoardMemoryMapRangeCount
< 16);
54 for (i
= 0; i
< ArmBoardMemoryMapRangeCount
; i
++)
59 RtlCopyMemory(&ArmBoardMemoryMap
[i
],
60 &ArmBoardBlock
->MemoryMap
[i
],
61 sizeof(ADDRESS_RANGE
));
65 // Call FreeLDR's portable entrypoint with our command-line
67 BootMain(ArmBoardBlock
->CommandLine
);
71 ArmDiskGetDriveGeometry(IN ULONG DriveNumber
,
72 OUT PGEOMETRY Geometry
)
78 ArmDiskReadLogicalSectors(IN ULONG DriveNumber
,
79 IN ULONGLONG SectorNumber
,
87 ArmDiskGetCacheableBlockCount(IN ULONG DriveNumber
)
92 PCONFIGURATION_COMPONENT_DATA
95 PCONFIGURATION_COMPONENT_DATA RootNode
;
98 // Create the root node
100 FldrCreateSystemKey(&RootNode
);
104 // There's no such thing as "PnP" on embedded hardware.
105 // The boot loader will send us a device tree, similar to ACPI
106 // or OpenFirmware device trees, and we will convert it to ARC.
110 // Return the root node
116 ArmMemGetMemoryMap(OUT PBIOS_MEMORY_MAP BiosMemoryMap
,
117 IN ULONG MaxMemoryMapSize
)
120 // Return whatever the board returned to us (CS0 Base + Size and FLASH0)
122 RtlCopyMemory(BiosMemoryMap
,
123 ArmBoardBlock
->MemoryMap
,
124 ArmBoardBlock
->MemoryMapEntryCount
* sizeof(BIOS_MEMORY_MAP
));
125 return ArmBoardBlock
->MemoryMapEntryCount
;
129 MachInit(IN PCCH CommandLine
)
132 // Setup board-specific ARM routines
134 switch (ArmBoardBlock
->BoardType
)
137 // Check for Feroceon-base boards
139 case MACH_TYPE_FEROCEON
:
142 // These boards use a UART16550. Set us up for 115200 bps
144 ArmFeroSerialInit(115200);
145 MachVtbl
.ConsPutChar
= ArmFeroPutChar
;
146 MachVtbl
.ConsKbHit
= ArmFeroKbHit
;
147 MachVtbl
.ConsGetCh
= ArmFeroGetCh
;
151 // Check for ARM Versatile PB boards
153 case MACH_TYPE_VERSATILE_PB
:
156 // These boards use a PrimeCell UART (PL011)
158 ArmVersaSerialInit(115200);
159 MachVtbl
.ConsPutChar
= ArmVersaPutChar
;
160 MachVtbl
.ConsKbHit
= ArmVersaKbHit
;
161 MachVtbl
.ConsGetCh
= ArmVersaGetCh
;
165 // Check for TI OMAP3 boards
166 // For now that means only Beagle, but ZOOM and others should be ok too
168 case MACH_TYPE_OMAP3_BEAGLE
:
171 // These boards use a UART16550
173 ArmOmap3SerialInit(115200);
174 MachVtbl
.ConsPutChar
= ArmOmap3PutChar
;
175 MachVtbl
.ConsKbHit
= ArmOmap3KbHit
;
176 MachVtbl
.ConsGetCh
= ArmOmap3GetCh
;
184 // Setup generic ARM routines for all boards
186 MachVtbl
.PrepareForReactOS
= ArmPrepareForReactOS
;
187 MachVtbl
.GetMemoryMap
= ArmMemGetMemoryMap
;
188 MachVtbl
.HwDetect
= ArmHwDetect
;
191 // Setup disk I/O routines
193 MachVtbl
.DiskReadLogicalSectors
= ArmDiskReadLogicalSectors
;
194 MachVtbl
.DiskGetDriveGeometry
= ArmDiskGetDriveGeometry
;
195 MachVtbl
.DiskGetCacheableBlockCount
= ArmDiskGetCacheableBlockCount
;
198 // Now set default disk handling routines -- we don't need to override
200 MachVtbl
.DiskGetBootPath
= DiskGetBootPath
;
201 MachVtbl
.DiskNormalizeSystemPath
= DiskNormalizeSystemPath
;
204 // We can now print to the console
206 TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
207 TuiPrintf("Bootargs: %s\n", CommandLine
);