2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/armllb/os/loader.c
5 * PURPOSE: OS Loader Code for LLB
6 * PROGRAMMERS: ReactOS Portable Systems Group
11 BIOS_MEMORY_MAP MemoryMap
[32];
12 ARM_BOARD_CONFIGURATION_BLOCK ArmBlock
;
13 POSLOADER_INIT LoaderInit
;
17 LlbAllocateMemoryEntry(IN BIOS_MEMORY_TYPE Type
,
21 PBIOS_MEMORY_MAP Entry
;
23 /* Get the next memory entry */
25 while (Entry
->Length
) Entry
++;
28 Entry
->Length
= Length
;
29 Entry
->BaseAddress
= BaseAddress
;
33 ArmBlock
.MemoryMapEntryCount
++;
38 LlbSetCommandLine(IN PCHAR CommandLine
)
40 /* Copy the command line in the ARM block */
41 strcpy(ArmBlock
.CommandLine
, CommandLine
);
46 LlbBuildArmBlock(VOID
)
48 /* Write version number */
49 ArmBlock
.MajorVersion
= ARM_BOARD_CONFIGURATION_MAJOR_VERSION
;
50 ArmBlock
.MinorVersion
= ARM_BOARD_CONFIGURATION_MINOR_VERSION
;
53 ArmBlock
.BoardType
= LlbHwGetBoardType();
55 /* Get peripheral clock rate */
56 ArmBlock
.ClockRate
= LlbHwGetPClk();
58 /* Get timer and serial port base addresses */
59 ArmBlock
.TimerRegisterBase
= LlbHwGetTmr0Base();
60 ArmBlock
.UartRegisterBase
= LlbHwGetUartBase(LlbHwGetSerialUart());
63 DbgPrint("Machine Identifier: %lx\nPCLK: %d\nTIMER 0: %p\nSERIAL UART: %p\n",
66 ArmBlock
.TimerRegisterBase
,
67 ArmBlock
.UartRegisterBase
);
69 /* Now load the memory map */
70 ArmBlock
.MemoryMap
= MemoryMap
;
72 /* Write firmware callbacks */
73 ArmBlock
.ConsPutChar
= LlbFwPutChar
;
74 ArmBlock
.ConsKbHit
= LlbFwKbHit
;
75 ArmBlock
.ConsGetCh
= LlbFwGetCh
;
76 ArmBlock
.VideoClearScreen
= LlbFwVideoClearScreen
;
77 ArmBlock
.VideoSetDisplayMode
= LlbFwVideoSetDisplayMode
;
78 ArmBlock
.VideoGetDisplaySize
= LlbFwVideoGetDisplaySize
;
79 ArmBlock
.VideoGetBufferSize
= LlbFwVideoGetBufferSize
;
80 ArmBlock
.VideoSetTextCursorPosition
= LlbFwVideoSetTextCursorPosition
;
81 ArmBlock
.VideoSetTextCursorPosition
= LlbFwVideoSetTextCursorPosition
;
82 ArmBlock
.VideoHideShowTextCursor
= LlbFwVideoHideShowTextCursor
;
83 ArmBlock
.VideoPutChar
= LlbFwVideoPutChar
;
84 ArmBlock
.VideoCopyOffScreenBufferToVRAM
= LlbFwVideoCopyOffScreenBufferToVRAM
;
85 ArmBlock
.VideoIsPaletteFixed
= LlbFwVideoIsPaletteFixed
;
86 ArmBlock
.VideoSetPaletteColor
= LlbFwVideoSetPaletteColor
;
87 ArmBlock
.VideoGetPaletteColor
= LlbFwVideoGetPaletteColor
;
88 ArmBlock
.VideoSync
= LlbFwVideoSync
;
93 LlbBuildMemoryMap(VOID
)
97 /* Zero out the memory map */
98 memset(MemoryMap
, 0, sizeof(MemoryMap
));
100 /* Query memory information */
101 LlbEnvGetMemoryInformation(&Base
, &Size
);
103 /* Don't use memory that the RAMDISK is using */
105 Base
+= 32 * 1024 * 1024;
106 Size
-= 32 * 1024 * 1024;
108 /* Allocate an entry for it */
109 LlbAllocateMemoryEntry(BiosMemoryUsable
, Base
, Size
);
111 /* Call the hardware-specific function for hardware-defined regions */
112 LlbHwBuildMemoryMap(MemoryMap
);
117 LlbLoadOsLoader(VOID
)
121 /* Read the current boot device */
122 BootDevice
= LlbEnvRead("boot-device");
123 printf("Loading OS Loader from: %s...\n", BootDevice
);
124 if (!strcmp(BootDevice
, "NAND"))
128 else if (!strcmp(BootDevice
, "RAMDISK"))
130 /* Call the hardware-specific function */
131 LoaderInit
= LlbHwLoadOsLoaderFromRam();
133 else if (!strcmp(BootDevice
, "MMC") ||
134 !strcmp(BootDevice
, "SD"))
138 else if (!strcmp(BootDevice
, "HDD"))
142 printf("OS Loader loaded at 0x%p...JUMP!\n\n\n\n\n", LoaderInit
);
149 /* Setup the ARM block */
152 /* Build the memory map */
155 /* Load the OS loader */
158 /* Jump to the OS Loader (FreeLDR in this case) */
159 LoaderInit(&ArmBlock
);