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