ReactOS 0.4.15-dev-7934-g1dc8d80
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 SystemTable->ConOut->OutputString(SystemTable->ConOut, L"UEFI EntryPoint: Starting freeldr from UEFI");
30 GlobalImageHandle = ImageHandle;
31 GlobalSystemTable = SystemTable;
32
33 /* Needed for default settings */
34 CmdLineParse("");
35
36 /* Debugger pre-initialization */
37 DebugInit(0);
38
39 MachInit("");
40
41 /* UI pre-initialization */
42 if (!UiInitialize(FALSE))
43 {
44 UiMessageBoxCritical("Unable to initialize UI.");
45 goto Quit;
46 }
47
48 /* Initialize memory manager */
50 {
51 UiMessageBoxCritical("Unable to initialize memory manager.");
52 goto Quit;
53 }
54
55 /* Initialize I/O subsystem */
56 FsInit();
57
58 /* 0x32000 is what UEFI defines, but we can go smaller if we want */
61
62Quit:
63 /* If we reach this point, something went wrong before, therefore reboot */
64 Reboot();
65
67 return 0;
68}
69
70void
72{
73 TRACE("ExecuteLoaderCleanly Entry\n");
74 UefiServiceStack = PreviousStack;
75
76 RunLoader();
78}
79
80#ifndef _M_ARM
82{
83 //TODO: Replace with a true firmware reboot eventually
84 WARN("Something has gone wrong - halting FreeLoader\n");
85 for (;;)
86 {
87 NOTHING;
88 }
89}
90#endif
#define WARNING
Definition: BusLogic958.h:56
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
#define __cdecl
Definition: accygwin.h:79
@ Reboot
Definition: bl.h:891
#define DebugInit(FrLdrSectionId)
Definition: debug.h:117
#define WARN(fmt,...)
Definition: debug.h:112
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:103
VOID FsInit(VOID)
Definition: fs.c:432
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
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
#define ULONG_PTR
Definition: config.h:101
VOID RunLoader(VOID)
Definition: bootmgr.c:371
#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
void * PVOID
Definition: typedefs.h:50
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:71
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