From 9542bcf88c9647c5effc02812afd0bd65507c1dd Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Tue, 28 Sep 2021 17:26:42 +0200 Subject: [PATCH] base-hw: reduce includes in board.h The includes for the address-space-ID allocator and the translation table are usually specific to the CPU in use. Therefore these includes can be moved from their current location in the board header to the CPU headers. This reduces the number of decisions a board maintainer has to make if the CPU model he's aiming for is already available. This can probably also be applied for other includes in the board headers but I intentionally leave it for a future commit as I don't have the time to do it all now. Ref #4217 --- .../base-hw/src/core/board/imx53_qsb/board.h | 2 -- .../src/core/board/imx6q_sabrelite/board.h | 2 -- .../src/core/board/imx7d_sabre/board.h | 2 -- .../base-hw/src/core/board/imx8q_evk/board.h | 2 -- .../base-hw/src/core/board/nit6_solox/board.h | 2 -- repos/base-hw/src/core/board/pbxa9/board.h | 2 -- repos/base-hw/src/core/board/pc/board.h | 2 -- .../base-hw/src/core/board/riscv_qemu/board.h | 7 +---- repos/base-hw/src/core/board/rpi/board.h | 2 -- repos/base-hw/src/core/board/rpi3/board.h | 2 -- .../base-hw/src/core/board/usb_armory/board.h | 2 -- .../base-hw/src/core/board/virt_qemu/board.h | 2 -- .../src/core/board/virt_qemu_64/board.h | 2 -- .../base-hw/src/core/board/wand_quad/board.h | 2 -- .../base-hw/src/core/board/zynq_qemu/board.h | 2 -- repos/base-hw/src/core/spec/arm_v6/cpu.h | 3 ++- repos/base-hw/src/core/spec/arm_v8/cpu.h | 10 ++++++- repos/base-hw/src/core/spec/cortex_a15/cpu.h | 3 ++- repos/base-hw/src/core/spec/cortex_a8/cpu.h | 3 ++- .../core/spec/cortex_a8/translation_table.h | 4 +-- repos/base-hw/src/core/spec/cortex_a9/cpu.h | 1 + repos/base-hw/src/core/spec/riscv/cpu.h | 18 +++++++++++-- repos/base-hw/src/core/spec/riscv/timer.h | 7 +++-- .../src/core/spec/riscv/translation_table.h | 26 ------------------- repos/base-hw/src/core/spec/x86_64/cpu.h | 11 +++++--- 25 files changed, 47 insertions(+), 74 deletions(-) delete mode 100644 repos/base-hw/src/core/spec/riscv/translation_table.h diff --git a/repos/base-hw/src/core/board/imx53_qsb/board.h b/repos/base-hw/src/core/board/imx53_qsb/board.h index a8bf3de8bd..962cc85be4 100644 --- a/repos/base-hw/src/core/board/imx53_qsb/board.h +++ b/repos/base-hw/src/core/board/imx53_qsb/board.h @@ -22,9 +22,7 @@ /* base-hw Core includes */ #include #include -#include #include -#include namespace Board { using namespace Hw::Imx53_qsb_board; } diff --git a/repos/base-hw/src/core/board/imx6q_sabrelite/board.h b/repos/base-hw/src/core/board/imx6q_sabrelite/board.h index ebef3f6d6a..3e36070a8f 100644 --- a/repos/base-hw/src/core/board/imx6q_sabrelite/board.h +++ b/repos/base-hw/src/core/board/imx6q_sabrelite/board.h @@ -20,9 +20,7 @@ /* base-hw Core includes */ #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/board/imx7d_sabre/board.h b/repos/base-hw/src/core/board/imx7d_sabre/board.h index 7b23c299fc..06feed0330 100644 --- a/repos/base-hw/src/core/board/imx7d_sabre/board.h +++ b/repos/base-hw/src/core/board/imx7d_sabre/board.h @@ -22,9 +22,7 @@ #include #include #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/board/imx8q_evk/board.h b/repos/base-hw/src/core/board/imx8q_evk/board.h index b1a0db55e5..b6b3179529 100644 --- a/repos/base-hw/src/core/board/imx8q_evk/board.h +++ b/repos/base-hw/src/core/board/imx8q_evk/board.h @@ -20,9 +20,7 @@ /* base-hw Core includes */ #include #include -#include #include -#include /* base-hw includes */ #include diff --git a/repos/base-hw/src/core/board/nit6_solox/board.h b/repos/base-hw/src/core/board/nit6_solox/board.h index 881868eb97..f2cff365e8 100644 --- a/repos/base-hw/src/core/board/nit6_solox/board.h +++ b/repos/base-hw/src/core/board/nit6_solox/board.h @@ -20,9 +20,7 @@ /* base-hw Core includes */ #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/board/pbxa9/board.h b/repos/base-hw/src/core/board/pbxa9/board.h index e6aa4fe7f5..c49d19725e 100644 --- a/repos/base-hw/src/core/board/pbxa9/board.h +++ b/repos/base-hw/src/core/board/pbxa9/board.h @@ -20,9 +20,7 @@ /* base-hw Core includes */ #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/board/pc/board.h b/repos/base-hw/src/core/board/pc/board.h index 4e419bfaef..27ef96c304 100644 --- a/repos/base-hw/src/core/board/pc/board.h +++ b/repos/base-hw/src/core/board/pc/board.h @@ -20,9 +20,7 @@ /* base-hw Core includes */ #include #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/board/riscv_qemu/board.h b/repos/base-hw/src/core/board/riscv_qemu/board.h index b6ad816485..2c33300172 100644 --- a/repos/base-hw/src/core/board/riscv_qemu/board.h +++ b/repos/base-hw/src/core/board/riscv_qemu/board.h @@ -19,14 +19,9 @@ /* base-hw Core includes */ #include -#include #include -#include +#include namespace Board { using namespace Hw::Riscv_board; } -/* base-hw Core includes */ -#include - - #endif /* _CORE__SPEC__RISCV_QEMU__BOARD_H_ */ diff --git a/repos/base-hw/src/core/board/rpi/board.h b/repos/base-hw/src/core/board/rpi/board.h index c721479d15..d03503548a 100644 --- a/repos/base-hw/src/core/board/rpi/board.h +++ b/repos/base-hw/src/core/board/rpi/board.h @@ -21,9 +21,7 @@ /* base-hw Core includes */ #include #include -#include #include -#include namespace Board { using namespace Hw::Rpi_board; }; diff --git a/repos/base-hw/src/core/board/rpi3/board.h b/repos/base-hw/src/core/board/rpi3/board.h index cae7074fe9..b7573b4c75 100644 --- a/repos/base-hw/src/core/board/rpi3/board.h +++ b/repos/base-hw/src/core/board/rpi3/board.h @@ -20,9 +20,7 @@ /* base-hw Core includes */ #include #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/board/usb_armory/board.h b/repos/base-hw/src/core/board/usb_armory/board.h index fce5932099..d0f5d14745 100644 --- a/repos/base-hw/src/core/board/usb_armory/board.h +++ b/repos/base-hw/src/core/board/usb_armory/board.h @@ -22,9 +22,7 @@ /* base-hw Core includes */ #include #include -#include #include -#include namespace Board { using namespace Hw::Usb_armory_board; } diff --git a/repos/base-hw/src/core/board/virt_qemu/board.h b/repos/base-hw/src/core/board/virt_qemu/board.h index 48373f680c..c12a54cc67 100644 --- a/repos/base-hw/src/core/board/virt_qemu/board.h +++ b/repos/base-hw/src/core/board/virt_qemu/board.h @@ -26,9 +26,7 @@ /* base-hw Core includes */ #include -#include #include -#include namespace Kernel { class Cpu; } diff --git a/repos/base-hw/src/core/board/virt_qemu_64/board.h b/repos/base-hw/src/core/board/virt_qemu_64/board.h index 1381b555a5..0e72f97486 100644 --- a/repos/base-hw/src/core/board/virt_qemu_64/board.h +++ b/repos/base-hw/src/core/board/virt_qemu_64/board.h @@ -27,9 +27,7 @@ /* base-hw Core includes */ #include #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/board/wand_quad/board.h b/repos/base-hw/src/core/board/wand_quad/board.h index a8c71df0fa..8802e63e08 100644 --- a/repos/base-hw/src/core/board/wand_quad/board.h +++ b/repos/base-hw/src/core/board/wand_quad/board.h @@ -21,9 +21,7 @@ /* base-hw Core includes */ #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/board/zynq_qemu/board.h b/repos/base-hw/src/core/board/zynq_qemu/board.h index 9e7b76334d..14d7fd5858 100644 --- a/repos/base-hw/src/core/board/zynq_qemu/board.h +++ b/repos/base-hw/src/core/board/zynq_qemu/board.h @@ -22,9 +22,7 @@ /* base-hw Core includes */ #include -#include #include -#include namespace Board { diff --git a/repos/base-hw/src/core/spec/arm_v6/cpu.h b/repos/base-hw/src/core/spec/arm_v6/cpu.h index 69c9776a82..6a9c6dfeb9 100644 --- a/repos/base-hw/src/core/spec/arm_v6/cpu.h +++ b/repos/base-hw/src/core/spec/arm_v6/cpu.h @@ -15,8 +15,9 @@ #ifndef _CORE__SPEC__ARM_V6__CPU_H_ #define _CORE__SPEC__ARM_V6__CPU_H_ -/* core includes */ +/* base-hw Core includes */ #include +#include namespace Genode { struct Cpu; } diff --git a/repos/base-hw/src/core/spec/arm_v8/cpu.h b/repos/base-hw/src/core/spec/arm_v8/cpu.h index 90a379761d..d6874d755d 100644 --- a/repos/base-hw/src/core/spec/arm_v8/cpu.h +++ b/repos/base-hw/src/core/spec/arm_v8/cpu.h @@ -14,12 +14,20 @@ #ifndef _CORE__SPEC__ARM_V8__CPU_H_ #define _CORE__SPEC__ARM_V8__CPU_H_ -/* Genode includes */ +/* base includes */ #include #include + +/* base internal includes */ #include + +/* base-hw internal includes */ #include +/* base-hw Core includes */ +#include +#include + namespace Kernel { struct Thread_fault; } diff --git a/repos/base-hw/src/core/spec/cortex_a15/cpu.h b/repos/base-hw/src/core/spec/cortex_a15/cpu.h index 182a983560..3a1ad078cf 100644 --- a/repos/base-hw/src/core/spec/cortex_a15/cpu.h +++ b/repos/base-hw/src/core/spec/cortex_a15/cpu.h @@ -15,8 +15,9 @@ #ifndef _CORE__SPEC__CORTEX_A15__CPU_H_ #define _CORE__SPEC__CORTEX_A15__CPU_H_ -/* core includes */ +/* base-hw Core includes */ #include +#include namespace Genode { class Cpu; } diff --git a/repos/base-hw/src/core/spec/cortex_a8/cpu.h b/repos/base-hw/src/core/spec/cortex_a8/cpu.h index 84c22142f9..b59b787248 100644 --- a/repos/base-hw/src/core/spec/cortex_a8/cpu.h +++ b/repos/base-hw/src/core/spec/cortex_a8/cpu.h @@ -15,8 +15,9 @@ #ifndef _CORE__SPEC__CORTEX_A8__CPU_H_ #define _CORE__SPEC__CORTEX_A8__CPU_H_ -/* core includes */ +/* base-hw Core includes */ #include +#include namespace Genode { using Cpu = Arm_v7_cpu; } diff --git a/repos/base-hw/src/core/spec/cortex_a8/translation_table.h b/repos/base-hw/src/core/spec/cortex_a8/translation_table.h index 36c0ac9c38..1898f5261f 100644 --- a/repos/base-hw/src/core/spec/cortex_a8/translation_table.h +++ b/repos/base-hw/src/core/spec/cortex_a8/translation_table.h @@ -19,7 +19,7 @@ #include /* base-hw Core includes */ -#include +#include constexpr unsigned Hw::Page_table::Descriptor_base::_device_tex() { @@ -38,7 +38,7 @@ void Hw::Page_table::_table_changed(unsigned long addr, unsigned long size) * page table entry is added. We only do this as core as the kernel * adds translations solely before MMU and caches are enabled. */ - Genode::Cpu::cache_clean_data_region(addr, size); + Genode::Arm_cpu::cache_clean_data_region(addr, size); } #endif /* _CORE__SPEC__CORTEX_A8__TRANSLATION_TABLE_H_ */ diff --git a/repos/base-hw/src/core/spec/cortex_a9/cpu.h b/repos/base-hw/src/core/spec/cortex_a9/cpu.h index 80a33c1df4..18fe5c246d 100644 --- a/repos/base-hw/src/core/spec/cortex_a9/cpu.h +++ b/repos/base-hw/src/core/spec/cortex_a9/cpu.h @@ -17,6 +17,7 @@ /* base-hw Core includes */ #include +#include namespace Genode { struct Cpu; } diff --git a/repos/base-hw/src/core/spec/riscv/cpu.h b/repos/base-hw/src/core/spec/riscv/cpu.h index d03a0f8bbf..86820b3504 100644 --- a/repos/base-hw/src/core/spec/riscv/cpu.h +++ b/repos/base-hw/src/core/spec/riscv/cpu.h @@ -14,15 +14,21 @@ #ifndef _CORE__SPEC__RISCV__CPU_H_ #define _CORE__SPEC__RISCV__CPU_H_ -/* Genode includes */ +/* base includes */ #include #include #include +/* base internal includes */ #include -#include +/* base-hw internal includes */ #include +#include + +/* base-hw Core includes */ +#include +#include namespace Kernel { struct Thread_fault; } @@ -101,4 +107,12 @@ class Genode::Cpu : public Hw::Riscv_cpu bool changed_cache_properties); }; + +template +void Sv39::Level_x_translation_table::_translation_added(addr_t, size_t) +{ + Genode::Cpu::sfence(); +} + + #endif /* _CORE__SPEC__RISCV__CPU_H_ */ diff --git a/repos/base-hw/src/core/spec/riscv/timer.h b/repos/base-hw/src/core/spec/riscv/timer.h index d5032409a6..10942d2172 100644 --- a/repos/base-hw/src/core/spec/riscv/timer.h +++ b/repos/base-hw/src/core/spec/riscv/timer.h @@ -18,6 +18,9 @@ #include #include +/* base-hw internal includes */ +#include + namespace Board { class Timer; } @@ -27,8 +30,8 @@ namespace Board { class Timer; } struct Board::Timer { enum { - TICKS_PER_MS = TIMER_HZ / 1000, - TICKS_PER_US = TICKS_PER_MS / 1000, + TICKS_PER_MS = Hw::Riscv_board::TIMER_HZ / 1000, + TICKS_PER_US = TICKS_PER_MS / 1000, }; Kernel::time_t last_time { 0 }; diff --git a/repos/base-hw/src/core/spec/riscv/translation_table.h b/repos/base-hw/src/core/spec/riscv/translation_table.h deleted file mode 100644 index a492b09478..0000000000 --- a/repos/base-hw/src/core/spec/riscv/translation_table.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * \brief RISCV Sv39 page table format - * \author Sebastian Sumpf - * \date 2015-08-04 - */ - -/* - * Copyright (C) 2015-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _CORE__SPEC__RISCV__TRANSLATION_TABLE_H_ -#define _CORE__SPEC__RISCV__TRANSLATION_TABLE_H_ - -#include -#include - -template -void Sv39::Level_x_translation_table::_translation_added(addr_t, size_t) -{ - Genode::Cpu::sfence(); -} - -#endif /* _CORE__SPEC__RISCV__TRANSLATION_TABLE_H_ */ diff --git a/repos/base-hw/src/core/spec/x86_64/cpu.h b/repos/base-hw/src/core/spec/x86_64/cpu.h index 8537ff76fa..0e4be02227 100644 --- a/repos/base-hw/src/core/spec/x86_64/cpu.h +++ b/repos/base-hw/src/core/spec/x86_64/cpu.h @@ -17,18 +17,21 @@ #ifndef _CORE__SPEC__X86_64__CPU_H_ #define _CORE__SPEC__X86_64__CPU_H_ -/* Genode includes */ +/* base includes */ #include #include #include +/* base-hw internal includes */ #include -/* base includes */ +/* base internal includes */ #include -/* core includes */ -#include +/* base-hw Core includes */ +#include +#include +#include namespace Kernel { struct Thread_fault; }