]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/BootMode/BootMode.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[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
36 if (BootMode == NULL) {
37 return EFI_INVALID_PARAMETER;
38 }
39
40 PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
41
42 HandOffHob = (PrivateData->HobList.HandoffInformationTable);
43
44 *BootMode = HandOffHob->BootMode;
45
46
47 return EFI_SUCCESS;
48 }
49
50
51 /**
52 This service enables PEIMs to update the boot mode variable.
53
54
55 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
56 @param BootMode The value of the boot mode to set.
57
58 @return EFI_SUCCESS The value was successfully updated
59
60 **/
61 EFI_STATUS
62 EFIAPI
63 PeiSetBootMode (
64 IN CONST EFI_PEI_SERVICES **PeiServices,
65 IN EFI_BOOT_MODE BootMode
66 )
67 {
68 PEI_CORE_INSTANCE *PrivateData;
69 EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
70
71
72 PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
73
74 HandOffHob = (PrivateData->HobList.HandoffInformationTable);
75
76 HandOffHob->BootMode = BootMode;
77
78
79 return EFI_SUCCESS;
80 }