Use int64 functions consistently
Instead of manipulating the u64_t type directly, use the ex64hi()/ex64lo()/make64() functions.
This commit is contained in:
parent
a575be430d
commit
aaaad89244
@ -72,10 +72,8 @@ PRIVATE int hello_close(d, m)
|
|||||||
PRIVATE struct device * hello_prepare(dev)
|
PRIVATE struct device * hello_prepare(dev)
|
||||||
int dev;
|
int dev;
|
||||||
{
|
{
|
||||||
hello_device.dv_base.lo = 0;
|
hello_device.dv_base = make64(0, 0);
|
||||||
hello_device.dv_base.hi = 0;
|
hello_device.dv_size = make64(strlen(HELLO_MESSAGE), 0);
|
||||||
hello_device.dv_size.lo = strlen(HELLO_MESSAGE);
|
|
||||||
hello_device.dv_size.hi = 0;
|
|
||||||
return &hello_device;
|
return &hello_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +88,8 @@ PRIVATE int hello_transfer(proc_nr, opcode, position, iov, nr_req)
|
|||||||
|
|
||||||
printf("hello_transfer()\n");
|
printf("hello_transfer()\n");
|
||||||
|
|
||||||
bytes = strlen(HELLO_MESSAGE) - position.lo < iov->iov_size ?
|
bytes = strlen(HELLO_MESSAGE) - ex64lo(position) < iov->iov_size ?
|
||||||
strlen(HELLO_MESSAGE) - position.lo : iov->iov_size;
|
strlen(HELLO_MESSAGE) - ex64lo(position) : iov->iov_size;
|
||||||
|
|
||||||
if (bytes <= 0)
|
if (bytes <= 0)
|
||||||
{
|
{
|
||||||
@ -101,7 +99,7 @@ PRIVATE int hello_transfer(proc_nr, opcode, position, iov, nr_req)
|
|||||||
{
|
{
|
||||||
case DEV_GATHER_S:
|
case DEV_GATHER_S:
|
||||||
ret = sys_safecopyto(proc_nr, iov->iov_addr, 0,
|
ret = sys_safecopyto(proc_nr, iov->iov_addr, 0,
|
||||||
(vir_bytes) (HELLO_MESSAGE + position.lo),
|
(vir_bytes) (HELLO_MESSAGE + ex64lo(position)),
|
||||||
bytes, D);
|
bytes, D);
|
||||||
iov->iov_size -= bytes;
|
iov->iov_size -= bytes;
|
||||||
break;
|
break;
|
||||||
|
@ -570,13 +570,12 @@ PRIVATE u32_t lapic_errstatus(void)
|
|||||||
|
|
||||||
PRIVATE int lapic_disable_in_msr(void)
|
PRIVATE int lapic_disable_in_msr(void)
|
||||||
{
|
{
|
||||||
u64_t msr;
|
u32_t addr, msr_hi, msr_lo;
|
||||||
u32_t addr;
|
|
||||||
|
|
||||||
ia32_msr_read(IA32_APIC_BASE, &msr.hi, &msr.lo);
|
ia32_msr_read(IA32_APIC_BASE, &msr_hi, &msr_lo);
|
||||||
|
|
||||||
msr.lo &= ~(1 << IA32_APIC_BASE_ENABLE_BIT);
|
msr_lo &= ~(1 << IA32_APIC_BASE_ENABLE_BIT);
|
||||||
ia32_msr_write(IA32_APIC_BASE, msr.hi, msr.lo);
|
ia32_msr_write(IA32_APIC_BASE, msr_hi, msr_lo);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -618,10 +617,9 @@ PUBLIC void lapic_disable(void)
|
|||||||
|
|
||||||
PRIVATE int lapic_enable_in_msr(void)
|
PRIVATE int lapic_enable_in_msr(void)
|
||||||
{
|
{
|
||||||
u64_t msr;
|
u32_t addr, msr_hi, msr_lo;
|
||||||
u32_t addr;
|
|
||||||
|
|
||||||
ia32_msr_read(IA32_APIC_BASE, &msr.hi, &msr.lo);
|
ia32_msr_read(IA32_APIC_BASE, &msr_hi, &msr_lo);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/*FIXME this is a problem on AP */
|
/*FIXME this is a problem on AP */
|
||||||
@ -629,18 +627,18 @@ PRIVATE int lapic_enable_in_msr(void)
|
|||||||
* FIXME if the location is different (unlikely) then the one we expect,
|
* FIXME if the location is different (unlikely) then the one we expect,
|
||||||
* update it
|
* update it
|
||||||
*/
|
*/
|
||||||
addr = (msr.lo >> 12) | ((msr.hi & 0xf) << 20);
|
addr = (msr_lo >> 12) | ((msr_hi & 0xf) << 20);
|
||||||
if (phys2vir(addr) != (lapic_addr >> 12)) {
|
if (phys2vir(addr) != (lapic_addr >> 12)) {
|
||||||
if (msr.hi & 0xf) {
|
if (msr_hi & 0xf) {
|
||||||
printf("ERROR : APIC address needs more then 32 bits\n");
|
printf("ERROR : APIC address needs more then 32 bits\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lapic_addr = phys2vir(msr.lo & ~((1 << 12) - 1));
|
lapic_addr = phys2vir(msr_lo & ~((1 << 12) - 1));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
msr.lo |= (1 << IA32_APIC_BASE_ENABLE_BIT);
|
msr_lo |= (1 << IA32_APIC_BASE_ENABLE_BIT);
|
||||||
ia32_msr_write(IA32_APIC_BASE, msr.hi, msr.lo);
|
ia32_msr_write(IA32_APIC_BASE, msr_hi, msr_lo);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -251,9 +251,9 @@ PUBLIC void context_stop(struct proc * p)
|
|||||||
make_zero64(p->p_cpu_time_left);
|
make_zero64(p->p_cpu_time_left);
|
||||||
#else
|
#else
|
||||||
/* if (tsc_delta < p->p_cpu_time_left) in 64bit */
|
/* if (tsc_delta < p->p_cpu_time_left) in 64bit */
|
||||||
if (tsc_delta.hi < p->p_cpu_time_left.hi ||
|
if (ex64hi(tsc_delta) < ex64hi(p->p_cpu_time_left) ||
|
||||||
(tsc_delta.hi == p->p_cpu_time_left.hi &&
|
(ex64hi(tsc_delta) == ex64hi(p->p_cpu_time_left) &&
|
||||||
tsc_delta.lo < p->p_cpu_time_left.lo))
|
ex64lo(tsc_delta) < ex64lo(p->p_cpu_time_left)))
|
||||||
p->p_cpu_time_left = sub64(p->p_cpu_time_left, tsc_delta);
|
p->p_cpu_time_left = sub64(p->p_cpu_time_left, tsc_delta);
|
||||||
else {
|
else {
|
||||||
make_zero64(p->p_cpu_time_left);
|
make_zero64(p->p_cpu_time_left);
|
||||||
@ -315,7 +315,7 @@ PUBLIC short cpu_load(void)
|
|||||||
|
|
||||||
busy = sub64(tsc_delta, idle_delta);
|
busy = sub64(tsc_delta, idle_delta);
|
||||||
busy = mul64(busy, make64(100, 0));
|
busy = mul64(busy, make64(100, 0));
|
||||||
load = div64(busy, tsc_delta).lo;
|
load = ex64lo(div64(busy, tsc_delta));
|
||||||
|
|
||||||
if (load > 100)
|
if (load > 100)
|
||||||
load = 100;
|
load = 100;
|
||||||
|
@ -478,8 +478,10 @@ PRIVATE void dump_bkl_usage(void)
|
|||||||
printf("--- BKL usage ---\n");
|
printf("--- BKL usage ---\n");
|
||||||
for (cpu = 0; cpu < ncpus; cpu++) {
|
for (cpu = 0; cpu < ncpus; cpu++) {
|
||||||
printf("cpu %3d kernel ticks 0x%x%08x bkl ticks 0x%x%08x succ %d tries %d\n", cpu,
|
printf("cpu %3d kernel ticks 0x%x%08x bkl ticks 0x%x%08x succ %d tries %d\n", cpu,
|
||||||
kernel_ticks[cpu].hi, kernel_ticks[cpu].lo,
|
ex64hi(kernel_ticks[cpu]),
|
||||||
bkl_ticks[cpu].hi, bkl_ticks[cpu].lo,
|
ex64lo(kernel_ticks[cpu]),
|
||||||
|
ex64hi(bkl_ticks[cpu]),
|
||||||
|
ex64lo(bkl_ticks[cpu]),
|
||||||
bkl_succ[cpu], bkl_tries[cpu]);
|
bkl_succ[cpu], bkl_tries[cpu]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,12 @@ PRIVATE void intel_arch_watchdog_init(const unsigned cpu)
|
|||||||
* lowest 31 bits writable :(
|
* lowest 31 bits writable :(
|
||||||
*/
|
*/
|
||||||
cpuf = cpu_get_freq(cpu);
|
cpuf = cpu_get_freq(cpu);
|
||||||
while (cpuf.hi || cpuf.lo > 0x7fffffffU)
|
while (ex64hi(cpuf) || ex64lo(cpuf) > 0x7fffffffU)
|
||||||
cpuf = div64u64(cpuf, 2);
|
cpuf = div64u64(cpuf, 2);
|
||||||
cpuf.lo = -cpuf.lo;
|
cpuf = make64(-ex64lo(cpuf), ex64hi(cpuf));
|
||||||
watchdog->resetval = watchdog->watchdog_resetval = cpuf;
|
watchdog->resetval = watchdog->watchdog_resetval = cpuf;
|
||||||
|
|
||||||
ia32_msr_write(INTEL_MSR_PERFMON_CRT0, 0, cpuf.lo);
|
ia32_msr_write(INTEL_MSR_PERFMON_CRT0, 0, ex64lo(cpuf));
|
||||||
|
|
||||||
ia32_msr_write(INTEL_MSR_PERFMON_SEL0, 0,
|
ia32_msr_write(INTEL_MSR_PERFMON_SEL0, 0,
|
||||||
val | INTEL_MSR_PERFMON_SEL0_ENABLE);
|
val | INTEL_MSR_PERFMON_SEL0_ENABLE);
|
||||||
@ -54,7 +54,7 @@ PRIVATE void intel_arch_watchdog_init(const unsigned cpu)
|
|||||||
PRIVATE void intel_arch_watchdog_reinit(const unsigned cpu)
|
PRIVATE void intel_arch_watchdog_reinit(const unsigned cpu)
|
||||||
{
|
{
|
||||||
lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI);
|
lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI);
|
||||||
ia32_msr_write(INTEL_MSR_PERFMON_CRT0, 0, watchdog->resetval.lo);
|
ia32_msr_write(INTEL_MSR_PERFMON_CRT0, 0, ex64lo(watchdog->resetval));
|
||||||
}
|
}
|
||||||
|
|
||||||
PUBLIC int arch_watchdog_init(void)
|
PUBLIC int arch_watchdog_init(void)
|
||||||
@ -170,12 +170,12 @@ PRIVATE int intel_arch_watchdog_profile_init(const unsigned freq)
|
|||||||
* if freq is too low and the cpu freq too high we may get in a range of
|
* if freq is too low and the cpu freq too high we may get in a range of
|
||||||
* insane value which cannot be handled by the 31bit CPU perf counter
|
* insane value which cannot be handled by the 31bit CPU perf counter
|
||||||
*/
|
*/
|
||||||
if (cpuf.hi != 0 || cpuf.lo > 0x7fffffffU) {
|
if (ex64hi(cpuf) != 0 || ex64lo(cpuf) > 0x7fffffffU) {
|
||||||
printf("ERROR : nmi watchdog ticks exceed 31bits, use higher frequency\n");
|
printf("ERROR : nmi watchdog ticks exceed 31bits, use higher frequency\n");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpuf.lo = -cpuf.lo;
|
cpuf = make64(-ex64lo(cpuf), ex64hi(cpuf));
|
||||||
watchdog->profile_resetval = cpuf;
|
watchdog->profile_resetval = cpuf;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@ -207,7 +207,7 @@ PRIVATE void amd_watchdog_init(const unsigned cpu)
|
|||||||
watchdog->resetval = watchdog->watchdog_resetval = cpuf;
|
watchdog->resetval = watchdog->watchdog_resetval = cpuf;
|
||||||
|
|
||||||
ia32_msr_write(AMD_MSR_EVENT_CTR0,
|
ia32_msr_write(AMD_MSR_EVENT_CTR0,
|
||||||
watchdog->resetval.hi, watchdog->resetval.lo);
|
ex64hi(watchdog->resetval), ex64lo(watchdog->resetval));
|
||||||
|
|
||||||
ia32_msr_write(AMD_MSR_EVENT_SEL0, 0,
|
ia32_msr_write(AMD_MSR_EVENT_SEL0, 0,
|
||||||
val | AMD_MSR_EVENT_SEL0_ENABLE);
|
val | AMD_MSR_EVENT_SEL0_ENABLE);
|
||||||
@ -220,7 +220,7 @@ PRIVATE void amd_watchdog_reinit(const unsigned cpu)
|
|||||||
{
|
{
|
||||||
lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI);
|
lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI);
|
||||||
ia32_msr_write(AMD_MSR_EVENT_CTR0,
|
ia32_msr_write(AMD_MSR_EVENT_CTR0,
|
||||||
watchdog->resetval.hi, watchdog->resetval.lo);
|
ex64hi(watchdog->resetval), ex64lo(watchdog->resetval));
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIVATE int amd_watchdog_profile_init(const unsigned freq)
|
PRIVATE int amd_watchdog_profile_init(const unsigned freq)
|
||||||
|
@ -262,7 +262,8 @@ PUBLIC void print_proc(struct proc *pp)
|
|||||||
"cr3 0x%lx rts %s misc %s sched %s ",
|
"cr3 0x%lx rts %s misc %s sched %s ",
|
||||||
proc_nr(pp), pp->p_name, pp->p_endpoint,
|
proc_nr(pp), pp->p_name, pp->p_endpoint,
|
||||||
pp->p_priority, pp->p_user_time,
|
pp->p_priority, pp->p_user_time,
|
||||||
pp->p_sys_time, pp->p_cycles.hi, pp->p_cycles.lo, pp->p_cpu,
|
pp->p_sys_time, ex64hi(pp->p_cycles),
|
||||||
|
ex64lo(pp->p_cycles), pp->p_cpu,
|
||||||
pp->p_seg.p_cr3,
|
pp->p_seg.p_cr3,
|
||||||
rtsflagstr(pp->p_rts_flags), miscflagstr(pp->p_misc_flags),
|
rtsflagstr(pp->p_rts_flags), miscflagstr(pp->p_misc_flags),
|
||||||
schedulerstr(pp->p_scheduler));
|
schedulerstr(pp->p_scheduler));
|
||||||
|
@ -126,7 +126,7 @@ static struct block *block_alloc(size_t size)
|
|||||||
read_tsc_64(&tsc);
|
read_tsc_64(&tsc);
|
||||||
totalsize = block_get_totalsize(size);
|
totalsize = block_get_totalsize(size);
|
||||||
page_index_max = (ptr_max - ptr_min - totalsize) / PAGE_SIZE;
|
page_index_max = (ptr_max - ptr_min - totalsize) / PAGE_SIZE;
|
||||||
page_index = (page_index_max > 0) ? (tsc.lo % page_index_max) : 0;
|
page_index = (page_index_max > 0) ? (ex64lo(tsc) % page_index_max) : 0;
|
||||||
ptr = ptr_min + page_index * PAGE_SIZE;
|
ptr = ptr_min + page_index * PAGE_SIZE;
|
||||||
|
|
||||||
/* allocate block */
|
/* allocate block */
|
||||||
|
@ -170,12 +170,14 @@ PUBLIC void procentry (char *name)
|
|||||||
PUBLIC void procexit (char *UNUSED(name))
|
PUBLIC void procexit (char *UNUSED(name))
|
||||||
{
|
{
|
||||||
u64_t stop, spent;
|
u64_t stop, spent;
|
||||||
|
u32_t tsc_lo, tsc_hi;
|
||||||
|
|
||||||
/* Procexit is not reentrant. */
|
/* Procexit is not reentrant. */
|
||||||
if (cprof_locked) return; else cprof_locked = 1;
|
if (cprof_locked) return; else cprof_locked = 1;
|
||||||
|
|
||||||
/* First thing: read CPU cycle count into local variable. */
|
/* First thing: read CPU cycle count into local variable. */
|
||||||
read_tsc(&stop.hi, &stop.lo);
|
read_tsc(&tsc_hi, &tsc_lo);
|
||||||
|
stop = make64(tsc_lo, tsc_hi);
|
||||||
|
|
||||||
/* Only continue if sane. */
|
/* Only continue if sane. */
|
||||||
if (control.err) return;
|
if (control.err) return;
|
||||||
@ -210,7 +212,8 @@ PUBLIC void procexit (char *UNUSED(name))
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Read CPU cycle count. */
|
/* Read CPU cycle count. */
|
||||||
read_tsc(&stop.hi, &stop.lo);
|
read_tsc(&tsc_hi, &tsc_lo);
|
||||||
|
stop = make64(tsc_lo, tsc_hi);
|
||||||
|
|
||||||
/* Calculate "big" difference. */
|
/* Calculate "big" difference. */
|
||||||
spent = sub64(stop, cprof_stk[cprof_stk_top].start_1);
|
spent = sub64(stop, cprof_stk[cprof_stk_top].start_1);
|
||||||
@ -263,8 +266,7 @@ PRIVATE void clear_tbl()
|
|||||||
memset(cprof_tbl[i].cpath, '\0', CPROF_CPATH_MAX_LEN);
|
memset(cprof_tbl[i].cpath, '\0', CPROF_CPATH_MAX_LEN);
|
||||||
cprof_tbl[i].next = 0;
|
cprof_tbl[i].next = 0;
|
||||||
cprof_tbl[i].calls = 0;
|
cprof_tbl[i].calls = 0;
|
||||||
cprof_tbl[i].cycles.lo = 0;
|
cprof_tbl[i].cycles = make64(0, 0);
|
||||||
cprof_tbl[i].cycles.hi = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user