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