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