ReactOS 0.4.15-dev-7907-g95bf896
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 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 LoadOperatingSystem (_In_ OperatingSystemItem *OperatingSystem)
 
VOID RunLoader (VOID)
 
VOID FrLdrCheckCpuCompatibility (VOID)
 

Macro Definition Documentation

◆ printf

#define printf   TuiPrintf

Definition at line 93 of file freeldr.h.

◆ 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#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:303
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 210 of file bootmgr.c.

212{
213 ULONG_PTR SectionId = OperatingSystem->SectionId;
214 const OS_LOADING_METHOD* OSLoadingMethod;
215 ULONG Argc;
216 PCHAR* Argv;
217
218 /* Find the suitable OS loader to start */
219 OSLoadingMethod = GetOSLoadingMethod(SectionId);
220 if (!OSLoadingMethod)
221 return;
222 ASSERT(OSLoadingMethod->OsLoader);
223
224 /* Build the ARC-compatible argument vector */
225 Argv = BuildArgvForOsLoader(OperatingSystem->LoadIdentifier, SectionId, &Argc);
226 if (!Argv)
227 return; // Unexpected failure.
228
229#ifdef _M_IX86
230#ifndef UEFIBOOT
231 /* Install the drive mapper according to this section drive mappings */
232 DriveMapMapDrivesInSection(SectionId);
233#endif
234#endif
235
236 /* Start the OS loader */
237 OSLoadingMethod->OsLoader(Argc, Argv, NULL);
239}
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)
Definition: bootmgr.c:110
static const OS_LOADING_METHOD * GetOSLoadingMethod(_In_ ULONG_PTR SectionId)
Definition: bootmgr.c:77
#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 303 of file bootmgr.c.

304{
305 ULONG_PTR SectionId;
306 LONG TimeOut;
307 ULONG OperatingSystemCount;
308 OperatingSystemItem* OperatingSystemList;
309 PCSTR* OperatingSystemDisplayNames;
310 ULONG DefaultOperatingSystem;
311 ULONG SelectedOperatingSystem;
312 ULONG i;
313
315 {
316 UiMessageBoxCritical("Error when detecting hardware.");
317 return;
318 }
319
320#ifdef _M_IX86
321#ifndef UEFIBOOT
322 /* Load additional SCSI driver (if any) */
324 {
325 UiMessageBoxCritical("Unable to load additional boot device drivers.");
326 }
327#endif
328#endif
329
330 if (!IniFileInitialize())
331 {
332 UiMessageBoxCritical("Error initializing .ini file.");
333 return;
334 }
335
336 /* Open the [FreeLoader] section */
337 if (!IniOpenSection("FreeLoader", &SectionId))
338 {
339 UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
340 return;
341 }
342
343 /* Debugger main initialization */
344 DebugInit(SectionId);
345
346 /* Retrieve the default timeout */
347 TimeOut = GetTimeOut(SectionId);
348
349 /* UI main initialization */
350 if (!UiInitialize(TRUE))
351 {
352 UiMessageBoxCritical("Unable to initialize UI.");
353 return;
354 }
355
356 OperatingSystemList = InitOperatingSystemList(SectionId,
357 &OperatingSystemCount,
358 &DefaultOperatingSystem);
359 if (!OperatingSystemList)
360 {
361 UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
362 goto Reboot;
363 }
364 if (OperatingSystemCount == 0)
365 {
366 UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
367 goto Reboot;
368 }
369
370 /* Create list of display names */
371 OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
372 if (!OperatingSystemDisplayNames)
373 goto Reboot;
374
375 for (i = 0; i < OperatingSystemCount; i++)
376 {
377 OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier;
378 }
379
380 /* Find all the message box settings and run them */
382
383 for (;;)
384 {
385 /* Redraw the backdrop */
387
388 /* Show the operating system list menu */
389 if (!UiDisplayMenu("Please select the operating system to start:",
390 "For troubleshooting and advanced startup options for "
391 "ReactOS, press F8.",
392 TRUE,
393 OperatingSystemDisplayNames,
394 OperatingSystemCount,
395 DefaultOperatingSystem,
396 TimeOut,
397 &SelectedOperatingSystem,
398 FALSE,
400 OperatingSystemList))
401 {
402 UiMessageBox("Press ENTER to reboot.");
403 goto Reboot;
404 }
405
406 TimeOut = -1;
407
408 /* Load the chosen operating system */
409 LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
410
411 /* If we get there, the OS loader failed. As it may have
412 * messed up the display, re-initialize the UI. */
413#ifndef _M_ARM
415#endif
417 }
418
419Reboot:
420 UiUnInitialize("Rebooting...");
421 IniCleanup();
422 return;
423}
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:210
BOOLEAN MainBootMenuKeyPressFilter(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: bootmgr.c:280
static LONG GetTimeOut(IN ULONG_PTR FrLdrSectionId)
Definition: bootmgr.c:258
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().