summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-06-15lib: Fix __sbi_hfence_gvma_vmid_gpa() and __sbi_hfence_vvma_asid_va()Anup Patel3-16/+78
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-10platform: Add AE350 cache control SBIsNylon Chen5-1/+186
This patch contains the following AE350 specific SBIs: - get mcache_ctl status - get mmisc_ctl status - set mcache_ctl status - set mmisc_ctl status - I-cache operation - D-cache operation - enable/disable L1-I-cache prefetch - enable/disable L1-D-cache prefetch - enable/disable non-blocking load store - enable/disable write-around Signed-off-by: Nylon Chen <nylon7@andestech.com> Reviewed-by: Anup Patel <Anup.Patel@wdc.com> Reviewed-by: Atish Patra <Atish.Patra@wdc.com>
2020-06-10platform: Add AE350 platform specific SBI handlerNylon Chen2-3/+30
We add AE350 platform specific SBI handler to implement AE350 specific SBI calls. Signed-off-by: Nylon Chen <nylon7@andestech.com> Reviewed-by: Anup Patel <Anup.Patel@wdc.com> Reviewed-by: Atish Patra <Atish.Patra@wdc.com>
2020-06-08docs: Remove redundant documentation about combined payload use caseAtish Patra1-23/+0
U-Boot now supports loading Linux kernel image via network and storage media. Thus, we don't need to use a combined payload containing both U-Boot & Linux kernel image to boot Linux from U-Boot prompt. Remove the old documentation. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-06-08docs: Use doxygen config to mark the main pageAtish Patra2-2/+2
The doxygen config option "USE_MDFILE_AS_MAINPAGE" can be used to set the main page in doxygen generated pdf. This allows us to remove the "#mainpage" from the README file which markdown doesn't parse. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-06-08lib: Add RISC-V hypervisor v0.6.1 supportAnup Patel4-19/+17
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-06-05firmware: Remove FW_PAYLOAD_FDT and related documentationAnup Patel5-26/+6
Now that no platform is using FW_PAYLOAD_FDT mechanism, we remove related code from Makefile and related documentation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-05platform: kendryte/k210: Use new mechanism of builtin DTBAnup Patel3-2/+12
We update kendryte/k210 to use new mechanism of having builtin DTB where we convert k210.dts to C source and further compile-n-link it with libplatsbi.a. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-05Makefile: Add mechanism for platforms to have multiple builtin DTBsAnup Patel2-0/+84
Currently, we can only include one DTB as builtin for a platform using FDT_PAYLOAD_DTB make variable in platform config.mk. This patch adds new mechanism using which we can convert any DTS file to C source and futher compile-n-link it with libplatsbi.a. The generated C source will have the DTB contents as an array "const char <varprefix>_start[]" where <varprefix> is specified in platform objects.mk makefile. Example1 -------- If we have built-in k210.dts and desired <varprefix> is "dt_k210" then specify following in platform objects.mk: platform-objs-y += k210.o platform-varprefix-k210.o = dt_k210 Example2 -------- If we have built-in abc/k210.dts and desired <varprefix> is "dt_abc_k210" then specify following in platform objects.mk: platform-objs-y += abc/k210.o platform-varprefix-abc-k210.o = dt_abc_k210 Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-05Makefile: Preprocess builtin DTSAnup Patel1-2/+2
In order to use GCC style defines and macros in DTS, we should preporcess builtin DTS before converting it to DTB. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-05firmware: Allow fw_platform_init() to return updated FDT locationAnup Patel2-4/+12
Currently, the fw_platform_init() does not return anything but we can further improve by allowing fw_platform_init() to return updated FDT location. It is certainly not mandatory for fw_platform_init() to return a new location of FDT (or modify FDT). In fact, the fw_platform_init() can always return the original FDT location (i.e. 'arg1') unmodified. This new capability of fw_platform_init() will allow platforms to: 1. Have multiple built-in FDTs and select one 2. Modify FDT before using based on platform specific straps or OTP Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-05firmware: fw_base: Don't OR forced FW_OPTIONSAnup Patel1-5/+3
Currently, we are ORing FW_OPTIONS with the options passed by previous booting stage to fw_dynamic. This causes confusion because compiling fw_dynamic with FW_OPTIONS=0x2 does not force enable boot prints as the U-Boot SPL passes options=0x1 in fw_dyanmic_info. The best thing to do is always prefer FW_OPTIONS when available. This is intuitive for OpenSBI users and easy in debugging. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-05firmware: fw_base: Make builtin DTB available to fw_platform_init()Anup Patel1-14/+14
Currently, fw_prev_arg1() is called after fw_platform_init() which caused builtin DTB to be not available to fw_platform_init(). To allow builtin DTB available to fw_platform_init(), we should call fw_save_info() and fw_prev_arg1() before fw_platform_init(). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-05Makefile: Fix builtin DTB compilation for out-of-tree platformsAnup Patel1-3/+3
The make rule for builtin DTB compilation does not consider out-of-tree platforms so this patch fixes it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-23lib: utils/timer: Initialize all matching timer DT nodesAnup Patel2-13/+26
We can have multiple matching DT nodes of the same FDT timer driver so in this case we should call cold_init() for all matching DT nodes instead of just first matching DT node. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-23lib: utils/ipi: Initialize all matching ipi DT nodesAnup Patel2-13/+24
We can have multiple matching DT nodes of the same FDT ipi driver so in this case we should call cold_init() for all matching DT nodes instead of just first matching DT node. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-23lib: utils: Add fdt_parse_clint_node() functionAnup Patel4-26/+76
We add fdt_parse_clint_node() function which will be used by fdt_ipi_clint and fdt_timer_clint drivers to parse CLINT details from DT node. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-23lib: utils: Allow CLINT functions to be used for multiple CLINTsAnup Patel11-88/+203
We extend CLINT cold init function to have a "struct clint_data *" parameter pointing to CLINT details. This allows platforms to use CLINT functions for multiple CLINT instances. When multiple CLINTs are present, the platform can also provide one of the CLINT as reference CLINT for other CLINTs. This will help CLINTs to sync their time value with reference CLINT using a time_delta computed in warm init function. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-23lib: utils/irqchip: Initialize all matching irqchip DT nodesAnup Patel2-22/+40
We can have multiple matching DT nodes of the same FDT irqchip driver so in this case we should call cold_init() for all matching DT nodes instead of just first matching DT node. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-23lib: utils: Extend fdt_find_match() ImplementationAnup Patel8-9/+11
We extend fdt_find_match() implementation by adding node offset parameter which represents the first node to match from. The improved fdt_find_match() can be used to find multiple match nodes. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-23lib: utils: Allow PLIC functions to be used for multiple PLICsAnup Patel12-82/+127
We extend all PLIC functions to have a "struct plic_data *" parameter pointing to PLIC details. This allows platforms to use these functions for multiple PLIC instances. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-23lib: utils: Remove redundant parameters from PLIC init functionsAnup Patel10-48/+22
The "target_hart" and "hart_count" parameters of PLIC cold and warm init functions are only used for sanity checks and not required in PLIC initialization. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-19include: sbi: Add firmware extension constantsDaniel Schaefer1-0/+2
Cc: Abner Chang <abner.chang@hpe.com> Signed-off-by: Daniel Schaefer <git@danielschaefer.me> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-19lib: sbi_hart: Detect number of supported PMP regionsAnup Patel4-52/+103
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 Patel5-31/+32
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 Patel5-56/+34
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-18firmware: Correct spelling mistakesDaniel Schaefer1-2/+2
Signed-off-by: Daniel Schaefer <git@danielschaefer.me> Reviewed-by: Anup Patel <anup.patel@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 Patra3-0/+89
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 Patra4-27/+158
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 Patra3-9/+28
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: fpga: Remove redundant platform specific featuresAtish Patra2-10/+2
Any platform feature that belongs to a hart, have already been moved to hart features and are detected at run time. The remaining platform features are identical to platform default features. Use the platform default features instead of defining a separate copy of it. 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 Patra7-36/+77
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 Patra2-0/+24
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: utils: Update reserved memory fdt node even if PMP is not presentAtish Patra1-52/+71
As per RISC-V ISA, pmp is not mandatory. Currently, we only add reserved memory node in DT only if PMP is present. That allows supervisor to access the memory where OpenSBI continue to exist without realizing it for non-pmp based platforms. It may result in corrupting OpenSBI. That's why OpenSBI should at least let the supervisor know where it continue to exist. This a best effort service provided by OpenSBI expecting that supervisor software is not buggy and properly sets up its memory after parsing the reserved-memory device tree node. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-05-10lib: Create a separate math helper function fileAtish Patra4-13/+40
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: Add csr detect supportAtish Patra1-0/+50
As RISC-V ISA allows many CSRs such as pmp, s/mcounteren to be optional in hardware, OpenSBI should provide an option to dynamically detect these csr access capability at run time. Implement a csr read/write access check helper macros. 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: Rename unprivileged trap handlerAtish Patra5-17/+17
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>
2020-05-07docs: Don't use italic text in page titleAnup Patel3-3/+3
Doxygen does not support italic text in page title so fix some of the markdown files accordingly. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-07docs: Fix ordering of pages in table of contentsAnup Patel2-34/+37
Currently, all markdown pages are randomly arranged in table of contents so to fix this we treat top-level README.md as mainpage and enable Doxygen TREEVIEW. Also, there should not be any text before title of a markdown page so we move project copyright as separate section in top-level README.md. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-07docs: Add platform requirements documentAnup Patel3-0/+47
We add platform requirements document to clarify OpenSBI expectations from a RISC-V platform. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Bin Meng <bin.meng@windriver.com>
2020-05-07docs: platform/generic: Add details about IPI and timer expectationsAnup Patel1-0/+4
The generic platform provides IPI and timer functionality based on DT node provided in the FDT passed by previous booting stage. This patch updates generic platform documentation about IPI and timer expectations. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-07docs: platform/generic: Add details about stdout-path DT propertyAnup Patel1-0/+2
The generic platform will try to select serial console based on the stdout-path DT property in /chosen DT node hence we document this. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-07lib: sbi: Improve misa_string() implementationAnup Patel3-19/+52
The RISC-V ISA string does not follow alphabetical order. Instead, we have a RISC-V specific ordering of extensions in the RISC-V ISA string. This patch improves misa_string() implementation to return a valid RISC-V ISA string. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-07lib: sbi_tlb: Fix remote TLB HFENCE VVMA implementationAnup Patel5-22/+69
The HFENCE VVMA instructions flushes TLB based on the VMID present in HGATP CSR. To handle this, we get the current VMID for SBI HFENCE VVMA call and we use this current VMID to do remote TLB HFENCE VVMA on desired set of HARTs. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-05-07include: sbi: Remove redundant page table related definesAnup Patel1-20/+0
We don't have page table programming in OpenSBI so let's remove redundant page table related defines from riscv_encoding.h. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>