ReactOS 0.4.16-dev-2610-ge2c92c0
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/ext.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 FLDRAPI   DECLSPEC_IMPORT
 
#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

◆ FLDRAPI

#define FLDRAPI   DECLSPEC_IMPORT

Definition at line 28 of file freeldr.h.

◆ HAS_DEPRECATED_OPTIONS

#define HAS_DEPRECATED_OPTIONS

Definition at line 25 of file freeldr.h.

◆ printf

#define printf   TuiPrintf

Definition at line 103 of file freeldr.h.

◆ ROUND_DOWN

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

Definition at line 37 of file freeldr.h.

◆ ROUND_UP

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

Definition at line 40 of file freeldr.h.

◆ RVA

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

Definition at line 35 of file freeldr.h.

◆ UINT64_C

#define UINT64_C (   val)    val##ULL

Definition at line 34 of file freeldr.h.

Function Documentation

◆ BootMain()

VOID __cdecl BootMain ( IN PCCH  CmdLine)

Definition at line 92 of file freeldr.c.

93{
94 /* Load the default settings from the command-line */
96
97 /* Debugger pre-initialization */
99
101
102 TRACE("BootMain() called.\n");
103
104#ifndef UEFIBOOT
105 /* Check if the CPU is new enough */
106 FrLdrCheckCpuCompatibility(); // FIXME: Should be done inside MachInit!
107#endif
108
109 /* UI pre-initialization */
110 if (!UiInitialize(FALSE))
111 {
112 UiMessageBoxCritical("Unable to initialize UI.");
113 goto Quit;
114 }
115
116 /* Initialize memory manager */
118 {
119 UiMessageBoxCritical("Unable to initialize memory manager.");
120 goto Quit;
121 }
122
123 /* Initialize I/O subsystem */
124 FsInit();
125
126 /* Initialize the module list */
128 {
129 UiMessageBoxCritical("Unable to initialize module list.");
130 goto Quit;
131 }
132
134 {
135 UiMessageBoxCritical("Error when detecting hardware.");
136 goto Quit;
137 }
138
139 /* Launch second stage loader */
141 {
142 UiMessageBoxCritical("Unable to load second stage loader.");
143 }
144
145Quit:
146 /* If we reach this point, something went wrong before, therefore reboot */
147 Reboot();
148}
void LoadSettings(void)
Definition: settings.c:53
#define DebugInit(DebugString)
Definition: debug.h:120
VOID FsInit(VOID)
Definition: fs.c:725
#define MachInitializeBootDevices()
Definition: machine.h:127
BOOLEAN MmInitializeMemoryManager(VOID)
Definition: meminit.c:336
BOOTMGRINFO BootMgrInfo
Definition: settings.c:19
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
DECLSPEC_NORETURN VOID __cdecl Reboot(VOID)
Definition: uefildr.c:99

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

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

387{
388 OperatingSystemItem* OperatingSystemList;
389 PCSTR* OperatingSystemDisplayNames;
390 ULONG OperatingSystemCount;
391 ULONG SelectedOperatingSystem;
392 ULONG i;
393
394#ifdef _M_IX86
395#ifndef UEFIBOOT
396 /* Load additional SCSI driver (if any) */
398 UiMessageBoxCritical("Unable to load additional boot device drivers.");
399#endif
400#endif
401
402 /* Open FREELDR.INI and load the global FreeLoader settings */
403 if (!IniFileInitialize())
404 UiMessageBoxCritical("Error initializing .ini file.");
406#if 0
407 if (FALSE)
408 UiMessageBoxCritical("Could not load global FreeLoader settings.");
409#endif
410
411 /* Debugger main initialization */
413
414 /* UI main initialization. If it fails, fall back to default UI. */
415 if (!UiInitialize(TRUE))
416 UiMessageBoxCritical("Unable to initialize UI.");
417
418 /* If no FREELDR.INI, skip everything else and fall back to the FreeLdr setup menu */
420 goto Fallback;
421
422 /* Find all the message box settings and run them */
424
425 /* Retrieve the list of boot entries */
426 OperatingSystemList = InitOperatingSystemList(&OperatingSystemCount,
427 &SelectedOperatingSystem);
428 if (!OperatingSystemList)
429 {
430 UiMessageBox("There are no operating systems listed in freeldr.ini.");
431 goto Fallback;
432 }
433 ASSERT(OperatingSystemCount != 0);
434
435 /* Create list of display names */
436 OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
437 if (!OperatingSystemDisplayNames)
438 goto Fallback;
439
440 for (i = 0; i < OperatingSystemCount; i++)
441 {
442 OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier;
443 }
444
445 for (;;)
446 {
447 /* Redraw the backdrop, but don't overwrite boot options */
449 DisplayBootTimeOptions(&OperatingSystemList[SelectedOperatingSystem]);
450
451 /* Show the operating system list menu */
452 if (!UiDisplayMenu("Please select the operating system to start:",
453 /* The string is 80 characters long; don't make it longer! */
454 "Press F8 for troubleshooting and advanced startup options."
455 " F2: FreeLdr SETUP",
456 OperatingSystemDisplayNames,
457 OperatingSystemCount,
458 SelectedOperatingSystem,
459 GetBootMgrInfo()->TimeOut,
460 &SelectedOperatingSystem,
461 FALSE,
463 OperatingSystemList))
464 {
465 UiMessageBox("Press ENTER to reboot.");
466 goto Reboot;
467 }
468
469 /* Load the chosen operating system */
470 LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
471
472 GetBootMgrInfo()->TimeOut = -1;
473
474 /* If we get there, the OS loader failed. As it may have
475 * messed up the display, re-initialize the UI. */
476#ifndef _M_ARM
477 UiUnInitialize("");
478#endif
480 }
481
483 /* Fall back to the FreeLdr setup menu */
485 UiMessageBox("The system will now reboot.");
486
487Reboot:
488 UiUnInitialize("Rebooting...");
489 IniCleanup();
490 return;
491}
xD9 x84 xD8 xAD xD9 x80 xF0 x90 xAC x9A xE0 xA7 xA6 xE0 xA7 xAA xF0 x91 x84 xA4 xF0 x91 x84 x89 xF0 x91 x84 x9B xF0 x90 x8A xAB xF0 x90 x8B x89 xE2 xB2 x9E xE2 xB2 x9F xD0 xBE xD0 x9E xF0 x90 x90 x84 xF0 x90 x90 xAC xE1 x83 x98 xE1 x83 x94 xE1 x83 x90 xE1 xB2 xBF xE2 xB0 x95 xE2 xB1 x85 xCE xBF xCE x9F xE0 xA8 xA0 xE0 xA8 xB0 xE0 xA9 xA6 Kayah xEA xA4 x8D xEA xA4 x80 Khmer xE1 xA7 xA1 xE1 xA7 xAA xE0 xBB x90 Latin Subscript Fallback
Definition: afscript.h:223
ULONG LoadBootDeviceDriver(VOID)
Definition: scsiport.c:1656
PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: heap.c:545
VOID FreeLdrSetupMenu(_In_opt_ OperatingSystemItem *OperatingSystem)
Definition: options.c:53
VOID DisplayBootTimeOptions(_In_ OperatingSystemItem *OperatingSystem)
Definition: options.c:115
PBOOTMGRINFO GetBootMgrInfo(VOID)
Definition: settings.c:214
VOID UiShowMessageBoxesInSection(IN ULONG_PTR SectionId)
Definition: ui.c:524
VOID UiDrawBackdrop(ULONG DrawHeight)
Definition: ui.c:233
ULONG UiGetScreenHeight(VOID)
Definition: ui.c:655
VOID UiUnInitialize(PCSTR BootText)
Definition: ui.c:224
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
VOID LoadOperatingSystem(_In_ OperatingSystemItem *OperatingSystem)
Definition: bootmgr.c:287
BOOLEAN MainBootMenuKeyPressFilter(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: bootmgr.c:335
#define TRUE
Definition: types.h:120
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
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
PLIST_ENTRY IniGetFileSectionListHead(VOID)
Definition: inifile.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:15
const char * PCSTR
Definition: typedefs.h:52

Referenced by ExecuteLoaderCleanly().

◆ WarnDeprecated()

VOID WarnDeprecated ( _In_ PCSTR  MsgFmt,
  ... 
)

Referenced by GetOSLoadingMethod().