TlsAuthConfigImpl.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /** @file
  2. Header file of Miscellaneous Routines for TlsAuthConfigDxe driver.
  3. Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __TLS_AUTH_CONFIG_IMPL_H__
  7. #define __TLS_AUTH_CONFIG_IMPL_H__
  8. #include <Uefi.h>
  9. #include <Protocol/HiiConfigAccess.h>
  10. #include <Protocol/SimpleFileSystem.h>
  11. #include <Protocol/HiiPopup.h>
  12. //
  13. // Libraries
  14. //
  15. #include <Library/UefiBootServicesTableLib.h>
  16. #include <Library/UefiRuntimeServicesTableLib.h>
  17. #include <Library/MemoryAllocationLib.h>
  18. #include <Library/BaseMemoryLib.h>
  19. #include <Library/BaseLib.h>
  20. #include <Library/UefiLib.h>
  21. #include <Library/DebugLib.h>
  22. #include <Library/DevicePathLib.h>
  23. #include <Library/HiiLib.h>
  24. #include <Library/UefiHiiServicesLib.h>
  25. #include <Library/FileExplorerLib.h>
  26. #include <Library/PrintLib.h>
  27. #include <Guid/MdeModuleHii.h>
  28. #include <Guid/ImageAuthentication.h>
  29. #include <Guid/TlsAuthentication.h>
  30. //
  31. // Include files with function prototypes
  32. //
  33. #include "TlsAuthConfigNvData.h"
  34. extern UINT8 TlsAuthConfigDxeStrings[];
  35. extern UINT8 TlsAuthConfigVfrBin[];
  36. #define TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('T', 'A', 'C', 'D')
  37. #define TLS_AUTH_CONFIG_PRIVATE_FROM_THIS(a) CR (a, TLS_AUTH_CONFIG_PRIVATE_DATA, ConfigAccess, TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE)
  38. #define TLS_AUTH_CONFIG_VAR_BASE_ATTR (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
  39. typedef struct _TLS_AUTH_CONFIG_PRIVATE_DATA TLS_AUTH_CONFIG_PRIVATE_DATA;
  40. typedef struct _TLS_AUTH_CONFIG_FILE_CONTEXT TLS_AUTH_CONFIG_FILE_CONTEXT;
  41. ///
  42. /// HII specific Vendor Device Path definition.
  43. ///
  44. typedef struct {
  45. VENDOR_DEVICE_PATH VendorDevicePath;
  46. EFI_DEVICE_PATH_PROTOCOL End;
  47. } HII_VENDOR_DEVICE_PATH;
  48. struct _TLS_AUTH_CONFIG_FILE_CONTEXT {
  49. EFI_FILE_HANDLE FHandle;
  50. UINT16 *FileName;
  51. };
  52. struct _TLS_AUTH_CONFIG_PRIVATE_DATA {
  53. UINTN Signature;
  54. EFI_HANDLE DriverHandle;
  55. EFI_HII_HANDLE RegisteredHandle;
  56. EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
  57. TLS_AUTH_CONFIG_IFR_NVDATA TlsAuthConfigNvData;
  58. TLS_AUTH_CONFIG_FILE_CONTEXT *FileContext;
  59. EFI_GUID *CertGuid;
  60. };
  61. /**
  62. Unload the configuration form, this includes: delete all the configuration
  63. entries, uninstall the form callback protocol, and free the resources used.
  64. The form will only be unload completely when both IP4 and IP6 stack are stopped.
  65. @param[in] Private Pointer to the driver private data.
  66. @retval EFI_SUCCESS The configuration form is unloaded.
  67. @retval Others Failed to unload the form.
  68. **/
  69. EFI_STATUS
  70. TlsAuthConfigFormUnload (
  71. IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
  72. );
  73. /**
  74. Initialize the configuration form.
  75. @param[in] Private Pointer to the driver private data.
  76. @retval EFI_SUCCESS The configuration form is initialized.
  77. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
  78. **/
  79. EFI_STATUS
  80. TlsAuthConfigFormInit (
  81. IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
  82. );
  83. /**
  84. This function allows the caller to request the current
  85. configuration for one or more named elements. The resulting
  86. string is in <ConfigAltResp> format. Any and all alternative
  87. configuration strings shall also be appended to the end of the
  88. current configuration string. If they are, they must appear
  89. after the current configuration. They must contain the same
  90. routing (GUID, NAME, PATH) as the current configuration string.
  91. They must have an additional description indicating the type of
  92. alternative configuration the string represents,
  93. "ALTCFG=<StringToken>". That <StringToken> (when
  94. converted from Hex UNICODE to binary) is a reference to a
  95. string in the associated string pack.
  96. @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
  97. @param Request A null-terminated Unicode string in
  98. <ConfigRequest> format. Note that this
  99. includes the routing information as well as
  100. the configurable name / value pairs. It is
  101. invalid for this string to be in
  102. <MultiConfigRequest> format.
  103. If a NULL is passed in for the Request field,
  104. all of the settings being abstracted by this function
  105. will be returned in the Results field. In addition,
  106. if a ConfigHdr is passed in with no request elements,
  107. all of the settings being abstracted for that particular
  108. ConfigHdr reference will be returned in the Results Field.
  109. @param Progress On return, points to a character in the
  110. Request string. Points to the string's null
  111. terminator if request was successful. Points
  112. to the most recent "&" before the first
  113. failing name / value pair (or the beginning
  114. of the string if the failure is in the first
  115. name / value pair) if the request was not
  116. successful.
  117. @param Results A null-terminated Unicode string in
  118. <MultiConfigAltResp> format which has all values
  119. filled in for the names in the Request string.
  120. String to be allocated by the called function.
  121. @retval EFI_SUCCESS The Results string is filled with the
  122. values corresponding to all requested
  123. names.
  124. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
  125. parts of the results that must be
  126. stored awaiting possible future
  127. protocols.
  128. @retval EFI_NOT_FOUND Routing data doesn't match any
  129. known driver. Progress set to the
  130. first character in the routing header.
  131. Note: There is no requirement that the
  132. driver validate the routing data. It
  133. must skip the <ConfigHdr> in order to
  134. process the names.
  135. @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set
  136. to most recent "&" before the
  137. error or the beginning of the
  138. string.
  139. @retval EFI_INVALID_PARAMETER Unknown name. Progress points
  140. to the & before the name in
  141. question.
  142. **/
  143. EFI_STATUS
  144. EFIAPI
  145. TlsAuthConfigAccessExtractConfig (
  146. IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
  147. IN CONST EFI_STRING Request,
  148. OUT EFI_STRING *Progress,
  149. OUT EFI_STRING *Results
  150. );
  151. /**
  152. This function applies changes in a driver's configuration.
  153. Input is a Configuration, which has the routing data for this
  154. driver followed by name / value configuration pairs. The driver
  155. must apply those pairs to its configurable storage. If the
  156. driver's configuration is stored in a linear block of data
  157. and the driver's name / value pairs are in <BlockConfig>
  158. format, it may use the ConfigToBlock helper function (above) to
  159. simplify the job.
  160. @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
  161. @param Configuration A null-terminated Unicode string in
  162. <ConfigString> format.
  163. @param Progress A pointer to a string filled in with the
  164. offset of the most recent '&' before the
  165. first failing name / value pair (or the
  166. beginning of the string if the failure
  167. is in the first name / value pair) or
  168. the terminating NULL if all was
  169. successful.
  170. @retval EFI_SUCCESS The results have been distributed or are
  171. awaiting distribution.
  172. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
  173. parts of the results that must be
  174. stored awaiting possible future
  175. protocols.
  176. @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
  177. Results parameter would result
  178. in this type of error.
  179. @retval EFI_NOT_FOUND Target for the specified routing data
  180. was not found
  181. **/
  182. EFI_STATUS
  183. EFIAPI
  184. TlsAuthConfigAccessRouteConfig (
  185. IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
  186. IN CONST EFI_STRING Configuration,
  187. OUT EFI_STRING *Progress
  188. );
  189. /**
  190. This function is called to provide results data to the driver.
  191. This data consists of a unique key that is used to identify
  192. which data is either being passed back or being asked for.
  193. @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
  194. @param Action Specifies the type of action taken by the browser.
  195. @param QuestionId A unique value which is sent to the original
  196. exporting driver so that it can identify the type
  197. of data to expect. The format of the data tends to
  198. vary based on the opcode that generated the callback.
  199. @param Type The type of value for the question.
  200. @param Value A pointer to the data being sent to the original
  201. exporting driver.
  202. @param ActionRequest On return, points to the action requested by the
  203. callback function.
  204. @retval EFI_SUCCESS The callback successfully handled the action.
  205. @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
  206. variable and its data.
  207. @retval EFI_DEVICE_ERROR The variable could not be saved.
  208. @retval EFI_UNSUPPORTED The specified Action is not supported by the
  209. callback.
  210. **/
  211. EFI_STATUS
  212. EFIAPI
  213. TlsAuthConfigAccessCallback (
  214. IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
  215. IN EFI_BROWSER_ACTION Action,
  216. IN EFI_QUESTION_ID QuestionId,
  217. IN UINT8 Type,
  218. IN OUT EFI_IFR_TYPE_VALUE *Value,
  219. OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
  220. );
  221. #endif