summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-05 22:41:30 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-05 22:41:30 +0000
commitf051ed20e8b9559ef321022a9030bab777032716 (patch)
tree673268a0f21781434f2c4cac68007f9c70a81e40
parent817a79f5fea9b88f4e05c4465c491e3c246c04d4 (diff)
downloadedk2-f051ed20e8b9559ef321022a9030bab777032716.zip
edk2-f051ed20e8b9559ef321022a9030bab777032716.tar.gz
edk2-f051ed20e8b9559ef321022a9030bab777032716.tar.bz2
Add memory map display
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/SocketDev@13078 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--AppPkg/Applications/Sockets/WebServer/MemoryMap.c364
-rw-r--r--AppPkg/Applications/Sockets/WebServer/PageList.c1
-rw-r--r--AppPkg/Applications/Sockets/WebServer/WebServer.h17
-rw-r--r--AppPkg/Applications/Sockets/WebServer/WebServer.inf2
4 files changed, 384 insertions, 0 deletions
diff --git a/AppPkg/Applications/Sockets/WebServer/MemoryMap.c b/AppPkg/Applications/Sockets/WebServer/MemoryMap.c
new file mode 100644
index 0000000..72c1cec
--- /dev/null
+++ b/AppPkg/Applications/Sockets/WebServer/MemoryMap.c
@@ -0,0 +1,364 @@
+/*++
+ This file contains an 'Intel UEFI Application' and is
+ licensed for Intel CPUs and chipsets under the terms of your
+ license agreement with Intel or your vendor. This file may
+ be modified by the user, subject to additional terms of the
+ license agreement
+--*/
+/*++
+
+Copyright (c) 2012 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+--*/
+
+/** @file
+ Display the memory map
+
+**/
+
+#include <WebServer.h>
+#include <PiDxe.h>
+#include <Library/DxeServicesTableLib.h>
+
+
+CONST char * mpMemoryType[ ] = {
+ "Non-existent",
+ "Reserved",
+ "System Memory",
+ "Memory Mapped I/O"
+};
+
+
+/**
+ Page to display the memory map
+
+ @param [in] SocketFD The socket's file descriptor to add to the list.
+ @param [in] pPort The WSDT_PORT structure address
+ @param [out] pbDone Address to receive the request completion status
+
+ @retval EFI_SUCCESS The request was successfully processed
+
+**/
+EFI_STATUS
+MemoryMapPage (
+ IN int SocketFD,
+ IN WSDT_PORT * pPort,
+ OUT BOOLEAN * pbDone
+ )
+{
+ UINT64 Attributes;
+ BOOLEAN bSomethingDisplayed;
+ UINTN Count;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR * pMemoryEnd;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR * pMemoryDescriptor;
+ EFI_STATUS Status;
+
+ DBG_ENTER ( );
+
+ //
+ // Send the memory map page
+ //
+ for ( ; ; ) {
+ //
+ // Send the page header
+ //
+ Status = HttpPageHeader ( SocketFD, pPort, L"Memory Map" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+
+ //
+ // Start the table
+ //
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "<h1>Memory Map</h1>\r\n"
+ "<table>\r\n"
+ " <tr><th align=\"right\">Type</th><th align=\"right\">Start</th><th align=\"right\">End</th><th align=\"right\">Attributes</th></tr>\r\n" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+
+ //
+ // Get the memory map
+ //
+ Status = gDS->GetMemorySpaceMap ( &Count,
+ &pMemoryDescriptor );
+ if ( !EFI_ERROR ( Status )) {
+ pMemoryEnd = &pMemoryDescriptor[ Count ];
+ while ( pMemoryEnd > pMemoryDescriptor ) {
+ //
+ // Display the type
+ //
+ Status = HttpSendAnsiString ( SocketFD, pPort, "<tr><td align=\"right\"><code>" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ if ( DIM ( mpMemoryType ) > pMemoryDescriptor->GcdMemoryType ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ mpMemoryType[ pMemoryDescriptor->GcdMemoryType ]);
+ }
+ else {
+ Status = HttpSendValue ( SocketFD,
+ pPort,
+ pMemoryDescriptor->GcdMemoryType );
+ }
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+
+ //
+ // Display the start address
+ //
+ Status = HttpSendAnsiString ( SocketFD, pPort, "</code></td><td align=\"right\"><code>0x" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ Status = HttpSendHexValue ( SocketFD,
+ pPort,
+ pMemoryDescriptor->BaseAddress );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+
+ //
+ // Display the end address
+ //
+ Status = HttpSendAnsiString ( SocketFD, pPort, "</code></td><td align=\"right\"><code>0x" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ Status = HttpSendHexValue ( SocketFD,
+ pPort,
+ pMemoryDescriptor->BaseAddress
+ + pMemoryDescriptor->Length
+ - 1 );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+
+ //
+ // Display the attributes
+ //
+ Status = HttpSendAnsiString ( SocketFD, pPort, "</code></td><td align=\"right\"><code>0x" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ Status = HttpSendHexValue ( SocketFD,
+ pPort,
+ pMemoryDescriptor->Attributes );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+
+ //
+ // Decode the attributes
+ //
+ Status = HttpSendAnsiString ( SocketFD, pPort, "</code></td><td>" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ bSomethingDisplayed = FALSE;
+ Attributes = pMemoryDescriptor->Attributes;
+
+ if ( 0 != ( Attributes & EFI_MEMORY_RUNTIME )) {
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "Runtime" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+ if ( 0 != ( Attributes & EFI_MEMORY_XP )) {
+ if ( bSomethingDisplayed ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ ", " );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "No Execute" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+ if ( 0 != ( Attributes & EFI_MEMORY_RP )) {
+ if ( bSomethingDisplayed ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ ", " );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "No Read" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+ if ( 0 != ( Attributes & EFI_MEMORY_WP )) {
+ if ( bSomethingDisplayed ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ ", " );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "No Write" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+ if ( 0 != ( Attributes & EFI_MEMORY_UCE )) {
+ if ( bSomethingDisplayed ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ ", " );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "UCE" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+
+ if ( 0 != ( Attributes & EFI_MEMORY_WB )) {
+ if ( bSomethingDisplayed ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ ", " );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "Write Back" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+ if ( 0 != ( Attributes & EFI_MEMORY_WT )) {
+ if ( bSomethingDisplayed ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ ", " );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "Write Through" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+ if ( 0 != ( Attributes & EFI_MEMORY_WC )) {
+ if ( bSomethingDisplayed ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ ", " );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "Write Combining" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+ if ( 0 != ( Attributes & EFI_MEMORY_UC )) {
+ if ( bSomethingDisplayed ) {
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ ", " );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ bSomethingDisplayed = TRUE;
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "Uncached" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+
+ //
+ // Finish the row
+ //
+ Status = HttpSendAnsiString ( SocketFD, pPort, "</td></tr>" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+
+ //
+ // Set the next memory descriptor
+ //
+ pMemoryDescriptor += 1;
+ }
+ }
+
+ //
+ // Finish the table
+ //
+ Status = HttpSendAnsiString ( SocketFD,
+ pPort,
+ "</table>\r\n" );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+
+ //
+ // Send the page trailer
+ //
+ Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
+ break;
+ }
+
+ //
+ // Return the operation status
+ //
+ DBG_EXIT_STATUS ( Status );
+ return Status;
+}
diff --git a/AppPkg/Applications/Sockets/WebServer/PageList.c b/AppPkg/Applications/Sockets/WebServer/PageList.c
index 98927e8..8c40ed5 100644
--- a/AppPkg/Applications/Sockets/WebServer/PageList.c
+++ b/AppPkg/Applications/Sockets/WebServer/PageList.c
@@ -49,6 +49,7 @@ CONST DT_PAGE mPageList[] = {
{ L"/Firmware", FirmwarePage, L"Firmware" }, ///< Firmware status
{ L"/Handles", HandlePage, L"Display handles and associated protocol GUIDs" }, ///< Handle database page
{ L"/Hello", HelloPage, L"Hello World" }, ///< Hello world page
+ { L"/MemoryMap", MemoryMapPage, L"Memory Map" }, ///< Memory list
{ L"/Ports", PortsPage, L"Display web-server ports" },///< Web-server ports page
{ L"/Reboot", RebootPage, L"Reboot the sytem" }, ///< Reboot page
{ PAGE_ACPI_RSDP_10B, AcpiRsdp10Page, L"RSDP 1.0b - ACPI Root System Description Pointer" }, ///< Format RSDP 1.0b table
diff --git a/AppPkg/Applications/Sockets/WebServer/WebServer.h b/AppPkg/Applications/Sockets/WebServer/WebServer.h
index 48839f3..7b2c5d7 100644
--- a/AppPkg/Applications/Sockets/WebServer/WebServer.h
+++ b/AppPkg/Applications/Sockets/WebServer/WebServer.h
@@ -466,6 +466,23 @@ IndexPage (
);
/**
+ Page to display the memory map
+
+ @param [in] SocketFD The socket's file descriptor to add to the list.
+ @param [in] pPort The WSDT_PORT structure address
+ @param [out] pbDone Address to receive the request completion status
+
+ @retval EFI_SUCCESS The request was successfully processed
+
+**/
+EFI_STATUS
+MemoryMapPage (
+ IN int SocketFD,
+ IN WSDT_PORT * pPort,
+ OUT BOOLEAN * pbDone
+ );
+
+/**
Respond with the Ports page
@param [in] SocketFD The socket's file descriptor to add to the list.
diff --git a/AppPkg/Applications/Sockets/WebServer/WebServer.inf b/AppPkg/Applications/Sockets/WebServer/WebServer.inf
index c250007..a492760 100644
--- a/AppPkg/Applications/Sockets/WebServer/WebServer.inf
+++ b/AppPkg/Applications/Sockets/WebServer/WebServer.inf
@@ -46,6 +46,7 @@
Hello.c
HTTP.c
Index.c
+ MemoryMap.c
PageList.c
Ports.c
Reboot.c
@@ -70,6 +71,7 @@
BsdSocketLib
DebugLib
DevShell
+ DxeServicesTableLib
EfiSocketLib
LibC
ShellLib