ReactOS 0.4.15-dev-7958-gcd0bb1a
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 <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.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 HAS_DEPRECATED_OPTIONS
 
#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))
 
#define printf   TuiPrintf
 

Functions

VOID __cdecl BootMain (IN PCCH CmdLine)
 
VOID WarnDeprecated (_In_ PCSTR MsgFmt,...)
 
VOID LoadOperatingSystem (_In_ OperatingSystemItem *OperatingSystem)
 
VOID RunLoader (VOID)
 
VOID FrLdrCheckCpuCompatibility (VOID)
 

Macro Definition Documentation

◆ HAS_DEPRECATED_OPTIONS

#define HAS_DEPRECATED_OPTIONS

Definition at line 25 of file freeldr.h.

◆ printf

#define printf   TuiPrintf

Definition at line 97 of file freeldr.h.

◆ ROUND_DOWN

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

Definition at line 30 of file freeldr.h.

◆ ROUND_UP

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

Definition at line 33 of file freeldr.h.

◆ RVA

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

Definition at line 28 of file freeldr.h.

◆ UINT64_C

#define UINT64_C (   val)    val##ULL

Definition at line 27 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#ifndef UEFIBOOT
55 /* Check if the CPU is new enough */
56 FrLdrCheckCpuCompatibility(); // FIXME: Should be done inside MachInit!
57#endif
58
59 /* UI pre-initialization */
60 if (!UiInitialize(FALSE))
61 {
62 UiMessageBoxCritical("Unable to initialize UI.");
63 goto Quit;
64 }
65
66 /* Initialize memory manager */
68 {
69 UiMessageBoxCritical("Unable to initialize memory manager.");
70 goto Quit;
71 }
72
73 /* Initialize I/O subsystem */
74 FsInit();
75
76 RunLoader();
77
78Quit:
79 /* If we reach this point, something went wrong before, therefore reboot */
80 Reboot();
81}
@ Reboot
Definition: bl.h:891
#define DebugInit(FrLdrSectionId)
Definition: debug.h:117
VOID FsInit(VOID)
Definition: fs.c:432
BOOLEAN MmInitializeMemoryManager(VOID)
Definition: meminit.c:315
VOID UiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: ui.c:372
BOOLEAN UiInitialize(BOOLEAN ShowUi)
Definition: ui.c:92
VOID CmdLineParse(IN PCSTR CmdLine)
Definition: cmdline.c:29
#define FALSE
Definition: types.h:117
static const WCHAR CmdLine[]
Definition: install.c:48
VOID RunLoader(VOID)
Definition: bootmgr.c:371
VOID FrLdrCheckCpuCompatibility(VOID)
Definition: macharm.c:65
VOID MachInit(IN PCCH CommandLine)
Definition: macharm.c:182
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by ArmInit(), and RealEntryPoint().

◆ FrLdrCheckCpuCompatibility()

VOID FrLdrCheckCpuCompatibility ( VOID  )

Definition at line 65 of file macharm.c.

66{
67 /* Nothing for now */
68}

Referenced by BootMain().

◆ LoadOperatingSystem()

VOID LoadOperatingSystem ( _In_ OperatingSystemItem OperatingSystem)

Definition at line 278 of file bootmgr.c.

280{
281 ULONG_PTR SectionId = OperatingSystem->SectionId;
282 const OS_LOADING_METHOD* OSLoadingMethod;
283 ULONG Argc;
284 PCHAR* Argv;
285
286 /* Find the suitable OS loader to start */
287 OSLoadingMethod = GetOSLoadingMethod(SectionId);
288 if (!OSLoadingMethod)
289 return;
290 ASSERT(OSLoadingMethod->OsLoader);
291
292 /* Build the ARC-compatible argument vector */
293 Argv = BuildArgvForOsLoader(OperatingSystem->LoadIdentifier, SectionId, &Argc);
294 if (!Argv)
295 return; // Unexpected failure.
296
297#ifdef _M_IX86
298#ifndef UEFIBOOT
299 /* Install the drive mapper according to this section drive mappings */
300 DriveMapMapDrivesInSection(SectionId);
301#endif
302#endif
303
304 /* Start the OS loader */
305 OSLoadingMethod->OsLoader(Argc, Argv, NULL);
307}
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: mm.h:181
#define NULL
Definition: types.h:112
static PCHAR * BuildArgvForOsLoader(_In_ PCSTR LoadIdentifier, _In_ ULONG_PTR SectionId, _Out_ PULONG pArgc)
This function converts the list of Key=Value options in the given operating system section into an AR...
Definition: bootmgr.c:170
static const OS_LOADING_METHOD * GetOSLoadingMethod(_In_ ULONG_PTR SectionId)
Definition: bootmgr.c:104
#define ASSERT(a)
Definition: mode.c:44
#define TAG_STRING
Definition: oslist.h:22
ARC_ENTRY_POINT OsLoader
Definition: bootmgr.c:51
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51

Referenced by RunLoader().

◆ RunLoader()

VOID RunLoader ( VOID  )

Definition at line 371 of file bootmgr.c.

372{
373 ULONG_PTR SectionId;
374 LONG TimeOut;
375 ULONG OperatingSystemCount;
376 OperatingSystemItem* OperatingSystemList;
377 PCSTR* OperatingSystemDisplayNames;
378 ULONG DefaultOperatingSystem;
379 ULONG SelectedOperatingSystem;
380 ULONG i;
381
383 {
384 UiMessageBoxCritical("Error when detecting hardware.");
385 return;
386 }
387
388#ifdef _M_IX86
389#ifndef UEFIBOOT
390 /* Load additional SCSI driver (if any) */
392 {
393 UiMessageBoxCritical("Unable to load additional boot device drivers.");
394 }
395#endif
396#endif
397
398 if (!IniFileInitialize())
399 {
400 UiMessageBoxCritical("Error initializing .ini file.");
401 return;
402 }
403
404 /* Open the [FreeLoader] section */
405 if (!IniOpenSection("FreeLoader", &SectionId))
406 {
407 UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
408 return;
409 }
410
411 /* Debugger main initialization */
412 DebugInit(SectionId);
413
414 /* Retrieve the default timeout */
415 TimeOut = GetTimeOut(SectionId);
416
417 /* UI main initialization */
418 if (!UiInitialize(TRUE))
419 {
420 UiMessageBoxCritical("Unable to initialize UI.");
421 return;
422 }
423
424 OperatingSystemList = InitOperatingSystemList(SectionId,
425 &OperatingSystemCount,
426 &DefaultOperatingSystem);
427 if (!OperatingSystemList)
428 {
429 UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
430 goto Reboot;
431 }
432 if (OperatingSystemCount == 0)
433 {
434 UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
435 goto Reboot;
436 }
437
438 /* Create list of display names */
439 OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
440 if (!OperatingSystemDisplayNames)
441 goto Reboot;
442
443 for (i = 0; i < OperatingSystemCount; i++)
444 {
445 OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier;
446 }
447
448 /* Find all the message box settings and run them */
450
451 for (;;)
452 {
453 /* Redraw the backdrop */
455
456 /* Show the operating system list menu */
457 if (!UiDisplayMenu("Please select the operating system to start:",
458 "For troubleshooting and advanced startup options for "
459 "ReactOS, press F8.",
460 TRUE,
461 OperatingSystemDisplayNames,
462 OperatingSystemCount,
463 DefaultOperatingSystem,
464 TimeOut,
465 &SelectedOperatingSystem,
466 FALSE,
468 OperatingSystemList))
469 {
470 UiMessageBox("Press ENTER to reboot.");
471 goto Reboot;
472 }
473
474 TimeOut = -1;
475
476 /* Load the chosen operating system */
477 LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
478
479 /* If we get there, the OS loader failed. As it may have
480 * messed up the display, re-initialize the UI. */
481#ifndef _M_ARM
483#endif
485 }
486
487Reboot:
488 UiUnInitialize("Rebooting...");
489 IniCleanup();
490 return;
491}
ULONG LoadBootDeviceDriver(VOID)
Definition: scsiport.c:1635
#define MachInitializeBootDevices()
Definition: machine.h:133
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
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:605
VOID UiShowMessageBoxesInSection(IN ULONG_PTR SectionId)
Definition: ui.c:524
UIVTBL UiVtbl
Definition: ui.c:64
VOID UiUnInitialize(PCSTR BootText)
Definition: ui.c:224
VOID UiDrawBackdrop(VOID)
Definition: ui.c:233
VOID UiMessageBox(_In_ PCSTR Format,...)
Definition: ui.c:359
#define TRUE
Definition: types.h:120
VOID LoadOperatingSystem(_In_ OperatingSystemItem *OperatingSystem)
Definition: bootmgr.c:278
BOOLEAN MainBootMenuKeyPressFilter(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: bootmgr.c:348
static LONG GetTimeOut(IN ULONG_PTR FrLdrSectionId)
Definition: bootmgr.c:326
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
BOOLEAN IniFileInitialize(VOID)
Definition: ini_init.c:25
BOOLEAN IniOpenSection(PCSTR SectionName, ULONG_PTR *SectionId)
Definition: inifile.c:25
VOID IniCleanup(VOID)
Definition: inifile.c:238
OperatingSystemItem * InitOperatingSystemList(IN ULONG_PTR FrLdrSectionId, OUT PULONG OperatingSystemCount, OUT PULONG DefaultOperatingSystem)
Definition: oslist.c:46
long LONG
Definition: pedump.c:60
@ ESUCCESS
Definition: arc.h:32
VOID(* UnInitialize)(VOID)
Definition: ui.h:251
const char * PCSTR
Definition: typedefs.h:52

Referenced by BootMain(), and ExecuteLoaderCleanly().

◆ WarnDeprecated()

VOID WarnDeprecated ( _In_ PCSTR  MsgFmt,
  ... 
)

Referenced by GetOSLoadingMethod().