ReactOS  0.4.14-dev-583-g2a1ba2c
freeldr.h File Reference
#include <ntsup.h>
#include <arcname.h>
#include <arcsupp.h>
#include <bytesex.h>
#include <cache.h>
#include <cmdline.h>
#include <comm.h>
#include <disk.h>
#include <fs.h>
#include <inifile.h>
#include <keycodes.h>
#include <linux.h>
#include <custom.h>
#include <miscboot.h>
#include <machine.h>
#include <mm.h>
#include <multiboot.h>
#include <options.h>
#include <oslist.h>
#include <ramdisk.h>
#include <ui.h>
#include <ver.h>
#include <include/ntldr/winldr.h>
#include <conversion.h>
#include <peloader.h>
#include <fs/ext2.h>
#include <fs/fat.h>
#include <fs/ntfs.h>
#include <fs/iso.h>
#include <fs/pxe.h>
#include <fs/btrfs.h>
#include <ui/gui.h>
#include <ui/minitui.h>
#include <ui/noui.h>
#include <ui/tui.h>
#include <ui/video.h>
#include <arch/archwsup.h>
Include dependency graph for freeldr.h:

Go to the source code of this file.

Macros

#define UINT64_C(val)   val##ULL
 
#define RVA(m, b)   ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
 
#define ROUND_DOWN(n, align)   (((ULONG)n) & ~((align) - 1l))
 
#define ROUND_UP(n, align)   ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
 

Functions

VOID __cdecl BootMain (IN PCCH CmdLine)
 
VOID LoadOperatingSystem (IN OperatingSystemItem *OperatingSystem)
 
VOID EditOperatingSystemEntry (IN OperatingSystemItem *OperatingSystem)
 
VOID RunLoader (VOID)
 
VOID FrLdrCheckCpuCompatibility (VOID)
 

Macro Definition Documentation

◆ ROUND_DOWN

#define ROUND_DOWN (   n,
  align 
)    (((ULONG)n) & ~((align) - 1l))

Definition at line 26 of file freeldr.h.

◆ ROUND_UP

#define ROUND_UP (   n,
  align 
)    ROUND_DOWN(((ULONG)n) + (align) - 1, (align))

Definition at line 29 of file freeldr.h.

◆ RVA

#define RVA (   m,
  b 
)    ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))

Definition at line 24 of file freeldr.h.

◆ UINT64_C

#define UINT64_C (   val)    val##ULL

Definition at line 23 of file freeldr.h.

Function Documentation

◆ BootMain()

VOID __cdecl BootMain ( IN PCCH  CmdLine)

Definition at line 43 of file freeldr.c.

44 {
46 
47  /* Debugger pre-initialization */
48  DebugInit(0);
49 
51 
52  TRACE("BootMain() called.\n");
53 
54  /* Check if the CPU is new enough */
55  FrLdrCheckCpuCompatibility(); // FIXME: Should be done inside MachInit!
56 
57  /* UI pre-initialization */
58  if (!UiInitialize(FALSE))
59  {
60  UiMessageBoxCritical("Unable to initialize UI.");
61  goto Quit;
62  }
63 
64  /* Initialize memory manager */
66  {
67  UiMessageBoxCritical("Unable to initialize memory manager.");
68  goto Quit;
69  }
70 
71  /* Initialize I/O subsystem */
72  FsInit();
73 
74  RunLoader();
75 
76 Quit:
77  /* If we reach this point, something went wrong before, therefore reboot */
78  Reboot();
79 }
VOID FsInit(VOID)
Definition: fs.c:430
VOID RunLoader(VOID)
Definition: bootmgr.c:299
BOOLEAN MmInitializeMemoryManager(VOID)
Definition: meminit.c:313
BOOLEAN UiInitialize(BOOLEAN ShowGui)
Definition: ui.c:84
#define DebugInit(FrLdrSectionId)
Definition: debug.h:116
VOID CmdLineParse(IN PCSTR CmdLine)
Definition: cmdline.c:29
Definition: bl.h:892
#define TRACE(s)
Definition: solgame.cpp:4
VOID FrLdrCheckCpuCompatibility(VOID)
Definition: macharm.c:63
CHAR CmdLine[MAX_PATH]
Definition: mach.c:34
VOID UiMessageBoxCritical(PCSTR MessageText)
Definition: ui.c:331
#define MachInit
Definition: amd64.h:42

◆ EditOperatingSystemEntry()

VOID EditOperatingSystemEntry ( IN OperatingSystemItem OperatingSystem)

◆ FrLdrCheckCpuCompatibility()

VOID FrLdrCheckCpuCompatibility ( VOID  )

Definition at line 63 of file macharm.c.

64 {
65  /* Nothing for now */
66 }

Referenced by BootMain().

◆ LoadOperatingSystem()

VOID LoadOperatingSystem ( IN OperatingSystemItem OperatingSystem)

Definition at line 178 of file bootmgr.c.

179 {
180  ULONG_PTR SectionId = OperatingSystem->SectionId;
181  ULONG i;
182  ULONG Argc;
183  PCHAR* Argv;
184  CHAR BootType[80];
185 
186  /* The operating system section has been opened by InitOperatingSystemList() */
187  ASSERT(SectionId != 0);
188 
189  /* Try to read the boot type */
190  *BootType = ANSI_NULL;
191  IniReadSettingByName(SectionId, "BootType", BootType, sizeof(BootType));
192 
193  /* We must have the "BootType" value (it has been possibly added by InitOperatingSystemList()) */
194  ASSERT(*BootType);
195 
196 #ifdef _M_IX86
197  /* Install the drive mapper according to this section drive mappings */
198  DriveMapMapDrivesInSection(SectionId);
199 #endif
200 
201  /* Find the suitable OS loader to start */
202  for (i = 0; ; ++i)
203  {
205  return;
207  break;
208  }
209 
210  /* Build the ARC-compatible argument vector */
211  Argv = BuildArgvForOsLoader(OperatingSystem->LoadIdentifier, SectionId, &Argc);
212  if (!Argv)
213  return; // Unexpected failure.
214 
215  /* Start the OS loader */
216  OSLoadingMethods[i].OsLoader(Argc, Argv, NULL);
217  FrLdrHeapFree(Argv, TAG_STRING);
218 }
signed char * PCHAR
Definition: retypes.h:7
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: mm.h:170
char CHAR
Definition: xmlstorage.h:175
#define _stricmp
Definition: cat.c:22
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ANSI_NULL
#define TAG_STRING
Definition: oslist.h:22
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN IniReadSettingByName(ULONG_PTR SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize)
Definition: inifile.c:147
PCSTR BootType
Definition: bootmgr.c:50
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const struct @151 OSLoadingMethods[]
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
unsigned int ULONG
Definition: retypes.h:1
PCHAR * BuildArgvForOsLoader(IN PCSTR LoadIdentifier, IN ULONG_PTR SectionId, OUT PULONG pArgc)
Definition: bootmgr.c:79

Referenced by RunLoader().

◆ RunLoader()

VOID RunLoader ( VOID  )

Definition at line 299 of file bootmgr.c.

300 {
301  ULONG_PTR SectionId;
302  LONG TimeOut;
303  ULONG OperatingSystemCount;
304  OperatingSystemItem* OperatingSystemList;
305  PCSTR* OperatingSystemDisplayNames;
306  ULONG DefaultOperatingSystem;
307  ULONG SelectedOperatingSystem;
308  ULONG i;
309 
311  {
312  UiMessageBoxCritical("Error when detecting hardware.");
313  return;
314  }
315 
316 #ifdef _M_IX86
317  /* Load additional SCSI driver (if any) */
319  {
320  UiMessageBoxCritical("Unable to load additional boot device drivers.");
321  }
322 #endif
323 
324  if (!IniFileInitialize())
325  {
326  UiMessageBoxCritical("Error initializing .ini file.");
327  return;
328  }
329 
330  /* Open the [FreeLoader] section */
331  if (!IniOpenSection("FreeLoader", &SectionId))
332  {
333  UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
334  return;
335  }
336 
337  /* Debugger main initialization */
338  DebugInit(SectionId);
339 
340  /* Retrieve the default timeout */
341  TimeOut = GetTimeOut(SectionId);
342 
343  /* UI main initialization */
344  if (!UiInitialize(TRUE))
345  {
346  UiMessageBoxCritical("Unable to initialize UI.");
347  return;
348  }
349 
350  OperatingSystemList = InitOperatingSystemList(SectionId,
351  &OperatingSystemCount,
352  &DefaultOperatingSystem);
353  if (!OperatingSystemList)
354  {
355  UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
356  goto Reboot;
357  }
358  if (OperatingSystemCount == 0)
359  {
360  UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
361  goto Reboot;
362  }
363 
364  /* Create list of display names */
365  OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
366  if (!OperatingSystemDisplayNames)
367  goto Reboot;
368 
369  for (i = 0; i < OperatingSystemCount; i++)
370  {
371  OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier;
372  }
373 
374  /* Find all the message box settings and run them */
375  UiShowMessageBoxesInSection(SectionId);
376 
377  for (;;)
378  {
379  /* Redraw the backdrop */
380  UiDrawBackdrop();
381 
382  /* Show the operating system list menu */
383  if (!UiDisplayMenu("Please select the operating system to start:",
384  "For troubleshooting and advanced startup options for "
385  "ReactOS, press F8.",
386  TRUE,
387  OperatingSystemDisplayNames,
388  OperatingSystemCount,
389  DefaultOperatingSystem,
390  TimeOut,
391  &SelectedOperatingSystem,
392  FALSE,
394  OperatingSystemList))
395  {
396  UiMessageBox("Press ENTER to reboot.");
397  goto Reboot;
398  }
399 
400  TimeOut = -1;
401 
402  /* Load the chosen operating system */
403  LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
404  }
405 
406 Reboot:
407  UiUnInitialize("Rebooting...");
408  IniCleanup();
409  return;
410 }
static LONG GetTimeOut(IN ULONG_PTR FrLdrSectionId)
Definition: bootmgr.c:254
#define TRUE
Definition: types.h:120
Definition: arc.h:32
BOOLEAN UiInitialize(BOOLEAN ShowGui)
Definition: ui.c:84
#define DebugInit(FrLdrSectionId)
Definition: debug.h:116
ULONG LoadBootDeviceDriver(VOID)
Definition: scsiport.c:1619
BOOLEAN UiDisplayMenu(IN PCSTR MenuHeader, IN PCSTR MenuFooter OPTIONAL, IN BOOLEAN ShowBootOptions, IN PCSTR MenuItemList[], IN ULONG MenuItemCount, IN ULONG DefaultMenuItem, IN LONG MenuTimeOut, OUT PULONG SelectedMenuItem, IN BOOLEAN CanEscape, IN UiMenuKeyPressFilterCallback KeyPressFilter OPTIONAL, IN PVOID Context OPTIONAL)
Definition: ui.c:463
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define MachInitializeBootDevices()
Definition: machine.h:133
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
Definition: bl.h:892
BOOLEAN IniOpenSection(PCSTR SectionName, ULONG_PTR *SectionId)
Definition: inifile.c:25
VOID UiShowMessageBoxesInSection(IN ULONG_PTR SectionId)
Definition: ui.c:357
VOID IniCleanup(VOID)
Definition: inifile.c:235
VOID UiUnInitialize(PCSTR BootText)
Definition: ui.c:205
VOID UiDrawBackdrop(VOID)
Definition: ui.c:214
BOOLEAN IniFileInitialize(VOID)
Definition: ini_init.c:25
unsigned int ULONG
Definition: retypes.h:1
VOID LoadOperatingSystem(IN OperatingSystemItem *OperatingSystem)
Definition: bootmgr.c:178
const char * PCSTR
Definition: typedefs.h:51
OperatingSystemItem * InitOperatingSystemList(IN ULONG_PTR FrLdrSectionId, OUT PULONG OperatingSystemCount, OUT PULONG DefaultOperatingSystem)
Definition: oslist.c:46
BOOLEAN MainBootMenuKeyPressFilter(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: bootmgr.c:276
VOID UiMessageBoxCritical(PCSTR MessageText)
Definition: ui.c:331

Referenced by BootMain().