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