]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseCpuLibNull: Add Null version of CpuLib for host testing
authorMichael D Kinney <michael.d.kinney@intel.com>
Fri, 5 Jun 2020 18:01:22 +0000 (11:01 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 15 Jul 2020 05:25:21 +0000 (05:25 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2798

The services in CpuLib usually generate exceptions in a unit test
host application.  Provide a Null instance that can be safely used.

This Null instance can also be used as a template for implementing
new instances of CpuLib.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c [new file with mode: 0644]
MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf [new file with mode: 0644]
MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni [new file with mode: 0644]
MdePkg/MdePkg.dsc

diff --git a/MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c b/MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c
new file mode 100644 (file)
index 0000000..3ba7a35
--- /dev/null
@@ -0,0 +1,37 @@
+/** @file\r
+  Null instance of CPU Library.\r
+\r
+  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+/**\r
+  Places the CPU in a sleep state until an interrupt is received.\r
+\r
+  Places the CPU in a sleep state until an interrupt is received. If interrupts\r
+  are disabled prior to calling this function, then the CPU will be placed in a\r
+  sleep state indefinitely.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuSleep (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r
+\r
+  Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuFlushTlb (\r
+  VOID\r
+  )\r
+{\r
+}\r
diff --git a/MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf b/MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf
new file mode 100644 (file)
index 0000000..a9e8399
--- /dev/null
@@ -0,0 +1,26 @@
+## @file\r
+#  Null instance of CPU Library.\r
+#\r
+#  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = BaseCpuLibNull\r
+  MODULE_UNI_FILE                = BaseCpuLibNull.uni\r
+  FILE_GUID                      = 8A29AAA5-0FB7-44CC-8709-1344FE89B878\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = CpuLib\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64 RISCV64\r
+#\r
+\r
+[Sources]\r
+  BaseCpuLibNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
diff --git a/MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni b/MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni
new file mode 100644 (file)
index 0000000..1030221
--- /dev/null
@@ -0,0 +1,11 @@
+// /** @file\r
+// Null instance of CPU Library.\r
+//\r
+// Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+// SPDX-License-Identifier: BSD-2-Clause-Patent\r
+//\r
+// **/\r
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "Null Instance of CPU Library"\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "Null instance of CPU Library."\r
index 6cd38e7ec3c9f7a856db70e7d908f18729801151..3abe65ec7f717cde7619cd9f97f14feb5fbe7a7f 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # EFI/PI MdePkg Package\r
 #\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 # (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
 #\r
@@ -36,6 +36,7 @@
   MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
   MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
   MdePkg/Library/BaseCpuLib/BaseCpuLib.inf\r
+  MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf\r
   MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
   MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
   MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf\r