Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cycle & instret privilege mode filtering support #2

Open
wants to merge 187 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
f14595a
lib: sbi: Allow platform to influence cold boot HART selection
avpatel Dec 29, 2022
6957ae0
platform: generic: Allow platform_override to select cold boot HART
avpatel Dec 29, 2022
cb7e7c3
platform: generic: Allow platform_override to perform firmware init
Dec 29, 2022
8020df8
generic/starfive: Add Starfive JH7110 platform implementation
Dec 29, 2022
6997552
lib: sbi_hsm: Rename 'priv' argument to 'arg1'
lbmeng Dec 30, 2022
9e397e3
docs: domain_support: Use capital letter for privilege modes
lbmeng Dec 30, 2022
9e0ba09
include: sbi: Fine grain the permissions for M and SU modes
hschauhan Jan 9, 2023
aace1e1
lib: sbi: Use finer permission semantics for address validation
hschauhan Jan 9, 2023
22dbdb3
lib: sbi: Add permissions for the firmware start till end
hschauhan Jan 9, 2023
1ac14f1
lib: sbi: Use finer permission sematics to decide on PMP bits
hschauhan Jan 9, 2023
44f736c
lib: sbi: Modify the boot time region flag prints
hschauhan Jan 9, 2023
20646e0
lib: utils: Use SU-{R/W/X} flags for region permissions during parsing
hschauhan Jan 9, 2023
3e2f573
lib: utils: Disallow non-root domains from adding M-mode regions
hschauhan Jan 9, 2023
59a08cd
lib: utils: Add M-mode {R/W} flags to the MMIO regions
hschauhan Jan 9, 2023
001106d
docs: Update domain's region permissions and requirements
hschauhan Jan 9, 2023
da5594b
platform: generic: allwinner: Fix PLIC array bounds
smaeul Dec 27, 2022
ce2a834
docs: generic.md: fix typo of andes-ae350
lyctw Jan 20, 2023
8ecbe6d
lib: sbi_hsm: handle failure when hart_stop returns SBI_ENOTSUPP
lyctw Jan 20, 2023
b1818ee
include: types: add always inline compiler attribute
lyctw Jan 20, 2023
9c4eb35
lib: utils: atcsmu: Add Andes System Management Unit support
lyctw Jan 20, 2023
787296a
platform: andes/ae350: Implement hart hotplug using HSM extension
lyctw Jan 20, 2023
7aaeeab
lib: reset/fdt_reset_atcwdt200: Use defined macros and function in at…
lyctw Jan 20, 2023
a990309
lib: utils: Fix reserved memory node for firmware memory
mdchitale Jan 21, 2023
fefa548
firmware: Split RO/RX and RW sections
hschauhan Jan 19, 2023
2f40a99
firmware: Move dynsym and reladyn sections to RX section
hschauhan Jan 19, 2023
c10e3fe
firmware: Add RW section offset in scratch
hschauhan Jan 19, 2023
b666760
lib: sbi: Print the RW section offset
hschauhan Jan 19, 2023
230278d
lib: sbi: Add separate entries for firmware RX and RW regions
hschauhan Jan 19, 2023
dea0922
platform: renesas/rzfive: Configure Local memory regions as part of r…
prabhakarlad Jan 13, 2023
33bf917
lib: utils: Add fdt_add_cpu_idle_states() helper function
smaeul Jan 23, 2023
c45992c
platform: generic: allwinner: Advertise nonretentive suspend
smaeul Jan 23, 2023
c8ea836
firmware: Fix fw_rw_offset computation in fw_base.S
jrtc27 Jan 26, 2023
8050081
firmware: Not to clear all the MIP
nick650823 Jan 17, 2023
84d15f4
lib: sbi_hsm: Use csr_set to restore the MIP
nick650823 Jan 17, 2023
199189b
lib: utils: Mark only the largest region as reserved in FDT
hschauhan Jan 27, 2023
66b0e23
lib: sbi: Ensure domidx_to_domain_table is null-terminated
jones-drew Jan 30, 2023
642f3de
Makefile: Add missing .dep files for fw_*.elf.ld
jrtc27 Feb 1, 2023
09b34d8
include: Add support for byteorder/endianness conversion
pathakraul Feb 2, 2023
680bea0
lib: utils/fdt: Use byteorder conversion functions in libfdt_env.h
pathakraul Feb 2, 2023
b224ddb
include: types: Add typedefs for endianness
pathakraul Feb 2, 2023
aa5dafc
include: sbi: Fix BSWAPx() macros for big-endian host
avpatel Feb 9, 2023
e3bf1af
include: Add defines for SBI debug console extension
avpatel Jul 22, 2022
0ee3a86
lib: sbi: Add sbi_nputs() function
avpatel Jul 22, 2022
4e0572f
lib: sbi: Add sbi_ngets() function
avpatel Jan 4, 2023
eab48c3
lib: sbi: Add sbi_domain_check_addr_range() function
avpatel Nov 23, 2022
5a41a38
lib: sbi: Implement SBI debug console extension
avpatel Nov 23, 2022
c43903c
lib: sbi: Add console_puts() callback in the console device
avpatel Nov 23, 2022
29285ae
lib: utils/serial: Implement console_puts() for semihosting
avpatel Nov 23, 2022
65c2190
lib: sbi: Speed-up sbi_printf() and friends using nputs()
avpatel Jan 13, 2023
321293c
lib: utils/fdt: Fix fdt_pmu.c header dependency
lbmeng Feb 23, 2023
aafcc90
platform: generic/allwinner: Fix sun20i-d1.c header dependency
lbmeng Feb 23, 2023
745aaec
platform: generic/andes: Fix ae350.c header dependency
lbmeng Feb 23, 2023
99d09b6
include: fdt/fdt_helper: Change fdt_get_address() to return root.next…
lbmeng Feb 23, 2023
6861ee9
lib: utils: fdt_fixup: Fix compile error
wxjstz Feb 21, 2023
4f2be40
docs: fix typo in fw.md
Headcrabed Feb 15, 2023
30ea806
lib: sbi_hart: Enable hcontext and scontext
Feb 10, 2023
81adc62
lib: sbi: Align SBI vendor extension id with mvendorid CSR
avpatel Feb 13, 2023
31b82e0
include: sbi: Remove extid parameter from vendor_ext_provider() callback
avpatel Feb 13, 2023
c100951
platform: generic: renesas: rzfive: Add support to configure the PMA
prabhakarlad Feb 13, 2023
2491242
platform: generic: renesas: rzfive: Configure the PMA region
prabhakarlad Feb 13, 2023
67b2a40
lib: sbi: sbi_ecall: Check the range of SBI error
lyctw Feb 22, 2023
5a75f53
lib: sbi/sbi_domain: cosmetic style fixes
lbmeng Feb 24, 2023
bc06ff6
lib: utils/fdt/fdt_domain: Simplify region access permission check
lbmeng Feb 24, 2023
17b3776
docs: domain_support: Update the DT example
lbmeng Feb 24, 2023
1364d5a
lib: sbi_hsm: Factor out invalid state detection
jones-drew Feb 27, 2023
40f16a8
lib: sbi_hsm: Don't try to restore state on failed change
jones-drew Feb 27, 2023
c88e039
lib: sbi_hsm: Ensure errors are consistent with spec
jones-drew Feb 27, 2023
b1ae6ef
lib: sbi_hsm: Move misplaced comment
jones-drew Feb 27, 2023
07673fc
lib: sbi_hsm: Remove unnecessary include
jones-drew Feb 27, 2023
8a40306
lib: sbi_hsm: Export some functions
jones-drew Feb 27, 2023
73623a0
lib: sbi: Add system suspend skeleton
jones-drew Feb 27, 2023
c9917b6
lib: sbi: Add system_suspend_allowed domain property
jones-drew Feb 27, 2023
7c964e2
lib: sbi: Implement system suspend
jones-drew Feb 27, 2023
37558dc
docs: Correct opensbi-domain property name
jones-drew Feb 27, 2023
5ccebf0
platform: generic: Add system suspend test
jones-drew Feb 27, 2023
908be1b
gpio/starfive: add gpio driver and support gpio reset
mindachen1987 Feb 16, 2023
4b28afc
make: Add a command line option for debugging OpenSBI
lbmeng Feb 27, 2023
e9d08bd
lib: utils/i2c: Add minimal StarFive jh7110 I2C driver
mindachen1987 Mar 9, 2023
568ea49
platform: starfive: add PMIC power ops in JH7110 visionfive2 board
mindachen1987 Mar 9, 2023
506144f
lib: serial: Cadence: Enable compatibility for cdns,uart-r1p8
mdchitale Mar 1, 2023
1fe8dc9
lib: sbi_pmu: add callback for counter width
mdchitale Mar 9, 2023
51951d9
lib: sbi_pmu: Implement sbi_pmu_counter_fw_read_hi
mdchitale Mar 9, 2023
60c358e
lib: sbi_pmu: Reserve space for implementation specific firmware events
mdchitale Mar 9, 2023
548e4b4
lib: sbi_pmu: Rename fw_counter_value
mdchitale Mar 9, 2023
b51ddff
lib: sbi_pmu: Update sbi_pmu dev ops
mdchitale Mar 9, 2023
641d2e9
lib: sbi_pmu: Use dedicated event code for platform firmware events
mdchitale Mar 9, 2023
57d3aa3
lib: sbi_pmu: Introduce fw_counter_write_value API
mdchitale Mar 9, 2023
c631a7d
lib: sbi_pmu: Add hartid parameter PMU device ops
mdchitale Mar 9, 2023
d56049e
lib: sbi: Refactor the calls to sbi_hart_switch_mode()
Mar 5, 2023
e8e9ed3
lib: sbi: Set the state of a hart to START_PENDING after the hart is …
Mar 5, 2023
c6a092c
lib: sbi: Clear IPIs before init_warm_startup in non-boot harts
Mar 5, 2023
ed88a63
lib: sbi_scratch: Optimize the alignment code for alloc size
wxjstz Mar 9, 2023
73ab11d
lib: sbi: Fix how to check whether the domain contains fw_region
wxjstz Mar 16, 2023
f64dfcd
lib: sbi: Introduce sbi_entry_count() function
avpatel Mar 20, 2023
30b9e7e
lib: sbi_hsm: Fix sbi_hsm_hart_start() for platform with hart hotplug
avpatel Mar 20, 2023
8e90259
lib: sbi_hart: clear mip csr during hart init
mdchitale Mar 25, 2023
45ba2b2
include: Add defines for SBI CPPC extension
vlsunil Mar 29, 2023
33caae8
lib: sbi: Implement SBI CPPC extension
vlsunil Mar 29, 2023
91767d0
lib: sbi: Print the CPPC device name
vlsunil Mar 29, 2023
edc9914
lib: sbi_pmu: Align the event type offset as per SBI specification
lyctw Mar 30, 2023
ee016a7
docs: Correct FW_JUMP_FDT_ADDR calculation example
gsomlo Mar 30, 2023
2868f26
lib: utils: fdt_fixup: avoid buffer overrun
xypron Mar 31, 2023
66fa925
lib: sbi: Optimize sbi_tlb
wxjstz Apr 11, 2023
24dde46
lib: sbi: Optimize sbi_ipi
wxjstz Apr 11, 2023
80078ab
sbi: tlb: Simplify to tlb_process_count/tlb_process function
wxjstz Apr 11, 2023
bf40e07
lib: sbi: Optimize sbi_tlb queue waiting
wxjstz Apr 14, 2023
eeab500
platform: generic: andes/renesas: Add SBI EXT to check for enabling I…
prabhakarlad Apr 11, 2023
f692289
firmware: Optimize loading relocation type
lbmeng Apr 4, 2023
e41dbb5
firmware: Change to use positive offset to access relocation entries
lbmeng Apr 4, 2023
bdb3c42
lib: sbi: Do not clear active_events for cycle/instret when stopping
Apr 13, 2023
674e019
lib: sbi: Fix counter index calculation for SBI_PMU_CFG_FLAG_SKIP_MATCH
Apr 13, 2023
f5dfd99
lib: sbi: Don't check SBI error range for legacy console getchar
avpatel Apr 17, 2023
7919530
lib: sbi: Add debug print when sbi_pmu_init fails
endeneer Apr 14, 2023
4e33530
lib: sbi: Remove unnecessary semicolon
wxjstz Apr 25, 2023
6bc02de
lib: sbi: Simplify sbi_ipi_process remove goto
wxjstz Apr 25, 2023
dc1c7db
lib: sbi: Simplify BITS_PER_LONG definition
wxjstz Apr 25, 2023
f58c140
lib: sbi: Introduce register_extensions extension callback
jones-drew May 15, 2023
e307ba7
lib: sbi: Narrow vendor extension range
jones-drew May 15, 2023
042f0c3
lib: sbi: pmu: Remove unnecessary probe function
jones-drew May 15, 2023
8b952d4
lib: sbi: Only register available extensions
jones-drew May 15, 2023
767b5fc
lib: sbi: Optimize probe of srst/susp
wxjstz May 15, 2023
c3e31cb
lib: sbi: Remove 0/1 probe implementations
jones-drew May 15, 2023
33f1722
lib: sbi: Document sbi_ecall_extension members
jones-drew May 15, 2023
d4c46e0
Makefile: Dereference symlinks on install
filmil May 16, 2023
8b99a7f
lib: sbi: Fix return of sbi_console_init
wxjstz May 22, 2023
264d0be
lib: utils: Improve fdt_serial_init
wxjstz May 22, 2023
9a0bdd0
lib: utils: Improve fdt_ipi
wxjstz May 22, 2023
122f226
lib: utils: Improve fdt_timer
wxjstz May 22, 2023
df75e09
lib: utils/ipi: buffer overrun aclint_mswi_cold_init
xypron May 29, 2023
bdde2ec
lib: sbi: Align system suspend errors with spec
jones-drew Jun 1, 2023
aad7a37
include: sbi_scratch: Add helper macros to access data type
avpatel Jun 5, 2023
5cf9a54
platform: Allow platforms to specify heap size
avpatel Apr 17, 2023
40d36a6
lib: sbi: Introduce simple heap allocator
avpatel Apr 18, 2023
2a04f70
lib: sbi: Print scratch size and usage at boot time
avpatel Apr 20, 2023
bbff53f
lib: sbi_pmu: Use heap for per-HART PMU state
avpatel Apr 19, 2023
ef4542d
lib: sbi: Use heap for root domain creation
avpatel Apr 21, 2023
66daafe
lib: sbi: Use scratch space to save per-HART domain pointer
avpatel Apr 25, 2023
fa5ad2e
lib: utils/gpio: Use heap in SiFive and StartFive GPIO drivers
avpatel Apr 19, 2023
903e88c
lib: utils/i2c: Use heap in DesignWare and SiFive I2C drivers
avpatel Apr 19, 2023
5a8cfcd
lib: utils/ipi: Use heap in ACLINT MSWI driver
avpatel Apr 19, 2023
3013716
lib: utils/irqchip: Use heap in PLIC, APLIC and IMSIC drivers
avpatel Apr 19, 2023
7e5636a
lib: utils/timer: Use heap in ACLINT MTIMER driver
avpatel Apr 19, 2023
3c1c972
lib: utils/fdt: Use heap in FDT domain parsing
avpatel Apr 20, 2023
acbd8fc
lib: utils/ipi: Use scratch space to save per-HART MSWI pointer
avpatel Apr 19, 2023
f0516be
lib: utils/timer: Use scratch space to save per-HART MTIMER pointer
avpatel Apr 19, 2023
b3594ac
lib: utils/irqchip: Use scratch space to save per-HART PLIC pointer
avpatel Apr 19, 2023
1df52fa
lib: utils/irqchip: Don't check hartid in imsic_update_hartid_table()
avpatel Apr 20, 2023
355796c
lib: utils/irqchip: Use scratch space to save per-HART IMSIC pointer
avpatel Apr 20, 2023
524feec
docs: Add OpenSBI logo and use it in the top-level README.md
avpatel Jun 9, 2023
932be2c
README.md: Improve project copyright information
avpatel Jun 9, 2023
8153b26
platform/lib: Set no-map attribute on all PMP regions
Jun 14, 2023
d64942f
firmware: Fix find hart index
wxjstz Jun 16, 2023
27c957a
lib: reset: Move fdt_reset_init into generic_early_init
guoren83 Jun 18, 2023
8bd666a
lib: sbi: check A2 register in ecall_dbcn_handler.
glg-rv Jun 22, 2023
2552799
include: Bump-up version to 1.3
avpatel Jun 23, 2023
0907de3
lib: sbi: fix comment indent
glg-rv Jun 29, 2023
eb736a5
lib: sbi_pmu: Avoid out of bounds access
xypron Jul 3, 2023
7828eeb
gpio/desginware: add Synopsys DesignWare APB GPIO support
bjdooks-sifive Mar 1, 2023
c6a3573
lib: utils: Fix sbi_hartid_to_scratch() usage in ACLINT drivers
avpatel Jul 5, 2023
1a398d9
lib: sbi: Add Zicntr as a HART ISA extension
avpatel Jul 5, 2023
669089c
lib: sbi: Add Zihpm as a HART ISA extension
avpatel Jul 5, 2023
72b9c8f
lib: sbi: Alphabetically sort HART ISA extensions
avpatel Jul 5, 2023
5359fc6
lib: sbi: Rename hart_pmu_get_allowed_bits() function
avpatel Jul 5, 2023
976895c
lib: sbi: Fix Priv spec version for [m|s]counteren and mcountinhibit …
Jul 6, 2023
6053917
lib: sbi: Fix how print gets flags
wxjstz Jul 9, 2023
35ef182
lib: sbi: print not fill '0' when left-aligned
wxjstz Jul 9, 2023
40dac06
lib: sbi: Add '+' flags for print
wxjstz Jul 9, 2023
458fa74
lib: sbi: Add ' ' '\'' flags for print
wxjstz Jul 9, 2023
05cbb6e
lib: sbi: implifying the parameters of printi
wxjstz Jul 9, 2023
fe08281
lib: sbi: print add 'o' type
wxjstz Jul 9, 2023
c6ee5ae
lib: sbi: Fix printi
wxjstz Jul 9, 2023
3b6fcdd
lib: sbi: Simplify prints
wxjstz Jul 9, 2023
cc89fa7
lib: sbi: Fix printc
wxjstz Jul 9, 2023
ff43168
lib: sbi: Fix timing of clearing tbuf
wxjstz Jul 9, 2023
a73982d
lib: sbi: Fix missing '\0' when buffer szie equal 1
wxjstz Jul 9, 2023
ea6533a
lib: utils/gpio: Fix RV32 compile error for designware GPIO driver
avpatel Jul 11, 2023
c3b98c6
include: sbi: Add macro definitions for mseccfg CSR
hschauhan Jul 12, 2023
1c099c4
lib: sbi: Add functions to manipulate PMP entries
hschauhan Jul 12, 2023
6c202c5
include: sbi: Add Smepmp specific access flags for PMP entries
hschauhan Jul 12, 2023
cbcfc7b
lib: sbi: Add smepmp in hart extensions
hschauhan Jul 12, 2023
d72f5f1
lib: utils: Add detection of Smepmp from ISA string in FDT
hschauhan Jul 12, 2023
4a42a23
lib: sbi: Grant SU R/W/X permissions to whole memory
hschauhan Jul 12, 2023
f3fdd04
lib: sbi: Change the order of PMP initialization
hschauhan Jul 12, 2023
5dd8db5
lib: sbi: Add support for Smepmp
hschauhan Jul 12, 2023
6e44ef6
lib: sbi: Add functions to map/unmap shared memory
hschauhan Jul 12, 2023
0ad8660
lib: sbi: Map/Unmap debug console shared memory buffers
hschauhan Jul 12, 2023
de7cdbb
lib: sbi: Add support for smcntrpmf
KevinRSX Jul 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ deps-y=$(platform-objs-path-y:.o=.dep)
deps-y+=$(libsbi-objs-path-y:.o=.dep)
deps-y+=$(libsbiutils-objs-path-y:.o=.dep)
deps-y+=$(firmware-objs-path-y:.o=.dep)
deps-y+=$(firmware-elfs-path-y:=.dep)

# Setup platform ABI, ISA and Code Model
ifndef PLATFORM_RISCV_ABI
Expand Down Expand Up @@ -330,7 +331,12 @@ GENFLAGS += $(libsbiutils-genflags-y)
GENFLAGS += $(platform-genflags-y)
GENFLAGS += $(firmware-genflags-y)

CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -O2
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing
ifneq ($(DEBUG),)
CFLAGS += -O0
else
CFLAGS += -O2
endif
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
Expand Down Expand Up @@ -395,10 +401,10 @@ merge_deps = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
cat $(2) > $(1)
copy_file = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " COPY $(subst $(build_dir)/,,$(1))"; \
cp -f $(2) $(1)
cp -L -f $(2) $(1)
inst_file = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " INSTALL $(subst $(install_root_dir)/,,$(1))"; \
cp -f $(2) $(1)
cp -L -f $(2) $(1)
inst_file_list = $(CMD_PREFIX)if [ ! -z "$(4)" ]; then \
mkdir -p $(1)/$(3); \
for file in $(4) ; do \
Expand All @@ -407,12 +413,17 @@ inst_file_list = $(CMD_PREFIX)if [ ! -z "$(4)" ]; then \
dest_dir=`dirname $$dest_file`; \
echo " INSTALL "$(3)"/"`echo $$rel_file`; \
mkdir -p $$dest_dir; \
cp -f $$file $$dest_file; \
cp -L -f $$file $$dest_file; \
done \
fi
inst_header_dir = $(CMD_PREFIX)mkdir -p $(1); \
echo " INSTALL $(subst $(install_root_dir)/,,$(1))"; \
cp -rf $(2) $(1)
cp -L -rf $(2) $(1)
compile_cpp_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " CPP-DEP $(subst $(build_dir)/,,$(1))"; \
printf %s `dirname $(1)`/ > $(1) && \
$(CC) $(CPPFLAGS) -x c -MM $(3) \
-MT `basename $(1:.dep=$(2))` >> $(1) || rm -f $(1)
compile_cpp = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " CPP $(subst $(build_dir)/,,$(1))"; \
$(CPP) $(CPPFLAGS) -x c $(2) | grep -v "\#" > $(1)
Expand Down Expand Up @@ -543,6 +554,9 @@ $(platform_build_dir)/%.bin: $(platform_build_dir)/%.elf
$(platform_build_dir)/%.elf: $(platform_build_dir)/%.o $(platform_build_dir)/%.elf.ld $(platform_build_dir)/lib/libplatsbi.a
$(call compile_elf,$@,[email protected],$< $(platform_build_dir)/lib/libplatsbi.a)

$(platform_build_dir)/%.dep: $(src_dir)/%.ldS $(KCONFIG_CONFIG)
$(call compile_cpp_dep,$@,.ld,$<)

$(platform_build_dir)/%.ld: $(src_dir)/%.ldS
$(call compile_cpp,$@,$<)

Expand Down
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
RISC-V Open Source Supervisor Binary Interface (OpenSBI)
========================================================

![RISC-V OpenSBI](docs/riscv_opensbi_logo_final_color.png)

Copyright and License
---------------------

The OpenSBI project is copyright (c) 2019 Western Digital Corporation
or its affiliates and other contributors.
The OpenSBI project is:

* Copyright (c) 2019 Western Digital Corporation or its affiliates
* Copyright (c) 2023 RISC-V International

It is distributed under the terms of the BSD 2-clause license
("Simplified BSD License" or "FreeBSD License", SPDX: *BSD-2-Clause*).
Expand Down Expand Up @@ -298,6 +302,19 @@ NOTE: Using `BUILD_INFO=y` without specifying SOURCE_DATE_EPOCH will violate
purpose, and should NOT be used in a product which follows "reproducible
builds".

Building with optimization off for debugging
--------------------------------------------

When debugging OpenSBI, we may want to turn off the compiler optimization and
make debugging produce the expected results for a better debugging experience.
To build with optimization off we can just simply add `DEBUG=1`, like:
```
make DEBUG=1
```

This definition is ONLY for development and debug purpose, and should NOT be
used in a product build.

Contributing to OpenSBI
-----------------------

Expand Down
33 changes: 25 additions & 8 deletions docs/domain_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ has following details:
* **next_mode** - Privilege mode of the next booting stage for this
domain. This can be either S-mode or U-mode.
* **system_reset_allowed** - Is domain allowed to reset the system?
* **system_suspend_allowed** - Is domain allowed to suspend the system?

The memory regions represented by **regions** in **struct sbi_domain** have
following additional constraints to align with RISC-V PMP requirements:
Expand Down Expand Up @@ -91,6 +92,7 @@ following manner:
* **next_mode** - Next booting stage mode in coldboot HART scratch space
is the next mode for the ROOT domain
* **system_reset_allowed** - The ROOT domain is allowed to reset the system
* **system_suspend_allowed** - The ROOT domain is allowed to suspend the system

Domain Effects
--------------
Expand Down Expand Up @@ -124,6 +126,9 @@ The DT properties of a domain configuration DT node are as follows:
* **compatible** (Mandatory) - The compatible string of the domain
configuration. This DT property should have value *"opensbi,domain,config"*

* **system-suspend-test** (Optional) - When present, enable a system
suspend test implementation which simply waits five seconds and issues a WFI.

### Domain Memory Region Node

The domain memory region DT node describes details of a memory region and
Expand Down Expand Up @@ -160,8 +165,16 @@ The DT properties of a domain instance DT node are as follows:
* **regions** (Optional) - The list of domain memory region DT node phandle
and access permissions for the domain instance. Each list entry is a pair
of DT node phandle and access permissions. The access permissions are
represented as a 32bit bitmask having bits: **readable** (BIT[0]),
**writeable** (BIT[1]), **executable** (BIT[2]), and **m-mode** (BIT[3]).
represented as a 32bit bitmask having bits: **M readable** (BIT[0]),
**M writeable** (BIT[1]), **M executable** (BIT[2]), **SU readable**
(BIT[3]), **SU writable** (BIT[4]), and **SU executable** (BIT[5]).
The enforce permission bit (BIT[6]), if set, will lock the permissions
in the PMP. This will enforce the permissions on M-mode as well which
otherwise will have unrestricted access. This bit must be used with
caution because no changes can be made to a PMP entry once its locked
until the hart is reset.
Any region of a domain defined in DT node cannot have only M-bits set
in access permissions i.e. it cannot be an m-mode only accessible region.
* **boot-hart** (Optional) - The DT node phandle of the HART booting the
domain instance. If coldboot HART is assigned to the domain instance then
this DT property is ignored and the coldboot HART is assumed to be the
Expand All @@ -180,13 +193,15 @@ The DT properties of a domain instance DT node are as follows:
is used as default value.
* **next-mode** (Optional) - The 32 bit next booting stage mode for the
domain instance. The possible values of this DT property are: **0x1**
(s-mode), and **0x0** (u-mode). If this DT property is not available
(S-mode), and **0x0** (U-mode). If this DT property is not available
and coldboot HART is not assigned to the domain instance then **0x1**
is used as default value. If this DT property is not available and
coldboot HART is assigned to the domain instance then **next booting
stage mode of coldboot HART** is used as default value.
* **system-reset-allowed** (Optional) - A boolean flag representing
whether the domain instance is allowed to do system reset.
* **system-suspend-allowed** (Optional) - A boolean flag representing
whether the domain instance is allowed to do system suspend.

### Assigning HART To Domain Instance

Expand All @@ -195,9 +210,9 @@ platform support can provide the HART to domain instance assignment using
platform specific callback.

The HART to domain instance assignment can be parsed from the device tree
using optional DT property **opensbi,domain** in each CPU DT node. The
value of DT property **opensbi,domain** is the DT phandle of the domain
instance DT node. If **opensbi,domain** DT property is not specified then
using optional DT property **opensbi-domain** in each CPU DT node. The
value of DT property **opensbi-domain** is the DT phandle of the domain
instance DT node. If **opensbi-domain** DT property is not specified then
corresponding HART is assigned to **the ROOT domain**.

### Domain Configuration Only Accessible to OpenSBI
Expand All @@ -222,6 +237,7 @@ be done:
chosen {
opensbi-domains {
compatible = "opensbi,domain,config";
system-suspend-test;

tmem: tmem {
compatible = "opensbi,domain,memregion";
Expand All @@ -246,18 +262,19 @@ be done:
tdomain: trusted-domain {
compatible = "opensbi,domain,instance";
possible-harts = <&cpu0>;
regions = <&tmem 0x7>, <&tuart 0x7>;
regions = <&tmem 0x3f>, <&tuart 0x3f>;
boot-hart = <&cpu0>;
next-arg1 = <0x0 0x0>;
next-addr = <0x0 0x80100000>;
next-mode = <0x0>;
system-reset-allowed;
system-suspend-allowed;
};

udomain: untrusted-domain {
compatible = "opensbi,domain,instance";
possible-harts = <&cpu1 &cpu2 &cpu3 &cpu4>;
regions = <&tmem 0x0>, <&tuart 0x0>, <&allmem 0x7>;
regions = <&tmem 0x0>, <&tuart 0x0>, <&allmem 0x3f>;
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion docs/firmware/fw.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Firmware Configuration and Compilation
All firmware types support the following common compile time configuration
parameters:

* **FW_TEXT_ADDR** - Defines the execution address of the OpenSBI firmware.
* **FW_TEXT_START** - Defines the execution address of the OpenSBI firmware.
This configuration parameter is mandatory.
* **FW_FDT_PATH** - Path to an external flattened device tree binary file to
be embedded in the *.rodata* section of the final firmware. If this option
Expand Down
20 changes: 10 additions & 10 deletions docs/firmware/fw_jump.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ follows:

When using the default *FW_JUMP_FDT_ADDR* with *PLATFORM=generic*, you must
ensure *FW_JUMP_FDT_ADDR* is set high enough to avoid overwriting the kernel.
You can use the following method.
You can use the following method (e.g., using bash or zsh):

```
${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
{addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
| (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\
increase FW_JUMP_FDT_ADDR

${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
| (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\
increase FW_JUMP_FDT_ADDR
${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '
/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' |
(( `tail -1` > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR

${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n '
/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' |
(( `tail -1` > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
```

*FW_JUMP* Example
Expand Down
2 changes: 1 addition & 1 deletion docs/platform/generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ RISC-V Platforms Using Generic Platform
* **Spike** (*[spike.md]*)
* **T-HEAD C9xx series Processors** (*[thead-c9xx.md]*)

[andes-ae350.md]: andse-ae350.md
[andes-ae350.md]: andes-ae350.md
[qemu_virt.md]: qemu_virt.md
[renesas-rzfive.md]: renesas-rzfive.md
[shakti_cclass.md]: shakti_cclass.md
Expand Down
Binary file added docs/riscv_opensbi_logo_final_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/riscv_opensbi_logo_final_grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 31 additions & 12 deletions firmware/fw_base.S
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,12 @@ _try_lottery:
lla t0, __rel_dyn_start
lla t1, __rel_dyn_end
beq t0, t1, _relocate_done
j 5f
2:
REG_L t5, -(REGBYTES*2)(t0) /* t5 <-- relocation info:type */
REG_L t5, REGBYTES(t0) /* t5 <-- relocation info:type */
li t3, R_RISCV_RELATIVE /* reloc type R_RISCV_RELATIVE */
bne t5, t3, 3f
REG_L t3, -(REGBYTES*3)(t0)
REG_L t5, -(REGBYTES)(t0) /* t5 <-- addend */
REG_L t3, 0(t0)
REG_L t5, (REGBYTES * 2)(t0) /* t5 <-- addend */
add t5, t5, t2
add t3, t3, t2
REG_S t5, 0(t3) /* store runtime address to the GOT entry */
Expand All @@ -95,27 +94,26 @@ _try_lottery:
lla t4, __dyn_sym_start

4:
REG_L t5, -(REGBYTES*2)(t0) /* t5 <-- relocation info:type */
srli t6, t5, SYM_INDEX /* t6 <--- sym table index */
andi t5, t5, 0xFF /* t5 <--- relocation type */
li t3, RELOC_TYPE
bne t5, t3, 5f

/* address R_RISCV_64 or R_RISCV_32 cases*/
REG_L t3, -(REGBYTES*3)(t0)
REG_L t3, 0(t0)
li t5, SYM_SIZE
mul t6, t6, t5
add s5, t4, t6
REG_L t6, -(REGBYTES)(t0) /* t0 <-- addend */
REG_L t6, (REGBYTES * 2)(t0) /* t0 <-- addend */
REG_L t5, REGBYTES(s5)
add t5, t5, t6
add t5, t5, t2 /* t5 <-- location to fix up in RAM */
add t3, t3, t2 /* t3 <-- location to fix up in RAM */
REG_S t5, 0(t3) /* store runtime address to the variable */

5:
addi t0, t0, (REGBYTES*3)
ble t0, t1, 2b
addi t0, t0, (REGBYTES * 3)
blt t0, t1, 2b
j _relocate_done
_wait_relocate_copy_done:
j _wait_for_boot_hart
Expand Down Expand Up @@ -257,20 +255,28 @@ _bss_zero:
/* Preload HART details
* s7 -> HART Count
* s8 -> HART Stack Size
* s9 -> Heap Size
* s10 -> Heap Offset
*/
lla a4, platform
#if __riscv_xlen > 32
lwu s7, SBI_PLATFORM_HART_COUNT_OFFSET(a4)
lwu s8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4)
lwu s9, SBI_PLATFORM_HEAP_SIZE_OFFSET(a4)
#else
lw s7, SBI_PLATFORM_HART_COUNT_OFFSET(a4)
lw s8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4)
lw s9, SBI_PLATFORM_HEAP_SIZE_OFFSET(a4)
#endif

/* Setup scratch space for all the HARTs*/
lla tp, _fw_end
mul a5, s7, s8
add tp, tp, a5
/* Setup heap base address */
lla s10, _fw_start
sub s10, tp, s10
add tp, tp, s9
/* Keep a copy of tp */
add t3, tp, zero
/* Counter */
Expand All @@ -285,8 +291,11 @@ _scratch_init:
* t3 -> the firmware end address
* s7 -> HART count
* s8 -> HART stack size
* s9 -> Heap Size
* s10 -> Heap Offset
*/
add tp, t3, zero
sub tp, tp, s9
mul a5, s8, t1
sub tp, tp, a5
li a5, SBI_SCRATCH_SIZE
Expand All @@ -298,6 +307,16 @@ _scratch_init:
sub a5, t3, a4
REG_S a4, SBI_SCRATCH_FW_START_OFFSET(tp)
REG_S a5, SBI_SCRATCH_FW_SIZE_OFFSET(tp)

/* Store R/W section's offset in scratch space */
lla a4, __fw_rw_offset
REG_L a5, 0(a4)
REG_S a5, SBI_SCRATCH_FW_RW_OFFSET(tp)

/* Store fw_heap_offset and fw_heap_size in scratch space */
REG_S s10, SBI_SCRATCH_FW_HEAP_OFFSET(tp)
REG_S s9, SBI_SCRATCH_FW_HEAP_SIZE_OFFSET(tp)

/* Store next arg1 in scratch space */
MOV_3R s0, a0, s1, a1, s2, a2
call fw_next_arg1
Expand Down Expand Up @@ -422,9 +441,8 @@ _start_warm:
li ra, 0
call _reset_regs

/* Disable and clear all interrupts */
/* Disable all interrupts */
csrw CSR_MIE, zero
csrw CSR_MIP, zero

/* Find HART count and HART stack size */
lla a4, platform
Expand Down Expand Up @@ -453,7 +471,6 @@ _start_warm:
add s9, s9, 4
add a4, a4, 1
blt a4, s7, 1b
li a4, -1
2: add s6, a4, zero
3: bge s6, s7, _start_hang

Expand Down Expand Up @@ -519,6 +536,8 @@ _link_start:
RISCV_PTR FW_TEXT_START
_link_end:
RISCV_PTR _fw_reloc_end
__fw_rw_offset:
RISCV_PTR _fw_rw_start - _fw_start

.section .entry, "ax", %progbits
.align 3
Expand Down
Loading