Remove the dependency from memory.c to omap_timer.h.
Change-Id: I1f1a0e5436ac725e4b0db9d7d404194384794802
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;
}
#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>
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;
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
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);
}
}
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);
}
/* 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)
/* 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,
} 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);
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);
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);
/*
- * 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 );
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 */
* 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();
#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)
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;
if(first) {
memset(&minix_kerninfo, 0, sizeof(minix_kerninfo));
- frclock_index = freeidx++;
if(glo_len > 0) {
usermapped_glo_index = freeidx++;
}
*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;
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 */
/*
* 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 */
priv->addr = base_address;
priv->size = io_size;
+ priv->vm_flags = vm_flags;
priv->cb = cb;
priv->id = id;
priv->index = -1;
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);
}
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 */