forked from seL4/seL4
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
Axel Heider
committed
Mar 29, 2022
1 parent
646bf87
commit 351341f
Showing
4 changed files
with
140 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
libsel4/sel4_plat_include/qemu-riscv-virt/sel4/plat/api/constants.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright 2022, HENSOLDT Cyber | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <autoconf.h> | ||
|
||
/* nothing here */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# | ||
# Copyright 2022, HENSOLDT Cyber | ||
# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) | ||
# | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
|
||
cmake_minimum_required(VERSION 3.7.2) | ||
|
||
declare_platform(qemu-riscv-virt KernelPlatformQEMURiscVVirt PLAT_QEMU_RISCV_VIRT KernelArchRiscV) | ||
|
||
if(KernelPlatformQEMURiscVVirt) | ||
|
||
if("${KernelSel4Arch}" STREQUAL riscv64) | ||
declare_seL4_arch(riscv64) | ||
elseif("${KernelSel4Arch}" STREQUAL riscv32) | ||
# This is still untested | ||
declare_seL4_arch(riscv32) | ||
else() | ||
fallback_declare_seL4_arch_default(riscv64) | ||
endif() | ||
|
||
config_set(KernelOpenSBIPlatform OPENSBI_PLATFORM "generic") | ||
config_set(KernelPlatformFirstHartID FIRST_HART_ID 1) | ||
|
||
set(QEMU_BINARY "qemu-system-${KernelSel4Arch}") | ||
find_program(QEMU_BINARY ${QEMU_BINARY}) | ||
|
||
set(MIN_QEMU_VERSION "5.1.0") | ||
execute_process( | ||
COMMAND ${QEMU_BINARY} -version | ||
OUTPUT_VARIABLE QEMU_VERSION_STR | ||
RESULT_VARIABLE error | ||
) | ||
if(error) | ||
message(FATAL_ERROR "Failed to determine qemu version (${QEMU_BINARY})") | ||
endif() | ||
string( | ||
REGEX | ||
MATCH | ||
"[0-9](\\.[0-9])+" | ||
QEMU_VERSION | ||
${QEMU_VERSION_STR} | ||
) | ||
if("${QEMU_VERSION}" VERSION_LESS "${MIN_QEMU_VERSION}") | ||
message(FATAL_ERROR "Error: neev at least QEMU version ${MIN_QEMU_VERSION}") | ||
endif() | ||
|
||
set(QEMU_DT_BASE_NAME "${CMAKE_BINARY_DIR}/qemu-riscv-virt") | ||
set(QEMU_DTB "${QEMU_DT_BASE_NAME}.dtb") | ||
set(QEMU_DTS "${QEMU_DT_BASE_NAME}.dts") | ||
|
||
if(KernelSel4ArchRiscV64) | ||
set(QEMU_CPU "rv64") | ||
elseif(KernelSel4ArchRiscV32) | ||
set(QEMU_CPU "rv32") | ||
else() | ||
message(FATAL_ERROR "unknown RISC-V KernelSel4Arch '${KernelSel4Arch}'") | ||
endif() | ||
|
||
if("${QEMU_MEMORY}" STREQUAL "") | ||
set(QEMU_MEMORY "1024") | ||
endif() | ||
|
||
if(KernelMaxNumNodes) | ||
set(QEMU_SMP_OPTION "${KernelMaxNumNodes}") | ||
else() | ||
set(QEMU_SMP_OPTION "1") | ||
endif() | ||
|
||
execute_process( | ||
COMMAND | ||
${QEMU_BINARY} -machine virt,dumpdtb=${QEMU_DTB} -cpu ${QEMU_CPU} -smp | ||
${QEMU_SMP_OPTION} -m ${QEMU_MEMORY} -nographic | ||
ERROR_VARIABLE QEMU_OUTPUT_MESSAGE | ||
RESULT_VARIABLE error | ||
) | ||
if(${QEMU_OUTPUT_MESSAGE}) | ||
string(STRIP ${QEMU_OUTPUT_MESSAGE} QEMU_OUTPUT_MESSAGE) | ||
endif() | ||
message(STATUS ${QEMU_OUTPUT_MESSAGE}) | ||
if(error) | ||
message(FATAL_ERROR "Failed to dump DTB using ${QEMU_BINARY})") | ||
endif() | ||
execute_process( | ||
COMMAND | ||
dtc -q -I dtb -O dts -o ${QEMU_DTS} ${QEMU_DTB} | ||
RESULT_VARIABLE error | ||
) | ||
if(error) | ||
message(FATAL_ERROR "Failed to convert DTB to DTS (${QEMU_DTB})") | ||
endif() | ||
|
||
list(APPEND KernelDTSList "${QEMU_DTS}" "${CMAKE_CURRENT_LIST_DIR}/overlay-qemu-riscv-virt.dts") | ||
|
||
# QEMU emulates SiFive PLIC/CLINT by default with a few interrupts, using | ||
# 64 here seems a safe value. The 10 MHz timer clock is just a dummy value. | ||
declare_default_headers( | ||
TIMER_FREQUENCY 10000000 PLIC_MAX_NUM_INT 64 | ||
INTERRUPT_CONTROLLER drivers/irq/riscv_plic0.h | ||
) | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2022, HENSOLDT Cyber | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-only | ||
*/ | ||
|
||
/ { | ||
chosen { | ||
/* | ||
* - elfloader and kernel use SBI console by default | ||
* - QEMU emulates a SiFive PLIC and CLINT by default | ||
* | ||
* Nothing needed for elfloader | ||
* seL4,elfloader-devices = ... ; | ||
* | ||
*/ | ||
seL4,kernel-devices = | ||
&{/soc/plic@c000000}; | ||
}; | ||
}; |