Skip to content

Commit

Permalink
Upstream (#1)
Browse files Browse the repository at this point in the history
* cmake_tool: Add Rocketchip platform_strings

This commit allows sel4test to be compiled with
-DPLATFORM=rocketchip-base and DPLATFORM=rocketchip-zcu102.

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>

* cmake_tool: Build binaries for rocket chip plats

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>

* github: bump GitHub action versions

Update to current node16 versions. The old node12 actions are
deprecated and will stop working.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>

* CI: simulation and HW build with LLVM on RISCV

Signed-off-by: Axel Heider <axelheider@gmx.de>

* CI: bring back compiler to matrix

This was deleted by accident in commit 75fc800

Signed-off-by: Axel Heider <axelheider@gmx.de>

* lld: Enable building C projects without crt files

crt[begin|end].o files are used for C++ projects. While they usually
exist in GCC, they may or may not exist in LLVM builds that don't
rely on GCC toolchain, and typically require a separate (optional)
compiler-rt/cxx library to build.

This commit allows building projects without crt[begin|end].o files
if they do not exist.

Signed-off-by: Hesham Almatary <hesham.almatary@cl.cam.ac.uk>

* github: bump actions to node20

GitHub has started issuing warnings for node16 actions.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>

* elfloader: Add driver callback for non-boot core

This is to support core-specific driver init handling.

Signed-off-by: Kent McLeod <kent@kry10.com>

* elfloader: Add generic-timer driver

This driver just sets CNTVOFF_El2 to 0 if possible.
This can only be done if the elfloader is in hyp-mode, otherwise nothing
happens.

Signed-off-by: Kent McLeod <kent@kry10.com>

* elfloader: Replace calls to reset_cntvoff

These calls can now be implemented via binding the /timer driver in the
elfloader's device tree configuration (located in the kernel's platform
directory).

Signed-off-by: Kent McLeod <kent@kry10.com>

* elfloader: Only include driver source on arm

RISC-V platforms don't use any extension drivers currently so it's not
useful to compile and link them in when not building for arm.

Signed-off-by: Kent McLeod <kent@kry10.com>

* elfloader: Remove non_boot_init() interface

This was previously added to handle per-core initialization of the
generic timer. Now that a generic driver mechanism is used to perform
this initialization the old interface is redundant.

Signed-off-by: Kent McLeod <kent@kry10.com>

* elfloader: Check return code of device init

Device initialization returns early if an error is encountered. Handle
this error by printing an Error message and aborting the booting
process.

Signed-off-by: Kent McLeod <kent@kry10.com>

* CI: the seL4/machine_queue repo is public now

Signed-off-by: Axel Heider <axelheider@gmx.de>

* CI: cancel older concurrent PR runs

- Remove the space in the workflow name to ensure there are no side
  effects when using it as an identifier.
- Align workflow naming
- Act on PRs only, not on upstreaming.

Signed-off-by: Axel Heider <axelheider@gmx.de>

* misc: remove deprecated astyle option

Release 3.0 of astyle replaced this option with
'max-continuation-indent'. The replaced option is already in
the astylerc so we just need to remove the option here.

Further information can be found in the release notes:
https://astyle.sourceforge.net/news.html

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>

* Add support for Pine64 Star64

Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>

* cmake: Support binary build for imx8mp-evk

The imx8mp-evk as like with the other imx8m-* platforms require the
resulting image to just be a binary and not an ELF or other special
formats.

Signed-off-by: Damon Lee <damon@kry10.com>

* misc: check that astyle exists

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>

* Shift 32-bit image start address on imx8mm

The port of the hardware debug API to aarch64 has increased the size
of some debug images to the point that the address range the image is
loaded at overlaps with the address range the elf-loader relocates to
and expects to run at. This was solved on aarch64 by shifting the uboot
load address to 0x42000000. We do not differentiate between aarch32 and
aarch64 images in uboot, and the aarch32 elfloader is not relocated, so
the configuration in this commit must be changed to have the aarch32
elfloader expect to be executed from the new load address.

Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>

* cmake: use quotes

Avoid odd error messages in case TRIPLE is empty.

Signed-off-by: Axel Heider <axel.heider@codasip.com>

* trivial: style fix for autopep8 version bump

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>

* elfloader: initialise stack allocated struct

Only results in a compilation error on newer GCC versions.

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>

* cmake_tool: add ELF loader setting for zynqmq 32

Enable the ELF loader for 32-bit images on zynqmq platforms.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>

---------

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
Signed-off-by: Axel Heider <axelheider@gmx.de>
Signed-off-by: Hesham Almatary <hesham.almatary@cl.cam.ac.uk>
Signed-off-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Damon Lee <damon@kry10.com>
Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
Signed-off-by: Axel Heider <axel.heider@codasip.com>
Co-authored-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
Co-authored-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
Co-authored-by: Axel Heider <axelheider@gmx.de>
Co-authored-by: Hesham Almatary <hesham.almatary@cl.cam.ac.uk>
Co-authored-by: Kent McLeod <kent@kry10.com>
Co-authored-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
Co-authored-by: Damon Lee <damon@kry10.com>
Co-authored-by: Alwin Joshy <joshyalwin@gmail.com>
Co-authored-by: Axel Heider <axel.heider@codasip.com>
  • Loading branch information
10 people authored Sep 26, 2024
1 parent 1a929a7 commit f1bff11
Show file tree
Hide file tree
Showing 34 changed files with 160 additions and 401 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/sel4test-hw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# See sel4test-hw/builds.yml in the repo seL4/ci-actions for configs.

name: seL4Test HW
name: seL4Test-HW

on:
# needs PR target for secrets access; guard by requiring label
Expand All @@ -17,6 +17,11 @@ on:
permissions:
contents: read

# Cancel older runs to reduce the load, especially on the machine queue.
concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.number }}
cancel-in-progress: true

jobs:
hw-build:
name: HW Build
Expand All @@ -33,11 +38,9 @@ jobs:
strategy:
fail-fast: false
matrix:
march: [armv7a, armv8a, nehalem]
# There is no "rv32imac" hardware yet.
march: [armv7a, armv8a, nehalem, rv64imac]
compiler: [gcc, clang]
include:
- march: rv64imac
compiler: gcc
steps:
- name: Build
uses: seL4/ci-actions/sel4test-hw@master
Expand All @@ -46,7 +49,7 @@ jobs:
compiler: ${{ matrix.compiler }}
sha: ${{ github.event.pull_request.head.sha }}
- name: Upload images
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: images-${{ matrix.march }}-${{ matrix.compiler }}
path: '*-images.tar.gz'
Expand Down Expand Up @@ -78,13 +81,12 @@ jobs:
matrix: ${{ fromJson(needs.the_matrix.outputs.matrix) }}
steps:
- name: Get machine queue
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: seL4/machine_queue
path: machine_queue
token: ${{ secrets.PRIV_REPO_TOKEN }}
- name: Download image
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: images-${{ matrix.march }}-${{ matrix.compiler }}
- name: Run
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/sel4test-sim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
#
# See sel4test-sim/builds.yml in the repo seL4/ci-actions for configs.

name: seL4Test
name: seL4Test-Sim

on:
push:
branches: [master]
pull_request:

# Cancel older runs to reduce the load. The workflow also runs on pushes to
# the master branch, but skipping or cancellation will not happen there
# practically due to the unique run ID.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('run-{0}', github.run_id) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
simulation:
name: Simulation
Expand All @@ -21,11 +28,6 @@ jobs:
matrix:
march: [armv7a, armv8a, nehalem, rv32imac, rv64imac]
compiler: [gcc, clang]
exclude:
- march: rv32imac
compiler: clang
- march: rv64imac
compiler: clang
steps:
- uses: seL4/ci-actions/sel4test-sim@master
with:
Expand Down
20 changes: 16 additions & 4 deletions cmake-tool/helpers/application_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ cmake_minimum_required(VERSION 3.8.2)
include_guard(GLOBAL)

function(ApplyData61ElfLoaderSettings kernel_platform kernel_sel4_arch)
set(binary_list "tx1;hikey;odroidc2;odroidc4;imx8mq-evk;imx8mm-evk;hifive;tqma8xqp1gb;bcm2711")
set(
binary_list
"tx1;hikey;odroidc2;odroidc4;imx8mq-evk;imx8mm-evk;imx8mp-evk;hifive;tqma8xqp1gb;bcm2711;rocketchip;star64"
)
set(efi_list "tk1;rockpro64;quartz64")
set(uimage_list "tx2;am335x")
if(
Expand All @@ -33,18 +36,22 @@ function(ApplyData61ElfLoaderSettings kernel_platform kernel_sel4_arch)
set(ElfloaderMode "hypervisor" CACHE STRING "" FORCE)
set(ElfloaderMonitorHook ON CACHE BOOL "" FORCE)
endif()
if((KernelPlatformImx8mm-evk OR KernelPlatImx8mq) AND KernelSel4ArchAarch32)
if(
(KernelPlatformImx8mm-evk OR KernelPlatImx8mq OR KernelPlatformImx8mp-evk)
AND KernelSel4ArchAarch32
)
set(ElfloaderArmV8LeaveAarch64 ON CACHE BOOL "" FORCE)
# This applies to imx8mm, imx8mq (EVK and MaaXBoard) when in aarch32 configuration
# This applies to imx8mm, imx8mq (EVK and MaaXBoard), imx8mp when in aarch32 configuration
# It should be possible to use a uimage format but when tried nothing
# runs after uboot.
set(IMAGE_START_ADDR 0x41000000 CACHE INTERNAL "" FORCE)
set(IMAGE_START_ADDR 0x42000000 CACHE INTERNAL "" FORCE)
endif()
if(KernelPlatformHikey AND KernelSel4ArchAarch32)
# This is preserving what the Hikey's bootloader requires.
set(IMAGE_START_ADDR 0x1000 CACHE INTERNAL "" FORCE)
endif()
if(KernelPlatformZynqmp AND KernelSel4ArchAarch32)
set(ElfloaderArmV8LeaveAarch64 ON CACHE BOOL "" FORCE)
set(IMAGE_START_ADDR 0x8000000 CACHE INTERNAL "" FORCE)
endif()
if(KernelPlatformSpike AND KernelSel4ArchRiscV32)
Expand All @@ -56,6 +63,9 @@ function(ApplyData61ElfLoaderSettings kernel_platform kernel_sel4_arch)
endif()
set(IMAGE_START_ADDR 0x10000000 CACHE INTERNAL "" FORCE)
endif()
if(KernelPlatformStar64)
set(IMAGE_START_ADDR 0x60000000 CACHE INTERNAL "" FORCE)
endif()
endfunction()

function(ApplyCommonSimulationSettings kernel_sel4_arch)
Expand Down Expand Up @@ -159,6 +169,8 @@ function(correct_platform_strings)
# and leave all further setup to the architecture/platform specific
# configuration to <sel4 kernel>/src/plat/*/config.cmake
#
"-KernelRiscVPlatform"
"rocketchip:rocketchip-base,rocketchip-zcu102"
"-KernelARMPlatform"
"imx6:sabre,wandq,nitrogen6sx"
"bcm2837:rpi3"
Expand Down
14 changes: 7 additions & 7 deletions cmake-tool/helpers/check_arch_compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,54 @@ function(check_arch_clang)
MATCH
"^x86_64"
correct_triple
${TRIPLE}
"${TRIPLE}"
)
elseif("${KernelSel4Arch}" STREQUAL "x86_64")
string(
REGEX
MATCH
"^x86_64"
correct_triple
${TRIPLE}
"${TRIPLE}"
)
elseif("${KernelSel4Arch}" STREQUAL "aarch32" OR "${KernelSel4Arch}" STREQUAL "arm_hyp")
string(
REGEX
MATCH
"^arm"
correct_triple
${TRIPLE}
"${TRIPLE}"
)
elseif("${KernelSel4Arch}" STREQUAL "aarch64")
string(
REGEX
MATCH
"^aarch64"
correct_triple
${TRIPLE}
"${TRIPLE}"
)
elseif("${KernelSel4Arch}" STREQUAL "riscv32")
string(
REGEX
MATCH
"^riscv(32|64)"
correct_triple
${TRIPLE}
"${TRIPLE}"
)
elseif("${KernelSel4Arch}" STREQUAL "riscv64")
string(
REGEX
MATCH
"^riscv64"
correct_triple
${TRIPLE}
"${TRIPLE}"
)
else()
message(SEND_ERROR "KernelSel4Arch is not set to a valid arch")
endif()

if(NOT correct_triple)
message(SEND_ERROR "Clang Triple: ${TRIPLE} isn't for seL4_arch: ${KernelSel4Arch}")
message(SEND_ERROR "Clang Triple: '${TRIPLE}' isn't for seL4_arch: ${KernelSel4Arch}")
endif()

endfunction()
Expand Down
9 changes: 9 additions & 0 deletions cmake-tool/helpers/environment_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ macro(find_libgcc_files)
# find the compilers crtbegin and crtend files
gcc_print_file_name(CRTBeginFile crtbegin.o)
gcc_print_file_name(CRTEndFile crtend.o)

# Empty crt files variables if not found in the current toolchain.
# This should allow building/linking without cxx crt files (e.g., just C projects).
if("${CRTBeginFile}" STREQUAL "crtbegin.o" OR "${CRTEndFile}" STREQUAL "crtend.o")
message(WARNING "cxx: no crt object files found.")
set(CRTBeginFile "")
set(CRTEndFile "")
endif()

gcc_print_file_name(libgcc_eh libgcc_eh.a)
set(libgcc "-lgcc")
if(NOT "${libgcc_eh}" STREQUAL "libgcc_eh.a")
Expand Down
2 changes: 1 addition & 1 deletion cmake-tool/simulate_scripts/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def parse_args():

def notice(message):
# Don't call this without initialising `progname`.
assert(progname)
assert (progname)
sys.stderr.write("{}: {}".format(progname, message))
sys.stderr.flush()

Expand Down
15 changes: 12 additions & 3 deletions elfloader-tool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,22 @@ elseif(KernelSel4ArchAarch32)
add_compile_options(-mno-unaligned-access)
endif()

if(KernelArchARM)
# Only the Arm arch uses extension drivers.
set(
driver_file_globs
src/drivers/*.c
src/drivers/smp/*.c
src/drivers/uart/*.c
src/drivers/timer/*.c
)
endif()

file(
GLOB
files
src/*.c
src/drivers/*.c
src/drivers/smp/*.c
src/drivers/uart/*.c
${driver_file_globs}
src/utils/*.c
src/arch-${KernelArch}/*.c
src/arch-${KernelArch}/*.S
Expand Down
1 change: 1 addition & 0 deletions elfloader-tool/include/drivers.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
#pragma once

int initialise_devices(void);
int initialise_devices_non_boot(void);
2 changes: 2 additions & 0 deletions elfloader-tool/include/drivers/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ enum driver_type {
DRIVER_INVALID = 0,
DRIVER_SMP,
DRIVER_UART,
DRIVER_TIMER,
DRIVER_MAX
};

struct elfloader_driver {
const struct dtb_match_table *match_table;
enum driver_type type;
driver_init_t init;
driver_init_t init_on_secondary_cores;
/* ops struct, type depends on driver type. */
const void *ops;
};
Expand Down
10 changes: 6 additions & 4 deletions elfloader-tool/src/arch-arm/smp_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <autoconf.h>
#include <elfloader/gen_config.h>
#include <devices_gen.h>
#include <drivers.h>
#include <drivers/smp.h>

#include <printf.h>
Expand All @@ -25,8 +26,6 @@ void arm_disable_dcaches(void);
extern void const *dtb;
extern uint32_t dtb_size;

WEAK void non_boot_init(void) {}

/* Entry point for all CPUs other than the initial. */
void non_boot_main(void)
{
Expand All @@ -40,8 +39,11 @@ void non_boot_main(void)
#endif
}

/* Initialise any platform-specific per-core state */
non_boot_init();
/* Do any driver specific non_boot core init */
if (initialise_devices_non_boot()) {
printf("ERROR: Did not successfully return from initialise_devices_non_boot()\n");
abort();
}

#ifndef CONFIG_ARM_HYPERVISOR_SUPPORT
if (is_hyp_mode()) {
Expand Down
11 changes: 9 additions & 2 deletions elfloader-tool/src/arch-arm/sys_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ void main(UNUSED void *arg)
void *bootloader_dtb = NULL;

/* initialize platform to a state where we can print to a UART */
initialise_devices();
if (initialise_devices()) {
printf("ERROR: Did not successfully return from initialise_devices()\n");
abort();
}

platform_init();

/* Print welcome message. */
Expand Down Expand Up @@ -175,7 +179,10 @@ void continue_boot(int was_relocated)
* driver model so all its pointers are set up properly.
*/
if (was_relocated) {
initialise_devices();
if (initialise_devices()) {
printf("ERROR: Did not successfully return from initialise_devices()\n");
abort();
}
}

#if (defined(CONFIG_ARCH_ARM_V7A) || defined(CONFIG_ARCH_ARM_V8A)) && !defined(CONFIG_ARM_HYPERVISOR_SUPPORT)
Expand Down
37 changes: 36 additions & 1 deletion elfloader-tool/src/drivers/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ static int init_device(struct elfloader_device *dev)
int ret = table_has_match(dev->compat, drv->match_table);
if (ret >= 0) {
dev->drv = drv;
drv->init(dev, drv->match_table[ret].match_data);
ret = drv->init(dev, drv->match_table[ret].match_data);
if (ret) {
return ret;
}
}
drvp++;
}
Expand All @@ -53,3 +56,35 @@ int initialise_devices(void)

return 0;
}

static int init_device_non_boot(struct elfloader_device *dev)
{
struct elfloader_driver **drvp = __start__driver_list;

while (drvp < __stop__driver_list) {
struct elfloader_driver *drv = *drvp;
if (drv->init_on_secondary_cores) {
int ret = table_has_match(dev->compat, drv->match_table);
if (ret >= 0) {
dev->drv = drv;
ret = drv->init_on_secondary_cores(dev, drv->match_table[ret].match_data);
if (ret) {
return ret;
}
}
}
drvp++;
}
return 0;
}

int initialise_devices_non_boot(void)
{
for (unsigned int i = 0; i < ARRAY_SIZE(elfloader_devices); i++) {
int ret = init_device_non_boot(&elfloader_devices[i]);
if (ret) {
return ret;
}
}
return 0;
}
Loading

0 comments on commit f1bff11

Please sign in to comment.