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