From: l4check Date: Mon, 8 Apr 2013 17:38:05 +0000 (+0000) Subject: update: sync X-Git-Url: https://rtime.felk.cvut.cz/gitweb/l4.git/commitdiff_plain/013297c0d65e3dab85bb75c5a104babaebedd230 update: sync git-svn-id: http://svn.tudos.org/repos/oc/tudos/trunk@50 d050ee49-bd90-4346-b210-929a50b99cfc --- diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/Kconfig b/kernel/fiasco/src/kern/arm/bsp/omap3/Kconfig deleted file mode 100644 index 80e17e6b6..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/Kconfig +++ /dev/null @@ -1,38 +0,0 @@ -# PF: OMAP -# PFDESCR: TI OMAP -# PFDEPENDS: ARM - -choice - prompt "OMAP Platform" - default PF_OMAP3_EVM - -config PF_OMAP3_OMAP35XEVM - bool "TI OMAP35xEVM" - depends on PF_OMAP - select CAN_ARM_CPU_CORTEX_A8 - help - Choose for OMAP35xEVM platform. - -config PF_OMAP3_BEAGLEBOARD - bool "Beagle Board" - depends on PF_OMAP - select CAN_ARM_CPU_CORTEX_A8 - help - Choose for Beagleboard. - -config PF_OMAP3_AM33XX - bool "TI AM33xx" - depends on PF_OMAP - select CAN_ARM_CPU_CORTEX_A8 - help - Choose for AM33xx platforms (e.g. Beaglebone). - -config PF_OMAP4_PANDABOARD - bool "Pandaboard" - depends on PF_OMAP - select CAN_ARM_CPU_CORTEX_A9 - select CAN_ARM_CACHE_L2CXX0 - help - Choose for Pandaboard. - -endchoice diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/Modules b/kernel/fiasco/src/kern/arm/bsp/omap3/Modules deleted file mode 100644 index bdc12f517..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/Modules +++ /dev/null @@ -1,26 +0,0 @@ -# vim:set ft=make: - -SUBSYSTEMS += LIBUART -OBJECTS_LIBUART += uart_omap35x.o -PREPROCESS_PARTS += omap libuart generic_tickless_idle -PREPROCESS_PARTS += $(if $(CONFIG_PF_OMAP3_OMAP35XEVM),omap3 omap3_35x omap3_35xevm) -PREPROCESS_PARTS += $(if $(CONFIG_PF_OMAP3_BEAGLEBOARD),omap3 omap3_35x omap3_beagleboard) -PREPROCESS_PARTS += $(if $(CONFIG_PF_OMAP3_AM33XX),omap3 omap3_am33xx) -PREPROCESS_PARTS += $(if $(CONFIG_PF_OMAP4_PANDABOARD),omap4 mptimer pic_gic omap4_pandaboard) -CONFIG_KERNEL_LOAD_ADDR := 0x80000000 -MPCORE_PHYS_BASE := 0x48240000 - -INTERFACES_KERNEL += $(if $(CONFIG_PF_OMAP4_PANDABOARD),gic) - -uart_IMPL += uart-arm-omap -config_IMPL += config-arm-omap -mem_layout_IMPL += mem_layout-arm-omap -pic_IMPL += $(if $(CONFIG_PF_OMAP4_PANDABOARD),pic-gic pic-arm-gic-omap4,pic-arm-omap3) -bootstrap_IMPL += bootstrap-arm-omap -timer_IMPL += $(if $(CONFIG_PF_OMAP4_PANDABOARD),timer-arm-mptimer timer-arm-mptimer-omap4,timer-arm-omap3) -timer_tick_IMPL += timer_tick-single-vector -kernel_uart_IMPL += kernel_uart-arm-omap -reset_IMPL += reset-arm-omap -clock_IMPL += clock-generic -platform_control_IMPL += platform_control-arm-omap4 -outer_cache_IMPL += outer_cache-arm-omap diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/bootstrap-arm-omap.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/bootstrap-arm-omap.cpp deleted file mode 100644 index db547a003..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/bootstrap-arm-omap.cpp +++ /dev/null @@ -1,20 +0,0 @@ -INTERFACE [arm && omap]: - -enum { - Cache_flush_area = 0, -}; - -//----------------------------------------------------------------------------- -IMPLEMENTATION [arm && omap]: - -#include "mem_layout.h" -#include "io.h" - -void -map_hw(void *pd) -{ - map_dev(pd, 1); - map_dev(pd, 2); - map_dev(pd, 3); - map_dev(pd, 4); -} diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/config-arm-omap.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/config-arm-omap.cpp deleted file mode 100644 index 0a24f732e..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/config-arm-omap.cpp +++ /dev/null @@ -1,11 +0,0 @@ -INTERFACE[arm && omap3_35xevm]: //----------------------------------------- -#define TARGET_NAME "OMAP35xEVM" - -INTERFACE[arm && omap3_beagleboard]: //------------------------------------ -#define TARGET_NAME "Beagleboard" - -INTERFACE[arm && omap3_am33xx]: //----------------------------------------- -#define TARGET_NAME "AM33xx" - -INTERFACE[arm && omap4_pandaboard]: //------------------------------------- -#define TARGET_NAME "Pandaboard" diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/kernel_uart-arm-omap.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/kernel_uart-arm-omap.cpp deleted file mode 100644 index 6d834e566..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/kernel_uart-arm-omap.cpp +++ /dev/null @@ -1,12 +0,0 @@ -INTERFACE: - -// On ARM the MMIO for the uart is accessible before the MMU is fully up -EXTENSION class Kernel_uart { enum { Bsp_init_mode = Init_before_mmu }; }; - -IMPLEMENTATION [arm && omap && serial]: - -IMPLEMENT -bool Kernel_uart::startup(unsigned, int) -{ - return Uart::startup(); -} diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/mem_layout-arm-omap.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/mem_layout-arm-omap.cpp deleted file mode 100644 index e65a4cc3e..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/mem_layout-arm-omap.cpp +++ /dev/null @@ -1,101 +0,0 @@ -INTERFACE [arm && omap3_35x]: //------------------------------------------- - -EXTENSION class Mem_layout -{ -public: - enum Virt_layout_omap3_35x : Address { - L4_addr_prot_map_base = Devices1_map_base + 0x00040000, - Uart1_map_base = Devices1_map_base + 0x0006a000, - Gptimer10_map_base = Devices1_map_base + 0x00086000, - Wkup_cm_map_base = Devices1_map_base + 0x00004c00, - - Intc_map_base = Devices2_map_base + 0x0, - - Timer1ms_map_base = Devices3_map_base + 0x00018000, - Prm_global_reg_map_base = Devices3_map_base + 0x00007200, - - Uart3_map_base = Devices4_map_base + 0x00020000, - }; - - enum Phys_layout_omap3_35x : Address { - Devices1_phys_base = 0x48000000, - Devices2_phys_base = 0x48200000, - Devices3_phys_base = 0x48300000, - Devices4_phys_base = 0x49000000, - Sdram_phys_base = 0x80000000, - Flush_area_phys_base = 0xe0000000, - }; -}; - -INTERFACE [arm && omap3_35xevm]: //---------------------------------------- - -EXTENSION class Mem_layout -{ -public: - enum Virt_layout_omap3_35xevm : Address { - Uart_base = Uart1_map_base, - }; -}; - -INTERFACE [arm && omap3_beagleboard]: //----------------------------------- - -EXTENSION class Mem_layout -{ -public: - enum Virt_layout_omap3_beagleboard : Address { - Uart_base = Uart3_map_base, - }; -}; - -INTERFACE [arm && omap3_am33xx]: //---------------------------------------- - -EXTENSION class Mem_layout -{ -public: - enum Virt_layout_omap3_335x : Address { - Cm_per_map_base = Devices1_map_base + 0x00000000, - Cm_wkup_map_base = Devices1_map_base + 0x00000400, - Cm_dpll_map_base = Devices1_map_base + 0x00000500, - Timergen_map_base = Devices1_map_base + 0x00005000, // DMTIMER0 - Timer1ms_map_base = Devices1_map_base + 0x00031000, - Uart1_map_base = Devices1_map_base + 0x00009000, - Prm_global_reg_map_base = Devices3_map_base + 0x00007200, - Intc_map_base = Devices4_map_base + 0x0, - Uart_base = Uart1_map_base, - }; - - enum Phys_layout_omap3_335x : Address { - Devices1_phys_base = 0x44e00000, - Devices2_phys_base = 0x48000000, - Devices3_phys_base = 0x48100000, - Devices4_phys_base = 0x48200000, - Sdram_phys_base = 0x80000000, - Flush_area_phys_base = 0xe0000000, - }; -}; - -INTERFACE [arm && omap4]: //----------------------------------------------- - -EXTENSION class Mem_layout -{ -public: - enum Phys_layout_omap4 : Address { - Devices1_phys_base = 0x48000000, - Devices2_phys_base = 0x48200000, - Devices3_phys_base = 0x4a300000, - Devices4_phys_base = 0x49000000, - Sdram_phys_base = 0x80000000, - }; - - enum Virt_layout_omap4_pandaboard : Address { - Uart_base = Devices1_map_base + 0x20000, - Mp_scu_map_base = Devices2_map_base + 0x40000, - Gic_cpu_map_base = Devices2_map_base + 0x40100, - Gic_dist_map_base = Devices2_map_base + 0x41000, - L2cxx0_map_base = Devices2_map_base + 0x42000, - - __Timer = Devices2_map_base + 0x40600, - - Prm_map_base = Devices3_map_base + 0x6000, - }; -}; diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/outer_cache-arm-omap.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/outer_cache-arm-omap.cpp deleted file mode 100644 index 65f58477c..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/outer_cache-arm-omap.cpp +++ /dev/null @@ -1,48 +0,0 @@ -IMPLEMENTATION [arm && omap4 && outer_cache_l2cxx0]: - -EXTENSION class Outer_cache -{ - enum - { - Omap_l2cache_set_debug_reg = 0x100, - Omap_l2cache_clean_and_inv_range = 0x101, - Omap_l2cache_enable = 0x102, - Omap_l2cache_aux_reg = 0x109, - Omap_l2cache_tag_and_data_ram_lat_ctrl = 0x112, - Omap_l2cache_prefetch_ctrl = 0x113, - }; -}; - -PRIVATE static inline -void -Outer_cache::smc(Mword func, Mword val) -{ - register Mword _func asm("r12") = func; - register Mword _val asm("r0") = val; - asm volatile("dsb; smc #0" - : - : "r" (_func), "r" (_val) - : "memory", "cc", "r1", "r2", "r3", "r4", "r5", - "r6", "r7", "r8", "r9", "r10", "r11"); -} - -IMPLEMENT -Mword -Outer_cache::platform_init(Mword aux_control) -{ - aux_control = (1 << 16) // 16-way associativity - | (3 << 17) // 64k waysize - | (1 << 22) // shared attrib override - | (1 << 25) // reserved - | (1 << 26) // ns lockdown enable - | (1 << 27) // ns irq access enable - | (1 << 28) // data prefetch - | (1 << 29) // insn prefetch - | (1 << 30) // early BRESP enable - ; - - smc(Omap_l2cache_aux_reg, aux_control); - smc(Omap_l2cache_enable, 1); - - return aux_control; -} diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/pic-arm-gic-omap4.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/pic-arm-gic-omap4.cpp deleted file mode 100644 index c07a00c8c..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/pic-arm-gic-omap4.cpp +++ /dev/null @@ -1,40 +0,0 @@ -INTERFACE [arm && pic_gic && omap4]: - -#include "gic.h" - -// ------------------------------------------------------------------------ -IMPLEMENTATION [arm && pic_gic && omap4]: - -#include "irq_mgr_multi_chip.h" -#include "kmem.h" - -IMPLEMENT FIASCO_INIT -void -Pic::init() -{ - typedef Irq_mgr_multi_chip<8> M; - - M *m = new Boot_object(16); - - gic.construct(Kmem::Gic_cpu_map_base, Kmem::Gic_dist_map_base); - m->add_chip(0, gic, gic->nr_irqs()); - - Irq_mgr::mgr = m; -} - -IMPLEMENT inline -Pic::Status Pic::disable_all_save() -{ return 0; } - -IMPLEMENT inline -void Pic::restore_all(Status) -{} - -// ------------------------------------------------------------------------ -IMPLEMENTATION [arm && mp && pic_gic && omap4]: - -PUBLIC static -void Pic::init_ap(unsigned) -{ - gic->init_ap(); -} diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/pic-arm-omap3.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/pic-arm-omap3.cpp deleted file mode 100644 index b575a9e02..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/pic-arm-omap3.cpp +++ /dev/null @@ -1,155 +0,0 @@ -INTERFACE [arm && omap3]: - -#include "kmem.h" - -class Irq_base; - -EXTENSION class Pic -{ -public: - enum - { - INTCPS_SYSCONFIG = Kmem::Intc_map_base + 0x010, - INTCPS_SYSSTATUS = Kmem::Intc_map_base + 0x014, - INTCPS_CONTROL = Kmem::Intc_map_base + 0x048, - INTCPS_TRESHOLD = Kmem::Intc_map_base + 0x068, - INTCPS_ITRn_base = Kmem::Intc_map_base + 0x080, - INTCPS_MIRn_base = Kmem::Intc_map_base + 0x084, - INTCPS_MIR_CLEARn_base = Kmem::Intc_map_base + 0x088, - INTCPS_MIR_SETn_base = Kmem::Intc_map_base + 0x08c, - INTCPS_ISR_SETn_base = Kmem::Intc_map_base + 0x090, - INTCPS_ISR_CLEARn_base = Kmem::Intc_map_base + 0x094, - INTCPS_PENDING_IRQn_base = Kmem::Intc_map_base + 0x098, - INTCPS_ILRm_base = Kmem::Intc_map_base + 0x100, - }; -}; - -INTERFACE [arm && omap3_35x]: //------------------------------------------- - -EXTENSION class Pic -{ -public: - enum { Num_irqs = 96, }; -}; - -INTERFACE [arm && omap3_am33xx]: //---------------------------------------- - -EXTENSION class Pic -{ -public: - enum { Num_irqs = 128, }; -}; - -//------------------------------------------------------------------------- -IMPLEMENTATION [arm && omap3]: - -#include "config.h" -#include "io.h" -#include "irq_chip_generic.h" -#include "irq_mgr.h" - -class Irq_chip_arm_omap3 : public Irq_chip_gen -{ -public: - Irq_chip_arm_omap3() : Irq_chip_gen(Pic::Num_irqs) {} - unsigned set_mode(Mword, unsigned) { return Irq_base::Trigger_level; } - void set_cpu(Mword, unsigned) {} -}; - -PUBLIC -void -Irq_chip_arm_omap3::mask(Mword irq) -{ - assert(cpu_lock.test()); - Io::write(1 << (irq & 31), Pic::INTCPS_MIR_SETn_base + (irq & 0xe0)); -} - -PUBLIC -void -Irq_chip_arm_omap3::mask_and_ack(Mword irq) -{ - assert(cpu_lock.test()); - Io::write(1 << (irq & 31), Pic::INTCPS_MIR_SETn_base + (irq & 0xe0)); - Io::write(1, Pic::INTCPS_CONTROL); -} - -PUBLIC -void -Irq_chip_arm_omap3::ack(Mword irq) -{ - (void)irq; - Io::write(1, Pic::INTCPS_CONTROL); -} - -PUBLIC -void -Irq_chip_arm_omap3::unmask(Mword irq) -{ - assert(cpu_lock.test()); - Io::write(1 << (irq & 31), Pic::INTCPS_MIR_CLEARn_base + (irq & 0xe0)); -} - -static Static_object > mgr; - -IMPLEMENT FIASCO_INIT -void Pic::init() -{ - // Reset - Io::write(2, INTCPS_SYSCONFIG); - while (!Io::read(INTCPS_SYSSTATUS)) - ; - - // auto-idle - Io::write(1, INTCPS_SYSCONFIG); - - // disable treshold - Io::write(0xff, INTCPS_TRESHOLD); - - // set priority for each interrupt line, lets take 0x20 - // setting bit0 to 0 means IRQ (1 would mean FIQ) - for (int m = 0; m < Num_irqs; ++m) - Io::write(0x20 << 2, INTCPS_ILRm_base + (4 * m)); - - // mask all interrupts - for (int n = 0; n < 3; ++n) - Io::write(0xffffffff, INTCPS_MIR_SETn_base + 0x20 * n); - - Irq_mgr::mgr = mgr.construct(); -} - -IMPLEMENT inline -Pic::Status Pic::disable_all_save() -{ return 0; } - -IMPLEMENT inline -void Pic::restore_all(Status) -{} - -PUBLIC static inline NEEDS["io.h"] -Unsigned32 Irq_chip_arm_omap3::pending() -{ - for (int n = 0; n < (Pic::Num_irqs >> 5); ++n) - { - unsigned long x = Io::read(Pic::INTCPS_PENDING_IRQn_base + 0x20 * n); - for (int i = 0; i < 32; ++i) - if (x & (1 << i)) - return i + n * 32; - } - return 0; -} - -extern "C" -void irq_handler() -{ - Unsigned32 i; - while ((i = Irq_chip_arm_omap3::pending())) - mgr->c.handle_irq(i, 0); -} - -//--------------------------------------------------------------------------- -IMPLEMENTATION [debug && omap3]: - -PUBLIC -char const * -Irq_chip_arm_omap3::chip_type() const -{ return "HW OMAP3 IRQ"; } diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/platform_control-arm-omap4.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/platform_control-arm-omap4.cpp deleted file mode 100644 index c5d6b84ff..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/platform_control-arm-omap4.cpp +++ /dev/null @@ -1,51 +0,0 @@ -INTERFACE [arm && mp && omap4]: -#include "types.h" - -IMPLEMENTATION [arm && mp && omap4]: - -#include "io.h" -#include "kmem.h" - -PRIVATE static -void -Platform_control::aux(unsigned cmd, Mword arg0, Mword arg1) -{ - register unsigned long r0 asm("r0") = arg0; - register unsigned long r1 asm("r1") = arg1; - register unsigned long r12 asm("r12") = cmd; - - asm volatile("dsb; smc #0" - : : "r" (r0), "r" (r1), "r" (r12) - : "r2", "r3", "r4", "r5", "r6", - "r7", "r8", "r9", "r10", "r11", "lr", "memory"); -} - -PUBLIC static -void -Platform_control::boot_ap_cpus(Address phys_tramp_mp_addr) -{ - // two possibilities available, the memory mapped only in later board - // revisions - if (1) - { - enum { - AUX_CORE_BOOT_0 = 0x104, - AUX_CORE_BOOT_1 = 0x105, - }; - aux(AUX_CORE_BOOT_1, phys_tramp_mp_addr, 0); - asm volatile("dsb; sev" : : : "memory"); - aux(AUX_CORE_BOOT_0, 0x200, 0xfffffdff); - } - else - { - enum { - AUX_CORE_BOOT_0 = Kmem::Devices2_map_base + 0x81800, - AUX_CORE_BOOT_1 = Kmem::Devices2_map_base + 0x81804, - }; - Io::write(phys_tramp_mp_addr, AUX_CORE_BOOT_1); - asm volatile("dsb; sev" : : : "memory"); - Io::write((Io::read(AUX_CORE_BOOT_0) & ~0xfffffdff) | 0x200, - AUX_CORE_BOOT_0); - } -} - diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/reset-arm-omap.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/reset-arm-omap.cpp deleted file mode 100644 index 8d3ed70c8..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/reset-arm-omap.cpp +++ /dev/null @@ -1,54 +0,0 @@ -IMPLEMENTATION [arm && omap3_35x]: //-------------------------------------- - -#include "io.h" -#include "kmem.h" - -void __attribute__ ((noreturn)) -platform_reset(void) -{ - enum - { - PRM_RSTCTRL = Kmem::Prm_global_reg_map_base + 0x50, - }; - - Io::write(2, PRM_RSTCTRL); - - for (;;) - ; -} - -IMPLEMENTATION [arm && omap3_am33xx]: //----------------------------------- - -#include "io.h" -#include "kmem.h" - -void __attribute__ ((noreturn)) -platform_reset(void) -{ - enum { PRM_RSTCTRL = Kmem::Devices1_map_base + 0xF00, }; - - Io::write(1, PRM_RSTCTRL); - - for (;;) - ; -} - -IMPLEMENTATION [arm && omap4]: //------------------------------------------ - -#include "io.h" -#include "kmem.h" - -void __attribute__ ((noreturn)) -platform_reset(void) -{ - enum - { - DEVICE_PRM = Kmem::Prm_map_base + 0x1b00, - PRM_RSTCTRL = DEVICE_PRM + 0, - }; - - Io::write(1, PRM_RSTCTRL); - - for (;;) - ; -} diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/timer-arm-mptimer-omap4.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/timer-arm-mptimer-omap4.cpp deleted file mode 100644 index b721598a6..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/timer-arm-mptimer-omap4.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// -------------------------------------------------------------------------- -INTERFACE [arm && mptimer && omap4_pandaboard]: - -EXTENSION class Timer -{ -private: - static Mword interval() { return 499999; } -}; diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/timer-arm-omap3.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/timer-arm-omap3.cpp deleted file mode 100644 index 198575697..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/timer-arm-omap3.cpp +++ /dev/null @@ -1,285 +0,0 @@ -INTERFACE [omap3]: // ------------------------------------------------ - -#include "kmem.h" - -class Timer_omap_1mstimer -{ -public: - enum { - TIDR = Kmem::Timer1ms_map_base + 0x000, // IP revision code - TIOCP_CFG = Kmem::Timer1ms_map_base + 0x010, // config - TISTAT = Kmem::Timer1ms_map_base + 0x014, // non-interrupt status - TISR = Kmem::Timer1ms_map_base + 0x018, // pending interrupts - TIER = Kmem::Timer1ms_map_base + 0x01c, // enable/disable of interrupt events - TWER = Kmem::Timer1ms_map_base + 0x020, // wake-up features - TCLR = Kmem::Timer1ms_map_base + 0x024, // optional features - TCRR = Kmem::Timer1ms_map_base + 0x028, // internal counter - TLDR = Kmem::Timer1ms_map_base + 0x02c, // timer load value - TTGR = Kmem::Timer1ms_map_base + 0x030, // trigger reload by writing - TWPS = Kmem::Timer1ms_map_base + 0x034, // write-posted pending - TMAR = Kmem::Timer1ms_map_base + 0x038, // compare value - TCAR1 = Kmem::Timer1ms_map_base + 0x03c, // first capture value of the counter - TCAR2 = Kmem::Timer1ms_map_base + 0x044, // second capture value of the counter - TPIR = Kmem::Timer1ms_map_base + 0x048, // positive inc, gpt1, 2 and 10 only - TNIR = Kmem::Timer1ms_map_base + 0x04C, // negative inc, gpt1, 2 and 10 only - }; -}; - -// -------------------------------------------------------------------------- -INTERFACE [arm && omap3_35x]: - -EXTENSION class Timer -{ -public: - static unsigned irq() { return 37; } - -private: - enum { - CM_CLKSEL_WKUP = Kmem::Wkup_cm_map_base + 0x40, - }; -}; - -INTERFACE [arm && omap3_am33xx]: //---------------------------------------- - -class Timer_omap_gentimer -{ -public: - enum { - TIDR = Kmem::Timergen_map_base + 0x00, // ID - TIOCP_CFG = Kmem::Timergen_map_base + 0x10, // config - EOI = Kmem::Timergen_map_base + 0x20, - IRQSTATUS = Kmem::Timergen_map_base + 0x28, - IRQENABLE_SET = Kmem::Timergen_map_base + 0x2c, - IRQWAKEEN = Kmem::Timergen_map_base + 0x34, - TCLR = Kmem::Timergen_map_base + 0x38, - TCRR = Kmem::Timergen_map_base + 0x3c, - TLDR = Kmem::Timergen_map_base + 0x40, - }; -}; - -EXTENSION class Timer -{ -public: - enum Timer_type { Timer0, Timer1_1ms }; - static Timer_type type() { return Timer1_1ms; } - - static unsigned irq() - { - switch (type()) - { - case Timer0: default: return 66; - case Timer1_1ms: return 67; - } - } - - enum { - CM_WKUP_CLKSTCTRL = Kmem::Cm_wkup_map_base + 0x00, - CM_WKUP_TIMER0_CLKCTRL = Kmem::Cm_wkup_map_base + 0x10, - CM_WKUP_TIMER1_CLKCTRL = Kmem::Cm_wkup_map_base + 0xc4, - CLKSEL_TIMER1MS_CLK = Kmem::Cm_dpll_map_base + 0x28, - - CLKSEL_TIMER1MS_CLK_OSC = 0, - CLKSEL_TIMER1MS_CLK_32KHZ = 1, - CLKSEL_TIMER1MS_CLK_VALUE = CLKSEL_TIMER1MS_CLK_OSC, - }; -}; - -IMPLEMENTATION [omap3]: // ------------------------------------------------ - -PRIVATE static -void -Timer_omap_1mstimer::get_timer_values_32khz(unsigned &reload, int &tpir, int &tnir) -{ - tpir = 232000; - tnir = -768000; - reload = 0xffffffe0; - assert(Config::Scheduler_granularity == 1000); // need to adapt here -} - -IMPLEMENTATION [arm && omap3_35x]: // ------------------------------------- - -PRIVATE static -void -Timer_omap_1mstimer::get_timer_values(unsigned &reload, int &tpir, int &tnir) -{ - get_timer_values_32khz(reload, tpir, tnir); -} - -IMPLEMENTATION [arm && omap3_am33xx]: // ---------------------------------- - -PRIVATE static -void -Timer_omap_1mstimer::get_timer_values(unsigned &reload, int &tpir, int &tnir) -{ - if (Timer::CLKSEL_TIMER1MS_CLK_VALUE == Timer::CLKSEL_TIMER1MS_CLK_32KHZ) - get_timer_values_32khz(reload, tpir, tnir); - else - { - tpir = 100000; - tnir = 0; - reload = ~0 - 24 * Config::Scheduler_granularity + 1; // 24 MHz - } -} - -IMPLEMENTATION [omap3]: // ------------------------------------------------ - -#include "io.h" -#include - -PUBLIC static -void -Timer_omap_1mstimer::init() -{ - // reset - Io::write(1, TIOCP_CFG); - while (!Io::read(TISTAT)) - ; - // reset done - - // overflow mode - Io::write(0x2, TIER); - // no wakeup - Io::write(0x0, TWER); - - // program timer frequency - unsigned val; - int tpir, tnir; - get_timer_values(val, tpir, tnir); - - Io::write(tpir, TPIR); // gpt1, gpt2 and gpt10 only - Io::write(tnir, TNIR); // gpt1, gpt2 and gpt10 only - Io::write(val, TCRR); - Io::write(val, TLDR); - - // auto-reload + enable - Io::write(1 | 2, TCLR); -} - -PUBLIC static inline NEEDS["io.h"] -void -Timer_omap_1mstimer::acknowledge() -{ - Io::write(2, TISR); -} - -IMPLEMENTATION [arm && omap3_am33xx]: // ---------------------------------- - -PUBLIC static -void -Timer_omap_gentimer::init() -{ - // Mword idr = Io::read(TIDR); - // older timer: idr >> 16 == 0 - // newer timer: idr >> 16 != 0 - - // reset - Io::write(1, TIOCP_CFG); - while (Io::read(TIOCP_CFG) & 1) - ; - // reset done - - // overflow mode - Io::write(2, IRQENABLE_SET); - // no wakeup - Io::write(0, IRQWAKEEN); - - // program 1000 Hz timer frequency - // (FFFFFFFFh - TLDR + 1) * timer-clock-period * clock-divider(ps) - Mword val = 0xffffffda; - Io::write(val, TLDR); - Io::write(val, TCRR); - - Io::write(1 | 2, TCLR); -} - -PUBLIC static inline NEEDS["io.h"] -void -Timer_omap_gentimer::acknowledge() -{ - Io::write(2, IRQSTATUS); - Io::write(0, EOI); -} - -// ----------------------------------------------------------------------- -IMPLEMENTATION [arm && omap3_35x]: - -IMPLEMENT -void Timer::init(unsigned) -{ - // select 32768 Hz input to GPTimer1 (timer1 only!) - Io::write(~1 & Io::read(CM_CLKSEL_WKUP), CM_CLKSEL_WKUP); - Timer_omap_1mstimer::init(); -} - -PUBLIC static inline NEEDS[Timer_omap_1mstimer::acknowledge] -void Timer::acknowledge() -{ - Timer_omap_1mstimer::acknowledge(); -} - -// ----------------------------------------------------------------------- -IMPLEMENTATION [arm && omap3_am33xx]: - -IMPLEMENT -void -Timer::init(unsigned) -{ - switch (type()) - { - case Timer1_1ms: - // enable DMTIMER1_1MS - Io::write(2, CM_WKUP_TIMER1_CLKCTRL); - Io::read(CM_WKUP_TIMER1_CLKCTRL); - Io::write(CLKSEL_TIMER1MS_CLK_VALUE, CLKSEL_TIMER1MS_CLK); - for (int i = 0; i < 1000000; ++i) // instead, poll proper reg - asm volatile("" : : : "memory"); - Timer_omap_1mstimer::init(); - break; - case Timer0: - Io::write(2, CM_WKUP_TIMER0_CLKCTRL); - Timer_omap_gentimer::init(); - break; - } -} - -PUBLIC static inline NEEDS[Timer_omap_gentimer::acknowledge] -void Timer::acknowledge() -{ - if (type() == Timer1_1ms) - Timer_omap_1mstimer::acknowledge(); - else - Timer_omap_gentimer::acknowledge(); -} - -// ----------------------------------------------------------------------- -IMPLEMENTATION [arm && omap3]: - -#include "config.h" -#include "kip.h" - -static inline -Unsigned64 -Timer::timer_to_us(Unsigned32 /*cr*/) -{ return 0; } - -static inline -Unsigned64 -Timer::us_to_timer(Unsigned64 us) -{ (void)us; return 0; } - -IMPLEMENT inline -void -Timer::update_one_shot(Unsigned64 wakeup) -{ - (void)wakeup; -} - -IMPLEMENT inline NEEDS["config.h", "kip.h"] -Unsigned64 -Timer::system_clock() -{ - if (Config::Scheduler_one_shot) - return 0; - else - return Kip::k()->clock; -} diff --git a/kernel/fiasco/src/kern/arm/bsp/omap3/uart-arm-omap.cpp b/kernel/fiasco/src/kern/arm/bsp/omap3/uart-arm-omap.cpp deleted file mode 100644 index 53e8db3d0..000000000 --- a/kernel/fiasco/src/kern/arm/bsp/omap3/uart-arm-omap.cpp +++ /dev/null @@ -1,24 +0,0 @@ -IMPLEMENTATION [arm && (omap3_35xevm || omap3_am33xx)]: // ---------------- - -IMPLEMENT int Uart::irq() const { return 72; } - -IMPLEMENTATION [arm && omap3_beagleboard]: // ----------------------------- - -IMPLEMENT int Uart::irq() const { return 74; } - -IMPLEMENTATION [arm && omap4_pandaboard]: // ------------------------------ - -IMPLEMENT int Uart::irq() const { return 32 + 74; } - -IMPLEMENTATION: // -------------------------------------------------------- - -#include "mem_layout.h" -#include "uart_omap35x.h" - -IMPLEMENT Address Uart::base() const { return Mem_layout::Uart_base; } - -IMPLEMENT L4::Uart *Uart::uart() -{ - static L4::Uart_omap35x uart; - return &uart; -} diff --git a/kernel/fiasco/src/kern/arm/pagetable-arch.cpp b/kernel/fiasco/src/kern/arm/pagetable-arch.cpp deleted file mode 100644 index e36815914..000000000 --- a/kernel/fiasco/src/kern/arm/pagetable-arch.cpp +++ /dev/null @@ -1,732 +0,0 @@ -//--------------------------------------------------------------------------- -INTERFACE[arm]: - -class Mem_page_attr -{ - friend class Pte; - -public: - unsigned long get_ap() const; - void set_ap(unsigned long ap); - -private: - unsigned long _a; -}; - -//--------------------------------------------------------------------------- -INTERFACE[arm && armv5]: - -EXTENSION class Mem_page_attr -{ -public: - enum - { - Write = 0x400, - User = 0x800, - Ap_mask = 0xc00, - }; -}; - -//--------------------------------------------------------------------------- -INTERFACE[arm && (armv6 || armv7)]: - -EXTENSION class Mem_page_attr -{ -public: - enum - { - Write = 0x200, - User = 0x020, - Ap_mask = 0x220, - }; -}; - -//--------------------------------------------------------------------------- -INTERFACE[arm && !(mpcore || armca9)]: - -EXTENSION class Mem_page_attr -{ -public: - // do not use Shaed bit on non MP CPUs because this leads to uncached memory - // accesses most of the time! - enum { Shared = 0 }; -}; - -EXTENSION class Page_table -{ -public: - enum { Ttbr_bits = 0x0 }; -}; - -//--------------------------------------------------------------------------- -INTERFACE[arm && (mpcore || armca9)]: - -EXTENSION class Mem_page_attr -{ -public: - // use shared bit on MP CPUs as we need cache coherency - enum { Shared = 0x400 }; -}; - -//--------------------------------------------------------------------------- -INTERFACE[arm && mpcore]: - -EXTENSION class Page_table -{ -public: - enum { Ttbr_bits = 0xa }; -}; - -//--------------------------------------------------------------------------- -INTERFACE[arm && armca9]: - -EXTENSION class Page_table -{ -public: - enum - { - Ttbr_bits = (1 << 1) // S, Shareable bit - | (1 << 3) // RGN, Region bits, Outer WriteBackWriteAlloc - | (0 << 0) | (1 << 6) // IRGN, Inner region bits, WB-WA - | (1 << 5) // NOS - , - }; -}; - -//--------------------------------------------------------------------------- -INTERFACE [arm]: - -#include "paging.h" -#include "per_cpu_data.h" - -class Ram_quota; - -class Pte -{ -public: -//private: - unsigned long _pt; - Mword *_pte; - -public: - Pte(Page_table *pt, unsigned level, Mword *pte) - : _pt((unsigned long)pt | level), _pte(pte) - {} -}; - - -EXTENSION class Page_table -{ -private: - Mword raw[4096]; - enum - { - Pt_base_mask = 0xfffffc00, - Pde_type_coarse = 0x01, - }; -}; - -//--------------------------------------------------------------------------- -IMPLEMENTATION [arm && vcache]: - -PUBLIC static inline -bool -Pte::need_cache_clean() -{ - return false; -} - -//--------------------------------------------------------------------------- -IMPLEMENTATION [arm && !vcache && !armca9]: - -PUBLIC static inline -bool -Pte::need_cache_clean() -{ - return true; -} - -//--------------------------------------------------------------------------- -IMPLEMENTATION [arm && !vcache && armca9]: - -PUBLIC static inline -bool -Pte::need_cache_clean() -{ - return false; -} - -//--------------------------------------------------------------------------- -IMPLEMENTATION [arm]: - -#include -#include - -#include "mem_unit.h" -#include "kdb_ke.h" -#include "ram_quota.h" - -PUBLIC inline explicit -Mem_page_attr::Mem_page_attr(unsigned long attr) : _a(attr) -{} - -PRIVATE inline -unsigned long -Mem_page_attr::raw() const -{ return _a; } - -PUBLIC inline -void -Mem_page_attr::set_caching(unsigned long del, unsigned long set) -{ - del &= Page::Cache_mask; - set &= Page::Cache_mask; - _a = (_a & ~del) | set; -} - -PUBLIC inline NEEDS[Mem_page_attr::get_ap] -unsigned long -Mem_page_attr::get_abstract() const -{ return get_ap() | (_a & Page::Cache_mask); } - -PUBLIC inline NEEDS[Mem_page_attr::set_ap] -void -Mem_page_attr::set_abstract(unsigned long a) -{ - _a = (_a & ~Page::Cache_mask) | (a & Page::Cache_mask); - set_ap(a); -} - -PUBLIC inline NEEDS[Mem_page_attr::get_ap] -bool -Mem_page_attr::permits(unsigned long attr) -{ return (get_ap() & attr) == attr; } - -PUBLIC inline -unsigned long -Pte::valid() const -{ return *_pte & 3; } - -PUBLIC inline -unsigned long -Pte::phys() const -{ - switch(_pt & 3) - { - case 0: - switch (*_pte & 3) - { - case 2: return *_pte & ~((1 << 20) - 1); // 1MB - default: return ~0UL; - } - case 1: - switch (*_pte & 3) - { - case 2: return *_pte & ~((4 << 10) - 1); - default: return ~0UL; - } - default: return ~0UL; - } -} - -PUBLIC inline -unsigned long -Pte::phys(void *virt) -{ - unsigned long p = phys(); - return p | (((unsigned long)virt) & (size()-1)); -} - -PUBLIC inline -unsigned long -Pte::lvl() const -{ return (_pt & 3); } - -PUBLIC inline -unsigned long -Pte::raw() const -{ return *_pte; } - -PUBLIC inline -bool -Pte::superpage() const -{ return !(_pt & 3) && ((*_pte & 3) == 2); } - -PUBLIC inline -unsigned long -Pte::size() const -{ - switch(_pt & 3) - { - case 0: - switch (*_pte & 3) - { - case 2: return 1 << 20; // 1MB - default: return 1 << 20; - } - case 1: - switch (*_pte & 3) - { - case 1: return 64 << 10; - case 2: return 4 << 10; - case 3: return 1 << 10; - default: return 4 << 10; - } - default: return 0; - } -} - - -PRIVATE inline NEEDS["mem_unit.h"] -void -Pte::__set(unsigned long v, bool write_back) -{ - *_pte = v; - if (write_back || need_cache_clean()) - Mem_unit::clean_dcache(_pte); -} - -PUBLIC inline NEEDS[Pte::__set] -void -Pte::set_invalid(unsigned long val, bool write_back) -{ __set(val & ~3, write_back); } - - -//----------------------------------------------------------------------------- -IMPLEMENTATION [arm && armv5]: - -IMPLEMENT inline -unsigned long -Mem_page_attr::get_ap() const -{ - static unsigned char const _map[4] = { 0x8, 0x4, 0x0, 0xc }; - return ((unsigned long)_map[(_a >> 10) & 0x3]) << 8UL; -} - -IMPLEMENT inline -void -Mem_page_attr::set_ap(unsigned long ap) -{ - static unsigned char const _map[4] = { 0x4, 0x4, 0x0, 0xc }; - _a = (_a & ~0xc00) | (((unsigned long)_map[(ap >> 10) & 0x3]) << 8UL); -} - -PUBLIC inline NEEDS[Pte::__set, Mem_page_attr::raw] -void -Pte::set(Address phys, unsigned long size, Mem_page_attr const &attr, - bool write_back) -{ - switch (_pt & 3) - { - case 0: - if (size != (1 << 20)) - return; - __set(phys | (attr.raw() & Page::MAX_ATTRIBS) | 2, write_back); - break; - case 1: - { - if (size != (4 << 10)) - return; - unsigned long ap = attr.raw() & 0xc00; ap |= ap >> 2; ap |= ap >> 4; - __set(phys | (attr.raw() & 0x0c) | ap | 2, write_back); - } - break; - } -} - -PUBLIC inline NEEDS[Mem_page_attr::Mem_page_attr] -Mem_page_attr -Pte::attr() const { return Mem_page_attr(*_pte & 0xc0c); } - -PUBLIC inline NEEDS["mem_unit.h"] -void -Pte::attr(Mem_page_attr const &attr, bool write_back) -{ - switch (_pt & 3) - { - case 0: - __set((*_pte & ~0xc0c) | (attr.raw() & 0xc0c), write_back); - break; - case 1: - { - unsigned long ap = attr.raw() & 0xc00; ap |= ap >> 2; ap |= ap >> 4; - __set((*_pte & ~0xffc) | (attr.raw() & 0x0c) | ap, write_back); - } - break; - } -} - -PUBLIC /*inline*/ -void Page_table::activate() -{ - Pte p = walk(this, 0, false, Ptab::Null_alloc(), 0); - Mem_unit::flush_vcache(); - asm volatile ( - "mcr p15, 0, r0, c8, c7, 0 \n" // TLB flush - "mcr p15, 0, %0, c2, c0 \n" // pdbr - - "mrc p15, 0, r1, c2, c0 \n" - "mov r1, r1 \n" - "sub pc, pc, #4 \n" - : - : "r" (p.phys(this)) - : "r1"); -} - - -//----------------------------------------------------------------------------- -IMPLEMENTATION [arm && (armv6 || armv7)]: - -IMPLEMENT inline -unsigned long -Mem_page_attr::get_ap() const -{ - return (_a & User) | ((_a & Write) ^ Write); -} - -IMPLEMENT inline NEEDS[Mem_page_attr::raw] -void -Mem_page_attr::set_ap(unsigned long ap) -{ - _a = (_a & ~(User | Write)) | (ap & User) | ((ap & Write) ^ Write) | 0x10; -} - -PUBLIC inline NEEDS[Pte::__set] -void -Pte::set(Address phys, unsigned long size, Mem_page_attr const &attr, - bool write_back) -{ - switch (_pt & 3) - { - case 0: - if (size != (1 << 20)) - return; - { - unsigned long a = attr.raw() & 0x0c; // C & B - a |= ((attr.raw() & 0xff0) | Mem_page_attr::Shared) << 6; - __set(phys | a | 0x2, write_back); - } - break; - case 1: - if (size != (4 << 10)) - return; - __set(phys | (attr.raw() & Page::MAX_ATTRIBS) | 0x2 | Mem_page_attr::Shared, write_back); - break; - } -} - -PUBLIC inline NEEDS[Mem_page_attr::raw] -Mem_page_attr -Pte::attr() const -{ - switch (_pt & 3) - { - case 0: - { - unsigned long a = *_pte & 0x0c; // C & B - a |= (*_pte >> 6) & 0xff0; - return Mem_page_attr(a); - } - case 1: - default: - return Mem_page_attr(*_pte & Page::MAX_ATTRIBS); - } -} - -PUBLIC inline NEEDS["mem_unit.h", Mem_page_attr::raw] -void -Pte::attr(Mem_page_attr const &attr, bool write_back) -{ - switch (_pt & 3) - { - case 1: - __set((*_pte & ~Page::MAX_ATTRIBS) - | (attr.raw() & Page::MAX_ATTRIBS), write_back); - break; - case 0: - { - unsigned long a = attr.raw() & 0x0c; - a |= (attr.raw() & 0xff0) << 6; - __set((*_pte & ~0x3fcc) | a, write_back); - } - break; - } -} - -//----------------------------------------------------------------------------- -IMPLEMENTATION [armv6 || armca8]: - -PUBLIC -void Page_table::activate(unsigned long asid) -{ - Pte p = walk(this, 0, false, Ptab::Null_alloc(), 0); - asm volatile ( - "mcr p15, 0, %2, c7, c5, 6 \n" // bt flush - "mcr p15, 0, r0, c7, c10, 4 \n" // dsb - "mcr p15, 0, %0, c2, c0 \n" // set TTBR - "mcr p15, 0, r0, c7, c10, 4 \n" // dsb - "mcr p15, 0, %1, c13, c0, 1 \n" // set new ASID value - "mcr p15, 0, r0, c7, c5, 4 \n" // isb - "mcr p15, 0, %2, c7, c5, 6 \n" // bt flush - "mrc p15, 0, r1, c2, c0 \n" - "mov r1, r1 \n" - "sub pc, pc, #4 \n" - : - : "r" (p.phys(this) | Ttbr_bits), "r"(asid), "r" (0) - : "r1"); -} - -//----------------------------------------------------------------------------- -IMPLEMENTATION [armv7 && armca9]: - -PUBLIC -void Page_table::activate(unsigned long asid) -{ - Pte p = walk(this, 0, false, Ptab::Null_alloc(), 0); - asm volatile ( - "mcr p15, 0, %2, c7, c5, 6 \n" // bt flush - "dsb \n" - "mcr p15, 0, %2, c13, c0, 1 \n" // change ASID to 0 - "isb \n" - "mcr p15, 0, %0, c2, c0 \n" // set TTBR - "isb \n" - "mcr p15, 0, %1, c13, c0, 1 \n" // set new ASID value - "isb \n" - "mcr p15, 0, %2, c7, c5, 6 \n" // bt flush - "isb \n" - "mov r1, r1 \n" - "sub pc, pc, #4 \n" - : - : "r" (p.phys(this) | Ttbr_bits), "r"(asid), "r" (0) - : "r1"); -} - -//----------------------------------------------------------------------------- -IMPLEMENTATION [arm && !mp]: - -PRIVATE inline -Mword -Page_table::current_virt_to_phys(void *virt) -{ - return walk(virt, 0, false, Ptab::Null_alloc(), 0).phys(virt); -} - -//----------------------------------------------------------------------------- -IMPLEMENTATION [arm && mp]: - -/* - * This version for MP avoids calling Page_table::current() which calls - * current_cpu() which is not available on the boot-stack. That's why we use - * the following way of doing a virt->phys translation on the current page - * table. - */ -PRIVATE inline -Mword -Page_table::current_virt_to_phys(void *virt) -{ - Mword phys; - Mword offset = (Mword)virt & ~Config::PAGE_MASK; - asm volatile("mcr p15,0,%1,c7,c8,0 \n" - "mrc p15,0,%0,c7,c4,0 \n" - : "=r" (phys) - : "r" ((Mword)virt & Config::PAGE_MASK)); - return (phys & Config::PAGE_MASK) | offset; -} - - -//----------------------------------------------------------------------------- -IMPLEMENTATION [arm]: - -#include -#include "bug.h" -#include "auto_quota.h" -#include "mem.h" -#if 0 -IMPLEMENT -void *Page_table::operator new(size_t s) throw() -{ - (void)s; - assert(s == 16*1024); - return alloc()->alloc(14); // 2^14 = 16K -} - -IMPLEMENT -void Page_table::operator delete(void *b) -{ - alloc()->free(14, b); -} -#endif - -IMPLEMENT -Page_table::Page_table() -{ - Mem::memset_mwords(raw, 0, sizeof(raw) / sizeof(Mword)); - if (Pte::need_cache_clean()) - Mem_unit::clean_dcache(raw, (char *)raw + sizeof(raw)); -} - - -PUBLIC template< typename ALLOC > -void Page_table::free_page_tables(void *start, void *end, ALLOC const &a) -{ - for (unsigned i = (Address)start >> 20; i < ((Address)end >> 20); ++i) - { - Pte p(this, 0, raw + i); - if (p.valid() && !p.superpage()) - { - void *pt = (void*)Mem_layout::phys_to_pmem(p.raw() & Pt_base_mask); - - BUG_ON(pt == (void*)~0UL, "cannot get virtual (pmem) address for %lx (pte @ %p)\n", - p.raw() & Pt_base_mask, p._pte); - - a.free(pt, 1<<10); - } - } -} - -PRIVATE inline -static unsigned Page_table::pd_index( void const *const address ) -{ - return (Mword)address >> 20; // 1MB steps -} - -PRIVATE inline -static unsigned Page_table::pt_index( void const *const address ) -{ - return ((Mword)address >> 12) & 255; // 4KB steps for coarse pts -} - -PUBLIC template< typename Alloc > -inline NEEDS[, "bug.h", Page_table::pd_index, - Page_table::current_virt_to_phys, Page_table::pt_index] -Pte -Page_table::walk(void *va, unsigned long size, bool write_back, Alloc const &q, - Page_table *ldir) -{ - unsigned const pd_idx = pd_index(va); - - Mword *pt = 0; - - Pte pde(this, 0, raw + pd_idx); - - if (!pde.valid()) - { - if (size == (4 << 10)) - { - assert (q.valid()); - pt = (Mword*)q.alloc(1<<10); - if (EXPECT_FALSE(!pt)) - return pde; - - Mem::memset_mwords(pt, 0, 1024 >> 2); - - if (write_back || Pte::need_cache_clean()) - Mem_unit::clean_dcache(pt, (char*)pt + 1024); - - raw[pd_idx] = ldir->current_virt_to_phys(pt) | Pde_type_coarse; - - if (write_back || Pte::need_cache_clean()) - Mem_unit::clean_dcache(raw + pd_idx); - } - else - return pde; - } - else if (pde.superpage()) - return pde; - - if (!pt) - pt = (Mword *)Mem_layout::phys_to_pmem(pde.raw() & Pt_base_mask); - - BUG_ON(pt == (void*)~0UL, "could not get virtual address for %lx (from pte @%p)\n", - pde.raw(), pde._pte); - - return Pte(this, 1, pt + pt_index(va)); -} - - -IMPLEMENT -void Page_table::init() -{ - unsigned domains = 0x0001; - - asm volatile ( - "mcr p15, 0, %0, c3, c0 \n" // domains - : - : "r"(domains) ); -} - - -IMPLEMENT /*inline*/ -void Page_table::copy_in(void *my_base, Page_table *o, - void *base, size_t size, unsigned long asid) -{ - unsigned pd_idx = pd_index(my_base); - unsigned pd_idx_max = pd_index(my_base) + pd_index((void*)size); - unsigned o_pd_idx = pd_index(base); - bool need_flush = false; - - //printf("copy_in: %03x-%03x from %03x\n", pd_idx, pd_idx_max, o_pd_idx); - - if (asid != ~0UL) - { - for (unsigned i = pd_idx; i < pd_idx_max; ++i) - if (Pte(this, 0, raw + i).valid()) - { - Mem_unit::flush_vdcache(); - need_flush = true; - break; - } - } - - for (unsigned i = pd_idx; i < pd_idx_max; ++i, ++o_pd_idx) - raw[i] = o->raw[o_pd_idx]; - - if (Pte::need_cache_clean()) - Mem_unit::clean_dcache(raw + pd_idx, raw + pd_idx_max); - - if (need_flush && (asid != ~0UL)) - Mem_unit::dtlb_flush(asid); -} - -#if 0 -PUBLIC -void -Page_table::invalidate(void *my_base, unsigned size, unsigned long asid = ~0UL) -{ - unsigned pd_idx = pd_index(my_base); - unsigned pd_idx_max = pd_index(my_base) + pd_index((void*)size); - bool need_flush = false; - - //printf("invalidate: %03x-%03x\n", pd_idx, pd_idx_max); - - if (asid != ~0UL) - { - for (unsigned i = pd_idx; i < pd_idx_max; ++i) - if (Pte(this, 0, raw + i).valid()) - { - Mem_unit::flush_vdcache(); - need_flush = true; - break; - } - } - - for (unsigned i = pd_idx; i < pd_idx_max; ++i) - raw[i] = 0; - - // clean the caches if manipulating the current pt or in the case if phys. - // tagged caches. - if ((asid != ~0UL) || Pte::need_cache_clean()) - Mem_unit::clean_dcache(raw + pd_idx, raw + pd_idx_max); - - if (need_flush && (asid != ~0UL)) - Mem_unit::tlb_flush(asid); -} -#endif - -IMPLEMENT -void * -Page_table::dir() const -{ - return const_cast(this); -} - diff --git a/kernel/fiasco/src/kern/arm/pagetable-arch_defs.h b/kernel/fiasco/src/kern/arm/pagetable-arch_defs.h deleted file mode 100644 index 3d2161396..000000000 --- a/kernel/fiasco/src/kern/arm/pagetable-arch_defs.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef __PAGETABLE_ARCH_DEFS_H__ -#define __PAGETABLE_ARCH_DEFS_H__ - -struct Fld_coarse -{ - mword_t type : 2; // must be 0x01 - mword_t imp : 3; // Implementation defined - mword_t domain : 4; - mword_t sbz : 1; // should be zero - mword_t ptb : MWORD_BITS - 10; // ptb >> 10 -}; - -struct Fld_fine -{ - mword_t type : 2; // must be 0x03 - mword_t imp : 3; // Implementation defined - mword_t domain : 4; - mword_t sbz : 3; // should be zero - mword_t ptb : MWORD_BITS - 12;// ptb >> 12 -}; - -struct Fld_section -{ - mword_t type : 2; // must be 0x02 - mword_t cb : 2; // cachable and bufferable - mword_t imp : 1; // implementation defined - mword_t domain : 4; - mword_t sbz1 : 1; // should be zero - mword_t ap : 2; // protection - mword_t sbz2 : 8; // should be zero 2 - mword_t sb : MWORD_BITS - 20; // sb >> 20 -}; - -struct Fld_empty -{ - mword_t type : 2; // must bew 0x00 - mword_t udef : MWORD_BITS - 2; -}; - -union Fld -{ - Fld_empty e; - Fld_section s; - Fld_coarse c; - Fld_fine f; - mword_t raw; -}; - - -struct Sld_large -{ - mword_t type : 2; // must be 0x01 - mword_t cb : 2; // cache & buffer - mword_t ap0 : 2; - mword_t ap1 : 2; - mword_t ap2 : 2; - mword_t ap3 : 2; - mword_t sbz : 4; // should be zwero - mword_t pb : MWORD_BITS - 16; -}; - -struct Sld_small -{ - mword_t type : 2; // must be 0x02 - mword_t cb : 2; // cache & buffer - mword_t ap0 : 2; - mword_t ap1 : 2; - mword_t ap2 : 2; - mword_t ap3 : 2; - mword_t pb : MWORD_BITS - 12; -}; - -struct Sld_tiny -{ - mword_t type : 2; // must be 0x03 - mword_t cb : 2; // cache & buffer - mword_t ap : 2; - mword_t sbz : 4; - mword_t pb : MWORD_BITS - 10; -}; - -struct Sld_empty -{ - mword_t type : 2; // must be 0x00 - mword_t udef : MWORD_BITS - 2; -}; - -union Sld -{ - Sld_empty e; - Sld_tiny t; - Sld_small s; - Sld_large l; - mword_t raw; -}; - -#endif // __PAGETABLE_ARCH_DEFS_H__ diff --git a/kernel/fiasco/src/kern/arm/pagetable.cpp b/kernel/fiasco/src/kern/arm/pagetable.cpp deleted file mode 100644 index dccb383d5..000000000 --- a/kernel/fiasco/src/kern/arm/pagetable.cpp +++ /dev/null @@ -1,37 +0,0 @@ -INTERFACE: - -#include "paging.h" - -class Pte; -class Mem_page_attr; - -class Page_table //: public Page_table_defs -{ -public: - - enum Status { - E_OK = 0, - E_NOMEM, - E_EXISTS, - E_UPGRADE, - E_INVALID, - }; - -#if 0 - void * operator new(size_t) throw(); - void operator delete(void *); -#endif - static void init(); - - Page_table(); - - void copy_in(void *my_base, Page_table *o, - void *base, size_t size = 0, unsigned long asid = ~0UL); - - void *dir() const; - - static size_t num_page_sizes(); - static size_t const *page_sizes(); - static size_t const *page_shifts(); -}; - diff --git a/kernel/fiasco/src/lib/libk/bitfield b/kernel/fiasco/src/lib/libk/bitfield deleted file mode 100644 index 8b637e40e..000000000 --- a/kernel/fiasco/src/lib/libk/bitfield +++ /dev/null @@ -1,248 +0,0 @@ -// vi: ft=cpp -/* - * (c) 2012 Alexander Warg , - * economic rights: Technische Universität Dresden (Germany) - * - * This file is part of TUD:OS and distributed under the terms of the - * GNU General Public License 2. - * Please see the COPYING-GPL-2 file for details. - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - */ - -#pragma once - -#include - -/** \brief Our C++ library. */ -namespace cxx { - -/** \brief Definition for a member (part) of a bit field. - * - * \param T the underlying type of the bit field. - * \param LSB the least significant bit of our bits. - * \param MSB the mos significant bit if our bits. - */ -template -class Bitfield -{ -private: - static_assert(MSB >= LSB, "boundary mismatch in bit-field definition"); - static_assert(MSB < sizeof(T) * 8, "MSB outside of bit-field type"); - static_assert(LSB < sizeof(T) * 8, "LSB outside of bit-field type"); - - /** \brief Get the best unsigned type for \a bits. - * \param BITS number of bits to cover - */ - template struct Best_type - { - template< typename TY > struct Cmp { enum { value = (BITS <= sizeof(TY)*8) }; }; - typedef cxx::type_list< - unsigned char, - unsigned short, - unsigned int, - unsigned long, - unsigned long long - > Unsigned_types; - typedef typename cxx::find_type::type Type; - }; - -public: - enum - { - Bits = MSB + 1 - LSB, ///< Number of bits - Lsb = LSB, ///< index of the LSB - Msb = MSB, ///< index of the MSB - }; - - enum Masks : T - { - /** Mask value to get #Bits bits. */ - Low_mask = ((T)~0ULL) >> (sizeof(T)*8 - Bits), - /** Mask value to the bits out of a \a T. */ - Mask = Low_mask << Lsb, - }; - - /** \brief Type to hold at least #Bits bits. - * - * This type can handle all values that can be stored in this part of the bit - * field. - */ - typedef typename Best_type::Type Bits_type; - - /** \brief Type to hold at least #Bits + #Lsb bits. - * - * This type can handle all values that can be stored in this part of the bit - * field when they are at the target location (#Lsb bits shifted to the - * left). - */ - typedef typename Best_type::Type Shift_type; - -private: - static_assert(sizeof(Bits_type)*8 >= Bits, "error finding the type to store the bits"); - static_assert(sizeof(Shift_type)*8 >= Bits + Lsb, "error finding the type to keep the shifted bits"); - static_assert(sizeof(Bits_type) <= sizeof(T), "size mismatch for Bits_type"); - static_assert(sizeof(Shift_type) <= sizeof(T), "size mismatch for Shift_type"); - static_assert(sizeof(Bits_type) <= sizeof(Shift_type), "size mismacht for Shift_type and Bits_type"); - -public: - /** \brief Get the bits out of \a val. - * \param val the raw value of the whole bit field. - * \return the bits form #Lsb to #Msb shifted to the right. - */ - static Bits_type get(Shift_type val) - { return (val >> Lsb) & Low_mask; } - - /** \brief Get the bits in place out of \val. - * \param val the raw value of the whole bit field. - * \return the bits from #Lsb to #Msb (unshifted). - * - * This means other bits are masked out, however the result is not shifted to - * the right, - */ - static T get_unshifted(Shift_type val) - { return val & Mask; } - - /** \brief Set the bits corresponding to \a val. - * \param dest the current value of the whole bit field. - * \param val the value to set into the bits. - * \return the new value of the whole bit field. - * \pre \a val must contain not more than bits than #Bits. - * \note This function does not mask \a val to the right number of bits. - */ - static T set_dirty(T dest, Shift_type val) - { - //assert (!(val & ~Low_mask)); - return (dest & ~Mask) | (val << Lsb); - } - - /** \brief Set the bits corresponding to \a val. - * \param dest the current value of the whole bit field. - * \param val the value shifted #Lsb bits to the left that shall be set into - * the bits. - * \return the new value of the whole bit field. - * \pre \a val must contain not more than bits than #Bits shifted #Lsb bits - * to the left. - * \note This function does not mask \a val to the right number of bits. - */ - static T set_unshifted_dirty(T dest, Shift_type val) - { - //assert (!(val & ~Mask)); - return (dest & ~Mask) | val; - } - - /** \brief Set the bits corresponding to \a val. - * \param dest the current value of the whole bit field. - * \param val the value to set into the bits. - * \return the new value of the whole bit field. - */ - static T set(T dest, Bits_type val) - { return set_dirty(dest, val & Low_mask); } - - /** \brief Set the bits corresponding to \a val. - * \param dest the current value of the whole bit field. - * \param val the value shifted #Lsb bits to the left that shall be set into - * the bits. - * \return the new value of the whole bit field. - */ - static T set_unshifted(T dest, Shift_type val) - { return set_unshifted_dirty(dest, val & Mask); } - - /** \brief Get the shifted bits for \a val. - * \param val the value to set into the bits. - * \return the raw bit field value containing. - * \pre \a val must contain not more than bits than #Bits. - * \note This function does not mask \a val to the right number of bits. - */ - static T val_dirty(Shift_type val) { return val << Lsb; } - - /** \brief Get the shifted bits for \a val. - * \param val the value to set into the bits. - * \return the raw bit field value containing. - */ - static T val(Bits_type val) { return val_dirty(val & Low_mask); } - - /** \brief Get the shifted bits for \a val. - * \param val the value shifted #Lsb bits to the left that shall be set into - * the bits. - * \return the raw bit field value containing. - */ - static T val_unshifted(Shift_type val) { return val & Mask; } - - /** Internal helper type */ - template< typename TT > - class Value_base - { - private: - TT v; - - public: - Value_base(TT t) : v(t) {} - Bits_type get() const { return Bitfield::get(v); } - T get_unshifted() const { return Bitfield::get_unshifted(v); } - - void set(Bits_type val) { v = Bitfield::set(v, val); } - void set_dirty(Bits_type val) { v = Bitfield::set_dirty(v, val); } - void set_unshifted(Shift_type val) { v = Bitfield::set_unshifted(v, val); } - void set_unshifted_dirty(Shift_type val) { v = Bitfield::set_unshifted_dirty(v, val); } - }; - - /** Internal helper type */ - template< typename TT > - class Value : public Value_base - { - public: - Value(TT t) : Value_base(t) {} - operator Bits_type () const { return this->get(); } - Value &operator = (Bits_type val) { this->set(val); return *this; } - }; - - /** Internal helper type */ - template< typename TT > - class Value_unshifted : public Value_base - { - public: - Value_unshifted(TT t) : Value_base(t) {} - operator Shift_type () const { return this->get_unshifted(); } - Value_unshifted &operator = (Shift_type val) { this->set_unshifted(val); return *this; } - }; - - /** Reference type to access the bits inside a raw bit field. */ - typedef Value Ref; - /** Value type to access the bits inside a raw bit field. */ - typedef Value Val; - - /** Reference type to access the bits inside a raw bit field (in place). */ - typedef Value_unshifted Ref_unshifted; - /** Value type to access the bits inside a raw bit field (in place). */ - typedef Value_unshifted Val_unshifted; -}; - -#define CXX_BITFIELD_MEMBER(LSB, MSB, name, data_member) \ - /** @{ */ \ - /** \brief Type to access the \a name bits (LSB to MSB) of \a data_member. */ \ - typedef cxx::Bitfield name ## _bfm_t; \ - /** \brief Get the \a name bits (LSB to MSB) of \a data_member. */ \ - name ## _bfm_t::Val name() const { return data_member; } \ - /** \brief Get a reference to the \a name bits (LSB to MSB) of \a data_member. */ \ - name ## _bfm_t::Ref name() { return data_member; } \ - /** @} */ - -#define CXX_BITFIELD_MEMBER_UNSHIFTED(LSB, MSB, name, data_member) \ - /** @{ */ \ - /** \brief Type to access the \a name bits (LSB to MSB) of \a data_member. */ \ - typedef cxx::Bitfield name ## _bfm_t; \ - /** \brief Get the \a name bits (LSB to MSB) of \a data_member. */ \ - name ## _bfm_t::Val_unshifted name() const { return data_member; } \ - /** \brief Get a reference to the \a name bits (LSB to MSB) of \a data_member. */ \ - name ## _bfm_t::Ref_unshifted name() { return data_member; } \ - /** @} */ - -} diff --git a/kernel/fiasco/src/lib/libk/bits/list_basics.h b/kernel/fiasco/src/lib/libk/bits/list_basics.h deleted file mode 100644 index cfb27280f..000000000 --- a/kernel/fiasco/src/lib/libk/bits/list_basics.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * (c) 2011 Alexander Warg - * economic rights: Technische Universität Dresden (Germany) - * - * This file is part of TUD:OS and distributed under the terms of the - * GNU General Public License 2. - * Please see the COPYING-GPL-2 file for details. - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - */ - -#pragma once - -namespace cxx { namespace Bits { - -template< typename T > -class List_iterator_end_ptr -{ -private: - template< typename U > friend class Basic_list; - static void *_end; -}; - -template< typename T > -void *List_iterator_end_ptr::_end; - -template< typename VALUE_T, typename TYPE > -struct Basic_list_policy -{ - typedef VALUE_T *Value_type; - typedef VALUE_T const *Const_value_type; - typedef TYPE **Type; - typedef TYPE *Const_type; - typedef TYPE *Head_type; - - static Type next(Type c) { return &(*c)->_n; } - static Const_type next(Const_type c) { return c->_n; } -}; - -template< typename POLICY > -class Basic_list -{ - Basic_list(Basic_list const &) = delete; - void operator = (Basic_list const &) = delete; - -public: - typedef typename POLICY::Value_type Value_type; - typedef typename POLICY::Const_value_type Const_value_type; - - class End_iterator {}; - - class Iterator - { - private: - typedef typename POLICY::Type Internal_type; - - public: - typedef typename POLICY::Value_type value_type; - typedef typename POLICY::Value_type Value_type; - - Value_type operator * () const { return static_cast(*_c); } - Value_type operator -> () const { return static_cast(*_c); } - Iterator operator ++ () { _c = POLICY::next(_c); return *this; } - - bool operator == (End_iterator const &) const { return *_c == 0; } - bool operator != (End_iterator const &) const { return *_c != 0; } - bool operator == (Iterator const &o) const { return *_c == *o._c; } - bool operator != (Iterator const &o) const { return !operator == (o); } - - Iterator() {} - Iterator(End_iterator const &) : _c(__end()) {} - - private: - friend class Basic_list; - static Internal_type __end() - { - union X { Internal_type l; void **v; } z; - z.v = &Bits::List_iterator_end_ptr::_end; - return z.l; - } - - explicit Iterator(Internal_type i) : _c(i) {} - - Internal_type _c; - }; - - class Const_iterator - { - private: - typedef typename POLICY::Const_type Internal_type; - - public: - typedef typename POLICY::Value_type value_type; - typedef typename POLICY::Value_type Value_type; - - Value_type operator * () const { return static_cast(_c); } - Value_type operator -> () const { return static_cast(_c); } - Const_iterator operator ++ () { _c = POLICY::next(_c); return *this; } - - bool operator == (End_iterator const &) const { return _c == 0; } - bool operator != (End_iterator const &) const { return _c != 0; } - bool operator == (Const_iterator const &o) const { return _c == o._c; } - bool operator != (Const_iterator const &o) const { return !operator == (o); } - - Const_iterator() {} - Const_iterator(End_iterator const &) : _c(0) {} - Const_iterator(Iterator const &o) : _c(*o) {} - - private: - friend class Basic_list; - - explicit Const_iterator(Internal_type i) : _c(i) {} - - Internal_type _c; - }; - - // BSS allocation - explicit Basic_list(bool) {} - Basic_list() : _f(0) {} - - Basic_list(Basic_list &&o) : _f(o._f) - { - o.clear(); - } - - Basic_list &operator = (Basic_list &&o) - { - _f = o._f; - o.clear(); - return *this; - } - - bool empty() const { return !_f; } - Value_type front() const { return static_cast(_f); } - - void clear() { _f = 0; } - - Iterator begin() { return Iterator(&_f); } - Const_iterator begin() const { return Const_iterator(_f); } - static Const_iterator iter(Const_value_type c) { return Const_iterator(c); } - static End_iterator end() { return End_iterator(); } - -protected: - static typename POLICY::Type __get_internal(Iterator const &i) { return i._c; } - static Iterator __iter(typename POLICY::Type c) { return Iterator(c); } - - typename POLICY::Head_type _f; -}; - -}} - diff --git a/kernel/fiasco/src/lib/libk/dlist b/kernel/fiasco/src/lib/libk/dlist deleted file mode 100644 index 81a16da36..000000000 --- a/kernel/fiasco/src/lib/libk/dlist +++ /dev/null @@ -1,270 +0,0 @@ -// vi:ft=cpp -/* - * (c) 2011 Alexander Warg - * economic rights: Technische Universität Dresden (Germany) - * - * This file is part of TUD:OS and distributed under the terms of the - * GNU General Public License 2. - * Please see the COPYING-GPL-2 file for details. - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - */ - -#pragma once - -namespace cxx { - -class D_list_item -{ -public: - D_list_item() : _dli_next(0) {} -private: - friend struct D_list_item_policy; - - D_list_item(D_list_item const &); - void operator = (D_list_item const &); - - D_list_item *_dli_next, *_dli_prev; -}; - -struct D_list_item_policy -{ - typedef D_list_item Item; - static D_list_item *&prev(D_list_item *e) { return e->_dli_prev; } - static D_list_item *&next(D_list_item *e) { return e->_dli_next; } -}; - -template< typename T > -struct Sd_list_head_policy -{ - typedef T *Head_type; - static T *head(Head_type h) { return h; } - static void set_head(Head_type &h, T *v) { h = v; } -}; - -template< - typename T, - typename C = D_list_item_policy -> -class D_list_cyclic -{ -protected: - template< typename VALUE, typename ITEM > - class __Iterator - { - public: - typedef VALUE *Value_type; - typedef VALUE *value_type; - - __Iterator() {} - - bool operator == (__Iterator const &o) const - { return _c == o._c; } - - bool operator != (__Iterator const &o) const - { return _c != o._c; } - - __Iterator &operator ++ () - { - _c = C::next(_c); - return *this; - } - - __Iterator &operator -- () - { - _c = C::prev(_c); - return *this; - } - - Value_type operator * () const { return static_cast(_c); } - Value_type operator -> () const { return static_cast(_c); } - - private: - friend class D_list_cyclic; - - explicit __Iterator(ITEM *s) : _c(s) {} - - ITEM *_c; - }; - -public: - typedef T *Value_type; - typedef T *value_type; - typedef __Iterator Iterator; - typedef Iterator Const_iterator; - - static void remove(T *e) - { - C::next(C::prev(e)) = C::next(e); - C::prev(C::next(e)) = C::prev(e); - C::next(e) = 0; - } - - static Iterator erase(Iterator const &e) - { - typename C::Item *n = C::next(*e); - remove(*e); - return __iter(n); - } - - static Iterator iter(T const *e) { return Iterator(const_cast(e)); } - - static bool in_list(T const *e) { return C::next(const_cast(e)); } - static bool has_sibling(T const *e) { return C::next(const_cast(e)) != e; } - - static Iterator insert_after(T *e, Iterator const &pos) - { - C::prev(e) = *pos; - C::next(e) = C::next(*pos); - C::prev(C::next(*pos)) = e; - C::next(*pos) = e; - return pos; - } - - static Iterator insert_before(T *e, Iterator const &pos) - { - C::next(e) = *pos; - C::prev(e) = C::prev(*pos); - C::next(C::prev(*pos)) = e; - C::prev(*pos) = e; - return pos; - } - - static T *self_insert(T *e) - { C::next(e) = C::prev(e) = e; return e; } - - static void remove_last(T *e) - { C::next(e) = 0; } - -protected: - static Iterator __iter(typename C::Item *e) { return Iterator(e); } -}; - -template< - typename T, - typename C = D_list_item_policy, - typename H = Sd_list_head_policy, - bool BSS = false -> -class Sd_list : public D_list_cyclic -{ -private: - typedef D_list_cyclic Base; - -public: - typedef typename Base::Iterator Iterator; - enum Pos - { Back, Front }; - - Sd_list() { if (!BSS) H::set_head(_f, 0); } - - bool empty() const { return !H::head(_f); } - T *front() const { return H::head(_f); } - - void remove(T *e) - { - T *h = H::head(_f); - if (e == C::next(e)) // must be the last - { - Base::remove_last(e); - H::set_head(_f, 0); - return; - } - - if (e == H::head(_f)) - H::set_head(_f, static_cast(C::next(h))); - - Base::remove(e); - } - - Iterator erase(Iterator const &e) - { - typename C::Item *n = C::next(*e); - remove(*e); - return __iter(n); - } - - void push(T *e, Pos pos) - { - T *h = H::head(_f); - if (!h) - H::set_head(_f, Base::self_insert(e)); - else - { - Base::insert_before(e, this->iter(h)); - if (pos == Front) - H::set_head(_f, e); - } - } - - void push_back(T *e) { push(e, Back); } - void push_front(T *e) { push(e, Front); } - void rotate_to(T *h) { H::set_head(_f, h); } - - typename H::Head_type const &head() const { return _f; } - typename H::Head_type &head() { return _f; } - -private: - Sd_list(Sd_list const &); - void operator = (Sd_list const &); - - typename H::Head_type _f; -}; - -template< - typename T, - typename C = D_list_item_policy, - bool BSS = false -> -class D_list : public D_list_cyclic -{ -private: - typedef D_list_cyclic Base; - typedef typename C::Item Internal_type; - -public: - enum Pos - { Back, Front }; - - typedef typename Base::Iterator Iterator; - typedef typename Base::Const_iterator Const_iterator; - typedef T* value_type; - typedef T* Value_type; - - D_list() { this->self_insert(static_cast(&_h)); } - - bool empty() const { return C::next(static_cast(&_h)) == &_h; } - - void remove(T *e) { Base::remove(e); } - void erase(Iterator const &e) { return Base::erase(e); } - - void push(T *e, Pos pos) - { - if (pos == Front) - Base::insert_after(e, end()); - else - Base::insert_before(e, end()); - } - - void push_back(T *e) { push(e, Back); } - void push_front(T *e) { push(e, Front); } - - Iterator begin() const { return this->__iter(C::next(const_cast(&_h))); } - Iterator end() const { return this->__iter(const_cast(&_h)); } - -private: - D_list(D_list const &); - void operator = (D_list const &); - - Internal_type _h; -}; - -} - diff --git a/kernel/fiasco/src/lib/libk/hlist b/kernel/fiasco/src/lib/libk/hlist deleted file mode 100644 index 187eb1c6e..000000000 --- a/kernel/fiasco/src/lib/libk/hlist +++ /dev/null @@ -1,137 +0,0 @@ -// vi:ft=cpp -/* - * (c) 2011 Alexander Warg - * economic rights: Technische Universität Dresden (Germany) - * - * This file is part of TUD:OS and distributed under the terms of the - * GNU General Public License 2. - * Please see the COPYING-GPL-2 file for details. - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - */ - -#pragma once - -#include "bits/list_basics.h" - -namespace cxx { - -class H_list_item -{ -public: - H_list_item() : _pn(0) {} - ~H_list_item() { l_remove(); } - -private: - H_list_item(H_list_item const &); - void operator = (H_list_item const &); - - template friend class H_list; - template friend struct Bits::Basic_list_policy; - - void l_remove() - { - if (!_pn) - return; - - *_pn = _n; - if (_n) - _n->_pn = _pn; - - _pn = 0; - } - - H_list_item *_n, **_pn; -}; - -template< typename T, typename POLICY = Bits::Basic_list_policy< T, H_list_item > > -class H_list : public Bits::Basic_list -{ -private: - typedef Bits::Basic_list Base; - H_list(H_list const &); - void operator = (H_list const &); - -public: - typedef typename Base::Iterator Iterator; - - // BSS allocation - explicit H_list(bool x) : Base(x) {} - H_list() : Base() {} - - static Iterator iter(T *c) { return Base::__iter(c->_pn); } - - static bool in_list(T const *e) { return e->_pn; } - - void add(T *e) - { - if (this->_f) - this->_f->_pn = &e->_n; - e->_n = this->_f; - e->_pn = &this->_f; - this->_f = e; - } - - void push_front(T *e) { add(e); } - - void insert(T *e, Iterator const &pred) - { - H_list_item **x = &this->_f; - if (pred != Base::end()) - x = &(*pred)->_n; - - e->_n = *x; - - if (*x) - (*x)->_pn = &(e->_n); - - e->_pn = x; - *x = e; - } - - static void insert_before(T *e, Iterator const &succ) - { - H_list_item **x = Base::__get_internal(succ); - - e->_n = *x; - e->_pn = x; - - if (*x) - (*x)->_pn = &e->_n; - - *x = e; - } - - static void replace(T *p, T *e) - { - e->_n = p->_n; - e->_pn = p->_pn; - *(p->_pn) = e; - if (e->_n) - e->_n->_pn = &(e->_n); - - p->_pn = 0; - } - - static void remove(T *e) - { e->H_list_item::l_remove(); } - - static Iterator erase(Iterator const &e) - { e->H_list_item::l_remove(); return e; } -}; - -template< typename T > -class H_list_bss : public H_list -{ -public: - H_list_bss() : H_list(true) {} -}; - -} diff --git a/kernel/fiasco/src/lib/libk/slist b/kernel/fiasco/src/lib/libk/slist deleted file mode 100644 index 43eaeaad9..000000000 --- a/kernel/fiasco/src/lib/libk/slist +++ /dev/null @@ -1,181 +0,0 @@ -// vi:ft=cpp -/* - * (c) 2011 Alexander Warg - * economic rights: Technische Universität Dresden (Germany) - * - * This file is part of TUD:OS and distributed under the terms of the - * GNU General Public License 2. - * Please see the COPYING-GPL-2 file for details. - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - */ - -#pragma once - -#include "bits/list_basics.h" - -namespace cxx { - -class S_list_item -{ -public: - S_list_item() : _n(0) {} - explicit S_list_item(bool) {} - -private: - template friend class S_list; - template friend class S_list_tail; - template friend struct Bits::Basic_list_policy; - - S_list_item(S_list_item const &); - void operator = (S_list_item const &); - - S_list_item *_n; -}; - -template< typename T, typename POLICY = Bits::Basic_list_policy< T, S_list_item > > -class S_list : public Bits::Basic_list -{ - S_list(S_list const &) = delete; - void operator = (S_list const &) = delete; - -private: - typedef typename Bits::Basic_list Base; - -public: - typedef typename Base::Iterator Iterator; - - S_list(S_list &&o) : Base(static_cast(o)) {} - - S_list &operator = (S_list &&o) - { - Base::operator = (static_cast(o)); - return *this; - } - - // BSS allocation - explicit S_list(bool x) : Base(x) {} - - S_list() : Base() {} - - void add(T *e) - { - e->_n = this->_f; - this->_f = e; - } - - template< typename CAS > - void add(T *e, CAS const &c) - { - do - { - e->_n = this->_f; - } - while (!c(&this->_f, e->_n, e)); - } - - void push_front(T *e) { add(e); } - T *pop_front() - { - T *r = this->front(); - if (this->_f) - this->_f = this->_f->_n; - return r; - } - - void insert(T *e, Iterator const &pred) - { - S_list_item *p = *pred; - e->_n = p->_n; - p->_n = e; - } - - static void insert_before(T *e, Iterator const &succ) - { - S_list_item **x = Base::__get_internal(succ); - - e->_n = *x; - *x = e; - } - - static void replace(Iterator const &p, T*e) - { - S_list_item **x = Base::__get_internal(p); - e->_n = (*x)->_n; - *x = e; - } - - static Iterator erase(Iterator const &e) - { - S_list_item **x = Base::__get_internal(e); - *x = (*x)->_n; - return e; - } - -}; - - -template< typename T > -class S_list_bss : public S_list -{ -public: - S_list_bss() : S_list(true) {} -}; - -template< typename T, typename POLICY = Bits::Basic_list_policy< T, S_list_item > > -class S_list_tail : public S_list -{ -private: - typedef S_list Base; - -public: - S_list_tail() : Base(), _tail(&this->_f) {} - - S_list_tail(S_list_tail &&t) : Base(static_cast(t)), _tail(t._tail) - { - t._tail = &t._f; - } - - S_list_tail &operator = (S_list_tail &&t) - { - Base::operator = (static_cast(t)); - _tail = t._tail; - t._tail = &t._f; - return *this; - } - - void push_back(T *e) - { - e->_n = 0; - *_tail = e; - _tail = &e->_n; - } - - void clear() - { - Base::clear(); - _tail = &this->_f; - } - - void append(S_list_tail &o) - { - T *x = o.front(); - *_tail = x; - if (x) - _tail = o._tail; - o.clear(); - } - - -private: - S_list_item **_tail; -}; - -} diff --git a/kernel/fiasco/src/lib/libk/type_list b/kernel/fiasco/src/lib/libk/type_list deleted file mode 100644 index 58bed7cd4..000000000 --- a/kernel/fiasco/src/lib/libk/type_list +++ /dev/null @@ -1,61 +0,0 @@ -// vi:ft=cpp -#pragma once - -/* - * (c) 2012 Alexander Warg , - * economic rights: Technische Universität Dresden (Germany) - * - * This file is part of TUD:OS and distributed under the terms of the - * GNU General Public License 2. - * Please see the COPYING-GPL-2 file for details. - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - */ - - -#include - -namespace cxx { - -template< typename ...T > -struct type_list; - -template<> -struct type_list<> -{ - typedef false_type head; - typedef false_type tail; -}; - -template -struct type_list -{ - typedef HEAD head; - typedef type_list tail; -}; - -template class PREDICATE> -struct find_type; - -template