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 "Undi32.h"
15 
16 
17 UINTN      mSupportedInfoTypesCount = 1;
18 EFI_GUID   mSupportedInfoTypes[] = {
19   EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT_GUID
20 };
21 
22 /**
23   Returns the current state information for the adapter.
24 
25   This function returns information of type InformationType from the adapter.
26   If an adapter does not support the requested informational type, then
27   EFI_UNSUPPORTED is returned.
28 
29   @param[in]  This                   A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
30   @param[in]  InformationType        A pointer to an EFI_GUID that defines the contents of InformationBlock.
31   @param[out] InforamtionBlock       The service returns a pointer to the buffer with the InformationBlock
32                                      structure which contains details about the data specific to InformationType.
33   @param[out] InforamtionBlockSize   The driver returns the size of the InformationBlock in bytes.
34 
35   @retval EFI_SUCCESS                The InformationType information was retrieved.
36   @retval EFI_UNSUPPORTED            The InformationType is not known.
37   @retval EFI_DEVICE_ERROR           The device reported an error.
38   @retval EFI_OUT_OF_RESOURCES       The request could not be completed due to a lack of resources.
39   @retval EFI_INVALID_PARAMETER      This is NULL.
40   @retval EFI_INVALID_PARAMETER      InformationBlock is NULL.
41   @retval EFI_INVALID_PARAMETER      InformationBlockSize is NULL.
42 
43 **/
44 EFI_STATUS
45 EFIAPI
UndiAipGetInfo(IN EFI_ADAPTER_INFORMATION_PROTOCOL * This,IN EFI_GUID * InformationType,OUT VOID ** InformationBlock,OUT UINTN * InformationBlockSize)46 UndiAipGetInfo (
47   IN   EFI_ADAPTER_INFORMATION_PROTOCOL *This,
48   IN   EFI_GUID                         *InformationType,
49   OUT  VOID                             **InformationBlock,
50   OUT  UINTN                            *InformationBlockSize
51   )
52 {
53   UNDI32_DEV                            *UNDI32Device;
54   EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT    *UndiIpv6Support;
55 
56   if (This == NULL || InformationBlock == NULL || InformationBlockSize == NULL) {
57     return EFI_INVALID_PARAMETER;
58   }
59 
60   if (!CompareGuid (InformationType, &gEfiAdapterInfoUndiIpv6SupportGuid)) {
61     return EFI_UNSUPPORTED;
62   }
63 
64   UNDI32Device = UNDI_DEV_FROM_AIP (This);
65   *InformationBlockSize = sizeof (EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT);
66   *InformationBlock = AllocateZeroPool (*InformationBlockSize);
67   if (*InformationBlock == NULL) {
68     return EFI_OUT_OF_RESOURCES;
69   }
70 
71   UndiIpv6Support = (EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) (*InformationBlock);
72   UndiIpv6Support->Ipv6Support = UNDI32Device->NIIProtocol_31.Ipv6Supported;
73 
74   return EFI_SUCCESS;
75 }
76 
77 /**
78   Sets state information for an adapter.
79 
80   This function sends information of type InformationType for an adapter.
81   If an adapter does not support the requested information type, then EFI_UNSUPPORTED
82   is returned.
83 
84   @param[in]  This                   A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
85   @param[in]  InformationType        A pointer to an EFI_GUID that defines the contents of InformationBlock.
86   @param[in]  InforamtionBlock       A pointer to the InformationBlock structure which contains details
87                                      about the data specific to InformationType.
88   @param[in]  InforamtionBlockSize   The size of the InformationBlock in bytes.
89 
90   @retval EFI_SUCCESS                The information was received and interpreted successfully.
91   @retval EFI_UNSUPPORTED            The InformationType is not known.
92   @retval EFI_DEVICE_ERROR           The device reported an error.
93   @retval EFI_INVALID_PARAMETER      This is NULL.
94   @retval EFI_INVALID_PARAMETER      InformationBlock is NULL.
95   @retval EFI_WRITE_PROTECTED        The InformationType cannot be modified using EFI_ADAPTER_INFO_SET_INFO().
96 
97 **/
98 EFI_STATUS
99 EFIAPI
UndiAipSetInfo(IN EFI_ADAPTER_INFORMATION_PROTOCOL * This,IN EFI_GUID * InformationType,IN VOID * InformationBlock,IN UINTN InformationBlockSize)100 UndiAipSetInfo (
101   IN   EFI_ADAPTER_INFORMATION_PROTOCOL *This,
102   IN   EFI_GUID                         *InformationType,
103   IN   VOID                             *InformationBlock,
104   IN   UINTN                            InformationBlockSize
105   )
106 {
107   return EFI_WRITE_PROTECTED;
108 }
109 
110 /**
111   Get a list of supported information types for this instance of the protocol.
112 
113   This function returns a list of InformationType GUIDs that are supported on an
114   adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list is returned
115   in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer is returned in
116   InfoTypesBufferCount.
117 
118   @param[in]  This                  A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
119   @param[out] InfoTypesBuffer       A pointer to the list of InformationType GUID pointers that are supported
120                                     by This.
121   @param[out] InfoTypesBufferCount  A pointer to the number of GUID pointers present in InfoTypesBuffer.
122 
123   @retval EFI_SUCCESS               The list of information type GUIDs that are supported on this adapter was
124                                     returned in InfoTypesBuffer. The number of information type GUIDs was
125                                     returned in InfoTypesBufferCount.
126   @retval EFI_INVALID_PARAMETER     This is NULL.
127   @retval EFI_INVALID_PARAMETER     InfoTypesBuffer is NULL.
128   @retval EFI_INVALID_PARAMETER     InfoTypesBufferCount is NULL.
129   @retval EFI_OUT_OF_RESOURCES      There is not enough pool memory to store the results.
130 
131 **/
132 EFI_STATUS
133 EFIAPI
UndiAipGetSupportedTypes(IN EFI_ADAPTER_INFORMATION_PROTOCOL * This,OUT EFI_GUID ** InfoTypesBuffer,OUT UINTN * InfoTypesBufferCount)134 UndiAipGetSupportedTypes (
135   IN    EFI_ADAPTER_INFORMATION_PROTOCOL *This,
136   OUT   EFI_GUID                         **InfoTypesBuffer,
137   OUT   UINTN                            *InfoTypesBufferCount
138   )
139 {
140   if (This == NULL || InfoTypesBuffer == NULL || InfoTypesBufferCount == NULL) {
141     return EFI_INVALID_PARAMETER;
142   }
143 
144   *InfoTypesBufferCount = 1;
145   *InfoTypesBuffer = AllocateCopyPool (sizeof (EFI_GUID), &gEfiAdapterInfoUndiIpv6SupportGuid);
146   if (InfoTypesBuffer == NULL) {
147     return EFI_OUT_OF_RESOURCES;
148   }
149 
150   return EFI_SUCCESS;
151 }
152