• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Header file for driver binding protocol and HII config access protocol.
3 
4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution.  The full
8 text of the license may be found at<BR>
9 http://opensource.org/licenses/bsd-license.php
10 
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 **/
15 
16 #ifndef __VLAN_CONFIG_IMPL_H__
17 #define __VLAN_CONFIG_IMPL_H__
18 
19 #include <Uefi.h>
20 
21 #include <Protocol/ComponentName.h>
22 #include <Protocol/ComponentName2.h>
23 #include <Protocol/HiiConfigAccess.h>
24 #include <Protocol/HiiConfigRouting.h>
25 #include <Protocol/VlanConfig.h>
26 
27 #include <Library/BaseLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/DebugLib.h>
30 #include <Library/MemoryAllocationLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/UefiLib.h>
33 #include <Library/NetLib.h>
34 #include <Library/HiiLib.h>
35 #include <Library/DevicePathLib.h>
36 #include <Library/PrintLib.h>
37 
38 #include <Guid/MdeModuleHii.h>
39 
40 #include "VlanConfigNvData.h"
41 
42 extern EFI_COMPONENT_NAME2_PROTOCOL gVlanConfigComponentName2;
43 extern EFI_COMPONENT_NAME_PROTOCOL  gVlanConfigComponentName;
44 
45 //
46 // Tool generated IFR binary data and String package data
47 //
48 extern UINT8                        VlanConfigBin[];
49 extern UINT8                        VlanConfigDxeStrings[];
50 
51 #define VLAN_LIST_VAR_OFFSET ((UINT16) OFFSET_OF (VLAN_CONFIGURATION, VlanList))
52 
53 typedef struct {
54   UINTN                           Signature;
55 
56   EFI_HII_CONFIG_ACCESS_PROTOCOL  ConfigAccess;
57   EFI_HII_HANDLE                  HiiHandle;
58   EFI_HANDLE                      DriverHandle;
59   EFI_DEVICE_PATH_PROTOCOL        *ChildDevicePath;
60 
61   EFI_HANDLE                      ControllerHandle;
62   EFI_HANDLE                      ImageHandle;
63   EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;
64   EFI_VLAN_CONFIG_PROTOCOL        *VlanConfig;
65   CHAR16                          *MacString;
66 
67   UINT16                          NumberOfVlan;
68   UINT16                          VlanId[MAX_VLAN_NUMBER];
69 } VLAN_CONFIG_PRIVATE_DATA;
70 
71 #define VLAN_CONFIG_PRIVATE_DATA_SIGNATURE     SIGNATURE_32 ('V', 'C', 'P', 'D')
72 #define VLAN_CONFIG_PRIVATE_DATA_FROM_THIS(a)  CR (a, VLAN_CONFIG_PRIVATE_DATA, ConfigAccess, VLAN_CONFIG_PRIVATE_DATA_SIGNATURE)
73 
74 extern VLAN_CONFIG_PRIVATE_DATA mVlanConfigPrivateDateTemplate;
75 
76 
77 /**
78   Retrieves a Unicode string that is the user readable name of the driver.
79 
80   This function retrieves the user readable name of a driver in the form of a
81   Unicode string. If the driver specified by This has a user readable name in
82   the language specified by Language, then a pointer to the driver name is
83   returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
84   by This does not support the language specified by Language,
85   then EFI_UNSUPPORTED is returned.
86 
87   @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
88                                 EFI_COMPONENT_NAME_PROTOCOL instance.
89   @param  Language[in]          A pointer to a Null-terminated ASCII string
90                                 array indicating the language. This is the
91                                 language of the driver name that the caller is
92                                 requesting, and it must match one of the
93                                 languages specified in SupportedLanguages. The
94                                 number of languages supported by a driver is up
95                                 to the driver writer. Language is specified
96                                 in RFC 4646 or ISO 639-2 language code format.
97   @param  DriverName[out]       A pointer to the Unicode string to return.
98                                 This Unicode string is the name of the
99                                 driver specified by This in the language
100                                 specified by Language.
101 
102   @retval EFI_SUCCESS           The Unicode string for the Driver specified by
103                                 This and the language specified by Language was
104                                 returned in DriverName.
105   @retval EFI_INVALID_PARAMETER Language is NULL.
106   @retval EFI_INVALID_PARAMETER DriverName is NULL.
107   @retval EFI_UNSUPPORTED       The driver specified by This does not support
108                                 the language specified by Language.
109 
110 **/
111 EFI_STATUS
112 EFIAPI
113 VlanConfigComponentNameGetDriverName (
114   IN     EFI_COMPONENT_NAME_PROTOCOL   *This,
115   IN     CHAR8                         *Language,
116      OUT CHAR16                        **DriverName
117   );
118 
119 /**
120   Retrieves a Unicode string that is the user readable name of the controller
121   that is being managed by a driver.
122 
123   This function retrieves the user readable name of the controller specified by
124   ControllerHandle and ChildHandle in the form of a Unicode string. If the
125   driver specified by This has a user readable name in the language specified by
126   Language, then a pointer to the controller name is returned in ControllerName,
127   and EFI_SUCCESS is returned.  If the driver specified by This is not currently
128   managing the controller specified by ControllerHandle and ChildHandle,
129   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not
130   support the language specified by Language, then EFI_UNSUPPORTED is returned.
131 
132   @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
133                                 EFI_COMPONENT_NAME_PROTOCOL instance.
134   @param  ControllerHandle[in]  The handle of a controller that the driver
135                                 specified by This is managing.  This handle
136                                 specifies the controller whose name is to be
137                                 returned.
138   @param  ChildHandle[in]       The handle of the child controller to retrieve
139                                 the name of.  This is an optional parameter that
140                                 may be NULL.  It will be NULL for device
141                                 drivers.  It will also be NULL for a bus drivers
142                                 that wish to retrieve the name of the bus
143                                 controller.  It will not be NULL for a bus
144                                 driver that wishes to retrieve the name of a
145                                 child controller.
146   @param  Language[in]          A pointer to a Null-terminated ASCII string
147                                 array indicating the language.  This is the
148                                 language of the driver name that the caller is
149                                 requesting, and it must match one of the
150                                 languages specified in SupportedLanguages. The
151                                 number of languages supported by a driver is up
152                                 to the driver writer. Language is specified in
153                                 RFC 4646 or ISO 639-2 language code format.
154   @param  ControllerName[out]   A pointer to the Unicode string to return.
155                                 This Unicode string is the name of the
156                                 controller specified by ControllerHandle and
157                                 ChildHandle in the language specified by
158                                 Language from the point of view of the driver
159                                 specified by This.
160 
161   @retval EFI_SUCCESS           The Unicode string for the user readable name in
162                                 the language specified by Language for the
163                                 driver specified by This was returned in
164                                 DriverName.
165   @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
166   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
167                                 EFI_HANDLE.
168   @retval EFI_INVALID_PARAMETER Language is NULL.
169   @retval EFI_INVALID_PARAMETER ControllerName is NULL.
170   @retval EFI_UNSUPPORTED       The driver specified by This is not currently
171                                 managing the controller specified by
172                                 ControllerHandle and ChildHandle.
173   @retval EFI_UNSUPPORTED       The driver specified by This does not support
174                                 the language specified by Language.
175 
176 **/
177 EFI_STATUS
178 EFIAPI
179 VlanConfigComponentNameGetControllerName (
180   IN     EFI_COMPONENT_NAME_PROTOCOL   *This,
181   IN     EFI_HANDLE                    ControllerHandle,
182   IN     EFI_HANDLE                    ChildHandle OPTIONAL,
183   IN     CHAR8                         *Language,
184      OUT CHAR16                        **ControllerName
185   );
186 
187 /**
188   Test to see if this driver supports ControllerHandle.
189 
190   @param[in]  This                 Protocol instance pointer.
191   @param[in]  ControllerHandle     Handle of device to test
192   @param[in]  RemainingDevicePath  Optional parameter use to pick a specific child
193                                    device to start.
194 
195   @retval EFI_SUCCES           This driver supports this device
196   @retval EFI_ALREADY_STARTED  This driver is already running on this device
197   @retval other                This driver does not support this device
198 
199 **/
200 EFI_STATUS
201 EFIAPI
202 VlanConfigDriverBindingSupported (
203   IN EFI_DRIVER_BINDING_PROTOCOL     *This,
204   IN EFI_HANDLE                      ControllerHandle,
205   IN EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath OPTIONAL
206   );
207 
208 /**
209   Start this driver on ControllerHandle.
210 
211   @param[in]  This                 Protocol instance pointer.
212   @param[in]  ControllerHandle     Handle of device to bind driver to
213   @param[in]  RemainingDevicePath  Optional parameter use to pick a specific child
214                                    device to start.
215 
216   @retval EFI_SUCCES           This driver is added to ControllerHandle
217   @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle
218   @retval other                This driver does not support this device
219 
220 **/
221 EFI_STATUS
222 EFIAPI
223 VlanConfigDriverBindingStart (
224   IN EFI_DRIVER_BINDING_PROTOCOL     *This,
225   IN EFI_HANDLE                      ControllerHandle,
226   IN EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath OPTIONAL
227   );
228 
229 /**
230   Stop this driver on ControllerHandle.
231 
232   @param[in]  This                 Protocol instance pointer.
233   @param[in]  ControllerHandle     Handle of device to stop driver on
234   @param[in]  NumberOfChildren     Number of Handles in ChildHandleBuffer. If number
235                                    of children is zero stop the entire bus driver.
236   @param[in]  ChildHandleBuffer    List of Child Handles to Stop.
237 
238   @retval EFI_SUCCES           This driver is removed ControllerHandle
239   @retval other                This driver was not removed from this device
240 
241 **/
242 EFI_STATUS
243 EFIAPI
244 VlanConfigDriverBindingStop (
245   IN EFI_DRIVER_BINDING_PROTOCOL     *This,
246   IN EFI_HANDLE                      ControllerHandle,
247   IN UINTN                           NumberOfChildren,
248   IN EFI_HANDLE                      *ChildHandleBuffer
249   );
250 
251 /**
252   This function update VLAN list in the VLAN configuration Form.
253 
254   @param[in, out]  PrivateData   Points to VLAN configuration private data.
255 
256 **/
257 VOID
258 VlanUpdateForm (
259   IN OUT VLAN_CONFIG_PRIVATE_DATA    *PrivateData
260   );
261 
262 /**
263   This function publish the VLAN configuration Form for a network device. The
264   HII Config Access protocol will be installed on a child handle of the network
265   device.
266 
267   @param[in, out]  PrivateData   Points to VLAN configuration private data.
268 
269   @retval EFI_SUCCESS            HII Form is installed for this network device.
270   @retval EFI_OUT_OF_RESOURCES   Not enough resource for HII Form installation.
271   @retval Others                 Other errors as indicated.
272 
273 **/
274 EFI_STATUS
275 InstallVlanConfigForm (
276   IN OUT VLAN_CONFIG_PRIVATE_DATA    *PrivateData
277   );
278 
279 /**
280   This function remove the VLAN configuration Form for a network device. The
281   child handle for HII Config Access protocol will be destroyed.
282 
283   @param[in, out]  PrivateData   Points to VLAN configuration private data.
284 
285   @retval EFI_SUCCESS            HII Form has been uninstalled successfully.
286   @retval Others                 Other errors as indicated.
287 
288 **/
289 EFI_STATUS
290 UninstallVlanConfigForm (
291   IN OUT VLAN_CONFIG_PRIVATE_DATA    *PrivateData
292   );
293 
294 /**
295   This function allows a caller to extract the current configuration for one
296   or more named elements from the target driver.
297 
298   @param[in]  This               Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
299   @param[in]  Request            A null-terminated Unicode string in
300                                  <ConfigRequest> format.
301   @param[out]  Progress          On return, points to a character in the Request
302                                  string. Points to the string's null terminator if
303                                  request was successful. Points to the most recent
304                                  '&' before the first failing name/value pair (or
305                                  the beginning of the string if the failure is in
306                                  the first name/value pair) if the request was not
307                                  successful.
308   @param[out]  Results           A null-terminated Unicode string in
309                                  <ConfigAltResp> format which has all values filled
310                                  in for the names in the Request string. String to
311                                  be allocated by the called function.
312 
313   @retval EFI_SUCCESS            The Results is filled with the requested values.
314   @retval EFI_OUT_OF_RESOURCES   Not enough memory to store the results.
315   @retval EFI_INVALID_PARAMETER  Request is NULL, illegal syntax, or unknown name.
316   @retval EFI_NOT_FOUND          Routing data doesn't match any storage in this
317                                  driver.
318 
319 **/
320 EFI_STATUS
321 EFIAPI
322 VlanExtractConfig (
323   IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL        *This,
324   IN CONST EFI_STRING                            Request,
325        OUT EFI_STRING                            *Progress,
326        OUT EFI_STRING                            *Results
327   );
328 
329 /**
330   This function processes the results of changes in configuration.
331 
332   @param[in]  This               Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
333   @param[in]  Configuration      A null-terminated Unicode string in <ConfigResp>
334                                  format.
335   @param[out]  Progress          A pointer to a string filled in with the offset of
336                                  the most recent '&' before the first failing
337                                  name/value pair (or the beginning of the string if
338                                  the failure is in the first name/value pair) or
339                                  the terminating NULL if all was successful.
340 
341   @retval EFI_SUCCESS            The Results is processed successfully.
342   @retval EFI_INVALID_PARAMETER  Configuration is NULL.
343   @retval EFI_NOT_FOUND          Routing data doesn't match any storage in this
344                                  driver.
345 
346 **/
347 EFI_STATUS
348 EFIAPI
349 VlanRouteConfig (
350   IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL      *This,
351   IN CONST EFI_STRING                          Configuration,
352        OUT EFI_STRING                          *Progress
353   );
354 
355 /**
356   This function processes the results of changes in configuration.
357 
358   @param[in]  This               Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
359   @param[in]  Action             Specifies the type of action taken by the browser.
360   @param[in]  QuestionId         A unique value which is sent to the original
361                                  exporting driver so that it can identify the type
362                                  of data to expect.
363   @param[in]  Type               The type of value for the question.
364   @param[in]  Value              A pointer to the data being sent to the original
365                                  exporting driver.
366   @param[out] ActionRequest      On return, points to the action requested by the
367                                  callback function.
368 
369   @retval EFI_SUCCESS            The callback successfully handled the action.
370   @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the
371                                  variable and its data.
372   @retval EFI_DEVICE_ERROR       The variable could not be saved.
373   @retval EFI_UNSUPPORTED        The specified Action is not supported by the
374                                  callback.
375 
376 **/
377 EFI_STATUS
378 EFIAPI
379 VlanCallback (
380   IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL      *This,
381   IN     EFI_BROWSER_ACTION                    Action,
382   IN     EFI_QUESTION_ID                       QuestionId,
383   IN     UINT8                                 Type,
384   IN     EFI_IFR_TYPE_VALUE                    *Value,
385      OUT EFI_BROWSER_ACTION_REQUEST            *ActionRequest
386   );
387 
388 #endif
389