TianoCore EDK2 master
Loading...
Searching...
No Matches
AhciPeiStorageSecurity.c
Go to the documentation of this file.
1
11#include "AhciPei.h"
12
28 IN UINTN TrustComputingDeviceIndex
29 )
30{
31 PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
32 LIST_ENTRY *Node;
33
34 Node = GetFirstNode (&Private->DeviceList);
35 while (!IsNull (&Private->DeviceList, Node)) {
36 DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
37
38 if (DeviceData->TrustComputingDeviceIndex == TrustComputingDeviceIndex) {
39 return DeviceData;
40 }
41
42 Node = GetNextNode (&Private->DeviceList, Node);
43 }
44
45 return NULL;
46}
47
59EFIAPI
62 OUT UINTN *NumberofDevices
63 )
64{
66
67 if ((This == NULL) || (NumberofDevices == NULL)) {
68 return EFI_INVALID_PARAMETER;
69 }
70
71 Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This);
72 *NumberofDevices = Private->TrustComputingDevices;
73
74 return EFI_SUCCESS;
75}
76
103EFIAPI
106 IN UINTN DeviceIndex,
107 OUT UINTN *DevicePathLength,
108 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
109 )
110{
112 PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
113 EFI_STATUS Status;
114
115 if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) {
116 return EFI_INVALID_PARAMETER;
117 }
118
119 Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This);
120 if ((DeviceIndex == 0) || (DeviceIndex > Private->TrustComputingDevices)) {
121 return EFI_INVALID_PARAMETER;
122 }
123
124 DeviceData = SearchTrustComputingDeviceByIndex (Private, DeviceIndex);
125 if (DeviceData == NULL) {
126 return EFI_NOT_FOUND;
127 }
128
129 Status = AhciBuildDevicePath (
130 Private,
131 DeviceData->Port,
132 DeviceData->PortMultiplier,
133 DevicePathLength,
134 DevicePath
135 );
136 if (EFI_ERROR (Status)) {
137 return Status;
138 }
139
140 return EFI_SUCCESS;
141}
142
230EFIAPI
233 IN UINTN DeviceIndex,
234 IN UINT64 Timeout,
235 IN UINT8 SecurityProtocolId,
236 IN UINT16 SecurityProtocolSpecificData,
237 IN UINTN PayloadBufferSize,
238 OUT VOID *PayloadBuffer,
239 OUT UINTN *PayloadTransferSize
240 )
241{
243 PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
244
245 if ((PayloadBuffer == NULL) || (PayloadTransferSize == NULL) || (PayloadBufferSize == 0)) {
246 return EFI_INVALID_PARAMETER;
247 }
248
249 Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This);
250 if ((DeviceIndex == 0) || (DeviceIndex > Private->TrustComputingDevices)) {
251 return EFI_INVALID_PARAMETER;
252 }
253
254 DeviceData = SearchTrustComputingDeviceByIndex (Private, DeviceIndex);
255 if (DeviceData == NULL) {
256 return EFI_NOT_FOUND;
257 }
258
259 ASSERT ((DeviceData->IdentifyData->trusted_computing_support & BIT0) != 0);
260 if ((DeviceData->IdentifyData->trusted_computing_support & BIT0) == 0) {
261 return EFI_UNSUPPORTED;
262 }
263
265 DeviceData,
266 PayloadBuffer,
267 SecurityProtocolId,
268 SecurityProtocolSpecificData,
269 PayloadBufferSize,
270 FALSE,
271 Timeout,
272 PayloadTransferSize
273 );
274}
275
341EFIAPI
344 IN UINTN DeviceIndex,
345 IN UINT64 Timeout,
346 IN UINT8 SecurityProtocolId,
347 IN UINT16 SecurityProtocolSpecificData,
348 IN UINTN PayloadBufferSize,
349 IN VOID *PayloadBuffer
350 )
351{
353 PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
354
355 if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {
356 return EFI_INVALID_PARAMETER;
357 }
358
359 Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This);
360 if ((DeviceIndex == 0) || (DeviceIndex > Private->TrustComputingDevices)) {
361 return EFI_INVALID_PARAMETER;
362 }
363
364 DeviceData = SearchTrustComputingDeviceByIndex (Private, DeviceIndex);
365 if (DeviceData == NULL) {
366 return EFI_NOT_FOUND;
367 }
368
369 ASSERT ((DeviceData->IdentifyData->trusted_computing_support & BIT0) != 0);
370 if ((DeviceData->IdentifyData->trusted_computing_support & BIT0) == 0) {
371 return EFI_UNSUPPORTED;
372 }
373
375 DeviceData,
376 PayloadBuffer,
377 SecurityProtocolId,
378 SecurityProtocolSpecificData,
379 PayloadBufferSize,
380 TRUE,
381 Timeout,
382 NULL
383 );
384}
UINT64 UINTN
EFI_STATUS TrustTransferAtaDevice(IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData, IN OUT VOID *Buffer, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN TransferLength, IN BOOLEAN IsTrustSend, IN UINT64 Timeout, OUT UINTN *TransferLengthOut)
Definition: AhciMode.c:2063
EFI_STATUS AhciBuildDevicePath(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT16 Port, IN UINT16 PortMultiplierPort, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
Definition: DevicePath.c:177
EFI_STATUS EFIAPI AhciStorageSecurityGetDevicePath(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI AhciStorageSecuritySendData(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, IN VOID *PayloadBuffer)
EFI_STATUS EFIAPI AhciStorageSecurityReceiveData(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer, OUT UINTN *PayloadTransferSize)
EFI_STATUS EFIAPI AhciStorageSecurityGetDeviceNo(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, OUT UINTN *NumberofDevices)
PEI_AHCI_ATA_DEVICE_DATA * SearchTrustComputingDeviceByIndex(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINTN TrustComputingDeviceIndex)
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:443
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:333
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112