]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/UndiRuntimeDxe/UndiAipImpl.c
Add IPV6 support from UNDI
[mirror_edk2.git] / OptionRomPkg / UndiRuntimeDxe / UndiAipImpl.c
diff --git a/OptionRomPkg/UndiRuntimeDxe/UndiAipImpl.c b/OptionRomPkg/UndiRuntimeDxe/UndiAipImpl.c
new file mode 100644 (file)
index 0000000..17552a1
--- /dev/null
@@ -0,0 +1,151 @@
+/** @file\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+\r
+#include "Undi32.h"\r
+\r
+\r
+UINTN      mSupportedInfoTypesCount = 1;\r
+EFI_GUID   mSupportedInfoTypes[] = {\r
+  EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT_GUID\r
+};\r
+\r
+/**\r
+  Returns the current state information for the adapter.\r
+\r
+  This function returns information of type InformationType from the adapter.\r
+  If an adapter does not support the requested informational type, then\r
+  EFI_UNSUPPORTED is returned. \r
+\r
+  @param[in]  This                   A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.\r
+  @param[in]  InformationType        A pointer to an EFI_GUID that defines the contents of InformationBlock.\r
+  @param[out] InforamtionBlock       The service returns a pointer to the buffer with the InformationBlock\r
+                                     structure which contains details about the data specific to InformationType.\r
+  @param[out] InforamtionBlockSize   The driver returns the size of the InformationBlock in bytes.\r
+\r
+  @retval EFI_SUCCESS                The InformationType information was retrieved.\r
+  @retval EFI_UNSUPPORTED            The InformationType is not known.\r
+  @retval EFI_DEVICE_ERROR           The device reported an error.\r
+  @retval EFI_OUT_OF_RESOURCES       The request could not be completed due to a lack of resources.\r
+  @retval EFI_INVALID_PARAMETER      This is NULL. \r
+  @retval EFI_INVALID_PARAMETER      InformationBlock is NULL. \r
+  @retval EFI_INVALID_PARAMETER      InformationBlockSize is NULL.\r
+\r
+**/  \r
+EFI_STATUS\r
+EFIAPI\r
+UndiAipGetInfo (\r
+  IN   EFI_ADAPTER_INFORMATION_PROTOCOL *This,\r
+  IN   EFI_GUID                         *InformationType,\r
+  OUT  VOID                             **InformationBlock,\r
+  OUT  UINTN                            *InformationBlockSize\r
+  )\r
+{\r
+  UNDI32_DEV                            *UNDI32Device;\r
+  EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT    *UndiIpv6Support;\r
+\r
+  if (This == NULL || InformationBlock == NULL || InformationBlockSize == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (!CompareGuid (InformationType, &gEfiAdapterInfoUndiIpv6SupportGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  UNDI32Device = UNDI_DEV_FROM_AIP (This);\r
+  *InformationBlockSize = sizeof (EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT);\r
+  *InformationBlock = AllocateZeroPool (*InformationBlockSize);\r
+  if (*InformationBlock == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  UndiIpv6Support = (EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) (*InformationBlock);\r
+  UndiIpv6Support->Ipv6Support = UNDI32Device->NIIProtocol_31.Ipv6Supported;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Sets state information for an adapter.\r
+\r
+  This function sends information of type InformationType for an adapter.\r
+  If an adapter does not support the requested information type, then EFI_UNSUPPORTED\r
+  is returned.\r
+\r
+  @param[in]  This                   A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.\r
+  @param[in]  InformationType        A pointer to an EFI_GUID that defines the contents of InformationBlock.\r
+  @param[in]  InforamtionBlock       A pointer to the InformationBlock structure which contains details\r
+                                     about the data specific to InformationType.\r
+  @param[in]  InforamtionBlockSize   The size of the InformationBlock in bytes.\r
+\r
+  @retval EFI_SUCCESS                The information was received and interpreted successfully.\r
+  @retval EFI_UNSUPPORTED            The InformationType is not known.\r
+  @retval EFI_DEVICE_ERROR           The device reported an error.\r
+  @retval EFI_INVALID_PARAMETER      This is NULL.\r
+  @retval EFI_INVALID_PARAMETER      InformationBlock is NULL.\r
+  @retval EFI_WRITE_PROTECTED        The InformationType cannot be modified using EFI_ADAPTER_INFO_SET_INFO().\r
+\r
+**/                        \r
+EFI_STATUS\r
+EFIAPI\r
+UndiAipSetInfo (\r
+  IN   EFI_ADAPTER_INFORMATION_PROTOCOL *This,\r
+  IN   EFI_GUID                         *InformationType,\r
+  IN   VOID                             *InformationBlock,\r
+  IN   UINTN                            InformationBlockSize\r
+  )\r
+{\r
+  return EFI_WRITE_PROTECTED;\r
+}\r
+\r
+/**\r
+  Get a list of supported information types for this instance of the protocol.\r
+\r
+  This function returns a list of InformationType GUIDs that are supported on an\r
+  adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list is returned\r
+  in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer is returned in\r
+  InfoTypesBufferCount.\r
+\r
+  @param[in]  This                  A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.\r
+  @param[out] InfoTypesBuffer       A pointer to the list of InformationType GUID pointers that are supported\r
+                                    by This.\r
+  @param[out] InfoTypesBufferCount  A pointer to the number of GUID pointers present in InfoTypesBuffer.\r
+\r
+  @retval EFI_SUCCESS               The list of information type GUIDs that are supported on this adapter was\r
+                                    returned in InfoTypesBuffer. The number of information type GUIDs was\r
+                                    returned in InfoTypesBufferCount.\r
+  @retval EFI_INVALID_PARAMETER     This is NULL.\r
+  @retval EFI_INVALID_PARAMETER     InfoTypesBuffer is NULL.\r
+  @retval EFI_INVALID_PARAMETER     InfoTypesBufferCount is NULL.\r
+  @retval EFI_OUT_OF_RESOURCES      There is not enough pool memory to store the results.\r
+\r
+**/                        \r
+EFI_STATUS\r
+EFIAPI\r
+UndiAipGetSupportedTypes (\r
+  IN    EFI_ADAPTER_INFORMATION_PROTOCOL *This,\r
+  OUT   EFI_GUID                         **InfoTypesBuffer,\r
+  OUT   UINTN                            *InfoTypesBufferCount\r
+  )\r
+{\r
+  if (This == NULL || InfoTypesBuffer == NULL || InfoTypesBufferCount == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *InfoTypesBufferCount = 1;\r
+  *InfoTypesBuffer = AllocateCopyPool (sizeof (EFI_GUID), &gEfiAdapterInfoUndiIpv6SupportGuid);\r
+  if (InfoTypesBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r