WebServer.h 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  1. /** @file
  2. Definitions for the web server.
  3. Copyright (c) 2011-2012, Intel Corporation
  4. All rights reserved. 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. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  10. **/
  11. #ifndef _WEB_SERVER_H_
  12. #define _WEB_SERVER_H_
  13. #include <errno.h>
  14. #include <Uefi.h>
  15. #include <Guid/EventGroup.h>
  16. #include <Library/BaseMemoryLib.h>
  17. #include <Library/DebugLib.h>
  18. #include <Library/MemoryAllocationLib.h>
  19. #include <Library/PcdLib.h>
  20. #include <Library/UefiApplicationEntryPoint.h>
  21. #include <Library/UefiBootServicesTableLib.h>
  22. #include <Library/UefiLib.h>
  23. #include <Protocol/BlockIo.h>
  24. #include <netinet/in.h>
  25. #include <sys/EfiSysCall.h>
  26. #include <sys/poll.h>
  27. #include <sys/socket.h>
  28. #if defined(_MSC_VER) // Handle Microsoft VC++ compiler specifics.
  29. #pragma warning ( disable : 4054 )
  30. #pragma warning ( disable : 4152 )
  31. #endif // defined(_MSC_VER)
  32. //------------------------------------------------------------------------------
  33. // Pages
  34. //------------------------------------------------------------------------------
  35. #define PAGE_ACPI_APIC L"/APIC"
  36. #define PAGE_ACPI_BGRT L"/BGRT"
  37. #define PAGE_ACPI_DSDT L"/DSDT"
  38. #define PAGE_ACPI_FADT L"/FADT"
  39. #define PAGE_ACPI_HPET L"/HPET"
  40. #define PAGE_ACPI_MCFG L"/MCFG"
  41. #define PAGE_ACPI_RSDP_10B L"/RSDP1.0b"
  42. #define PAGE_ACPI_RSDP_30 L"/RSDP3.0"
  43. #define PAGE_ACPI_RSDT L"/RSDT"
  44. #define PAGE_ACPI_SSDT L"/SSDT"
  45. #define PAGE_ACPI_TCPA L"/TCPA"
  46. #define PAGE_ACPI_UEFI L"/UEFI"
  47. #define PAGE_BOOT_SERVICES_TABLE L"/BootServicesTable"
  48. #define PAGE_CONFIGURATION_TABLE L"/ConfigurationTable"
  49. #define PAGE_DXE_SERVICES_TABLE L"/DxeServicesTable"
  50. #define PAGE_RUNTIME_SERVICES_TABLE L"/RuntimeServicesTable"
  51. //------------------------------------------------------------------------------
  52. // Signatures
  53. //------------------------------------------------------------------------------
  54. #define APIC_SIGNATURE 0x43495041
  55. #define BGRT_SIGNATURE 0x54524742
  56. #define DSDT_SIGNATURE 0x54445344
  57. #define FADT_SIGNATURE 0x50434146
  58. #define HPET_SIGNATURE 0x54455048
  59. #define MCFG_SIGNATURE 0x4746434d
  60. #define SSDT_SIGNATURE 0x54445353
  61. #define TCPA_SIGNATURE 0x41504354
  62. #define UEFI_SIGNATURE 0x49464555
  63. //------------------------------------------------------------------------------
  64. // Macros
  65. //------------------------------------------------------------------------------
  66. #if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
  67. #define DBG_ENTER() DEBUG (( DEBUG_INFO, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry
  68. #define DBG_EXIT() DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit
  69. #define DBG_EXIT_DEC(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value
  70. #define DBG_EXIT_HEX(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value
  71. #define DBG_EXIT_STATUS(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value
  72. #define DBG_EXIT_TF(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value
  73. #else // _MSC_VER
  74. #define DBG_ENTER()
  75. #define DBG_EXIT()
  76. #define DBG_EXIT_DEC(Status)
  77. #define DBG_EXIT_HEX(Status)
  78. #define DBG_EXIT_STATUS(Status)
  79. #define DBG_EXIT_TF(Status)
  80. #endif // _MSC_VER
  81. #define DIM(x) ( sizeof ( x ) / sizeof ( x[0] )) ///< Compute the number of entries in an array
  82. //------------------------------------------------------------------------------
  83. // Constants
  84. //------------------------------------------------------------------------------
  85. #define DEBUG_SOCKET_POLL 0x00080000 ///< Display the socket poll messages
  86. #define DEBUG_PORT_WORK 0x00040000 ///< Display the port work messages
  87. #define DEBUG_SERVER_LISTEN 0x00020000 ///< Display the socket poll messages
  88. #define DEBUG_HTTP_PORT 0x00010000 ///< Display HTTP port related messages
  89. #define DEBUG_REQUEST 0x00008000 ///< Display the HTTP request messages
  90. #define HTTP_PORT_POLL_DELAY ( 2 * 1000 ) ///< Delay in milliseconds for attempts to open the HTTP port
  91. #define CLIENT_POLL_DELAY 50 ///< Delay in milliseconds between client polls
  92. #define TPL_WEB_SERVER TPL_CALLBACK ///< TPL for routine synchronization
  93. /**
  94. Verify new TPL value
  95. This macro which is enabled when debug is enabled verifies that
  96. the new TPL value is >= the current TPL value.
  97. **/
  98. #ifdef VERIFY_TPL
  99. #undef VERIFY_TPL
  100. #endif // VERIFY_TPL
  101. #if !defined(MDEPKG_NDEBUG)
  102. #define VERIFY_TPL(tpl) \
  103. { \
  104. EFI_TPL PreviousTpl; \
  105. \
  106. PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \
  107. gBS->RestoreTPL ( PreviousTpl ); \
  108. if ( PreviousTpl > tpl ) { \
  109. DEBUG (( DEBUG_ERROR, "Current TPL: %d, New TPL: %d\r\n", PreviousTpl, tpl )); \
  110. ASSERT ( PreviousTpl <= tpl ); \
  111. } \
  112. }
  113. #else // MDEPKG_NDEBUG
  114. #define VERIFY_TPL(tpl)
  115. #endif // MDEPKG_NDEBUG
  116. #define WEB_SERVER_SIGNATURE SIGNATURE_32 ('W','e','b','S') ///< DT_WEB_SERVER memory signature
  117. #define SPACES_ADDRESS_TO_DATA 2
  118. #define BYTES_ON_A_LINE 16
  119. #define SPACES_BETWEEN_BYTES 1
  120. #define SPACES_DATA_TO_ASCII 2
  121. //------------------------------------------------------------------------------
  122. // Protocol Declarations
  123. //------------------------------------------------------------------------------
  124. extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; ///< Component name protocol declaration
  125. extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2; ///< Component name 2 protocol declaration
  126. extern EFI_DRIVER_BINDING_PROTOCOL gDriverBinding; ///< Driver binding protocol declaration
  127. //------------------------------------------------------------------------------
  128. // Data Types
  129. //------------------------------------------------------------------------------
  130. /**
  131. Port control structure
  132. **/
  133. typedef struct {
  134. //
  135. // Buffer management
  136. //
  137. size_t RequestLength; ///< Request length in bytes
  138. size_t TxBytes; ///< Bytes in the TX buffer
  139. UINT8 Request[ 65536 ]; ///< Page request
  140. UINT8 RxBuffer[ 65536 ]; ///< Receive buffer
  141. UINT8 TxBuffer[ 65536 ]; ///< Transmit buffer
  142. } WSDT_PORT;
  143. /**
  144. Web server control structure
  145. **/
  146. typedef struct {
  147. UINTN Signature; ///< Structure identification
  148. //
  149. // Image attributes
  150. //
  151. EFI_HANDLE ImageHandle; ///< Image handle
  152. //
  153. // HTTP port management
  154. //
  155. BOOLEAN bRunning; ///< Web server running
  156. EFI_EVENT TimerEvent; ///< Timer to open HTTP port
  157. int HttpListenPort; ///< File descriptor for the HTTP listen port over TCP4
  158. int HttpListenPort6; ///< File descriptor for the HTTP listen port over TCP6
  159. //
  160. // Client port management
  161. //
  162. nfds_t MaxEntries; ///< Maximum entries in the PortList array
  163. nfds_t Entries; ///< The current number of entries in the PortList array
  164. struct pollfd * pFdList; ///< List of socket file descriptors
  165. WSDT_PORT ** ppPortList; ///< List of port management structures
  166. } DT_WEB_SERVER;
  167. //#define SERVER_FROM_SERVICE(a) CR (a, DT_WEB_SERVER, ServiceBinding, WEB_SERVER_SIGNATURE) ///< Locate DT_LAYER from service binding
  168. extern DT_WEB_SERVER mWebServer;
  169. /**
  170. Process an HTTP request
  171. @param [in] SocketFD The socket's file descriptor to add to the list.
  172. @param [in] pPort The WSDT_PORT structure address
  173. @param [out] pbDone Address to receive the request completion status
  174. @retval EFI_SUCCESS The request was successfully processed
  175. **/
  176. typedef
  177. EFI_STATUS
  178. (* PFN_RESPONSE) (
  179. IN int SocketFD,
  180. IN WSDT_PORT * pPort,
  181. IN BOOLEAN * pbDone
  182. );
  183. /**
  184. Data structure to delcare page support routines
  185. **/
  186. typedef struct {
  187. UINT16 * pPageName; ///< Name of the page
  188. PFN_RESPONSE pfnResponse; ///< Routine to generate the response
  189. UINT16 * pDescription; ///< Description of the page
  190. } DT_PAGE;
  191. extern CONST DT_PAGE mPageList[]; ///< List of pages
  192. extern CONST UINTN mPageCount; ///< Number of pages
  193. //------------------------------------------------------------------------------
  194. // Web Pages
  195. //------------------------------------------------------------------------------
  196. /**
  197. Respond with the APIC table
  198. @param [in] SocketFD The socket's file descriptor to add to the list.
  199. @param [in] pPort The WSDT_PORT structure address
  200. @param [out] pbDone Address to receive the request completion status
  201. @retval EFI_SUCCESS The request was successfully processed
  202. **/
  203. EFI_STATUS
  204. AcpiApicPage (
  205. IN int SocketFD,
  206. IN WSDT_PORT * pPort,
  207. OUT BOOLEAN * pbDone
  208. );
  209. /**
  210. Respond with the BGRT table
  211. @param [in] SocketFD The socket's file descriptor to add to the list.
  212. @param [in] pPort The WSDT_PORT structure address
  213. @param [out] pbDone Address to receive the request completion status
  214. @retval EFI_SUCCESS The request was successfully processed
  215. **/
  216. EFI_STATUS
  217. AcpiBgrtPage (
  218. IN int SocketFD,
  219. IN WSDT_PORT * pPort,
  220. OUT BOOLEAN * pbDone
  221. );
  222. /**
  223. Respond with the ACPI DSDT table
  224. @param [in] SocketFD The socket's file descriptor to add to the list.
  225. @param [in] pPort The WSDT_PORT structure address
  226. @param [out] pbDone Address to receive the request completion status
  227. @retval EFI_SUCCESS The request was successfully processed
  228. **/
  229. EFI_STATUS
  230. AcpiDsdtPage (
  231. IN int SocketFD,
  232. IN WSDT_PORT * pPort,
  233. OUT BOOLEAN * pbDone
  234. );
  235. /**
  236. Respond with the ACPI FADT table
  237. @param [in] SocketFD The socket's file descriptor to add to the list.
  238. @param [in] pPort The WSDT_PORT structure address
  239. @param [out] pbDone Address to receive the request completion status
  240. @retval EFI_SUCCESS The request was successfully processed
  241. **/
  242. EFI_STATUS
  243. AcpiFadtPage (
  244. IN int SocketFD,
  245. IN WSDT_PORT * pPort,
  246. OUT BOOLEAN * pbDone
  247. );
  248. /**
  249. Respond with the HPET table
  250. @param [in] SocketFD The socket's file descriptor to add to the list.
  251. @param [in] pPort The WSDT_PORT structure address
  252. @param [out] pbDone Address to receive the request completion status
  253. @retval EFI_SUCCESS The request was successfully processed
  254. **/
  255. EFI_STATUS
  256. AcpiHpetPage (
  257. IN int SocketFD,
  258. IN WSDT_PORT * pPort,
  259. OUT BOOLEAN * pbDone
  260. );
  261. /**
  262. Respond with the MCFG table
  263. @param [in] SocketFD The socket's file descriptor to add to the list.
  264. @param [in] pPort The WSDT_PORT structure address
  265. @param [out] pbDone Address to receive the request completion status
  266. @retval EFI_SUCCESS The request was successfully processed
  267. **/
  268. EFI_STATUS
  269. AcpiMcfgPage (
  270. IN int SocketFD,
  271. IN WSDT_PORT * pPort,
  272. OUT BOOLEAN * pbDone
  273. );
  274. /**
  275. Respond with the ACPI RSDP 1.0b table
  276. @param [in] SocketFD The socket's file descriptor to add to the list.
  277. @param [in] pPort The WSDT_PORT structure address
  278. @param [out] pbDone Address to receive the request completion status
  279. @retval EFI_SUCCESS The request was successfully processed
  280. **/
  281. EFI_STATUS
  282. AcpiRsdp10Page (
  283. IN int SocketFD,
  284. IN WSDT_PORT * pPort,
  285. OUT BOOLEAN * pbDone
  286. );
  287. /**
  288. Respond with the ACPI RSDP 3.0 table
  289. @param [in] SocketFD The socket's file descriptor to add to the list.
  290. @param [in] pPort The WSDT_PORT structure address
  291. @param [out] pbDone Address to receive the request completion status
  292. @retval EFI_SUCCESS The request was successfully processed
  293. **/
  294. EFI_STATUS
  295. AcpiRsdp30Page (
  296. IN int SocketFD,
  297. IN WSDT_PORT * pPort,
  298. OUT BOOLEAN * pbDone
  299. );
  300. /**
  301. Respond with the ACPI RSDT table
  302. @param [in] SocketFD The socket's file descriptor to add to the list.
  303. @param [in] pPort The WSDT_PORT structure address
  304. @param [out] pbDone Address to receive the request completion status
  305. @retval EFI_SUCCESS The request was successfully processed
  306. **/
  307. EFI_STATUS
  308. AcpiRsdtPage (
  309. IN int SocketFD,
  310. IN WSDT_PORT * pPort,
  311. OUT BOOLEAN * pbDone
  312. );
  313. /**
  314. Respond with the SSDT table
  315. @param [in] SocketFD The socket's file descriptor to add to the list.
  316. @param [in] pPort The WSDT_PORT structure address
  317. @param [out] pbDone Address to receive the request completion status
  318. @retval EFI_SUCCESS The request was successfully processed
  319. **/
  320. EFI_STATUS
  321. AcpiSsdtPage (
  322. IN int SocketFD,
  323. IN WSDT_PORT * pPort,
  324. OUT BOOLEAN * pbDone
  325. );
  326. /**
  327. Respond with the TCPA table
  328. @param [in] SocketFD The socket's file descriptor to add to the list.
  329. @param [in] pPort The WSDT_PORT structure address
  330. @param [out] pbDone Address to receive the request completion status
  331. @retval EFI_SUCCESS The request was successfully processed
  332. **/
  333. EFI_STATUS
  334. AcpiTcpaPage (
  335. IN int SocketFD,
  336. IN WSDT_PORT * pPort,
  337. OUT BOOLEAN * pbDone
  338. );
  339. /**
  340. Respond with the UEFI table
  341. @param [in] SocketFD The socket's file descriptor to add to the list.
  342. @param [in] pPort The WSDT_PORT structure address
  343. @param [out] pbDone Address to receive the request completion status
  344. @retval EFI_SUCCESS The request was successfully processed
  345. **/
  346. EFI_STATUS
  347. AcpiUefiPage (
  348. IN int SocketFD,
  349. IN WSDT_PORT * pPort,
  350. OUT BOOLEAN * pbDone
  351. );
  352. /**
  353. Respond with the boot services table
  354. @param [in] SocketFD The socket's file descriptor to add to the list.
  355. @param [in] pPort The WSDT_PORT structure address
  356. @param [out] pbDone Address to receive the request completion status
  357. @retval EFI_SUCCESS The request was successfully processed
  358. **/
  359. EFI_STATUS
  360. BootServicesTablePage (
  361. IN int SocketFD,
  362. IN WSDT_PORT * pPort,
  363. OUT BOOLEAN * pbDone
  364. );
  365. /**
  366. Respond with the configuration tables
  367. @param [in] SocketFD The socket's file descriptor to add to the list.
  368. @param [in] pPort The WSDT_PORT structure address
  369. @param [out] pbDone Address to receive the request completion status
  370. @retval EFI_SUCCESS The request was successfully processed
  371. **/
  372. EFI_STATUS
  373. ConfigurationTablePage (
  374. IN int SocketFD,
  375. IN WSDT_PORT * pPort,
  376. OUT BOOLEAN * pbDone
  377. );
  378. /**
  379. Respond with the DHCP options
  380. @param [in] SocketFD The socket's file descriptor to add to the list.
  381. @param [in] pPort The WSDT_PORT structure address
  382. @param [out] pbDone Address to receive the request completion status
  383. @retval EFI_SUCCESS The request was successfully processed
  384. **/
  385. EFI_STATUS
  386. DhcpOptionsPage (
  387. IN int SocketFD,
  388. IN WSDT_PORT * pPort,
  389. OUT BOOLEAN * pbDone
  390. );
  391. /**
  392. Respond with the DXE services table
  393. @param [in] SocketFD The socket's file descriptor to add to the list.
  394. @param [in] pPort The WSDT_PORT structure address
  395. @param [out] pbDone Address to receive the request completion status
  396. @retval EFI_SUCCESS The request was successfully processed
  397. **/
  398. EFI_STATUS
  399. DxeServicesTablePage (
  400. IN int SocketFD,
  401. IN WSDT_PORT * pPort,
  402. OUT BOOLEAN * pbDone
  403. );
  404. /**
  405. Respond with the Exit page
  406. @param [in] SocketFD The socket's file descriptor to add to the list.
  407. @param [in] pPort The WSDT_PORT structure address
  408. @param [out] pbDone Address to receive the request completion status
  409. @retval EFI_SUCCESS The request was successfully processed
  410. **/
  411. EFI_STATUS
  412. ExitPage (
  413. IN int SocketFD,
  414. IN WSDT_PORT * pPort,
  415. OUT BOOLEAN * pbDone
  416. );
  417. /**
  418. Respond with the firmware status
  419. @param [in] SocketFD The socket's file descriptor to add to the list.
  420. @param [in] pPort The WSDT_PORT structure address
  421. @param [out] pbDone Address to receive the request completion status
  422. @retval EFI_SUCCESS The request was successfully processed
  423. **/
  424. EFI_STATUS
  425. FirmwarePage (
  426. IN int SocketFD,
  427. IN WSDT_PORT * pPort,
  428. OUT BOOLEAN * pbDone
  429. );
  430. /**
  431. Respond with the handles in the system
  432. @param [in] SocketFD The socket's file descriptor to add to the list.
  433. @param [in] pPort The WSDT_PORT structure address
  434. @param [out] pbDone Address to receive the request completion status
  435. @retval EFI_SUCCESS The request was successfully processed
  436. **/
  437. EFI_STATUS
  438. HandlePage (
  439. IN int SocketFD,
  440. IN WSDT_PORT * pPort,
  441. OUT BOOLEAN * pbDone
  442. );
  443. /**
  444. Respond with the Hello World page
  445. @param [in] SocketFD The socket's file descriptor to add to the list.
  446. @param [in] pPort The WSDT_PORT structure address
  447. @param [out] pbDone Address to receive the request completion status
  448. @retval EFI_SUCCESS The request was successfully processed
  449. **/
  450. EFI_STATUS
  451. HelloPage (
  452. IN int SocketFD,
  453. IN WSDT_PORT * pPort,
  454. OUT BOOLEAN * pbDone
  455. );
  456. /**
  457. Respond with the list of known pages
  458. @param [in] SocketFD The socket's file descriptor to add to the list.
  459. @param [in] pPort The WSDT_PORT structure address
  460. @param [out] pbDone Address to receive the request completion status
  461. @retval EFI_SUCCESS The request was successfully processed
  462. **/
  463. EFI_STATUS
  464. IndexPage (
  465. IN int SocketFD,
  466. IN WSDT_PORT * pPort,
  467. OUT BOOLEAN * pbDone
  468. );
  469. /**
  470. Page to display the memory map
  471. @param [in] SocketFD The socket's file descriptor to add to the list.
  472. @param [in] pPort The WSDT_PORT structure address
  473. @param [out] pbDone Address to receive the request completion status
  474. @retval EFI_SUCCESS The request was successfully processed
  475. **/
  476. EFI_STATUS
  477. MemoryMapPage (
  478. IN int SocketFD,
  479. IN WSDT_PORT * pPort,
  480. OUT BOOLEAN * pbDone
  481. );
  482. /**
  483. Display the memory type registers
  484. @param [in] SocketFD The socket's file descriptor to add to the list.
  485. @param [in] pPort The WSDT_PORT structure address
  486. @param [out] pbDone Address to receive the request completion status
  487. @retval EFI_SUCCESS The request was successfully processed
  488. **/
  489. EFI_STATUS
  490. MemoryTypeRegistersPage (
  491. IN int SocketFD,
  492. IN WSDT_PORT * pPort,
  493. OUT BOOLEAN * pbDone
  494. );
  495. /**
  496. Respond with the Ports page
  497. @param [in] SocketFD The socket's file descriptor to add to the list.
  498. @param [in] pPort The WSDT_PORT structure address
  499. @param [out] pbDone Address to receive the request completion status
  500. @retval EFI_SUCCESS The request was successfully processed
  501. **/
  502. EFI_STATUS
  503. PortsPage (
  504. IN int SocketFD,
  505. IN WSDT_PORT * pPort,
  506. OUT BOOLEAN * pbDone
  507. );
  508. /**
  509. Page to reboot the system
  510. @param [in] SocketFD The socket's file descriptor to add to the list.
  511. @param [in] pPort The WSDT_PORT structure address
  512. @param [out] pbDone Address to receive the request completion status
  513. @retval EFI_SUCCESS The request was successfully processed
  514. **/
  515. EFI_STATUS
  516. RebootPage (
  517. IN int SocketFD,
  518. IN WSDT_PORT * pPort,
  519. OUT BOOLEAN * pbDone
  520. );
  521. /**
  522. Respond with the runtime services table
  523. @param [in] SocketFD The socket's file descriptor to add to the list.
  524. @param [in] pPort The WSDT_PORT structure address
  525. @param [out] pbDone Address to receive the request completion status
  526. @retval EFI_SUCCESS The request was successfully processed
  527. **/
  528. EFI_STATUS
  529. RuntimeSservicesTablePage (
  530. IN int SocketFD,
  531. IN WSDT_PORT * pPort,
  532. OUT BOOLEAN * pbDone
  533. );
  534. /**
  535. Respond with the system table
  536. @param [in] SocketFD The socket's file descriptor to add to the list.
  537. @param [in] pPort The WSDT_PORT structure address
  538. @param [out] pbDone Address to receive the request completion status
  539. @retval EFI_SUCCESS The request was successfully processed
  540. **/
  541. EFI_STATUS
  542. SystemTablePage (
  543. IN int SocketFD,
  544. IN WSDT_PORT * pPort,
  545. OUT BOOLEAN * pbDone
  546. );
  547. //------------------------------------------------------------------------------
  548. // Support routines
  549. //------------------------------------------------------------------------------
  550. /**
  551. Display the EFI Table Header
  552. @param [in] SocketFD The socket's file descriptor to add to the list.
  553. @param [in] pPort The WSDT_PORT structure address
  554. @param [in] pHeader Address of the EFI_TABLE_HEADER structure
  555. @retval EFI_SUCCESS The request was successfully processed
  556. **/
  557. EFI_STATUS
  558. EfiTableHeader (
  559. IN int SocketFD,
  560. IN WSDT_PORT * pPort,
  561. IN EFI_TABLE_HEADER * pHeader
  562. );
  563. /**
  564. Buffer the HTTP page header
  565. @param [in] SocketFD The socket's file descriptor to add to the list.
  566. @param [in] pPort The WSDT_PORT structure address
  567. @param [in] pTitle A zero terminated Unicode title string
  568. @retval EFI_SUCCESS The request was successfully processed
  569. **/
  570. EFI_STATUS
  571. HttpPageHeader (
  572. IN int SocketFD,
  573. IN WSDT_PORT * pPort,
  574. IN CONST CHAR16 * pTitle
  575. );
  576. /**
  577. Buffer and send the HTTP page trailer
  578. @param [in] SocketFD The socket's file descriptor to add to the list.
  579. @param [in] pPort The WSDT_PORT structure address
  580. @param [out] pbDone Address to receive the request completion status
  581. @retval EFI_SUCCESS The request was successfully processed
  582. **/
  583. EFI_STATUS
  584. HttpPageTrailer (
  585. IN int SocketFD,
  586. IN WSDT_PORT * pPort,
  587. IN BOOLEAN * pbDone
  588. );
  589. /**
  590. Process an HTTP request
  591. @param [in] SocketFD The socket's file descriptor to add to the list.
  592. @param [in] pPort The WSDT_PORT structure address
  593. @param [out] pbDone Address to receive the request completion status
  594. @retval EFI_SUCCESS The request was successfully processed
  595. **/
  596. EFI_STATUS
  597. HttpRequest (
  598. IN int SocketFD,
  599. IN WSDT_PORT * pPort,
  600. IN BOOLEAN * pbDone
  601. );
  602. /**
  603. Buffer data for sending
  604. @param [in] SocketFD The socket's file descriptor to add to the list.
  605. @param [in] pPort The WSDT_PORT structure address
  606. @param [in] LengthInBytes Length of valid data in the buffer
  607. @param [in] pBuffer Buffer of data to send
  608. @retval EFI_SUCCESS The request was successfully processed
  609. **/
  610. EFI_STATUS
  611. HttpSend (
  612. IN int SocketFD,
  613. IN WSDT_PORT * pPort,
  614. IN size_t LengthInBytes,
  615. IN CONST UINT8 * pBuffer
  616. );
  617. /**
  618. Send an ANSI string
  619. @param [in] SocketFD The socket's file descriptor to add to the list.
  620. @param [in] pPort The WSDT_PORT structure address
  621. @param [in] pString A zero terminated Unicode string
  622. @retval EFI_SUCCESS The request was successfully processed
  623. **/
  624. EFI_STATUS
  625. HttpSendAnsiString (
  626. IN int SocketFD,
  627. IN WSDT_PORT * pPort,
  628. IN CONST char * pString
  629. );
  630. /**
  631. Buffer a single byte
  632. @param [in] SocketFD The socket's file descriptor to add to the list.
  633. @param [in] pPort The WSDT_PORT structure address
  634. @param [in] Data The data byte to send
  635. @retval EFI_SUCCESS The request was successfully processed
  636. **/
  637. EFI_STATUS
  638. HttpSendByte (
  639. IN int SocketFD,
  640. IN WSDT_PORT * pPort,
  641. IN UINT8 Data
  642. );
  643. /**
  644. Display a character
  645. @param [in] SocketFD The socket's file descriptor to add to the list.
  646. @param [in] pPort The WSDT_PORT structure address
  647. @param [in] Character Character to display
  648. @param [in] pReplacement Replacement character string
  649. @retval EFI_SUCCESS The request was successfully processed
  650. **/
  651. EFI_STATUS
  652. HttpSendCharacter (
  653. IN int SocketFD,
  654. IN WSDT_PORT * pPort,
  655. IN CHAR8 Character,
  656. IN CHAR8 * pReplacement
  657. );
  658. /**
  659. Send a buffer dump
  660. @param [in] SocketFD The socket's file descriptor to add to the list.
  661. @param [in] pPort The WSDT_PORT structure address
  662. @param [in] ByteCount The number of bytes to display
  663. @param [in] pData Address of the byte array
  664. @retval EFI_SUCCESS The request was successfully processed
  665. **/
  666. EFI_STATUS
  667. HttpSendDump (
  668. IN int SocketFD,
  669. IN WSDT_PORT * pPort,
  670. IN UINTN ByteCount,
  671. IN CONST UINT8 * pData
  672. );
  673. /**
  674. Display a row containing a GUID value
  675. @param [in] SocketFD The socket's file descriptor to add to the list.
  676. @param [in] pPort The WSDT_PORT structure address
  677. @param [in] pGuid Address of the GUID to display
  678. @retval EFI_SUCCESS The request was successfully processed
  679. **/
  680. EFI_STATUS
  681. HttpSendGuid (
  682. IN int SocketFD,
  683. IN WSDT_PORT * pPort,
  684. IN CONST EFI_GUID * pGuid
  685. );
  686. /**
  687. Output a hex value to the HTML page
  688. @param [in] SocketFD Socket file descriptor
  689. @param [in] pPort The WSDT_PORT structure address
  690. @param [in] Bits Number of bits to display
  691. @param [in] Value Value to display
  692. @retval EFI_SUCCESS Successfully displayed the address
  693. **/
  694. EFI_STATUS
  695. HttpSendHexBits (
  696. IN int SocketFD,
  697. IN WSDT_PORT * pPort,
  698. IN INT32 Bits,
  699. IN UINT64 Value
  700. );
  701. /**
  702. Output a hex value to the HTML page
  703. @param [in] SocketFD Socket file descriptor
  704. @param [in] pPort The WSDT_PORT structure address
  705. @param [in] Value Value to display
  706. @retval EFI_SUCCESS Successfully displayed the address
  707. **/
  708. EFI_STATUS
  709. HttpSendHexValue (
  710. IN int SocketFD,
  711. IN WSDT_PORT * pPort,
  712. IN UINT64 Value
  713. );
  714. /**
  715. Output an IP address to the HTML page
  716. @param [in] SocketFD Socket file descriptor
  717. @param [in] pPort The WSDT_PORT structure address
  718. @param [in] pAddress Address of the socket address
  719. @retval EFI_SUCCESS Successfully displayed the address
  720. **/
  721. EFI_STATUS
  722. HttpSendIpAddress (
  723. IN int SocketFD,
  724. IN WSDT_PORT * pPort,
  725. IN struct sockaddr_in6 * pAddress
  726. );
  727. /**
  728. Send a Unicode string
  729. @param [in] SocketFD The socket's file descriptor to add to the list.
  730. @param [in] pPort The WSDT_PORT structure address
  731. @param [in] pString A zero terminated Unicode string
  732. @retval EFI_SUCCESS The request was successfully processed
  733. **/
  734. EFI_STATUS
  735. HttpSendUnicodeString (
  736. IN int SocketFD,
  737. IN WSDT_PORT * pPort,
  738. IN CONST UINT16 * pString
  739. );
  740. /**
  741. Output a value to the HTML page
  742. @param [in] SocketFD Socket file descriptor
  743. @param [in] pPort The WSDT_PORT structure address
  744. @param [in] Value Value to display
  745. @retval EFI_SUCCESS Successfully displayed the address
  746. **/
  747. EFI_STATUS
  748. HttpSendValue (
  749. IN int SocketFD,
  750. IN WSDT_PORT * pPort,
  751. IN UINT64 Value
  752. );
  753. /**
  754. Display a row containing a decimal value
  755. @param [in] SocketFD The socket's file descriptor to add to the list.
  756. @param [in] pPort The WSDT_PORT structure address
  757. @param [in] pName Address of a zero terminated name string
  758. @param [in] Value The value to display
  759. @retval EFI_SUCCESS The request was successfully processed
  760. **/
  761. EFI_STATUS
  762. RowDecimalValue (
  763. IN int SocketFD,
  764. IN WSDT_PORT * pPort,
  765. IN CONST CHAR8 * pName,
  766. IN UINT64 Value
  767. );
  768. /**
  769. Display a row containing a GUID value
  770. @param [in] SocketFD The socket's file descriptor to add to the list.
  771. @param [in] pPort The WSDT_PORT structure address
  772. @param [in] pName Address of a zero terminated name string
  773. @param [in] pGuid Address of the GUID to display
  774. @retval EFI_SUCCESS The request was successfully processed
  775. **/
  776. EFI_STATUS
  777. RowGuid (
  778. IN int SocketFD,
  779. IN WSDT_PORT * pPort,
  780. IN CONST CHAR8 * pName,
  781. IN CONST EFI_GUID * pGuid
  782. );
  783. /**
  784. Display a row containing a hex value
  785. @param [in] SocketFD The socket's file descriptor to add to the list.
  786. @param [in] pPort The WSDT_PORT structure address
  787. @param [in] pName Address of a zero terminated name string
  788. @param [in] Value The value to display
  789. @param [in] pWebPage Address of a zero terminated web page name
  790. @retval EFI_SUCCESS The request was successfully processed
  791. **/
  792. EFI_STATUS
  793. RowHexValue (
  794. IN int SocketFD,
  795. IN WSDT_PORT * pPort,
  796. IN CONST CHAR8 * pName,
  797. IN UINT64 Value,
  798. IN CONST CHAR16 * pWebPage
  799. );
  800. /**
  801. Display a row containing a pointer
  802. @param [in] SocketFD The socket's file descriptor to add to the list.
  803. @param [in] pPort The WSDT_PORT structure address
  804. @param [in] pName Address of a zero terminated name string
  805. @param [in] pAddress The address to display
  806. @param [in] pWebPage Address of a zero terminated web page name
  807. @retval EFI_SUCCESS The request was successfully processed
  808. **/
  809. EFI_STATUS
  810. RowPointer (
  811. IN int SocketFD,
  812. IN WSDT_PORT * pPort,
  813. IN CONST CHAR8 * pName,
  814. IN CONST VOID * pAddress,
  815. IN CONST CHAR16 * pWebPage
  816. );
  817. /**
  818. Display a row containing a revision
  819. @param [in] SocketFD The socket's file descriptor to add to the list.
  820. @param [in] pPort The WSDT_PORT structure address
  821. @param [in] pName Address of a zero terminated name string
  822. @param [in] Revision The revision to display
  823. @retval EFI_SUCCESS The request was successfully processed
  824. **/
  825. EFI_STATUS
  826. RowRevision (
  827. IN int SocketFD,
  828. IN WSDT_PORT * pPort,
  829. IN CONST CHAR8 * pName,
  830. IN UINT32 Revision
  831. );
  832. /**
  833. Display a row containing a unicode string
  834. @param [in] SocketFD The socket's file descriptor to add to the list.
  835. @param [in] pPort The WSDT_PORT structure address
  836. @param [in] pName Address of a zero terminated name string
  837. @param [in] pString Address of a zero terminated unicode string
  838. @retval EFI_SUCCESS The request was successfully processed
  839. **/
  840. EFI_STATUS
  841. RowUnicodeString (
  842. IN int SocketFD,
  843. IN WSDT_PORT * pPort,
  844. IN CONST CHAR8 * pName,
  845. IN CONST CHAR16 * pString
  846. );
  847. /**
  848. Start the table page
  849. @param [in] SocketFD The socket's file descriptor to add to the list.
  850. @param [in] pPort The WSDT_PORT structure address
  851. @param [in] pName Address of a zero terminated name string
  852. @param [in] pTable Address of the table
  853. @retval EFI_SUCCESS The request was successfully processed
  854. **/
  855. EFI_STATUS
  856. TableHeader (
  857. IN int SocketFD,
  858. IN WSDT_PORT * pPort,
  859. IN CONST CHAR16 * pName,
  860. IN CONST VOID * pTable
  861. );
  862. /**
  863. End the table page
  864. @param [in] SocketFD The socket's file descriptor to add to the list.
  865. @param [in] pPort The WSDT_PORT structure address
  866. @param [out] pbDone Address to receive the request completion status
  867. @retval EFI_SUCCESS The request was successfully processed
  868. **/
  869. EFI_STATUS
  870. TableTrailer (
  871. IN int SocketFD,
  872. IN WSDT_PORT * pPort,
  873. OUT BOOLEAN *pbDone
  874. );
  875. /**
  876. HTTP port creation timer routine
  877. This routine polls the socket layer waiting for the initial network connection
  878. which will enable the creation of the HTTP port. The socket layer will manage
  879. the coming and going of the network connections after that until the last network
  880. connection is broken.
  881. @param [in] pWebServer The web server control structure address.
  882. **/
  883. VOID
  884. WebServerTimer (
  885. IN DT_WEB_SERVER * pWebServer
  886. );
  887. /**
  888. Start the web server port creation timer
  889. @param [in] pWebServer The web server control structure address.
  890. @retval EFI_SUCCESS The timer was successfully started.
  891. @retval EFI_ALREADY_STARTED The timer is already running.
  892. @retval Other The timer failed to start.
  893. **/
  894. EFI_STATUS
  895. WebServerTimerStart (
  896. IN DT_WEB_SERVER * pWebServer
  897. );
  898. /**
  899. Stop the web server port creation timer
  900. @param [in] pWebServer The web server control structure address.
  901. @retval EFI_SUCCESS The HTTP port timer is stopped
  902. @retval Other Failed to stop the HTTP port timer
  903. **/
  904. EFI_STATUS
  905. WebServerTimerStop (
  906. IN DT_WEB_SERVER * pWebServer
  907. );
  908. //------------------------------------------------------------------------------
  909. // Driver Binding Protocol Support
  910. //------------------------------------------------------------------------------
  911. /**
  912. Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and
  913. closing the DevicePath and PciIo protocols on Controller.
  914. @param [in] pThis Protocol instance pointer.
  915. @param [in] Controller Handle of device to stop driver on.
  916. @param [in] NumberOfChildren How many children need to be stopped.
  917. @param [in] pChildHandleBuffer Not used.
  918. @retval EFI_SUCCESS This driver is removed Controller.
  919. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
  920. @retval other This driver was not removed from this device.
  921. **/
  922. EFI_STATUS
  923. EFIAPI
  924. DriverStop (
  925. IN EFI_DRIVER_BINDING_PROTOCOL * pThis,
  926. IN EFI_HANDLE Controller,
  927. IN UINTN NumberOfChildren,
  928. IN EFI_HANDLE * pChildHandleBuffer
  929. );
  930. //------------------------------------------------------------------------------
  931. // EFI Component Name Protocol Support
  932. //------------------------------------------------------------------------------
  933. /**
  934. Retrieves a Unicode string that is the user readable name of the driver.
  935. This function retrieves the user readable name of a driver in the form of a
  936. Unicode string. If the driver specified by This has a user readable name in
  937. the language specified by Language, then a pointer to the driver name is
  938. returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
  939. by This does not support the language specified by Language,
  940. then EFI_UNSUPPORTED is returned.
  941. @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  942. EFI_COMPONENT_NAME_PROTOCOL instance.
  943. @param [in] pLanguage A pointer to a Null-terminated ASCII string
  944. array indicating the language. This is the
  945. language of the driver name that the caller is
  946. requesting, and it must match one of the
  947. languages specified in SupportedLanguages. The
  948. number of languages supported by a driver is up
  949. to the driver writer. Language is specified
  950. in RFC 3066 or ISO 639-2 language code format.
  951. @param [out] ppDriverName A pointer to the Unicode string to return.
  952. This Unicode string is the name of the
  953. driver specified by This in the language
  954. specified by Language.
  955. @retval EFI_SUCCESS The Unicode string for the Driver specified by
  956. This and the language specified by Language was
  957. returned in DriverName.
  958. @retval EFI_INVALID_PARAMETER Language is NULL.
  959. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  960. @retval EFI_UNSUPPORTED The driver specified by This does not support
  961. the language specified by Language.
  962. **/
  963. EFI_STATUS
  964. EFIAPI
  965. GetDriverName (
  966. IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
  967. IN CHAR8 * pLanguage,
  968. OUT CHAR16 ** ppDriverName
  969. );
  970. /**
  971. Retrieves a Unicode string that is the user readable name of the controller
  972. that is being managed by a driver.
  973. This function retrieves the user readable name of the controller specified by
  974. ControllerHandle and ChildHandle in the form of a Unicode string. If the
  975. driver specified by This has a user readable name in the language specified by
  976. Language, then a pointer to the controller name is returned in ControllerName,
  977. and EFI_SUCCESS is returned. If the driver specified by This is not currently
  978. managing the controller specified by ControllerHandle and ChildHandle,
  979. then EFI_UNSUPPORTED is returned. If the driver specified by This does not
  980. support the language specified by Language, then EFI_UNSUPPORTED is returned.
  981. @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  982. EFI_COMPONENT_NAME_PROTOCOL instance.
  983. @param [in] ControllerHandle The handle of a controller that the driver
  984. specified by This is managing. This handle
  985. specifies the controller whose name is to be
  986. returned.
  987. @param [in] ChildHandle The handle of the child controller to retrieve
  988. the name of. This is an optional parameter that
  989. may be NULL. It will be NULL for device
  990. drivers. It will also be NULL for a bus drivers
  991. that wish to retrieve the name of the bus
  992. controller. It will not be NULL for a bus
  993. driver that wishes to retrieve the name of a
  994. child controller.
  995. @param [in] pLanguage A pointer to a Null-terminated ASCII string
  996. array indicating the language. This is the
  997. language of the driver name that the caller is
  998. requesting, and it must match one of the
  999. languages specified in SupportedLanguages. The
  1000. number of languages supported by a driver is up
  1001. to the driver writer. Language is specified in
  1002. RFC 3066 or ISO 639-2 language code format.
  1003. @param [out] ppControllerName A pointer to the Unicode string to return.
  1004. This Unicode string is the name of the
  1005. controller specified by ControllerHandle and
  1006. ChildHandle in the language specified by
  1007. Language from the point of view of the driver
  1008. specified by This.
  1009. @retval EFI_SUCCESS The Unicode string for the user readable name in
  1010. the language specified by Language for the
  1011. driver specified by This was returned in
  1012. DriverName.
  1013. @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
  1014. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
  1015. EFI_HANDLE.
  1016. @retval EFI_INVALID_PARAMETER Language is NULL.
  1017. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  1018. @retval EFI_UNSUPPORTED The driver specified by This is not currently
  1019. managing the controller specified by
  1020. ControllerHandle and ChildHandle.
  1021. @retval EFI_UNSUPPORTED The driver specified by This does not support
  1022. the language specified by Language.
  1023. **/
  1024. EFI_STATUS
  1025. EFIAPI
  1026. GetControllerName (
  1027. IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
  1028. IN EFI_HANDLE ControllerHandle,
  1029. IN OPTIONAL EFI_HANDLE ChildHandle,
  1030. IN CHAR8 * pLanguage,
  1031. OUT CHAR16 ** ppControllerName
  1032. );
  1033. //------------------------------------------------------------------------------
  1034. #endif // _WEB_SERVER_H_