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
;
34 CHAR reactos_arc_hardware_data
[256];
52 4 // 4-way associative
59 8 // 8 words per line (32 bytes)
62 /* FUNCTIONS ******************************************************************/
65 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext
)
67 /* Remember the pointer */
68 ArmBoardBlock
= BootContext
;
70 /* Let's make sure we understand the LLB */
71 ASSERT(ArmBoardBlock
->MajorVersion
== ARM_BOARD_CONFIGURATION_MAJOR_VERSION
);
72 ASSERT(ArmBoardBlock
->MinorVersion
== ARM_BOARD_CONFIGURATION_MINOR_VERSION
);
74 /* This should probably go away once we support more boards */
75 ASSERT((ArmBoardBlock
->BoardType
== MACH_TYPE_FEROCEON
) ||
76 (ArmBoardBlock
->BoardType
== MACH_TYPE_VERSATILE_PB
) ||
77 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP3_BEAGLE
) ||
78 (ArmBoardBlock
->BoardType
== MACH_TYPE_OMAP_ZOOM2
));
80 /* Call FreeLDR's portable entrypoint with our command-line */
81 BootMain(ArmBoardBlock
->CommandLine
);
85 ArmPrepareForReactOS(IN BOOLEAN Setup
)
91 ArmDiskGetBootPath(OUT PCHAR BootPath
,
94 PCCH Path
= "ramdisk(0)";
96 /* Make sure enough space exists */
97 if (Size
< sizeof(Path
)) return FALSE
;
99 /* On ARM platforms, the loader is always in RAM */
100 strcpy(BootPath
, Path
);
104 PCONFIGURATION_COMPONENT_DATA
107 ARM_CACHE_REGISTER CacheReg
;
109 /* Create the root node */
110 if (ArmHwDetectRan
++) return RootNode
;
111 FldrCreateSystemKey(&RootNode
);
115 * There's no such thing as "PnP" on embedded hardware.
116 * The boot loader will send us a device tree, similar to ACPI
117 * or OpenFirmware device trees, and we will convert it to ARC.
120 /* Get cache information */
121 CacheReg
= KeArmCacheRegisterGet();
122 FirstLevelDcacheSize
= SizeBits
[CacheReg
.DSize
];
123 FirstLevelDcacheFillSize
= LenBits
[CacheReg
.DLength
];
124 FirstLevelDcacheFillSize
<<= 2;
125 FirstLevelIcacheSize
= SizeBits
[CacheReg
.ISize
];
126 FirstLevelIcacheFillSize
= LenBits
[CacheReg
.ILength
];
127 FirstLevelIcacheFillSize
<<= 2;
128 SecondLevelDcacheSize
=
129 SecondLevelDcacheFillSize
=
130 SecondLevelIcacheSize
=
131 SecondLevelIcacheFillSize
= 0;
133 /* Register RAMDISK Device */
136 /* Fill out the ARC disk block */
137 reactos_arc_disk_info
.Signature
= 0xBADAB00F;
138 reactos_arc_disk_info
.CheckSum
= 0xDEADBABE;
139 reactos_arc_disk_info
.ArcName
= "ramdisk(0)";
140 reactos_disk_count
= 1;
142 /* Return the root node */
146 FREELDR_MEMORY_DESCRIPTOR ArmMemoryMap
[32];
148 PFREELDR_MEMORY_DESCRIPTOR
149 ArmMemGetMemoryMap(OUT ULONG
*MemoryMapSize
)
151 ASSERT(ArmBoardBlock
->MemoryMapEntryCount
<= 32);
153 /* Return whatever the board returned to us (CS0 Base + Size and FLASH0) */
154 for (i
= 0; i
< ArmBoardBlock
->MemoryMapEntryCount
; i
++)
156 ArmMemoryMap
[i
].BasePage
= ArmBoardBlock
->MemoryMap
[i
].BaseAddress
/ PAGE_SIZE
;
157 ArmMemoryMap
[i
].PageCount
= ArmBoardBlock
->MemoryMap
[i
].Length
/ PAGE_SIZE
;
158 if (ArmBoardBlock
->MemoryMap
[i
].Type
== BiosMemoryUsable
)
159 ArmMemoryMap
[i
].MemoryType
= MemoryFree
;
161 ArmMemoryMap
[i
].MemoryType
= MemoryFirmwarePermanent
;
164 return ArmBoardBlock
->MemoryMapEntryCount
;
168 MachInit(IN PCCH CommandLine
)
170 /* Copy Machine Routines from Firmware Table */
171 MachVtbl
.ConsPutChar
= ArmBoardBlock
->ConsPutChar
;
172 MachVtbl
.ConsKbHit
= ArmBoardBlock
->ConsKbHit
;
173 MachVtbl
.ConsGetCh
= ArmBoardBlock
->ConsGetCh
;
174 MachVtbl
.VideoClearScreen
= ArmBoardBlock
->VideoClearScreen
;
175 MachVtbl
.VideoSetDisplayMode
= ArmBoardBlock
->VideoSetDisplayMode
;
176 MachVtbl
.VideoGetDisplaySize
= ArmBoardBlock
->VideoGetDisplaySize
;
177 MachVtbl
.VideoPutChar
= ArmBoardBlock
->VideoPutChar
;
178 MachVtbl
.GetTime
= ArmBoardBlock
->GetTime
;
180 /* Setup board-specific ARM routines */
181 switch (ArmBoardBlock
->BoardType
)
183 /* Check for Feroceon-base boards */
184 case MACH_TYPE_FEROCEON
:
185 TuiPrintf("Not implemented\n");
189 /* Check for TI OMAP3 ZOOM-II MDK */
190 case MACH_TYPE_OMAP_ZOOM2
:
192 /* Setup the disk and file system buffers */
193 gDiskReadBuffer
= 0x81094000;
194 gFileSysBuffer
= 0x81094000;
197 /* Check for ARM Versatile PB boards */
198 case MACH_TYPE_VERSATILE_PB
:
200 /* Setup the disk and file system buffers */
201 gDiskReadBuffer
= 0x00090000;
202 gFileSysBuffer
= 0x00090000;
205 /* Check for TI OMAP3 Beagleboard */
206 case MACH_TYPE_OMAP3_BEAGLE
:
207 TuiPrintf("Not implemented\n");
215 /* Setup generic ARM routines for all boards */
216 MachVtbl
.PrepareForReactOS
= ArmPrepareForReactOS
;
217 MachVtbl
.GetMemoryMap
= ArmMemGetMemoryMap
;
218 MachVtbl
.HwDetect
= ArmHwDetect
;
219 MachVtbl
.DiskGetBootPath
= ArmDiskGetBootPath
;