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