]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/BootMode/BootMode.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Core / Pei / BootMode / BootMode.c
1 /** @file
2 This module provide function for ascertaining and updating the boot mode:
3 GetBootMode()
4 SetBootMode()
5 See PI Specification volume I, chapter 9 Boot Paths for additional information
6 on the boot mode.
7
8 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
10
11 **/
12
13 #include "PeiMain.h"
14
15 /**
16 This service enables PEIMs to ascertain the present value of the boot mode.
17
18 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
19 @param BootMode A pointer to contain the value of the boot mode.
20
21 @retval EFI_SUCCESS The boot mode was returned successfully.
22 @retval EFI_INVALID_PARAMETER BootMode is NULL.
23
24 **/
25 EFI_STATUS
26 EFIAPI
27 PeiGetBootMode (
28 IN CONST EFI_PEI_SERVICES **PeiServices,
29 IN OUT EFI_BOOT_MODE *BootMode
30 )
31 {
32 PEI_CORE_INSTANCE *PrivateData;
33 EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
34
35 if (BootMode == NULL) {
36 return EFI_INVALID_PARAMETER;
37 }
38
39 PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
40
41 HandOffHob = (PrivateData->HobList.HandoffInformationTable);
42
43 *BootMode = HandOffHob->BootMode;
44
45 return EFI_SUCCESS;
46 }
47
48 /**
49 This service enables PEIMs to update the boot mode variable.
50
51
52 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
53 @param BootMode The value of the boot mode to set.
54
55 @return EFI_SUCCESS The value was successfully updated
56
57 **/
58 EFI_STATUS
59 EFIAPI
60 PeiSetBootMode (
61 IN CONST EFI_PEI_SERVICES **PeiServices,
62 IN EFI_BOOT_MODE BootMode
63 )
64 {
65 PEI_CORE_INSTANCE *PrivateData;
66 EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
67
68 PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
69
70 HandOffHob = (PrivateData->HobList.HandoffInformationTable);
71
72 HandOffHob->BootMode = BootMode;
73
74 return EFI_SUCCESS;
75 }