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