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