]> Zhao Yanbai Git Server - minix.git/commitdiff
arm-refactor:remove dependency from memory.c to omap_timer.h.
authorKees Jongenburger <kees.jongenburger@gmail.com>
Mon, 24 Feb 2014 08:47:13 +0000 (09:47 +0100)
committerLionel Sambuc <lionel@minix3.org>
Mon, 28 Jul 2014 15:05:09 +0000 (17:05 +0200)
Remove the dependency from memory.c to omap_timer.h.

Change-Id: I1f1a0e5436ac725e4b0db9d7d404194384794802

kernel/arch/earm/bsp/ti/omap_intr.c
kernel/arch/earm/bsp/ti/omap_padconf.c
kernel/arch/earm/bsp/ti/omap_reset.c
kernel/arch/earm/bsp/ti/omap_rtc.c
kernel/arch/earm/bsp/ti/omap_serial.c
kernel/arch/earm/bsp/ti/omap_timer.c
kernel/arch/earm/include/arch_proto.h
kernel/arch/earm/memory.c
kernel/arch/earm/pre_init.c

index 862d43442449e5fa67eb27bc4b7701f87eb6f12b..59bd4c2b9101e2c645fd6f1648283fb4c7b9cd93 100644 (file)
@@ -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;
 }
index 1a803fdb08317993c1dbc1ca67557828f9729784..318769beae28329d41aaae3d818012967a6a918a 100644 (file)
@@ -7,6 +7,7 @@
 #include <minix/mmio.h>
 #include <minix/padconf.h>
 #include <minix/board.h>
+#include <minix/com.h>
 #include <assert.h>
 #include <io.h>
 #include <stdlib.h>
@@ -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;
index c0c157dcacb74d21c1737507858e72cec6237774..13daa5a59330ea3ec4459aae5cb0018826a3666d 100644 (file)
@@ -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
index 3911cb1f82613255e9705d596c7122968a426b59..4e2fdeb3f5796fac70bf2ac335f221c2fc012482 100644 (file)
@@ -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);
        }
 }
index 86470900269ac7d8e1436d0137cafdea9d9b481b..9affc52efdb9b414d0e170777fd8c8958174583d 100644 (file)
@@ -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);
 }
 
index db570c06764cd4c67c482e013c7915b26f5b7522..bb764b3777f5461bfdd990bd9ccbd650665c6985 100644 (file)
@@ -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);
index 7a1e5bf50965121ed17888c38ae62cf329197b4d..2ec2ef16b703227437e13724318bbebe7ba1a6ea 100644 (file)
@@ -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();
 
index f3a4e260c6862d9c1b714c26aa146fdeb7e3249c..ee77a71b8fb3119615c4cfd97db768c496942d59 100644 (file)
@@ -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);
 }
 
index 49186c26b0a9b0be804698a17353dd76fda9aca1..86b4e52aa4ebd41399af19b08efb125600eb545a 100644 (file)
@@ -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 */