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 ******************************************************************/
63 FrLdrCheckCpuCompatibility(VOID
)
69 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext
)
71 /* Remember the pointer */
72 ArmBoardBlock
= BootContext
;
74 /* Let's make sure we understand the LLB */
75 ASSERT(ArmBoardBlock
->MajorVersion
== ARM_BOARD_CONFIGURATION_MAJOR_VERSION
);
76 ASSERT(ArmBoardBlock
->MinorVersion
== ARM_BOARD_CONFIGURATION_MINOR_VERSION
);
78 /* This should probably go away once we support more boards */
79 ASSERT((ArmBoardBlock
->BoardType
== MACH_TYPE_FEROCEON
) ||
80 (ArmBoardBlock
->BoardType
== MACH_TYPE_VERSATILE_PB
) ||
81 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP3_BEAGLE
) ||
82 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP_ZOOM2
));
84 /* Call FreeLDR's portable entrypoint with our command-line */
85 BootMain(ArmBoardBlock
->CommandLine
);
89 ArmPrepareForReactOS(VOID
)
94 PCONFIGURATION_COMPONENT_DATA
97 ARM_CACHE_REGISTER CacheReg
;
99 /* Create the root node */
100 if (ArmHwDetectRan
++) return RootNode
;
101 FldrCreateSystemKey(&RootNode
);
105 * There's no such thing as "PnP" on embedded hardware.
106 * The boot loader will send us a device tree, similar to ACPI
107 * or OpenFirmware device trees, and we will convert it to ARC.
110 /* Get cache information */
111 CacheReg
= KeArmCacheRegisterGet();
112 FirstLevelDcacheSize
= SizeBits
[CacheReg
.DSize
];
113 FirstLevelDcacheFillSize
= LenBits
[CacheReg
.DLength
];
114 FirstLevelDcacheFillSize
<<= 2;
115 FirstLevelIcacheSize
= SizeBits
[CacheReg
.ISize
];
116 FirstLevelIcacheFillSize
= LenBits
[CacheReg
.ILength
];
117 FirstLevelIcacheFillSize
<<= 2;
118 SecondLevelDcacheSize
=
119 SecondLevelDcacheFillSize
=
120 SecondLevelIcacheSize
=
121 SecondLevelIcacheFillSize
= 0;
123 /* Register RAMDISK Device */
126 /* Fill out the ARC disk block */
127 AddReactOSArcDiskInfo("ramdisk(0)", 0xBADAB00F, 0xDEADBABE, TRUE
);
128 ASSERT(reactos_disk_count
== 1);
130 /* Return the root node */
135 ArmInitializeBootDevices(VOID
)
137 /* Emulate old behavior */
138 if (ArmHwDetect() == NULL
)
141 /* On ARM platforms, the loader is always in RAM */
142 strcpy(FrldrBootPath
, "ramdisk(0)");
146 FREELDR_MEMORY_DESCRIPTOR ArmMemoryMap
[32];
148 PFREELDR_MEMORY_DESCRIPTOR
149 ArmMemGetMemoryMap(OUT ULONG
*MemoryMapSize
)
152 ASSERT(ArmBoardBlock
->MemoryMapEntryCount
<= 32);
154 /* Return whatever the board returned to us (CS0 Base + Size and FLASH0) */
155 for (i
= 0; i
< ArmBoardBlock
->MemoryMapEntryCount
; i
++)
157 ArmMemoryMap
[i
].BasePage
= ArmBoardBlock
->MemoryMap
[i
].BaseAddress
/ PAGE_SIZE
;
158 ArmMemoryMap
[i
].PageCount
= ArmBoardBlock
->MemoryMap
[i
].Length
/ PAGE_SIZE
;
159 if (ArmBoardBlock
->MemoryMap
[i
].Type
== BiosMemoryUsable
)
160 ArmMemoryMap
[i
].MemoryType
= MemoryFree
;
162 ArmMemoryMap
[i
].MemoryType
= MemoryFirmwarePermanent
;
165 *MemoryMapSize
= ArmBoardBlock
->MemoryMapEntryCount
;
178 MachInit(IN PCCH CommandLine
)
180 /* Copy Machine Routines from Firmware Table */
181 MachVtbl
.ConsPutChar
= ArmBoardBlock
->ConsPutChar
;
182 MachVtbl
.ConsKbHit
= ArmBoardBlock
->ConsKbHit
;
183 MachVtbl
.ConsGetCh
= ArmBoardBlock
->ConsGetCh
;
184 MachVtbl
.VideoClearScreen
= ArmBoardBlock
->VideoClearScreen
;
185 MachVtbl
.VideoSetDisplayMode
= ArmBoardBlock
->VideoSetDisplayMode
;
186 MachVtbl
.VideoGetDisplaySize
= ArmBoardBlock
->VideoGetDisplaySize
;
187 MachVtbl
.VideoPutChar
= ArmBoardBlock
->VideoPutChar
;
188 MachVtbl
.GetTime
= ArmBoardBlock
->GetTime
;
190 /* Setup board-specific ARM routines */
191 switch (ArmBoardBlock
->BoardType
)
193 /* Check for Feroceon-base boards */
194 case MACH_TYPE_FEROCEON
:
195 TuiPrintf("Not implemented\n");
199 /* Check for TI OMAP3 ZOOM-II MDK */
200 case MACH_TYPE_OMAP_ZOOM2
:
202 /* Setup the disk and file system buffers */
203 gDiskReadBuffer
= 0x81094000;
204 gFileSysBuffer
= 0x81094000;
207 /* Check for ARM Versatile PB boards */
208 case MACH_TYPE_VERSATILE_PB
:
210 /* Setup the disk and file system buffers */
211 gDiskReadBuffer
= 0x00090000;
212 gFileSysBuffer
= 0x00090000;
215 /* Check for TI OMAP3 Beagleboard */
216 case MACH_TYPE_OMAP3_BEAGLE
:
217 TuiPrintf("Not implemented\n");
225 /* Setup generic ARM routines for all boards */
226 MachVtbl
.PrepareForReactOS
= ArmPrepareForReactOS
;
227 MachVtbl
.GetMemoryMap
= ArmMemGetMemoryMap
;
228 MachVtbl
.InitializeBootDevices
= ArmInitializeBootDevices
;
229 MachVtbl
.HwDetect
= ArmHwDetect
;
230 MachVtbl
.HwIdle
= ArmHwIdle
;