ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

loader.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Boot Loader
00003  * LICENSE:         BSD - See COPYING.ARM in the top level directory
00004  * FILE:            boot/armllb/os/loader.c
00005  * PURPOSE:         OS Loader Code for LLB
00006  * PROGRAMMERS:     ReactOS Portable Systems Group
00007  */
00008 
00009 #include "precomp.h"
00010 
00011 BIOS_MEMORY_MAP MemoryMap[32];
00012 ARM_BOARD_CONFIGURATION_BLOCK ArmBlock;
00013 POSLOADER_INIT LoaderInit;
00014     
00015 VOID
00016 NTAPI
00017 LlbAllocateMemoryEntry(IN BIOS_MEMORY_TYPE Type,
00018                       IN ULONG BaseAddress,
00019                       IN ULONG Length)
00020 {
00021     PBIOS_MEMORY_MAP Entry;
00022     
00023     /* Get the next memory entry */
00024     Entry = MemoryMap;
00025     while (Entry->Length) Entry++;
00026     
00027     /* Fill it out */
00028     Entry->Length = Length;
00029     Entry->BaseAddress = BaseAddress;
00030     Entry->Type = Type;
00031     
00032     /* Block count */
00033     ArmBlock.MemoryMapEntryCount++;
00034 }
00035 
00036 VOID
00037 NTAPI
00038 LlbSetCommandLine(IN PCHAR CommandLine)
00039 {
00040     /* Copy the command line in the ARM block */
00041     strcpy(ArmBlock.CommandLine, CommandLine);
00042 }
00043 
00044 VOID
00045 NTAPI
00046 LlbBuildArmBlock(VOID)
00047 {
00048     /* Write version number */
00049     ArmBlock.MajorVersion = ARM_BOARD_CONFIGURATION_MAJOR_VERSION;
00050     ArmBlock.MinorVersion = ARM_BOARD_CONFIGURATION_MINOR_VERSION;
00051     
00052     /* Get arch type */
00053     ArmBlock.BoardType = LlbHwGetBoardType();
00054     
00055     /* Get peripheral clock rate */
00056     ArmBlock.ClockRate = LlbHwGetPClk();
00057     
00058     /* Get timer and serial port base addresses */
00059     ArmBlock.TimerRegisterBase = LlbHwGetTmr0Base();
00060     ArmBlock.UartRegisterBase = LlbHwGetUartBase(LlbHwGetSerialUart());
00061     
00062     /* Debug */
00063     DbgPrint("Machine Identifier: %lx\nPCLK: %d\nTIMER 0: %p\nSERIAL UART: %p\n",
00064              ArmBlock.BoardType,
00065              ArmBlock.ClockRate,
00066              ArmBlock.TimerRegisterBase,
00067              ArmBlock.UartRegisterBase);
00068     
00069     /* Now load the memory map */
00070     ArmBlock.MemoryMap = MemoryMap;
00071     
00072     /* Write firmware callbacks */
00073     ArmBlock.ConsPutChar = LlbFwPutChar;
00074     ArmBlock.ConsKbHit = LlbFwKbHit;
00075     ArmBlock.ConsGetCh = LlbFwGetCh;
00076     ArmBlock.VideoClearScreen = LlbFwVideoClearScreen;
00077     ArmBlock.VideoSetDisplayMode = LlbFwVideoSetDisplayMode;
00078     ArmBlock.VideoGetDisplaySize = LlbFwVideoGetDisplaySize;
00079     ArmBlock.VideoPutChar = LlbFwVideoPutChar;
00080     ArmBlock.GetTime = LlbFwGetTime;
00081 }
00082 
00083 VOID
00084 NTAPI
00085 LlbBuildMemoryMap(VOID)
00086 {
00087     /* Zero out the memory map */
00088     memset(MemoryMap, 0, sizeof(MemoryMap));
00089 
00090     /* Call the hardware-specific function for hardware-defined regions */
00091     LlbHwBuildMemoryMap(MemoryMap);
00092 }
00093 
00094 //
00095 // Should go to hwdev.c
00096 //
00097 POSLOADER_INIT
00098 NTAPI
00099 LlbHwLoadOsLoaderFromRam(VOID)
00100 {
00101     ULONG Base, RootFs, Size;
00102     PCHAR Offset;
00103     CHAR CommandLine[64];
00104     
00105     /* On versatile we load the RAMDISK with initrd */
00106     LlbEnvGetRamDiskInformation(&RootFs, &Size);
00107     DbgPrint("Root fs: %lx, size: %lx\n", RootFs, Size);
00108     
00109     /* The OS Loader is at 0x20000, always */
00110     Base = 0x20000;
00111     
00112     /* Read image offset */
00113     Offset = LlbEnvRead("rdoffset");
00114     
00115     /* Set parameters for the OS loader */
00116     snprintf(CommandLine,
00117              sizeof(CommandLine),
00118              "rdbase=0x%x rdsize=0x%x rdoffset=%s",
00119              RootFs, Size, Offset);
00120     LlbSetCommandLine(CommandLine);
00121     
00122     /* Return the OS loader base address */
00123     return (POSLOADER_INIT)Base;
00124 }
00125 
00126 VOID
00127 NTAPI
00128 LlbLoadOsLoader(VOID)
00129 {
00130     PCHAR BootDevice;
00131     
00132     /* Read the current boot device */
00133     BootDevice = LlbEnvRead("boot-device");
00134     printf("Loading OS Loader from: %s...\n", BootDevice);
00135     if (!strcmp(BootDevice, "NAND"))
00136     {
00137         // todo
00138     }
00139     else if (!strcmp(BootDevice, "RAMDISK"))
00140     {
00141         /* Call the hardware-specific function */
00142         LoaderInit = LlbHwLoadOsLoaderFromRam();
00143     }
00144     else if (!strcmp(BootDevice, "MMC") ||
00145              !strcmp(BootDevice, "SD"))
00146     {
00147         //todo
00148     }
00149     else if (!strcmp(BootDevice, "HDD"))
00150     {
00151         //todo
00152     }
00153     
00154     LoaderInit = (PVOID)0x80000000;
00155 #ifdef _ZOOM2_ // need something better than this...
00156     LoaderInit = (PVOID)0x81070000;
00157 #endif
00158     printf("OS Loader loaded at 0x%p...JUMP!\n\n\n\n\n", LoaderInit);
00159 }
00160 
00161 VOID
00162 NTAPI
00163 LlbBoot(VOID)
00164 {
00165     /* Setup the ARM block */
00166     LlbBuildArmBlock();
00167     
00168     /* Build the memory map */
00169     LlbBuildMemoryMap();
00170     
00171     /* Load the OS loader */
00172     LlbLoadOsLoader();
00173 
00174     /* Jump to the OS Loader (FreeLDR in this case) */
00175     LoaderInit(&ArmBlock);
00176 }
00177 
00178 /* EOF */

Generated on Sun May 27 2012 04:19:04 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.