public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/1] MdeModulePkg/EbcDxe: add EBC Debugger configuration application
@ 2016-11-24 11:29 Pete Batard
  2016-11-24 11:29 ` [PATCH 1/1] " Pete Batard
  0 siblings, 1 reply; 4+ messages in thread
From: Pete Batard @ 2016-11-24 11:29 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jiewen Yao, Pete Batard

This patch adds the UEFI Shell configuration application for the EBC Debugger.
The source for the original Tianocore app can be found at:
  https://github.com/jyao1/EbcDebuggerApp

The changes from the original sources mostly had to do with:
* Using ShellCEntryLib to parse the Shell arguments.
* Returning Shell error codes instead of EFI ones.

You'll notice that the required Shell library dependencies have been added in
MdeModulePkg.dsc under [LibraryClasses.common.UEFI_APPLICATION].

I validated that the generated application compiled successfully for IA32 and
X64 (VS2015/Windows) and could switch breakpoints on or off when used against
a recompiled version of the EBC Debugger.

I also believe that the patch should apply cleanly on top of the recent change
proposal for the EBC Debugger.

Regards,

/Pete

Pete Batard (1):
  MdeModulePkg/EbcDxe: add EBC Debugger configuration application

 .../Include/Protocol/DebuggerConfiguration.h       |  32 ++++
 MdeModulePkg/MdeModulePkg.dec                      |   4 +
 MdeModulePkg/MdeModulePkg.dsc                      |   4 +
 MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf      |   1 +
 .../EbcDxe/EbcDebugger/EbcDebuggerConfig.c         | 207 +++++++++++++++++++++
 MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c    |   4 +
 .../Universal/EbcDxe/EbcDebugger/EdbCommon.h       |   3 +
 .../Universal/EbcDxe/EbcDebugger/EdbHook.c         |  11 ++
 .../Universal/EbcDxe/EbcDebuggerConfig.inf         |  57 ++++++
 .../Universal/EbcDxe/EbcDebuggerConfig.uni         |  18 ++
 .../Universal/EbcDxe/EbcDebuggerConfigExtra.uni    |  17 ++
 11 files changed, 358 insertions(+)
 create mode 100644 MdeModulePkg/Include/Protocol/DebuggerConfiguration.h
 create mode 100644 MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
 create mode 100644 MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
 create mode 100644 MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni
 create mode 100644 MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni

-- 
2.9.3.windows.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] MdeModulePkg/EbcDxe: add EBC Debugger configuration application
  2016-11-24 11:29 [PATCH 0/1] MdeModulePkg/EbcDxe: add EBC Debugger configuration application Pete Batard
@ 2016-11-24 11:29 ` Pete Batard
  2016-11-24 12:40   ` Yao, Jiewen
  0 siblings, 1 reply; 4+ messages in thread
From: Pete Batard @ 2016-11-24 11:29 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jiewen Yao, Pete Batard

* Introduce a generic Debugger Configuration protocol.
* Add private configuration data in the EBC Debugger and make it
  register the Debugger Configuration protocol on initialization.
* Add a shell application that uses the protocol above to access
  the private data in order to configure the EBC debugger.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Pete Batard <pete@akeo.ie>
---
 .../Include/Protocol/DebuggerConfiguration.h       |  32 ++++
 MdeModulePkg/MdeModulePkg.dec                      |   4 +
 MdeModulePkg/MdeModulePkg.dsc                      |   4 +
 MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf      |   1 +
 .../EbcDxe/EbcDebugger/EbcDebuggerConfig.c         | 207 +++++++++++++++++++++
 MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c    |   4 +
 .../Universal/EbcDxe/EbcDebugger/EdbCommon.h       |   3 +
 .../Universal/EbcDxe/EbcDebugger/EdbHook.c         |  11 ++
 .../Universal/EbcDxe/EbcDebuggerConfig.inf         |  57 ++++++
 .../Universal/EbcDxe/EbcDebuggerConfig.uni         |  18 ++
 .../Universal/EbcDxe/EbcDebuggerConfigExtra.uni    |  17 ++
 11 files changed, 358 insertions(+)
 create mode 100644 MdeModulePkg/Include/Protocol/DebuggerConfiguration.h
 create mode 100644 MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
 create mode 100644 MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
 create mode 100644 MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni
 create mode 100644 MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni

diff --git a/MdeModulePkg/Include/Protocol/DebuggerConfiguration.h b/MdeModulePkg/Include/Protocol/DebuggerConfiguration.h
new file mode 100644
index 000000000000..eaaa6b925fad
--- /dev/null
+++ b/MdeModulePkg/Include/Protocol/DebuggerConfiguration.h
@@ -0,0 +1,32 @@
+/** @file
+  EBC Debugger configuration protocol.
+
+  Copyright (c) 2007-2016, Intel Corporation. All rights reserved.<BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions
+  of the BSD License which accompanies this distribution.  The
+  full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __EFI_DEBUGGER_CONFIGURATION_H__
+#define __EFI_DEBUGGER_CONFIGURATION_H__
+
+#define EFI_DEBUGGER_CONFIGURATION_PROTOCOL_GUID \
+  { 0x577d959c, 0xe967, 0x4546, 0x86, 0x20, 0xc7, 0x78, 0xfa, 0xe5, 0xda, 0x5 }
+
+#define EFI_DEBUGGER_CONFIGURATION_VERSION  0x00000001
+
+typedef struct _EFI_DEBUGGER_CONFIGURATION_PROTOCOL {
+  UINT32                      DebuggerConfigurationRevision;
+  VOID                        *DebuggerPrivateData;
+} EFI_DEBUGGER_CONFIGURATION_PROTOCOL;
+
+extern EFI_GUID gEfiDebuggerConfigurationProtocolGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 22898e3f7487..08c3e40e930c 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -420,6 +420,10 @@ [Protocols]
   # Include/Protocol/GenericMemoryTest.h
   gEfiGenericMemTestProtocolGuid = { 0x309DE7F1, 0x7F5E, 0x4ACE, { 0xB4, 0x9C, 0x53, 0x1B, 0xE5, 0xAA, 0x95, 0xEF }}
 
+  ## This protocol defines the Debugger Configuration protocol.
+  # Include/Protocol/DebuggerConfiguration.h
+  gEfiDebuggerConfigurationProtocolGuid = { 0x577d959c, 0xe967, 0x4546, { 0x86, 0x20, 0xc7, 0x78, 0xfa, 0xe5, 0xda, 0x05 }}
+
   ## Include/Protocol/Dpc.h
   gEfiDpcProtocolGuid            = {0x480f8ae9, 0xc46, 0x4aa9,  { 0xbc, 0x89, 0xdb, 0x9f, 0xba, 0x61, 0x98, 0x6 }}
 
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index bfecb3078737..60202d65600c 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -163,6 +163,9 @@ [LibraryClasses.common.UEFI_APPLICATION]
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+  ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+  ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
@@ -432,6 +435,7 @@ [Components.IA32, Components.X64, Components.IPF, Components.AARCH64]
   MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
   MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
+  MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
 
 [Components.IA32, Components.X64, Components.Ebc]
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf b/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
index 7e0166672b99..ce413c0b25f6 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
@@ -102,6 +102,7 @@ [LibraryClasses]
 [Protocols]
   gEfiDebugSupportProtocolGuid                  ## PRODUCES
   gEfiEbcProtocolGuid                           ## PRODUCES
+  gEfiDebuggerConfigurationProtocolGuid         ## PRODUCES
   gEfiEbcVmTestProtocolGuid                     ## SOMETIMES_PRODUCES
   gEfiEbcSimpleDebuggerProtocolGuid             ## SOMETIMES_CONSUMES
   gEfiPciRootBridgeIoProtocolGuid               ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
new file mode 100644
index 000000000000..8e9fca9d3ef8
--- /dev/null
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
@@ -0,0 +1,207 @@
+/** @file
+  Configuration application for the EBC Debugger.
+
+  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <Protocol/Shell.h>
+#include <Library/ShellCEntryLib.h>
+
+#include "EdbCommon.h"
+#include "EdbSupport.h"
+
+VOID
+PrintUsage (
+  VOID
+  )
+{
+  Print (
+    L"EbcDebuggerConfig Version 0.2\n"
+    L"Copyright (C) Intel Corp 2007-2016. All rights reserved.\n"
+    L"\n"
+    L"Configure EbcDebugger in EFI Shell Environment.\n"
+    L"\n"
+    L"usage: EdbCfg <Command>\n"
+    L"  CommandList:\n"
+    L"    BO[C|CX|R|E|T|K] <ON|OFF> - Enable/Disable BOC/BOCX/BOR/BOE/BOT/BOK.\n"
+//    L"    SHOWINFO                - Show Debugger Information.\n"
+    L"\n"
+    );
+  return;
+}
+
+VOID
+EdbShowInfo (
+  EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration
+  )
+{
+  Print (L"Not supported!\n");
+  return ;
+}
+
+VOID
+EdbConfigBreak (
+  EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration,
+  CHAR16                              *Command,
+  CHAR16                              *CommandArg
+  )
+{
+  EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate;
+
+  DebuggerPrivate = (EFI_DEBUGGER_PRIVATE_DATA *)DebuggerConfiguration->DebuggerPrivateData;
+
+  if (StriCmp (Command, L"BOC") == 0) {
+    if (CommandArg == NULL) {
+      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOC) == EFI_DEBUG_FLAG_EBC_BOC) {
+        Print (L"BOC on\n");
+      } else {
+        Print (L"BOC off\n");
+      }
+    } else if (StriCmp (CommandArg, L"ON") == 0) {
+      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOC;
+    } else if (StriCmp (CommandArg, L"OFF") == 0) {
+      DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOC;
+    } else {
+      Print (L"Invalid parameter\n");
+    }
+  } else if (StriCmp (Command, L"BOCX") == 0) {
+    if (CommandArg == NULL) {
+      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOCX) == EFI_DEBUG_FLAG_EBC_BOCX) {
+        Print (L"BOCX on\n");
+      } else {
+        Print (L"BOCX off\n");
+      }
+    } else if (StriCmp (CommandArg, L"ON") == 0) {
+      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOCX;
+    } else if (StriCmp (CommandArg, L"OFF") == 0) {
+      DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOCX;
+    } else {
+      Print (L"Invalid parameter\n");
+    }
+  } else if (StriCmp (Command, L"BOR") == 0) {
+    if (CommandArg == NULL) {
+      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOR) == EFI_DEBUG_FLAG_EBC_BOR) {
+        Print (L"BOR on\n");
+      } else {
+        Print (L"BOR off\n");
+      }
+    } else if (StriCmp (CommandArg, L"ON") == 0) {
+      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOR;
+    } else if (StriCmp (CommandArg, L"OFF") == 0) {
+      DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOR;
+    } else {
+      Print (L"Invalid parameter\n");
+    }
+  } else if (StriCmp (Command, L"BOE") == 0) {
+    if (CommandArg == NULL) {
+      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOE) == EFI_DEBUG_FLAG_EBC_BOE) {
+        Print (L"BOE on\n");
+      } else {
+        Print (L"BOE off\n");
+      }
+    } else if (StriCmp (CommandArg, L"ON") == 0) {
+      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOE;
+    } else if (StriCmp (CommandArg, L"OFF") == 0) {
+      DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOE;
+    } else {
+      Print (L"Invalid parameter\n");
+    }
+  } else if (StriCmp (Command, L"BOT") == 0) {
+    if (CommandArg == NULL) {
+      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOT) == EFI_DEBUG_FLAG_EBC_BOT) {
+        Print (L"BOT on\n");
+      } else {
+        Print (L"BOT off\n");
+      }
+    } else if (StriCmp (CommandArg, L"ON") == 0) {
+      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOT;
+    } else if (StriCmp (CommandArg, L"OFF") == 0) {
+      DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOT;
+    } else {
+      Print (L"Invalid parameter\n");
+    }
+  } else if (StriCmp (Command, L"BOK") == 0) {
+    if (CommandArg == NULL) {
+      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOK) == EFI_DEBUG_FLAG_EBC_BOK) {
+        Print (L"BOK on\n");
+      } else {
+        Print (L"BOK off\n");
+      }
+    } else if (StriCmp (CommandArg, L"ON") == 0) {
+      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOK;
+    } else if (StriCmp (CommandArg, L"OFF") == 0) {
+      DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOK;
+    } else {
+      Print (L"Invalid parameter\n");
+    }
+  }
+  return ;
+}
+
+INTN
+EFIAPI
+ShellAppMain (
+  IN UINTN Argc,
+  IN CHAR16 **Argv
+  )
+{
+  EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration;
+  EFI_STATUS                          Status;
+
+  if (Argc < 2) {
+    PrintUsage ();
+    return SHELL_INVALID_PARAMETER;
+  }
+
+  if (Argc == 2) {
+    if ((StrCmp (Argv[1], L"/?") == 0) ||
+        (StrCmp (Argv[1], L"-?") == 0) ||
+        (StrCmp (Argv[1], L"-h") == 0) ||
+        (StrCmp (Argv[1], L"-H") == 0) ) {
+      PrintUsage ();
+      return SHELL_SUCCESS;
+    }
+  }
+
+  Status = gBS->LocateProtocol (
+                 &gEfiDebuggerConfigurationProtocolGuid,
+                 NULL,
+                 &DebuggerConfiguration
+                 );
+  if (EFI_ERROR(Status)) {
+    Print (L"Error: DebuggerConfiguration Protocol not found!\n");
+    return SHELL_SUCCESS;
+  }
+
+  if (StriCmp (Argv[1], L"SHOWINFO") == 0) {
+    EdbShowInfo (DebuggerConfiguration);
+    return SHELL_SUCCESS;
+  }
+
+  if (((Argc == 2) || (Argc == 3)) &&
+      ((StriCmp (Argv[1], L"BOC")  == 0) ||
+       (StriCmp (Argv[1], L"BOCX") == 0) ||
+       (StriCmp (Argv[1], L"BOR")  == 0) ||
+       (StriCmp (Argv[1], L"BOE")  == 0) ||
+       (StriCmp (Argv[1], L"BOT")  == 0) ||
+       (StriCmp (Argv[1], L"BOK")  == 0))) {
+    if (Argc == 3) {
+      EdbConfigBreak (DebuggerConfiguration, Argv[1], Argv[2]);
+    } else {
+      EdbConfigBreak (DebuggerConfiguration, Argv[1], NULL);
+    }
+    return SHELL_SUCCESS;
+  }
+
+  Print (L"Error: Invalid Command!\n");
+  return SHELL_INVALID_PARAMETER;
+}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c
index e0b85c70eff5..189b88357758 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c
@@ -27,6 +27,10 @@ EFI_DEBUGGER_PRIVATE_DATA mDebuggerPrivate = {
     EBC_DEBUGGER_MINOR_VERSION,              // EfiDebuggerRevision
   (VM_MAJOR_VERSION << 16) |
     VM_MINOR_VERSION,                        // EbcVmRevision
+  {
+    EFI_DEBUGGER_CONFIGURATION_VERSION,
+    &mDebuggerPrivate,
+  },                                         // DebuggerConfiguration
   NULL,                                      // DebugImageInfoTableHeader
   NULL,                                      // Vol
   NULL,                                      // PciRootBridgeIo
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h
index 45634af9ce39..616c369253b8 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h
@@ -30,9 +30,11 @@ Abstract:
 #include <Library/PrintLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Protocol/Ebc.h>
+#include <Protocol/EbcVmTest.h>
 #include <Protocol/DebugSupport.h>
 #include <Protocol/PciRootBridgeIo.h>
 #include <Protocol/SimpleFileSystem.h>
+#include <Protocol/DebuggerConfiguration.h>
 #include <Guid/FileInfo.h>
 #include <Guid/FileSystemInfo.h>
 #include <Guid/FileSystemVolumeLabelInfo.h>
@@ -227,6 +229,7 @@ typedef struct _EFI_DEBUGGER_PRIVATE_DATA {
   EFI_INSTRUCTION_SET_ARCHITECTURE            Isa;
   UINT32                                      EfiDebuggerRevision;
   UINT32                                      EbcVmRevision;
+  EFI_DEBUGGER_CONFIGURATION_PROTOCOL         DebuggerConfiguration;
   EFI_DEBUG_IMAGE_INFO_TABLE_HEADER           *DebugImageInfoTableHeader;
   EFI_SIMPLE_FILE_SYSTEM_PROTOCOL             *Vol;
   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL             *PciRootBridgeIo;
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c
index 9196adb74ba3..3bfee927e227 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c
@@ -448,6 +448,17 @@ Returns:
              );
 
   //
+  // Register Debugger Configuration Protocol, for config in shell
+  //
+  Status = gBS->InstallProtocolInterface (
+                  &Handle,
+                  &gEfiDebuggerConfigurationProtocolGuid,
+                  EFI_NATIVE_INTERFACE,
+                  &mDebuggerPrivate.DebuggerConfiguration
+                  );
+
+  //
+  //
   // Create break event
   //
   Status = gBS->CreateEvent (
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
new file mode 100644
index 000000000000..db21f301d87c
--- /dev/null
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
@@ -0,0 +1,57 @@
+## @file
+#  EBC Debugger configuration application.
+#
+#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = EdbCfg
+  MODULE_UNI_FILE                = EbcDebuggerConfig.uni
+  FILE_GUID                      = 8CFC5233-23C6-49e3-8A2D-7E581AB305BA
+  MODULE_TYPE                    = UEFI_APPLICATION
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = ShellCEntryLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF AARCH64
+#
+
+[Sources]
+  EbcDebugger/EbcDebuggerConfig.c
+  EbcDebugger/EdbCommon.h
+  EbcDebugger/EdbSupportString.c
+  EbcDebugger/EdbSupport.h
+
+[Packages]
+  AppPkg/AppPkg.dec
+  MdePkg/MdePkg.dec
+  ShellPkg/ShellPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  UefiLib
+  BaseLib
+  DebugLib
+  ShellLib
+  ShellCEntryLib
+
+[Protocols]
+  gEfiDebuggerConfigurationProtocolGuid     ## CONSUMES
+
+[Depex]
+  TRUE
+
+[UserExtensions.TianoCore."ExtraFiles"]
+  EbcDebuggerConfigExtra.uni
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni
new file mode 100644
index 000000000000..5201b9358346
--- /dev/null
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni
@@ -0,0 +1,18 @@
+// /** @file
+// EBC Debugger configuration application.
+//
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "EBC Debugger configuration application"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "This application allows configuring the EBC Debugger."
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni
new file mode 100644
index 000000000000..b3ad472c4c44
--- /dev/null
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni
@@ -0,0 +1,17 @@
+// /** @file
+// EBC Debugger configuration application.
+//
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+#string STR_PROPERTIES_MODULE_NAME
+#language en-US
+"EBC Debugger Config"
-- 
2.9.3.windows.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] MdeModulePkg/EbcDxe: add EBC Debugger configuration application
  2016-11-24 11:29 ` [PATCH 1/1] " Pete Batard
@ 2016-11-24 12:40   ` Yao, Jiewen
  2016-11-24 13:06     ` Pete Batard
  0 siblings, 1 reply; 4+ messages in thread
From: Yao, Jiewen @ 2016-11-24 12:40 UTC (permalink / raw)
  To: Pete Batard, edk2-devel@lists.01.org

Thank you Peter. I like this porting work.

One comment is that we have special restriction on package dependency.
 -- The MdeModulePkg should not depend upon ShellPkg.
 -- The MdeModulePkg can only depend upon MdePkg.

I know you want to parse the shell argument, such as Argc and Argv.
If an application has ShellPkg dependency issue, the recommended way is to use EFI_SHELL_PARAMETERS_PROTOCOL, which is defined in UEFI SHELL 2.x specification.
 -- It is located in MdePkg\Include\Protocol\ShellParameters.h

An application may use ShellLib, if and only if it can depend upon ShellPkg, such as a platform Package, or ShellPkg itself.

You can refer to MdeModulePkg\Application\CapsuleApp\AppSupport.c, GetArg() to see how to get Argv and Argc via EFI_SHELL_PARAMETERS_PROTOCOL. :-)

Other part looks good to me.

Thank you
Yao Jiewen

> -----Original Message-----
> From: Pete Batard [mailto:pete@akeo.ie]
> Sent: Thursday, November 24, 2016 7:30 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Pete Batard <pete@akeo.ie>
> Subject: [PATCH 1/1] MdeModulePkg/EbcDxe: add EBC Debugger
> configuration application
> 
> * Introduce a generic Debugger Configuration protocol.
> * Add private configuration data in the EBC Debugger and make it
>   register the Debugger Configuration protocol on initialization.
> * Add a shell application that uses the protocol above to access
>   the private data in order to configure the EBC debugger.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
>  .../Include/Protocol/DebuggerConfiguration.h       |  32 ++++
>  MdeModulePkg/MdeModulePkg.dec                      |   4 +
>  MdeModulePkg/MdeModulePkg.dsc                      |   4 +
>  MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf      |   1 +
>  .../EbcDxe/EbcDebugger/EbcDebuggerConfig.c         | 207
> +++++++++++++++++++++
>  MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c    |   4 +
>  .../Universal/EbcDxe/EbcDebugger/EdbCommon.h       |   3 +
>  .../Universal/EbcDxe/EbcDebugger/EdbHook.c         |  11 ++
>  .../Universal/EbcDxe/EbcDebuggerConfig.inf         |  57 ++++++
>  .../Universal/EbcDxe/EbcDebuggerConfig.uni         |  18 ++
>  .../Universal/EbcDxe/EbcDebuggerConfigExtra.uni    |  17 ++
>  11 files changed, 358 insertions(+)
>  create mode 100644
> MdeModulePkg/Include/Protocol/DebuggerConfiguration.h
>  create mode 100644
> MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
>  create mode 100644
> MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
>  create mode 100644
> MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni
>  create mode 100644
> MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni
> 
> diff --git a/MdeModulePkg/Include/Protocol/DebuggerConfiguration.h
> b/MdeModulePkg/Include/Protocol/DebuggerConfiguration.h
> new file mode 100644
> index 000000000000..eaaa6b925fad
> --- /dev/null
> +++ b/MdeModulePkg/Include/Protocol/DebuggerConfiguration.h
> @@ -0,0 +1,32 @@
> +/** @file
> +  EBC Debugger configuration protocol.
> +
> +  Copyright (c) 2007-2016, Intel Corporation. All rights reserved.<BR>
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions
> +  of the BSD License which accompanies this distribution.  The
> +  full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __EFI_DEBUGGER_CONFIGURATION_H__
> +#define __EFI_DEBUGGER_CONFIGURATION_H__
> +
> +#define EFI_DEBUGGER_CONFIGURATION_PROTOCOL_GUID \
> +  { 0x577d959c, 0xe967, 0x4546, 0x86, 0x20, 0xc7, 0x78, 0xfa, 0xe5, 0xda,
> 0x5 }
> +
> +#define EFI_DEBUGGER_CONFIGURATION_VERSION  0x00000001
> +
> +typedef struct _EFI_DEBUGGER_CONFIGURATION_PROTOCOL {
> +  UINT32                      DebuggerConfigurationRevision;
> +  VOID                        *DebuggerPrivateData;
> +} EFI_DEBUGGER_CONFIGURATION_PROTOCOL;
> +
> +extern EFI_GUID gEfiDebuggerConfigurationProtocolGuid;
> +
> +#endif
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 22898e3f7487..08c3e40e930c 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -420,6 +420,10 @@ [Protocols]
>    # Include/Protocol/GenericMemoryTest.h
>    gEfiGenericMemTestProtocolGuid = { 0x309DE7F1, 0x7F5E, 0x4ACE,
> { 0xB4, 0x9C, 0x53, 0x1B, 0xE5, 0xAA, 0x95, 0xEF }}
> 
> +  ## This protocol defines the Debugger Configuration protocol.
> +  # Include/Protocol/DebuggerConfiguration.h
> +  gEfiDebuggerConfigurationProtocolGuid = { 0x577d959c, 0xe967, 0x4546,
> { 0x86, 0x20, 0xc7, 0x78, 0xfa, 0xe5, 0xda, 0x05 }}
> +
>    ## Include/Protocol/Dpc.h
>    gEfiDpcProtocolGuid            = {0x480f8ae9, 0xc46, 0x4aa9,
> { 0xbc, 0x89, 0xdb, 0x9f, 0xba, 0x61, 0x98, 0x6 }}
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc
> b/MdeModulePkg/MdeModulePkg.dsc
> index bfecb3078737..60202d65600c 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -163,6 +163,9 @@ [LibraryClasses.common.UEFI_APPLICATION]
>    HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> 
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMem
> oryAllocationLib.inf
>    DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
> +  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
> +  ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
> +
> ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
> 
>  [LibraryClasses.ARM, LibraryClasses.AARCH64]
>    ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
> @@ -432,6 +435,7 @@ [Components.IA32, Components.X64,
> Components.IPF, Components.AARCH64]
>    MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
>    MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
>    MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
> +  MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
> 
>  [Components.IA32, Components.X64, Components.Ebc]
>    MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> {
> diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
> b/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
> index 7e0166672b99..ce413c0b25f6 100644
> --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
> +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
> @@ -102,6 +102,7 @@ [LibraryClasses]
>  [Protocols]
>    gEfiDebugSupportProtocolGuid                  ## PRODUCES
>    gEfiEbcProtocolGuid                           ## PRODUCES
> +  gEfiDebuggerConfigurationProtocolGuid         ## PRODUCES
>    gEfiEbcVmTestProtocolGuid                     ##
> SOMETIMES_PRODUCES
>    gEfiEbcSimpleDebuggerProtocolGuid             ##
> SOMETIMES_CONSUMES
>    gEfiPciRootBridgeIoProtocolGuid               ##
> SOMETIMES_CONSUMES
> diff --git
> a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
> b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
> new file mode 100644
> index 000000000000..8e9fca9d3ef8
> --- /dev/null
> +++
> b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
> @@ -0,0 +1,207 @@
> +/** @file
> +  Configuration application for the EBC Debugger.
> +
> +  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the
> BSD License
> +  which accompanies this distribution.  The full text of the license may be
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Protocol/Shell.h>
> +#include <Library/ShellCEntryLib.h>
> +
> +#include "EdbCommon.h"
> +#include "EdbSupport.h"
> +
> +VOID
> +PrintUsage (
> +  VOID
> +  )
> +{
> +  Print (
> +    L"EbcDebuggerConfig Version 0.2\n"
> +    L"Copyright (C) Intel Corp 2007-2016. All rights reserved.\n"
> +    L"\n"
> +    L"Configure EbcDebugger in EFI Shell Environment.\n"
> +    L"\n"
> +    L"usage: EdbCfg <Command>\n"
> +    L"  CommandList:\n"
> +    L"    BO[C|CX|R|E|T|K] <ON|OFF> - Enable/Disable
> BOC/BOCX/BOR/BOE/BOT/BOK.\n"
> +//    L"    SHOWINFO                - Show Debugger
> Information.\n"
> +    L"\n"
> +    );
> +  return;
> +}
> +
> +VOID
> +EdbShowInfo (
> +  EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration
> +  )
> +{
> +  Print (L"Not supported!\n");
> +  return ;
> +}
> +
> +VOID
> +EdbConfigBreak (
> +  EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration,
> +  CHAR16                              *Command,
> +  CHAR16                              *CommandArg
> +  )
> +{
> +  EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate;
> +
> +  DebuggerPrivate = (EFI_DEBUGGER_PRIVATE_DATA
> *)DebuggerConfiguration->DebuggerPrivateData;
> +
> +  if (StriCmp (Command, L"BOC") == 0) {
> +    if (CommandArg == NULL) {
> +      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOC)
> == EFI_DEBUG_FLAG_EBC_BOC) {
> +        Print (L"BOC on\n");
> +      } else {
> +        Print (L"BOC off\n");
> +      }
> +    } else if (StriCmp (CommandArg, L"ON") == 0) {
> +      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOC;
> +    } else if (StriCmp (CommandArg, L"OFF") == 0) {
> +      DebuggerPrivate->FeatureFlags &=
> ~EFI_DEBUG_FLAG_EBC_B_BOC;
> +    } else {
> +      Print (L"Invalid parameter\n");
> +    }
> +  } else if (StriCmp (Command, L"BOCX") == 0) {
> +    if (CommandArg == NULL) {
> +      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOCX)
> == EFI_DEBUG_FLAG_EBC_BOCX) {
> +        Print (L"BOCX on\n");
> +      } else {
> +        Print (L"BOCX off\n");
> +      }
> +    } else if (StriCmp (CommandArg, L"ON") == 0) {
> +      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOCX;
> +    } else if (StriCmp (CommandArg, L"OFF") == 0) {
> +      DebuggerPrivate->FeatureFlags &=
> ~EFI_DEBUG_FLAG_EBC_B_BOCX;
> +    } else {
> +      Print (L"Invalid parameter\n");
> +    }
> +  } else if (StriCmp (Command, L"BOR") == 0) {
> +    if (CommandArg == NULL) {
> +      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOR)
> == EFI_DEBUG_FLAG_EBC_BOR) {
> +        Print (L"BOR on\n");
> +      } else {
> +        Print (L"BOR off\n");
> +      }
> +    } else if (StriCmp (CommandArg, L"ON") == 0) {
> +      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOR;
> +    } else if (StriCmp (CommandArg, L"OFF") == 0) {
> +      DebuggerPrivate->FeatureFlags &=
> ~EFI_DEBUG_FLAG_EBC_B_BOR;
> +    } else {
> +      Print (L"Invalid parameter\n");
> +    }
> +  } else if (StriCmp (Command, L"BOE") == 0) {
> +    if (CommandArg == NULL) {
> +      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOE)
> == EFI_DEBUG_FLAG_EBC_BOE) {
> +        Print (L"BOE on\n");
> +      } else {
> +        Print (L"BOE off\n");
> +      }
> +    } else if (StriCmp (CommandArg, L"ON") == 0) {
> +      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOE;
> +    } else if (StriCmp (CommandArg, L"OFF") == 0) {
> +      DebuggerPrivate->FeatureFlags &=
> ~EFI_DEBUG_FLAG_EBC_B_BOE;
> +    } else {
> +      Print (L"Invalid parameter\n");
> +    }
> +  } else if (StriCmp (Command, L"BOT") == 0) {
> +    if (CommandArg == NULL) {
> +      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOT)
> == EFI_DEBUG_FLAG_EBC_BOT) {
> +        Print (L"BOT on\n");
> +      } else {
> +        Print (L"BOT off\n");
> +      }
> +    } else if (StriCmp (CommandArg, L"ON") == 0) {
> +      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOT;
> +    } else if (StriCmp (CommandArg, L"OFF") == 0) {
> +      DebuggerPrivate->FeatureFlags &=
> ~EFI_DEBUG_FLAG_EBC_B_BOT;
> +    } else {
> +      Print (L"Invalid parameter\n");
> +    }
> +  } else if (StriCmp (Command, L"BOK") == 0) {
> +    if (CommandArg == NULL) {
> +      if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOK)
> == EFI_DEBUG_FLAG_EBC_BOK) {
> +        Print (L"BOK on\n");
> +      } else {
> +        Print (L"BOK off\n");
> +      }
> +    } else if (StriCmp (CommandArg, L"ON") == 0) {
> +      DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOK;
> +    } else if (StriCmp (CommandArg, L"OFF") == 0) {
> +      DebuggerPrivate->FeatureFlags &=
> ~EFI_DEBUG_FLAG_EBC_B_BOK;
> +    } else {
> +      Print (L"Invalid parameter\n");
> +    }
> +  }
> +  return ;
> +}
> +
> +INTN
> +EFIAPI
> +ShellAppMain (
> +  IN UINTN Argc,
> +  IN CHAR16 **Argv
> +  )
> +{
> +  EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration;
> +  EFI_STATUS                          Status;
> +
> +  if (Argc < 2) {
> +    PrintUsage ();
> +    return SHELL_INVALID_PARAMETER;
> +  }
> +
> +  if (Argc == 2) {
> +    if ((StrCmp (Argv[1], L"/?") == 0) ||
> +        (StrCmp (Argv[1], L"-?") == 0) ||
> +        (StrCmp (Argv[1], L"-h") == 0) ||
> +        (StrCmp (Argv[1], L"-H") == 0) ) {
> +      PrintUsage ();
> +      return SHELL_SUCCESS;
> +    }
> +  }
> +
> +  Status = gBS->LocateProtocol (
> +                 &gEfiDebuggerConfigurationProtocolGuid,
> +                 NULL,
> +                 &DebuggerConfiguration
> +                 );
> +  if (EFI_ERROR(Status)) {
> +    Print (L"Error: DebuggerConfiguration Protocol not found!\n");
> +    return SHELL_SUCCESS;
> +  }
> +
> +  if (StriCmp (Argv[1], L"SHOWINFO") == 0) {
> +    EdbShowInfo (DebuggerConfiguration);
> +    return SHELL_SUCCESS;
> +  }
> +
> +  if (((Argc == 2) || (Argc == 3)) &&
> +      ((StriCmp (Argv[1], L"BOC")  == 0) ||
> +       (StriCmp (Argv[1], L"BOCX") == 0) ||
> +       (StriCmp (Argv[1], L"BOR")  == 0) ||
> +       (StriCmp (Argv[1], L"BOE")  == 0) ||
> +       (StriCmp (Argv[1], L"BOT")  == 0) ||
> +       (StriCmp (Argv[1], L"BOK")  == 0))) {
> +    if (Argc == 3) {
> +      EdbConfigBreak (DebuggerConfiguration, Argv[1], Argv[2]);
> +    } else {
> +      EdbConfigBreak (DebuggerConfiguration, Argv[1], NULL);
> +    }
> +    return SHELL_SUCCESS;
> +  }
> +
> +  Print (L"Error: Invalid Command!\n");
> +  return SHELL_INVALID_PARAMETER;
> +}
> diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c
> b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c
> index e0b85c70eff5..189b88357758 100644
> --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c
> +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c
> @@ -27,6 +27,10 @@ EFI_DEBUGGER_PRIVATE_DATA mDebuggerPrivate = {
>      EBC_DEBUGGER_MINOR_VERSION,              //
> EfiDebuggerRevision
>    (VM_MAJOR_VERSION << 16) |
>      VM_MINOR_VERSION,                        // EbcVmRevision
> +  {
> +    EFI_DEBUGGER_CONFIGURATION_VERSION,
> +    &mDebuggerPrivate,
> +  },                                         //
> DebuggerConfiguration
>    NULL,                                      //
> DebugImageInfoTableHeader
>    NULL,                                      // Vol
>    NULL,                                      // PciRootBridgeIo
> diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h
> b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h
> index 45634af9ce39..616c369253b8 100644
> --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h
> +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h
> @@ -30,9 +30,11 @@ Abstract:
>  #include <Library/PrintLib.h>
>  #include <Library/UefiBootServicesTableLib.h>
>  #include <Protocol/Ebc.h>
> +#include <Protocol/EbcVmTest.h>
>  #include <Protocol/DebugSupport.h>
>  #include <Protocol/PciRootBridgeIo.h>
>  #include <Protocol/SimpleFileSystem.h>
> +#include <Protocol/DebuggerConfiguration.h>
>  #include <Guid/FileInfo.h>
>  #include <Guid/FileSystemInfo.h>
>  #include <Guid/FileSystemVolumeLabelInfo.h>
> @@ -227,6 +229,7 @@ typedef struct _EFI_DEBUGGER_PRIVATE_DATA {
>    EFI_INSTRUCTION_SET_ARCHITECTURE            Isa;
>    UINT32
> EfiDebuggerRevision;
>    UINT32                                      EbcVmRevision;
> +  EFI_DEBUGGER_CONFIGURATION_PROTOCOL
> DebuggerConfiguration;
>    EFI_DEBUG_IMAGE_INFO_TABLE_HEADER
> *DebugImageInfoTableHeader;
>    EFI_SIMPLE_FILE_SYSTEM_PROTOCOL             *Vol;
>    EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
> *PciRootBridgeIo;
> diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c
> b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c
> index 9196adb74ba3..3bfee927e227 100644
> --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c
> +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c
> @@ -448,6 +448,17 @@ Returns:
>               );
> 
>    //
> +  // Register Debugger Configuration Protocol, for config in shell
> +  //
> +  Status = gBS->InstallProtocolInterface (
> +                  &Handle,
> +                  &gEfiDebuggerConfigurationProtocolGuid,
> +                  EFI_NATIVE_INTERFACE,
> +                  &mDebuggerPrivate.DebuggerConfiguration
> +                  );
> +
> +  //
> +  //
>    // Create break event
>    //
>    Status = gBS->CreateEvent (
> diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
> b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
> new file mode 100644
> index 000000000000..db21f301d87c
> --- /dev/null
> +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
> @@ -0,0 +1,57 @@
> +## @file
> +#  EBC Debugger configuration application.
> +#
> +#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the
> BSD License
> +#  which accompanies this distribution. The full text of the license may be
> found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
> IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +#
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010005
> +  BASE_NAME                      = EdbCfg
> +  MODULE_UNI_FILE                = EbcDebuggerConfig.uni
> +  FILE_GUID                      =
> 8CFC5233-23C6-49e3-8A2D-7E581AB305BA
> +  MODULE_TYPE                    = UEFI_APPLICATION
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = ShellCEntryLib
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +#  VALID_ARCHITECTURES           = IA32 X64 IPF AARCH64
> +#
> +
> +[Sources]
> +  EbcDebugger/EbcDebuggerConfig.c
> +  EbcDebugger/EdbCommon.h
> +  EbcDebugger/EdbSupportString.c
> +  EbcDebugger/EdbSupport.h
> +
> +[Packages]
> +  AppPkg/AppPkg.dec
> +  MdePkg/MdePkg.dec
> +  ShellPkg/ShellPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> +  UefiLib
> +  BaseLib
> +  DebugLib
> +  ShellLib
> +  ShellCEntryLib
> +
> +[Protocols]
> +  gEfiDebuggerConfigurationProtocolGuid     ## CONSUMES
> +
> +[Depex]
> +  TRUE
> +
> +[UserExtensions.TianoCore."ExtraFiles"]
> +  EbcDebuggerConfigExtra.uni
> diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni
> b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni
> new file mode 100644
> index 000000000000..5201b9358346
> --- /dev/null
> +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.uni
> @@ -0,0 +1,18 @@
> +// /** @file
> +// EBC Debugger configuration application.
> +//
> +// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> +//
> +// This program and the accompanying materials
> +// are licensed and made available under the terms and conditions of the
> BSD License
> +// which accompanies this distribution. The full text of the license may be
> found at
> +// http://opensource.org/licenses/bsd-license.php
> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT             #language en-US "EBC
> Debugger configuration application"
> +
> +#string STR_MODULE_DESCRIPTION          #language en-US "This
> application allows configuring the EBC Debugger."
> diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni
> b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni
> new file mode 100644
> index 000000000000..b3ad472c4c44
> --- /dev/null
> +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfigExtra.uni
> @@ -0,0 +1,17 @@
> +// /** @file
> +// EBC Debugger configuration application.
> +//
> +// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> +//
> +// This program and the accompanying materials
> +// are licensed and made available under the terms and conditions of the
> BSD License
> +// which accompanies this distribution. The full text of the license may be
> found at
> +// http://opensource.org/licenses/bsd-license.php
> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +//
> +// **/
> +
> +#string STR_PROPERTIES_MODULE_NAME
> +#language en-US
> +"EBC Debugger Config"
> --
> 2.9.3.windows.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] MdeModulePkg/EbcDxe: add EBC Debugger configuration application
  2016-11-24 12:40   ` Yao, Jiewen
@ 2016-11-24 13:06     ` Pete Batard
  0 siblings, 0 replies; 4+ messages in thread
From: Pete Batard @ 2016-11-24 13:06 UTC (permalink / raw)
  To: Yao, Jiewen, edk2-devel@lists.01.org

Hi Jiewen,

Thanks for clarifying the dependency restrictions. This is something I 
had been wondering about when I ported the app.

I'll work on removing the unwanted libraries and submit a v2.

Regards,

/Pete

On 2016.11.24 12:40, Yao, Jiewen wrote:
> Thank you Peter. I like this porting work.
>
> One comment is that we have special restriction on package dependency.
>  -- The MdeModulePkg should not depend upon ShellPkg.
>  -- The MdeModulePkg can only depend upon MdePkg.
>
> I know you want to parse the shell argument, such as Argc and Argv.
> If an application has ShellPkg dependency issue, the recommended way is to use EFI_SHELL_PARAMETERS_PROTOCOL, which is defined in UEFI SHELL 2.x specification.
>  -- It is located in MdePkg\Include\Protocol\ShellParameters.h
>
> An application may use ShellLib, if and only if it can depend upon ShellPkg, such as a platform Package, or ShellPkg itself.
>
> You can refer to MdeModulePkg\Application\CapsuleApp\AppSupport.c, GetArg() to see how to get Argv and Argc via EFI_SHELL_PARAMETERS_PROTOCOL. :-)
>
> Other part looks good to me.
>
> Thank you
> Yao Jiewen



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-24 13:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-24 11:29 [PATCH 0/1] MdeModulePkg/EbcDxe: add EBC Debugger configuration application Pete Batard
2016-11-24 11:29 ` [PATCH 1/1] " Pete Batard
2016-11-24 12:40   ` Yao, Jiewen
2016-11-24 13:06     ` Pete Batard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox