1 /** @file
2   Head file for BDS Architectural Protocol implementation
3 
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7 **/
8 
9 #ifndef _BDS_MODULE_H_
10 #define _BDS_MODULE_H_
11 
12 #include <Uefi.h>
13 #include <Guid/GlobalVariable.h>
14 #include <Guid/ConnectConInEvent.h>
15 #include <Guid/StatusCodeDataTypeVariable.h>
16 #include <Guid/EventGroup.h>
17 
18 #include <Protocol/Bds.h>
19 #include <Protocol/LoadedImage.h>
20 #include <Protocol/VariableLock.h>
21 #include <Protocol/DeferredImageLoad.h>
22 
23 #include <Library/UefiDriverEntryPoint.h>
24 #include <Library/DebugLib.h>
25 #include <Library/BaseMemoryLib.h>
26 #include <Library/UefiBootServicesTableLib.h>
27 #include <Library/UefiRuntimeServicesTableLib.h>
28 #include <Library/UefiLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/ReportStatusCodeLib.h>
31 #include <Library/BaseLib.h>
32 #include <Library/PcdLib.h>
33 #include <Library/PerformanceLib.h>
34 #include <Library/DevicePathLib.h>
35 #include <Library/PrintLib.h>
36 
37 #include <Library/UefiBootManagerLib.h>
38 #include <Library/PlatformBootManagerLib.h>
39 
40 #if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
41     #if defined (MDE_CPU_EBC)
42         //
43         // Uefi specification only defines the default boot file name for IA32, X64
44         // and IPF processor, so need define boot file name for EBC architecture here.
45         //
46         #define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
47     #else
48         #error "Can not determine the default boot file name for unknown processor type!"
49     #endif
50 #endif
51 
52 /**
53 
54   Service routine for BdsInstance->Entry(). Devices are connected, the
55   consoles are initialized, and the boot options are tried.
56 
57   @param This            Protocol Instance structure.
58 
59 **/
60 VOID
61 EFIAPI
62 BdsEntry (
63   IN  EFI_BDS_ARCH_PROTOCOL *This
64   );
65 
66 /**
67   Set the variable and report the error through status code upon failure.
68 
69   @param  VariableName           A Null-terminated string that is the name of the vendor's variable.
70                                  Each VariableName is unique for each VendorGuid. VariableName must
71                                  contain 1 or more characters. If VariableName is an empty string,
72                                  then EFI_INVALID_PARAMETER is returned.
73   @param  VendorGuid             A unique identifier for the vendor.
74   @param  Attributes             Attributes bitmask to set for the variable.
75   @param  DataSize               The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
76                                  or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
77                                  causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
78                                  set, then a SetVariable() call with a DataSize of zero will not cause any change to
79                                  the variable value (the timestamp associated with the variable may be updated however
80                                  even if no new data value is provided,see the description of the
81                                  EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
82                                  be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
83   @param  Data                   The contents for the variable.
84 
85   @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as
86                                  defined by the Attributes.
87   @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits, name, and GUID was supplied, or the
88                                  DataSize exceeds the maximum allowed.
89   @retval EFI_INVALID_PARAMETER  VariableName is an empty string.
90   @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.
91   @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.
92   @retval EFI_WRITE_PROTECTED    The variable in question is read-only.
93   @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.
94   @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS
95                                  being set, but the AuthInfo does NOT pass the validation check carried out by the firmware.
96 
97   @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.
98 **/
99 EFI_STATUS
100 BdsDxeSetVariableAndReportStatusCodeOnError (
101   IN CHAR16     *VariableName,
102   IN EFI_GUID   *VendorGuid,
103   IN UINT32     Attributes,
104   IN UINTN      DataSize,
105   IN VOID       *Data
106   );
107 
108 #endif
109