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 *******************************************************************/
12 #define RGB565(r, g, b) (((r >> 3) << 11)| ((g >> 2) << 5)| ((b >> 3) << 0))
14 /* GLOBALS ********************************************************************/
16 UCHAR BootStack
[0x4000];
17 PUCHAR BootStackEnd
= &BootStack
[0x3FFF];
18 PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock
;
19 ULONG BootDrive
, BootPartition
;
20 VOID
ArmPrepareForReactOS(IN BOOLEAN Setup
);
21 ADDRESS_RANGE ArmBoardMemoryMap
[16];
22 ULONG ArmBoardMemoryMapRangeCount
;
23 ULONG gDiskReadBuffer
, gFileSysBuffer
;
25 /* FUNCTIONS ******************************************************************/
28 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext
)
33 // Remember the pointer
35 ArmBoardBlock
= BootContext
;
38 // Let's make sure we understand the LLB
40 ASSERT(ArmBoardBlock
->MajorVersion
== ARM_BOARD_CONFIGURATION_MAJOR_VERSION
);
41 ASSERT(ArmBoardBlock
->MinorVersion
== ARM_BOARD_CONFIGURATION_MINOR_VERSION
);
44 // This should probably go away once we support more boards
46 ASSERT((ArmBoardBlock
->BoardType
== MACH_TYPE_FEROCEON
) ||
47 (ArmBoardBlock
->BoardType
== MACH_TYPE_VERSATILE_PB
) ||
48 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP3_BEAGLE
));
51 // Save data required for memory initialization
53 ArmBoardMemoryMapRangeCount
= ArmBoardBlock
->MemoryMapEntryCount
;
54 ASSERT(ArmBoardMemoryMapRangeCount
!= 0);
55 ASSERT(ArmBoardMemoryMapRangeCount
< 16);
56 for (i
= 0; i
< ArmBoardMemoryMapRangeCount
; i
++)
61 RtlCopyMemory(&ArmBoardMemoryMap
[i
],
62 &ArmBoardBlock
->MemoryMap
[i
],
63 sizeof(ADDRESS_RANGE
));
67 // Call FreeLDR's portable entrypoint with our command-line
69 BootMain(ArmBoardBlock
->CommandLine
);
73 ArmDiskNormalizeSystemPath(IN OUT PCHAR SystemPath
,
76 TuiPrintf("Called: %s\n", SystemPath
);
82 ArmDiskGetBootPath(OUT PCHAR BootPath
,
85 PCCH Path
= "ramdisk(0)";
87 /* Make sure enough space exists */
88 if (Size
< sizeof(Path
)) return FALSE
;
90 /* On ARM platforms, the loader is always in RAM */
91 strcpy(BootPath
, Path
);
95 PCONFIGURATION_COMPONENT_DATA
98 PCONFIGURATION_COMPONENT_DATA RootNode
;
101 // Create the root node
103 FldrCreateSystemKey(&RootNode
);
107 // There's no such thing as "PnP" on embedded hardware.
108 // The boot loader will send us a device tree, similar to ACPI
109 // or OpenFirmware device trees, and we will convert it to ARC.
113 // Register RAMDISK Device
118 // Return the root node
124 ArmMemGetMemoryMap(OUT PBIOS_MEMORY_MAP BiosMemoryMap
,
125 IN ULONG MaxMemoryMapSize
)
128 // Return whatever the board returned to us (CS0 Base + Size and FLASH0)
130 RtlCopyMemory(BiosMemoryMap
,
131 ArmBoardBlock
->MemoryMap
,
132 ArmBoardBlock
->MemoryMapEntryCount
* sizeof(BIOS_MEMORY_MAP
));
133 return ArmBoardBlock
->MemoryMapEntryCount
;
137 MachInit(IN PCCH CommandLine
)
140 // Setup board-specific ARM routines
142 switch (ArmBoardBlock
->BoardType
)
145 // Check for Feroceon-base boards
147 case MACH_TYPE_FEROCEON
:
148 TuiPrintf("Not implemented\n");
153 // Check for ARM Versatile PB boards
155 case MACH_TYPE_VERSATILE_PB
:
157 /* Copy Machine Routines from Firmware Table */
158 MachVtbl
.ConsPutChar
= ArmBoardBlock
->ConsPutChar
;
159 MachVtbl
.ConsKbHit
= ArmBoardBlock
->ConsKbHit
;
160 MachVtbl
.ConsGetCh
= ArmBoardBlock
->ConsGetCh
;
161 MachVtbl
.VideoClearScreen
= ArmBoardBlock
->VideoClearScreen
;
162 MachVtbl
.VideoSetDisplayMode
= ArmBoardBlock
->VideoSetDisplayMode
;
163 MachVtbl
.VideoGetDisplaySize
= ArmBoardBlock
->VideoGetDisplaySize
;
164 MachVtbl
.VideoGetBufferSize
= ArmBoardBlock
->VideoGetBufferSize
;
165 MachVtbl
.VideoSetTextCursorPosition
= ArmBoardBlock
->VideoSetTextCursorPosition
;
166 MachVtbl
.VideoSetTextCursorPosition
= ArmBoardBlock
->VideoSetTextCursorPosition
;
167 MachVtbl
.VideoHideShowTextCursor
= ArmBoardBlock
->VideoHideShowTextCursor
;
168 MachVtbl
.VideoPutChar
= ArmBoardBlock
->VideoPutChar
;
169 MachVtbl
.VideoCopyOffScreenBufferToVRAM
= ArmBoardBlock
->VideoCopyOffScreenBufferToVRAM
;
170 MachVtbl
.VideoIsPaletteFixed
= ArmBoardBlock
->VideoIsPaletteFixed
;
171 MachVtbl
.VideoSetPaletteColor
= ArmBoardBlock
->VideoSetPaletteColor
;
172 MachVtbl
.VideoGetPaletteColor
= ArmBoardBlock
->VideoGetPaletteColor
;
173 MachVtbl
.VideoSync
= ArmBoardBlock
->VideoSync
;
175 /* Setup the disk and file system buffers */
176 gDiskReadBuffer
= 0x00090000;
177 gFileSysBuffer
= 0x00090000;
181 // Check for TI OMAP3 boards
182 // For now that means only Beagle, but ZOOM and others should be ok too
184 case MACH_TYPE_OMAP3_BEAGLE
:
185 TuiPrintf("Not implemented\n");
194 // Setup generic ARM routines for all boards
196 MachVtbl
.PrepareForReactOS
= ArmPrepareForReactOS
;
197 MachVtbl
.GetMemoryMap
= ArmMemGetMemoryMap
;
198 MachVtbl
.HwDetect
= ArmHwDetect
;
201 // Setup disk I/O routines
203 MachVtbl
.DiskGetBootPath
= ArmDiskGetBootPath
;
204 MachVtbl
.DiskNormalizeSystemPath
= ArmDiskNormalizeSystemPath
;
207 // We can now print to the console
209 TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
210 TuiPrintf("Bootargs: %s\n\n", CommandLine
);