[freeldr] Remove MachDiskGetPartitionEntry, and directly use the correct one
[reactos.git] / reactos / boot / freeldr / freeldr / arch / arm / macharm.c
1 /*
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
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include <freeldr.h>
12
13 /* GLOBALS ********************************************************************/
14
15 UCHAR BootStack[0x4000];
16 PUCHAR BootStackEnd = &BootStack[0x3FFF];
17 PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
18 ULONG BootDrive, BootPartition;
19 VOID ArmPrepareForReactOS(IN BOOLEAN Setup);
20 ADDRESS_RANGE ArmBoardMemoryMap[16];
21 ULONG ArmBoardMemoryMapRangeCount;
22
23 /* FUNCTIONS ******************************************************************/
24
25 VOID
26 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
27 {
28 ULONG i;
29
30 //
31 // Remember the pointer
32 //
33 ArmBoardBlock = BootContext;
34
35 //
36 // Let's make sure we understand the boot-loader
37 //
38 ASSERT(ArmBoardBlock->MajorVersion == ARM_BOARD_CONFIGURATION_MAJOR_VERSION);
39 ASSERT(ArmBoardBlock->MinorVersion == ARM_BOARD_CONFIGURATION_MINOR_VERSION);
40
41 //
42 // This should probably go away once we support more boards
43 //
44 ASSERT((ArmBoardBlock->BoardType == MACH_TYPE_FEROCEON) ||
45 (ArmBoardBlock->BoardType == MACH_TYPE_VERSATILE_PB) ||
46 (ArmBoardBlock->BoardType == MACH_TYPE_OMAP3_BEAGLE));
47
48 //
49 // Save data required for memory initialization
50 //
51 ArmBoardMemoryMapRangeCount = ArmBoardBlock->MemoryMapEntryCount;
52 ASSERT(ArmBoardMemoryMapRangeCount != 0);
53 ASSERT(ArmBoardMemoryMapRangeCount < 16);
54 for (i = 0; i < ArmBoardMemoryMapRangeCount; i++)
55 {
56 //
57 // Copy each entry
58 //
59 RtlCopyMemory(&ArmBoardMemoryMap[i],
60 &ArmBoardBlock->MemoryMap[i],
61 sizeof(ADDRESS_RANGE));
62 }
63
64 //
65 // Call FreeLDR's portable entrypoint with our command-line
66 //
67 BootMain(ArmBoardBlock->CommandLine);
68 }
69
70 BOOLEAN
71 ArmDiskGetDriveGeometry(IN ULONG DriveNumber,
72 OUT PGEOMETRY Geometry)
73 {
74 ASSERT(gRamDiskBase == NULL);
75 return FALSE;
76 }
77
78 BOOLEAN
79 ArmDiskReadLogicalSectors(IN ULONG DriveNumber,
80 IN ULONGLONG SectorNumber,
81 IN ULONG SectorCount,
82 IN PVOID Buffer)
83 {
84 ASSERT(gRamDiskBase == NULL);
85 return FALSE;
86 }
87
88 ULONG
89 ArmDiskGetCacheableBlockCount(IN ULONG DriveNumber)
90 {
91 ASSERT(gRamDiskBase == NULL);
92 return FALSE;
93 }
94
95 PCONFIGURATION_COMPONENT_DATA
96 ArmHwDetect(VOID)
97 {
98 PCONFIGURATION_COMPONENT_DATA RootNode;
99
100 //
101 // Create the root node
102 //
103 FldrCreateSystemKey(&RootNode);
104
105 //
106 // TODO:
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.
110 //
111
112 //
113 // Return the root node
114 //
115 return RootNode;
116 }
117
118 ULONG
119 ArmMemGetMemoryMap(OUT PBIOS_MEMORY_MAP BiosMemoryMap,
120 IN ULONG MaxMemoryMapSize)
121 {
122 //
123 // Return whatever the board returned to us (CS0 Base + Size and FLASH0)
124 //
125 RtlCopyMemory(BiosMemoryMap,
126 ArmBoardBlock->MemoryMap,
127 ArmBoardBlock->MemoryMapEntryCount * sizeof(BIOS_MEMORY_MAP));
128 return ArmBoardBlock->MemoryMapEntryCount;
129 }
130
131 VOID
132 MachInit(IN PCCH CommandLine)
133 {
134 //
135 // Setup board-specific ARM routines
136 //
137 switch (ArmBoardBlock->BoardType)
138 {
139 //
140 // Check for Feroceon-base boards
141 //
142 case MACH_TYPE_FEROCEON:
143
144 //
145 // These boards use a UART16550. Set us up for 115200 bps
146 //
147 ArmFeroSerialInit(115200);
148 MachVtbl.ConsPutChar = ArmFeroPutChar;
149 MachVtbl.ConsKbHit = ArmFeroKbHit;
150 MachVtbl.ConsGetCh = ArmFeroGetCh;
151 break;
152
153 //
154 // Check for ARM Versatile PB boards
155 //
156 case MACH_TYPE_VERSATILE_PB:
157
158 //
159 // These boards use a PrimeCell UART (PL011)
160 //
161 ArmVersaSerialInit(115200);
162 MachVtbl.ConsPutChar = ArmVersaPutChar;
163 MachVtbl.ConsKbHit = ArmVersaKbHit;
164 MachVtbl.ConsGetCh = ArmVersaGetCh;
165 break;
166
167 //
168 // Check for TI OMAP3 boards
169 // For now that means only Beagle, but ZOOM and others should be ok too
170 //
171 case MACH_TYPE_OMAP3_BEAGLE:
172
173 //
174 // These boards use a UART16550
175 //
176 ArmOmap3SerialInit(115200);
177 MachVtbl.ConsPutChar = ArmOmap3PutChar;
178 MachVtbl.ConsKbHit = ArmOmap3KbHit;
179 MachVtbl.ConsGetCh = ArmOmap3GetCh;
180 break;
181
182 default:
183 ASSERT(FALSE);
184 }
185
186 //
187 // Setup generic ARM routines for all boards
188 //
189 MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
190 MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
191 MachVtbl.HwDetect = ArmHwDetect;
192
193 //
194 // Setup disk I/O routines, switch to ramdisk ones for non-NAND boot
195 //
196 MachVtbl.DiskReadLogicalSectors = ArmDiskReadLogicalSectors;
197 MachVtbl.DiskGetDriveGeometry = ArmDiskGetDriveGeometry;
198 MachVtbl.DiskGetCacheableBlockCount = ArmDiskGetCacheableBlockCount;
199 RamDiskSwitchFromBios();
200
201 //
202 // Now set default disk handling routines -- we don't need to override
203 //
204 MachVtbl.DiskGetBootPath = DiskGetBootPath;
205 MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
206
207 //
208 // We can now print to the console
209 //
210 TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
211 TuiPrintf("Bootargs: %s\n", CommandLine);
212 }