]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/WebServer/Handles.c
2 This file contains an 'Intel UEFI Application' and is
3 licensed for Intel CPUs and chipsets under the terms of your
4 license agreement with Intel or your vendor. This file may
5 be modified by the user, subject to additional terms of the
10 Copyright (c) 2011 Intel Corporation. All rights reserved
11 This software and associated documentation (if any) is furnished
12 under a license and may only be used or copied in accordance
13 with the terms of the license. Except as permitted by such
14 license, no part of this software or documentation may be
15 reproduced, stored in a retrieval system, or transmitted in any
16 form or by any means without the express written consent of
22 Display the handles in the system
26 #include <WebServer.h>
30 Respond with the handles in the system
32 @param [in] SocketFD The socket's file descriptor to add to the list.
33 @param [in] pPort The WSDT_PORT structure address
34 @param [out] pbDone Address to receive the request completion status
36 @retval EFI_SUCCESS The request was successfully processed
52 EFI_HANDLE
* pHandleArray
;
54 EFI_HANDLE
* pHandleEnd
;
55 EFI_GUID
** ppGuidArray
;
57 EFI_GUID
** ppGuidEnd
;
61 CONST UINTN cDigit
[] = {
62 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 };
67 // Send the handles page
71 // Send the page header
73 Status
= HttpPageHeader ( SocketFD
, pPort
, L
"Handle Database" );
74 if ( EFI_ERROR ( Status
)) {
79 // Build the table header
81 Status
= HttpSendAnsiString ( SocketFD
,
83 "<h1>Handle Database</h1>\r\n"
84 "<table border=\"1\">\r\n"
85 " <tr bgcolor=\"c0c0ff\"><th>Handle</th><th>Protocol Guids</th></tr>\r\n" );
86 if ( EFI_ERROR ( Status
)) {
91 // Determine the number of handles in the database
94 Status
= gBS
->LocateHandle ( AllHandles
,
99 if ( EFI_BUFFER_TOO_SMALL
== Status
) {
101 // Allocate space for the handles
103 Status
= gBS
->AllocatePool ( EfiRuntimeServicesData
,
105 (VOID
**) &pHandleArray
);
106 if ( !EFI_ERROR ( Status
)) {
108 // Get the list of handles
110 Status
= gBS
->LocateHandle ( AllHandles
,
115 if ( !EFI_ERROR ( Status
)) {
116 Entries
= LengthInBytes
/ sizeof ( *pHandleArray
);
117 pHandle
= pHandleArray
;
118 pHandleEnd
= &pHandle
[ Entries
];
119 while ( pHandleEnd
> pHandle
) {
121 // Build the table entry for this page
123 Status
= HttpSendAnsiString ( SocketFD
,
125 "<tr><td><code>0x" );
126 if ( EFI_ERROR ( Status
)) {
129 Value
= (UINTN
) *pHandle
;
130 for ( Shift
= ( sizeof ( Shift
) << 3 ) - 4; 0 <= Shift
; Shift
-= 4 ) {
132 // Convert the next address nibble to ANSI hex
134 Digit
= (( Value
>> Shift
) & 0xf ) | '0';
136 Digit
+= 'a' - '0' - 10;
140 // Display the address digit
142 Status
= HttpSendByte ( SocketFD
,
145 if ( EFI_ERROR ( Status
)) {
149 if ( EFI_ERROR ( Status
)) {
154 // Start the second column
156 Status
= HttpSendAnsiString ( SocketFD
,
158 "</code></td><td><code>\r\n" );
159 if ( EFI_ERROR ( Status
)) {
164 // Determine the number of protocols connected to this handle
166 Status
= gBS
->ProtocolsPerHandle ( *pHandle
,
169 if ( EFI_ERROR ( Status
)) {
172 ppGuid
= ppGuidArray
;
173 ppGuidEnd
= &ppGuid
[ GuidCount
];
174 while ( ppGuidEnd
> ppGuid
) {
178 pDigit
= (UINT8
*) *ppGuid
;
179 for ( Index
= 0; 16 > Index
; Index
++ ) {
181 // Separate the portions of the GUID
182 // 99E87DCF-6162-40c5-9FA1-32111F5197F7
187 || ( 10 == Index
)) {
188 Status
= HttpSendByte ( SocketFD
,
191 if ( EFI_ERROR ( Status
)) {
197 // Display the GUID digits
199 Value
= pDigit
[ cDigit
[ Index
]];
200 for ( Shift
= 4; 0 <= Shift
; Shift
-= 4 ) {
202 // Convert the next address nibble to ANSI hex
204 Digit
= (( Value
>> Shift
) & 0xf ) | '0';
206 Digit
+= 'a' - '0' - 10;
210 // Display the address digit
212 Status
= HttpSendByte ( SocketFD
,
215 if ( EFI_ERROR ( Status
)) {
219 if ( EFI_ERROR ( Status
)) {
225 // Separate each GUID
227 Status
= HttpSendAnsiString ( SocketFD
,
230 if ( EFI_ERROR ( Status
)) {
235 // Set the next protocol
241 // Free the GUID array
243 gBS
->FreePool ( ppGuidArray
);
244 if ( EFI_ERROR ( Status
)) {
251 Status
= HttpSendAnsiString ( SocketFD
,
253 "</code></td></tr>\r\n" );
254 if ( EFI_ERROR ( Status
)) {
259 // Set the next handle
266 // Done with the handle array
268 gBS
->FreePool ( pHandleArray
);
273 // Build the table trailer
275 Status
= HttpSendAnsiString ( SocketFD
,
278 if ( EFI_ERROR ( Status
)) {
283 // Send the page trailer
285 Status
= HttpPageTrailer ( SocketFD
, pPort
, pbDone
);
290 // Return the operation status
292 DBG_EXIT_STATUS ( Status
);