Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/arch/x86/x86/lapic.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/arch/x86/x86/lapic.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.20 retrieving revision 1.20.22.5 diff -u -p -r1.20 -r1.20.22.5 --- src/sys/arch/x86/x86/lapic.c 2007/02/09 21:55:14 1.20 +++ src/sys/arch/x86/x86/lapic.c 2007/09/06 00:55:03 1.20.22.5 @@ -1,4 +1,4 @@ -/* $NetBSD: lapic.c,v 1.20 2007/02/09 21:55:14 ad Exp $ */ +/* $NetBSD: lapic.c,v 1.20.22.5 2007/09/06 00:55:03 joerg Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.20 2007/02/09 21:55:14 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.20.22.5 2007/09/06 00:55:03 joerg Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -67,9 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1. #include #include #include -#ifdef _HAVE_TIMECOUNTER #include -#endif #include #include @@ -77,7 +75,7 @@ __KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1. void lapic_delay(int); void lapic_microtime(struct timeval *); -static u_int32_t lapic_gettick(void); +static uint32_t lapic_gettick(void); void lapic_clockintr(void *, struct intrframe *); static void lapic_map(paddr_t); @@ -85,6 +83,14 @@ static void lapic_hwmask(struct pic *, i static void lapic_hwunmask(struct pic *, int); static void lapic_setup(struct pic *, struct cpu_info *, int, int, int); +static const struct lapic_state { + uint32_t id, + tpri, + ldr, + dfr, + svr; +} lapic_state; + extern char idt_allocmap[]; struct pic local_pic = { @@ -100,8 +106,7 @@ struct pic local_pic = { }; static void -lapic_map(lapic_base) - paddr_t lapic_base; +lapic_map(paddr_t lapic_base) { int s; pt_entry_t *pte; @@ -135,13 +140,18 @@ lapic_map(lapic_base) * enable local apic */ void -lapic_enable() +lapic_enable(void) { i82489_writereg(LAPIC_SVR, LAPIC_SVR_ENABLE | LAPIC_SPURIOUS_VECTOR); } void -lapic_set_lvt() +lapic_suspend(void) +{ +} + +void +lapic_set_lvt(void) { struct cpu_info *ci = curcpu(); int i; @@ -203,14 +213,17 @@ lapic_set_lvt() * Initialize fixed idt vectors for use by local apic. */ void -lapic_boot_init(lapic_base) - paddr_t lapic_base; +lapic_boot_init(paddr_t lapic_base) { lapic_map(lapic_base); #ifdef MULTIPROCESSOR idt_allocmap[LAPIC_IPI_VECTOR] = 1; idt_vec_set(LAPIC_IPI_VECTOR, Xintr_lapic_ipi); + idt_allocmap[LAPIC_TLB_MCAST_VECTOR] = 1; + idt_vec_set(LAPIC_TLB_MCAST_VECTOR, Xintr_lapic_tlb_mcast); + idt_allocmap[LAPIC_TLB_BCAST_VECTOR] = 1; + idt_vec_set(LAPIC_TLB_BCAST_VECTOR, Xintr_lapic_tlb_bcast); #endif idt_allocmap[LAPIC_SPURIOUS_VECTOR] = 1; idt_vec_set(LAPIC_SPURIOUS_VECTOR, Xintrspurious); @@ -219,7 +232,8 @@ lapic_boot_init(lapic_base) idt_vec_set(LAPIC_TIMER_VECTOR, Xintr_lapic_ltimer); } -static inline u_int32_t lapic_gettick() +static uint32_t +lapic_gettick(void) { return i82489_readreg(LAPIC_CCR_TIMER); } @@ -227,38 +241,36 @@ static inline u_int32_t lapic_gettick() #include /* for hz */ int lapic_timer = 0; -u_int32_t lapic_tval; +uint32_t lapic_tval; /* * this gets us up to a 4GHz busclock.... */ -u_int32_t lapic_per_second; -u_int32_t lapic_frac_usec_per_cycle; -u_int64_t lapic_frac_cycle_per_usec; -u_int32_t lapic_delaytab[26]; +uint32_t lapic_per_second; +uint32_t lapic_frac_usec_per_cycle; +uint64_t lapic_frac_cycle_per_usec; +uint32_t lapic_delaytab[26]; + +extern u_int i8254_get_timecount(struct timecounter *); void lapic_clockintr(void *arg, struct intrframe *frame) { #if defined(I586_CPU) || defined(I686_CPU) || defined(__x86_64__) -#ifndef __HAVE_TIMECOUNTER - static int microset_iter; /* call cc_microset once/sec */ -#endif /* __HAVE_TIMECOUNTER */ -#if defined(TIMECOUNTER_DEBUG) && defined(__HAVE_TIMECOUNTER) +#if defined(TIMECOUNTER_DEBUG) static u_int last_count[X86_MAXPROCS], last_delta[X86_MAXPROCS], last_tsc[X86_MAXPROCS], last_tscdelta[X86_MAXPROCS], last_factor[X86_MAXPROCS]; -#endif /* TIMECOUNTER_DEBUG && __HAVE_TIMECOUNTER */ +#endif /* TIMECOUNTER_DEBUG */ struct cpu_info *ci = curcpu(); ci->ci_isources[LIR_TIMER]->is_evcnt.ev_count++; -#if defined(TIMECOUNTER_DEBUG) && defined(__HAVE_TIMECOUNTER) +#if defined(TIMECOUNTER_DEBUG) { int cid = ci->ci_cpuid; - extern u_int i8254_get_timecount(struct timecounter *); u_int c_count = i8254_get_timecount(NULL); u_int c_tsc = cpu_counter32(); u_int delta, ddelta, tsc_delta, factor = 0; @@ -314,44 +326,16 @@ lapic_clockintr(void *arg, struct intrfr last_tsc[cid] = c_tsc; last_tscdelta[cid] = tsc_delta; } -#endif /* TIMECOUNTER_DEBUG && __HAVE_TIMECOUNTER */ - -#ifndef __HAVE_TIMECOUNTER - /* - * If we have a cycle counter, do the microset thing. - */ - if (ci->ci_feature_flags & CPUID_TSC) { - if (CPU_IS_PRIMARY(ci) && (microset_iter--) == 0) { - microset_iter = hz - 1; - cc_microset_time = time; -#if defined(MULTIPROCESSOR) - x86_broadcast_ipi(X86_IPI_MICROSET); -#endif - cc_microset(ci); - } - } -#endif /* !__HAVE_TIMECOUNTER */ +#endif /* TIMECOUNTER_DEBUG */ #endif /* I586_CPU || I686_CPU || __x86_64__ */ hardclock((struct clockframe *)frame); } -#if !defined(__HAVE_TIMECOUNTER) && defined(NTP) -extern int fixtick; -#endif /* !__HAVE_TIMECOUNTER && NTP */ - void -lapic_initclocks() +lapic_initclocks(void) { -#if !defined(__HAVE_TIMECOUNTER) && defined(NTP) - /* - * we'll actually get (lapic_per_second/lapic_tval) interrupts/sec. - */ - fixtick = 1000000 - - ((int64_t)tick * lapic_per_second + lapic_tval / 2) / lapic_tval; -#endif /* !__HAVE_TIMECOUNTER && NTP */ - /* * Start local apic countdown timer running, in repeated mode. * @@ -381,12 +365,11 @@ extern void (*initclock_func)(void); /* * We're actually using the IRQ0 timer. Hmm. */ void -lapic_calibrate_timer(ci) - struct cpu_info *ci; +lapic_calibrate_timer(struct cpu_info *ci) { unsigned int starttick, tick1, tick2, endtick; unsigned int startapic, apic1, apic2, endapic; - u_int64_t dtick, dapic, tmp; + uint64_t dtick, dapic, tmp; int i; char tbuf[9]; @@ -474,11 +457,7 @@ lapic_calibrate_timer(ci) */ delay_func = lapic_delay; initclock_func = lapic_initclocks; -#ifdef __HAVE_TIMECOUNTER initrtclock(0); -#else - initrtclock(); -#endif } } @@ -486,8 +465,8 @@ lapic_calibrate_timer(ci) * delay for N usec. */ -void lapic_delay(usec) - int usec; +void +lapic_delay(int usec) { int32_t xtick, otick; int64_t deltat; /* XXX may want to be 64bit */ @@ -517,10 +496,8 @@ void lapic_delay(usec) * XXX the following belong mostly or partly elsewhere.. */ -static inline void i82489_icr_wait(void); - -static inline void -i82489_icr_wait() +static void +i82489_icr_wait(void) { #ifdef DIAGNOSTIC unsigned j = 100000; @@ -537,8 +514,7 @@ i82489_icr_wait() } int -x86_ipi_init(target) - int target; +x86_ipi_init(int target) { if ((target&LAPIC_DEST_MASK)==0) { @@ -561,8 +537,7 @@ x86_ipi_init(target) } int -x86_ipi(vec,target,dl) - int vec,target,dl; +x86_ipi(int vec, int target, int dl) { int result, s; @@ -576,10 +551,13 @@ x86_ipi(vec,target,dl) i82489_writereg(LAPIC_ICRLO, (target & LAPIC_DEST_MASK) | vec | dl | LAPIC_LVL_ASSERT); +#ifdef DIAGNOSTIC i82489_icr_wait(); - result = (i82489_readreg(LAPIC_ICRLO) & LAPIC_DLSTAT_BUSY) ? EBUSY : 0; - +#else + /* Don't wait - if it doesn't go, we're in big trouble anyway. */ + result = 0; +#endif splx(s); return result;