]>
Commit | Line | Data |
---|---|---|
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 | |
32 | EFI_STATUS\r | |
33 | EFIAPI\r | |
34 | HstiAipGetInfo (\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 | |
2f88bd3a | 46 | \r |
aaedfe3c JY |
47 | if (!CompareGuid (InformationType, &gAdapterInfoPlatformSecurityGuid)) {\r |
48 | return EFI_UNSUPPORTED;\r | |
49 | }\r | |
50 | \r | |
2f88bd3a | 51 | HstiAip = HSTI_AIP_PRIVATE_DATA_FROM_THIS (This);\r |
aaedfe3c JY |
52 | \r |
53 | *InformationBlock = AllocateCopyPool (HstiAip->HstiSize, HstiAip->Hsti);\r | |
54 | if (*InformationBlock == NULL) {\r | |
55 | return EFI_OUT_OF_RESOURCES;\r | |
56 | }\r | |
2f88bd3a | 57 | \r |
aaedfe3c JY |
58 | *InformationBlockSize = HstiAip->HstiSize;\r |
59 | return EFI_SUCCESS;\r | |
60 | }\r | |
61 | \r | |
62 | /**\r | |
63 | Sets state information for an adapter.\r | |
64 | \r | |
65 | This function sends information of type InformationType for an adapter.\r | |
66 | If an adapter does not support the requested information type, then EFI_UNSUPPORTED\r | |
67 | is returned.\r | |
68 | \r | |
69 | @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.\r | |
70 | @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock.\r | |
71 | @param[in] InformationBlock A pointer to the InformationBlock structure which contains details\r | |
72 | about the data specific to InformationType.\r | |
73 | @param[in] InformationBlockSize The size of the InformationBlock in bytes.\r | |
74 | \r | |
75 | @retval EFI_SUCCESS The information was received and interpreted successfully.\r | |
76 | @retval EFI_UNSUPPORTED The InformationType is not known.\r | |
77 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
78 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
79 | @retval EFI_INVALID_PARAMETER InformationBlock is NULL.\r | |
80 | @retval EFI_WRITE_PROTECTED The InformationType cannot be modified using EFI_ADAPTER_INFO_SET_INFO().\r | |
81 | \r | |
82 | **/\r | |
83 | EFI_STATUS\r | |
84 | EFIAPI\r | |
85 | HstiAipSetInfo (\r | |
86 | IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,\r | |
87 | IN EFI_GUID *InformationType,\r | |
88 | IN VOID *InformationBlock,\r | |
89 | IN UINTN InformationBlockSize\r | |
90 | )\r | |
91 | {\r | |
92 | HSTI_AIP_PRIVATE_DATA *HstiAip;\r | |
93 | VOID *NewHsti;\r | |
94 | \r | |
95 | if ((This == NULL) || (InformationBlock == NULL)) {\r | |
96 | return EFI_INVALID_PARAMETER;\r | |
97 | }\r | |
2f88bd3a | 98 | \r |
aaedfe3c JY |
99 | if (!CompareGuid (InformationType, &gAdapterInfoPlatformSecurityGuid)) {\r |
100 | return EFI_UNSUPPORTED;\r | |
101 | }\r | |
102 | \r | |
103 | if (!InternalHstiIsValidTable (InformationBlock, InformationBlockSize)) {\r | |
104 | return EFI_VOLUME_CORRUPTED;\r | |
105 | }\r | |
106 | \r | |
2f88bd3a | 107 | HstiAip = HSTI_AIP_PRIVATE_DATA_FROM_THIS (This);\r |
aaedfe3c JY |
108 | \r |
109 | if (InformationBlockSize > HstiAip->HstiMaxSize) {\r | |
110 | NewHsti = AllocateZeroPool (InformationBlockSize);\r | |
111 | if (NewHsti == NULL) {\r | |
112 | return EFI_OUT_OF_RESOURCES;\r | |
113 | }\r | |
2f88bd3a | 114 | \r |
aaedfe3c | 115 | FreePool (HstiAip->Hsti);\r |
2f88bd3a MK |
116 | HstiAip->Hsti = NewHsti;\r |
117 | HstiAip->HstiSize = 0;\r | |
aaedfe3c JY |
118 | HstiAip->HstiMaxSize = InformationBlockSize;\r |
119 | }\r | |
120 | \r | |
121 | CopyMem (HstiAip->Hsti, InformationBlock, InformationBlockSize);\r | |
122 | HstiAip->HstiSize = InformationBlockSize;\r | |
123 | return EFI_SUCCESS;\r | |
124 | }\r | |
125 | \r | |
126 | /**\r | |
127 | Get a list of supported information types for this instance of the protocol.\r | |
128 | \r | |
129 | This function returns a list of InformationType GUIDs that are supported on an\r | |
130 | adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list is returned\r | |
131 | in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer is returned in\r | |
132 | InfoTypesBufferCount.\r | |
133 | \r | |
134 | @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.\r | |
135 | @param[out] InfoTypesBuffer A pointer to the array of InformationType GUIDs that are supported\r | |
136 | by This.\r | |
137 | @param[out] InfoTypesBufferCount A pointer to the number of GUIDs present in InfoTypesBuffer.\r | |
138 | \r | |
139 | @retval EFI_SUCCESS The list of information type GUIDs that are supported on this adapter was\r | |
140 | returned in InfoTypesBuffer. The number of information type GUIDs was\r | |
141 | returned in InfoTypesBufferCount.\r | |
142 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
143 | @retval EFI_INVALID_PARAMETER InfoTypesBuffer is NULL.\r | |
144 | @retval EFI_INVALID_PARAMETER InfoTypesBufferCount is NULL.\r | |
145 | @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the results.\r | |
146 | \r | |
147 | **/\r | |
148 | EFI_STATUS\r | |
149 | EFIAPI\r | |
150 | HstiAipGetSupportedTypes (\r | |
151 | IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,\r | |
152 | OUT EFI_GUID **InfoTypesBuffer,\r | |
153 | OUT UINTN *InfoTypesBufferCount\r | |
154 | )\r | |
155 | {\r | |
156 | if ((This == NULL) || (InfoTypesBuffer == NULL) || (InfoTypesBufferCount == NULL)) {\r | |
157 | return EFI_INVALID_PARAMETER;\r | |
158 | }\r | |
159 | \r | |
2f88bd3a | 160 | *InfoTypesBuffer = AllocateCopyPool (sizeof (gAdapterInfoPlatformSecurityGuid), &gAdapterInfoPlatformSecurityGuid);\r |
aaedfe3c JY |
161 | if (*InfoTypesBuffer == NULL) {\r |
162 | return EFI_OUT_OF_RESOURCES;\r | |
163 | }\r | |
2f88bd3a | 164 | \r |
aaedfe3c JY |
165 | *InfoTypesBufferCount = 1;\r |
166 | \r | |
167 | return EFI_SUCCESS;\r | |
168 | }\r | |
169 | \r | |
2f88bd3a | 170 | EFI_ADAPTER_INFORMATION_PROTOCOL mAdapterInformationProtocol = {\r |
aaedfe3c JY |
171 | HstiAipGetInfo,\r |
172 | HstiAipSetInfo,\r | |
173 | HstiAipGetSupportedTypes,\r | |
174 | };\r |