From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.1898.1614828108171599307 for ; Wed, 03 Mar 2021 19:21:48 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=i9nZOT1m; spf=pass (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=06976aa159=daniel.schaefer@hpe.com) Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1243HwLu029370; Thu, 4 Mar 2021 03:21:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=QQzoRuQUQJY5Z9/djxRR4/oHB+bnvZB4zfCdqLj2k1Q=; b=i9nZOT1mN/S+2z31RjYP0fntEUxQO2bf8FMZVh4HE6C79UU428dMwNUQSJh8T8kiGemp Vl928Y920yePsFyzGKuElW/aeRQGXkAoPMQfrXD+1hnuEM9Wzf02FeIz1l30rY19BlDy TzRYvemwX6NRsr2RQzGZbvoGSfa0E9ckWyxMGhU2UjMkzfF0X+18klo7OdUWJlEsUzLf HnTR2w9S5XpGdvg+x/pKpklD/V3Lmx0YK6vjW7nZQtTmOMUl/I62jiIb3mSiIf70vLzC TyiEGx+ExBHyYhV1uNtL4/STIkCsxwYv1+7SWVm5h3xbvIQWx3slSGHryvkuNF4bOEnl pQ== Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0a-002e3701.pphosted.com with ESMTP id 3720nmjdra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Mar 2021 03:21:41 +0000 Received: from G4W9120.americas.hpqcorp.net (g4w9120.houston.hp.com [16.210.21.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3426.houston.hpe.com (Postfix) with ESMTPS id DEB764E; Thu, 4 Mar 2021 03:21:40 +0000 (UTC) Received: from G2W6309.americas.hpqcorp.net (2002:10c5:4033::10c5:4033) by G4W9120.americas.hpqcorp.net (2002:10d2:150f::10d2:150f) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 4 Mar 2021 03:21:40 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (15.241.52.10) by G2W6309.americas.hpqcorp.net (16.197.64.51) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 4 Mar 2021 03:21:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oPE7vKCA7AOSogodmOSeGI8BP6m0UI6lPPV1KmwzucD1fLGnEcXyvIpGGORZEoPnS/Y99f3v0Py/KUKR2TJTVEbzzTxQuxlGNofimvJCGJrgXxhI/zAo08QXHqcMLloxPx/OGmUa7qrND+ukG/9YCv8iia9PpoUA+L98dqWQ4vvRMXtc3T5Cl4CwxUu+z8fwVV6eTCy3P8OCvrKoJmaU3mHRLubccYHf1+72j7V0TwFOizw5eNcHsUdq+XKGBShByYF9kiK7weekOtO3e0NhsNc3Dc3bC3Fj6UROj4SV4FWVu5bJ4pDX3u9i+Q7ADqoTeRBry/4OJfqSVNx+4Vvh6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QQzoRuQUQJY5Z9/djxRR4/oHB+bnvZB4zfCdqLj2k1Q=; b=EzmgUuD+WOzbPGNjD0cGfLZSDWLP6n5Kq/titWgqFqMbxiyos8KgxcuZBJrKpNbipwSACcnR4pksDBfF74e4HTWUPEgFqGqWNKmiv+jDrTKy5ncsedJDhGq8DIfg/6tkRpA+l9JmsWLKqtPNHmsq4HwgS5Aw9SNXSPLmrGeLTiTUKCnhux1Q8EWdY+JTjWNw5Ep2CuJBdcHKMjRM9jRHqAeq6mclNdbETAOJMTNPQmkNReIQd0JpMwh9/VQI3mJ9CWAXRbSLvXRoBPFiw2PkDyQ/MKxLko8jtezOi7vd3goBVvD2++L9SF9qfCdr09lIS5ud5VWgnLFhtCMOVJh2Ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; Received: from DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760d::23) by DF4PR8401MB0506.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7606::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Thu, 4 Mar 2021 03:21:38 +0000 Received: from DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM ([fe80::ad2c:ff74:846c:5318]) by DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM ([fe80::ad2c:ff74:846c:5318%7]) with mapi id 15.20.3912.017; Thu, 4 Mar 2021 03:21:38 +0000 From: "Daniel Schaefer" To: CC: G Edhaya Chandran , Barton Gao , Samer El-Haj-Mahmoud , Eric Jin , Arvin Chen , Leif Lindholm , Heinrich Schuchardt , Abner Chang Subject: [edk2-test PATCHv3 1/5] SctPkg: Add RISCV64 support by using Aarch64 sources Date: Thu, 4 Mar 2021 11:21:12 +0800 Message-ID: <20210304032116.24357-2-daniel.schaefer@hpe.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210304032116.24357-1-daniel.schaefer@hpe.com> References: <20210304032116.24357-1-daniel.schaefer@hpe.com> X-Originating-IP: [15.211.146.34] X-ClientProxiedBy: SG2PR06CA0172.apcprd06.prod.outlook.com (2603:1096:1:1e::26) To DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760d::23) X-MS-Exchange-MessageSentRepresentingType: 1 Received: from x360-nix.wireless.hpe.com (15.211.146.34) by SG2PR06CA0172.apcprd06.prod.outlook.com (2603:1096:1:1e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Thu, 4 Mar 2021 03:21:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 58d4d74e-7184-451a-497f-08d8debc9f59 X-MS-TrafficTypeDiagnostic: DF4PR8401MB0506: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +VwzEHOxn8r8ihiEubgXbkbppMAC5PCYS2Re1ffHcZ3xku0AMotuw4CukyB4TlBK4beetCVzbPnf1Sy541XMfq0A/imyV4FAcOiUc4les3jTq5JGw/F1jKWGD3upoawOs1eghNtioIEnCYWaiKpkY1ulpbvMrZYlnxw8IAo11SKg86E1I3bGaBHEY1NvL8Qh6K+nd7cwVLWV++ePDfiFlkAaQ794oKCkp/xSLKEy+EzJnPBztrwtdw4cDTuxMvmLYlf665FMCSdV1KxKLo5bv05GzQOynbf7v9ZALhPrfDIX+vWfnS3kacjrgC45/ac6lW6J5G+z5PanJl53fL7wNpJhuZoRSzLUpM0LXkR5pROkNrq4aI4ujnPEpvaNksbPhQ0g6ZAvx/WvOmpsvoWmFA3MgZ59DO3/qtIZJi0WH7hWrv4Ddb+RR8pBjlxrjAbOXmOXtLl9ZIqhHipL9j/kEr60KkJ1ruZGG/FDeocJkQSmTiTXjSDN3d2S8wks15YQ1aEnF/BRGhWSynsQbxbCBgBwyexvSqMDPHCUuMCen7ESCfu/8hbDaTYh3jXjn8gAAMAbOZKX2JxobFFPb7HCnbdmAME5ACgt/rishHtzdug= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(136003)(366004)(346002)(396003)(376002)(39860400002)(316002)(5660300002)(26005)(186003)(83380400001)(1076003)(86362001)(30864003)(66946007)(2616005)(6916009)(8936002)(6666004)(956004)(2906002)(44832011)(36756003)(16526019)(66556008)(66476007)(4326008)(19627235002)(8676002)(7696005)(478600001)(52116002)(15188155005)(6486002)(16799955002)(54906003)(966005)(579004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?B7sd9ZqSM5WZDiCBRO7kPXYyzbXfUXAJ5yYRvZneDA2ScgO9oZx81O0hqNA7?= =?us-ascii?Q?c6gpDvT2owO+Ae8xCmxJz8opfasQyf2bPnyW5bEeEFDr1gt1gFhHJpQ3wto/?= =?us-ascii?Q?4q+IuI+XcjXaQHQJq33Gu5iOdsJdJ+tbqzF9Z0oeFS++IdSmZNXQOBDgbzev?= =?us-ascii?Q?be7WBnh2dbGk1bkjkh4waDxvWJs3uVMcPoQSr4TzzDdI1ybrgJlipwqNn7TW?= =?us-ascii?Q?vdNKwdn45DbUCZFQGIjXkRpiz69udQO/hUYIiMU+HrOr5QpQSUzKrVP4l3ZS?= =?us-ascii?Q?EEsfwZeSe2dhHAHa+qJgubVtm4Cq4S77kiF4su8wrWX0yh9g35HzEWKXqmnY?= =?us-ascii?Q?Z05HydFjj44Xnsy0IA3mXssc8YqZvtMcmcW/a4aQirEMrspfBoNnLy+W68lz?= =?us-ascii?Q?tO/35uNHFPp01ZDfJa9qP5l5HgozkjX/a90KNzcueENtZXDWRHnlDWsXPlPJ?= =?us-ascii?Q?eSR79zq7yC179YSTYzmB8ESEPxQuJKMxvBOhBLaNDx7aWajR/uBeDQjfse4q?= =?us-ascii?Q?q49pwAjO2QPs5dKEXKi3x6tzBKOYqYQ4vpTfZELfON5bvhSzVUKPm/+DLM/G?= =?us-ascii?Q?wwOgP2Gi1IqOmqj3RbjZOmCUCkflQHczOZ2HURhapKwa5rIo+hN6BFpOuVvg?= =?us-ascii?Q?e11oMD8NTyq5Lw7kpH/8uYPIC4TP16iPizUAVOpF/THe0w73SChdN845lOJc?= =?us-ascii?Q?IR8/t6YznDmQYFOY+ALdcifH8QuYwycV7CH3Fdwx0j4uGee8FDwAcjCYK+DC?= =?us-ascii?Q?i7GTRqRNcCWViqvYHvud9L3Le1+e/dZP6nO4FW1OTclxjpy6Pjrr9YOtHgCv?= =?us-ascii?Q?wakD/vDrCq5Dgiqm7gJpytOBPEdhFaE8mqbcxLQQNIme/OuITXcfPZT1G79A?= =?us-ascii?Q?UzLlWKxuPfPhwDULWqIk+x9NN/AUk3E+jFjs80Ts3eeMII+Sc4X5gTpuwSZm?= =?us-ascii?Q?Dz67/BeXWIgU5SaPJp/fp2ULVzq5XcPOGbr4AcDWb3bBkJMuA1D9NU2uBa7a?= =?us-ascii?Q?0tx/Kc6T8gtWgd8iyRF5KCa+Rg8yvAwWml6Y1OqUG7MQcS4lVHTiarnsYUxF?= =?us-ascii?Q?eSwNGYKQaqkpfzv7xKz3QKsHyy/LlE9XVhRQL/g7a4gdXJKc+Ywy9weE45N8?= =?us-ascii?Q?iYN5CSehXGa5S33JT8woTWdnEpSXWlI78GJk0WNPDB/QG3r4vKGkHEob4qfm?= =?us-ascii?Q?MWkek93bsahQGf+RND8z9xpoBchOxoWjXAbZ5inzAl5BhKQzFw89FY9li1PJ?= =?us-ascii?Q?xFBkNud+AS0XhK6eelRZqA79Ni3BhxAa+kClCfsjWR/w6HcTGefszifd8CtW?= =?us-ascii?Q?wSlAKiXZqkxB0tpD2BALv/dn?= X-MS-Exchange-CrossTenant-Network-Message-Id: 58d4d74e-7184-451a-497f-08d8debc9f59 X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 03:21:38.6339 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GCJFcatCeEzj8muhZjv4sAYc1rtsBOHxp0V+e/c4QAYh582H5ZKecFsiYxlI1cJHjdG2p3Hygez69fIYl1h/Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0506 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-04_01:2021-03-03,2021-03-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103040012 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable The sources were copied from Aarch64. Follow-up commit will adapt them for Riscv64. REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3042 Cc: G Edhaya Chandran Cc: Barton Gao Cc: Samer El-Haj-Mahmoud Cc: Eric Jin Cc: Arvin Chen Cc: Leif Lindholm Cc: Heinrich Schuchardt Cc: Abner Chang Signed-off-by: Daniel Schaefer --- 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/Riscv= 64/DebugSupportBBTestCacheFunction.c | 137 ++++++++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv= 64/DebugSupportBBTestExceptionCallbackFunction.c | 276 ++++++++++++++++++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv= 64/PlatformIsa.c | 30 +++ uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/EntsL= ibPlat.h | 55 ++++ uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/Riscv64/InitP= lat.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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + SctLibPlat.h=0D +=0D +Abstract:=0D +=0D + AArch64 specific defines=0D +=0D +--*/=0D +=0D +#ifndef _EFI_LIB_PLAT_H_=0D +#define _EFI_LIB_PLAT_H_=0D +=0D +#define MIN_ALIGNMENT_SIZE 8=0D +=0D +#endif=0D diff --git a/uefi-sct/SctPkg/Library/SctLib/Riscv64/initplat.c b/uefi-sct/S= ctPkg/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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + initplat.c=0D +=0D +Abstract:=0D +=0D + Math routines for compatibility with native EFI library routines.=0D +=0D +--*/=0D +=0D +#include "SctLibInternal.h"=0D +=0D +VOID=0D +InitializeLibPlatform (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +=0D +{=0D + // No platform-specific initializations=0D +}=0D +=0D +UINT64=0D +SctReadTsc (=0D + VOID=0D + )=0D +{=0D + return 0;=0D +}=0D diff --git a/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/GoVirtual.S b/uefi-sct/Sc= tPkg/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=0D +#=0D +# Copyright 2010 - 2012 Unified EFI, Inc.
=0D +# Copyright (c) 2012, ARM Ltd. All rights reserved.
=0D +#=0D +# This program and the accompanying materials=0D +# are licensed and made available under the terms and conditions of the B= SD License=0D +# which accompanies this distribution. The full text of the license may = be found at =0D +# http://opensource.org/licenses/bsd-license.php=0D +# =0D +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED.=0D +# =0D +##=0D +#=0D +#=0D +#/*++=0D +#=0D +# Module Name:=0D +#=0D +# GoVirtual.S=0D +#=0D +#--*/=0D +#start of the code section=0D +.text=0D +/* FIXME: Should alignment be different on Aarch64? */=0D +.align 3=0D +=0D +.global JumpToTestFunc=0D +.type JumpToTestFunc, %function=0D +=0D +#-------------------------------------------------------------------------= -----=0D +# VOID=0D +# JumpToTestFunc (=0D +# IN UINTN FuncPointer,=0D +# IN UNITN ConfigInfo=0D +# )=0D +#=0D +JumpToTestFunc:=0D + mov x2, x0=0D + mov x0, x1=0D +=0D + // Jump to Virtual function=0D + blr x2=0D diff --git a/uefi-sct/SctPkg/SCRT/SCRTApp/Riscv64/VirtualMemory.c b/uefi-sc= t/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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2012, ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + VirtualMemory.c=0D +=0D +--*/=0D +=0D +#include "SCRTApp.h"=0D +=0D +#define VIRT_TO_PHYS_OFFSET (0x80000000) //2G=0D +=0D +BOOLEAN HighAddress =3D FALSE;=0D +UINTN PageTable =3D 0;=0D +=0D +=0D +VOID=0D +ConvertRuntimeFuncPtr (=0D + IN OUT UINTN *VirtualFunc=0D + )=0D +/*++=0D +=0D +Routine Description:=0D +=0D + Change RuntimeTestFunc physical address to virtual address=0D +=0D +Arguments:=0D +=0D + VirtualFunc - On input, RuntimeTestFunc physical address.=0D + On output, RuntimeTest virtual address.=0D +=0D +Returns:=0D +=0D + NONE=0D +=0D +--*/=0D +{=0D + /*Note: It is presumed that on ARM v5, V6 and V7 architectures=0D + * the MMU is configured and enabled in PEI phase. As VirtualFunc=0D + * is already mapped to virtual memory, don't have to do anything here.=0D + */=0D + /* FIXME: Is it the same on ARM v8? */=0D +}=0D +=0D +=0D +EFI_STATUS=0D +DoMemoryAllocation (=0D + IN UINTN PhysicalFunc=0D + )=0D +/*++=0D +=0D +Routine Description:=0D +=0D + Allocate memory and create the PageTable to set up physical-virtual map.= =0D +=0D +Arguments:=0D +=0D + PhysicalFunc - Physical address where RuntimeTestFunc locates.=0D +=0D +Returns:=0D +=0D + EFI_STATUS=0D +=0D +--*/=0D +{=0D + EFI_STATUS Status;=0D + EFI_PHYSICAL_ADDRESS AllocateMemory;=0D +=0D + //create new page tables or use existing page tables.=0D + //=0D + // Allocate PageTable memory close to this Application image location in= =0D + // the system memory. In this way, it is safe for page table memory.=0D + //=0D + AllocateMemory =3D PhysicalFunc;=0D +=0D + Status =3D tBS->AllocatePages (=0D + AllocateMaxAddress,=0D + EfiRuntimeServicesData,=0D + 1,=0D + &AllocateMemory=0D + );=0D +=0D + if (EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D +=0D + PageTable =3D (UINTN)AllocateMemory;=0D + return EFI_SUCCESS;=0D +}=0D +=0D +=0D +VOID=0D +PrepareVirtualAddressMap (=0D + IN UINTN MemoryMapSize,=0D + IN UINTN DescriptorSize,=0D + IN EFI_MEMORY_DESCRIPTOR *MemoryMap,=0D + IN EFI_MEMORY_DESCRIPTOR *VirtualMemoryMap,=0D + IN OUT UINTN *VirtualMapSize=0D + )=0D +/*++=0D +=0D +Routine Description:=0D +=0D + Construct VirtualAddressMap from physical address to virtual address=0D +=0D +Arguments:=0D +=0D + MemoryMapSize - The size, in bytes, of the MemoryMap buffer=0D + DescriptorSize - The size, in bytes, of an individual EFI_MEMORY_DESC= RIPTOR=0D + MemoryMap - A pointer to the current memory map=0D + VirtualMemoryMap - A pointer to the modified virtual memory map=0D + VirtualMapSize - A pointer to the size, in bytes, of the VirtualMemor= yMap buffer=0D +=0D +Returns:=0D +=0D + NONE=0D +=0D +--*/=0D +{=0D + UINTN Index;=0D + *VirtualMapSize =3D 0;=0D +=0D + //=0D + // Copy entries that need runtime mapping to construct virtualMemoryMap= =0D + //=0D + for (Index =3D 0; Index < (MemoryMapSize / DescriptorSize); Index++) {=0D + if ((MemoryMap->Attribute & EFI_MEMORY_RUNTIME) =3D=3D EFI_MEMORY_RUNT= IME) {=0D + SctCopyMem ((VOID *) VirtualMemoryMap, (VOID *) MemoryMap, Descripto= rSize);=0D + VirtualMemoryMap->VirtualStart =3D VirtualMemoryMap->PhysicalStart;= =0D + *VirtualMapSize +=3D DescriptorSize;=0D + VirtualMemoryMap =3D NextMemoryDescriptor (VirtualMemoryMap, Descrip= torSize);=0D + }=0D +=0D + MemoryMap =3D NextMemoryDescriptor (MemoryMap, DescriptorSize);=0D + }=0D +}=0D +=0D +=0D +=0D +VOID=0D +JumpVirtualMode(=0D + IN UINTN VirtualFunc,=0D + IN UINTN HandOffAddr=0D + )=0D +/*++=0D +=0D +Routine Description:=0D +=0D + Enable virtual addressing mode, and jump to RuntimeTestFunc in virtual a= ddress=0D +=0D +Arguments:=0D +=0D + VirtualFunc - RuntimeTestFunc virtual address=0D + HandOffAddr - Configuration Data Address=0D +=0D +Returns:=0D +=0D + NONE=0D +=0D +--*/=0D +{=0D + //=0D + // Note: It is assumed that the MMU and page tables are configured on AR= M platforms=0D + // based on ARM v5 v6 and v7 architecture.=0D + //=0D + /* FIXME: Is it the same on ARM v8? */=0D + JumpToTestFunc(VirtualFunc, HandOffAddr);=0D +}=0D diff --git a/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Debug.c b/uefi-sct/Sct= Pkg/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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2012 ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +=0D +/*++=0D +=0D +Module Name:=0D +=0D + Debug.c=0D +=0D +--*/=0D +=0D +#include "SCRTDriver.h"=0D +=0D +UINTN mHandOffPtr =3D 0;=0D +EFI_PHYSICAL_ADDRESS mIoPortSpaceAddress =3D 0;=0D +=0D +=0D +EFI_STATUS=0D +ConsumeHandOff (=0D + IN UINTN HandOffAddr,=0D + OUT CONF_INFO *ConfigData=0D + )=0D +{=0D + RUNTIME_HANDOFF *HandOffPtr;=0D + //=0D + // First fix the memory address of hand off data.=0D + //=0D + FixAddress(&HandOffAddr);=0D + mHandOffPtr =3D HandOffAddr;=0D + HandOffPtr =3D (RUNTIME_HANDOFF*)mHandOffPtr;=0D + *ConfigData =3D HandOffPtr->ConfigureInfo;=0D +=0D + if (!HandOffPtr->DebuggerInfo.MmioFlag){=0D + //=0D + // If debug port is I/O mapped, fix IoBase Address.=0D + //=0D + FixAddress(&HandOffPtr->DebuggerInfo.IoBase);=0D + mIoPortSpaceAddress =3D HandOffPtr->DebuggerInfo.IoBase;=0D + } else {=0D + //=0D + // If debug port is MMIO, fix MmioBase Address.=0D + //=0D + FixAddress(&HandOffPtr->DebuggerInfo.MmioBase);=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +=0D +EFI_STATUS=0D +Send2UART (=0D + CHAR8 *String=0D + )=0D +{=0D + //=0D + // TODO: On ARM platforms use platform specific functions to=0D + // write the data to UART.=0D + //=0D + return EFI_SUCCESS;=0D +}=0D +=0D +=0D +=0D +EFI_STATUS=0D +DebugWorker (=0D + IN CHAR8 *String=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + //=0D + // Send text message to registered UART.=0D + //=0D + Status =3D Send2UART(String);=0D + return Status;=0D +}=0D diff --git a/uefi-sct/SctPkg/SCRT/SCRTDriver/Riscv64/Dump.c b/uefi-sct/SctP= kg/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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2012 ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +=0D +/*++=0D +=0D +Module Name:=0D +=0D + Dump.c=0D +=0D +--*/=0D +=0D +#include "SCRTDriver.h"=0D +=0D +VOID=0D +DumpRuntimeTable()=0D +{=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DDump Runti= me Table=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("Header Signature =3D 0x%x\n", VRT->Hdr.Signature);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DGetTime Se= rvice=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("GetTime @ 0x%x\n", VRT->GetTime);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DSetTime Se= rvice=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("SetTime @ 0x%x\n", VRT->SetTime);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DGetWakeupT= ime Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("GetWakeupTime @ 0x%x\n", VRT->GetWakeupTime);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DSetWakeupT= ime Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("SetWakeupTime @ 0x%x\n", VRT->SetWakeupTime);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DGetVariabl= e Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("GetVariable @ 0x%x\n", VRT->GetVariable);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DGetNextVar= iableName Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("GetNextVariableName @ 0x%x\n", VRT->GetNextVariableName);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DSetVariabl= e Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("SetVariable @ 0x%x\n", VRT->SetVariable);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DGetNextHig= hMonotonicCount Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("GetNextHighMonotonicCount @ 0x%x\n", VRT->GetNextHighMonoton= icCount);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DResetSyste= m Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("ResetSystem @ 0x%x\n", VRT->ResetSystem);=0D +#if 0=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DUpdateCaps= ule Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("UpdateCapsule @ 0x%x\n", VRT->UpdateCapsule);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DQueryCapsu= leCapabilities Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("QueryCapsuleCapabilities @ 0x%x\n", VRT->QueryCapsuleCapabil= ities);=0D +=0D + SctAPrint ("\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DQueryVaria= bleInfo Service=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n");=0D + SctAPrint ("QueryVariableInfo @ 0x%x\n", VRT->QueryVariableInfo);=0D +#endif=0D +}=0D 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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2012 ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +=0D +/*++=0D +=0D +Module Name:=0D +=0D + Io.c=0D +=0D +--*/=0D +=0D +#include "Io.h"=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +CpuIoServiceWrite (=0D + IN EFI_PEI_CPU_IO_PPI_WIDTH Width,=0D + IN UINT64 UserAddress,=0D + IN UINTN Count,=0D + IN VOID *UserBuffer=0D + )=0D +/*++=0D +=0D +Routine Description:=0D +=0D + Perform the port I/O write service=0D +=0D +Arguments:=0D +=0D + Width - Width of the port I/O operation=0D + Address - Base address of the port I/O operation=0D + Count - Count of the number of accesses to perform=0D + Buffer - Pointer to the source buffer from which to write data=0D +=0D +Returns:=0D +=0D + EFI_SUCCESS - The data was written.=0D + EFI_INVALID_PARAMETER - Width is invalid.=0D + EFI_INVALID_PARAMETER - Buffer is NULL.=0D + EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.=0D + EFI_UNSUPPORTED - The address range specified by Address, Width,=0D + and Count is not valid.=0D +=0D +--*/=0D +{=0D + return EFI_UNSUPPORTED;=0D +}=0D +=0D +=0D +EFI_STATUS=0D +EfiIoWrite (=0D + IN EFI_PEI_CPU_IO_PPI_WIDTH Width,=0D + IN UINT64 Address,=0D + IN UINTN Count,=0D + IN OUT VOID *Buffer=0D + )=0D +/*++=0D +=0D +Routine Description:=0D + Perform an IO write into Buffer.=0D +=0D +Arguments:=0D + Width - Width of write transaction, and repeat operation to use=0D + Address - IO address to write=0D + Count - Number of times to write the IO address.=0D + Buffer - Buffer to write data from. size is Width * Count=0D +=0D +Returns:=0D + Status code=0D +=0D +--*/=0D +{=0D + return CpuIoServiceWrite(Width, Address, Count, Buffer);=0D +}=0D +=0D +=0D +EFI_STATUS=0D +EfiIoRead (=0D + IN EFI_PEI_CPU_IO_PPI_WIDTH Width,=0D + IN UINT64 Address,=0D + IN UINTN Count,=0D + IN OUT VOID *Buffer=0D + )=0D +/*++=0D +=0D +Routine Description:=0D + Perform an IO read into Buffer.=0D +=0D +Arguments:=0D + Width - Width of read transaction, and repeat operation to use=0D + Address - IO address to read=0D + Count - Number of times to read the IO address.=0D + Buffer - Buffer to read data into. size is Width * Count=0D +=0D +Returns:=0D + Status code=0D +=0D +--*/=0D +{=0D + return EFI_UNSUPPORTED;=0D +}=0D +=0D +=0D +VOID=0D +FixAddress (=0D + IN UINTN *PhyAddress=0D + )=0D +{=0D + //=0D + //Note: On ARM platforms don't have to do this as all the functions are = virtually mapped.=0D + //=0D +}=0D +=0D +// Quick port to ARM=0D +=0D +VOID=0D +Port80 (=0D + UINT8 Number=0D + )=0D +{=0D + //EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Port80 %02x", Number));=0D +}=0D 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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2012 ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +=0D +/*++=0D +=0D +Module Name:=0D +=0D + Debug.h=0D +=0D +--*/=0D +=0D +#ifndef _IA32_IO_ACCESS_H=0D +#define _IA32_IO_ACCESS_H=0D +=0D +#include "SCRTDriver.h"=0D +=0D +#define IA32_MAX_IO_ADDRESS 0xFFFF=0D +=0D +#define IA32API=0D +=0D +=0D +typedef union {=0D + UINT8 VOLATILE *buf;=0D + UINT8 VOLATILE *ui8;=0D + UINT16 VOLATILE *ui16;=0D + UINT32 VOLATILE *ui32;=0D + UINT64 VOLATILE *ui64;=0D + UINTN VOLATILE ui;=0D +} PTR;=0D +=0D +// This address is assuming a pure PC architecture. Not required?=0D +#define VIRT_TO_PHYS_OFFSET (0x80000000) //2G=0D +=0D +=0D +=0D +#endif=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackB= oxTest/Riscv64/DebugSupportBBTestCacheFunction.c b/uefi-sct/SctPkg/TestCase= /UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSupportBBTestCach= eFunction.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=0D +=0D + Copyright 2006 - 2016 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + DebugSupportBBTestCacheFunction.c=0D +=0D +Abstract:=0D +=0D + Interface Function Test Cases of Debug Support Protocol=0D +=0D +--*/=0D +=0D +=0D +#include "DebugSupportBBTestMain.h"=0D +=0D +/**=0D + * Entrypoint for EFI_DEBUG_SUPPORT_PROTOCOL.InvalidateInstructionCache()= Function Test.=0D + * @param This a pointer of EFI_BB_TEST_PROTOCOL.=0D + * @param ClientInterface a pointer to the interface to be tested.=0D + * @param TestLevel test "thoroughness" control.=0D + * @param SupportHandle a handle containing protocols required.=0D + * @return EFI_SUCCESS Finish the test successfully.=0D + */=0D +//=0D +// TDS 3.5=0D +//=0D +EFI_STATUS=0D +BBTestInvalidateInstructionCacheFunctionAutoTest (=0D + IN EFI_BB_TEST_PROTOCOL *This,=0D + IN VOID *ClientInterface,=0D + IN EFI_TEST_LEVEL TestLevel,=0D + IN EFI_HANDLE SupportHandle=0D + )=0D +{=0D + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;=0D + EFI_STATUS Status;=0D + EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;=0D + EFI_TEST_ASSERTION AssertionType;=0D + UINT64 Start;=0D + UINT64 Length;=0D + UINTN MaxProcessorIndex;=0D + UINTN ProcessorIndex;=0D +=0D + //=0D + // Get the Standard Library Interface=0D + //=0D + Status =3D gtBS->HandleProtocol (=0D + SupportHandle,=0D + &gEfiStandardTestLibraryGuid,=0D + (VOID **) &StandardLib=0D + );=0D +=0D + if (EFI_ERROR(Status)) {=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + EFI_TEST_ASSERTION_FAILED,=0D + gTestGenericFailureGuid,=0D + L"BS.HandleProtocol - Handle standard test library",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D + return Status;=0D + }=0D +=0D + DebugSupport =3D (EFI_DEBUG_SUPPORT_PROTOCOL *)ClientInterface;=0D +=0D + if (DebugSupport->Isa !=3D PlatformIsa) {=0D + return EFI_SUCCESS;=0D + }=0D +=0D + Status =3D DebugSupport->GetMaximumProcessorIndex (DebugSupport, &MaxPro= cessorIndex);=0D + if (EFI_ERROR(Status)) {=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + EFI_TEST_ASSERTION_FAILED,=0D + gTestGenericFailureGuid,=0D + L"EFI_DEBUG_SUPPORT_PROTOCOL.GetMaximumProcessorIndex",= =0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D + return Status;=0D + }=0D +=0D + for (ProcessorIndex =3D 0; ProcessorIndex <=3D MaxProcessorIndex; Proces= sorIndex++) {=0D +=0D + //=0D + // Assertion Point 3.5.2.1=0D + // Invoke InvalidateInstructionCache and verify interface correctness.= =0D + //=0D +=0D + // The Physical base of the memory range to be invalidated.=0D + Start =3D 0x0;=0D +=0D + // The minimum number of bytes in the processor's instruction cache to= be invalidated.=0D + Length =3D 0x0;=0D +=0D + Status =3D DebugSupport->InvalidateInstructionCache (DebugSupport, Pro= cessorIndex, (VOID*)&Start, Length);=0D +=0D + if (EFI_ERROR(Status)) {=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gDebugSupportBBTestFunctionAssertionGuid015,=0D + L"EFI_DEBUG_SUPPORT_PROTOCOL.InvalidateInstructionCache -= Invoke this function and verify interface correctness",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackB= oxTest/Riscv64/DebugSupportBBTestExceptionCallbackFunction.c b/uefi-sct/Sct= Pkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/Riscv64/DebugSuppo= rtBBTestExceptionCallbackFunction.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=0D +=0D + Copyright 2006 - 2016 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + DebugSupportBBExceptionCallbackFunction.c=0D +=0D +Abstract:=0D +=0D + Interface Function Test Cases of Debug Support Protocol=0D +=0D +--*/=0D +=0D +=0D +#include "DebugSupportBBTestMain.h"=0D +=0D +extern volatile UINTN InvokedExceptionCallback;=0D +extern volatile UINTN InvokedPeriodicCallback;=0D +=0D +extern EFI_INSTRUCTION_SET_ARCHITECTURE PlatformIsa;=0D +=0D +void=0D +SoftwareBreak (=0D + void=0D + )=0D +{=0D + // Not ported to ARM yet=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + * Entrypoint for EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback() = Function Test.=0D + * @param This a pointer of EFI_BB_TEST_PROTOCOL.=0D + * @param ClientInterface a pointer to the interface to be tested.=0D + * @param TestLevel test "thoroughness" control.=0D + * @param SupportHandle a handle containing protocols required.=0D + * @return EFI_SUCCESS Finish the test successfully.=0D + */=0D +//=0D +// TDS 3.4=0D +//=0D +EFI_STATUS=0D +BBTestRegisterExceptionCallbackFunctionManualTest (=0D + IN EFI_BB_TEST_PROTOCOL *This,=0D + IN VOID *ClientInterface,=0D + IN EFI_TEST_LEVEL TestLevel,=0D + IN EFI_HANDLE SupportHandle=0D + )=0D +{=0D + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;=0D + EFI_STATUS Status;=0D + EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;=0D + EFI_TEST_ASSERTION AssertionType;=0D +=0D + DebugSupport =3D (EFI_DEBUG_SUPPORT_PROTOCOL *)ClientInterface;=0D +=0D + if (DebugSupport->Isa !=3D PlatformIsa) {=0D + return EFI_SUCCESS;=0D + }=0D +=0D + //=0D + // Get the Standard Library Interface=0D + //=0D + Status =3D gtBS->HandleProtocol (=0D + SupportHandle,=0D + &gEfiStandardTestLibraryGuid,=0D + (VOID **) &StandardLib=0D + );=0D +=0D + if (EFI_ERROR(Status)) {=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + EFI_TEST_ASSERTION_FAILED,=0D + gTestGenericFailureGuid,=0D + L"BS.HandleProtocol - Handle standard test library",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D + return Status;=0D + }=0D +=0D + //=0D + // Assertion Point 3.4.2.1=0D + // Invoke RegisterExceptionCallback() to install an interrupt handler fu= nction.=0D + //=0D + InvokedExceptionCallback =3D FALSE;=0D + // FIXME: Is it normal that we use EXCEPT_IA32_BREAKPOINT here?=0D + // Shouldn't we define proper constants for ARM exceptions in DebugSuppo= rtProtocol.h file?=0D + Status =3D DebugSupport->RegisterExceptionCallback (DebugSupport, 0, Exc= eptionCallback, EXCEPT_IA32_BREAKPOINT);=0D +=0D + if ((Status =3D=3D EFI_SUCCESS) || (Status =3D=3D EFI_ALREADY_STARTED)) = {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gDebugSupportBBTestFunctionAssertionGuid009,=0D + L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - = Invoke this function and verify interface correctness",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // If the callback function is already registed, return=0D + //=0D + if (EFI_ERROR(Status)) {=0D + return EFI_SUCCESS;=0D + }=0D +=0D + //=0D + // Test the callback function registed.=0D + //=0D +=0D + //=0D + // Call SoftwareBreak to invoke the interrupt handler function.=0D + //=0D + SoftwareBreak ();=0D +=0D + if (InvokedExceptionCallback =3D=3D FALSE) {=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gDebugSupportBBTestFunctionAssertionGuid010,=0D + L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - = Verify the callback function was invoked.",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Assertion Point 3.4.2.2=0D + // Invoke RegisterPeriodicCallback() to install the Periodic interrupt h= andler function.=0D + // Verify the two callback functions can be both invoked.=0D + //=0D + InvokedExceptionCallback =3D FALSE;=0D + InvokedPeriodicCallback =3D FALSE;=0D +=0D + Status =3D DebugSupport->RegisterPeriodicCallback (DebugSupport, 0, Peri= odicCallback);=0D + if (EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D +=0D + //=0D + // Wait the PeriodicCallback to be invoked.=0D + //=0D + gtBS->Stall (500000);=0D +=0D + //=0D + // Call SoftwareBreak to invoke the interrupt handler function.=0D + //=0D + SoftwareBreak ();=0D +=0D + if ((InvokedExceptionCallback =3D=3D TRUE) && (InvokedPeriodicCallback = =3D=3D TRUE)) {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gDebugSupportBBTestFunctionAssertionGuid011,=0D + L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - = Verify the two callback functions can be both invoked.",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Uninstall the Periodic callback function.=0D + //=0D + Status =3D DebugSupport->RegisterPeriodicCallback (DebugSupport, 0, NULL= );=0D + if (EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D +=0D + //=0D + // Assertion Point 3.4.2.3=0D + // Invoke RegisterExceptionCallback() to install another interrupt handl= er function.=0D + //=0D + Status =3D DebugSupport->RegisterExceptionCallback (DebugSupport, 0, Exc= eptionCallback1, EXCEPT_IA32_BREAKPOINT);=0D +=0D + if (Status !=3D EFI_ALREADY_STARTED) {=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gDebugSupportBBTestFunctionAssertionGuid012,=0D + L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - = Register another callback function.",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Assertion Point 3.4.2.4=0D + // Invoke RegisterExceptionCallback() to unstall the interrupt handler f= unction.=0D + //=0D + Status =3D DebugSupport->RegisterExceptionCallback (DebugSupport, 0, NUL= L, EXCEPT_IA32_BREAKPOINT);=0D +=0D + if (EFI_ERROR(Status)) {=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gDebugSupportBBTestFunctionAssertionGuid013,=0D + L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - = Invoke this function to uninstall the interrupt handler function",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + InvokedExceptionCallback =3D FALSE;=0D +=0D + //=0D + // Call SoftwareBreak to invoke the interrupt handler function.=0D + //=0D + SoftwareBreak ();=0D +=0D + if (InvokedExceptionCallback !=3D FALSE) {=0D + AssertionType =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + AssertionType,=0D + gDebugSupportBBTestFunctionAssertionGuid014,=0D + L"EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback - = Verify the callback function wasn't invoked",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackB= oxTest/Riscv64/PlatformIsa.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/D= ebugSupport/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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + PlatformIsa.c=0D +=0D +Abstract:=0D +=0D + Platform related Isa definition.=0D +=0D +--*/=0D +=0D +#include "DebugSupportBBTestMain.h"=0D +=0D +EFI_INSTRUCTION_SET_ARCHITECTURE PlatformIsa =3D IsaAArch64;=0D +=0D diff --git a/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/R= iscv64/EntsLibPlat.h b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENT= S/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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2010 - 2012, ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + EntsLibPlat.h=0D +=0D +Abstract:=0D +=0D + AArch64 specific defines=0D +=0D +--*/=0D +=0D +#ifndef _EFI_LIB_PLAT_H_=0D +#define _EFI_LIB_PLAT_H_=0D +=0D +#define MIN_ALIGNMENT_SIZE 8=0D +=0D +VOID=0D +EntsInitializeLibPlatform (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +/*++=0D +=0D +Routine Description:=0D +=0D + Initialize platform.=0D +=0D +Arguments:=0D +=0D + ImageHandle - The image handle.=0D + SystemTable - The system table.=0D +=0D +Returns:=0D +=0D + None.=0D +=0D +--*/=0D +;=0D +=0D +#endif=0D diff --git a/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/R= iscv64/InitPlat.c b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/E= asLib/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=0D +=0D + Copyright 2006 - 2012 Unified EFI, Inc.
=0D + Copyright (c) 2010 - 2012, ARM Ltd. All rights reserved.
=0D +=0D + This program and the accompanying materials=0D + are licensed and made available under the terms and conditions of the BS= D License=0D + which accompanies this distribution. The full text of the license may b= e found at =0D + http://opensource.org/licenses/bsd-license.php=0D + =0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=0D + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED.=0D + =0D +**/=0D +/*++=0D +=0D +Module Name:=0D +=0D + InitPlat.c=0D +=0D +Abstract:=0D +=0D + Math routines for compatibility with native EFI library routines.=0D +=0D +--*/=0D +=0D +#include "Efi.h"=0D +#include "EntsLibPlat.h"=0D +=0D +VOID=0D +EntsInitializeLibPlatform (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +/*++=0D +=0D +Routine Description:=0D +=0D + Initialize platform.=0D +=0D +Arguments:=0D +=0D + ImageHandle - The image handle.=0D + SystemTable - The system table.=0D +=0D +Returns:=0D +=0D + None.=0D +=0D +--*/=0D +{=0D + //=0D + // No platform-specific initializations=0D + //=0D +}=0D --=20 2.30.0