VlanConfigImpl.h 16 KB

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