From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.5825.1576728571313060132 for ; Wed, 18 Dec 2019 20:09:31 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=02562c19b1=abner.chang@hpe.com) Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBJ460V5020614; Thu, 19 Dec 2019 04:09:29 GMT Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 2wyp46cv1d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Dec 2019 04:09:29 +0000 Received: from G4W10204.americas.hpqcorp.net (g4w10204.houston.hpecorp.net [16.207.82.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id 63133133; Thu, 19 Dec 2019 04:09:28 +0000 (UTC) Received: from G2W6311.americas.hpqcorp.net (16.197.64.53) by G4W10204.americas.hpqcorp.net (16.207.82.16) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 19 Dec 2019 04:09:28 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (15.241.52.12) by G2W6311.americas.hpqcorp.net (16.197.64.53) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Thu, 19 Dec 2019 04:09:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h95Y6avNeBs5x0nDyNre8rpembLI7OT+5zIpKyNf3wUCamgkJw/KoLWqtlLJ/E0z3RPA0qyGpYRyRlNkSN96AIrKN/o8/L+zMQ7/tBhbIBpasdRNExsbpgT3MsVBDg4PHHIe4e25NWZ46GkOI650iCbak+jbqRKhZHVjoe1SAK9o/8M7eT5xXGRjfiHwNDXAV/iSESwFu/JiJ0WPfAvNmhha31qpDOzCEHNd37s6oUlFyYq8ybWU/OBoR4jYuez+RnTfmDXxczktUSKwYjBhlJRg83QAcRhnHSzAXLO428tqNvxKNa9weL9idhUQ7BA0b+MYDIp0p9HFu+ux2lFj1Q== 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=GwSLu1ivoVCGSVtOHifT3YjeMxQNvbXVDhBRPhsArOY=; b=oZpl7jUdYfxBu+wTTeavL8vSW5t8blxWwwjrg3SG3dT9LH/o6KgioRohT8Qke7rPdFGI3e8nNFNrEmHpKamHLq0k87QkGR4zoVsEEPkuwnmdd8Ag0dZRLEBaOw6soyXJ9R/06JXaRv+URHc1yWm/bPkGujnzCSHHi5leTRyEXDQXzG7oj03iG+0p5AjrtFI0Iy28MREer1lVqKtH4uQLf7A2zkTT0/fVTLGqmOcSw0zT1ePpfhR2h8W/cEuqS/eFM2I36TonJH7fK2iMyIdkQZqV8Egpw8uXVU/GV3guQ0gZqNgct7WfHwUeIFTdN5vxGZrmXTvHDOn7aFJSgoJcmw== 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 Received: from AT5PR8401MB1154.NAMPRD84.PROD.OUTLOOK.COM (10.169.9.22) by AT5PR8401MB1219.NAMPRD84.PROD.OUTLOOK.COM (10.169.9.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14; Thu, 19 Dec 2019 04:09:22 +0000 Received: from AT5PR8401MB1154.NAMPRD84.PROD.OUTLOOK.COM ([fe80::b85b:f4a5:4bd8:586f]) by AT5PR8401MB1154.NAMPRD84.PROD.OUTLOOK.COM ([fe80::b85b:f4a5:4bd8:586f%12]) with mapi id 15.20.2538.019; Thu, 19 Dec 2019 04:09:22 +0000 From: "Abner Chang" To: "devel@edk2.groups.io" , "leif.lindholm@linaro.org" CC: "Chen, Gilbert" , Palmer Dabbelt , "Kinney, Michael D" Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v3 03/39] RiscVPkg/opensbi: EDK2 RISC-V OpenSBI support Thread-Topic: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v3 03/39] RiscVPkg/opensbi: EDK2 RISC-V OpenSBI support Thread-Index: AQHVjTfJa4rNPSnzMUmbDlf31G3UAqeV9dsAgCswxyA= Date: Thu, 19 Dec 2019 04:09:22 +0000 Message-ID: References: <1572227957-13169-1-git-send-email-abner.chang@hpe.com> <1572227957-13169-4-git-send-email-abner.chang@hpe.com> <20191121162428.GJ7359@bivouac.eciton.net> In-Reply-To: <20191121162428.GJ7359@bivouac.eciton.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [16.242.247.131] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: b9008a42-71e5-485f-aec6-08d784393a77 x-ms-traffictypediagnostic: AT5PR8401MB1219: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:337; x-forefront-prvs: 0256C18696 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(396003)(39860400002)(136003)(366004)(199004)(189003)(13464003)(26005)(316002)(110136005)(8936002)(54906003)(6506007)(81156014)(81166006)(2906002)(53546011)(186003)(66556008)(52536014)(7696005)(71200400001)(4326008)(19627235002)(66446008)(8676002)(966005)(64756008)(66476007)(478600001)(5660300002)(33656002)(55016002)(9686003)(66946007)(86362001)(76116006);DIR:OUT;SFP:1102;SCL:1;SRVR:AT5PR8401MB1219;H:AT5PR8401MB1154.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: LWs5XF7/MKrabYGiOfW79oZKo6qoJZcWHomCtsLt52tFacaeDi2jSxBA4Q0QD+440rVuFpC/EKbFDPeWAo4hpG0GFXwMZkLZKbrwtk2Xudu3ocQBjx5TfwdDrXOW9ZPKRpTMg0WIRWy4s38X4mQ0QOLdMopx4GhdONwxivr6JCJWz3aPE7EcQ2vTtx5wPnk9Z6/ggUlEuO7VScR8+wupvZxrQFz6kK5AVnAVafNoTYEWJxNNQAMf/Bvf2ci4EHL23mCNI4sy98PaP8hlCf+uP1t4wqBWNnv+5CIbfhZ5/0YygdUXV9sdMzoh3J58kGtz8fcp6r8DdOJFYcpyj4QEMaUZCQH5xMaREKesvRMRdfhQS3bNSO84dh7wTm1SdmSMcWmJw2FRrs7ExWgwThSnhDW10vGvlRbu6Wqq9E5rnesr9wjG1/sx3jN7tTAB681yJVlUeDv0UeHw5m8mLyUmGt2rosYhGRmzRSS6/B7LY4qxyL2kcM3AfBA3w92Wp80d+ntG9uVbese/UZSr2+u3rmgEtgei11hIEP4V44/cvQ4= X-MS-Exchange-CrossTenant-Network-Message-Id: b9008a42-71e5-485f-aec6-08d784393a77 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2019 04:09:22.3319 (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: 9p+86hc1AHbdKrgiIfNykyXg/5ZFyP9P1RQmLwcjkAKrrX2cgZeuPbZFa0VT/nZCyZ0pmvobztwHfdZv7YitAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AT5PR8401MB1219 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.95,18.0.572 definitions=2019-12-18_08:2019-12-17,2019-12-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 clxscore=1011 bulkscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912190031 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Leif Lindholm > Sent: Friday, November 22, 2019 12:24 AM > To: Chang, Abner (HPS SW/FW Technologist) > Cc: devel@edk2.groups.io; Chen, Gilbert ; Palmer > Dabbelt ; Kinney, Michael D > > Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v3 03/39] > RiscVPkg/opensbi: EDK2 RISC-V OpenSBI support >=20 > On Mon, Oct 28, 2019 at 09:58:41 +0800, Abner Chang wrote: > > Add EDK2 RISC-V OpenSBI header files. > > > > Signed-off-by: Abner Chang > > > > Cc: Leif Lindholm > > Cc: Gilbert Chen > > --- > > RiscVPkg/Include/sbi/SbiFirmwareContext.h | 33 > ++++++++++++++++++++ > > RiscVPkg/Include/sbi/sbi.h | 52 > +++++++++++++++++++++++++++++++ > > RiscVPkg/Include/sbi/sbi_bits.h | 17 ++++++++++ > > RiscVPkg/Include/sbi/sbi_types.h | 45 > ++++++++++++++++++++++++++ > > 4 files changed, 147 insertions(+) > > create mode 100644 RiscVPkg/Include/sbi/SbiFirmwareContext.h > > create mode 100644 RiscVPkg/Include/sbi/sbi.h create mode 100644 > > RiscVPkg/Include/sbi/sbi_bits.h create mode 100644 > > RiscVPkg/Include/sbi/sbi_types.h > > > > diff --git a/RiscVPkg/Include/sbi/SbiFirmwareContext.h > > b/RiscVPkg/Include/sbi/SbiFirmwareContext.h > > new file mode 100644 > > index 0000000..c3d3489 > > --- /dev/null > > +++ b/RiscVPkg/Include/sbi/SbiFirmwareContext.h > > @@ -0,0 +1,33 @@ > > +/** @file > > + RISC-V OpesbSBI Platform Firmware context definition > > + > > + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All > > + rights reserved.
> > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > +#ifndef SBI_FIRMWARE_CONTEXT_H_ > > +#define SBI_FIRMWARE_CONTEXT_H_ > > + > > +#include > > + > > +#define RISC_V_MAX_HART_SUPPORTED 16 > > + > > +// > > +// keep the structure member in 64-bit alignment. > > +// > > +typedef struct { > > + UINT64 IsaExtensionSupported; // The ISA extension this= core > supported. > > + RISCV_UINT128 MachineVendorId; // Machine vendor ID > > + RISCV_UINT128 MachineArchId; // Machine Architecture I= D > > + RISCV_UINT128 MachineImplId; // Machine Implementation= ID > > +} EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC; > > + > > +#define FIRMWARE_CONTEXT_HART_SPECIFIC_SIZE (64 * 7) > > + > > +typedef struct { > > + VOID *PeiServiceTable; // PEI Service table > > + EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC > > +*HartSpecific[RISC_V_MAX_HART_SUPPORTED]; > > +} EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT; > > +#endif > > + > > diff --git a/RiscVPkg/Include/sbi/sbi.h b/RiscVPkg/Include/sbi/sbi.h > > new file mode 100644 index 0000000..04e7f18 > > --- /dev/null > > +++ b/RiscVPkg/Include/sbi/sbi.h > > @@ -0,0 +1,52 @@ > > +/** @file > > + SBI inline function calls. > > + > > + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All > > + rights reserved.
> > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef EDK2_SBI_H_ > > +#define EDK2_SBI_H_ > > + > > +#include // Reference to header file wrapper > > +#include // Reference to header file in > > +opensbi >=20 > This whole sbi situation is too much of a hornets' nest, and really does= need > to get sorted before we even push this to -staging. > (But I do think is is one of the last things we need to address.) >=20 > And I think the starting point to untangle it is to rename the wrapper i= nclude > files in RiscVPkg/Include/sbi (and indeed the directory > itself) to conform with the TianoCore standard. >=20 > That means: >=20 > RiscVPkg/Include/IndustryStandard/Sbi/Sbi.h > RiscVPkg/Include/IndustryStandard/Sbi/SbiBits.h > RiscVPkg/Include/IndustryStandard/Sbi/SbiTypes.h >=20 > Unless all of the wrappers can be combined into a single > RiscVPkg/Include/IndustryStandard/Sbi.h >=20 > ...and then tested on a case-sensitive filesystem. >=20 > For the record, doing that immediately results in the non-wrapper versio= ns > being pulled in and then the build failing. Leif, We can't change the naming of those header files under RiscVPkg/Include/sb= i. We build opensbi source code in edk2 and those source files refer to tho= se header file. And we are not going to change opensbi code as we discussed= before. The only file we can change is sbi.h -> Sbi.h because this header file is = created for edk2 RISC-V related drivers. I think we can make it this way, Rename sbi.h to RiscVOpensbi.h and move it to under RiscVPkg/Include/Indus= tryStandard, no need "/Sbi" subdirectory. Keep the naming of sbi_bits.h and sbi_types.h and still leave those under= RiscVPkg/Include/sbi. No naming changes in order to build opensbi source f= ile. Can't even change "/sbi" subdirectory to "/Sbi". sbi_bits.h and sbi_ty= pes.h are the binding files for edk2 framework BTW. >=20 > / > Leif >=20 > > + > > +#define SBI_SET_TIMER 0 > > +#define SBI_CONSOLE_PUTCHAR 1 > > +#define SBI_CONSOLE_GETCHAR 2 > > +#define SBI_CLEAR_IPI 3 > > +#define SBI_SEND_IPI 4 > > +#define SBI_REMOTE_FENCE_I 5 > > +#define SBI_REMOTE_SFENCE_VMA 6 > > +#define SBI_REMOTE_SFENCE_VMA_ASID 7 > > +#define SBI_SHUTDOWN 8 > > + > > +#define SBI_CALL(which, arg0, arg1, arg2) ({ \ > > + register uintptr_t a0 asm ("a0") =3D (uintptr_t)(arg0); \ > > + register uintptr_t a1 asm ("a1") =3D (uintptr_t)(arg1); \ > > + register uintptr_t a2 asm ("a2") =3D (uintptr_t)(arg2); \ > > + register uintptr_t a7 asm ("a7") =3D (uintptr_t)(which); \ > > + asm volatile ("ecall" \ > > + : "+r" (a0) \ > > + : "r" (a1), "r" (a2), "r" (a7) \ > > + : "memory"); \ > > + a0; \ > > +}) > > + > > +#define SBI_CALL_0(which) SBI_CALL(which, 0, 0, 0) #define > > +SBI_CALL_1(which, arg0) SBI_CALL(which, arg0, 0, 0) #define > > +SBI_CALL_2(which, arg0, arg1) SBI_CALL(which, arg0, arg1, 0) > > + > > +#define sbi_console_putchar(ch) SBI_CALL_1(SBI_CONSOLE_PUTCHAR, > ch) > > +#define sbi_console_getchar() SBI_CALL_0(SBI_CONSOLE_GETCHAR) > > +#define sbi_set_timer(stime_value) SBI_CALL_1(SBI_SET_TIMER, > stime_value) > > +#define sbi_shutdown() SBI_CALL_0(SBI_SHUTDOWN) > > +#define sbi_clear_ipi() SBI_CALL_0(SBI_CLEAR_IPI) > > +#define sbi_send_ipi(hart_mask) SBI_CALL_1(SBI_SEND_IPI, > hart_mask) > > +#define sbi_remote_fence_i(hart_mask) > SBI_CALL_1(SBI_REMOTE_FENCE_I, > > +hart_mask) #define sbi_remote_sfence_vma(hart_mask, start, size) > > +SBI_CALL_1(SBI_REMOTE_SFENCE_VMA, hart_mask) #define > > +sbi_remote_sfence_vma_asid(hart_mask, start, size, asid) > > +SBI_CALL_1(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask) > > + > > +#endif > > diff --git a/RiscVPkg/Include/sbi/sbi_bits.h > > b/RiscVPkg/Include/sbi/sbi_bits.h new file mode 100644 index > > 0000000..c935547 > > --- /dev/null > > +++ b/RiscVPkg/Include/sbi/sbi_bits.h > > @@ -0,0 +1,17 @@ > > +/** @file > > + RISC-V OpesbSBI header file reference. > > + > > + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All > > + rights reserved.
> > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > +#ifndef EDK2_SBI_BITS_H_ > > +#define EDK2_SBI_BITS_H_ > > + > > +#undef MAX > > +#undef MIN > > + > > +#include "include/sbi/sbi_bits.h" // Reference to header file in > > +opensbi > > + > > +#endif > > diff --git a/RiscVPkg/Include/sbi/sbi_types.h > > b/RiscVPkg/Include/sbi/sbi_types.h > > new file mode 100644 > > index 0000000..95ee213 > > --- /dev/null > > +++ b/RiscVPkg/Include/sbi/sbi_types.h > > @@ -0,0 +1,45 @@ > > +/** @file > > + RISC-V OpesbSBI header file reference. > > + > > + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All > > + rights reserved.
> > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > +#ifndef EDK2_SBI_TYPES_H_ > > +#define EDK2_SBI_TYPES_H_ > > + > > +typedef INT8 s8; > > +typedef UINT8 u8; > > +typedef UINT8 uint8_t; > > + > > +typedef INT16 s16; > > +typedef UINT16 u16; > > +typedef INT16 int16_t; > > +typedef UINT16 uint16_t; > > + > > +typedef INT32 s32; > > +typedef UINT32 u32; > > +typedef INT32 int32_t; > > +typedef UINT32 uint32_t; > > + > > +typedef INT64 s64; > > +typedef UINT64 u64; > > +typedef INT64 int64_t; > > +typedef UINT64 uint64_t; > > + > > +#define PRILX "016lx" > > + > > +typedef INT32 bool; > > +typedef unsigned long ulong; > > +typedef UINT64 uintptr_t; > > +typedef UINT64 size_t; > > +typedef INT64 ssize_t; > > +typedef UINT64 virtual_addr_t; > > +typedef UINT64 virtual_size_t; > > +typedef UINT64 physical_addr_t; > > +typedef UINT64 physical_size_t; > > + > > +#define __packed __attribute__((packed)) > > +#define __noreturn __attribute__((noreturn)) > > +#endif > > -- > > 2.7.4 > > >=20 >=20