2 Opal Password PEI driver which is used to unlock Opal Password for S3.
4 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _OPAL_PASSWORD_PEI_H_
16 #define _OPAL_PASSWORD_PEI_H_
19 #include <IndustryStandard/Atapi.h>
20 #include <IndustryStandard/Pci.h>
22 #include <Library/DebugLib.h>
23 #include <Library/IoLib.h>
24 #include <Library/PciLib.h>
25 #include <Library/BaseLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/PeimEntryPoint.h>
29 #include <Library/PeiServicesLib.h>
30 #include <Library/HobLib.h>
31 #include <Library/TimerLib.h>
32 #include <Library/LockBoxLib.h>
33 #include <Library/TcgStorageOpalLib.h>
34 #include <Library/Tcg2PhysicalPresenceLib.h>
36 #include <Protocol/StorageSecurityCommand.h>
38 #include <Ppi/IoMmu.h>
40 #include "OpalPasswordCommon.h"
41 #include "OpalAhciMode.h"
42 #include "OpalNvmeMode.h"
45 // Time out Value for ATA pass through protocol
47 #define ATA_TIMEOUT 30000000
50 // The payload Length of HDD related ATA commands
52 #define HDD_PAYLOAD 512
54 // According to ATA spec, the max Length of hdd password is 32 bytes
56 #define OPAL_PASSWORD_MAX_LENGTH 32
61 * Opal I/O Type utilized by the Trusted IO callback
63 * The type indicates if the I/O is a send or receive
67 // I/O is a TCG Trusted Send command
72 // I/O is a TCG Trusted Receive command
77 #define OPAL_PEI_DEVICE_SIGNATURE SIGNATURE_32 ('o', 'p', 'd', 's')
81 EFI_STORAGE_SECURITY_COMMAND_PROTOCOL Sscp
;
83 OPAL_DEVICE_COMMON
*Device
;
87 #define OPAL_PEI_DEVICE_FROM_THIS(a) CR (a, OPAL_PEI_DEVICE, Sscp, OPAL_PEI_DEVICE_SIGNATURE)
92 Allocates pages that are suitable for an OperationBusMasterCommonBuffer or
93 OperationBusMasterCommonBuffer64 mapping.
95 @param Pages The number of pages to allocate.
96 @param HostAddress A pointer to store the base system memory address of the
98 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
99 access the hosts HostAddress.
100 @param Mapping A resulting value to pass to Unmap().
102 @retval EFI_SUCCESS The requested memory pages were allocated.
103 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
104 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
105 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
106 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
110 IoMmuAllocateBuffer (
112 OUT VOID
**HostAddress
,
113 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
118 Frees memory that was allocated with AllocateBuffer().
120 @param Pages The number of pages to free.
121 @param HostAddress The base system memory address of the allocated range.
122 @param Mapping The mapping value returned from Map().
128 IN VOID
*HostAddress
,
132 #endif // _OPAL_PASSWORD_PEI_H_