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