base-hw: don't include board.h from hardw. headers

The 'src/core/board/<board>/board.h' header is thought as front end of
hardware-specific headers of a given board towards the generic base-hw Core
code. Therefore it leads to problems (circular includes) if the board.h header
is included from within another hardware-specific header.

If hardware-specific headers access declarations from namespace Board in a
definition, the definition should be moved to a compilation unit that may
include board.h. If hardware-specific headers access declarations from board.h
in a declaration, they should either use the primary declaration from the
original header or, if the declaration must be selected according to the board,
another board-specific header should be introduced to reflect this abstraction.

This is applied by this commit for the current state of base-hw.

Ref #4217
This commit is contained in:
Martin Stein 2021-09-27 12:33:35 +02:00 committed by Norman Feske
parent 5d74509b2d
commit 49b09702b8
5 changed files with 34 additions and 11 deletions

View File

@ -9,6 +9,7 @@ REP_INC_DIR += src/core/spec/cortex_a9
# add C++ sources
SRC_CC += spec/cortex_a9/board.cc
SRC_CC += spec/cortex_a9/cpu.cc
SRC_CC += spec/arm/cortex_a9_private_timer.cc
SRC_CC += spec/arm/gicv2.cc
SRC_CC += spec/arm/kernel/lock.cc

View File

@ -15,16 +15,19 @@
#ifndef _CORE__SPEC__ARM__CPU_SUPPORT_H_
#define _CORE__SPEC__ARM__CPU_SUPPORT_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/cpu.h>
/* local includes */
/* base-hw Core includes */
#include <spec/arm/address_space_id_allocator.h>
#include <kernel/interface_support.h>
#include <board.h>
#include <util.h>
namespace Kernel { struct Thread_fault; }

View File

@ -0,0 +1,25 @@
/*
* \brief CPU driver for core
* \author Martin stein
* \author Stefan Kalkowski
* \date 2011-11-03
*/
/*
* Copyright (C) 2011-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.
*/
/* base-hw Core includes */
#include <spec/cortex_a9/cpu.h>
#include <board.h>
void Genode::Cpu::cache_clean_invalidate_data_region(addr_t const base,
size_t const size)
{
Arm_cpu::cache_clean_invalidate_data_region(base, size);
Board::l2_cache().clean_invalidate();
}

View File

@ -15,9 +15,8 @@
#ifndef _CORE__SPEC__CORTEX_A9__CPU_H_
#define _CORE__SPEC__CORTEX_A9__CPU_H_
/* core includes */
/* base-hw Core includes */
#include <spec/arm_v7/cpu_support.h>
#include <board.h>
namespace Genode { struct Cpu; }
@ -29,11 +28,7 @@ struct Genode::Cpu : Arm_v7_cpu
* 'base' - 'base + size'
*/
static void cache_clean_invalidate_data_region(addr_t const base,
size_t const size)
{
Arm_cpu::cache_clean_invalidate_data_region(base, size);
Board::l2_cache().clean_invalidate();
}
size_t const size);
static unsigned executing_id() { return Mpidr::Aff_0::get(Mpidr::read()); }
};

View File

@ -21,7 +21,6 @@
/* core includes */
#include <port_io.h>
#include <board.h>
namespace Board { class Timer; }