Better organize FreeLDR ARM files -- there are no more stubs now. We have the ReactOS...
[reactos.git] / reactos / boot / freeldr / freeldr / arch / arm / macharm.c
1 /*
2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: GPL - See COPYING 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 PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
16 ULONG BootDrive, BootPartition;
17 VOID ArmPrepareForReactOS(IN BOOLEAN Setup);
18
19 /* FUNCTIONS ******************************************************************/
20
21 VOID
22 ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
23 {
24 //
25 // Remember the pointer
26 //
27 ArmBoardBlock = BootContext;
28
29 //
30 // Let's make sure we understand the boot-loader
31 //
32 ASSERT(ArmBoardBlock->MajorVersion == ARM_BOARD_CONFIGURATION_MAJOR_VERSION);
33 ASSERT(ArmBoardBlock->MinorVersion == ARM_BOARD_CONFIGURATION_MINOR_VERSION);
34
35 //
36 // This should probably go away once we support more boards
37 //
38 ASSERT((ArmBoardBlock->BoardType == MACH_TYPE_FEROCEON) ||
39 (ArmBoardBlock->BoardType == MACH_TYPE_VERSATILE_PB));
40
41 //
42 // Call FreeLDR's portable entrypoint with our command-line
43 //
44 BootMain(ArmBoardBlock->CommandLine);
45 }
46
47 BOOLEAN
48 ArmDiskGetDriveGeometry(IN ULONG DriveNumber,
49 OUT PGEOMETRY Geometry)
50 {
51 ASSERT(gRamDiskBase == NULL);
52 return FALSE;
53 }
54
55 BOOLEAN
56 ArmDiskReadLogicalSectors(IN ULONG DriveNumber,
57 IN ULONGLONG SectorNumber,
58 IN ULONG SectorCount,
59 IN PVOID Buffer)
60 {
61 ASSERT(gRamDiskBase == NULL);
62 return FALSE;
63 }
64
65 ULONG
66 ArmDiskGetCacheableBlockCount(IN ULONG DriveNumber)
67 {
68 ASSERT(gRamDiskBase == NULL);
69 return FALSE;
70 }
71
72 PCONFIGURATION_COMPONENT_DATA
73 ArmHwDetect(VOID)
74 {
75 PCONFIGURATION_COMPONENT_DATA RootNode;
76
77 //
78 // Create the root node
79 //
80 FldrCreateSystemKey(&RootNode);
81
82 //
83 // Write null component information
84 //
85 FldrSetComponentInformation(RootNode,
86 0x0,
87 0x0,
88 0xFFFFFFFF);
89
90 //
91 // TODO:
92 // There's no such thing as "PnP" on embedded hardware.
93 // The boot loader will send us a device tree, similar to ACPI
94 // or OpenFirmware device trees, and we will convert it to ARC.
95 //
96
97 //
98 // Return the root node
99 //
100 return RootNode;
101 }
102
103 ULONG
104 ArmMemGetMemoryMap(OUT PBIOS_MEMORY_MAP BiosMemoryMap,
105 IN ULONG MaxMemoryMapSize)
106 {
107 //
108 // Return whatever the board returned to us (CS0 Base + Size and FLASH0)
109 //
110 RtlCopyMemory(BiosMemoryMap,
111 ArmBoardBlock->MemoryMap,
112 ArmBoardBlock->MemoryMapEntryCount * sizeof(BIOS_MEMORY_MAP));
113 return ArmBoardBlock->MemoryMapEntryCount;
114 }
115
116 VOID
117 MachInit(IN PCCH CommandLine)
118 {
119 //
120 // Setup board-specific ARM routines
121 //
122 switch (ArmBoardBlock->BoardType)
123 {
124 //
125 // Check for Feroceon-base boards
126 //
127 case MACH_TYPE_FEROCEON:
128
129 //
130 // These boards use a UART16550. Set us up for 115200 bps
131 //
132 ArmFeroSerialInit(115200);
133 MachVtbl.ConsPutChar = ArmFeroPutChar;
134 MachVtbl.ConsKbHit = ArmFeroKbHit;
135 MachVtbl.ConsGetCh = ArmFeroGetCh;
136 break;
137
138 //
139 // Check for ARM Versatile PB boards
140 //
141 case MACH_TYPE_VERSATILE_PB:
142
143 //
144 // These boards use a PrimeCell UART (PL011)
145 //
146 ArmVersaSerialInit(115200);
147 MachVtbl.ConsPutChar = ArmVersaPutChar;
148 MachVtbl.ConsKbHit = ArmVersaKbHit;
149 MachVtbl.ConsGetCh = ArmVersaGetCh;
150 break;
151
152 default:
153 ASSERT(FALSE);
154 }
155
156 //
157 // Setup generic ARM routines for all boards
158 //
159 MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
160 MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
161 MachVtbl.HwDetect = ArmHwDetect;
162
163 //
164 // Setup disk I/O routines, switch to ramdisk ones for non-NAND boot
165 //
166 MachVtbl.DiskReadLogicalSectors = ArmDiskReadLogicalSectors;
167 MachVtbl.DiskGetDriveGeometry = ArmDiskGetDriveGeometry;
168 MachVtbl.DiskGetCacheableBlockCount = ArmDiskGetCacheableBlockCount;
169 RamDiskSwitchFromBios();
170
171 //
172 // Now set default disk handling routines -- we don't need to override
173 //
174 MachVtbl.DiskGetBootVolume = DiskGetBootVolume;
175 MachVtbl.DiskGetSystemVolume = DiskGetSystemVolume;
176 MachVtbl.DiskGetBootPath = DiskGetBootPath;
177 MachVtbl.DiskGetBootDevice = DiskGetBootDevice;
178 MachVtbl.DiskBootingFromFloppy = DiskBootingFromFloppy;
179 MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
180 MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry;
181
182 //
183 // We can now print to the console
184 //
185 TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
186 TuiPrintf("Bootargs: %s\n", CommandLine);
187 }