From: Kees Jongenburger Date: Mon, 24 Feb 2014 08:47:13 +0000 (+0100) Subject: arm-refactor:remove dependency from memory.c to omap_timer.h. X-Git-Tag: v3.3.0~431 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/mult.png?a=commitdiff_plain;h=e54d075f6fec9aeb230dd299aaa10f49f75f4166;p=minix.git arm-refactor:remove dependency from memory.c to omap_timer.h. Remove the dependency from memory.c to omap_timer.h. Change-Id: I1f1a0e5436ac725e4b0db9d7d404194384794802 --- diff --git a/kernel/arch/earm/bsp/ti/omap_intr.c b/kernel/arch/earm/bsp/ti/omap_intr.c index 862d43442..59bd4c2b9 100644 --- a/kernel/arch/earm/bsp/ti/omap_intr.c +++ b/kernel/arch/earm/bsp/ti/omap_intr.c @@ -35,6 +35,7 @@ intr_init(const int auto_eoi) omap_intr.size = 0x1000; /* 4K */ kern_phys_map_ptr(omap_intr.base, omap_intr.size, + VMMF_UNCACHED | VMMF_WRITE, &intr_phys_map, (vir_bytes) & omap_intr.base); return 0; } diff --git a/kernel/arch/earm/bsp/ti/omap_padconf.c b/kernel/arch/earm/bsp/ti/omap_padconf.c index 1a803fdb0..318769bea 100644 --- a/kernel/arch/earm/bsp/ti/omap_padconf.c +++ b/kernel/arch/earm/bsp/ti/omap_padconf.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -75,6 +76,7 @@ bsp_padconf_init(void) assert(omap_padconf); kern_phys_map_ptr(omap_padconf->base, omap_padconf->size, + VMMF_UNCACHED | VMMF_WRITE, &padconf_phys_map, (vir_bytes) & omap_padconf->base); return; diff --git a/kernel/arch/earm/bsp/ti/omap_reset.c b/kernel/arch/earm/bsp/ti/omap_reset.c index c0c157dca..13daa5a59 100644 --- a/kernel/arch/earm/bsp/ti/omap_reset.c +++ b/kernel/arch/earm/bsp/ti/omap_reset.c @@ -47,8 +47,9 @@ bsp_reset_init(void) omap_reset.size = AM335X_CM_SIZE; } - kern_phys_map_ptr(omap_reset.base, omap_reset.size, &reset_phys_map, - (vir_bytes) & omap_reset.base); + kern_phys_map_ptr(omap_reset.base, omap_reset.size, + VMMF_UNCACHED | VMMF_WRITE, + &reset_phys_map, (vir_bytes) & omap_reset.base); } void diff --git a/kernel/arch/earm/bsp/ti/omap_rtc.c b/kernel/arch/earm/bsp/ti/omap_rtc.c index 3911cb1f8..4e2fdeb3f 100644 --- a/kernel/arch/earm/bsp/ti/omap_rtc.c +++ b/kernel/arch/earm/bsp/ti/omap_rtc.c @@ -41,7 +41,8 @@ void omap3_rtc_init(void) { if (BOARD_IS_BB(machine.board_id)) { - kern_phys_map_ptr(omap_rtc.base, omap_rtc.size, &rtc_phys_map, + kern_phys_map_ptr(omap_rtc.base, omap_rtc.size, + VMMF_UNCACHED | VMMF_WRITE, &rtc_phys_map, (vir_bytes) & omap_rtc.base); } } diff --git a/kernel/arch/earm/bsp/ti/omap_serial.c b/kernel/arch/earm/bsp/ti/omap_serial.c index 864709002..9affc52ef 100644 --- a/kernel/arch/earm/bsp/ti/omap_serial.c +++ b/kernel/arch/earm/bsp/ti/omap_serial.c @@ -53,7 +53,8 @@ bsp_ser_init() omap_serial.size = 0x1000; /* 4k */ kern_phys_map_ptr(omap_serial.base, omap_serial.size, - &serial_phys_map, (vir_bytes) & omap_serial.base); + VMMF_UNCACHED | VMMF_WRITE, &serial_phys_map, + (vir_bytes) & omap_serial.base); assert(omap_serial.base); } diff --git a/kernel/arch/earm/bsp/ti/omap_timer.c b/kernel/arch/earm/bsp/ti/omap_timer.c index db570c067..bb764b377 100644 --- a/kernel/arch/earm/bsp/ti/omap_timer.c +++ b/kernel/arch/earm/bsp/ti/omap_timer.c @@ -149,6 +149,26 @@ bsp_register_timer_handler(const irq_handler_t handler) /* meta data for remapping */ static kern_phys_map timer_phys_map; static kern_phys_map fr_timer_phys_map; +static kern_phys_map fr_timer_user_phys_map; /* struct for when the free */ + /* running timer is mapped to */ + /* userland */ + +/* callback for when the free running clock gets mapped */ +int +kern_phys_fr_user_mapped(vir_bytes id, phys_bytes address) +{ + /* the only thing we need to do at this stage is to set the address */ + /* in the kerninfo struct */ + if (BOARD_IS_BBXM(machine.board_id)) { + minix_kerninfo.minix_frclock_tcrr = address + OMAP3_TIMER_TCRR; + minix_kerninfo.minix_arm_frclock_hz = 1625000; + } else if (BOARD_IS_BB(machine.board_id)) { + minix_kerninfo.minix_frclock_tcrr = + address + AM335X_TIMER_TCRR; + minix_kerninfo.minix_arm_frclock_hz = 1500000; + } + return 0; +} void omap3_frclock_init(void) @@ -158,8 +178,16 @@ omap3_frclock_init(void) /* enable the clock */ if (BOARD_IS_BBXM(machine.board_id)) { fr_timer = &dm37xx_fr_timer; + kern_phys_map_ptr(fr_timer->base, ARM_PAGE_SIZE, - &fr_timer_phys_map, (vir_bytes) & fr_timer->base); + VMMF_UNCACHED | VMMF_WRITE, &fr_timer_phys_map, + (vir_bytes) & fr_timer->base); + + /* the timer is also mapped in user space hence the this */ + /* second mapping and callback to set kerninfo frclock_tcrr */ + kern_req_phys_map(fr_timer->base, ARM_PAGE_SIZE, + VMMF_UNCACHED | VMMF_USER, + &fr_timer_user_phys_map, kern_phys_fr_user_mapped, 0); /* Stop timer */ mmio_clear(fr_timer->base + fr_timer->regs->TCLR, @@ -177,7 +205,14 @@ omap3_frclock_init(void) } else if (BOARD_IS_BB(machine.board_id)) { fr_timer = &am335x_fr_timer; kern_phys_map_ptr(fr_timer->base, ARM_PAGE_SIZE, + VMMF_UNCACHED | VMMF_WRITE, &fr_timer_phys_map, (vir_bytes) & fr_timer->base); + + /* the timer is also mapped in user space hence the this */ + /* second mapping and callback to set kerninfo frclock_tcrr */ + kern_req_phys_map(fr_timer->base, ARM_PAGE_SIZE, + VMMF_UNCACHED | VMMF_USER, + &fr_timer_user_phys_map, kern_phys_fr_user_mapped, 0); /* Disable the module and wait for the module to be disabled */ set32(CM_PER_TIMER7_CLKCTRL, CM_MODULEMODE_MASK, CM_MODULEMODE_DISABLED); @@ -236,8 +271,9 @@ bsp_timer_init(unsigned freq) u32_t tisr; if (BOARD_IS_BBXM(machine.board_id)) { timer = &dm37xx_timer; - kern_phys_map_ptr(timer->base, ARM_PAGE_SIZE, &timer_phys_map, - (vir_bytes) & timer->base); + kern_phys_map_ptr(timer->base, ARM_PAGE_SIZE, + VMMF_UNCACHED | VMMF_WRITE, + &timer_phys_map, (vir_bytes) & timer->base); /* Stop timer */ mmio_clear(timer->base + timer->regs->TCLR, OMAP3_TCLR_ST); @@ -245,8 +281,9 @@ bsp_timer_init(unsigned freq) mmio_clear(OMAP3_CM_CLKSEL_WKUP, OMAP3_CLKSEL_GPT1); } else if (BOARD_IS_BB(machine.board_id)) { timer = &am335x_timer; - kern_phys_map_ptr(timer->base, ARM_PAGE_SIZE, &timer_phys_map, - (vir_bytes) & timer->base); + kern_phys_map_ptr(timer->base, ARM_PAGE_SIZE, + VMMF_UNCACHED | VMMF_WRITE, + &timer_phys_map, (vir_bytes) & timer->base); /* disable the module and wait for the module to be disabled */ set32(CM_WKUP_TIMER1_CLKCTRL, CM_MODULEMODE_MASK, CM_MODULEMODE_DISABLED); diff --git a/kernel/arch/earm/include/arch_proto.h b/kernel/arch/earm/include/arch_proto.h index 7a1e5bf50..2ec2ef16b 100644 --- a/kernel/arch/earm/include/arch_proto.h +++ b/kernel/arch/earm/include/arch_proto.h @@ -54,7 +54,7 @@ extern void * k_stacks; /* - * Definition of a callback used when a memory map changes it's base address + * Definition of a callback used when a memory map changed it's base address */ typedef int (*kern_phys_map_mapped)(vir_bytes id, vir_bytes new_addr ); @@ -69,6 +69,7 @@ typedef struct kern_phys_map{ phys_bytes addr; /* The physical address to map */ vir_bytes size; /* The size of the mapping */ vir_bytes id; /* an id passed to the callback */ + int vm_flags; /* flags to be passed to vm map */ kern_phys_map_mapped cb; /* the callback itself */ phys_bytes vir; /* The virtual address once remapped */ int index; /* index */ @@ -103,15 +104,16 @@ typedef struct kern_phys_map{ * the same reason. */ int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size, - kern_phys_map * priv, kern_phys_map_mapped cb, - vir_bytes id); + int vm_flags, kern_phys_map * priv, + kern_phys_map_mapped cb, vir_bytes id); /* * Request a physical mapping and put the result in the given prt * Note that ptr will only be valid once the callback happened. */ int kern_phys_map_ptr( phys_bytes base_address, vir_bytes io_size, - kern_phys_map * priv, vir_bytes ptr); + int vm_flags, kern_phys_map * priv, + vir_bytes ptr); void arch_ser_init(); diff --git a/kernel/arch/earm/memory.c b/kernel/arch/earm/memory.c index f3a4e260c..ee77a71b8 100644 --- a/kernel/arch/earm/memory.c +++ b/kernel/arch/earm/memory.c @@ -20,7 +20,6 @@ #include "kernel/proto.h" #include "kernel/debug.h" #include "bsp_timer.h" -#include "bsp/ti/omap_timer_registers.h" #define HASPT(procptr) ((procptr)->p_seg.p_ttbr != 0) @@ -684,11 +683,7 @@ void arch_proc_init(struct proc *pr, const u32_t ip, const u32_t sp, pr->p_reg.retreg = ps_str; /* a.k.a r0*/ } -/* TODO keesj: rewrite the free running clock to use callbacks - * the current implementation introduces a two-way depedency -*/ -static int frclock_index = -1, - usermapped_glo_index = -1, +static int usermapped_glo_index = -1, usermapped_index = -1, first_um_idx = -1; @@ -709,7 +704,6 @@ int arch_phys_map(const int index, if(first) { memset(&minix_kerninfo, 0, sizeof(minix_kerninfo)); - frclock_index = freeidx++; if(glo_len > 0) { usermapped_glo_index = freeidx++; } @@ -742,26 +736,14 @@ int arch_phys_map(const int index, *flags = VMMF_USER; return OK; } - else if (index == frclock_index) { - - if (BOARD_IS_BBXM(machine.board_id)){ - *addr = OMAP3_GPTIMER10_BASE; - } else if (BOARD_IS_BB(machine.board_id)){ - *addr = AM335X_DMTIMER7_BASE; - } else { - panic("Can not do the clock setup. machine (0x%08x) is unknown\n",machine.board_id); - }; - *len = ARM_PAGE_SIZE; - *flags = VMMF_UNCACHED | VMMF_USER; - return OK; - } + /* if this all fails loop over the maps */ phys_maps = kern_phys_map_head; while(phys_maps != NULL){ if(phys_maps->index == index){ *addr = phys_maps->addr; *len = phys_maps->size; - *flags = VMMF_UNCACHED | VMMF_WRITE; + *flags = phys_maps->vm_flags; return OK; } phys_maps = phys_maps->next; @@ -792,26 +774,12 @@ int arch_phys_map_reply(const int index, const vir_bytes addr) minix_kerninfo.kerninfo_magic = KERNINFO_MAGIC; minix_kerninfo.minix_feature_flags = minix_feature_flags; minix_kerninfo_user = (vir_bytes) FIXEDPTR(&minix_kerninfo); - return OK; } if (index == usermapped_index) { return OK; } - else if (index == frclock_index) { - if (BOARD_IS_BBXM(machine.board_id)){ - minix_kerninfo.minix_frclock_tcrr = addr + OMAP3_TIMER_TCRR; - minix_kerninfo.minix_arm_frclock_hz = 1625000; - } else if (BOARD_IS_BB(machine.board_id)){ - minix_kerninfo.minix_frclock_tcrr = addr + AM335X_TIMER_TCRR; - minix_kerninfo.minix_arm_frclock_hz = 1500000; - } else { - panic("memory setup errot machine (0x%08x) is unhandled\n",machine.board_id); - }; - - return OK; - } /* if this all fails loop over the maps */ /* list over the maps and index them */ @@ -866,9 +834,9 @@ void release_address_space(struct proc *pr) /* * Request a physical mapping */ -int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size, - kern_phys_map * priv, kern_phys_map_mapped cb, - vir_bytes id) +int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size, + int vm_flags, kern_phys_map * priv, + kern_phys_map_mapped cb, vir_bytes id) { /* Assign the values to the given struct and add priv to the list */ @@ -878,6 +846,7 @@ int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size, priv->addr = base_address; priv->size = io_size; + priv->vm_flags = vm_flags; priv->cb = cb; priv->id = id; priv->index = -1; @@ -916,9 +885,10 @@ int kern_phys_map_mapped_ptr(vir_bytes id, phys_bytes address){ int kern_phys_map_ptr( phys_bytes base_address, vir_bytes io_size, + int vm_flags, kern_phys_map * priv, vir_bytes ptr) { - return kern_req_phys_map(base_address,io_size,priv,kern_phys_map_mapped_ptr,ptr); + return kern_req_phys_map(base_address,io_size,vm_flags,priv,kern_phys_map_mapped_ptr,ptr); } diff --git a/kernel/arch/earm/pre_init.c b/kernel/arch/earm/pre_init.c index 49186c26b..86b4e52aa 100644 --- a/kernel/arch/earm/pre_init.c +++ b/kernel/arch/earm/pre_init.c @@ -415,6 +415,6 @@ void send_diag_sig(void) { } void minix_shutdown(minix_timer_t *t) { arch_shutdown(0); } void busy_delay_ms(int x) { } int raise(int n) { panic("raise(%d)\n", n); } -int kern_phys_map_ptr( phys_bytes base_address, vir_bytes io_size, +int kern_phys_map_ptr( phys_bytes base_address, vir_bytes io_size, int vm_flags, struct kern_phys_map * priv, vir_bytes ptr) {}; struct machine machine; /* pre init stage machine */