Commit graph

330 commits

Author SHA1 Message Date
Curtis Millar
6fbee8ba05 Invert address mapping diagrams
This makes all daigrams have their first address at the end of the
diagram and their last address at the start of the diagram.

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
2020-05-22 12:26:13 +10:00
Curtis Millar
96456c6ae7 trivial: fix header files
Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
2020-05-22 12:26:13 +10:00
Curtis Millar
fba7c896b0 Consolidate kernel virtual memory regions
Each architecture now only needs to describe the bounds of the three
memory regions: the 1:1 mapped physical memory region, the kernel ELF
region (which may or may not overlap the physical memory region) and the
device / kernel page table region.

The physical base address of the 1:1 mapped physcial memory region and
the kernel ELF region must also be specified.

The top of user addressable memory (where in the same virtual address
space as the kernel) is defined by USER_TOP.

The physic memory virtual mapping is described by PPTR_BASE and
PPTR_TOP. The base physical memory address is PADDR_BASE and is the
physical address used to map PPTR_BASE.

Don't use kernelBase when referring to the base of the 1:1 mapped
physical memory window.

The kernel ELF virtual address region is described by KERNEL_ELF_BASE
and extends until the virtual address of the symbol `ki_end` which is
created by the linker. KERNEL_ELF_PADDR_BASE is the base address of
the physical memory region used to map the kernel and is the address to
which KERNEL_ELF_BASE maps.

KERNEL_ELF_BASE and KERNEL_ELF_PADDR_BASE do not need to be aligned to a
page size boundary as they are approriately truncated during boot by the
`map_kernel_window` function.

KDEV_BASE describes the base virtual address of the kernel device region
and the region is assumed to extend to the end of virtual memory.

Note: The offset between PPTR_BASE and PADDR_BASE is used to translate
the virtual address of all untyped objects to physical addresses. This
includes device untyped objects or frame objects where the virtual
address does not fall within the 1:1 mapped physical memory region.

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
2020-05-22 12:26:13 +10:00
Qian Ge
512a0200de replacing all ifndef with pargma once
All the kernel header files now use pargma once rather than the ifndef,
as the pre-processed C files do not change while header files
are protected with pargma once. This will also solve any naming issues
caused by ifndef.
2020-03-23 11:04:46 +11:00
Gerwin Klein
79da079239 Convert license tags to SPDX identifiers
This commit also converts our own copyright headers to directly use
SPDX, but leaves all other copyright header intact, only adding the
SPDX ident. As far as possible this commit also merges multiple
Data61 copyright statements/headers into one for consistency.
2020-03-09 13:21:49 +08:00
Kent McLeod
2cd80a8c7e Document internal machine/interrupt.h interface
Every platform has to implement a standard set of interrupt interfaces
that the kernel uses to interract with a machine's interrupt controller.
Providing a single header file for each of these functions provides a
single location to document their behavior.
2020-02-05 13:56:48 +11:00
Kent McLeod
60ffdb1f0a trivial: Fix x86 KERNEL_TIMER_IRQ definition
This was using the hardware irq number instead of the irq number seL4
uses. This change affects MCS preemption point handling.
2019-11-26 08:49:46 +11:00
Victor Phan
66bc2b1724 rename KDEV_PPTR/PPTR_KDEV to KDEV_BASE
This is the virtual address for the start of the kernel device mapping
region.
2019-11-21 15:53:11 +11:00
Simon Shields
b5c56244f1 Create device untypeds at boot for all arches
Currently on x86 device untypeds are generated by passing the entire
address space minus any parts that are reserved by the kernel or that
are "real" memory (e.g. kernel image, physical RAM).

On ARM and RISC-V, device untypeds were generated at compile-time from
a device tree. This patch moves ARM and RISC-V to use the same approach
as x86, and moves the code from x86 into a common location that's
shared between the three architectures.

Co-Authored-By: Anna Lyons <anna@gh.st>
2019-11-12 16:20:07 +11:00
Kent McLeod
ef8b01390d KernelIRQReporting: Change reserved IRQ reporting
Reserved IRQ reporting would print on every received reserved IRQ. This
feature is supposed to report spurious interrupts, yet most cases
reserved IRQs are not spurious. We change the printing to only print if
the reserved IRQ was unhandled. The intention is to allow more app
configurations to leave this feature enabled in development builds.
2019-09-19 11:33:03 +10:00
Anna Lyons
86e50d0703 mcs: Avoid missing a timer tick
Preemption can be via the timer interrupt. In this case we need to
update the timestamp so we can reprogram the timer for the next timeout
and guarantee it is in the future, otherwise we will end up setting a
timeout in the past.
2019-08-22 11:22:41 +10:00
Anna Lyons
acfc3c5257 mcs: tickless driver for x86
Add a tickless timer driver for x86. The driver defaults to using
TSC_DEADLINE mode, but falls back to the apic if that feature is not
available.
2019-08-22 11:22:34 +10:00
Siwei Zhuang
8b4ed9941a RISCV: Add Hifive unleashed platform
This change adds support for Hifive unleashed board. It also removes the
outdated hifive suport from the spike platform.
2019-06-26 15:11:47 +10:00
Siwei Zhuang
375a98c8b3 CMake: Generate device headers from DTS for spike
The DTS compilation was arm platforms only. Moving it to the top level
config file, making it available to RISCV platforms. The generated files
are almost identical with minor differences. A new argument(--arch) is
added to the hardware_gen.py for the differences.
2019-06-26 11:38:08 +10:00
Anna Lyons
8586b7f2b8 boot: refactor allocation of rootserver objects
Prior to this change, the boot process would dynamically allocate
memory for root server objects based on the order of initialisation.
Allocation was a best-fit algorithm.

This change preallocates all memory for root server objects to an
aligned untyped just after the user image. By allocating the objects in
order of size, allocation is greatly simplified and the ability to
reproduce the allocation offline based on the kernel and user image
sizes is increased.
2019-06-20 14:11:50 +10:00
Kent McLeod
4ce8f0a9f5 Add RISC-V IRQ invocations
We add support for seL4_IRQControlGet and seL4_IRQControlGetTrigger. If
a platform doesn't support setting the trigger, then
seL4_IRQControlGetTrigger will return an error. If the platform doesn't
have a PLIC driver, then it won't have any IRQs that can be requested.

Also authored by: Siwei Zhuang <siwei.zhuang@data61.csiro.au>
2019-06-18 10:22:47 +10:00
Kent McLeod
9a552d84b6 RISC-V: Refactor IRQ handling to use PLIC
Previously we only handled IRQs generated by the BBL running in machine
mode via changes to supervisor interrupt pending (SIP) bits. Now that we
need to support shared global interrupts through the PLIC we need to
modify the way interrupts are processed.

We additionally remove many DONT_TRANSLATE annotations on functions that
the CParser is able to parse.

Also authored by: Siwei Zhuang <siwei.zhuang@data61.csiro.au>
2019-06-18 10:22:47 +10:00
Kent McLeod
c73d5178d9 RISC-V: Add PLIC interface and HiFive driver
We assume the PLIC is currently the only global interrupt controller
that RISC-V platforms are going to use. Each platform may have a
different programmers model for interracting with the hardware
controller. We provide a common interface for PLIC drivers to implement
that the kernel will use to manage IRQs.

Also authored by: Siwei Zhuang <siwei.zhuang@data61.csiro.au>
2019-06-18 10:22:47 +10:00
Siwei Zhuang
4b24006678 RISC-V: Add kernel device functionalty
- Create device untypeds for platform devices that can be passed to user
space.
- Create kernel device mapping for devices required by the kernel.
Note that the current kernel device mapping is simply a 1GiB of page
physical memory as that contains all devices for all RISC-V platforms
that are currently supported.
2019-06-18 10:22:43 +10:00
Kent McLeod
2865d6b61b spike: Refactor into clearer subplatforms
For now we keep the RISC-V platforms under the spike kernel platform
name. Splitting the different platform definitions into different header
files will help maintainability as we add different device layouts and
kernel device drivers.
2019-06-17 20:31:33 +10:00
Kent McLeod
8dc90b559f RISC-V: Correct PPTR_USER_TOP definition
PPTR_USER_TOP represents the first inaccessible user address which is
usually ((2^(38-12))-1)*0x1000 on SV39. This corresponds to the first
address of the last page in the lower half of the top level page table.
2019-06-17 20:31:33 +10:00
Kent McLeod
4957c5e8a5 RISC-V: Comment 64-bit SV39 kernel address space
Add a comment and diagram explaining the current structure of the SV39
kernel address space. The top half of the virtual address space is
reserved for the kernel and consists of the Kernel window of all
accessible physical memory, the kernel ELF mapping and the Kernel device
mapping region.
2019-06-17 20:31:33 +10:00
Kent McLeod
10655ce634 RISC-V: Add PPTR_KDEV for kernel device mappings
There is a 1GiB region reserved at the top of the Kernel virtual address
space to map devices used by the kernel into. The start of this range is
referred to by PPTR_KDEV. This also represents the end of the Kernel ELF
window mapping.
2019-06-17 20:31:33 +10:00
Siwei Zhuang
6a16d532e6 RISCV: Introduce KERNEL_ELF_BASE for verification
Verification requires the KERNEL_BASE to be 1GB aligned at the start of
the kernel elf window. It was also the location where the kernel elf was
mapped. As we have to include SBI memory in the kernel elf window,
the KERNEL_ELF_BASE is introduced for the real kernel elf mapping.
Keeping KERNEL_BASE unchanged.
2019-06-17 20:31:33 +10:00
Anna Lyons
9dcb470631 arm: remove plat/machine/timer.h
plat/machine/timer.h is unused on arm, so remove it and fix up the
includes.
2019-06-17 10:44:36 +10:00
Anna Lyons
e3a83035f8 boot: consolidate init_freemem
init_freemem sets up available regions of memory for the hardware that
seL4 is booting on. Previously this function was duplicated across
architectures, with minor duplication.

This change provides a top-level init_freemem suitable for all
architectures.

- arm/riscv: change get_avail_p_reg to return whole p_reg array
- update all architectures to use new init_freemem.
- wrap init_freemem calls with arch_init_freemem for each arch, where
arch_init_freemem sets up the available and reserved regions of memory
which are passed to init_freemem.
2019-05-15 14:03:40 +10:00
Anna Lyons
67f2de94a1 trivial: riscv - remove unused function prototype 2019-05-15 14:03:40 +10:00
Anna Lyons
41780b0602 x64: add missing constant PPTR_TOP
PPTR_TOP represents the top that can be made available to the
user as untyped.
2019-05-15 14:03:40 +10:00
Anna Lyons
a6b4cf739d boot: allocate irq cnode statically
The memory used for the irq cnode is never available to the user. As a
result this memory can be allocated statically, simplifying the
bootcode.

- remove allocation of irq cnode
- add static init
- generate irq cnode size from cmake for arm
- add static constants for riscv, x86 as there is no variability at the
moment.
2019-05-03 16:18:39 +10:00
Anna Lyons
cb9499069d zynqmp: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
66df769f8c zynq7000: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
26a3b55521 omap3: use declare_default_headers
- remove unused header files replaced by declare_default_headers
- move timer.h to drivers/timer/omap3430.h
- move interrupt.h to drivers/irq/omap3.h
2019-04-12 14:25:58 +10:00
Anna Lyons
df4d19ae5f imx7: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
e4f567e19e imx6: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
7bf513b75e imx31: use declare_default_headers
- remove unused header files replaced by declare_default_headers
- move interrupt.h -> drivers/irq/imx31.h
- move hardware.bf -> drivers/timer/imx31-epit.bf
- move timer.h -> drivers/timer/imx31-epit.h
- move definitions from hardware.h to plat/imx31/machine/hardware.c
2019-04-12 14:25:58 +10:00
Anna Lyons
209563d4ca hikey: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
e1a36c2601 exynos: use declare_default_headers
- remove unused header files replaced by declare_default_headers
- move timer.h to drivers/timer/exynos5422-mct.h
- move mct.h to drivers/timer/mct.h
2019-04-12 14:25:58 +10:00
Anna Lyons
474a7da5c0 bcm2837: use declare_default_headers
- remove unused header files replaced by declare_default_headers
- move machine.h to drivers/irq/bcm2836-armctrl-ic.h
2019-04-12 14:25:58 +10:00
Anna Lyons
2d77062df4 apq8064: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
a69c3f0f9c am335x: use declare_default_headers
- move timer.h to include/drivers/timer/am335x.h
- move interrupt.h to include/drivers/irq/am335x.h
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Anna Lyons
0a4ffd0a9a allwinnerA20: use declare_default_headers
- move timer.h to include/drivers/timer/allwinner.h
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Kent McLeod
78c8ac9fae tx2: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Kent McLeod
e86190839e tx1: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Kent McLeod
04aabf92ce tk1: use declare_default_headers
- remove unused header files replaced by declare_default_headers
2019-04-12 14:25:58 +10:00
Kent McLeod
d703eab23d cmake: add declare_default_headers
This allows for arm headers to be generated for an arm platform
in include/plat/default that specifies the following:

- maxIRQ
- TIMER_CLOCK_HZ
- the timer header to use
- the interrupt controller header to use
2019-04-12 14:25:53 +10:00
Anna Lyons
0cdd0514cf ia32: adjustments to pass c-parser
This commit updates the ia32 build to pass the c-parser.

- replaces ++i with i++
- use void in functions with no parameters
- add a missing typecast
- remove a void cast of an unused variable

It does not provide any verification guarantees about ia32 code.
2019-04-05 15:39:20 +11:00
Siwei Zhuang
897aaf5b13 RISCV: Change 64 bit kernel window mapping to avoid PMP exception.
The SBI memory was mapped outside the kernel window. This would trigger
an instruction access fault on some hardware, when the bootloader has set
up PMP to protect the SBI memory. Instead of protecting a particular memory
region, the PMP locks the entire page table entry that covers the region.

The PADDR_LOAD and kernel base are adjusted to have the SBI memory
included in the kernel window. So that the SBI memory can be mapped as
part of the kernel image to a separate page table entry. This also
avoids the kernel to allocate untyped memory from the SBI region.
2019-04-03 15:03:25 +11:00
Kent McLeod
f6e5e218dc Remove symlinked libsel4 files from include dir
These files can be included normally using libsel4 include paths. This
removes situations where the same file is available under different
include paths due to symlinking into different directory structures.
2019-03-21 12:44:57 +11:00
Kofi Doku Atuah
2352855213 pc99: Use kernelBase in linker script 2019-03-21 12:31:25 +11:00
Edward Pierzchalski
1ca215cfea RISCV: make sure i has a uniform type.
The C parser produces abbreviations for local variables that depend on
the variable type and the order they appear in the source.

The signature for `get_avail_p_reg` on RISCV has a different type for
`i` than every other function, which causes issues when `hardware.h` is
included early in `kernel_all.c_pp`. Changing the type to `word_t`
avoids these issues.
2019-03-20 17:37:41 +11:00