ReactOS 0.4.16-dev-112-g52265ae
uefildr.c
Go to the documentation of this file.
1/*
2 * PROJECT: FreeLoader UEFI Support
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Entry point and helpers
5 * COPYRIGHT: Copyright 2022 Justin Miller <justinmiller100@gmail.com>
6 */
7
8#include <uefildr.h>
9
10#include <debug.h>
12
13/* GLOBALS ********************************************************************/
14
19
21
22/* FUNCTIONS ******************************************************************/
23
26 _In_ EFI_HANDLE ImageHandle,
27 _In_ EFI_SYSTEM_TABLE *SystemTable)
28{
29 PCSTR CmdLine = ""; // FIXME: Determine a command-line from UEFI boot options
30
31 SystemTable->ConOut->OutputString(SystemTable->ConOut, L"UEFI EntryPoint: Starting freeldr from UEFI");
32 GlobalImageHandle = ImageHandle;
33 GlobalSystemTable = SystemTable;
34
35 /* Load the default settings from the command-line */
37
38 /* Debugger pre-initialization */
40
42
43 /* UI pre-initialization */
44 if (!UiInitialize(FALSE))
45 {
46 UiMessageBoxCritical("Unable to initialize UI.");
47 goto Quit;
48 }
49
50 /* Initialize memory manager */
52 {
53 UiMessageBoxCritical("Unable to initialize memory manager.");
54 goto Quit;
55 }
56
57 /* Initialize I/O subsystem */
58 FsInit();
59
60 /* 0x32000 is what UEFI defines, but we can go smaller if we want */
63
64Quit:
65 /* If we reach this point, something went wrong before, therefore reboot */
66 Reboot();
67
69 return 0;
70}
71
72void
74{
75 TRACE("ExecuteLoaderCleanly Entry\n");
76 UefiServiceStack = PreviousStack;
77
78 RunLoader();
80}
81
82#ifndef _M_ARM
84{
85 //TODO: Replace with a true firmware reboot eventually
86 WARN("Something has gone wrong - halting FreeLoader\n");
87 for (;;)
88 {
89 NOTHING;
90 }
91}
92#endif
#define WARNING
Definition: BusLogic958.h:56
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
#define __cdecl
Definition: accygwin.h:79
void LoadSettings(void)
Definition: settings.c:53
#define WARN(fmt,...)
Definition: precomp.h:61
@ Reboot
Definition: bl.h:891
#define DebugInit(DebugString)
Definition: debug.h:120
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
VOID FsInit(VOID)
Definition: fs.c:492
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
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
#define ULONG_PTR
Definition: config.h:101
VOID RunLoader(VOID)
Definition: bootmgr.c:356
#define NOTHING
Definition: input_list.c:10
VOID MachInit(IN PCCH CommandLine)
Definition: macharm.c:182
#define _In_
Definition: ms_sal.h:308
#define UNREACHABLE
#define L(x)
Definition: ntvdm.h:50
@ LoaderOsloaderStack
Definition: arc.h:182
#define TRACE(s)
Definition: solgame.cpp:4
PCSTR DebugString
Definition: settings.h:12
void * PVOID
Definition: typedefs.h:50
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG_PTR
Definition: typedefs.h:65
EFI_STATUS EfiEntry(_In_ EFI_HANDLE ImageHandle, _In_ EFI_SYSTEM_TABLE *SystemTable)
Definition: uefildr.c:25
void _changestack(VOID)
void ExecuteLoaderCleanly(PVOID PreviousStack)
Definition: uefildr.c:73
PVOID BasicStack
Definition: uefildr.c:18
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
EFI_HANDLE GlobalImageHandle
Definition: uefildr.c:15
PVOID UefiServiceStack
Definition: uefildr.c:17