summaryrefslogtreecommitdiff
path: root/lib/sbi
AgeCommit message (Collapse)AuthorFilesLines
2020-10-26lib: sbi: Detect PMP granularity and number of address bitsAtish Patra1-4/+58
As per RISC-V privilege specification, a platform may choose to implement a coarser granularity scheme for PMP addresses. In that case, we shouldn't allow any pmp region size smaller than the platform supports. A platform may not also implement all the bits for a PMP address specified in the priv specification. The pmp range granularity and address bits should be detected dynamically before detecing PMP regions. Any pmp modification request beyond these detected value must not succeed. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-10-21lib: sbi: Display domain details in boot printsAnup Patel3-46/+119
We extend boot prints to display details of each domain. In the process, we remove sbi_hart_pmp_dump() because it shows redundant information which domain details already show. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Configure PMP based on domain memory regionsAnup Patel1-15/+22
The PMP configuration on each HART should be only based on the memory regions of the assigned domain because each domain includes a memory region to protect the underlying firmware. This patch updates the sbi_hart_pmp_configure() function accordingly. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Remove redundant sbi_hart_pmp_xyz() functionsAnup Patel1-42/+0
The sbi_hart_pmp_get() and sbi_hart_pmp_check_addr() functions are not used anymore hence this patch removes these functions. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Extend sbi_system_reset() for domainsAnup Patel1-3/+4
The sbi_system_reset() should issue platform system reset only if domain of current HART is allowed to do system reset. This patch extends sbi_system_reset() as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Optimize sbi_hsm_hart_started_mask() implementationAnup Patel1-12/+22
Instead of calling sbi_hsm_hart_get_state() in a loop, we can simply call a new inline __sbi_hsm_hart_get_state() which only takes "hartid" and enforce domain checks using sbi_domain_assigned_hartmask(). This patch optimizes sbi_hsm_hart_started_mask() as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Extend sbi_hsm_hart_start() for domainsAnup Patel3-13/+16
The sbi_hsm_hart_start() should consider the domain under which we are trying to start the HART. This will help ensure that HART A can start HART B only if both HARTs A and B belong to the same domain. We also have a special case when we bring-up boot HART of non-root domains in sbi_domain_finalize() where we should skip domain checks in sbi_hsm_hart_start(). To achieve this, sbi_hsm_hart_start() should do domain checks only when domain parameter is non-NULL. This patch extends sbi_hsm_hart_start() as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Extend sbi_hsm_hart_started_mask() for domainsAnup Patel5-12/+23
The sbi_hsm_hart_started_mask() API should take one more parameter to allow caller specify domain under which started_mask is being generated. Further, the sbi_hsm_hart_started_mask() depends on sbi_hsm_hart_get_state() which also should return HART state under specified domain. This patch updates both sbi_hsm_hart_started_mask() and sbi_hsm_hart_get_state() as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-10-20lib: sbi: Add initial domain supportAnup Patel3-0/+401
An OpenSBI domain is a logical entity representing a set of HARTs and a set of memory regions for these HARTs. The OpenSBI domains support will allow OpenSBI platforms and previous booting stage (i.e. U-Boot SPL, Coreboot, etc) to partition a system into multiple domains where each domain will run it's own software. For inter-domain isolation, OpenSBI will eventually use various HW features such as PMP, ePMP, IOPMP, SiFive shield, etc but initial implementation only use HW PMP support. This patch provides initial implementation of OpenSBI domains where we have a root/default domain and OpenSBI platforms can provide non-root/custom domains using domain_get() callback. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Remove redundant hartid parameter from sbi_hart_init()Anup Patel2-9/+9
The hartid parameter of sbi_hart_init() is not used anywhere in sbi_hart_init() implementation so let's remove it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-10-20lib: sbi: Configure PMP late in coldboot and warmboot pathAnup Patel2-2/+10
We factor-out PMP configuration from sbi_hart_init() as a separate sbi_hart_pmp_configure() function and do the PMP configuration very late in coldboot and warmboot path just before platform_final_init(). Eventually, this enable us to configure PMP totally based on OpenSBI domain where OpenSBI domains can be parsed from device-tree in any of the platform operations except platform_final_init(). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-10-20include: sbi: Remove pmp_region callbacks from sbi_platform_operationsAnup Patel1-13/+1
The pmp_region_xyz() callbacks are not required in sbi_platform_operations because we will be using OpenSBI domain memory regions to program the PMP CSRs. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-10-20include: sbi: Remove redundant includes from sbi_platform.hAnup Patel1-0/+1
The sbi_ecall.h and sbi_trap.h are not required to be included in sbi_platform.h hence we remove it. This way sources requiring these headers will have to explicitly include it thereby reducing implicit includes. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-25lib: sbi: Fix PMP CSR detectionPragnesh Patel1-1/+1
HiFive unleashed currently implements fewer than 56 bits of physical address so existing PMP CSR detection is broken. PMP address register encodes bits 55-2 of a 56-bit physical address, Not all physical address bits may be implemented, So just check minimum 1 bit. Fixes: 74d1db706293 ("lib: sbi: Improve PMP CSR detection and progamming") Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-09-16lib: sbi: Ensure coldboot HART supports next privilege modeAnup Patel1-1/+28
The coldboot HART jumps to the next booting stage at the end of init_coldboot() so it is absolutely necessary for coldboot HART to support the privilege mode expected by the next booting stage. We extend the coldboot HART selection in sbi_init() to ensure that the selected coldboot HART always supports privilege mode specified in scratch space (i.e. scratch->next_mode). This will further help us allow E-core (without MMU) on SiFive Unleashed and PolarFire ICICLE boards to proceed further and wait in HSM STOPPED state. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-16lib: sbi: Allow specifying mode in sbi_hart_pmp_check_addr() APIAnup Patel3-18/+30
We extend sbi_hart_pmp_check_addr() API so that users can specify privilege mode of the address for checking PMP access permissions. To achieve this, we end-up converting "unsigned long *size" parameter to "unsigned long *log2len" for pmp_get() implementation so that we can deal with regions of "1UL << __riscv_xlen" size in a special case in sbi_hart_pmp_check_addr() implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-16lib: sbi: Allow specifying start mode to sbi_hsm_hart_start() APIAnup Patel2-2/+10
The sbi_scratch already has provision to specify the next stage mode so we can leverage this to specify start mode to sbi_hsm_hart_start(). In future, this will be useful in providing SBI calls to U-mode on embedded cores where we M-mode and U-mode but no S-mode. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-09lib: sbi_trap: Allow M-mode to M-mode ECALLsAnup Patel1-0/+1
We should allow M-mode to M-mode ECALLs because: 1. No other mode can handle M-mode ECALLs 2. In future, we can allow M-mode baremetal application (not linked to OpenSBI) running independently and cooperatively without corrupting OpenSBI M-mode state (CSRs and memory). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-09include: Rename ECALL defines to match latest RISC-V specAnup Patel2-2/+2
We rename CAUSE_HYPERVISOR_ECALL to CAUSE_SUPERVISOR_ECALL and CAUSE_SUPERVISOR_ECALL to CAUSE_VIRTUAL_SUPERVISOR_ECALL so that it matches latest RISC-V privilege spec. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-09lib: sbi: Don't handle VS-mode ecall in sbi_trap_handler()Anup Patel1-1/+0
The VS-mode ecall is supposed to be handled by HS-mode so sbi_trap_handler() should fallback to default case for VS-mode ecall trap. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-01lib: sbi: Improve HPM CSR read/write emulationAnup Patel1-72/+75
We improve HPM CSR read/write emulation as follows: 1. Fail for unimplemented counters so that trap is redirected to S-mode which can further help debugging S-mode software. 2. Check permissions in both MCOUNTEREN and SCOUNTEREN for HS-mode and U-mode. 3. Don't check permissions for TIME CSR because we emulate TIME CSR for both Host (HS/U-mode) and Guest (VS/VU-mode). Also, faster TIME CSR read is very helpful for good performance of S-mode software. 4. Don't emulate S-mode CSR read/write to M-mode HPM CSRs because these should not be accessible to S-mode software. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-01lib: sbi: Detect and print MHPM counters at boot-timeAnup Patel2-0/+18
A RISC-V platform can leave unimplemented MHPM counters hard-wired to zero. We extend hart_detect_features() to detect MHPM counters which are accessible and not hard-wired to zero. We also print number of available MHPM counters as part of boot prints. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-01lib: sbi: Improve PMP CSR detection and progammingAnup Patel2-144/+114
As-per latest RISC-V privilege spec up to 64 PMP entries are supported. Implementations may implement zero, 16, or 64 PMP CSRs. All PMP CSR fields are WARL and may be hardwired to zero. This patch improves PMP CSR detection and progamming considering above facts. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-01lib: sbi: Remove redundant SBI_HART_HAS_PMP featureAnup Patel1-14/+1
The SBI_HART_HAS_PMP feature is redundant because we already have number of PMP regions returned by sbi_hart_pmp_count(). Checking whether PMP is supported for a HART can be simply done by checking non-zero value returned by sbi_hart_pmp_count(). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-08-21lib: sbi: Handle the case where MTVAL has illegal instruction addressAnup Patel1-6/+15
The Kendryte K210 follows RISC-V v1.9 spec so MTVAL has instruction address (instead of instruction encoding) on illegal instruction trap. To handle above case, we fix sbi_illegal_insn_handler() without any impact on RISC-V v1.10 (or higher) systems. This achieved by exploiting the fact that program counter (and instruction address) is always 2-byte aligned in RISC-V world. Signed-off-by: Anup Patel <anup.patel@wdc.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-08-21lib: sbi_init: Avoid thundering hurd problem with coldboot_lockAnup Patel1-7/+13
We can have thundering hurd problem with coldboot_lock where the boot HART can potentially starve trying to acquire coldboot_lock because some of the non-boot HARTs are continuously acquiring and releasing coldboot_lock. This can happen if MIP.MSIP bit is already set for some of the non-boot HARTs. To avoid thundering hurd problem for coldboot_lock, we use the __smp_load_acquire() and __smp_store_release() for coldboot_done flag and use coldboot_lock only for coldboot_wait_hmask. Signed-off-by: Anup Patel <anup.patel@wdc.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Bin Meng <bin.meng@windriver.com>
2020-08-17lib: sbi_trap: Fix hstatus.SPVP update in sbi_trap_redirect()Georg Kotheimer1-1/+1
When redirecting from VS/VU-mode to HS-mode, hstatus.SPVP was set to the value of mstatus.SPP, as according to the specification both flags should be set to the same value. However, the assignment of SPVP takes place before SPP itself is updated, which results in SPVP having an outdated value. Signed-off-by: Georg Kotheimer <georg.kotheimer@tu-dresden.de> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-08-04lib: sbi_misaligned_ldst: Determine transformed instruction length correctlyAnup Patel1-4/+8
If MTINST[0:0] bit is 1 then we have transformed instruction encoding in MTINST CSR. For transformed instructions, if the MTINST[1:1] bit is Zero then original trapped instruction was a 16bit instruction which was converted to 32bit instruction at time of taking trap. We should use MTINST[1:1] bit to determine correct instruction length of transformed instruction. This patch updates misaligned load/store emulation as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-07-29lib: Add sbi_strncmp implementationAbner Chang1-0/+13
This commit add an implementation of sbi_strncmp. Signed-off-by: Abner Chang <abner.chang@hpe.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-06-20lib: Don't return any invalid error from SBI ecallAnup Patel3-3/+11
We should only return valid error codes from SBI ecalls as defined by the RISC-V SBI spec. To achieve this: 1. We use SBI_Exxxx defines for OpenSBI internal errors with error values starting from -1000 2. We use SBI_ERR_xxxx defines for errors defined by SBI spec 3. We map some of the SBI_Exxxx defines to SBI_ERR_xxxx defines which are semantically same 4. We throw a error print and force return error code to SBI_ERR_FAILED in sbi_ecall_handler() if we see an invalid error code being returned to S-mode Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-20lib: sbi: Fix 32/64 bits variable compatibilityLiush1-2/+2
On RV64,"unsigned long" is 64bit and "unsigned int" is 32bit. So in function "pmp_get" and "pmp_set", if "pmpcfg_shift >= 32", "0xff << pmpcfg_shift" will go beyond "unsigned int" width. This patch tries to fix this issue. In function 'pmp_get': cfgmask = (0xff << pmpcfg_shift); --> cfgmask = (0xffUL << pmpcfg_shift); In function 'pmp_set': cfgmask = ~(0xff << pmpcfg_shift); --> cfgmask = ~(0xffUL << pmpcfg_shift); Signed-off-by: Liush <liush.damon@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-06-18lib: Fix the SBI_HART_HAS_MCOUNTEREN feature checkAlistair Francis1-1/+1
Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-06-18lib: Don't print delegation CSRs if there is no S-ModeAlistair Francis1-0/+4
If the platform doesn't support S-Mode don't print the delegation registers. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-06-15lib: Fix __sbi_hfence_gvma_vmid_gpa() and __sbi_hfence_vvma_asid_va()Anup Patel2-14/+74
The arguments/parameters of __sbi_hfence_gvma_vmid_gpa() and __sbi_hfence_vvma_asid_va() functions are swapped so we fix it. Currently, we did not face any issues because QEMU does a full TLB flush for all HFENCE instructions. We also improve documentation of HFENCE.GVMA and HFENCE.VVMA instruction encoding. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-08lib: Add RISC-V hypervisor v0.6.1 supportAnup Patel3-16/+5
To support RISC-V hypervisor v0.6.1, we: 1. Don't need to explicitly forward WFI traps from VS/VU-mode 2. Have to delegate virtual instruction trap to HS-mode 3. Have to update trap redirection for changes in HSTATUS CSR Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-19lib: sbi_hart: Detect number of supported PMP regionsAnup Patel2-36/+81
It is not mandatory for a RISC-V systems to implement all PMP regions so we have to check all PMPADDRx CSRs to determine excat number of supported PMP regions. Signed-off-by: Anup Patel <anup.patel@wdc.com>
2020-05-19lib: sbi: Few cosmetic improvements to HART feature detectionAnup Patel1-20/+12
This patch does few cosmetic improvements to HART feature detection: 1. Remove sbi_ perfix from HART feature detection functions because all local/static functions in sbi_hart.c don't have sbi_ prefix 2. Remove sbi_hart_set_feature() because it's quite small and local/static in sbi_hart.c Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-19include: sbi: Use scratch pointer as parmeter in HART feature APIsAnup Patel3-25/+25
It makes more sense to have scratch pointer as parameter in HART feature APIs because: 1. We already have scratch pointer at places where these APIs are used. 2. This is consistent with lot of other APIs in sbi_hart.h Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-19lib: sbi: Print platform HART count just before boot HART idAnup Patel1-2/+2
On platforms with continuous HART ids starting from zero: 0 <= boot HART id < platform HART count The above co-relation of boot HART id and platform HART count is true for most RISC-V platfors so it's better to print platform HART count just before boot HART id. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-19lib: sbi: Remove extra spaces from boot time printsAnup Patel1-9/+9
We remove extra spaces from boot time prints. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-19lib: sbi: Improve get_feature_str() implementation and usageAnup Patel3-52/+31
We do following improvements for get_feature_str(): 1. We should return "none" from get_feature_str() no features available instead of sbi_boot_prints() explicitly handling failure. 2. We don't need to return failure (just like misa_xlen()) because we are returning "none" for no features and we are truncating output when space is not available. 3. Based on 1 and 2, the sbi_boot_prints() can be further simplified. 4. No need for two char[] in sbi_boot_prints() Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-19lib: sbi: detect features before everything else in sbi_hart_init()Anup Patel1-3/+3
We should detect HART features in sbi_hart_init() before mstatus_init(), delegate_traps() and pmp_init(). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-16lib: Optimize inline assembly for unprivilege access functionsAtish Patra1-17/+16
Currently, unprivileged access functions uses few additional instructions which are redundant. It also uses specific registers which are not necessary. Remove those additional instructions and let the compiler choose the registers. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-10lib: Add hart features in boot time printAtish Patra2-0/+85
We have now clear distinction between platform and hart features. Modify the boot print messages to print hart specific features in a string format. Signed-off-by: Atish Patra <atish.patra@wdc.com> Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-10lib: Add platform features in boot time printAtish Patra3-1/+117
We have now clear distinction between platform and hart features. Modify the boot print messages to print platform features in a string format. In the process, this patch moved relatively larger functions to its own file from platform.h header file. Signed-off-by: Atish Patra <atish.patra@wdc.com> Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-10lib: timer: Provide a hart based timer featureAtish Patra2-9/+26
As per the RISC-V specification, time value can be obtained from a time CSR implemented in hardware or a MMIO based IP block. Qemu virt machine already supports timer csr while CLINT provides the timer for other platforms. Implement a hart specific timer feature that can be detected at runtime. As CSR based timer implementation are faster than MMIO address based, it is always preferred over MMIO based one. Signed-off-by: Atish Patra <atish.patra@wdc.com> Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-10platform: Move platform features to hartAtish Patra1-8/+60
PMP & performance counters belong to a hart rather than a platform. In addition to that, these features enable reading/writing from a particular csr. Thus, they can be detected and set at runtime rather than compile time. Move PMP/MCOUNTEREN/SCOUNTEREN features to hart and detect them at runtime. Signed-off-by: Atish Patra <atish.patra@wdc.com> Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-10lib: Add support for hart specific featuresAtish Patra1-0/+23
There may be some features which are hart specific rather than a platform specific feature. Add a framework to support that. Signed-off-by: Atish Patra <atish.patra@wdc.com> Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-10lib: Create a separate math helper function fileAtish Patra3-13/+25
There may be few common mathematics helper functions which can be used anywhere in OpenSBI project. Add a separate math helper function file to add these functions. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-10lib: Rename unprivileged trap handlerAtish Patra4-14/+14
Unprivileged trap handler can be reused for any cases where the executing code expects a trap. Rename it to "expected" trap handler as it will be used in other cases in future. Signed-off-by: Atish Patra <atish.patra@wdc.com> Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu> Reviewed-by: Anup Patel <anup.patel@wdc.com>