[BOOTMGFW]
[reactos.git] / reactos / boot / environ / app / bootmgr / efiemu.c
1 /*
2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Manager
4 * FILE: boot/environ/app/efiemu.c
5 * PURPOSE: UEFI Entrypoint for Boot Manager
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include "bootmgr.h"
12
13 /* FUNCTIONS *****************************************************************/
14
15 /*++
16 * @name EfiInitCreateInputParametersEx
17 *
18 * The EfiInitCreateInputParametersEx routine converts UEFI entrypoint
19 * parameters to the ones expected by Windows Boot Applications
20 *
21 * @param ImageHandle
22 * UEFI Image Handle for the current loaded application.
23 *
24 * @param SystemTable
25 * Pointer to the UEFI System Table.
26 *
27 * @return A PBOOT_APPLICATION_PARAMETER_BLOCK structure containing the data
28 * from UEFI, translated to the Boot Library-compatible format.
29 *
30 *--*/
31 PBOOT_APPLICATION_PARAMETER_BLOCK
32 EfiInitCreateInputParametersEx (
33 _In_ EFI_HANDLE ImageHandle,
34 _In_ EFI_SYSTEM_TABLE *SystemTable
35 )
36 {
37 DBG_UNREFERENCED_PARAMETER(ImageHandle);
38 DBG_UNREFERENCED_PARAMETER(SystemTable);
39
40 /* Not yet implemented */
41 return NULL;
42 }
43
44 /*++
45 * @name EfiEntry
46 *
47 * The EfiEntry routine implements the UEFI entrypoint for the application.
48 *
49 * @param ImageHandle
50 * UEFI Image Handle for the current loaded application.
51 *
52 * @param SystemTable
53 * Pointer to the UEFI System Table.
54 *
55 * @return EFI_SUCCESS if the image was loaded correctly, relevant error code
56 * otherwise.
57 *
58 *--*/
59 EFI_STATUS
60 EfiEntry (
61 _In_ EFI_HANDLE ImageHandle,
62 _In_ EFI_SYSTEM_TABLE *SystemTable
63 )
64 {
65 NTSTATUS Status;
66 PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters;
67
68 /* Temporary debugging string */
69 SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"Hello from EFI\n");
70
71 /* Convert EFI parameters to Windows Boot Application parameters */
72 BootParameters = EfiInitCreateInputParametersEx(ImageHandle, SystemTable);
73 if (BootParameters != NULL)
74 {
75 /* Conversion was good -- call the Boot Manager Entrypoint */
76 SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"EFI input OK!\n");
77 Status = BmMain(BootParameters);
78 }
79 else
80 {
81 /* Conversion failed, bail out */
82 SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"EFI input failed\n");
83 Status = STATUS_INVALID_PARAMETER;
84 }
85
86 /* Convert the NT status code to an EFI code */
87 return EfiGetEfiStatusCode(Status);
88 }
89