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