From: David van Moolenbroek Date: Mon, 21 Sep 2015 14:17:11 +0000 (+0000) Subject: Kernel: store ARM frclock info in one structure X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F3178%2F2;p=minix.git Kernel: store ARM frclock info in one structure This change serves to reduce the clutter inside the top-level kerninfo structure, and allows other ARM-specific values to be added on the kernel page in one place. Change-Id: I36a6aada9dbd1230b25014728be675d389088667 --- diff --git a/minix/include/minix/type.h b/minix/include/minix/type.h index 599e2a86a..29a2838ae 100644 --- a/minix/include/minix/type.h +++ b/minix/include/minix/type.h @@ -184,6 +184,12 @@ struct k_randomness { } bin[RANDOM_SOURCES]; }; +/* ARM free-running timer information. */ +struct arm_frclock { + u64_t hz; /* tcrr frequency */ + u32_t tcrr; /* tcrr address */ +}; + struct minix_kerninfo { /* Binaries will depend on the offsets etc. in this * structure, so it can't be changed willy-nilly. In @@ -193,7 +199,7 @@ struct minix_kerninfo { u32_t kerninfo_magic; u32_t minix_feature_flags; /* features in minix kernel */ u32_t ki_flags; /* what is present in this struct */ - u32_t minix_frclock_tcrr; /* NOT userland ABI */ + u32_t flags_unused2; u32_t flags_unused3; u32_t flags_unused4; struct kinfo *kinfo; @@ -201,7 +207,8 @@ struct minix_kerninfo { struct kmessages *kmessages; /* NOT userland ABI */ struct loadinfo *loadinfo; /* NOT userland ABI */ struct minix_ipcvecs *minix_ipcvecs; - u64_t minix_arm_frclock_hz; /* minix_frclock_tcrr frequency !ABI */ + u32_t reserved; + struct arm_frclock *arm_frclock; /* NOT userland ABI */ volatile struct kclockinfo *kclockinfo; /* NOT userland ABI */ } __packed; diff --git a/minix/kernel/arch/earm/bsp/ti/omap_timer.c b/minix/kernel/arch/earm/bsp/ti/omap_timer.c index bb764b377..f37f7163f 100644 --- a/minix/kernel/arch/earm/bsp/ti/omap_timer.c +++ b/minix/kernel/arch/earm/bsp/ti/omap_timer.c @@ -160,12 +160,11 @@ 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; + arm_frclock.tcrr = address + OMAP3_TIMER_TCRR; + 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; + arm_frclock.tcrr = address + AM335X_TIMER_TCRR; + arm_frclock.hz = 1500000; } return 0; } diff --git a/minix/kernel/arch/earm/memory.c b/minix/kernel/arch/earm/memory.c index acc3a8257..26a8eae21 100644 --- a/minix/kernel/arch/earm/memory.c +++ b/minix/kernel/arch/earm/memory.c @@ -714,6 +714,7 @@ int arch_phys_map_reply(const int index, const vir_bytes addr) ASSIGN(machine); ASSIGN(kmessages); ASSIGN(loadinfo); + ASSIGN(arm_frclock); ASSIGN(kclockinfo); /* adjust the pointers of the functions and the struct diff --git a/minix/kernel/arch/i386/memory.c b/minix/kernel/arch/i386/memory.c index cabd73ff9..a29e06826 100644 --- a/minix/kernel/arch/i386/memory.c +++ b/minix/kernel/arch/i386/memory.c @@ -879,6 +879,7 @@ int arch_phys_map_reply(const int index, const vir_bytes addr) ASSIGN(machine); ASSIGN(kmessages); ASSIGN(loadinfo); + ASSIGN(arm_frclock); /* eh, why not. */ ASSIGN(kclockinfo); /* select the right set of IPC routines to map into processes */ diff --git a/minix/kernel/glo.h b/minix/kernel/glo.h index 666655387..2bab873e3 100644 --- a/minix/kernel/glo.h +++ b/minix/kernel/glo.h @@ -23,6 +23,7 @@ extern struct kinfo kinfo; /* kernel information for users */ extern struct machine machine; /* machine information for users */ extern struct kmessages kmessages; /* diagnostic messages in kernel */ extern struct loadinfo loadinfo; /* status of load average */ +extern struct arm_frclock arm_frclock; /* ARM free-running timer info */ extern struct kclockinfo kclockinfo; /* clock information */ extern struct minix_kerninfo minix_kerninfo; diff --git a/minix/kernel/main.c b/minix/kernel/main.c index 58865c59f..1c1e52be8 100644 --- a/minix/kernel/main.c +++ b/minix/kernel/main.c @@ -436,6 +436,9 @@ void cstart() strlcpy(kinfo.release, OS_RELEASE, sizeof(kinfo.release)); strlcpy(kinfo.version, OS_VERSION, sizeof(kinfo.version)); + /* Initialize various user-mapped structures. */ + memset(&arm_frclock, 0, sizeof(arm_frclock)); + #ifdef USE_APIC value = env_get("no_apic"); if(value) diff --git a/minix/kernel/usermapped_data.c b/minix/kernel/usermapped_data.c index d3862ad1c..cad2511a8 100644 --- a/minix/kernel/usermapped_data.c +++ b/minix/kernel/usermapped_data.c @@ -8,4 +8,6 @@ struct kinfo kinfo __section(".usermapped"); /* kernel information for users */ struct machine machine __section(".usermapped"); /* machine information for users */ struct kmessages kmessages __section(".usermapped"); /* diagnostic messages in kernel */ struct loadinfo loadinfo __section(".usermapped"); /* status of load average */ +struct arm_frclock arm_frclock __section(".usermapped"); + /* ARM free running timer information */ struct kclockinfo kclockinfo __section(".usermapped"); /* clock information */ diff --git a/minix/lib/libsys/arch/earm/frclock_util.c b/minix/lib/libsys/arch/earm/frclock_util.c index d93198121..cb1924466 100644 --- a/minix/lib/libsys/arch/earm/frclock_util.c +++ b/minix/lib/libsys/arch/earm/frclock_util.c @@ -26,8 +26,9 @@ micro_delay(u32_t micros) /* Start of delay. */ read_frclock_64(&start); - assert(minix_kerninfo->minix_arm_frclock_hz); - delta_end = (minix_kerninfo->minix_arm_frclock_hz * micros) / MICROHZ; + assert(minix_kerninfo->arm_frclock); + assert(minix_kerninfo->arm_frclock->hz); + delta_end = (minix_kerninfo->arm_frclock->hz * micros) / MICROHZ; /* If we have to wait for at least one HZ tick, use the regular * tickdelay first. Round downwards on purpose, so the average @@ -50,7 +51,7 @@ micro_delay(u32_t micros) u32_t frclock_64_to_micros(u64_t tsc) { return (u32_t) - (tsc / (get_minix_kerninfo()->minix_arm_frclock_hz / MICROHZ)); + (tsc / (get_minix_kerninfo()->arm_frclock->hz / MICROHZ)); } void @@ -59,10 +60,10 @@ read_frclock(u32_t *frclk) struct minix_kerninfo *minix_kerninfo = get_minix_kerninfo(); assert(frclk); - assert(minix_kerninfo->minix_frclock_tcrr); - assert(minix_kerninfo->minix_arm_frclock_hz); + assert(minix_kerninfo->arm_frclock); + assert(minix_kerninfo->arm_frclock->tcrr); *frclk = *(volatile u32_t *)((u8_t *) - minix_kerninfo->minix_frclock_tcrr); + minix_kerninfo->arm_frclock->tcrr); } u32_t