]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/BootModePei/BootModePei.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / BootModePei / BootModePei.c
1 /** @file
2
3 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2011, Apple Inc. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 //
10 // The package level header files this module uses
11 //
12 #include <PiPei.h>
13
14 #include <Library/PcdLib.h>
15 #include <Library/PeiServicesLib.h>
16
17 //
18 // The protocols, PPI and GUID defintions for this module
19 //
20 #include <Ppi/MasterBootMode.h>
21 #include <Ppi/BootInRecoveryMode.h>
22 //
23 // The Library classes this module consumes
24 //
25 #include <Library/DebugLib.h>
26 #include <Library/PeimEntryPoint.h>
27
28 //
29 // Module globals
30 //
31 EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
32 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
33 &gEfiPeiMasterBootModePpiGuid,
34 NULL
35 };
36
37 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
38 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
39 &gEfiPeiBootInRecoveryModePpiGuid,
40 NULL
41 };
42
43 EFI_STATUS
44 EFIAPI
45 InitializeBootMode (
46 IN EFI_PEI_FILE_HANDLE FileHandle,
47 IN CONST EFI_PEI_SERVICES **PeiServices
48 )
49
50 /*++
51
52 Routine Description:
53
54 Peform the boot mode determination logic
55
56 Arguments:
57
58 PeiServices - General purpose services available to every PEIM.
59
60 Returns:
61
62 Status - EFI_SUCCESS if the boot mode could be set
63
64 **/
65 {
66 EFI_STATUS Status;
67 EFI_BOOT_MODE BootMode;
68
69 DEBUG ((DEBUG_ERROR, "Emu Boot Mode PEIM Loaded\n"));
70
71 BootMode = FixedPcdGet32 (PcdEmuBootMode);
72
73 Status = PeiServicesSetBootMode (BootMode);
74 ASSERT_EFI_ERROR (Status);
75
76 Status = PeiServicesInstallPpi (&mPpiListBootMode);
77 ASSERT_EFI_ERROR (Status);
78
79 if (BootMode == BOOT_IN_RECOVERY_MODE) {
80 Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);
81 ASSERT_EFI_ERROR (Status);
82 }
83
84 return Status;
85 }