2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/freeldr/freeldr/arch/arm/macharm.c
5 * PURPOSE: Provides abstraction between the ARM Boot Loader and FreeLDR
6 * PROGRAMMERS: ReactOS Portable Systems Group
9 /* INCLUDES *******************************************************************/
12 #include <internal/arm/intrin_i.h>
14 /* GLOBALS ********************************************************************/
16 PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock
;
17 ULONG gDiskReadBuffer
, gFileSysBuffer
;
18 BOOLEAN ArmHwDetectRan
;
19 PCONFIGURATION_COMPONENT_DATA RootNode
;
21 BOOLEAN AcpiPresent
= FALSE
;
23 ULONG FirstLevelDcacheSize
;
24 ULONG FirstLevelDcacheFillSize
;
25 ULONG FirstLevelIcacheSize
;
26 ULONG FirstLevelIcacheFillSize
;
27 ULONG SecondLevelDcacheSize
;
28 ULONG SecondLevelDcacheFillSize
;
29 ULONG SecondLevelIcacheSize
;
30 ULONG SecondLevelIcacheFillSize
;
32 extern ULONG reactos_disk_count
;
50 4 // 4-way associative
57 8 // 8 words per line (32 bytes)
60 /* FUNCTIONS ******************************************************************/
62 VOID
DiskStopFloppyMotor(VOID
)
67 FrLdrCheckCpuCompatibility(VOID
)
73 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext
)
75 /* Remember the pointer */
76 ArmBoardBlock
= BootContext
;
78 /* Let's make sure we understand the LLB */
79 ASSERT(ArmBoardBlock
->MajorVersion
== ARM_BOARD_CONFIGURATION_MAJOR_VERSION
);
80 ASSERT(ArmBoardBlock
->MinorVersion
== ARM_BOARD_CONFIGURATION_MINOR_VERSION
);
82 /* This should probably go away once we support more boards */
83 ASSERT((ArmBoardBlock
->BoardType
== MACH_TYPE_FEROCEON
) ||
84 (ArmBoardBlock
->BoardType
== MACH_TYPE_VERSATILE_PB
) ||
85 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP3_BEAGLE
) ||
86 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP_ZOOM2
));
88 /* Call FreeLDR's portable entrypoint with our command-line */
89 BootMain(ArmBoardBlock
->CommandLine
);
93 ArmPrepareForReactOS(IN BOOLEAN Setup
)
99 ArmDiskGetBootPath(OUT PCHAR BootPath
, IN ULONG Size
)
101 PCCH Path
= "ramdisk(0)";
103 /* Make sure enough space exists */
104 if (Size
< sizeof(Path
)) return FALSE
;
106 /* On ARM platforms, the loader is always in RAM */
107 strcpy(BootPath
, Path
);
111 PCONFIGURATION_COMPONENT_DATA
114 ARM_CACHE_REGISTER CacheReg
;
116 /* Create the root node */
117 if (ArmHwDetectRan
++) return RootNode
;
118 FldrCreateSystemKey(&RootNode
);
122 * There's no such thing as "PnP" on embedded hardware.
123 * The boot loader will send us a device tree, similar to ACPI
124 * or OpenFirmware device trees, and we will convert it to ARC.
127 /* Get cache information */
128 CacheReg
= KeArmCacheRegisterGet();
129 FirstLevelDcacheSize
= SizeBits
[CacheReg
.DSize
];
130 FirstLevelDcacheFillSize
= LenBits
[CacheReg
.DLength
];
131 FirstLevelDcacheFillSize
<<= 2;
132 FirstLevelIcacheSize
= SizeBits
[CacheReg
.ISize
];
133 FirstLevelIcacheFillSize
= LenBits
[CacheReg
.ILength
];
134 FirstLevelIcacheFillSize
<<= 2;
135 SecondLevelDcacheSize
=
136 SecondLevelDcacheFillSize
=
137 SecondLevelIcacheSize
=
138 SecondLevelIcacheFillSize
= 0;
140 /* Register RAMDISK Device */
143 /* Fill out the ARC disk block */
144 AddReactOSArcDiskInfo("ramdisk(0)", 0xBADAB00F, 0xDEADBABE, TRUE
);
145 ASSERT(reactos_disk_count
== 1);
147 /* Return the root node */
152 ArmInitializeBootDevices(VOID
)
154 /* Emulate old behavior */
155 return (ArmHwDetect() != NULL
);
158 FREELDR_MEMORY_DESCRIPTOR ArmMemoryMap
[32];
160 PFREELDR_MEMORY_DESCRIPTOR
161 ArmMemGetMemoryMap(OUT ULONG
*MemoryMapSize
)
164 ASSERT(ArmBoardBlock
->MemoryMapEntryCount
<= 32);
166 /* Return whatever the board returned to us (CS0 Base + Size and FLASH0) */
167 for (i
= 0; i
< ArmBoardBlock
->MemoryMapEntryCount
; i
++)
169 ArmMemoryMap
[i
].BasePage
= ArmBoardBlock
->MemoryMap
[i
].BaseAddress
/ PAGE_SIZE
;
170 ArmMemoryMap
[i
].PageCount
= ArmBoardBlock
->MemoryMap
[i
].Length
/ PAGE_SIZE
;
171 if (ArmBoardBlock
->MemoryMap
[i
].Type
== BiosMemoryUsable
)
172 ArmMemoryMap
[i
].MemoryType
= MemoryFree
;
174 ArmMemoryMap
[i
].MemoryType
= MemoryFirmwarePermanent
;
177 *MemoryMapSize
= ArmBoardBlock
->MemoryMapEntryCount
;
190 MachInit(IN PCCH CommandLine
)
192 /* Copy Machine Routines from Firmware Table */
193 MachVtbl
.ConsPutChar
= ArmBoardBlock
->ConsPutChar
;
194 MachVtbl
.ConsKbHit
= ArmBoardBlock
->ConsKbHit
;
195 MachVtbl
.ConsGetCh
= ArmBoardBlock
->ConsGetCh
;
196 MachVtbl
.VideoClearScreen
= ArmBoardBlock
->VideoClearScreen
;
197 MachVtbl
.VideoSetDisplayMode
= ArmBoardBlock
->VideoSetDisplayMode
;
198 MachVtbl
.VideoGetDisplaySize
= ArmBoardBlock
->VideoGetDisplaySize
;
199 MachVtbl
.VideoPutChar
= ArmBoardBlock
->VideoPutChar
;
200 MachVtbl
.GetTime
= ArmBoardBlock
->GetTime
;
202 /* Setup board-specific ARM routines */
203 switch (ArmBoardBlock
->BoardType
)
205 /* Check for Feroceon-base boards */
206 case MACH_TYPE_FEROCEON
:
207 TuiPrintf("Not implemented\n");
211 /* Check for TI OMAP3 ZOOM-II MDK */
212 case MACH_TYPE_OMAP_ZOOM2
:
214 /* Setup the disk and file system buffers */
215 gDiskReadBuffer
= 0x81094000;
216 gFileSysBuffer
= 0x81094000;
219 /* Check for ARM Versatile PB boards */
220 case MACH_TYPE_VERSATILE_PB
:
222 /* Setup the disk and file system buffers */
223 gDiskReadBuffer
= 0x00090000;
224 gFileSysBuffer
= 0x00090000;
227 /* Check for TI OMAP3 Beagleboard */
228 case MACH_TYPE_OMAP3_BEAGLE
:
229 TuiPrintf("Not implemented\n");
237 /* Setup generic ARM routines for all boards */
238 MachVtbl
.PrepareForReactOS
= ArmPrepareForReactOS
;
239 MachVtbl
.GetMemoryMap
= ArmMemGetMemoryMap
;
240 MachVtbl
.InitializeBootDevices
= ArmInitializeBootDevices
;
241 MachVtbl
.HwDetect
= ArmHwDetect
;
242 MachVtbl
.DiskGetBootPath
= ArmDiskGetBootPath
;
243 MachVtbl
.HwIdle
= ArmHwIdle
;