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 #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 ARC_DISK_SIGNATURE reactos_arc_disk_info
;
33 ULONG reactos_disk_count
;
51 4 // 4-way associative
58 8 // 8 words per line (32 bytes)
61 /* FUNCTIONS ******************************************************************/
64 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext
)
66 /* Remember the pointer */
67 ArmBoardBlock
= BootContext
;
69 /* Let's make sure we understand the LLB */
70 ASSERT(ArmBoardBlock
->MajorVersion
== ARM_BOARD_CONFIGURATION_MAJOR_VERSION
);
71 ASSERT(ArmBoardBlock
->MinorVersion
== ARM_BOARD_CONFIGURATION_MINOR_VERSION
);
73 /* This should probably go away once we support more boards */
74 ASSERT((ArmBoardBlock
->BoardType
== MACH_TYPE_FEROCEON
) ||
75 (ArmBoardBlock
->BoardType
== MACH_TYPE_VERSATILE_PB
) ||
76 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP3_BEAGLE
) ||
77 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP_ZOOM2
));
79 /* Call FreeLDR's portable entrypoint with our command-line */
80 BootMain(ArmBoardBlock
->CommandLine
);
84 ArmPrepareForReactOS(IN BOOLEAN Setup
)
90 ArmDiskGetBootPath(OUT PCHAR BootPath
,
93 PCCH Path
= "ramdisk(0)";
95 /* Make sure enough space exists */
96 if (Size
< sizeof(Path
)) return FALSE
;
98 /* On ARM platforms, the loader is always in RAM */
99 strcpy(BootPath
, Path
);
104 ArmInitializeBootDevices(VOID
)
106 /* Emulate old behavior */
107 return (ArmHwDetect() != NULL
);
110 PCONFIGURATION_COMPONENT_DATA
113 ARM_CACHE_REGISTER CacheReg
;
115 /* Create the root node */
116 if (ArmHwDetectRan
++) return RootNode
;
117 FldrCreateSystemKey(&RootNode
);
121 * There's no such thing as "PnP" on embedded hardware.
122 * The boot loader will send us a device tree, similar to ACPI
123 * or OpenFirmware device trees, and we will convert it to ARC.
126 /* Get cache information */
127 CacheReg
= KeArmCacheRegisterGet();
128 FirstLevelDcacheSize
= SizeBits
[CacheReg
.DSize
];
129 FirstLevelDcacheFillSize
= LenBits
[CacheReg
.DLength
];
130 FirstLevelDcacheFillSize
<<= 2;
131 FirstLevelIcacheSize
= SizeBits
[CacheReg
.ISize
];
132 FirstLevelIcacheFillSize
= LenBits
[CacheReg
.ILength
];
133 FirstLevelIcacheFillSize
<<= 2;
134 SecondLevelDcacheSize
=
135 SecondLevelDcacheFillSize
=
136 SecondLevelIcacheSize
=
137 SecondLevelIcacheFillSize
= 0;
139 /* Register RAMDISK Device */
142 /* Fill out the ARC disk block */
143 reactos_arc_disk_info
.Signature
= 0xBADAB00F;
144 reactos_arc_disk_info
.CheckSum
= 0xDEADBABE;
145 reactos_arc_disk_info
.ArcName
= "ramdisk(0)";
146 reactos_disk_count
= 1;
148 /* Return the root node */
152 FREELDR_MEMORY_DESCRIPTOR ArmMemoryMap
[32];
154 PFREELDR_MEMORY_DESCRIPTOR
155 ArmMemGetMemoryMap(OUT ULONG
*MemoryMapSize
)
157 ASSERT(ArmBoardBlock
->MemoryMapEntryCount
<= 32);
159 /* Return whatever the board returned to us (CS0 Base + Size and FLASH0) */
160 for (i
= 0; i
< ArmBoardBlock
->MemoryMapEntryCount
; i
++)
162 ArmMemoryMap
[i
].BasePage
= ArmBoardBlock
->MemoryMap
[i
].BaseAddress
/ PAGE_SIZE
;
163 ArmMemoryMap
[i
].PageCount
= ArmBoardBlock
->MemoryMap
[i
].Length
/ PAGE_SIZE
;
164 if (ArmBoardBlock
->MemoryMap
[i
].Type
== BiosMemoryUsable
)
165 ArmMemoryMap
[i
].MemoryType
= MemoryFree
;
167 ArmMemoryMap
[i
].MemoryType
= MemoryFirmwarePermanent
;
170 return ArmBoardBlock
->MemoryMapEntryCount
;
180 MachInit(IN PCCH CommandLine
)
182 /* Copy Machine Routines from Firmware Table */
183 MachVtbl
.ConsPutChar
= ArmBoardBlock
->ConsPutChar
;
184 MachVtbl
.ConsKbHit
= ArmBoardBlock
->ConsKbHit
;
185 MachVtbl
.ConsGetCh
= ArmBoardBlock
->ConsGetCh
;
186 MachVtbl
.VideoClearScreen
= ArmBoardBlock
->VideoClearScreen
;
187 MachVtbl
.VideoSetDisplayMode
= ArmBoardBlock
->VideoSetDisplayMode
;
188 MachVtbl
.VideoGetDisplaySize
= ArmBoardBlock
->VideoGetDisplaySize
;
189 MachVtbl
.VideoPutChar
= ArmBoardBlock
->VideoPutChar
;
190 MachVtbl
.GetTime
= ArmBoardBlock
->GetTime
;
192 /* Setup board-specific ARM routines */
193 switch (ArmBoardBlock
->BoardType
)
195 /* Check for Feroceon-base boards */
196 case MACH_TYPE_FEROCEON
:
197 TuiPrintf("Not implemented\n");
201 /* Check for TI OMAP3 ZOOM-II MDK */
202 case MACH_TYPE_OMAP_ZOOM2
:
204 /* Setup the disk and file system buffers */
205 gDiskReadBuffer
= 0x81094000;
206 gFileSysBuffer
= 0x81094000;
209 /* Check for ARM Versatile PB boards */
210 case MACH_TYPE_VERSATILE_PB
:
212 /* Setup the disk and file system buffers */
213 gDiskReadBuffer
= 0x00090000;
214 gFileSysBuffer
= 0x00090000;
217 /* Check for TI OMAP3 Beagleboard */
218 case MACH_TYPE_OMAP3_BEAGLE
:
219 TuiPrintf("Not implemented\n");
227 /* Setup generic ARM routines for all boards */
228 MachVtbl
.PrepareForReactOS
= ArmPrepareForReactOS
;
229 MachVtbl
.GetMemoryMap
= ArmMemGetMemoryMap
;
230 MachVtbl
.InitializeBootDevices
= ArmInitializeBootDevices
;
231 MachVtbl
.HwDetect
= ArmHwDetect
;
232 MachVtbl
.DiskGetBootPath
= ArmDiskGetBootPath
;
233 MachVtbl
.HwIdle
= ArmHwIdle
;