The sources were copied from Aarch64. Follow-up commit will adapt them
for Riscv64.
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3042
Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>
Cc: Barton Gao <gaojie@byosoft.com.cn>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Cc: Eric Jin <eric.jin@intel.com>
Cc: Arvin Chen <arvinx.chen@intel.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Abner Chang <abner.chang@hpe.com>
Signed-off-by: Daniel Schaefer <daniel.schaefer@hpe.com>
---
uefi-sct/SctPkg/Library/SctLib/Riscv64/SctLibPlat.h | 32 +++
uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c | 45 ++++
uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S | 44 ++++
uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c | 182 +++++++++++++
uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c | 88 +++++++
uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c | 68 +++++
uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.c | 134 ++++++++++
uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.h | 48 ++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestCacheFunction.c | 137 ++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestExceptionCallbackFunction.c | 276 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/PlatformIsa.c | 30 +++
uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/EntsLibPlat.h | 55 ++++
uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/InitPlat.c | 55 ++++
13 files changed, 1194 insertions(+)
diff --git a/uefi-sct/SctPkg/Library/SctLib/Riscv64/SctLibPlat.h b/uefi-sct/SctPkg/Library/SctLib/Riscv64/SctLibPlat.h
new file mode 100644
index 00000000..ee7c656b
--- /dev/null
+++ b/uefi-sct/SctPkg/Library/SctLib/Riscv64/SctLibPlat.h
@@ -0,0 +1,32 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2012, ARM Ltd. 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.
+
+**/
+/*++
+
+Module Name:
+
+ SctLibPlat.h
+
+Abstract:
+
+ AArch64 specific defines
+
+--*/
+
+#ifndef _EFI_LIB_PLAT_H_
+#define _EFI_LIB_PLAT_H_
+
+#define MIN_ALIGNMENT_SIZE 8
+
+#endif
diff --git a/uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c b/uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c
new file mode 100644
index 00000000..a48bb2f3
--- /dev/null
+++ b/uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c
@@ -0,0 +1,45 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2012, ARM Ltd. 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.
+
+**/
+/*++
+
+Module Name:
+
+ initplat.c
+
+Abstract:
+
+ Math routines for compatibility with native EFI library routines.
+
+--*/
+
+#include "SctLibInternal.h"
+
+VOID
+InitializeLibPlatform (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+
+{
+ // No platform-specific initializations
+}
+
+UINT64
+SctReadTsc (
+ VOID
+ )
+{
+ return 0;
+}
diff --git a/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S b/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S
new file mode 100644
index 00000000..d223b36b
--- /dev/null
+++ b/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S
@@ -0,0 +1,44 @@
+## @file
+#
+# Copyright 2010 - 2012 Unified EFI, Inc.<BR>
+# Copyright (c) 2012, ARM Ltd. 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.
+#
+##
+#
+#
+#/*++
+#
+# Module Name:
+#
+# GoVirtual.S
+#
+#--*/
+#start of the code section
+.text
+/* FIXME: Should alignment be different on Aarch64? */
+.align 3
+
+.global JumpToTestFunc
+.type JumpToTestFunc, %function
+
+#------------------------------------------------------------------------------
+# VOID
+# JumpToTestFunc (
+# IN UINTN FuncPointer,
+# IN UNITN ConfigInfo
+# )
+#
+JumpToTestFunc:
+ mov x2, x0
+ mov x0, x1
+
+ // Jump to Virtual function
+ blr x2
diff --git a/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c b/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c
new file mode 100644
index 00000000..397b3514
--- /dev/null
+++ b/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c
@@ -0,0 +1,182 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2012, ARM Ltd. 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.
+
+**/
+/*++
+
+Module Name:
+
+ VirtualMemory.c
+
+--*/
+
+#include "SCRTApp.h"
+
+#define VIRT_TO_PHYS_OFFSET (0x80000000) //2G
+
+BOOLEAN HighAddress = FALSE;
+UINTN PageTable = 0;
+
+
+VOID
+ConvertRuntimeFuncPtr (
+ IN OUT UINTN *VirtualFunc
+ )
+/*++
+
+Routine Description:
+
+ Change RuntimeTestFunc physical address to virtual address
+
+Arguments:
+
+ VirtualFunc - On input, RuntimeTestFunc physical address.
+ On output, RuntimeTest virtual address.
+
+Returns:
+
+ NONE
+
+--*/
+{
+ /*Note: It is presumed that on ARM v5, V6 and V7 architectures
+ * the MMU is configured and enabled in PEI phase. As VirtualFunc
+ * is already mapped to virtual memory, don't have to do anything here.
+ */
+ /* FIXME: Is it the same on ARM v8? */
+}
+
+
+EFI_STATUS
+DoMemoryAllocation (
+ IN UINTN PhysicalFunc
+ )
+/*++
+
+Routine Description:
+
+ Allocate memory and create the PageTable to set up physical-virtual map.
+
+Arguments:
+
+ PhysicalFunc - Physical address where RuntimeTestFunc locates.
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS AllocateMemory;
+
+ //create new page tables or use existing page tables.
+ //
+ // Allocate PageTable memory close to this Application image location in
+ // the system memory. In this way, it is safe for page table memory.
+ //
+ AllocateMemory = PhysicalFunc;
+
+ Status = tBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiRuntimeServicesData,
+ 1,
+ &AllocateMemory
+ );
+
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ PageTable = (UINTN)AllocateMemory;
+ return EFI_SUCCESS;
+}
+
+
+VOID
+PrepareVirtualAddressMap (
+ IN UINTN MemoryMapSize,
+ IN UINTN DescriptorSize,
+ IN EFI_MEMORY_DESCRIPTOR *MemoryMap,
+ IN EFI_MEMORY_DESCRIPTOR *VirtualMemoryMap,
+ IN OUT UINTN *VirtualMapSize
+ )
+/*++
+
+Routine Description:
+
+ Construct VirtualAddressMap from physical address to virtual address
+
+Arguments:
+
+ MemoryMapSize - The size, in bytes, of the MemoryMap buffer
+ DescriptorSize - The size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR
+ MemoryMap - A pointer to the current memory map
+ VirtualMemoryMap - A pointer to the modified virtual memory map
+ VirtualMapSize - A pointer to the size, in bytes, of the VirtualMemoryMap buffer
+
+Returns:
+
+ NONE
+
+--*/
+{
+ UINTN Index;
+ *VirtualMapSize = 0;
+
+ //
+ // Copy entries that need runtime mapping to construct virtualMemoryMap
+ //
+ for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {
+ if ((MemoryMap->Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {
+ SctCopyMem ((VOID *) VirtualMemoryMap, (VOID *) MemoryMap, DescriptorSize);
+ VirtualMemoryMap->VirtualStart = VirtualMemoryMap->PhysicalStart;
+ *VirtualMapSize += DescriptorSize;
+ VirtualMemoryMap = NextMemoryDescriptor (VirtualMemoryMap, DescriptorSize);
+ }
+
+ MemoryMap = NextMemoryDescriptor (MemoryMap, DescriptorSize);
+ }
+}
+
+
+
+VOID
+JumpVirtualMode(
+ IN UINTN VirtualFunc,
+ IN UINTN HandOffAddr
+ )
+/*++
+
+Routine Description:
+
+ Enable virtual addressing mode, and jump to RuntimeTestFunc in virtual address
+
+Arguments:
+
+ VirtualFunc - RuntimeTestFunc virtual address
+ HandOffAddr - Configuration Data Address
+
+Returns:
+
+ NONE
+
+--*/
+{
+ //
+ // Note: It is assumed that the MMU and page tables are configured on ARM platforms
+ // based on ARM v5 v6 and v7 architecture.
+ //
+ /* FIXME: Is it the same on ARM v8? */
+ JumpToTestFunc(VirtualFunc, HandOffAddr);
+}
diff --git a/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c
new file mode 100644
index 00000000..6161d596
--- /dev/null
+++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c
@@ -0,0 +1,88 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2012 ARM Ltd. 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.
+
+**/
+
+/*++
+
+Module Name:
+
+ Debug.c
+
+--*/
+
+#include "SCRTDriver.h"
+
+UINTN mHandOffPtr = 0;
+EFI_PHYSICAL_ADDRESS mIoPortSpaceAddress = 0;
+
+
+EFI_STATUS
+ConsumeHandOff (
+ IN UINTN HandOffAddr,
+ OUT CONF_INFO *ConfigData
+ )
+{
+ RUNTIME_HANDOFF *HandOffPtr;
+ //
+ // First fix the memory address of hand off data.
+ //
+ FixAddress(&HandOffAddr);
+ mHandOffPtr = HandOffAddr;
+ HandOffPtr = (RUNTIME_HANDOFF*)mHandOffPtr;
+ *ConfigData = HandOffPtr->ConfigureInfo;
+
+ if (!HandOffPtr->DebuggerInfo.MmioFlag){
+ //
+ // If debug port is I/O mapped, fix IoBase Address.
+ //
+ FixAddress(&HandOffPtr->DebuggerInfo.IoBase);
+ mIoPortSpaceAddress = HandOffPtr->DebuggerInfo.IoBase;
+ } else {
+ //
+ // If debug port is MMIO, fix MmioBase Address.
+ //
+ FixAddress(&HandOffPtr->DebuggerInfo.MmioBase);
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+Send2UART (
+ CHAR8 *String
+ )
+{
+ //
+ // TODO: On ARM platforms use platform specific functions to
+ // write the data to UART.
+ //
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+DebugWorker (
+ IN CHAR8 *String
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Send text message to registered UART.
+ //
+ Status = Send2UART(String);
+ return Status;
+}
diff --git a/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c
new file mode 100644
index 00000000..cc8d9869
--- /dev/null
+++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c
@@ -0,0 +1,68 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2012 ARM Ltd. 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.
+
+**/
+
+/*++
+
+Module Name:
+
+ Dump.c
+
+--*/
+
+#include "SCRTDriver.h"
+
+VOID
+DumpRuntimeTable()
+{
+ SctAPrint ("\n================Dump Runtime Table===============\n");
+ SctAPrint ("Header Signature = 0x%x\n", VRT->Hdr.Signature);
+
+ SctAPrint ("\n================GetTime Service==============\n");
+ SctAPrint ("GetTime @ 0x%x\n", VRT->GetTime);
+
+ SctAPrint ("\n================SetTime Service==============\n");
+ SctAPrint ("SetTime @ 0x%x\n", VRT->SetTime);
+
+ SctAPrint ("\n================GetWakeupTime Service==============\n");
+ SctAPrint ("GetWakeupTime @ 0x%x\n", VRT->GetWakeupTime);
+
+ SctAPrint ("\n================SetWakeupTime Service==============\n");
+ SctAPrint ("SetWakeupTime @ 0x%x\n", VRT->SetWakeupTime);
+
+ SctAPrint ("\n================GetVariable Service==============\n");
+ SctAPrint ("GetVariable @ 0x%x\n", VRT->GetVariable);
+
+ SctAPrint ("\n================GetNextVariableName Service==============\n");
+ SctAPrint ("GetNextVariableName @ 0x%x\n", VRT->GetNextVariableName);
+
+ SctAPrint ("\n================SetVariable Service==============\n");
+ SctAPrint ("SetVariable @ 0x%x\n", VRT->SetVariable);
+
+ SctAPrint ("\n================GetNextHighMonotonicCount Service==============\n");
+ SctAPrint ("GetNextHighMonotonicCount @ 0x%x\n", VRT->GetNextHighMonotonicCount);
+
+ SctAPrint ("\n================ResetSystem Service==============\n");
+ SctAPrint ("ResetSystem @ 0x%x\n", VRT->ResetSystem);
+#if 0
+ SctAPrint ("\n================UpdateCapsule Service==============\n");
+ SctAPrint ("UpdateCapsule @ 0x%x\n", VRT->UpdateCapsule);
+
+ SctAPrint ("\n================QueryCapsuleCapabilities Service==============\n");
+ SctAPrint ("QueryCapsuleCapabilities @ 0x%x\n", VRT->QueryCapsuleCapabilities);
+
+ SctAPrint ("\n================QueryVariableInfo Service==============\n");
+ SctAPrint ("QueryVariableInfo @ 0x%x\n", VRT->QueryVariableInfo);
+#endif
+}
diff --git a/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.c b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.c
new file mode 100644
index 00000000..b925e151
--- /dev/null
+++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.c
@@ -0,0 +1,134 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2012 ARM Ltd. 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.
+
+**/
+
+/*++
+
+Module Name:
+
+ Io.c
+
+--*/
+
+#include "Io.h"
+
+EFI_STATUS
+EFIAPI
+CpuIoServiceWrite (
+ IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
+ IN UINT64 UserAddress,
+ IN UINTN Count,
+ IN VOID *UserBuffer
+ )
+/*++
+
+Routine Description:
+
+ Perform the port I/O write service
+
+Arguments:
+
+ Width - Width of the port I/O operation
+ Address - Base address of the port I/O operation
+ Count - Count of the number of accesses to perform
+ Buffer - Pointer to the source buffer from which to write data
+
+Returns:
+
+ EFI_SUCCESS - The data was written.
+ EFI_INVALID_PARAMETER - Width is invalid.
+ EFI_INVALID_PARAMETER - Buffer is NULL.
+ EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
+ EFI_UNSUPPORTED - The address range specified by Address, Width,
+ and Count is not valid.
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+EFI_STATUS
+EfiIoWrite (
+ IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+{
+ return CpuIoServiceWrite(Width, Address, Count, Buffer);
+}
+
+
+EFI_STATUS
+EfiIoRead (
+ IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO read into Buffer.
+
+Arguments:
+ Width - Width of read transaction, and repeat operation to use
+ Address - IO address to read
+ Count - Number of times to read the IO address.
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+VOID
+FixAddress (
+ IN UINTN *PhyAddress
+ )
+{
+ //
+ //Note: On ARM platforms don't have to do this as all the functions are virtually mapped.
+ //
+}
+
+// Quick port to ARM
+
+VOID
+Port80 (
+ UINT8 Number
+ )
+{
+ //EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Port80 %02x", Number));
+}
diff --git a/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.h b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.h
new file mode 100644
index 00000000..1e78b3e4
--- /dev/null
+++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.h
@@ -0,0 +1,48 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2012 ARM Ltd. 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.
+
+**/
+
+/*++
+
+Module Name:
+
+ Debug.h
+
+--*/
+
+#ifndef _IA32_IO_ACCESS_H
+#define _IA32_IO_ACCESS_H
+
+#include "SCRTDriver.h"
+
+#define IA32_MAX_IO_ADDRESS 0xFFFF
+
+#define IA32API
+
+
+typedef union {
+ UINT8 VOLATILE *buf;
+ UINT8 VOLATILE *ui8;
+ UINT16 VOLATILE *ui16;
+ UINT32 VOLATILE *ui32;
+ UINT64 VOLATILE *ui64;
+ UINTN VOLATILE ui;
+} PTR;
+
+// This address is assuming a pure PC architecture. Not required?
+#define VIRT_TO_PHYS_OFFSET (0x80000000) //2G
+
+
+
+#endif
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestCacheFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestCacheFunction.c
new file mode 100644
index 00000000..96ee7b57
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestCacheFunction.c
@@ -0,0 +1,137 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2016, ARM Ltd. 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.
+
+**/
+/*++
+
+Module Name:
+
+ DebugSupportBBTestCacheFunction.c
+
+Abstract:
+
+ Interface Function Test Cases of Debug Support Protocol
+
+--*/
+
+
+#include "DebugSupportBBTestMain.h"
+
+/**
+ * Entrypoint for EFI_DEBUG_SUPPORT_PROTOCOL.InvalidateInstructionCache() Function Test.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL.
+ * @param ClientInterface a pointer to the interface to be tested.
+ * @param TestLevel test "thoroughness" control.
+ * @param SupportHandle a handle containing protocols required.
+ * @return EFI_SUCCESS Finish the test successfully.
+ */
+//
+// TDS 3.5
+//
+EFI_STATUS
+BBTestInvalidateInstructionCacheFunctionAutoTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;
+ EFI_TEST_ASSERTION AssertionType;
+ UINT64 Start;
+ UINT64 Length;
+ UINTN MaxProcessorIndex;
+ UINTN ProcessorIndex;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_FAILED,
+ gTestGenericFailureGuid,
+ L"BS.HandleProtocol - Handle standard test library",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ return Status;
+ }
+
+ DebugSupport = (EFI_DEBUG_SUPPORT_PROTOCOL *)ClientInterface;
+
+ if (DebugSupport->Isa != PlatformIsa) {
+ return EFI_SUCCESS;
+ }
+
+ Status = DebugSupport->GetMaximumProcessorIndex (DebugSupport, &MaxProcessorIndex);
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_FAILED,
+ gTestGenericFailureGuid,
+ L"EFI_DEBUG_SUPPORT_PROTOCOL.GetMaximumProcessorIndex",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ return Status;
+ }
+
+ for (ProcessorIndex = 0; ProcessorIndex <= MaxProcessorIndex; ProcessorIndex++) {
+
+ //
+ // Assertion Point 3.5.2.1
+ // Invoke InvalidateInstructionCache and verify interface correctness.
+ //
+
+ // The Physical base of the memory range to be invalidated.
+ Start = 0x0;
+
+ // The minimum number of bytes in the processor's instruction cache to be invalidated.
+ Length = 0x0;
+
+ Status = DebugSupport->InvalidateInstructionCache (DebugSupport, ProcessorIndex, (VOID*)&Start, Length);
+
+ if (EFI_ERROR(Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gDebugSupportBBTestFunctionAssertionGuid015,
+ L"EFI_DEBUG_SUPPORT_PROTOCOL.InvalidateInstructionCache - Invoke this function and verify interface correctness",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ }
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestExceptionCallbackFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestExceptionCallbackFunction.c
new file mode 100644
index 00000000..c27c0c0c
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestExceptionCallbackFunction.c
@@ -0,0 +1,276 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2016, ARM Ltd. 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.
+
+**/
+/*++
+
+Module Name:
+
+ DebugSupportBBExceptionCallbackFunction.c
+
+Abstract:
+
+ Interface Function Test Cases of Debug Support Protocol
+
+--*/
+
+
+#include "DebugSupportBBTestMain.h"
+
+extern volatile UINTN InvokedExceptionCallback;
+extern volatile UINTN InvokedPeriodicCallback;
+
+extern EFI_INSTRUCTION_SET_ARCHITECTURE PlatformIsa;
+
+void
+SoftwareBreak (
+ void
+ )
+{
+ // Not ported to ARM yet
+ ASSERT (FALSE);
+}
+
+/**
+ * Entrypoint for EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback() Function Test.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL.
+ * @param ClientInterface a pointer to the interface to be tested.
+ * @param TestLevel test "thoroughness" control.
+ * @param SupportHandle a handle containing protocols required.
+ * @return EFI_SUCCESS Finish the test successfully.
+ */
+//
+// TDS 3.4
+//
+EFI_STATUS
+BBTestRegisterExceptionCallbackFunctionManualTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;
+ EFI_TEST_ASSERTION AssertionType;
+
+ DebugSupport = (EFI_DEBUG_SUPPORT_PROTOCOL *)ClientInterface;
+
+ if (DebugSupport->Isa != PlatformIsa) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_FAILED,
+ gTestGenericFailureGuid,
+ L"BS.HandleProtocol - Handle standard test library",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ return Status;
+ }
+
+ //
+ // Assertion Point 3.4.2.1
+ // Invoke RegisterExceptionCallback() to install an interrupt handler function.
+ //
+ InvokedExceptionCallback = FALSE;
+ // FIXME: Is it normal that we use EXCEPT_IA32_BREAKPOINT here?
+ // Shouldn't we define proper constants for ARM exceptions in DebugSupportProtocol.h file?
+ Status = DebugSupport->RegisterExceptionCallback (DebugSupport, 0, ExceptionCallback, EXCEPT_IA32_BREAKPOINT);
+
+ if ((Status == EFI_SUCCESS) || (Status == EFI_ALREADY_STARTED)) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gDebugSupportBBTestFunctionAssertionGuid009,
+ L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Invoke this function and verify interface correctness",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // If the callback function is already registed, return
+ //
+ if (EFI_ERROR(Status)) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Test the callback function registed.
+ //
+
+ //
+ // Call SoftwareBreak to invoke the interrupt handler function.
+ //
+ SoftwareBreak ();
+
+ if (InvokedExceptionCallback == FALSE) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gDebugSupportBBTestFunctionAssertionGuid010,
+ L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Verify the callback function was invoked.",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Assertion Point 3.4.2.2
+ // Invoke RegisterPeriodicCallback() to install the Periodic interrupt handler function.
+ // Verify the two callback functions can be both invoked.
+ //
+ InvokedExceptionCallback = FALSE;
+ InvokedPeriodicCallback = FALSE;
+
+ Status = DebugSupport->RegisterPeriodicCallback (DebugSupport, 0, PeriodicCallback);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Wait the PeriodicCallback to be invoked.
+ //
+ gtBS->Stall (500000);
+
+ //
+ // Call SoftwareBreak to invoke the interrupt handler function.
+ //
+ SoftwareBreak ();
+
+ if ((InvokedExceptionCallback == TRUE) && (InvokedPeriodicCallback == TRUE)) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gDebugSupportBBTestFunctionAssertionGuid011,
+ L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Verify the two callback functions can be both invoked.",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Uninstall the Periodic callback function.
+ //
+ Status = DebugSupport->RegisterPeriodicCallback (DebugSupport, 0, NULL);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Assertion Point 3.4.2.3
+ // Invoke RegisterExceptionCallback() to install another interrupt handler function.
+ //
+ Status = DebugSupport->RegisterExceptionCallback (DebugSupport, 0, ExceptionCallback1, EXCEPT_IA32_BREAKPOINT);
+
+ if (Status != EFI_ALREADY_STARTED) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gDebugSupportBBTestFunctionAssertionGuid012,
+ L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Register another callback function.",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Assertion Point 3.4.2.4
+ // Invoke RegisterExceptionCallback() to unstall the interrupt handler function.
+ //
+ Status = DebugSupport->RegisterExceptionCallback (DebugSupport, 0, NULL, EXCEPT_IA32_BREAKPOINT);
+
+ if (EFI_ERROR(Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gDebugSupportBBTestFunctionAssertionGuid013,
+ L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Invoke this function to uninstall the interrupt handler function",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ InvokedExceptionCallback = FALSE;
+
+ //
+ // Call SoftwareBreak to invoke the interrupt handler function.
+ //
+ SoftwareBreak ();
+
+ if (InvokedExceptionCallback != FALSE) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gDebugSupportBBTestFunctionAssertionGuid014,
+ L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Verify the callback function wasn't invoked",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/PlatformIsa.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/PlatformIsa.c
new file mode 100644
index 00000000..8334f601
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/PlatformIsa.c
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2011 - 2012, ARM Ltd. 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.
+
+**/
+/*++
+
+Module Name:
+
+ PlatformIsa.c
+
+Abstract:
+
+ Platform related Isa definition.
+
+--*/
+
+#include "DebugSupportBBTestMain.h"
+
+EFI_INSTRUCTION_SET_ARCHITECTURE PlatformIsa = IsaAArch64;
+
diff --git a/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/EntsLibPlat.h b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/EntsLibPlat.h
new file mode 100644
index 00000000..ff781aee
--- /dev/null
+++ b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/EntsLibPlat.h
@@ -0,0 +1,55 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2012, ARM Ltd. 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.
+
+**/
+/*++
+
+Module Name:
+
+ EntsLibPlat.h
+
+Abstract:
+
+ AArch64 specific defines
+
+--*/
+
+#ifndef _EFI_LIB_PLAT_H_
+#define _EFI_LIB_PLAT_H_
+
+#define MIN_ALIGNMENT_SIZE 8
+
+VOID
+EntsInitializeLibPlatform (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Initialize platform.
+
+Arguments:
+
+ ImageHandle - The image handle.
+ SystemTable - The system table.
+
+Returns:
+
+ None.
+
+--*/
+;
+
+#endif
diff --git a/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/InitPlat.c b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/InitPlat.c
new file mode 100644
index 00000000..70a509a4
--- /dev/null
+++ b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/InitPlat.c
@@ -0,0 +1,55 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2012, ARM Ltd. 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.
+
+**/
+/*++
+
+Module Name:
+
+ InitPlat.c
+
+Abstract:
+
+ Math routines for compatibility with native EFI library routines.
+
+--*/
+
+#include "Efi.h"
+#include "EntsLibPlat.h"
+
+VOID
+EntsInitializeLibPlatform (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Initialize platform.
+
+Arguments:
+
+ ImageHandle - The image handle.
+ SystemTable - The system table.
+
+Returns:
+
+ None.
+
+--*/
+{
+ //
+ // No platform-specific initializations
+ //
+}
--
2.30.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#71529): https://edk2.groups.io/g/devel/message/71529
Mute This Topic: https://groups.io/mt/80507443/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Abner Chang <abner.chang@hpe.com>
> -----Original Message-----
> From: Schaefer, Daniel
> Sent: Tuesday, February 9, 2021 11:44 PM
> To: devel@edk2.groups.io
> Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>; Barton Gao
> <gaojie@byosoft.com.cn>; Samer El-Haj-Mahmoud <Samer.El-Haj-
> Mahmoud@arm.com>; Eric Jin <eric.jin@intel.com>; Arvin Chen
> <arvinx.chen@intel.com>; Leif Lindholm <leif@nuviainc.com>; Heinrich
> Schuchardt <xypron.glpk@gmx.de>; Chang, Abner (HPS SW/FW Technologist)
> <abner.chang@hpe.com>
> Subject: [edk2-test PATCHv2 1/5] SctPkg: Add RISCV64 support by using
> Aarch64 sources
>
> The sources were copied from Aarch64. Follow-up commit will adapt them
> for Riscv64.
>
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3042
>
> Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>
> Cc: Barton Gao <gaojie@byosoft.com.cn>
> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
> Cc: Eric Jin <eric.jin@intel.com>
> Cc: Arvin Chen <arvinx.chen@intel.com>
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Abner Chang <abner.chang@hpe.com>
> Signed-off-by: Daniel Schaefer <daniel.schaefer@hpe.com>
> ---
> uefi-sct/SctPkg/Library/SctLib/Riscv64/SctLibPlat.h
> | 32 +++
> uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c
> | 45 ++++
> uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S
> | 44 ++++
> uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c
> | 182 +++++++++++++
> uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c
> | 88 +++++++
> uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c
> | 68 +++++
> uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.c
> | 134 ++++++++++
> uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.h
> | 48 ++++
> uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /DebugSupportBBTestCacheFunction.c | 137 ++++++++++
> uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /DebugSupportBBTestExceptionCallbackFunction.c | 276
> ++++++++++++++++++++
> uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /PlatformIsa.c | 30 +++
> uefi-
> sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/EntsLib
> Plat.h | 55 ++++
> uefi-
> sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/InitPlat.
> c | 55 ++++
> 13 files changed, 1194 insertions(+)
>
> diff --git a/uefi-sct/SctPkg/Library/SctLib/Riscv64/SctLibPlat.h b/uefi-
> sct/SctPkg/Library/SctLib/Riscv64/SctLibPlat.h
> new file mode 100644
> index 00000000..ee7c656b
> --- /dev/null
> +++ b/uefi-sct/SctPkg/Library/SctLib/Riscv64/SctLibPlat.h
> @@ -0,0 +1,32 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright
> +(c) 2011 - 2012, ARM Ltd. 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.+
> ++**/+/*++++Module Name:++ SctLibPlat.h++Abstract:++ AArch64 specific
> +defines++--*/++#ifndef _EFI_LIB_PLAT_H_+#define
> +_EFI_LIB_PLAT_H_++#define MIN_ALIGNMENT_SIZE 8++#endifdiff --git
> +a/uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c
> +b/uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c
> new file mode 100644
> index 00000000..a48bb2f3
> --- /dev/null
> +++ b/uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c
> @@ -0,0 +1,45 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright (c) 2011
> - 2012, ARM Ltd. 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.+ +**/+/*++++Module Name:++ initplat.c++Abstract:++ Math
> routines for compatibility with native EFI library routines.++--*/++#include
> "SctLibInternal.h"++VOID+InitializeLibPlatform (+ IN EFI_HANDLE
> ImageHandle,+ IN EFI_SYSTEM_TABLE *SystemTable+ )++{+ // No
> platform-specific initializations+}++UINT64+SctReadTsc (+ VOID+ )+{+
> return 0;+}diff --git a/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S
> b/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S
> new file mode 100644
> index 00000000..d223b36b
> --- /dev/null
> +++ b/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S
> @@ -0,0 +1,44 @@
> +## @file+#+# Copyright 2010 - 2012 Unified EFI, Inc.<BR>+# Copyright (c)
> 2012, ARM Ltd. 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.+# +##+#+#+#/*+++#+# Module Name:+#+# GoVirtual.S+#+#--
> */+#start of the code section+.text+/* FIXME: Should alignment be different
> on Aarch64? */+.align 3++.global JumpToTestFunc+.type JumpToTestFunc,
> %function++#----------------------------------------------------------------------------
> --+# VOID+# JumpToTestFunc (+# IN UINTN FuncPointer,+# IN UNITN
> ConfigInfo+# )+#+JumpToTestFunc:+ mov x2, x0+ mov x0, x1++ //
> Jump to Virtual function+ blr x2diff --git a/uefi-
> sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c b/uefi-
> sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c
> new file mode 100644
> index 00000000..397b3514
> --- /dev/null
> +++ b/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c
> @@ -0,0 +1,182 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright (c) 2012,
> ARM Ltd. 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.+ +**/+/*++++Module Name:++ VirtualMemory.c++--
> */++#include "SCRTApp.h"++#define VIRT_TO_PHYS_OFFSET
> (0x80000000) //2G++BOOLEAN HighAddress = FALSE;+UINTN
> PageTable = 0;+++VOID+ConvertRuntimeFuncPtr (+ IN OUT UINTN
> *VirtualFunc+ )+/*++++Routine Description:++ Change RuntimeTestFunc
> physical address to virtual address++Arguments:++ VirtualFunc - On input,
> RuntimeTestFunc physical address.+ On output, RuntimeTest virtual
> address.++Returns:++ NONE++--*/+{+ /*Note: It is presumed that
> on ARM v5, V6 and V7 architectures+ * the MMU is configured and
> enabled in PEI phase. As VirtualFunc+ * is already mapped to virtual
> memory, don't have to do anything here.+ */+ /* FIXME: Is it the same
> on ARM v8? */+}+++EFI_STATUS+DoMemoryAllocation (+ IN UINTN
> PhysicalFunc+ )+/*++++Routine Description:++ Allocate memory and create
> the PageTable to set up physical-virtual map.++Arguments:++ PhysicalFunc -
> Physical address where RuntimeTestFunc locates.++Returns:++
> EFI_STATUS++--*/+{+ EFI_STATUS Status;+
> EFI_PHYSICAL_ADDRESS AllocateMemory;++ //create new page tables or
> use existing page tables.+ //+ // Allocate PageTable memory close to this
> Application image location in+ // the system memory. In this way, it is safe
> for page table memory.+ //+ AllocateMemory = PhysicalFunc;++ Status =
> tBS->AllocatePages (+ AllocateMaxAddress,+
> EfiRuntimeServicesData,+ 1,+
> &AllocateMemory+ );++ if (EFI_ERROR(Status)) {+ return
> Status;+ }++ PageTable = (UINTN)AllocateMemory;+ return
> EFI_SUCCESS;+}+++VOID+PrepareVirtualAddressMap (+ IN UINTN
> MemoryMapSize,+ IN UINTN DescriptorSize,+ IN
> EFI_MEMORY_DESCRIPTOR *MemoryMap,+ IN
> EFI_MEMORY_DESCRIPTOR *VirtualMemoryMap,+ IN OUT UINTN
> *VirtualMapSize+ )+/*++++Routine Description:++ Construct
> VirtualAddressMap from physical address to virtual address++Arguments:++
> MemoryMapSize - The size, in bytes, of the MemoryMap buffer+
> DescriptorSize - The size, in bytes, of an individual
> EFI_MEMORY_DESCRIPTOR+ MemoryMap - A pointer to the current
> memory map+ VirtualMemoryMap - A pointer to the modified virtual
> memory map+ VirtualMapSize - A pointer to the size, in bytes, of the
> VirtualMemoryMap buffer++Returns:++ NONE++--*/+{+ UINTN Index;+
> *VirtualMapSize = 0;++ //+ // Copy entries that need runtime mapping
> to construct virtualMemoryMap+ //+ for (Index = 0; Index <
> (MemoryMapSize / DescriptorSize); Index++) {+ if ((MemoryMap-
> >Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {+
> SctCopyMem ((VOID *) VirtualMemoryMap, (VOID *) MemoryMap,
> DescriptorSize);+ VirtualMemoryMap->VirtualStart = VirtualMemoryMap-
> >PhysicalStart;+ *VirtualMapSize += DescriptorSize;+
> VirtualMemoryMap = NextMemoryDescriptor (VirtualMemoryMap,
> DescriptorSize);+ }++ MemoryMap = NextMemoryDescriptor
> (MemoryMap, DescriptorSize);+ }+}++++VOID+JumpVirtualMode(+ IN
> UINTN VirtualFunc,+ IN UINTN HandOffAddr+ )+/*++++Routine
> Description:++ Enable virtual addressing mode, and jump to
> RuntimeTestFunc in virtual address++Arguments:++ VirtualFunc -
> RuntimeTestFunc virtual address+ HandOffAddr - Configuration Data
> Address++Returns:++ NONE++--*/+{+ //+ // Note: It is assumed that the
> MMU and page tables are configured on ARM platforms+ // based on ARM
> v5 v6 and v7 architecture.+ //+ /* FIXME: Is it the same on ARM v8? */+
> JumpToTestFunc(VirtualFunc, HandOffAddr);+}diff --git a/uefi-
> sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c b/uefi-
> sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c
> new file mode 100644
> index 00000000..6161d596
> --- /dev/null
> +++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c
> @@ -0,0 +1,88 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright (c) 2011
> - 2012 ARM Ltd. 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.+ +**/++/*++++Module Name:++ Debug.c++--*/++#include
> "SCRTDriver.h"++UINTN mHandOffPtr =
> 0;+EFI_PHYSICAL_ADDRESS mIoPortSpaceAddress =
> 0;+++EFI_STATUS+ConsumeHandOff (+ IN UINTN HandOffAddr,+ OUT
> CONF_INFO *ConfigData+ )+{+ RUNTIME_HANDOFF *HandOffPtr;+ //+
> // First fix the memory address of hand off data.+ //+
> FixAddress(&HandOffAddr);+ mHandOffPtr = HandOffAddr;+ HandOffPtr
> = (RUNTIME_HANDOFF*)mHandOffPtr;+ *ConfigData = HandOffPtr-
> >ConfigureInfo;++ if (!HandOffPtr->DebuggerInfo.MmioFlag){+ //+ // If
> debug port is I/O mapped, fix IoBase Address.+ //+
> FixAddress(&HandOffPtr->DebuggerInfo.IoBase);+ mIoPortSpaceAddress
> = HandOffPtr->DebuggerInfo.IoBase;+ } else {+ //+ // If debug port is
> MMIO, fix MmioBase Address.+ //+ FixAddress(&HandOffPtr-
> >DebuggerInfo.MmioBase);+ }++ return
> EFI_SUCCESS;+}+++EFI_STATUS+Send2UART (+ CHAR8 *String+ )+{+
> //+ // TODO: On ARM platforms use platform specific functions to+ // write
> the data to UART.+ //+ return
> EFI_SUCCESS;+}++++EFI_STATUS+DebugWorker (+ IN CHAR8
> *String+ )+{+ EFI_STATUS Status;++ //+ // Send text message to
> registered UART.+ //+ Status = Send2UART(String);+ return Status;+}diff --
> git a/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c b/uefi-
> sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c
> new file mode 100644
> index 00000000..cc8d9869
> --- /dev/null
> +++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c
> @@ -0,0 +1,68 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright (c) 2011
> - 2012 ARM Ltd. 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.+ +**/++/*++++Module Name:++ Dump.c++--*/++#include
> "SCRTDriver.h"++VOID+DumpRuntimeTable()+{+ SctAPrint
> ("\n================Dump Runtime Table===============\n");+
> SctAPrint ("Header Signature = 0x%x\n", VRT->Hdr.Signature);++ SctAPrint
> ("\n================GetTime Service==============\n");+ SctAPrint
> ("GetTime @ 0x%x\n", VRT->GetTime);++ SctAPrint
> ("\n================SetTime Service==============\n");+ SctAPrint
> ("SetTime @ 0x%x\n", VRT->SetTime);++ SctAPrint
> ("\n================GetWakeupTime Service==============\n");+
> SctAPrint ("GetWakeupTime @ 0x%x\n", VRT->GetWakeupTime);++
> SctAPrint ("\n================SetWakeupTime
> Service==============\n");+ SctAPrint ("SetWakeupTime @ 0x%x\n",
> VRT->SetWakeupTime);++ SctAPrint ("\n================GetVariable
> Service==============\n");+ SctAPrint ("GetVariable @ 0x%x\n", VRT-
> >GetVariable);++ SctAPrint ("\n================GetNextVariableName
> Service==============\n");+ SctAPrint ("GetNextVariableName @
> 0x%x\n", VRT->GetNextVariableName);++ SctAPrint
> ("\n================SetVariable Service==============\n");+
> SctAPrint ("SetVariable @ 0x%x\n", VRT->SetVariable);++ SctAPrint
> ("\n================GetNextHighMonotonicCount
> Service==============\n");+ SctAPrint ("GetNextHighMonotonicCount @
> 0x%x\n", VRT->GetNextHighMonotonicCount);++ SctAPrint
> ("\n================ResetSystem Service==============\n");+
> SctAPrint ("ResetSystem @ 0x%x\n", VRT->ResetSystem);+#if 0+ SctAPrint
> ("\n================UpdateCapsule Service==============\n");+
> SctAPrint ("UpdateCapsule @ 0x%x\n", VRT->UpdateCapsule);++ SctAPrint
> ("\n================QueryCapsuleCapabilities
> Service==============\n");+ SctAPrint ("QueryCapsuleCapabilities @
> 0x%x\n", VRT->QueryCapsuleCapabilities);++ SctAPrint
> ("\n================QueryVariableInfo Service==============\n");+
> SctAPrint ("QueryVariableInfo @ 0x%x\n", VRT-
> >QueryVariableInfo);+#endif+}diff --git a/uefi-
> sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.c b/uefi-
> sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.c
> new file mode 100644
> index 00000000..b925e151
> --- /dev/null
> +++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.c
> @@ -0,0 +1,134 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright (c) 2011
> - 2012 ARM Ltd. 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.+ +**/++/*++++Module Name:++ Io.c++--*/++#include
> "Io.h"++EFI_STATUS+EFIAPI+CpuIoServiceWrite (+ IN
> EFI_PEI_CPU_IO_PPI_WIDTH Width,+ IN UINT64 UserAddress,+
> IN UINTN Count,+ IN VOID
> *UserBuffer+ )+/*++++Routine Description:++ Perform the port I/O write
> service++Arguments:++ Width - Width of the port I/O operation+ Address
> - Base address of the port I/O operation+ Count - Count of the number of
> accesses to perform+ Buffer - Pointer to the source buffer from which to
> write data++Returns:++ EFI_SUCCESS - The data was written.+
> EFI_INVALID_PARAMETER - Width is invalid.+ EFI_INVALID_PARAMETER -
> Buffer is NULL.+ EFI_UNSUPPORTED - The Buffer is not aligned for the
> given Width.+ EFI_UNSUPPORTED - The address range specified by
> Address, Width,+ and Count is not valid.++--*/+{+ return
> EFI_UNSUPPORTED;+}+++EFI_STATUS+EfiIoWrite (+ IN
> EFI_PEI_CPU_IO_PPI_WIDTH Width,+ IN UINT64 Address,+ IN
> UINTN Count,+ IN OUT VOID
> *Buffer+ )+/*++++Routine Description:+ Perform an IO write into
> Buffer.++Arguments:+ Width - Width of write transaction, and repeat
> operation to use+ Address - IO address to write+ Count - Number of times
> to write the IO address.+ Buffer - Buffer to write data from. size is Width *
> Count++Returns:+ Status code++--*/+{+ return CpuIoServiceWrite(Width,
> Address, Count, Buffer);+}+++EFI_STATUS+EfiIoRead (+ IN
> EFI_PEI_CPU_IO_PPI_WIDTH Width,+ IN UINT64 Address,+ IN
> UINTN Count,+ IN OUT VOID
> *Buffer+ )+/*++++Routine Description:+ Perform an IO read into
> Buffer.++Arguments:+ Width - Width of read transaction, and repeat
> operation to use+ Address - IO address to read+ Count - Number of times
> to read the IO address.+ Buffer - Buffer to read data into. size is Width *
> Count++Returns:+ Status code++--*/+{+ return
> EFI_UNSUPPORTED;+}+++VOID+FixAddress (+ IN UINTN
> *PhyAddress+ )+{+ //+ //Note: On ARM platforms
> don't have to do this as all the functions are virtually mapped.+
> //+}++// Quick port to ARM++VOID+Port80 (+ UINT8 Number+ )+{+
> //EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Port80 %02x", Number));+}diff --
> git a/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.h b/uefi-
> sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.h
> new file mode 100644
> index 00000000..1e78b3e4
> --- /dev/null
> +++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Io.h
> @@ -0,0 +1,48 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright (c) 2011
> - 2012 ARM Ltd. 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.+ +**/++/*++++Module Name:++ Debug.h++--*/++#ifndef
> _IA32_IO_ACCESS_H+#define _IA32_IO_ACCESS_H++#include
> "SCRTDriver.h"++#define IA32_MAX_IO_ADDRESS 0xFFFF++#define
> IA32API+++typedef union {+ UINT8 VOLATILE *buf;+ UINT8 VOLATILE
> *ui8;+ UINT16 VOLATILE *ui16;+ UINT32 VOLATILE *ui32;+ UINT64
> VOLATILE *ui64;+ UINTN VOLATILE ui;+} PTR;++// This address is assuming
> a pure PC architecture. Not required?+#define VIRT_TO_PHYS_OFFSET
> (0x80000000) //2G++++#endifdiff --git a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /DebugSupportBBTestCacheFunction.c b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /DebugSupportBBTestCacheFunction.c
> new file mode 100644
> index 00000000..96ee7b57
> --- /dev/null
> +++ b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTe
> +++ st/Riscv64/DebugSupportBBTestCacheFunction.c
> @@ -0,0 +1,137 @@
> +/** @file++ Copyright 2006 - 2016 Unified EFI, Inc.<BR>+ Copyright (c) 2011
> - 2016, ARM Ltd. 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.+ +**/+/*++++Module Name:++
> DebugSupportBBTestCacheFunction.c++Abstract:++ Interface Function Test
> Cases of Debug Support Protocol++--*/+++#include
> "DebugSupportBBTestMain.h"++/**+ * Entrypoint for
> EFI_DEBUG_SUPPORT_PROTOCOL.InvalidateInstructionCache() Function
> Test.+ * @param This a pointer of EFI_BB_TEST_PROTOCOL.+ * @param
> ClientInterface a pointer to the interface to be tested.+ * @param TestLevel
> test "thoroughness" control.+ * @param SupportHandle a handle containing
> protocols required.+ * @return EFI_SUCCESS Finish the test successfully.+
> */+//+// TDS
> 3.5+//+EFI_STATUS+BBTestInvalidateInstructionCacheFunctionAutoTest (+
> IN EFI_BB_TEST_PROTOCOL *This,+ IN VOID *ClientInterface,+
> IN EFI_TEST_LEVEL TestLevel,+ IN EFI_HANDLE
> SupportHandle+ )+{+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL
> *StandardLib;+ EFI_STATUS Status;+
> EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;+
> EFI_TEST_ASSERTION AssertionType;+ UINT64
> Start;+ UINT64 Length;+ UINTN
> MaxProcessorIndex;+ UINTN ProcessorIndex;++ //+ // Get
> the Standard Library Interface+ //+ Status = gtBS->HandleProtocol (+
> SupportHandle,+ &gEfiStandardTestLibraryGuid,+ (VOID **)
> &StandardLib+ );++ if (EFI_ERROR(Status)) {+ StandardLib-
> >RecordAssertion (+ StandardLib,+
> EFI_TEST_ASSERTION_FAILED,+ gTestGenericFailureGuid,+
> L"BS.HandleProtocol - Handle standard test library",+
> L"%a:%d:Status - %r",+ __FILE__,+ (UINTN)__LINE__,+
> Status+ );+ return Status;+ }++ DebugSupport =
> (EFI_DEBUG_SUPPORT_PROTOCOL *)ClientInterface;++ if (DebugSupport-
> >Isa != PlatformIsa) {+ return EFI_SUCCESS;+ }++ Status = DebugSupport-
> >GetMaximumProcessorIndex (DebugSupport, &MaxProcessorIndex);+ if
> (EFI_ERROR(Status)) {+ StandardLib->RecordAssertion (+
> StandardLib,+ EFI_TEST_ASSERTION_FAILED,+
> gTestGenericFailureGuid,+
> L"EFI_DEBUG_SUPPORT_PROTOCOL.GetMaximumProcessorIndex",+
> L"%a:%d:Status - %r",+ __FILE__,+ (UINTN)__LINE__,+
> Status+ );+ return Status;+ }++ for (ProcessorIndex = 0;
> ProcessorIndex <= MaxProcessorIndex; ProcessorIndex++) {++ //+ //
> Assertion Point 3.5.2.1+ // Invoke InvalidateInstructionCache and verify
> interface correctness.+ //++ // The Physical base of the memory range to
> be invalidated.+ Start = 0x0;++ // The minimum number of bytes in the
> processor's instruction cache to be invalidated.+ Length = 0x0;++ Status =
> DebugSupport->InvalidateInstructionCache (DebugSupport, ProcessorIndex,
> (VOID*)&Start, Length);++ if (EFI_ERROR(Status)) {+ AssertionType =
> EFI_TEST_ASSERTION_FAILED;+ } else {+ AssertionType =
> EFI_TEST_ASSERTION_PASSED;+ }++ StandardLib->RecordAssertion (+
> StandardLib,+ AssertionType,+
> gDebugSupportBBTestFunctionAssertionGuid015,+
> L"EFI_DEBUG_SUPPORT_PROTOCOL.InvalidateInstructionCache - Invoke this
> function and verify interface correctness",+ L"%a:%d:Status - %r",+
> __FILE__,+ (UINTN)__LINE__,+ Status+ );+ }++
> return EFI_SUCCESS;+}+diff --git a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /DebugSupportBBTestExceptionCallbackFunction.c b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /DebugSupportBBTestExceptionCallbackFunction.c
> new file mode 100644
> index 00000000..c27c0c0c
> --- /dev/null
> +++ b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTe
> +++ st/Riscv64/DebugSupportBBTestExceptionCallbackFunction.c
> @@ -0,0 +1,276 @@
> +/** @file++ Copyright 2006 - 2016 Unified EFI, Inc.<BR>+ Copyright (c) 2011
> - 2016, ARM Ltd. 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.+ +**/+/*++++Module Name:++
> DebugSupportBBExceptionCallbackFunction.c++Abstract:++ Interface
> Function Test Cases of Debug Support Protocol++--*/+++#include
> "DebugSupportBBTestMain.h"++extern volatile UINTN
> InvokedExceptionCallback;+extern volatile UINTN
> InvokedPeriodicCallback;++extern EFI_INSTRUCTION_SET_ARCHITECTURE
> PlatformIsa;++void+SoftwareBreak (+ void+ )+{+ // Not ported to ARM
> yet+ ASSERT (FALSE);+}++/**+ * Entrypoint for
> EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback() Function
> Test.+ * @param This a pointer of EFI_BB_TEST_PROTOCOL.+ * @param
> ClientInterface a pointer to the interface to be tested.+ * @param TestLevel
> test "thoroughness" control.+ * @param SupportHandle a handle containing
> protocols required.+ * @return EFI_SUCCESS Finish the test successfully.+
> */+//+// TDS
> 3.4+//+EFI_STATUS+BBTestRegisterExceptionCallbackFunctionManualTest (+
> IN EFI_BB_TEST_PROTOCOL *This,+ IN VOID *ClientInterface,+
> IN EFI_TEST_LEVEL TestLevel,+ IN EFI_HANDLE
> SupportHandle+ )+{+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL
> *StandardLib;+ EFI_STATUS Status;+
> EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;+
> EFI_TEST_ASSERTION AssertionType;++ DebugSupport =
> (EFI_DEBUG_SUPPORT_PROTOCOL *)ClientInterface;++ if (DebugSupport-
> >Isa != PlatformIsa) {+ return EFI_SUCCESS;+ }++ //+ // Get the Standard
> Library Interface+ //+ Status = gtBS->HandleProtocol (+
> SupportHandle,+ &gEfiStandardTestLibraryGuid,+ (VOID **)
> &StandardLib+ );++ if (EFI_ERROR(Status)) {+ StandardLib-
> >RecordAssertion (+ StandardLib,+
> EFI_TEST_ASSERTION_FAILED,+ gTestGenericFailureGuid,+
> L"BS.HandleProtocol - Handle standard test library",+
> L"%a:%d:Status - %r",+ __FILE__,+ (UINTN)__LINE__,+
> Status+ );+ return Status;+ }++ //+ // Assertion Point 3.4.2.1+ //
> Invoke RegisterExceptionCallback() to install an interrupt handler function.+
> //+ InvokedExceptionCallback = FALSE;+ // FIXME: Is it normal that we use
> EXCEPT_IA32_BREAKPOINT here?+ // Shouldn't we define proper constants
> for ARM exceptions in DebugSupportProtocol.h file?+ Status =
> DebugSupport->RegisterExceptionCallback (DebugSupport, 0,
> ExceptionCallback, EXCEPT_IA32_BREAKPOINT);++ if ((Status ==
> EFI_SUCCESS) || (Status == EFI_ALREADY_STARTED)) {+ AssertionType =
> EFI_TEST_ASSERTION_PASSED;+ } else {+ AssertionType =
> EFI_TEST_ASSERTION_FAILED;+ }++ StandardLib->RecordAssertion (+
> StandardLib,+ AssertionType,+
> gDebugSupportBBTestFunctionAssertionGuid009,+
> L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Invoke this
> function and verify interface correctness",+ L"%a:%d:Status - %r",+
> __FILE__,+ (UINTN)__LINE__,+ Status+ );++ //+ // If
> the callback function is already registed, return+ //+ if (EFI_ERROR(Status))
> {+ return EFI_SUCCESS;+ }++ //+ // Test the callback function registed.+
> //++ //+ // Call SoftwareBreak to invoke the interrupt handler function.+
> //+ SoftwareBreak ();++ if (InvokedExceptionCallback == FALSE) {+
> AssertionType = EFI_TEST_ASSERTION_FAILED;+ } else {+ AssertionType =
> EFI_TEST_ASSERTION_PASSED;+ }++ StandardLib->RecordAssertion (+
> StandardLib,+ AssertionType,+
> gDebugSupportBBTestFunctionAssertionGuid010,+
> L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Verify the
> callback function was invoked.",+ L"%a:%d:Status - %r",+
> __FILE__,+ (UINTN)__LINE__,+ Status+ );++ //+ //
> Assertion Point 3.4.2.2+ // Invoke RegisterPeriodicCallback() to install the
> Periodic interrupt handler function.+ // Verify the two callback functions can
> be both invoked.+ //+ InvokedExceptionCallback = FALSE;+
> InvokedPeriodicCallback = FALSE;++ Status = DebugSupport-
> >RegisterPeriodicCallback (DebugSupport, 0, PeriodicCallback);+ if
> (EFI_ERROR(Status)) {+ return Status;+ }++ //+ // Wait the
> PeriodicCallback to be invoked.+ //+ gtBS->Stall (500000);++ //+ // Call
> SoftwareBreak to invoke the interrupt handler function.+ //+
> SoftwareBreak ();++ if ((InvokedExceptionCallback == TRUE) &&
> (InvokedPeriodicCallback == TRUE)) {+ AssertionType =
> EFI_TEST_ASSERTION_PASSED;+ } else {+ AssertionType =
> EFI_TEST_ASSERTION_FAILED;+ }++ StandardLib->RecordAssertion (+
> StandardLib,+ AssertionType,+
> gDebugSupportBBTestFunctionAssertionGuid011,+
> L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Verify the
> two callback functions can be both invoked.",+ L"%a:%d:Status -
> %r",+ __FILE__,+ (UINTN)__LINE__,+
> Status+ );++ //+ // Uninstall the Periodic callback function.+ //+
> Status = DebugSupport->RegisterPeriodicCallback (DebugSupport, 0, NULL);+
> if (EFI_ERROR(Status)) {+ return Status;+ }++ //+ // Assertion Point
> 3.4.2.3+ // Invoke RegisterExceptionCallback() to install another interrupt
> handler function.+ //+ Status = DebugSupport->RegisterExceptionCallback
> (DebugSupport, 0, ExceptionCallback1, EXCEPT_IA32_BREAKPOINT);++ if
> (Status != EFI_ALREADY_STARTED) {+ AssertionType =
> EFI_TEST_ASSERTION_FAILED;+ } else {+ AssertionType =
> EFI_TEST_ASSERTION_PASSED;+ }++ StandardLib->RecordAssertion (+
> StandardLib,+ AssertionType,+
> gDebugSupportBBTestFunctionAssertionGuid012,+
> L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Register
> another callback function.",+ L"%a:%d:Status - %r",+
> __FILE__,+ (UINTN)__LINE__,+ Status+ );++ //+ //
> Assertion Point 3.4.2.4+ // Invoke RegisterExceptionCallback() to unstall the
> interrupt handler function.+ //+ Status = DebugSupport-
> >RegisterExceptionCallback (DebugSupport, 0, NULL,
> EXCEPT_IA32_BREAKPOINT);++ if (EFI_ERROR(Status)) {+ AssertionType =
> EFI_TEST_ASSERTION_FAILED;+ } else {+ AssertionType =
> EFI_TEST_ASSERTION_PASSED;+ }++ StandardLib->RecordAssertion (+
> StandardLib,+ AssertionType,+
> gDebugSupportBBTestFunctionAssertionGuid013,+
> L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Invoke this
> function to uninstall the interrupt handler function",+
> L"%a:%d:Status - %r",+ __FILE__,+ (UINTN)__LINE__,+
> Status+ );++ InvokedExceptionCallback = FALSE;++ //+ // Call
> SoftwareBreak to invoke the interrupt handler function.+ //+
> SoftwareBreak ();++ if (InvokedExceptionCallback != FALSE) {+
> AssertionType = EFI_TEST_ASSERTION_FAILED;+ } else {+ AssertionType =
> EFI_TEST_ASSERTION_PASSED;+ }++ StandardLib->RecordAssertion (+
> StandardLib,+ AssertionType,+
> gDebugSupportBBTestFunctionAssertionGuid014,+
> L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - Verify the
> callback function wasn't invoked",+ L"%a:%d:Status - %r",+
> __FILE__,+ (UINTN)__LINE__,+ Status+ );++ return
> EFI_SUCCESS;+}+diff --git a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /PlatformIsa.c b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64
> /PlatformIsa.c
> new file mode 100644
> index 00000000..8334f601
> --- /dev/null
> +++ b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTe
> +++ st/Riscv64/PlatformIsa.c
> @@ -0,0 +1,30 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright
> +(c) 2011 - 2012, ARM Ltd. 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.+
> ++**/+/*++++Module Name:++ PlatformIsa.c++Abstract:++ Platform
> related
> +Isa definition.++--*/++#include
> +"DebugSupportBBTestMain.h"++EFI_INSTRUCTION_SET_ARCHITECTURE
> +PlatformIsa = IsaAArch64;+diff --git
> +a/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/
> +EntsLibPlat.h
> +b/uefi-
> sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/
> +EntsLibPlat.h
> new file mode 100644
> index 00000000..ff781aee
> --- /dev/null
> +++ b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv
> +++ 64/EntsLibPlat.h
> @@ -0,0 +1,55 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright (c) 2010
> - 2012, ARM Ltd. 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.+ +**/+/*++++Module Name:++ EntsLibPlat.h++Abstract:++
> AArch64 specific defines++--*/++#ifndef _EFI_LIB_PLAT_H_+#define
> _EFI_LIB_PLAT_H_++#define MIN_ALIGNMENT_SIZE
> 8++VOID+EntsInitializeLibPlatform (+ IN EFI_HANDLE ImageHandle,+ IN
> EFI_SYSTEM_TABLE *SystemTable+ )+/*++++Routine Description:++
> Initialize platform.++Arguments:++ ImageHandle - The image handle.+
> SystemTable - The system table.++Returns:++ None.++--
> */+;++#endifdiff --git a/uefi-
> sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/InitPlat.
> c b/uefi-
> sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/InitPlat.
> c
> new file mode 100644
> index 00000000..70a509a4
> --- /dev/null
> +++ b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv
> +++ 64/InitPlat.c
> @@ -0,0 +1,55 @@
> +/** @file++ Copyright 2006 - 2012 Unified EFI, Inc.<BR>+ Copyright (c) 2010
> - 2012, ARM Ltd. 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.+ +**/+/*++++Module Name:++ InitPlat.c++Abstract:++ Math
> routines for compatibility with native EFI library routines.++--*/++#include
> "Efi.h"+#include "EntsLibPlat.h"++VOID+EntsInitializeLibPlatform (+ IN
> EFI_HANDLE ImageHandle,+ IN EFI_SYSTEM_TABLE
> *SystemTable+ )+/*++++Routine Description:++ Initialize
> platform.++Arguments:++ ImageHandle - The image handle.+
> SystemTable - The system table.++Returns:++ None.++--*/+{+ //+ //
> No platform-specific initializations+ //+}--
> 2.30.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#72171): https://edk2.groups.io/g/devel/message/72171
Mute This Topic: https://groups.io/mt/80507443/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.