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 printf("Command Line %s\n", CommandLine
);
42 strcpy(ArmBlock
.CommandLine
, CommandLine
);
47 LlbBuildArmBlock(VOID
)
49 /* Write version number */
50 ArmBlock
.MajorVersion
= ARM_BOARD_CONFIGURATION_MAJOR_VERSION
;
51 ArmBlock
.MinorVersion
= ARM_BOARD_CONFIGURATION_MINOR_VERSION
;
54 ArmBlock
.BoardType
= LlbHwGetBoardType();
56 /* Get peripheral clock rate */
57 ArmBlock
.ClockRate
= LlbHwGetPClk();
59 /* Get timer and serial port base addresses */
60 ArmBlock
.TimerRegisterBase
= LlbHwGetTmr0Base();
61 ArmBlock
.UartRegisterBase
= LlbHwGetUartBase(LlbHwGetSerialUart());
64 printf("Machine Identifier: %lx\nPCLK: %d\nTIMER 0: %p\nSERIAL UART: %p\n",
67 ArmBlock
.TimerRegisterBase
,
68 ArmBlock
.UartRegisterBase
);
70 /* Now load the memory map */
71 ArmBlock
.MemoryMap
= MemoryMap
;
73 /* Write firmware callbacks */
74 ArmBlock
.ConsPutChar
= LlbFwPutChar
;
75 ArmBlock
.ConsKbHit
= LlbFwKbHit
;
76 ArmBlock
.ConsGetCh
= LlbFwGetCh
;
81 LlbBuildMemoryMap(VOID
)
83 /* Zero out the memory map */
84 memset(MemoryMap
, 0, sizeof(MemoryMap
));
86 /* Call the hardware-specific function */
87 LlbHwBuildMemoryMap(MemoryMap
);
96 /* Read the current boot device */
97 BootDevice
= LlbEnvRead("boot-device");
98 printf("Loading OS Loader from: %s...\n", BootDevice
);
99 if (!strcmp(BootDevice
, "NAND"))
103 else if (!strcmp(BootDevice
, "RAMDISK"))
105 /* Call the hardware-specific function */
106 LoaderInit
= LlbHwLoadOsLoaderFromRam();
108 else if (!strcmp(BootDevice
, "MMC") ||
109 !strcmp(BootDevice
, "SD"))
113 else if (!strcmp(BootDevice
, "HDD"))
117 printf("OS Loader loaded at 0x%p...JUMP!\n\n\n\n\n", LoaderInit
);
122 LlbBoot(IN PCHAR CommandLine
)
124 /* Setup the ARM block */
127 /* Build the memory map */
130 /* Set the command-line */
131 LlbSetCommandLine(CommandLine
);
133 /* Load the OS loader */
136 /* Jump to the OS Loader (FreeLDR in this case) */
137 LoaderInit(&ArmBlock
);