ReactOS 0.4.15-dev-8434-g155a7c7
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 43 of file freeldr.c.

44{
45 /* Load the default settings from the command-line */
47
48 /* Debugger pre-initialization */
50
52
53 TRACE("BootMain() called.\n");
54
55#ifndef UEFIBOOT
56 /* Check if the CPU is new enough */
57 FrLdrCheckCpuCompatibility(); // FIXME: Should be done inside MachInit!
58#endif
59
60 /* UI pre-initialization */
61 if (!UiInitialize(FALSE))
62 {
63 UiMessageBoxCritical("Unable to initialize UI.");
64 goto Quit;
65 }
66
67 /* Initialize memory manager */
69 {
70 UiMessageBoxCritical("Unable to initialize memory manager.");
71 goto Quit;
72 }
73
74 /* Initialize I/O subsystem */
75 FsInit();
76
77 RunLoader();
78
79Quit:
80 /* If we reach this point, something went wrong before, therefore reboot */
81 Reboot();
82}
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:432
BOOLEAN MmInitializeMemoryManager(VOID)
Definition: meminit.c:315
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
VOID RunLoader(VOID)
Definition: bootmgr.c:356
VOID FrLdrCheckCpuCompatibility(VOID)
Definition: macharm.c:65
VOID MachInit(IN PCCH CommandLine)
Definition: macharm.c:182
#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 282 of file bootmgr.c.

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

357{
358 OperatingSystemItem* OperatingSystemList;
359 PCSTR* OperatingSystemDisplayNames;
360 ULONG OperatingSystemCount;
361 ULONG DefaultOperatingSystem;
362 ULONG SelectedOperatingSystem;
363 ULONG i;
364
366 {
367 UiMessageBoxCritical("Error when detecting hardware.");
368 return;
369 }
370
371#ifdef _M_IX86
372#ifndef UEFIBOOT
373 /* Load additional SCSI driver (if any) */
375 {
376 UiMessageBoxCritical("Unable to load additional boot device drivers.");
377 }
378#endif
379#endif
380
381 /* Open FREELDR.INI and load the global FreeLoader settings */
382 if (!IniFileInitialize())
383 {
384 UiMessageBoxCritical("Error initializing .ini file.");
385 return;
386 }
388#if 0
389 if (FALSE)
390 {
391 UiMessageBoxCritical("Could not load global FreeLoader settings.");
392 return;
393 }
394#endif
395
396 /* Debugger main initialization */
398
399 /* UI main initialization */
400 if (!UiInitialize(TRUE))
401 {
402 UiMessageBoxCritical("Unable to initialize UI.");
403 return;
404 }
405
406 OperatingSystemList = InitOperatingSystemList(&OperatingSystemCount,
407 &DefaultOperatingSystem);
408 if (!OperatingSystemList)
409 {
410 UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
411 goto Reboot;
412 }
413 if (OperatingSystemCount == 0)
414 {
415 UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
416 goto Reboot;
417 }
418
419 /* Create list of display names */
420 OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
421 if (!OperatingSystemDisplayNames)
422 goto Reboot;
423
424 for (i = 0; i < OperatingSystemCount; i++)
425 {
426 OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier;
427 }
428
429 /* Find all the message box settings and run them */
431
432 for (;;)
433 {
434 /* Redraw the backdrop */
436
437 /* Show the operating system list menu */
438 if (!UiDisplayMenu("Please select the operating system to start:",
439 "For troubleshooting and advanced startup options for "
440 "ReactOS, press F8.",
441 TRUE,
442 OperatingSystemDisplayNames,
443 OperatingSystemCount,
444 DefaultOperatingSystem,
446 &SelectedOperatingSystem,
447 FALSE,
449 OperatingSystemList))
450 {
451 UiMessageBox("Press ENTER to reboot.");
452 goto Reboot;
453 }
454
455 /* Load the chosen operating system */
456 LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
457
458 BootMgrInfo.TimeOut = -1;
459
460 /* If we get there, the OS loader failed. As it may have
461 * messed up the display, re-initialize the UI. */
462#ifndef _M_ARM
464#endif
466 }
467
468Reboot:
469 UiUnInitialize("Rebooting...");
470 IniCleanup();
471 return;
472}
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:282
BOOLEAN MainBootMenuKeyPressFilter(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: bootmgr.c:330
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:238
OperatingSystemItem * InitOperatingSystemList(_Out_ PULONG OperatingSystemCount, _Out_ PULONG DefaultOperatingSystem)
Definition: oslist.c:46
@ ESUCCESS
Definition: arc.h:32
LONG TimeOut
Definition: settings.h:14
ULONG_PTR FrLdrSection
Definition: settings.h:15
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().