ReactOS  0.4.12-dev-918-g6c6e7b8
loader.c
Go to the documentation of this file.
1 /*
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
7  */
8 
9 #include "precomp.h"
10 
14 
15 VOID
16 NTAPI
19  IN ULONG Length)
20 {
22 
23  /* Get the next memory entry */
24  Entry = MemoryMap;
25  while (Entry->Length) Entry++;
26 
27  /* Fill it out */
28  Entry->Length = Length;
29  Entry->BaseAddress = BaseAddress;
30  Entry->Type = Type;
31 
32  /* Block count */
34 }
35 
36 VOID
37 NTAPI
39 {
40  /* Copy the command line in the ARM block */
41  strcpy(ArmBlock.CommandLine, CommandLine);
42 }
43 
44 VOID
45 NTAPI
47 {
48  /* Write version number */
51 
52  /* Get arch type */
54 
55  /* Get peripheral clock rate */
57 
58  /* Get timer and serial port base addresses */
61 
62  /* Debug */
63  DbgPrint("Machine Identifier: %lx\nPCLK: %d\nTIMER 0: %p\nSERIAL UART: %p\n",
68 
69  /* Now load the memory map */
71 
72  /* Write firmware callbacks */
81 }
82 
83 VOID
84 NTAPI
86 {
87  /* Zero out the memory map */
88  memset(MemoryMap, 0, sizeof(MemoryMap));
89 
90  /* Call the hardware-specific function for hardware-defined regions */
92 }
93 
94 //
95 // Should go to hwdev.c
96 //
98 NTAPI
100 {
101  ULONG Base, RootFs, Size;
102  PCHAR Offset;
103  CHAR CommandLine[64];
104 
105  /* On versatile we load the RAMDISK with initrd */
107  DbgPrint("Root fs: %lx, size: %lx\n", RootFs, Size);
108 
109  /* The OS Loader is at 0x20000, always */
110  Base = 0x20000;
111 
112  /* Read image offset */
113  Offset = LlbEnvRead("rdoffset");
114 
115  /* Set parameters for the OS loader */
116  snprintf(CommandLine,
117  sizeof(CommandLine),
118  "rdbase=0x%lx rdsize=0x%lx rdoffset=%s",
119  RootFs, Size, Offset);
120  LlbSetCommandLine(CommandLine);
121 
122  /* Return the OS loader base address */
123  return (POSLOADER_INIT)Base;
124 }
125 
126 VOID
127 NTAPI
129 {
131 
132  /* Read the current boot device */
133  BootDevice = LlbEnvRead("boot-device");
134  printf("Loading OS Loader from: %s...\n", BootDevice);
135  if (!strcmp(BootDevice, "NAND"))
136  {
137  // todo
138  }
139  else if (!strcmp(BootDevice, "RAMDISK"))
140  {
141  /* Call the hardware-specific function */
143  }
144  else if (!strcmp(BootDevice, "MMC") ||
145  !strcmp(BootDevice, "SD"))
146  {
147  //todo
148  }
149  else if (!strcmp(BootDevice, "HDD"))
150  {
151  //todo
152  }
153 
154  LoaderInit = (PVOID)0x80000000;
155 #ifdef _ZOOM2_ // need something better than this...
156  LoaderInit = (PVOID)0x81070000;
157 #endif
158  printf("OS Loader loaded at 0x%p...JUMP!\n\n\n\n\n", LoaderInit);
159 }
160 
161 VOID
162 NTAPI
164 {
165  /* Setup the ARM block */
167 
168  /* Build the memory map */
170 
171  /* Load the OS loader */
172  LlbLoadOsLoader();
173 
174  /* Jump to the OS Loader (FreeLDR in this case) */
176 }
177 
178 /* EOF */
signed char * PCHAR
Definition: retypes.h:7
#define IN
Definition: typedefs.h:38
Type
Definition: Type.h:6
struct _Entry Entry
Definition: kefuncs.h:640
#define DbgPrint
Definition: loader.c:25
VOID LlbFwVideoPutChar(IN INT c, IN UCHAR Attr, IN ULONG X, IN ULONG Y)
Definition: fw.c:88
BIOS_MEMORY_MAP MemoryMap[32]
Definition: loader.c:11
char CHAR
Definition: xmlstorage.h:175
Definition: bl.h:252
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2327
#define ARM_BOARD_CONFIGURATION_MAJOR_VERSION
Definition: osloader.h:42
#define snprintf
Definition: wintirpc.h:48
VOID NTAPI LlbSetCommandLine(IN PCHAR CommandLine)
Definition: loader.c:38
static PVOID
Definition: loader.c:61
VOID NTAPI LlbLoadOsLoader(VOID)
Definition: loader.c:128
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
INT LlbFwGetCh(VOID)
Definition: fw.c:49
ARM_BOARD_CONFIGURATION_BLOCK ArmBlock
Definition: loader.c:12
ULONG LlbFwVideoSetDisplayMode(IN PCHAR DisplayModeName, IN BOOLEAN Init)
Definition: fw.c:60
ULONG NTAPI LlbHwGetSerialUart(VOID)
Definition: hwinfo.c:34
POSLOADER_INIT LoaderInit
Definition: loader.c:13
#define ARM_BOARD_CONFIGURATION_MINOR_VERSION
Definition: osloader.h:43
PCHAR NTAPI LlbEnvRead(IN PCHAR ValueName)
Definition: envir.c:127
VOID NTAPI LlbHwBuildMemoryMap(IN PBIOS_MEMORY_MAP MemoryMap)
Definition: hwinfo.c:101
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
ULONG NTAPI LlbHwGetPClk(VOID)
Definition: hwinfo.c:20
VOID NTAPI LlbAllocateMemoryEntry(IN BIOS_MEMORY_TYPE Type, IN ULONG BaseAddress, IN ULONG Length)
Definition: loader.c:17
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI LlbBuildArmBlock(VOID)
Definition: loader.c:46
BIOS_MEMORY_TYPE
Definition: osloader.h:20
VOID LlbFwVideoClearScreen(IN UCHAR Attr)
Definition: fw.c:81
VOID LlbFwVideoGetDisplaySize(OUT PULONG Width, OUT PULONG Height, OUT PULONG Depth)
Definition: fw.c:68
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG NTAPI LlbHwGetTmr0Base(VOID)
Definition: hwinfo.c:27
TIMEINFO * LlbFwGetTime(VOID)
Definition: fw.c:113
BOOLEAN NTAPI LlbEnvGetRamDiskInformation(IN PULONG Base, IN PULONG Size)
Definition: envir.c:107
PBIOS_MEMORY_MAP MemoryMap
Definition: osloader.h:53
VOID(* POSLOADER_INIT)(IN PVOID BoardInit)
Definition: osloader.h:13
POSLOADER_INIT NTAPI LlbHwLoadOsLoaderFromRam(VOID)
Definition: loader.c:99
ULONG NTAPI LlbHwGetUartBase(IN ULONG Port)
Definition: hwuart.c:36
VOID NTAPI LlbBuildMemoryMap(VOID)
Definition: loader.c:85
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
VOID LlbFwPutChar(INT Ch)
Definition: fw.c:32
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
VOID NTAPI LlbBoot(VOID)
Definition: loader.c:163
BOOLEAN LlbFwKbHit(VOID)
Definition: fw.c:42
#define memset(x, y, z)
Definition: compat.h:39
ULONG NTAPI LlbHwGetBoardType(VOID)
Definition: hwinfo.c:13
base of all file and directory entries
Definition: entries.h:82
#define printf
Definition: config.h:203