ReactOS 0.4.16-dev-747-gbc52d5f
freeldr.h File Reference
#include <ntsup.h>
#include <arcname.h>
#include <arcsupp.h>
#include <bytesex.h>
#include <cache.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 <settings.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 91 of file freeldr.c.

92{
93 /* Load the default settings from the command-line */
95
96 /* Debugger pre-initialization */
98
100
101 TRACE("BootMain() called.\n");
102
103#ifndef UEFIBOOT
104 /* Check if the CPU is new enough */
105 FrLdrCheckCpuCompatibility(); // FIXME: Should be done inside MachInit!
106#endif
107
108 /* UI pre-initialization */
109 if (!UiInitialize(FALSE))
110 {
111 UiMessageBoxCritical("Unable to initialize UI.");
112 goto Quit;
113 }
114
115 /* Initialize memory manager */
117 {
118 UiMessageBoxCritical("Unable to initialize memory manager.");
119 goto Quit;
120 }
121
122 /* Initialize I/O subsystem */
123 FsInit();
124
125 /* Initialize the module list */
127 {
128 UiMessageBoxCritical("Unable to initialize module list.");
129 goto Quit;
130 }
131
133 {
134 UiMessageBoxCritical("Error when detecting hardware.");
135 goto Quit;
136 }
137
138 /* Launch second stage loader */
140 {
141 UiMessageBoxCritical("Unable to load second stage loader.");
142 }
143
144Quit:
145 /* If we reach this point, something went wrong before, therefore reboot */
146 Reboot();
147}
void LoadSettings(void)
Definition: settings.c:53
@ Reboot
Definition: bl.h:891
#define DebugInit(DebugString)
Definition: debug.h:120
VOID FsInit(VOID)
Definition: fs.c:646
#define MachInitializeBootDevices()
Definition: machine.h:127
BOOLEAN MmInitializeMemoryManager(VOID)
Definition: meminit.c:336
BOOTMGRINFO BootMgrInfo
Definition: settings.c:18
VOID UiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: ui.c:372
BOOLEAN UiInitialize(BOOLEAN ShowUi)
Definition: ui.c:92
#define FALSE
Definition: types.h:117
static const WCHAR CmdLine[]
Definition: install.c:48
static ULONG LaunchSecondStageLoader(VOID)
Definition: freeldr.c:69
VOID FrLdrCheckCpuCompatibility(VOID)
Definition: macharm.c:65
VOID MachInit(IN PCCH CommandLine)
Definition: macharm.c:182
BOOLEAN PeLdrInitializeModuleList(VOID)
Definition: peloader.c:525
@ ESUCCESS
Definition: arc.h:32
#define TRACE(s)
Definition: solgame.cpp:4
PCSTR DebugString
Definition: settings.h:12

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 283 of file bootmgr.c.

285{
286 ULONG_PTR SectionId = OperatingSystem->SectionId;
287 const OS_LOADING_METHOD* OSLoadingMethod;
288 ULONG Argc;
289 PCHAR* Argv;
290
291 /* Find the suitable OS loader to start */
292 OSLoadingMethod = GetOSLoadingMethod(SectionId);
293 if (!OSLoadingMethod)
294 return;
295 ASSERT(OSLoadingMethod->OsLoader);
296
297 /* Build the ARC-compatible argument vector */
298 Argv = BuildArgvForOsLoader(OperatingSystem->LoadIdentifier, SectionId, &Argc);
299 if (!Argv)
300 return; // Unexpected failure.
301
302#ifdef _M_IX86
303#ifndef UEFIBOOT
304 /* Install the drive mapper according to this section drive mappings */
305 DriveMapMapDrivesInSection(SectionId);
306#endif
307#endif
308
309 /* Start the OS loader */
310 OSLoadingMethod->OsLoader(Argc, Argv, NULL);
312}
VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: heap.c:539
#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:174
static const OS_LOADING_METHOD * GetOSLoadingMethod(_In_ ULONG_PTR SectionId)
Definition: bootmgr.c:108
#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 358 of file bootmgr.c.

359{
360 OperatingSystemItem* OperatingSystemList;
361 PCSTR* OperatingSystemDisplayNames;
362 ULONG OperatingSystemCount;
363 ULONG DefaultOperatingSystem;
364 ULONG SelectedOperatingSystem;
365 ULONG i;
366
367#ifdef _M_IX86
368#ifndef UEFIBOOT
369 /* Load additional SCSI driver (if any) */
371 {
372 UiMessageBoxCritical("Unable to load additional boot device drivers.");
373 }
374#endif
375#endif
376
377 /* Open FREELDR.INI and load the global FreeLoader settings */
378 if (!IniFileInitialize())
379 {
380 UiMessageBoxCritical("Error initializing .ini file.");
381 return;
382 }
384#if 0
385 if (FALSE)
386 {
387 UiMessageBoxCritical("Could not load global FreeLoader settings.");
388 return;
389 }
390#endif
391
392 /* Debugger main initialization */
394
395 /* UI main initialization */
396 if (!UiInitialize(TRUE))
397 {
398 UiMessageBoxCritical("Unable to initialize UI.");
399 return;
400 }
401
402 OperatingSystemList = InitOperatingSystemList(&OperatingSystemCount,
403 &DefaultOperatingSystem);
404 if (!OperatingSystemList)
405 {
406 UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
407 goto Reboot;
408 }
409 if (OperatingSystemCount == 0)
410 {
411 UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
412 goto Reboot;
413 }
414
415 /* Create list of display names */
416 OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
417 if (!OperatingSystemDisplayNames)
418 goto Reboot;
419
420 for (i = 0; i < OperatingSystemCount; i++)
421 {
422 OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier;
423 }
424
425 /* Find all the message box settings and run them */
427
428 for (;;)
429 {
430 /* Redraw the backdrop */
432
433 /* Show the operating system list menu */
434 if (!UiDisplayMenu("Please select the operating system to start:",
435 "For troubleshooting and advanced startup options for "
436 "ReactOS, press F8.",
437 OperatingSystemDisplayNames,
438 OperatingSystemCount,
439 DefaultOperatingSystem,
440 GetBootMgrInfo()->TimeOut,
441 &SelectedOperatingSystem,
442 FALSE,
444 OperatingSystemList))
445 {
446 UiMessageBox("Press ENTER to reboot.");
447 goto Reboot;
448 }
449
450 /* Load the chosen operating system */
451 LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
452
453 GetBootMgrInfo()->TimeOut = -1;
454
455 /* If we get there, the OS loader failed. As it may have
456 * messed up the display, re-initialize the UI. */
457#ifndef _M_ARM
458 UiUnInitialize("");
459#endif
461 }
462
463Reboot:
464 UiUnInitialize("Rebooting...");
465 IniCleanup();
466 return;
467}
ULONG LoadBootDeviceDriver(VOID)
Definition: scsiport.c:1635
PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: heap.c:545
PBOOTMGRINFO GetBootMgrInfo(VOID)
Definition: settings.c:191
VOID UiShowMessageBoxesInSection(IN ULONG_PTR SectionId)
Definition: ui.c:524
VOID UiUnInitialize(PCSTR BootText)
Definition: ui.c:224
VOID UiDrawBackdrop(VOID)
Definition: ui.c:233
BOOLEAN UiDisplayMenu(IN PCSTR MenuHeader, IN PCSTR MenuFooter OPTIONAL, 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 UiMessageBox(_In_ PCSTR Format,...)
Definition: ui.c:359
static CCHAR DebugString[256]
Definition: settings.c:16
#define TRUE
Definition: types.h:120
VOID LoadOperatingSystem(_In_ OperatingSystemItem *OperatingSystem)
Definition: bootmgr.c:283
BOOLEAN MainBootMenuKeyPressFilter(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: bootmgr.c:331
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
VOID IniCleanup(VOID)
Definition: inifile.c:243
OperatingSystemItem * InitOperatingSystemList(_Out_ PULONG OperatingSystemCount, _Out_ PULONG DefaultOperatingSystem)
Definition: oslist.c:46
LONG TimeOut
Definition: settings.h:14
const char * PCSTR
Definition: typedefs.h:52

Referenced by ExecuteLoaderCleanly().

◆ WarnDeprecated()

VOID WarnDeprecated ( _In_ PCSTR  MsgFmt,
  ... 
)

Referenced by GetOSLoadingMethod().