]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeHstiLib/HstiAip.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / DxeHstiLib / HstiAip.c
CommitLineData
aaedfe3c
JY
1/** @file\r
2\r
9095d37b 3 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 4 SPDX-License-Identifier: BSD-2-Clause-Patent\r
aaedfe3c
JY
5\r
6**/\r
7\r
8#include "HstiDxe.h"\r
9\r
10/**\r
11 Returns the current state information for the adapter.\r
12\r
13 This function returns information of type InformationType from the adapter.\r
14 If an adapter does not support the requested informational type, then\r
9095d37b 15 EFI_UNSUPPORTED is returned.\r
aaedfe3c
JY
16\r
17 @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.\r
18 @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock.\r
19 @param[out] InformationBlock The service returns a pointer to the buffer with the InformationBlock\r
20 structure which contains details about the data specific to InformationType.\r
21 @param[out] InformationBlockSize The driver returns the size of the InformationBlock in bytes.\r
22\r
23 @retval EFI_SUCCESS The InformationType information was retrieved.\r
24 @retval EFI_UNSUPPORTED The InformationType is not known.\r
25 @retval EFI_DEVICE_ERROR The device reported an error.\r
26 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
9095d37b
LG
27 @retval EFI_INVALID_PARAMETER This is NULL.\r
28 @retval EFI_INVALID_PARAMETER InformationBlock is NULL.\r
aaedfe3c
JY
29 @retval EFI_INVALID_PARAMETER InformationBlockSize is NULL.\r
30\r
31**/\r
32EFI_STATUS\r
33EFIAPI\r
34HstiAipGetInfo (\r
35 IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,\r
36 IN EFI_GUID *InformationType,\r
37 OUT VOID **InformationBlock,\r
38 OUT UINTN *InformationBlockSize\r
39 )\r
40{\r
41 HSTI_AIP_PRIVATE_DATA *HstiAip;\r
42\r
43 if ((This == NULL) || (InformationBlock == NULL) || (InformationBlockSize == NULL)) {\r
44 return EFI_INVALID_PARAMETER;\r
45 }\r
46 if (!CompareGuid (InformationType, &gAdapterInfoPlatformSecurityGuid)) {\r
47 return EFI_UNSUPPORTED;\r
48 }\r
49\r
50 HstiAip = HSTI_AIP_PRIVATE_DATA_FROM_THIS(This);\r
51\r
52 *InformationBlock = AllocateCopyPool (HstiAip->HstiSize, HstiAip->Hsti);\r
53 if (*InformationBlock == NULL) {\r
54 return EFI_OUT_OF_RESOURCES;\r
55 }\r
56 *InformationBlockSize = HstiAip->HstiSize;\r
57 return EFI_SUCCESS;\r
58}\r
59\r
60/**\r
61 Sets state information for an adapter.\r
62\r
63 This function sends information of type InformationType for an adapter.\r
64 If an adapter does not support the requested information type, then EFI_UNSUPPORTED\r
65 is returned.\r
66\r
67 @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.\r
68 @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock.\r
69 @param[in] InformationBlock A pointer to the InformationBlock structure which contains details\r
70 about the data specific to InformationType.\r
71 @param[in] InformationBlockSize The size of the InformationBlock in bytes.\r
72\r
73 @retval EFI_SUCCESS The information was received and interpreted successfully.\r
74 @retval EFI_UNSUPPORTED The InformationType is not known.\r
75 @retval EFI_DEVICE_ERROR The device reported an error.\r
76 @retval EFI_INVALID_PARAMETER This is NULL.\r
77 @retval EFI_INVALID_PARAMETER InformationBlock is NULL.\r
78 @retval EFI_WRITE_PROTECTED The InformationType cannot be modified using EFI_ADAPTER_INFO_SET_INFO().\r
79\r
80**/\r
81EFI_STATUS\r
82EFIAPI\r
83HstiAipSetInfo (\r
84 IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,\r
85 IN EFI_GUID *InformationType,\r
86 IN VOID *InformationBlock,\r
87 IN UINTN InformationBlockSize\r
88 )\r
89{\r
90 HSTI_AIP_PRIVATE_DATA *HstiAip;\r
91 VOID *NewHsti;\r
92\r
93 if ((This == NULL) || (InformationBlock == NULL)) {\r
94 return EFI_INVALID_PARAMETER;\r
95 }\r
96 if (!CompareGuid (InformationType, &gAdapterInfoPlatformSecurityGuid)) {\r
97 return EFI_UNSUPPORTED;\r
98 }\r
99\r
100 if (!InternalHstiIsValidTable (InformationBlock, InformationBlockSize)) {\r
101 return EFI_VOLUME_CORRUPTED;\r
102 }\r
103\r
104 HstiAip = HSTI_AIP_PRIVATE_DATA_FROM_THIS(This);\r
105\r
106 if (InformationBlockSize > HstiAip->HstiMaxSize) {\r
107 NewHsti = AllocateZeroPool (InformationBlockSize);\r
108 if (NewHsti == NULL) {\r
109 return EFI_OUT_OF_RESOURCES;\r
110 }\r
111 FreePool (HstiAip->Hsti);\r
112 HstiAip->Hsti = NewHsti;\r
113 HstiAip->HstiSize = 0;\r
114 HstiAip->HstiMaxSize = InformationBlockSize;\r
115 }\r
116\r
117 CopyMem (HstiAip->Hsti, InformationBlock, InformationBlockSize);\r
118 HstiAip->HstiSize = InformationBlockSize;\r
119 return EFI_SUCCESS;\r
120}\r
121\r
122/**\r
123 Get a list of supported information types for this instance of the protocol.\r
124\r
125 This function returns a list of InformationType GUIDs that are supported on an\r
126 adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list is returned\r
127 in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer is returned in\r
128 InfoTypesBufferCount.\r
129\r
130 @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.\r
131 @param[out] InfoTypesBuffer A pointer to the array of InformationType GUIDs that are supported\r
132 by This.\r
133 @param[out] InfoTypesBufferCount A pointer to the number of GUIDs present in InfoTypesBuffer.\r
134\r
135 @retval EFI_SUCCESS The list of information type GUIDs that are supported on this adapter was\r
136 returned in InfoTypesBuffer. The number of information type GUIDs was\r
137 returned in InfoTypesBufferCount.\r
138 @retval EFI_INVALID_PARAMETER This is NULL.\r
139 @retval EFI_INVALID_PARAMETER InfoTypesBuffer is NULL.\r
140 @retval EFI_INVALID_PARAMETER InfoTypesBufferCount is NULL.\r
141 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the results.\r
142\r
143**/\r
144EFI_STATUS\r
145EFIAPI\r
146HstiAipGetSupportedTypes (\r
147 IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,\r
148 OUT EFI_GUID **InfoTypesBuffer,\r
149 OUT UINTN *InfoTypesBufferCount\r
150 )\r
151{\r
152 if ((This == NULL) || (InfoTypesBuffer == NULL) || (InfoTypesBufferCount == NULL)) {\r
153 return EFI_INVALID_PARAMETER;\r
154 }\r
155\r
156 *InfoTypesBuffer = AllocateCopyPool (sizeof(gAdapterInfoPlatformSecurityGuid), &gAdapterInfoPlatformSecurityGuid);\r
157 if (*InfoTypesBuffer == NULL) {\r
158 return EFI_OUT_OF_RESOURCES;\r
159 }\r
160 *InfoTypesBufferCount = 1;\r
161\r
162 return EFI_SUCCESS;\r
163}\r
164\r
165EFI_ADAPTER_INFORMATION_PROTOCOL mAdapterInformationProtocol = {\r
166 HstiAipGetInfo,\r
167 HstiAipSetInfo,\r
168 HstiAipGetSupportedTypes,\r
169};\r