Commit graph

3952 commits

Author SHA1 Message Date
Axel Heider
f507075db8 boot: remove redundancy in assignments
- Make assignments an atom, the compiler can handle the details.
- Define variables when they are needed.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-28 09:20:55 +10:00
Axel Heider
ee7a52d927 move type checks to mode/types.h
Moving the type checks avoid the need for conditional compilation. This
also allows simplifying some include file dependencies.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-28 09:20:01 +10:00
Axel Heider
77fb21aa90 python: add __str__() for Region
- Provide a nicer string for debugging purposes.
- improve comments about the purpose of __repr__() and __str__()

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-27 23:09:24 +10:00
Axel Heider
fcb46e119d boot: improve error message
Print the value for MAX_NUM_FREEMEM_REG.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-27 23:09:09 +10:00
Axel Heider
30d4fe1937 remove unnecessary brackets
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-27 23:09:09 +10:00
Axel Heider
5a7ab341b7 fix typo in comment
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-27 23:09:09 +10:00
Axel Heider
98f28676b2 trivial: remove superfluous empty lines
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-27 23:09:09 +10:00
Axel Heider
7d7a404bff python: raise exceptions on errors
- A region can't be created from an invalid range
- A region might be too small to support the change. There is no trivial
  way to fix this.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-27 20:49:56 +10:00
Matthew Brecknell
577ca01803 boot: handle failure to find root server memory
Previously, the case where there was no memory region large enough for
the root server objects was unhandled. The loop termination condition
(i>=0) was trivially true for all values of the loop variable. This
commit fixes the issue by making the loop variable signed, and adding a
failure case.

It also:
- adds a check for underflow in the calculation of the address to begin
  allocating root server objects,
- removes two redundant checks that were guaranteed to be true, and
- adds some clarifying comments.

Co-authored-by: Axel Heider <axelheider@gmx.de>
Signed-off-by: Matthew Brecknell <matthew@brecknell.net>
2021-09-27 09:47:44 +10:00
Axel Heider
f908fd8517 risc-v: merge getNewActiveIRQ(), getActiveIRQ()
Simplify the program flow and inline comments.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
59e8aa73a8 risc-v: call plic_init_hart() unconditionally
The function plic_init_hart() is part of the internal kernel API, so
every SOC's PLIC implementation has to provide it, even if it is
empty.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
b21faf8a9c risc-v: clenaup U54/U74 PLIC handling code
- Use SMP_TERNARY() macro.
- Rename get_hart_id() to plic_get_current_hart_id(), as this is just a
  helper function for the other PLIC code in this file.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
14314983a6 risc-v: clarify PLIC is for SiFive U54/U74
RISC-V defines the concept of a PLIC, but leaves the details open. The
driver is for the PLIC of the SiFive U54/U74 SOC, which is used on
the HiFive Unleashed/Unmatched and Polarfire board.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
4081010f5b risc-v: use dummy PLIC driver on ariane/rocketchip
Both Ariane and Rocketchip are experimental platforms that support
accessing peripherals, but the status of support for external interrupts
via a PLIC is unclear and my differ depending on the version that is
synthesized. Using the dummy PLIC driver seems the better option for now
to avoid confusion or even crashes.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
1400a8a8a2 risc-v: improve PLIC driver API and documentation
- describe PLIC behavior and corner cases.
- provide a common header file for the API.
- add a dummy PLIC driver for spike.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
624786b95f risc-v: move SIE access wrappers to generic code
- Move CSR SIE access wrappers to generic code.
- Move CSR SIE/SIP bit constants to header file.
- Rename CSR SIE/SIP bit constants to use the names from the RISC-V
  specification.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
046abdc9f4 risc-v: drop constant INTERRUPT_CORE_TIMER
INTERRUPT_CORE_TIMER is just an alias for KERNEL_TIMER_IRQ. There is
no need for this indirection, KERNEL_TIMER_IRQ can be used directly.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
2450a1f910 risc-v: initialize active_irq during PLIC init
- Initialize all elements active_irq during PLIC init and done't assume
  implicitly that irqInvalid is zero.
- make active_irq hold elements of the type irq_t and not uint32_t.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-26 11:31:51 +10:00
Axel Heider
c2bf323d0a boot/risc-v: remove unused MODE_RESERVED
MODE_RESERVED is unused on RISC-V, so remove it from the code base. It
can be brought back when needed based on the state of the ARM
implementation, which has been clean up to remove global dependencies.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-26 09:50:53 +10:00
Axel Heider
699a4cd803 boot: define NUM_RESERVED_REGIONS
- define NUM_RESERVED_REGIONS to align ARM and RSIC-V code
- add runtime checks to catch errors. These checks can't be static or
  use assert(), as the parameters are passed by a kernel loader. They
  must be considered dynamic and can potentially change any time out
  of the kernel's control.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-26 09:50:53 +10:00
Axel Heider
415fb2090c boot/arm: add missing includes
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-26 09:50:53 +10:00
Axel Heider
d76f9f93a6 boot: improve comments
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-26 09:50:53 +10:00
Qiao Yongchang
e1fce5122e Change QEMU version check to FATAL_ERROR
Low version QEMU dump dts not have intc location information
and make subsequent generate dtb failed.

Error information:
Reference to non-existent node or label "/intc@8000000"

So when the QEMU version does not meet the requirements there
should be FATAL_ERROR to notice user early and immediately exit

Signed-off-by: Qiao Yongchang <qiaoyongchang@gmail.com>
2021-09-24 11:31:09 +10:00
Axel Heider
b384dc02af add missing includes
Using LIBSEL4_BIT() requires including sel4/macros.h.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-22 12:15:37 +10:00
Axel Heider
d6b63832d1 remove goto in printf_core() and return directly
There is no need to keep an option for potentially debugging the error.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-21 10:25:04 +10:00
laokz
2c64a01c26 trivial: fix warning of multiboot_mmap_length
In x86/boot_sys.c, we output a warning when `multiboot_mmap_length`
exceed limit. So we should correct its value after the `printf`.

close: #177

Signed-off-by: laokz <laokz@foxmail.com>
2021-09-20 17:22:51 +10:00
Axel Heider
91bfdf4b1c boot: simplify create_untypeds_for_region()
Simplify code and add comments.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-20 16:49:11 +10:00
Axel Heider
5a47047233 boot: change order to improve debug output
Print the available physical memory regions before printing the reserved
virtual memory regions, because as this order is more intuitive. For the
checks the order does not make any difference. Factor out the checks
into separate function to improve code readability.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-14 21:09:10 +10:00
Ben Leslie
94269ed5be Remove unused PYTHON tool definition
python2 is not used in the kernel build anymore so the tool
definition is unnecessary.

python2 is also end-of-line so there is no reason to think
we would ever depend on it again.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-09-14 16:09:33 +10:00
Ben Leslie
e11ef82663 Ensure execute_process is error checked
Check the return value from execute_process calls and fail
with an appropriate message.

This makes debugging of cmake failures much easier.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-09-14 16:03:51 +10:00
Axel Heider
502dec1cd3 trivial: formatting, improve comments
Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-14 08:41:09 +10:00
Axel Heider
751198038a boot/risc-v: grab BKL on primary core for SMP
Ensure the primary core grabs the BKL once the generic kernel init is
done and the secondary cores are running. Improve the comments to
clarify that this is done to play safe.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-13 15:53:09 +10:00
Indan Zupancic
f3addaa0fb Trivial: Remove now incorrect comment
Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-10 20:48:04 +10:00
Gerwin Klein
863ee83ca8 github: drop python2 tests
Since the build system defaults to python3 now, these have not worked
as advertised in a while now (they have test py3 twice).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-09 08:43:56 +10:00
Indan Zupancic
e18e32e28e Allow Lazy SC Rebind
Before, binding a scheduling context to a TCB was not allowed if the
SC was bound to a notification object. Also, binding a SC to a NF was
not allowed if that scheduling context was already bound to a TCB.

Without these restriction it is much easier to move scheduling contexts
around: In effect having a SC bound on both the TCB and a NF acts as if
the thread is running on a donated SC which will be returned when the
tasks calls Recv/Wait, which is done by maybeReturnSchedContext().

This greatly simplifies startup and time-out exception handling for
passive threads having a NF with a SC bound to it.

Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-08 07:56:47 +10:00
Indan Zupancic
fbb11221cf Document Lazy SC Rebind
Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-08 07:56:47 +10:00
Indan Zupancic
0d2fac8b0a Fix spelling mistakes in threads.tex
Signed-off-by: Indan Zupancic <Indan.Zupancic@mep-info.com>
2021-09-08 07:56:47 +10:00
Bertrand Virfollet
b32b9568b2 tools: merge adjacent memory regions
Merge memory regions before checking for reserved areas

Co-authored-by: Gerwin Klein <gerwin.klein@proofcraft.systems>

Signed-off-by: Bertrand Virfollet <bvirfollet@silicom.fr>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-08 07:53:53 +10:00
Axel Heider
975f86b742 boot: unify insert_region() behavior
Unify ARM and RISC-V behavior for insert_region(). Print a message and
return an error in release builds, so the caller must decide what to do.
Debug build trigger an assert(),  because this is usually something that
should not happen.

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-07 20:10:14 +10:00
Axel Heider
6b8cbc96d1 risc-v: add comment about SBI constants
Explan the origin of the SBI constants.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-07 20:09:26 +10:00
Axel Heider
1bdf8d5a1b boot: improve user image location check
- On ARM systems, the UART must be set up first before any error
  messages are visible. Move the user image location check after
  the platform init that brings up the UART.
- Add the user image location check on RISC-V systems also.
- Make the error message more verbose to clearly show the problem.

Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-07 18:56:44 +10:00
Axel Heider
f8054d41dc risc-v: fix signature for Arch_setTLSRegister()
Signed-off-by: Axel Heider <axel.heider@hensoldt-cyber.de>
2021-09-07 15:56:31 +10:00
Gerwin Klein
646deeb4d4 trivial: update comment
The whole reason we have this comparison is that the user input has
not been checked yet when we get here.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-06 16:18:23 +10:00
Chris Guikema
805a031d55 libsel4: add EPT attributes
In x86, EPT and normal mappings have different cache attributes. This
commit adds an enum for the EPT attributes.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2021-09-06 16:18:23 +10:00
Ben Leslie
7f6f0008a9 Add additional cmake checks
Verify that KernelArch and KernelWordSize have been correctly
set after including the platform cmake files.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-09-06 13:14:20 +10:00
Axel Heider
2f18705be0 boot: use helper variable to simplify code
- Improve comments about macros
- use helper variable to simplify code

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-06 09:22:04 +10:00
Axel Heider
543a09f435 trivial: style
Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-06 09:22:04 +10:00
Axel Heider
dbda7046b9 Clarify assumptions about boot info frame size
- Improve comments
- allocate BI_FRAME_SIZE_BITS and not seL4_PageBits

Signed-off-by: Axel Heider <axelheider@gmx.de>
2021-09-06 09:22:04 +10:00
Kent McLeod
6bc0b06338 CMake: Add support for cmake install <dir> cmd
When using CMake to only build the kernel, an install target is now
provided to copy important outputs into an installation directory.

Currently only the following files are installed:
- ./bin/kernel.elf: Location of kernel.elf binary
- ./libsel4/include: The include root for libsel4
- ./libsel4/src: The c source files for the libsel4 library

To build and install this project to an installation directory should
now only require the following from a clean build directory:
```
export CMAKE_GENERATOR=Ninja
cmake -DCMAKE_INSTALL_PREFIX=<path-to-install> -DOption=Val <src-dir>;
cmake --build .;
cmake --install .;
```

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-06 08:23:17 +10:00
Kent McLeod
fe96ceba17 gcc.cmake: Remove unused CMAKE_STAGING_PREFIX var
This path variable overrides the destination that installation files are
copied to. It was set according to an example CMake toolchain file.
Instead it would be better to allow it to be optionally set by some
caller.

Signed-off-by: Kent McLeod <kent@kry10.com>
2021-09-06 08:23:17 +10:00