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
This commit is contained in:
Martin Stein 2021-09-28 17:26:42 +02:00 committed by Norman Feske
parent ad059362d2
commit 9542bcf88c
25 changed files with 47 additions and 74 deletions

View File

@ -22,9 +22,7 @@
/* base-hw Core includes */
#include <spec/arm/imx_epit.h>
#include <spec/arm/trustzone_board.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a8/cpu.h>
#include <spec/cortex_a8/translation_table.h>
namespace Board { using namespace Hw::Imx53_qsb_board; }

View File

@ -20,9 +20,7 @@
/* base-hw Core includes */
#include <spec/arm/cortex_a9_private_timer.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a9/cpu.h>
#include <spec/cortex_a9/translation_table.h>
namespace Board {

View File

@ -22,9 +22,7 @@
#include <spec/arm/generic_timer.h>
#include <spec/arm/cpu/vm_state_virtualization.h>
#include <spec/arm/virtualization/board.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a15/cpu.h>
#include <spec/cortex_a15/translation_table.h>
namespace Board {

View File

@ -20,9 +20,7 @@
/* base-hw Core includes */
#include <spec/arm/generic_timer.h>
#include <spec/arm/virtualization/gicv3.h>
#include <spec/arm_v8/address_space_id_allocator.h>
#include <spec/arm_v8/cpu.h>
#include <spec/arm_v8/translation_table.h>
/* base-hw includes */
#include <spec/arm_64/cpu/vm_state_virtualization.h>

View File

@ -20,9 +20,7 @@
/* base-hw Core includes */
#include <spec/arm/cortex_a9_private_timer.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a9/cpu.h>
#include <spec/cortex_a9/translation_table.h>
namespace Board {

View File

@ -20,9 +20,7 @@
/* base-hw Core includes */
#include <spec/arm/cortex_a9_private_timer.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a9/cpu.h>
#include <spec/cortex_a9/translation_table.h>
namespace Board {

View File

@ -20,9 +20,7 @@
/* base-hw Core includes */
#include <spec/x86_64/pic.h>
#include <spec/x86_64/pit.h>
#include <spec/x86_64/address_space_id_allocator.h>
#include <spec/x86_64/cpu.h>
#include <spec/x86_64/translation_table.h>
namespace Board {

View File

@ -19,14 +19,9 @@
/* base-hw Core includes */
#include <spec/riscv/pic.h>
#include <spec/riscv/address_space_id_allocator.h>
#include <spec/riscv/cpu.h>
#include <spec/riscv/translation_table.h>
#include <spec/riscv/timer.h>
namespace Board { using namespace Hw::Riscv_board; }
/* base-hw Core includes */
#include <spec/riscv/timer.h>
#endif /* _CORE__SPEC__RISCV_QEMU__BOARD_H_ */

View File

@ -21,9 +21,7 @@
/* base-hw Core includes */
#include <spec/arm/bcm2835_pic.h>
#include <spec/arm/bcm2835_system_timer.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/arm_v6/cpu.h>
#include <spec/arm_v6/translation_table.h>
namespace Board { using namespace Hw::Rpi_board; };

View File

@ -20,9 +20,7 @@
/* base-hw Core includes */
#include <spec/arm/bcm2837_pic.h>
#include <spec/arm/generic_timer.h>
#include <spec/arm_v8/address_space_id_allocator.h>
#include <spec/arm_v8/cpu.h>
#include <spec/arm_v8/translation_table.h>
namespace Board {

View File

@ -22,9 +22,7 @@
/* base-hw Core includes */
#include <spec/arm/imx_epit.h>
#include <spec/arm/trustzone_board.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a8/cpu.h>
#include <spec/cortex_a8/translation_table.h>
namespace Board { using namespace Hw::Usb_armory_board; }

View File

@ -26,9 +26,7 @@
/* base-hw Core includes */
#include <spec/arm/virtualization/board.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a15/cpu.h>
#include <spec/cortex_a15/translation_table.h>
namespace Kernel { class Cpu; }

View File

@ -27,9 +27,7 @@
/* base-hw Core includes */
#include <kernel/configuration.h>
#include <kernel/irq.h>
#include <spec/arm_v8/address_space_id_allocator.h>
#include <spec/arm_v8/cpu.h>
#include <spec/arm_v8/translation_table.h>
namespace Board {

View File

@ -21,9 +21,7 @@
/* base-hw Core includes */
#include <spec/arm/cortex_a9_private_timer.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a9/cpu.h>
#include <spec/cortex_a9/translation_table.h>
namespace Board {

View File

@ -22,9 +22,7 @@
/* base-hw Core includes */
#include <spec/arm/cortex_a9_private_timer.h>
#include <spec/arm/address_space_id_allocator.h>
#include <spec/cortex_a9/cpu.h>
#include <spec/cortex_a9/translation_table.h>
namespace Board {

View File

@ -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 <spec/arm/cpu_support.h>
#include <spec/arm_v6/translation_table.h>
namespace Genode { struct Cpu; }

View File

@ -14,12 +14,20 @@
#ifndef _CORE__SPEC__ARM_V8__CPU_H_
#define _CORE__SPEC__ARM_V8__CPU_H_
/* Genode includes */
/* base includes */
#include <util/register.h>
#include <cpu/cpu_state.h>
/* base internal includes */
#include <base/internal/align_at.h>
/* base-hw internal includes */
#include <hw/spec/arm_64/cpu.h>
/* base-hw Core includes */
#include <spec/arm_v8/address_space_id_allocator.h>
#include <spec/arm_v8/translation_table.h>
namespace Kernel { struct Thread_fault; }

View File

@ -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 <spec/arm_v7/cpu_support.h>
#include <spec/cortex_a15/translation_table.h>
namespace Genode { class Cpu; }

View File

@ -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 <spec/arm_v7/cpu_support.h>
#include <spec/cortex_a8/translation_table.h>
namespace Genode { using Cpu = Arm_v7_cpu; }

View File

@ -19,7 +19,7 @@
#include <hw/spec/arm/page_table.h>
/* base-hw Core includes */
#include <kernel/interface.h>
#include <spec/arm/cpu_support.h>
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_ */

View File

@ -17,6 +17,7 @@
/* base-hw Core includes */
#include <spec/arm_v7/cpu_support.h>
#include <spec/cortex_a9/translation_table.h>
namespace Genode { struct Cpu; }

View File

@ -14,15 +14,21 @@
#ifndef _CORE__SPEC__RISCV__CPU_H_
#define _CORE__SPEC__RISCV__CPU_H_
/* Genode includes */
/* base includes */
#include <base/stdint.h>
#include <cpu/cpu_state.h>
#include <util/register.h>
/* base internal includes */
#include <base/internal/align_at.h>
#include <kernel/interface.h>
/* base-hw internal includes */
#include <hw/spec/riscv/cpu.h>
#include <hw/spec/riscv/page_table.h>
/* base-hw Core includes */
#include <kernel/interface.h>
#include <spec/riscv/address_space_id_allocator.h>
namespace Kernel { struct Thread_fault; }
@ -101,4 +107,12 @@ class Genode::Cpu : public Hw::Riscv_cpu
bool changed_cache_properties);
};
template <typename E, unsigned B, unsigned S>
void Sv39::Level_x_translation_table<E, B, S>::_translation_added(addr_t, size_t)
{
Genode::Cpu::sfence();
}
#endif /* _CORE__SPEC__RISCV__CPU_H_ */

View File

@ -18,6 +18,9 @@
#include <base/stdint.h>
#include <kernel/types.h>
/* base-hw internal includes */
#include <hw/spec/riscv/qemu_board.h>
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 };

View File

@ -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 <hw/spec/riscv/page_table.h>
#include <cpu.h>
template <typename E, unsigned B, unsigned S>
void Sv39::Level_x_translation_table<E, B, S>::_translation_added(addr_t, size_t)
{
Genode::Cpu::sfence();
}
#endif /* _CORE__SPEC__RISCV__TRANSLATION_TABLE_H_ */

View File

@ -17,18 +17,21 @@
#ifndef _CORE__SPEC__X86_64__CPU_H_
#define _CORE__SPEC__X86_64__CPU_H_
/* Genode includes */
/* base includes */
#include <util/register.h>
#include <kernel/interface_support.h>
#include <cpu/cpu_state.h>
/* base-hw internal includes */
#include <hw/spec/x86_64/cpu.h>
/* base includes */
/* base internal includes */
#include <base/internal/align_at.h>
/* core includes */
#include <fpu.h>
/* base-hw Core includes */
#include <spec/x86_64/fpu.h>
#include <spec/x86_64/address_space_id_allocator.h>
#include <spec/x86_64/translation_table.h>
namespace Kernel { struct Thread_fault; }