From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: Sunil V L <sunilvl@ventanamicro.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Daniel Schaefer <git@danielschaefer.me>,
"Gao, Liming" <gaoliming@byosoft.com.cn>,
"Liu, Zhiguang" <zhiguang.liu@intel.com>,
"Abner Chang" <abner.chang@amd.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [edk2-staging/RiscV64QemuVirt PATCH V7 01/20] MdePkg/Register: Add register definition header files for RISC-V
Date: Thu, 9 Feb 2023 01:44:32 +0000 [thread overview]
Message-ID: <CO1PR11MB49295BD75B1C490E875568D9D2D99@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230128191807.2080547-2-sunilvl@ventanamicro.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> -----Original Message-----
> From: Sunil V L <sunilvl@ventanamicro.com>
> Sent: Saturday, January 28, 2023 11:18 AM
> To: devel@edk2.groups.io
> Cc: Daniel Schaefer <git@danielschaefer.me>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> Liu, Zhiguang <zhiguang.liu@intel.com>; Abner Chang <abner.chang@amd.com>
> Subject: [edk2-staging/RiscV64QemuVirt PATCH V7 01/20] MdePkg/Register: Add register definition header files for RISC-V
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076
>
> Add register definitions and access routines for RISC-V. These
> headers are leveraged from opensbi repo.
>
> Cc: Daniel Schaefer <git@danielschaefer.me>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
> Acked-by: Abner Chang <abner.chang@amd.com>
> ---
> MdePkg/Include/Register/RiscV64/RiscVEncoding.h | 119 ++++++++++++++++++++
> MdePkg/Include/Register/RiscV64/RiscVImpl.h | 25 ++++
> 2 files changed, 144 insertions(+)
>
> diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> new file mode 100644
> index 000000000000..5c2989b797bf
> --- /dev/null
> +++ b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> @@ -0,0 +1,119 @@
> +/** @file
> + RISC-V CSR encodings
> +
> + Copyright (c) 2019, Western Digital Corporation or its affiliates. All rights reserved.<BR>
> + Copyright (c) 2022, Ventana Micro Systems Inc. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef RISCV_ENCODING_H_
> +#define RISCV_ENCODING_H_
> +
> +#define MSTATUS_SIE 0x00000002UL
> +#define MSTATUS_MIE 0x00000008UL
> +#define MSTATUS_SPIE_SHIFT 5
> +#define MSTATUS_SPIE (1UL << MSTATUS_SPIE_SHIFT)
> +#define MSTATUS_UBE 0x00000040UL
> +#define MSTATUS_MPIE 0x00000080UL
> +#define MSTATUS_SPP_SHIFT 8
> +#define MSTATUS_SPP (1UL << MSTATUS_SPP_SHIFT)
> +#define MSTATUS_MPP_SHIFT 11
> +#define MSTATUS_MPP (3UL << MSTATUS_MPP_SHIFT)
> +
> +#define SSTATUS_SIE MSTATUS_SIE
> +#define SSTATUS_SPIE_SHIFT MSTATUS_SPIE_SHIFT
> +#define SSTATUS_SPIE MSTATUS_SPIE
> +#define SSTATUS_SPP_SHIFT MSTATUS_SPP_SHIFT
> +#define SSTATUS_SPP MSTATUS_SPP
> +
> +#define IRQ_S_SOFT 1
> +#define IRQ_VS_SOFT 2
> +#define IRQ_M_SOFT 3
> +#define IRQ_S_TIMER 5
> +#define IRQ_VS_TIMER 6
> +#define IRQ_M_TIMER 7
> +#define IRQ_S_EXT 9
> +#define IRQ_VS_EXT 10
> +#define IRQ_M_EXT 11
> +#define IRQ_S_GEXT 12
> +#define IRQ_PMU_OVF 13
> +
> +#define MIP_SSIP (1UL << IRQ_S_SOFT)
> +#define MIP_VSSIP (1UL << IRQ_VS_SOFT)
> +#define MIP_MSIP (1UL << IRQ_M_SOFT)
> +#define MIP_STIP (1UL << IRQ_S_TIMER)
> +#define MIP_VSTIP (1UL << IRQ_VS_TIMER)
> +#define MIP_MTIP (1UL << IRQ_M_TIMER)
> +#define MIP_SEIP (1UL << IRQ_S_EXT)
> +#define MIP_VSEIP (1UL << IRQ_VS_EXT)
> +#define MIP_MEIP (1UL << IRQ_M_EXT)
> +#define MIP_SGEIP (1UL << IRQ_S_GEXT)
> +#define MIP_LCOFIP (1UL << IRQ_PMU_OVF)
> +
> +#define SIP_SSIP MIP_SSIP
> +#define SIP_STIP MIP_STIP
> +
> +#define PRV_U 0UL
> +#define PRV_S 1UL
> +#define PRV_M 3UL
> +
> +#define SATP64_MODE 0xF000000000000000ULL
> +#define SATP64_ASID 0x0FFFF00000000000ULL
> +#define SATP64_PPN 0x00000FFFFFFFFFFFULL
> +
> +#define SATP_MODE_OFF 0UL
> +#define SATP_MODE_SV32 1UL
> +#define SATP_MODE_SV39 8UL
> +#define SATP_MODE_SV48 9UL
> +#define SATP_MODE_SV57 10UL
> +#define SATP_MODE_SV64 11UL
> +
> +#define SATP_MODE SATP64_MODE
> +
> +/* User Counters/Timers */
> +#define CSR_CYCLE 0xc00
> +#define CSR_TIME 0xc01
> +
> +/* Supervisor Trap Setup */
> +#define CSR_SSTATUS 0x100
> +#define CSR_SEDELEG 0x102
> +#define CSR_SIDELEG 0x103
> +#define CSR_SIE 0x104
> +#define CSR_STVEC 0x105
> +
> +/* Supervisor Configuration */
> +#define CSR_SENVCFG 0x10a
> +
> +/* Supervisor Trap Handling */
> +#define CSR_SSCRATCH 0x140
> +#define CSR_SEPC 0x141
> +#define CSR_SCAUSE 0x142
> +#define CSR_STVAL 0x143
> +#define CSR_SIP 0x144
> +
> +/* Supervisor Protection and Translation */
> +#define CSR_SATP 0x180
> +
> +/* Trap/Exception Causes */
> +#define CAUSE_MISALIGNED_FETCH 0x0
> +#define CAUSE_FETCH_ACCESS 0x1
> +#define CAUSE_ILLEGAL_INSTRUCTION 0x2
> +#define CAUSE_BREAKPOINT 0x3
> +#define CAUSE_MISALIGNED_LOAD 0x4
> +#define CAUSE_LOAD_ACCESS 0x5
> +#define CAUSE_MISALIGNED_STORE 0x6
> +#define CAUSE_STORE_ACCESS 0x7
> +#define CAUSE_USER_ECALL 0x8
> +#define CAUSE_SUPERVISOR_ECALL 0x9
> +#define CAUSE_VIRTUAL_SUPERVISOR_ECALL 0xa
> +#define CAUSE_MACHINE_ECALL 0xb
> +#define CAUSE_FETCH_PAGE_FAULT 0xc
> +#define CAUSE_LOAD_PAGE_FAULT 0xd
> +#define CAUSE_STORE_PAGE_FAULT 0xf
> +#define CAUSE_FETCH_GUEST_PAGE_FAULT 0x14
> +#define CAUSE_LOAD_GUEST_PAGE_FAULT 0x15
> +#define CAUSE_VIRTUAL_INST_FAULT 0x16
> +#define CAUSE_STORE_GUEST_PAGE_FAULT 0x17
> +
> +#endif
> diff --git a/MdePkg/Include/Register/RiscV64/RiscVImpl.h b/MdePkg/Include/Register/RiscV64/RiscVImpl.h
> new file mode 100644
> index 000000000000..ee5c2ba60377
> --- /dev/null
> +++ b/MdePkg/Include/Register/RiscV64/RiscVImpl.h
> @@ -0,0 +1,25 @@
> +/** @file
> + RISC-V package definitions.
> +
> + Copyright (c) 2016 - 2022, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef RISCV_IMPL_H_
> +#define RISCV_IMPL_H_
> +
> +#include <Register/RiscV64/RiscVEncoding.h>
> +
> +#define _ASM_FUNC(Name, Section) \
> + .global Name ; \
> + .section #Section, "ax" ; \
> + .type Name, %function ; \
> + .p2align 2 ; \
> + Name:
> +
> +#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
> +#define RISCV_TIMER_COMPARE_BITS 32
> +
> +#endif
> --
> 2.38.0
next prev parent reply other threads:[~2023-02-09 1:44 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-28 19:17 [edk2-staging/RiscV64QemuVirt PATCH V7 00/20] Add support for RISC-V virt machine Sunil V L
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 01/20] MdePkg/Register: Add register definition header files for RISC-V Sunil V L
2023-02-06 15:44 ` [edk2-devel] " Andrei Warkentin
2023-02-09 1:44 ` Michael D Kinney [this message]
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 02/20] MdePkg/BaseLib: RISC-V: Add few more helper functions Sunil V L
2023-02-06 15:46 ` [edk2-devel] " Andrei Warkentin
2023-02-09 1:43 ` Michael D Kinney
2023-02-09 7:21 ` Sunil V L
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 03/20] MdePkg: Add BaseRiscVSbiLib Library for RISC-V Sunil V L
2023-02-06 15:47 ` [edk2-devel] " Andrei Warkentin
2023-02-09 1:45 ` Michael D Kinney
2023-02-09 7:18 ` [edk2-devel] " Sunil V L
2023-02-09 15:47 ` Michael D Kinney
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 04/20] UefiCpuPkg: Add RISCV_EFI_BOOT_PROTOCOL related definitions Sunil V L
2023-02-06 15:47 ` [edk2-devel] " Andrei Warkentin
2023-02-09 5:16 ` Ni, Ray
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 05/20] UefiCpuPkg: Add CpuTimerDxe module Sunil V L
2023-02-08 18:02 ` [edk2-devel] " Michael D Kinney
2023-02-08 18:12 ` Sunil V L
2023-02-09 5:21 ` Ni, Ray
2023-02-09 10:17 ` Michael Brown
2023-02-09 10:28 ` Sunil V L
2023-02-09 10:30 ` Michael Brown
2023-02-09 10:37 ` Sunil V L
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 06/20] UefiCpuPkg/CpuExceptionHandlerLib: Add RISC-V instance Sunil V L
2023-02-09 5:24 ` [edk2-devel] " Ni, Ray
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 07/20] UefiCpuPkg/CpuDxe: " Sunil V L
2023-02-06 15:58 ` [edk2-devel] " Andrei Warkentin
2023-02-08 5:05 ` Sunil V L
2023-02-09 5:43 ` Ni, Ray
2023-02-09 5:49 ` Sunil V L
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 08/20] UefiCpuPkg/CpuTimerLib: " Sunil V L
2023-01-30 11:07 ` [edk2-devel] " dhaval
2023-01-30 13:08 ` Sunil V L
2023-02-06 16:00 ` Andrei Warkentin
2023-02-09 5:37 ` Ni, Ray
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 09/20] UefiCpuPkg/UefiCpuPkg.ci.yaml: Ignore RISC-V file Sunil V L
2023-02-06 16:00 ` [edk2-devel] " Andrei Warkentin
2023-02-09 1:50 ` Michael D Kinney
2023-02-09 5:38 ` Ni, Ray
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 10/20] EmbeddedPkg: Enable PcdPrePiCpuIoSize for RISC-V Sunil V L
2023-02-06 16:00 ` [edk2-devel] " Andrei Warkentin
2023-02-09 1:51 ` Michael D Kinney
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 11/20] ArmVirtPkg/PlatformHasAcpiDtDxe: Move to OvmfPkg Sunil V L
2023-02-06 16:01 ` [edk2-devel] " Andrei Warkentin
2023-01-28 19:17 ` [edk2-staging/RiscV64QemuVirt PATCH V7 12/20] ArmVirtPkg: Fix up the location of PlatformHasAcpiDtDxe Sunil V L
2023-02-06 16:01 ` [edk2-devel] " Andrei Warkentin
2023-01-28 19:18 ` [edk2-staging/RiscV64QemuVirt PATCH V7 13/20] OvmfPkg/RiscVVirt: Add PlatformBootManagerLib library Sunil V L
2023-02-06 16:01 ` [edk2-devel] " Andrei Warkentin
2023-01-28 19:18 ` [edk2-staging/RiscV64QemuVirt PATCH V7 14/20] OvmfPkg/RiscVVirt: Add PrePiHobListPointerLib library Sunil V L
2023-02-06 16:01 ` [edk2-devel] " Andrei Warkentin
2023-01-28 19:18 ` [edk2-staging/RiscV64QemuVirt PATCH V7 15/20] OvmfPkg/RiscVVirt: Add ResetSystemLib library Sunil V L
2023-02-06 16:01 ` [edk2-devel] " Andrei Warkentin
2023-01-28 19:18 ` [edk2-staging/RiscV64QemuVirt PATCH V7 16/20] OvmfPkg/RiscVVirt: Add VirtNorFlashPlatformLib library Sunil V L
2023-02-06 16:02 ` [edk2-devel] " Andrei Warkentin
2023-01-28 19:18 ` [edk2-staging/RiscV64QemuVirt PATCH V7 17/20] OvmfPkg/RiscVVirt: Add PciCpuIo2Dxe module Sunil V L
2023-01-30 10:12 ` [edk2-devel] " dhaval
2023-01-30 13:05 ` Sunil V L
2023-01-30 14:33 ` dhaval
2023-02-06 16:02 ` Andrei Warkentin
2023-01-28 19:18 ` [edk2-staging/RiscV64QemuVirt PATCH V7 18/20] OvmfPkg/RiscVVirt: Add SEC module Sunil V L
2023-01-30 5:17 ` [edk2-devel] " dhaval
2023-01-30 6:00 ` Sunil V L
2023-02-06 16:03 ` Andrei Warkentin
2023-01-28 19:18 ` [edk2-staging/RiscV64QemuVirt PATCH V7 19/20] OvmfPkg/RiscVVirt: Add build files for Qemu Virt platform Sunil V L
2023-02-06 16:03 ` [edk2-devel] " Andrei Warkentin
2023-01-28 19:18 ` [edk2-staging/RiscV64QemuVirt PATCH V7 20/20] Maintainers.txt: Add entry for OvmfPkg/RiscVVirt Sunil V L
2023-02-06 16:04 ` [edk2-devel] " Andrei Warkentin
2023-02-09 1:51 ` Michael D Kinney
2023-02-09 3:32 ` [edk2-devel] " Yao, Jiewen
2023-02-09 4:34 ` Sunil V L
2023-02-09 5:07 ` Yao, Jiewen
2023-02-09 5:15 ` Chang, Abner
2023-02-09 14:05 ` Yao, Jiewen
2023-02-09 15:19 ` Sunil V L
2023-02-09 15:21 ` Yao, Jiewen
[not found] ` <173E8F29CD0D02D8.27165@groups.io>
2023-01-30 13:43 ` [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V7 11/20] ArmVirtPkg/PlatformHasAcpiDtDxe: Move to OvmfPkg Sunil V L
2023-02-03 12:29 ` Ard Biesheuvel
[not found] ` <173E8F254E9BED62.27165@groups.io>
2023-02-02 14:35 ` [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V7 03/20] MdePkg: Add BaseRiscVSbiLib Library for RISC-V Sunil V L
[not found] ` <173E8F293E682CB4.27165@groups.io>
2023-02-03 9:46 ` [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V7 10/20] EmbeddedPkg: Enable PcdPrePiCpuIoSize " Sunil V L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CO1PR11MB49295BD75B1C490E875568D9D2D99@CO1PR11MB4929.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox