From 5a8d149fe3bc18995ae2c5e3c5bef62bc317a8b2 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Wed, 19 Jun 2024 11:40:07 +0200 Subject: [PATCH] hw: move all imx7d specifics to imx repository Ref genodelabs/genode#5252 --- repos/base-hw/board/imx7d_sabre/arch | 1 - .../board/imx7d_sabre/image_link_address | 1 - .../spec/arm_v7/bootstrap-hw-imx7d_sabre.mk | 13 - .../lib/mk/spec/arm_v7/core-hw-imx7d_sabre.mk | 32 --- .../src/base-hw-imx7d_sabre/content.mk | 1 - .../recipes/src/base-hw-imx7d_sabre/hash | 1 - .../recipes/src/base-hw-imx7d_sabre/used_apis | 2 - .../src/bootstrap/board/imx7d_sabre/board.h | 29 -- .../bootstrap/board/imx7d_sabre/platform.cc | 249 ------------------ .../src/core/board/imx7d_sabre/board.h | 36 --- .../include/hw/spec/arm/imx7d_sabre_board.h | 37 --- repos/base/include/drivers/defs/arm_v7.h | 30 --- repos/base/include/drivers/defs/imx7d_sabre.h | 43 --- repos/os/src/server/vmm/gic.h | 1 - 14 files changed, 476 deletions(-) delete mode 100644 repos/base-hw/board/imx7d_sabre/arch delete mode 100644 repos/base-hw/board/imx7d_sabre/image_link_address delete mode 100644 repos/base-hw/lib/mk/spec/arm_v7/bootstrap-hw-imx7d_sabre.mk delete mode 100644 repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx7d_sabre.mk delete mode 100644 repos/base-hw/recipes/src/base-hw-imx7d_sabre/content.mk delete mode 100644 repos/base-hw/recipes/src/base-hw-imx7d_sabre/hash delete mode 100644 repos/base-hw/recipes/src/base-hw-imx7d_sabre/used_apis delete mode 100644 repos/base-hw/src/bootstrap/board/imx7d_sabre/board.h delete mode 100644 repos/base-hw/src/bootstrap/board/imx7d_sabre/platform.cc delete mode 100644 repos/base-hw/src/core/board/imx7d_sabre/board.h delete mode 100644 repos/base-hw/src/include/hw/spec/arm/imx7d_sabre_board.h delete mode 100644 repos/base/include/drivers/defs/arm_v7.h delete mode 100644 repos/base/include/drivers/defs/imx7d_sabre.h diff --git a/repos/base-hw/board/imx7d_sabre/arch b/repos/base-hw/board/imx7d_sabre/arch deleted file mode 100644 index 16c61114d8..0000000000 --- a/repos/base-hw/board/imx7d_sabre/arch +++ /dev/null @@ -1 +0,0 @@ -arm_v7a diff --git a/repos/base-hw/board/imx7d_sabre/image_link_address b/repos/base-hw/board/imx7d_sabre/image_link_address deleted file mode 100644 index c6a2c50f36..0000000000 --- a/repos/base-hw/board/imx7d_sabre/image_link_address +++ /dev/null @@ -1 +0,0 @@ -0x88000000 diff --git a/repos/base-hw/lib/mk/spec/arm_v7/bootstrap-hw-imx7d_sabre.mk b/repos/base-hw/lib/mk/spec/arm_v7/bootstrap-hw-imx7d_sabre.mk deleted file mode 100644 index 0fac879149..0000000000 --- a/repos/base-hw/lib/mk/spec/arm_v7/bootstrap-hw-imx7d_sabre.mk +++ /dev/null @@ -1,13 +0,0 @@ -REP_INC_DIR += src/bootstrap/board/imx7d_sabre - -SRC_CC += bootstrap/spec/arm/cortex_a15_cpu.cc -SRC_CC += bootstrap/spec/arm/gicv2.cc -SRC_CC += bootstrap/board/imx7d_sabre/platform.cc - -include $(call select_from_repositories,lib/mk/spec/arm_v7/bootstrap-hw.inc) - -# -# we need more specific compiler hints for some 'special' assembly code -# override -march=armv7-a because it conflicts with -mcpu=cortex-a7 -# -CC_MARCH = -mcpu=cortex-a7+nofp -mfpu=vfpv3 diff --git a/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx7d_sabre.mk b/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx7d_sabre.mk deleted file mode 100644 index 3fa2d274de..0000000000 --- a/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx7d_sabre.mk +++ /dev/null @@ -1,32 +0,0 @@ -# -# \brief Build config for Genodes core process -# \author Stefan Kalkowski -# \date 2015-02-09 -# - -# add include paths -REP_INC_DIR += src/core/board/imx7d_sabre -REP_INC_DIR += src/core/spec/arm/virtualization - -# add C++ sources -SRC_CC += kernel/vm_thread_on.cc -SRC_CC += spec/arm/generic_timer.cc -SRC_CC += spec/arm/gicv2.cc -SRC_CC += spec/arm_v7/virtualization/kernel/vm.cc -SRC_CC += spec/arm/virtualization/gicv2.cc -SRC_CC += spec/arm/virtualization/platform_services.cc -SRC_CC += spec/arm/virtualization/vm_session_component.cc -SRC_CC += vm_session_common.cc -SRC_CC += vm_session_component.cc - -# add assembly sources -SRC_S += spec/arm_v7/virtualization/exception_vector.s - -# -# we need more specific compiler hints for some 'special' assembly code -# override -march=armv7-a because it conflicts with -mcpu=cortex-a7 -# -CC_MARCH = -mcpu=cortex-a7 -mfpu=vfpv3 -mfloat-abi=softfp - -# include less specific configuration -include $(call select_from_repositories,lib/mk/spec/cortex_a15/core-hw.inc) diff --git a/repos/base-hw/recipes/src/base-hw-imx7d_sabre/content.mk b/repos/base-hw/recipes/src/base-hw-imx7d_sabre/content.mk deleted file mode 100644 index 31319dcaf1..0000000000 --- a/repos/base-hw/recipes/src/base-hw-imx7d_sabre/content.mk +++ /dev/null @@ -1 +0,0 @@ -include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc diff --git a/repos/base-hw/recipes/src/base-hw-imx7d_sabre/hash b/repos/base-hw/recipes/src/base-hw-imx7d_sabre/hash deleted file mode 100644 index f35a2e1544..0000000000 --- a/repos/base-hw/recipes/src/base-hw-imx7d_sabre/hash +++ /dev/null @@ -1 +0,0 @@ -2024-06-19 3dca0840b93ba063d6368b5713b652706c3bc07e diff --git a/repos/base-hw/recipes/src/base-hw-imx7d_sabre/used_apis b/repos/base-hw/recipes/src/base-hw-imx7d_sabre/used_apis deleted file mode 100644 index ed9b772565..0000000000 --- a/repos/base-hw/recipes/src/base-hw-imx7d_sabre/used_apis +++ /dev/null @@ -1,2 +0,0 @@ -base-hw -base diff --git a/repos/base-hw/src/bootstrap/board/imx7d_sabre/board.h b/repos/base-hw/src/bootstrap/board/imx7d_sabre/board.h deleted file mode 100644 index b4c8446e8b..0000000000 --- a/repos/base-hw/src/bootstrap/board/imx7d_sabre/board.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * \brief Imx7 Sabrelite specific board definitions - * \author Stefan Kalkowski - * \date 2018-11-07 - */ - -/* - * Copyright (C) 2018 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 _SRC__BOOTSTRAP__SPEC__IMX7_SABRELITE__BOARD_H_ -#define _SRC__BOOTSTRAP__SPEC__IMX7_SABRELITE__BOARD_H_ - -#include -#include -#include -#include - -namespace Board { - - using namespace Hw::Imx7d_sabre_board; - using Pic = Hw::Gicv2; - static constexpr bool NON_SECURE = true; -} - -#endif /* _SRC__BOOTSTRAP__SPEC__IMX&_SABRELITE__BOARD_H_ */ diff --git a/repos/base-hw/src/bootstrap/board/imx7d_sabre/platform.cc b/repos/base-hw/src/bootstrap/board/imx7d_sabre/platform.cc deleted file mode 100644 index 043f73a15f..0000000000 --- a/repos/base-hw/src/bootstrap/board/imx7d_sabre/platform.cc +++ /dev/null @@ -1,249 +0,0 @@ -/* - * \brief Parts of platform that are specific to Imx7 sabrelite - * \author Stefan Kalkowski - * \date 2018-11-07 - */ - -/* - * Copyright (C) 2018 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. - */ - -#include -#include -#include -#include - -extern "C" void * _start_setup_stack; /* entrypoint for non-boot CPUs */ - -using namespace Board; - - -Bootstrap::Platform::Board::Board() -: - early_ram_regions(Memory_region { RAM_0_BASE, RAM_0_SIZE }), - core_mmio(Memory_region { IRQ_CONTROLLER_BASE, IRQ_CONTROLLER_SIZE }, - Memory_region { UART_1_MMIO_BASE, UART_1_MMIO_SIZE }) -{ - Aipstz aipstz_1(AIPS_1_MMIO_BASE); - Aipstz aipstz_2(AIPS_2_MMIO_BASE); - Aipstz aipstz_3(AIPS_3_MMIO_BASE); - - /* configure CSU */ - for (addr_t start = 0x303e0000; start <= 0x303e00fc; start += 4) - *(volatile addr_t *)start = 0x00ff00ff; - - static volatile unsigned long initial_values[][2] { - // CCM (Clock Control Module) - { 0x30384000, 0x3 }, - { 0x30384040, 0x3 }, - { 0x30384060, 0x3 }, - { 0x30384130, 0x3 }, - { 0x30384160, 0x0 }, - { 0x303844f0, 0x3 }, - { 0x30384510, 0x0 }, - { 0x30384520, 0x3 }, - { 0x303846d0, 0x0 }, - { 0x303846e0, 0x0 }, - { 0x30384780, 0x0 }, - { 0x30384790, 0x0 }, - { 0x303847a0, 0x0 }, - { 0x303847b0, 0x0 }, - { 0x303847c0, 0x3 }, - { 0x30384880, 0x0 }, - { 0x303848a0, 0x0 }, - { 0x30384950, 0x0 }, - { 0x30384960, 0x0 }, - { 0x30384970, 0x0 }, - { 0x30384980, 0x0 }, - { 0x30384990, 0x0 }, - { 0x303849a0, 0x0 }, - { 0x303849d0, 0x0 }, - { 0x303849e0, 0x0 }, - { 0x303849f0, 0x0 }, - { 0x303600c0, 0xd2605a56 }, - { 0x303600d0, 0xd2d2d256 }, - { 0x303600d4, 0xd2d2d256 }, - { 0x303600d8, 0xd2d2d256 }, - { 0x303600dc, 0xd2d2d256 }, - { 0x303600e0, 0x80000600 }, - { 0x303600f0, 0x101b }, - // IOMUXC (IOMUX Controller) - { 0x30330030, 0x14 }, - { 0x30330034, 0x10 }, - { 0x30330074, 0x2 }, - { 0x30330078, 0x2 }, - { 0x3033007c, 0x2 }, - { 0x30330080, 0x2 }, - { 0x30330084, 0x2 }, - { 0x30330088, 0x2 }, - { 0x3033008c, 0x2 }, - { 0x30330090, 0x2 }, - { 0x30330094, 0x2 }, - { 0x30330098, 0x2 }, - { 0x3033009c, 0x2 }, - { 0x303300a0, 0x2 }, - { 0x303300c4, 0x0 }, - { 0x30330150, 0x10 }, - { 0x30330154, 0x10 }, - { 0x30330210, 0x13 }, - { 0x30330214, 0x13 }, - { 0x3033021c, 0x1 }, - { 0x30330220, 0x1 }, - { 0x30330224, 0x1 }, - { 0x303302e4, 0x1 }, - { 0x303302e8, 0x1 }, - { 0x303302ec, 0x1 }, - { 0x303302f0, 0x1 }, - { 0x303302f4, 0x1 }, - { 0x303302f8, 0x1 }, - { 0x303302fc, 0x1 }, - { 0x30330300, 0x1 }, - { 0x30330304, 0x1 }, - { 0x30330308, 0x1 }, - { 0x3033030c, 0x1 }, - { 0x30330310, 0x1 }, - { 0x30330318, 0x59 }, - { 0x303303c0, 0x7f }, - { 0x303303c4, 0x7f }, - { 0x303303f4, 0x34 }, - { 0x303303f8, 0x59 }, - { 0x303303fc, 0x59 }, - { 0x30330400, 0x59 }, - { 0x30330404, 0x19 }, - { 0x30330408, 0x59 }, - { 0x3033040c, 0x59 }, - { 0x30330410, 0x59 }, - { 0x30330414, 0x59 }, - { 0x30330418, 0x59 }, - { 0x3033041c, 0x59 }, - { 0x30330440, 0x19 }, - { 0x30330444, 0x59 }, - { 0x30330448, 0x59 }, - { 0x3033044c, 0x59 }, - { 0x30330450, 0x59 }, - { 0x30330454, 0x59 }, - { 0x30330458, 0x59 }, - { 0x3033045c, 0x59 }, - { 0x30330460, 0x59 }, - { 0x30330464, 0x59 }, - { 0x30330468, 0x19 }, - { 0x30330480, 0x7f }, - { 0x30330484, 0x7f }, - { 0x3033048c, 0x2 }, - { 0x30330490, 0x2 }, - { 0x30330494, 0x2 }, - { 0x3033049c, 0x1 }, - { 0x303304a0, 0x1 }, - { 0x303304a4, 0x1 }, - { 0x303304a8, 0x1 }, - { 0x303304ac, 0x1 }, - { 0x303304b0, 0x1 }, - { 0x303304b4, 0x1 }, - { 0x303304b8, 0x1 }, - { 0x303304bc, 0x1 }, - { 0x303304c0, 0x1 }, - { 0x303304c4, 0x1 }, - { 0x303304c8, 0x1 }, - { 0x30330544, 0x1 }, - { 0x30330548, 0x1 }, - { 0x3033054c, 0x1 }, - { 0x303305dc, 0x1 }, - { 0x303305e0, 0x1 }, - { 0x303305ec, 0x3 }, - { 0x303305f0, 0x3 } - }; - - unsigned num_values = sizeof(initial_values) / (2*sizeof(unsigned long)); - for (unsigned i = 0; i < num_values; i++) - *((volatile unsigned long*)initial_values[i][0]) = initial_values[i][1]; - -} - - -static inline void switch_to_supervisor_mode(unsigned cpu_id) -{ - using Cpsr = Hw::Arm_cpu::Psr; - - Cpsr::access_t cpsr = 0; - Cpsr::M::set(cpsr, Cpsr::M::SVC); - Cpsr::F::set(cpsr, 1); - Cpsr::I::set(cpsr, 1); - - Genode::addr_t const stack = Hw::Mm::hypervisor_stack().base + - (cpu_id+1) * 0x1000; - - asm volatile ( - "msr sp_svc, sp \n" /* copy current mode's sp */ - "msr lr_svc, lr \n" /* copy current mode's lr */ - "msr elr_hyp, lr \n" /* copy current mode's lr to hyp lr */ - "msr sp_hyp, %[stack] \n" /* copy to hyp stack pointer */ - "msr spsr_cxfs, %[cpsr] \n" /* set psr for supervisor mode */ - "adr lr, 1f \n" /* load exception return address */ - "eret \n" /* exception return */ - "1:":: [cpsr] "r" (cpsr), [stack] "r" (stack)); -} - - -unsigned Bootstrap::Platform::enable_mmu() -{ - static volatile bool primary_cpu = true; - static unsigned long timer_freq = Cpu::Cntfrq::read(); - unsigned cpu = Cpu::Mpidr::Aff_0::get(Cpu::Mpidr::read()); - - /* locally initialize interrupt controller */ - ::Board::Pic pic { }; - - prepare_nonsecure_world(timer_freq); - prepare_hypervisor((addr_t)core_pd->table_base); - switch_to_supervisor_mode(cpu); - - Cpu::Sctlr::init(); - Cpu::Cpsr::init(); - - /* primary cpu wakes up all others */ - if (primary_cpu && NR_OF_CPUS > 1) { - Cpu::invalidate_data_cache(); - primary_cpu = false; - Cpu::wake_up_all_cpus(&_start_setup_stack); - } - - Cpu::enable_mmu_and_caches((Genode::addr_t)core_pd->table_base); - - return cpu; -} - - -void Board::Cpu::wake_up_all_cpus(void * const ip) -{ - struct Src : Genode::Mmio<0x84> - { - struct A7_cr0 : Register<0x4, 32> - { - struct Core1_por_reset : Bitfield<1,1> {}; - struct Core1_soft_reset : Bitfield<5,1> {}; - }; - struct A7_cr1 : Register<0x8, 32> - { - struct Core1_enable : Bitfield<1,1> {}; - }; - struct Gpr3 : Register<0x7c, 32> {}; /* ep core 1 */ - struct Gpr4 : Register<0x80, 32> {}; /* ep core 1 */ - - Src(void * const entry) : Mmio({(char *)SRC_MMIO_BASE, Mmio::SIZE}) - { - write((Gpr3::access_t)entry); - write((Gpr4::access_t)entry); - A7_cr0::access_t v0 = read(); - A7_cr0::Core1_soft_reset::set(v0,1); - write(v0); - A7_cr1::access_t v1 = read(); - A7_cr1::Core1_enable::set(v1,1); - write(v1); - } - }; - - Src src(ip); -} diff --git a/repos/base-hw/src/core/board/imx7d_sabre/board.h b/repos/base-hw/src/core/board/imx7d_sabre/board.h deleted file mode 100644 index a41b2e8109..0000000000 --- a/repos/base-hw/src/core/board/imx7d_sabre/board.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * \brief Board driver for core - * \author Stefan Kalkowski - * \date 2018-11-07 - */ - -/* - * Copyright (C) 2018 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__IMX7D_SABRE__BOARD_H_ -#define _CORE__SPEC__IMX7D_SABRE__BOARD_H_ - -/* base-hw internal includes */ -#include - -/* base-hw core includes */ -#include -#include -#include -#include -#include - -namespace Board { - - using namespace Hw::Imx7d_sabre_board; - - struct Virtual_local_pic {}; - - enum { TIMER_IRQ = 30, VCPU_MAX = 16 }; -} - -#endif /* _CORE__SPEC__IMX7_SABRELITE__BOARD_H_ */ diff --git a/repos/base-hw/src/include/hw/spec/arm/imx7d_sabre_board.h b/repos/base-hw/src/include/hw/spec/arm/imx7d_sabre_board.h deleted file mode 100644 index 917ed5c905..0000000000 --- a/repos/base-hw/src/include/hw/spec/arm/imx7d_sabre_board.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * \brief Imx7 Sabrelite specific board definitions - * \author Stefan Kalkowski - * \date 2018-11-07 - */ - -/* - * Copyright (C) 2018 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 _SRC__INCLUDE__HW__SPEC__ARM__IMX7_SABRELITE_BOARD_H_ -#define _SRC__INCLUDE__HW__SPEC__ARM__IMX7_SABRELITE_BOARD_H_ - -#include -#include -#include -#include - -namespace Hw::Imx7d_sabre_board { - - using namespace Imx7d_sabre; - - using Cpu_mmio = Hw::Cortex_a15_mmio; - using Serial = Genode::Imx_uart; - - enum { - UART_BASE = UART_1_MMIO_BASE, - UART_CLOCK = 0, /* unsued value */ - }; - - static constexpr Genode::size_t NR_OF_CPUS = 2; -} - -#endif /* _SRC__INCLUDE__HW__SPEC__ARM__IMX7_SABRELITE_BOARD_H_ */ diff --git a/repos/base/include/drivers/defs/arm_v7.h b/repos/base/include/drivers/defs/arm_v7.h deleted file mode 100644 index 9420d10f20..0000000000 --- a/repos/base/include/drivers/defs/arm_v7.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * \brief Definitions for Armv7 - * \author Stefan Kalkowski - * \date 2019-04-10 - */ - -/* - * Copyright (C) 2019 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 _INCLUDE__DRIVERS__DEFS__ARM_V7_H_ -#define _INCLUDE__DRIVERS__DEFS__ARM_V7_H_ - -namespace Arm_v7 { - - enum Interrupts { - - /****************************** - ** Virtualization extension ** - ******************************/ - - VT_MAINTAINANCE_IRQ = 25, - VT_TIMER_IRQ = 27, - }; -}; - -#endif /* _INCLUDE__DRIVERS__DEFS__ARM_V7_H_ */ diff --git a/repos/base/include/drivers/defs/imx7d_sabre.h b/repos/base/include/drivers/defs/imx7d_sabre.h deleted file mode 100644 index 6a572bf3eb..0000000000 --- a/repos/base/include/drivers/defs/imx7d_sabre.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * \brief Definitions for the Imx7 dual sabre board - * \author Stefan Kalkowski - * \date 2018-10-07 - */ - -/* - * Copyright (C) 2018 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 _INCLUDE__DRIVERS__DEFS__IMX7D_SABRE_H_ -#define _INCLUDE__DRIVERS__DEFS__IMX7D_SABRE_H_ - -#include - -namespace Imx7d_sabre { - - using namespace Arm_v7; - - enum { - RAM_0_BASE = 0x80000000UL, - RAM_0_SIZE = 0x40000000UL, - - IRQ_CONTROLLER_BASE = 0x31000000UL, - IRQ_CONTROLLER_SIZE = 0x8000, - - SRC_MMIO_BASE = 0x30390000UL, - - AIPS_1_MMIO_BASE = 0x301f0000UL, - AIPS_2_MMIO_BASE = 0x305f0000UL, - AIPS_3_MMIO_BASE = 0x309f0000UL, - - UART_1_MMIO_BASE = 0x30860000UL, - UART_1_MMIO_SIZE = 0x10000UL, - - TIMER_CLOCK = 1000000000UL, - }; -} - -#endif /* _INCLUDE__DRIVERS__DEFS__IMX7D_SABRE_H_ */ diff --git a/repos/os/src/server/vmm/gic.h b/repos/os/src/server/vmm/gic.h index 334a2f7e27..8356ef7deb 100644 --- a/repos/os/src/server/vmm/gic.h +++ b/repos/os/src/server/vmm/gic.h @@ -19,7 +19,6 @@ #include #include -#include #include #include #include