From ee6f25a028f0dea3a01b1eb20112d1318022363f Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 3 Dec 2012 17:21:35 +0100 Subject: [PATCH] base-hw: reorganize core-driver headers Ref #570 --- .../platform/imx31/drivers/serial_log.h | 2 +- .../lib/mk/platform_imx31/platform_support.mk | 3 +- .../lib/mk/platform_panda/platform_support.mk | 3 +- .../lib/mk/platform_pbxa9/platform_support.mk | 3 +- .../mk/trustzone/vea9x4_platform_support.mk | 5 +- base-hw/lib/mk/vea9x4_platform_support.mk | 3 +- base-hw/src/core/board/imx31.h | 95 ++++++++++ .../src/core/{include/arm/cpu.h => cpu/arm.h} | 10 +- .../{include/arm/v6/cpu.h => cpu/arm_v6.h} | 15 +- .../{include/arm/v7/cpu.h => cpu/arm_v7.h} | 12 +- .../cortex_a9/cpu.h => cpu/cortex_a9.h} | 12 +- .../{include/imx31/drivers => imx31}/board.h | 16 +- base-hw/src/core/imx31/platform_support.cc | 4 +- base-hw/src/core/imx31/tlb.h | 4 +- .../core/include/cortex_a9/kernel_support.h | 6 +- .../src/core/include/imx31/kernel_support.h | 6 +- base-hw/src/core/panda/platform_support.cc | 4 +- base-hw/src/core/panda/tlb.h | 2 +- base-hw/src/core/pbxa9/platform_support.cc | 4 +- base-hw/src/core/pbxa9/tlb.h | 2 +- .../cortex_a9/pic.h => pic/cortex_a9.h} | 6 +- .../pic.h => pic/cortex_a9_no_trustzone.h} | 10 +- .../core/{include/imx31/pic.h => pic/imx31.h} | 10 +- .../pic.h => pic/vea9x4_trustzone.h} | 10 +- .../cortex_a9/timer.h => timer/cortex_a9.h} | 8 +- base-hw/src/core/timer/imx31.h | 176 ++++++++++++++++++ .../arm/section_table.h => tlb/arm.h} | 8 +- .../arm/v6/section_table.h => tlb/arm_v6.h} | 10 +- .../arm/v7/section_table.h => tlb/arm_v7.h} | 12 +- base-hw/src/core/vea9x4/platform_support.cc | 4 +- base-hw/src/core/vea9x4/tlb.h | 2 +- .../core/vea9x4/trustzone/kernel_support.h | 6 +- .../core/vea9x4/trustzone/platform_support.cc | 4 +- 33 files changed, 379 insertions(+), 98 deletions(-) create mode 100644 base-hw/src/core/board/imx31.h rename base-hw/src/core/{include/arm/cpu.h => cpu/arm.h} (98%) rename base-hw/src/core/{include/arm/v6/cpu.h => cpu/arm_v6.h} (94%) rename base-hw/src/core/{include/arm/v7/cpu.h => cpu/arm_v7.h} (97%) rename base-hw/src/core/{include/cortex_a9/cpu.h => cpu/cortex_a9.h} (83%) rename base-hw/src/core/{include/imx31/drivers => imx31}/board.h (90%) rename base-hw/src/core/{include/cortex_a9/pic.h => pic/cortex_a9.h} (98%) rename base-hw/src/core/{include/cortex_a9/no_trustzone/pic.h => pic/cortex_a9_no_trustzone.h} (87%) rename base-hw/src/core/{include/imx31/pic.h => pic/imx31.h} (96%) rename base-hw/src/core/{include/vea9x4_trustzone/pic.h => pic/vea9x4_trustzone.h} (88%) rename base-hw/src/core/{include/cortex_a9/timer.h => timer/cortex_a9.h} (94%) create mode 100644 base-hw/src/core/timer/imx31.h rename base-hw/src/core/{include/arm/section_table.h => tlb/arm.h} (99%) rename base-hw/src/core/{include/arm/v6/section_table.h => tlb/arm_v6.h} (91%) rename base-hw/src/core/{include/arm/v7/section_table.h => tlb/arm_v7.h} (92%) diff --git a/base-hw/include/platform/imx31/drivers/serial_log.h b/base-hw/include/platform/imx31/drivers/serial_log.h index fba794de4..8baa82056 100644 --- a/base-hw/include/platform/imx31/drivers/serial_log.h +++ b/base-hw/include/platform/imx31/drivers/serial_log.h @@ -15,7 +15,7 @@ #define _INCLUDE__PLATFORM__IMX31__DRIVERS__SERIAL_LOG_H_ /* Genode includes */ -#include +#include #include namespace Genode diff --git a/base-hw/lib/mk/platform_imx31/platform_support.mk b/base-hw/lib/mk/platform_imx31/platform_support.mk index 34952100d..f2094bbf6 100644 --- a/base-hw/lib/mk/platform_imx31/platform_support.mk +++ b/base-hw/lib/mk/platform_imx31/platform_support.mk @@ -5,7 +5,8 @@ # # add include paths -INC_DIR += $(REP_DIR)/src/core/include \ +INC_DIR += $(REP_DIR)/src/core \ + $(REP_DIR)/src/core/include \ $(REP_DIR)/src/core/include/imx31 \ $(BASE_DIR)/src/core/include diff --git a/base-hw/lib/mk/platform_panda/platform_support.mk b/base-hw/lib/mk/platform_panda/platform_support.mk index ff42f0bad..f151039e0 100644 --- a/base-hw/lib/mk/platform_panda/platform_support.mk +++ b/base-hw/lib/mk/platform_panda/platform_support.mk @@ -5,7 +5,8 @@ # # add include paths -INC_DIR += $(REP_DIR)/src/core/include \ +INC_DIR += $(REP_DIR)/src/core \ + $(REP_DIR)/src/core/include \ $(BASE_DIR)/src/core/include # add C++ sources diff --git a/base-hw/lib/mk/platform_pbxa9/platform_support.mk b/base-hw/lib/mk/platform_pbxa9/platform_support.mk index 83b29ccc4..f0a746ab0 100644 --- a/base-hw/lib/mk/platform_pbxa9/platform_support.mk +++ b/base-hw/lib/mk/platform_pbxa9/platform_support.mk @@ -5,7 +5,8 @@ # # add include paths -INC_DIR += $(REP_DIR)/src/core/include \ +INC_DIR += $(REP_DIR)/src/core \ + $(REP_DIR)/src/core/include \ $(BASE_DIR)/src/core/include # add C++ sources diff --git a/base-hw/lib/mk/trustzone/vea9x4_platform_support.mk b/base-hw/lib/mk/trustzone/vea9x4_platform_support.mk index 39d9c7179..c2b3ef7dc 100644 --- a/base-hw/lib/mk/trustzone/vea9x4_platform_support.mk +++ b/base-hw/lib/mk/trustzone/vea9x4_platform_support.mk @@ -5,7 +5,8 @@ # # add include paths -INC_DIR += $(REP_DIR)/src/core/include \ +INC_DIR += $(REP_DIR)/src/core \ + $(REP_DIR)/src/core/include \ $(BASE_DIR)/src/core/include SRC_CC = platform_services.cc \ @@ -14,4 +15,4 @@ SRC_CC = platform_services.cc \ vpath platform_support.cc $(REP_DIR)/src/core/vea9x4/trustzone vpath platform_services.cc $(REP_DIR)/src/core/vea9x4/trustzone -vpath vm_session_component.cc $(REP_DIR)/src/core \ No newline at end of file +vpath vm_session_component.cc $(REP_DIR)/src/core diff --git a/base-hw/lib/mk/vea9x4_platform_support.mk b/base-hw/lib/mk/vea9x4_platform_support.mk index e27f68486..3fc38f82e 100644 --- a/base-hw/lib/mk/vea9x4_platform_support.mk +++ b/base-hw/lib/mk/vea9x4_platform_support.mk @@ -5,7 +5,8 @@ # # add include paths -INC_DIR += $(REP_DIR)/src/core/include \ +INC_DIR += $(REP_DIR)/src/core \ + $(REP_DIR)/src/core/include \ $(BASE_DIR)/src/core/include # avoid building of this lib with other platforms diff --git a/base-hw/src/core/board/imx31.h b/base-hw/src/core/board/imx31.h new file mode 100644 index 000000000..f28bdc84b --- /dev/null +++ b/base-hw/src/core/board/imx31.h @@ -0,0 +1,95 @@ +/* + * \brief Board driver for core + * \author Martin Stein + * \date 2012-11-01 + */ + +#ifndef _BOARD__IMX31_H_ +#define _BOARD__IMX31_H_ + +/* Genode includes */ +#include + +namespace Genode +{ + /** + * AHB-lite 2v6 to IP bus interface + */ + class Aips : public Mmio + { + /** + * Configuration of the masters + */ + struct Mpr { enum { ALL_UNBUFFERED_AND_FULLY_TRUSTED = 0x77777777 }; }; + struct Mpr1 : Register<0x0, 32>, Mpr { }; + struct Mpr2 : Register<0x4, 32>, Mpr { }; + + /** + * Configuration of the platform peripherals + */ + struct Pacr { enum { ALL_UNBUFFERED_AND_FULLY_UNPROTECTED = 0 }; }; + struct Pacr1 : Register<0x20, 32>, Pacr { }; + struct Pacr2 : Register<0x24, 32>, Pacr { }; + struct Pacr3 : Register<0x28, 32>, Pacr { }; + struct Pacr4 : Register<0x2c, 32>, Pacr { }; + + /** + * Configuration of the off-platform peripherals + */ + struct Opacr1 : Register<0x40, 32>, Pacr { }; + struct Opacr2 : Register<0x44, 32>, Pacr { }; + struct Opacr3 : Register<0x48, 32>, Pacr { }; + struct Opacr4 : Register<0x4c, 32>, Pacr { }; + struct Opacr5 : Register<0x50, 32>, Pacr { }; + + public: + + /** + * Constructor + */ + Aips(addr_t const base) : Mmio(base) { } + + /** + * Configure this module appropriately for the first kernel run + */ + void prepare_kernel() + { + /* avoid AIPS intervention at any memory access */ + write(Mpr::ALL_UNBUFFERED_AND_FULLY_TRUSTED); + write(Mpr::ALL_UNBUFFERED_AND_FULLY_TRUSTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + write(Pacr::ALL_UNBUFFERED_AND_FULLY_UNPROTECTED); + } + }; + + struct Board : Board_base + { + /** + * static AIPS 1 instance + */ + static Aips * aips_1() { static Aips a(AIPS_1_MMIO_BASE); return &a; } + + /** + * Static AIPS 2 instance + */ + static Aips * aips_2() { static Aips a(AIPS_2_MMIO_BASE); return &a; } + + /** + * Configure this module appropriately for the first kernel run + */ + static void prepare_kernel() + { + aips_1()->prepare_kernel(); + aips_2()->prepare_kernel(); + } + }; +} + +#endif /* _BOARD__IMX31_H_ */ diff --git a/base-hw/src/core/include/arm/cpu.h b/base-hw/src/core/cpu/arm.h similarity index 98% rename from base-hw/src/core/include/arm/cpu.h rename to base-hw/src/core/cpu/arm.h index 6a301afbe..f21be4848 100644 --- a/base-hw/src/core/include/arm/cpu.h +++ b/base-hw/src/core/cpu/arm.h @@ -1,5 +1,5 @@ /* - * \brief Simple driver for the ARM core + * \brief CPU driver for core * \author Martin stein * \date 2012-09-11 */ @@ -11,8 +11,8 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__ARM__CPU_H_ -#define _INCLUDE__ARM__CPU_H_ +#ifndef _CPU__ARM_H_ +#define _CPU__ARM_H_ /* Genode includes */ #include @@ -23,7 +23,7 @@ namespace Arm using namespace Genode; /** - * ARM core + * CPU driver for core */ struct Cpu { @@ -646,5 +646,5 @@ namespace Arm }; } -#endif /* _INCLUDE__ARM__CPU_H_ */ +#endif /* _CPU__ARM_H_ */ diff --git a/base-hw/src/core/include/arm/v6/cpu.h b/base-hw/src/core/cpu/arm_v6.h similarity index 94% rename from base-hw/src/core/include/arm/v6/cpu.h rename to base-hw/src/core/cpu/arm_v6.h index 0784b895f..624e5786b 100644 --- a/base-hw/src/core/include/arm/v6/cpu.h +++ b/base-hw/src/core/cpu/arm_v6.h @@ -1,6 +1,7 @@ /* - * \brief Simple driver for the ARMv6 CPU core + * \brief CPU driver for core * \author Norman Feske + * \author Martin stein * \date 2012-08-30 */ @@ -11,22 +12,22 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__ARM_V6__CPU_H_ -#define _INCLUDE__ARM_V6__CPU_H_ +#ifndef _CPU__ARM_V6_H_ +#define _CPU__ARM_V6_H_ /* Genode includes */ -#include +#include #include /* core includes */ -#include +#include namespace Arm_v6 { using namespace Genode; /** - * ARMv6 core + * CPU driver for core */ struct Cpu : Arm::Cpu { @@ -170,5 +171,5 @@ void Arm::Cpu::flush_data_caches() { asm volatile ("mcr p15, 0, %[rd], c7, c14, 0" :: [rd]"r"(0) : ); } -#endif /* _INCLUDE__ARM_V6__CPU_H_ */ +#endif /* _CPU__ARM_V6_H_ */ diff --git a/base-hw/src/core/include/arm/v7/cpu.h b/base-hw/src/core/cpu/arm_v7.h similarity index 97% rename from base-hw/src/core/include/arm/v7/cpu.h rename to base-hw/src/core/cpu/arm_v7.h index 771e09ebb..5ebf0d7fc 100644 --- a/base-hw/src/core/include/arm/v7/cpu.h +++ b/base-hw/src/core/cpu/arm_v7.h @@ -1,5 +1,5 @@ /* - * \brief Simple driver for the ARMv7 core + * \brief CPU driver for core * \author Martin stein * \date 2011-11-03 */ @@ -11,21 +11,21 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__ARM_V7__CPU_H_ -#define _INCLUDE__ARM_V7__CPU_H_ +#ifndef _CPU__ARM_V7_H_ +#define _CPU__ARM_V7_H_ /* Genode includes */ #include /* core includes */ -#include +#include namespace Arm_v7 { using namespace Genode; /** - * ARMv7 core + * CPU driver for core */ struct Cpu : Arm::Cpu { @@ -305,5 +305,5 @@ Arm::Cpu::Psr::access_t Arm::Cpu::Psr::init_user_with_trustzone() } -#endif /* _INCLUDE__ARM_V7__CPU_H_ */ +#endif /* _CPU__ARM_V7_H_ */ diff --git a/base-hw/src/core/include/cortex_a9/cpu.h b/base-hw/src/core/cpu/cortex_a9.h similarity index 83% rename from base-hw/src/core/include/cortex_a9/cpu.h rename to base-hw/src/core/cpu/cortex_a9.h index 560f25756..47ac8eb73 100644 --- a/base-hw/src/core/include/cortex_a9/cpu.h +++ b/base-hw/src/core/cpu/cortex_a9.h @@ -1,5 +1,5 @@ /* - * \brief Simple driver for the Cortex A9 + * \brief CPU driver for core * \author Martin stein * \date 2011-11-03 */ @@ -11,21 +11,21 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__CORTEX_A9__CPU_H_ -#define _INCLUDE__CORTEX_A9__CPU_H_ +#ifndef _CPU__CORTEX_A9_H_ +#define _CPU__CORTEX_A9_H_ /* Genode includes */ #include /* core includes */ -#include +#include namespace Cortex_a9 { using namespace Genode; /** - * Cortex A9 CPU + * CPU driver for core */ struct Cpu : Arm_v7::Cpu { @@ -50,5 +50,5 @@ namespace Cortex_a9 }; } -#endif /* _INCLUDE__CORTEX_A9__CPU_H_ */ +#endif /* _CPU__CORTEX_A9_H_ */ diff --git a/base-hw/src/core/include/imx31/drivers/board.h b/base-hw/src/core/imx31/board.h similarity index 90% rename from base-hw/src/core/include/imx31/drivers/board.h rename to base-hw/src/core/imx31/board.h index ab4211574..eea0bf0f4 100644 --- a/base-hw/src/core/include/imx31/drivers/board.h +++ b/base-hw/src/core/imx31/board.h @@ -1,14 +1,14 @@ /* - * \brief Board definitions for core + * \brief Board driver for core * \author Martin Stein * \date 2012-11-01 */ -#ifndef _INCLUDE__IMX31__DRIVERS__BOARD_H_ -#define _INCLUDE__IMX31__DRIVERS__BOARD_H_ +#ifndef _BOARD__IMX31_H_ +#define _BOARD__IMX31_H_ /* Genode includes */ -#include +#include namespace Genode { @@ -69,10 +69,13 @@ namespace Genode } }; + /** + * Board driver for core + */ struct Board : Board_base { /** - * static AIPS 1 instance + * Static AIPS 1 instance */ static Aips * aips_1() { static Aips a(AIPS_1_MMIO_BASE); return &a; } @@ -92,5 +95,4 @@ namespace Genode }; } -#endif /* _INCLUDE__IMX31__DRIVERS__BOARD_H_ */ - +#endif /* _BOARD__IMX31_H_ */ diff --git a/base-hw/src/core/imx31/platform_support.cc b/base-hw/src/core/imx31/platform_support.cc index 0d9d23d1f..ce0a856b8 100644 --- a/base-hw/src/core/imx31/platform_support.cc +++ b/base-hw/src/core/imx31/platform_support.cc @@ -12,8 +12,8 @@ */ /* Genode includes */ -#include -#include +#include +#include /* core includes */ #include diff --git a/base-hw/src/core/imx31/tlb.h b/base-hw/src/core/imx31/tlb.h index fc653eab3..24ea5e6f5 100644 --- a/base-hw/src/core/imx31/tlb.h +++ b/base-hw/src/core/imx31/tlb.h @@ -15,8 +15,8 @@ #define _SRC__CORE__IMX31__TLB_H_ /* Genode includes */ -#include -#include +#include +#include /** * Software TLB-controls diff --git a/base-hw/src/core/include/cortex_a9/kernel_support.h b/base-hw/src/core/include/cortex_a9/kernel_support.h index 2a0e6ca40..a202e43d8 100644 --- a/base-hw/src/core/include/cortex_a9/kernel_support.h +++ b/base-hw/src/core/include/cortex_a9/kernel_support.h @@ -15,9 +15,9 @@ #define _CORE__INCLUDE__CORTEX_A9__KERNEL_SUPPORT_H_ /* core includes */ -#include -#include -#include +#include +#include +#include /** * CPU driver diff --git a/base-hw/src/core/include/imx31/kernel_support.h b/base-hw/src/core/include/imx31/kernel_support.h index 6ae0c38d8..3eb745ac1 100644 --- a/base-hw/src/core/include/imx31/kernel_support.h +++ b/base-hw/src/core/include/imx31/kernel_support.h @@ -16,9 +16,9 @@ #define _CORE__INCLUDE__IMX31__KERNEL_SUPPORT_H_ /* Genode includes */ -#include -#include -#include +#include +#include +#include struct Cpu : Arm_v6::Cpu { }; diff --git a/base-hw/src/core/panda/platform_support.cc b/base-hw/src/core/panda/platform_support.cc index 3672e712d..a680535aa 100644 --- a/base-hw/src/core/panda/platform_support.cc +++ b/base-hw/src/core/panda/platform_support.cc @@ -15,8 +15,8 @@ #include /* core includes */ -#include -#include +#include +#include #include using namespace Genode; diff --git a/base-hw/src/core/panda/tlb.h b/base-hw/src/core/panda/tlb.h index 522938fd4..3050a3195 100644 --- a/base-hw/src/core/panda/tlb.h +++ b/base-hw/src/core/panda/tlb.h @@ -18,7 +18,7 @@ #include /* core includes */ -#include +#include /** * Software TLB-controls diff --git a/base-hw/src/core/pbxa9/platform_support.cc b/base-hw/src/core/pbxa9/platform_support.cc index fea5dff43..35790f288 100644 --- a/base-hw/src/core/pbxa9/platform_support.cc +++ b/base-hw/src/core/pbxa9/platform_support.cc @@ -16,8 +16,8 @@ /* core includes */ #include -#include -#include +#include +#include using namespace Genode; diff --git a/base-hw/src/core/pbxa9/tlb.h b/base-hw/src/core/pbxa9/tlb.h index df430dddd..f59f6cb1b 100644 --- a/base-hw/src/core/pbxa9/tlb.h +++ b/base-hw/src/core/pbxa9/tlb.h @@ -18,7 +18,7 @@ #include /* core includes */ -#include +#include /** * Software TLB-controls diff --git a/base-hw/src/core/include/cortex_a9/pic.h b/base-hw/src/core/pic/cortex_a9.h similarity index 98% rename from base-hw/src/core/include/cortex_a9/pic.h rename to base-hw/src/core/pic/cortex_a9.h index 7fdd537b8..03b48d159 100644 --- a/base-hw/src/core/include/cortex_a9/pic.h +++ b/base-hw/src/core/pic/cortex_a9.h @@ -11,8 +11,8 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__CORTEX_A9__PIC_H_ -#define _INCLUDE__CORTEX_A9__PIC_H_ +#ifndef _PIC__CORTEX_A9_H_ +#define _PIC__CORTEX_A9_H_ /* Genode includes */ #include @@ -288,5 +288,5 @@ namespace Cortex_a9 }; } -#endif /* _INCLUDE__CORTEX_A9__PIC_H_ */ +#endif /* _PIC__CORTEX_A9_H_ */ diff --git a/base-hw/src/core/include/cortex_a9/no_trustzone/pic.h b/base-hw/src/core/pic/cortex_a9_no_trustzone.h similarity index 87% rename from base-hw/src/core/include/cortex_a9/no_trustzone/pic.h rename to base-hw/src/core/pic/cortex_a9_no_trustzone.h index c667a9dbe..8beff3e1a 100644 --- a/base-hw/src/core/include/cortex_a9/no_trustzone/pic.h +++ b/base-hw/src/core/pic/cortex_a9_no_trustzone.h @@ -11,12 +11,12 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__CORTEX_A9__NO_TRUSTZONE__PIC_H_ -#define _INCLUDE__CORTEX_A9__NO_TRUSTZONE__PIC_H_ +#ifndef _PIC__CORTEX_A9_NO_TRUSTZONE_H_ +#define _PIC__CORTEX_A9_NO_TRUSTZONE_H_ /* core includes */ -#include -#include +#include +#include namespace Cortex_a9_no_trustzone { @@ -66,5 +66,5 @@ namespace Cortex_a9_no_trustzone }; } -#endif /* _INCLUDE__CORTEX_A9__NO_TRUSTZONE__PIC_H_ */ +#endif /* _PIC__CORTEX_A9_NO_TRUSTZONE_H_ */ diff --git a/base-hw/src/core/include/imx31/pic.h b/base-hw/src/core/pic/imx31.h similarity index 96% rename from base-hw/src/core/include/imx31/pic.h rename to base-hw/src/core/pic/imx31.h index fc98f1ef2..60db69454 100644 --- a/base-hw/src/core/include/imx31/pic.h +++ b/base-hw/src/core/pic/imx31.h @@ -12,12 +12,14 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__IMX31__PIC_H_ -#define _INCLUDE__IMX31__PIC_H_ +#ifndef _PIC__IMX31_H_ +#define _PIC__IMX31_H_ /* Genode includes */ #include -#include + +/* core includes */ +#include namespace Imx31 { @@ -193,5 +195,5 @@ namespace Imx31 }; } -#endif /* _INCLUDE__IMX31__PIC_H_ */ +#endif /* _PIC__IMX31_H_ */ diff --git a/base-hw/src/core/include/vea9x4_trustzone/pic.h b/base-hw/src/core/pic/vea9x4_trustzone.h similarity index 88% rename from base-hw/src/core/include/vea9x4_trustzone/pic.h rename to base-hw/src/core/pic/vea9x4_trustzone.h index 9441a59e3..9028ddaa2 100644 --- a/base-hw/src/core/include/vea9x4_trustzone/pic.h +++ b/base-hw/src/core/pic/vea9x4_trustzone.h @@ -11,12 +11,12 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__VEA9X4_TRUSTZONE__PIC_H_ -#define _INCLUDE__VEA9X4_TRUSTZONE__PIC_H_ +#ifndef _PIC__VEA9X4_TRUSTZONE_H_ +#define _PIC__VEA9X4_TRUSTZONE_H_ /* core includes */ -#include -#include +#include +#include namespace Vea9x4_trustzone { @@ -64,5 +64,5 @@ namespace Vea9x4_trustzone }; } -#endif /* _INCLUDE__VEA9X4_TRUSTZONE__PIC_H_ */ +#endif /* _PIC__VEA9X4_TRUSTZONE_H_ */ diff --git a/base-hw/src/core/include/cortex_a9/timer.h b/base-hw/src/core/timer/cortex_a9.h similarity index 94% rename from base-hw/src/core/include/cortex_a9/timer.h rename to base-hw/src/core/timer/cortex_a9.h index 9f4d20b0b..27cfde8cd 100644 --- a/base-hw/src/core/include/cortex_a9/timer.h +++ b/base-hw/src/core/timer/cortex_a9.h @@ -11,14 +11,14 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__CORTEX_A9__TIMER_H_ -#define _INCLUDE__CORTEX_A9__TIMER_H_ +#ifndef _TIMER__CORTEX_A9_H_ +#define _TIMER__CORTEX_A9_H_ /* Genode includes */ #include /* core includes */ -#include +#include namespace Cortex_a9 { @@ -127,5 +127,5 @@ namespace Cortex_a9 }; } -#endif /* _INCLUDE__CORTEX_A9__TIMER_H_ */ +#endif /* _TIMER__CORTEX_A9_H_ */ diff --git a/base-hw/src/core/timer/imx31.h b/base-hw/src/core/timer/imx31.h new file mode 100644 index 000000000..e4440a523 --- /dev/null +++ b/base-hw/src/core/timer/imx31.h @@ -0,0 +1,176 @@ +/* + * \brief Timer for core + * \author Martin Stein + * \author Norman Feske + * \date 2012-08-30 + */ + +/* + * Copyright (C) 2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _TIMER__IMX31_H_ +#define _TIMER__IMX31_H_ + +/* Genode includes */ +#include + +namespace Imx31 +{ + using namespace Genode; + + /** + * Core timer + */ + class Timer : public Mmio + { + enum { TICS_PER_MS = 32 }; + + /** + * Control register + */ + struct Cr : Register<0x0, 32> + { + struct En : Bitfield<0, 1> { }; /* enable timer */ + + struct En_mod : Bitfield<1, 1> /* reload or continue on enable */ + { + enum { RELOAD = 1 }; + }; + + struct Oci_en : Bitfield<2, 1> { }; /* interrupt on compare */ + + struct Rld : Bitfield<3, 1> /* reload or roll-over */ + { + enum { RELOAD_FROM_LR = 1 }; + }; + + struct Prescaler : Bitfield<4, 12> /* clock input divisor */ + { + enum { DIVIDE_BY_1 = 0 }; + }; + + struct Swr : Bitfield<16, 1> { }; /* software reset bit */ + struct Iovw : Bitfield<17, 1> { }; /* enable overwrite */ + struct Dbg_en : Bitfield<18, 1> { }; /* enable in debug mode */ + struct Wait_en : Bitfield<19, 1> { }; /* enable in wait mode */ + struct Doz_en : Bitfield<20, 1> { }; /* enable in doze mode */ + struct Stop_en : Bitfield<21, 1> { }; /* enable in stop mode */ + + struct Om : Bitfield<22, 2> /* mode of the output pin */ + { + enum { DISCONNECTED = 0 }; + }; + + struct Clk_src : Bitfield<24, 2> /* select clock input */ + { + enum { IPG_CLK_32K = 3 }; + }; + + /** + * Register value that configures the timer for a one-shot run + */ + static access_t prepare_one_shot() + { + return En::bits(0) | + En_mod::bits(En_mod::RELOAD) | + Oci_en::bits(1) | + Rld::bits(Rld::RELOAD_FROM_LR) | + Prescaler::bits(Prescaler::DIVIDE_BY_1) | + Swr::bits(0) | + Iovw::bits(0) | + Dbg_en::bits(0) | + Wait_en::bits(0) | + Doz_en::bits(0) | + Stop_en::bits(0) | + Om::bits(Om::DISCONNECTED) | + Clk_src::bits(Clk_src::IPG_CLK_32K); + } + }; + + /** + * Status register + */ + struct Sr : Register<0x4, 32> + { + struct Ocif : Bitfield<0, 1> { }; /* IRQ status, write 1 clears */ + }; + + struct Lr : Register<0x8, 32> { }; /* load value register */ + struct Cmpr : Register<0xc, 32> { }; /* compare value register */ + struct Cnt : Register<0x10, 32> { }; /* counter register */ + + /** + * Disable timer and clear its interrupt output + */ + void _reset() + { + /* wait until ongoing reset operations are finished */ + while (read()) ; + + /* disable timer */ + write(0); + clear_interrupt(); + } + + public: + + enum { IRQ = Board::EPIT_1_IRQ }; + + /** + * Constructor + */ + Timer() : Mmio(Board::EPIT_1_MMIO_BASE) { _reset(); } + + /** + * Start a one-shot run + * + * \param tics native timer value used to assess the delay + * of the timer interrupt as of the call + */ + void start_one_shot(unsigned const tics) + { + /* stop timer */ + _reset(); + + /* configure timer for a one-shot */ + write(Cr::prepare_one_shot()); + write(tics); + write(0); + + /* start timer */ + write(1); + } + + /** + * Stop the timer from a one-shot run + * + * \return last native timer value of the one-shot run + */ + unsigned long stop_one_shot() + { + /* disable timer */ + write(0); + + /* if the timer has hit zero already return 0 */ + return read() ? 0 : read(); + } + + /** + * Clear interrupt output line + */ + void clear_interrupt() { write(1); } + + /** + * Translate milliseconds to a native timer value + */ + static unsigned ms_to_tics(unsigned const ms) { + return TICS_PER_MS * ms; } + }; +} + +#endif /* _TIMER__IMX31_H_ */ + diff --git a/base-hw/src/core/include/arm/section_table.h b/base-hw/src/core/tlb/arm.h similarity index 99% rename from base-hw/src/core/include/arm/section_table.h rename to base-hw/src/core/tlb/arm.h index 8d8ee33ea..09b80615e 100644 --- a/base-hw/src/core/include/arm/section_table.h +++ b/base-hw/src/core/tlb/arm.h @@ -1,5 +1,5 @@ /* - * \brief Driver for ARM section tables + * \brief TLB driver for core * \author Martin Stein * \date 2012-02-22 */ @@ -11,8 +11,8 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__ARM__SECTION_TABLE_H_ -#define _INCLUDE__ARM__SECTION_TABLE_H_ +#ifndef _TLB__ARM_H_ +#define _TLB__ARM_H_ /* Genode includes */ #include @@ -962,5 +962,5 @@ namespace Arm } __attribute__((aligned(1< +#include namespace Arm_v6 { @@ -92,5 +92,5 @@ namespace Arm_v6 bool Arm::cache_support() { return 0; } -#endif /* _INCLUDE__ARM_V6__SECTION_TABLE_H_ */ +#endif /* _TLB__ARM_V6_H_ */ diff --git a/base-hw/src/core/include/arm/v7/section_table.h b/base-hw/src/core/tlb/arm_v7.h similarity index 92% rename from base-hw/src/core/include/arm/v7/section_table.h rename to base-hw/src/core/tlb/arm_v7.h index cafd7b462..0b2c83450 100644 --- a/base-hw/src/core/include/arm/v7/section_table.h +++ b/base-hw/src/core/tlb/arm_v7.h @@ -1,5 +1,5 @@ /* - * \brief Driver for ARMv7 section tables + * \brief TLB driver for core * \author Martin Stein * \date 2012-02-22 */ @@ -11,12 +11,12 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _INCLUDE__ARM_V7__SECTION_TABLE_H_ -#define _INCLUDE__ARM_V7__SECTION_TABLE_H_ +#ifndef _TLB__ARM_V7_H_ +#define _TLB__ARM_V7_H_ /* core includes */ -#include -#include +#include +#include namespace Arm_v7 { @@ -115,5 +115,5 @@ namespace Arm_v7 bool Arm::cache_support() { return 1; } -#endif /* _INCLUDE__ARM_V7__SECTION_TABLE_H_ */ +#endif /* _TLB__ARM_V7_H_ */ diff --git a/base-hw/src/core/vea9x4/platform_support.cc b/base-hw/src/core/vea9x4/platform_support.cc index 3d4aa2f0d..a87798671 100644 --- a/base-hw/src/core/vea9x4/platform_support.cc +++ b/base-hw/src/core/vea9x4/platform_support.cc @@ -16,8 +16,8 @@ /* Core includes */ #include -#include -#include +#include +#include using namespace Genode; diff --git a/base-hw/src/core/vea9x4/tlb.h b/base-hw/src/core/vea9x4/tlb.h index 4a31085c7..800a51700 100644 --- a/base-hw/src/core/vea9x4/tlb.h +++ b/base-hw/src/core/vea9x4/tlb.h @@ -18,7 +18,7 @@ #include /* core includes */ -#include +#include /** * Software TLB-controls diff --git a/base-hw/src/core/vea9x4/trustzone/kernel_support.h b/base-hw/src/core/vea9x4/trustzone/kernel_support.h index 10e11dcdd..f84a0fed3 100644 --- a/base-hw/src/core/vea9x4/trustzone/kernel_support.h +++ b/base-hw/src/core/vea9x4/trustzone/kernel_support.h @@ -15,9 +15,9 @@ #define _SRC__CORE__VEA9X4__TRUSTZONE__KERNEL_SUPPORT_H_ /* Core includes */ -#include -#include -#include +#include +#include +#include /** * CPU driver diff --git a/base-hw/src/core/vea9x4/trustzone/platform_support.cc b/base-hw/src/core/vea9x4/trustzone/platform_support.cc index eedd557ee..04ee76d4f 100644 --- a/base-hw/src/core/vea9x4/trustzone/platform_support.cc +++ b/base-hw/src/core/vea9x4/trustzone/platform_support.cc @@ -16,8 +16,8 @@ /* Core includes */ #include -#include -#include +#include +#include using namespace Genode;