]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/HddPassword/HddPasswordDxe.h
SecurityPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / SecurityPkg / HddPassword / HddPasswordDxe.h
1 /** @file
2
3 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _HDD_PASSWORD_DXE_H_
10 #define _HDD_PASSWORD_DXE_H_
11
12 #include <Uefi.h>
13
14 #include <IndustryStandard/Atapi.h>
15 #include <IndustryStandard/Pci.h>
16 #include <Protocol/AtaPassThru.h>
17 #include <Protocol/PciIo.h>
18 #include <Protocol/HiiConfigAccess.h>
19 #include <Protocol/VariableLock.h>
20
21 #include <Guid/MdeModuleHii.h>
22 #include <Guid/EventGroup.h>
23 #include <Guid/S3StorageDeviceInitList.h>
24
25 #include <Library/DebugLib.h>
26 #include <Library/BaseLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/UefiRuntimeServicesTableLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/DxeServicesTableLib.h>
32 #include <Library/MemoryAllocationLib.h>
33 #include <Library/UefiHiiServicesLib.h>
34 #include <Library/HiiLib.h>
35 #include <Library/DevicePathLib.h>
36 #include <Library/PrintLib.h>
37 #include <Library/UefiLib.h>
38 #include <Library/LockBoxLib.h>
39 #include <Library/S3BootScriptLib.h>
40 #include <Library/PciLib.h>
41 #include <Library/BaseCryptLib.h>
42
43 #include "HddPasswordCommon.h"
44 #include "HddPasswordHiiDataStruc.h"
45
46 //
47 // This is the generated IFR binary data for each formset defined in VFR.
48 // This data array is ready to be used as input of HiiAddPackages() to
49 // create a packagelist (which contains Form packages, String packages, etc).
50 //
51 extern UINT8 HddPasswordBin[];
52
53 //
54 // This is the generated String package data for all .UNI files.
55 // This data array is ready to be used as input of HiiAddPackages() to
56 // create a packagelist (which contains Form packages, String packages, etc).
57 //
58 extern UINT8 HddPasswordDxeStrings[];
59
60 #define HDD_PASSWORD_DXE_PRIVATE_SIGNATURE SIGNATURE_32 ('H', 'D', 'D', 'P')
61
62 typedef struct _HDD_PASSWORD_CONFIG_FORM_ENTRY {
63 LIST_ENTRY Link;
64 EFI_HANDLE Controller;
65 UINTN Bus;
66 UINTN Device;
67 UINTN Function;
68 UINT16 Port;
69 UINT16 PortMultiplierPort;
70 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
71 CHAR16 HddString[64];
72 CHAR8 Password[HDD_PASSWORD_MAX_LENGTH];
73 EFI_STRING_ID TitleToken;
74 EFI_STRING_ID TitleHelpToken;
75
76 HDD_PASSWORD_CONFIG IfrData;
77 EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
78 } HDD_PASSWORD_CONFIG_FORM_ENTRY;
79
80 typedef struct _HDD_PASSWORD_DXE_PRIVATE_DATA {
81 UINTN Signature;
82 EFI_HANDLE DriverHandle;
83 EFI_HII_HANDLE HiiHandle;
84 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
85 HDD_PASSWORD_CONFIG_FORM_ENTRY *Current;
86 } HDD_PASSWORD_DXE_PRIVATE_DATA;
87
88 #define HDD_PASSWORD_DXE_PRIVATE_FROM_THIS(a) CR (a, HDD_PASSWORD_DXE_PRIVATE_DATA, ConfigAccess, HDD_PASSWORD_DXE_PRIVATE_SIGNATURE)
89
90 //
91 //Iterate through the doule linked list. NOT delete safe
92 //
93 #define EFI_LIST_FOR_EACH(Entry, ListHead) \
94 for (Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
95
96 #define PASSWORD_SALT_SIZE 32
97
98 #define HDD_PASSWORD_REQUEST_VARIABLE_NAME L"HddPasswordRequest"
99
100 //
101 // It needs to be locked before EndOfDxe.
102 //
103 #define HDD_PASSWORD_VARIABLE_NAME L"HddPassword"
104
105 #pragma pack(1)
106
107 typedef struct {
108 HDD_PASSWORD_DEVICE Device;
109 HDD_PASSWORD_REQUEST Request;
110 } HDD_PASSWORD_REQUEST_VARIABLE;
111
112 //
113 // It will be used to validate HDD password when the device is at frozen state.
114 //
115 typedef struct {
116 HDD_PASSWORD_DEVICE Device;
117 UINT8 PasswordHash[SHA256_DIGEST_SIZE];
118 UINT8 PasswordSalt[PASSWORD_SALT_SIZE];
119 } HDD_PASSWORD_VARIABLE;
120
121 ///
122 /// HII specific Vendor Device Path definition.
123 ///
124 typedef struct {
125 VENDOR_DEVICE_PATH VendorDevicePath;
126 EFI_DEVICE_PATH_PROTOCOL End;
127 } HII_VENDOR_DEVICE_PATH;
128
129 #pragma pack()
130
131 //
132 // Time out value for ATA pass through protocol
133 //
134 #define ATA_TIMEOUT EFI_TIMER_PERIOD_SECONDS (3)
135
136 typedef struct {
137 UINT32 Address;
138 S3_BOOT_SCRIPT_LIB_WIDTH Width;
139 } HDD_HC_PCI_REGISTER_SAVE;
140
141 #endif