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