diff --git a/sys/alpha/alpha/clock.c b/sys/alpha/alpha/clock.c index 59acaba72bfb..df3142301369 100644 --- a/sys/alpha/alpha/clock.c +++ b/sys/alpha/alpha/clock.c @@ -157,7 +157,7 @@ static u_int64_t scaled_ticks_per_cycle; static u_int32_t max_cycles_per_tick; static u_int32_t last_time; -static void handleclock(void* arg); +static void handleclock(int usermode, uintfptr_t pc); static void calibrate_clocks(u_int32_t firmware_freq, u_int32_t *pcc, u_int32_t *timer); static void set_timer_freq(u_int freq, int intr_freq); @@ -230,8 +230,7 @@ clockattach(device_t dev) */ /* - * Start the real-time and statistics clocks. Leave stathz 0 since there - * are no other timers available. + * Start the real-time and statistics clocks. */ void cpu_initclocks() @@ -275,7 +274,9 @@ cpu_initclocks() */ if (hwrpb->rpb_type != ST_DEC_21000) { tc_init(&i8254_timecounter); - } + platform.clockintr = handleclock; + } else + platform.clockintr = hardclock; if (ncpus == 1) { alpha_timecounter.tc_frequency = freq; @@ -283,7 +284,7 @@ cpu_initclocks() } stathz = hz / 8; - platform.clockintr = (void (*)(void *)) handleclock; + profhz = hz; /* * Get the clock started. @@ -424,27 +425,23 @@ set_timer_freq(u_int freq, int intr_freq) } static void -handleclock(void *arg) +handleclock(int usermode, uintfptr_t pc) { - /* - * XXX: TurboLaser doesn't have an i8254 counter. - * XXX: A replacement is needed, and another method - * XXX: of determining this would be nice. - */ - if (hwrpb->rpb_type != ST_DEC_21000) { - if (timecounter->tc_get_timecount == i8254_get_timecount) { - mtx_lock_spin(&clock_lock); - if (i8254_ticked) - i8254_ticked = 0; - else { - i8254_offset += timer0_max_count; - i8254_lastcount = 0; - } - clkintr_pending = 0; - mtx_unlock_spin(&clock_lock); + + KASSERT(hwrpb->rpb_type != ST_DEC_21000, + ("custom clock handler called on TurboLaser")); + if (timecounter->tc_get_timecount == i8254_get_timecount) { + mtx_lock_spin(&clock_lock); + if (i8254_ticked) + i8254_ticked = 0; + else { + i8254_offset += timer0_max_count; + i8254_lastcount = 0; } + clkintr_pending = 0; + mtx_unlock_spin(&clock_lock); } - hardclock(arg); + hardclock(usermode, pc); } void diff --git a/sys/alpha/alpha/interrupt.c b/sys/alpha/alpha/interrupt.c index b4a7500c2fb8..0f5ff821a28b 100644 --- a/sys/alpha/alpha/interrupt.c +++ b/sys/alpha/alpha/interrupt.c @@ -489,23 +489,21 @@ alpha_clock_interrupt(struct trapframe *framep) */ if (PCPU_GET(cpuid) == 0) { #endif - (*platform.clockintr)(framep); - /* divide hz (1024) by 8 to get stathz (128) */ - if ((++schedclk2 & 0x7) == 0) { - if (profprocs != 0) - profclock((struct clockframe *)framep); - statclock((struct clockframe *)framep); - } + (*platform.clockintr)(TRAPF_USERMODE(framep), + TRAPF_PC(framep)); + + /* Bump stathz divider. */ + schedclk2++; #ifdef SMP - } else { - hardclock_process((struct clockframe *)framep); - if ((schedclk2 & 0x7) == 0) { - if (profprocs != 0) - profclock((struct clockframe *)framep); - statclock((struct clockframe *)framep); - } - } + } else + hardclock_cpu(TRAPF_USERMODE(framep)); #endif + if (profprocs != 0) + profclock(TRAPF_USERMODE(framep), TRAPF_PC(framep)); + + /* divide hz (1024) by 8 to get stathz (128) */ + if ((schedclk2 & 0x7) == 0) + statclock(TRAPF_USERMODE(framep)); critical_exit(); } } diff --git a/sys/alpha/include/cpu.h b/sys/alpha/include/cpu.h index 212ced04e3b0..a7a6a94701bd 100644 --- a/sys/alpha/include/cpu.h +++ b/sys/alpha/include/cpu.h @@ -48,21 +48,10 @@ #include -/* - * Arguments to hardclock and gatherstats encapsulate the previous - * machine state in an opaque clockframe. One the Alpha, we use - * what we push on an interrupt (a trapframe). - */ -struct clockframe { - struct trapframe cf_tf; -}; #define TRAPF_USERMODE(framep) \ (((framep)->tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) != 0) #define TRAPF_PC(framep) ((framep)->tf_regs[FRAME_PC]) -#define CLKF_USERMODE(framep) TRAPF_USERMODE(&(framep)->cf_tf) -#define CLKF_PC(framep) TRAPF_PC(&(framep)->cf_tf) - /* * CTL_MACHDEP definitions. */ diff --git a/sys/alpha/include/cpuconf.h b/sys/alpha/include/cpuconf.h index 669ca6c9bec3..6f1ccc3ca348 100644 --- a/sys/alpha/include/cpuconf.h +++ b/sys/alpha/include/cpuconf.h @@ -68,7 +68,7 @@ extern struct platform { void (*cons_init)(void); void (*device_register)(struct device *, void *); void (*iointr)(void *, unsigned long); - void (*clockintr)(void *); + void (*clockintr)(int, uintfptr_t); void (*mcheck_handler)(unsigned long, struct trapframe *, unsigned long, unsigned long); void (*cpu_idle)(void); diff --git a/sys/amd64/amd64/local_apic.c b/sys/amd64/amd64/local_apic.c index e81ac65ed77a..a2409b6320fb 100644 --- a/sys/amd64/amd64/local_apic.c +++ b/sys/amd64/amd64/local_apic.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -617,7 +618,7 @@ lapic_handle_intr(int vector, struct trapframe frame) } void -lapic_handle_timer(struct clockframe frame) +lapic_handle_timer(struct trapframe frame) { struct lapic *la; @@ -634,16 +635,16 @@ lapic_handle_timer(struct clockframe frame) if (la->la_hard_ticks >= lapic_timer_hz) { la->la_hard_ticks -= lapic_timer_hz; if (PCPU_GET(cpuid) == 0) - hardclock(&frame); + hardclock(TRAPF_USERMODE(&frame), TRAPF_PC(&frame)); else - hardclock_process(&frame); + hardclock_cpu(TRAPF_USERMODE(&frame)); } /* Fire statclock at stathz. */ la->la_stat_ticks += stathz; if (la->la_stat_ticks >= lapic_timer_hz) { la->la_stat_ticks -= lapic_timer_hz; - statclock(&frame); + statclock(TRAPF_USERMODE(&frame)); } /* Fire profclock at profhz, but only when needed. */ @@ -651,7 +652,7 @@ lapic_handle_timer(struct clockframe frame) if (la->la_prof_ticks >= lapic_timer_hz) { la->la_prof_ticks -= lapic_timer_hz; if (profprocs != 0) - profclock(&frame); + profclock(TRAPF_USERMODE(&frame), TRAPF_PC(&frame)); } critical_exit(); } diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index c0423547034d..c05b05f789bf 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -917,7 +917,7 @@ smp_masked_invlpg_range(u_int mask, vm_offset_t addr1, vm_offset_t addr2) } void -ipi_bitmap_handler(struct clockframe frame) +ipi_bitmap_handler(struct trapframe frame) { int cpu = PCPU_GET(cpuid); u_int ipi_bitmap; diff --git a/sys/amd64/include/apicvar.h b/sys/amd64/include/apicvar.h index ff2dd26d4bda..72603097ae74 100644 --- a/sys/amd64/include/apicvar.h +++ b/sys/amd64/include/apicvar.h @@ -202,7 +202,7 @@ void lapic_ipi_raw(register_t icrlo, u_int dest); void lapic_ipi_vectored(u_int vector, int dest); int lapic_ipi_wait(int delay); void lapic_handle_intr(int vector, struct trapframe frame); -void lapic_handle_timer(struct clockframe frame); +void lapic_handle_timer(struct trapframe frame); void lapic_set_logical_id(u_int apic_id, u_int cluster, u_int cluster_id); int lapic_set_lvt_mask(u_int apic_id, u_int lvt, u_char masked); int lapic_set_lvt_mode(u_int apic_id, u_int lvt, u_int32_t mode); diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h index 3d0fa4a820d4..a8a100f093d0 100644 --- a/sys/amd64/include/clock.h +++ b/sys/amd64/include/clock.h @@ -29,7 +29,6 @@ extern int wall_cmos_clock; /* * Driver to clock driver interface. */ -struct clockframe; int acquire_timer2(int mode); int release_timer2(void); diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h index f069d2ebebb8..15d9e4c757f6 100644 --- a/sys/amd64/include/cpu.h +++ b/sys/amd64/include/cpu.h @@ -59,10 +59,6 @@ (ISPL((framep)->tf_cs) == SEL_UPL) #define TRAPF_PC(framep) ((framep)->tf_rip) -#define CLKF_USERMODE(framep) \ - (ISPL((framep)->cf_cs) == SEL_UPL) -#define CLKF_PC(framep) ((framep)->cf_rip) - /* * CTL_MACHDEP definitions. */ diff --git a/sys/amd64/include/frame.h b/sys/amd64/include/frame.h index 2bf9f3b5508a..26c9dd06d33d 100644 --- a/sys/amd64/include/frame.h +++ b/sys/amd64/include/frame.h @@ -76,34 +76,4 @@ struct trapframe { register_t tf_ss; }; -/* frame of clock (same as interrupt frame) */ - -struct clockframe { - register_t cf_rdi; - register_t cf_rsi; - register_t cf_rdx; - register_t cf_rcx; - register_t cf_r8; - register_t cf_r9; - register_t cf_rax; - register_t cf_rbx; - register_t cf_rbp; - register_t cf_r10; - register_t cf_r11; - register_t cf_r12; - register_t cf_r13; - register_t cf_r14; - register_t cf_r15; - register_t :64; /* compat with trap frame - trapno */ - register_t :64; /* compat with trap frame - addr */ - register_t :64; /* compat with trap frame - flags */ - register_t :64; /* compat with trap frame - err */ - /* below portion defined in hardware */ - register_t cf_rip; - register_t cf_cs; - register_t cf_rflags; - register_t cf_rsp; - register_t cf_ss; -}; - #endif /* _MACHINE_FRAME_H_ */ diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index 45870fea0bd6..94a7022d517b 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -52,7 +52,7 @@ void ipi_selected(u_int cpus, u_int ipi); void ipi_all(u_int ipi); void ipi_all_but_self(u_int ipi); void ipi_self(u_int ipi); -void ipi_bitmap_handler(struct clockframe frame); +void ipi_bitmap_handler(struct trapframe frame); u_int mp_bootaddress(u_int); int mp_grab_cpu_hlt(void); void mp_topology(void); diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 9918a668074f..28116dc08420 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -141,7 +142,7 @@ static struct timecounter i8254_timecounter = { }; static void -clkintr(struct clockframe *frame) +clkintr(struct trapframe *frame) { if (timecounter->tc_get_timecount == i8254_get_timecount) { @@ -155,8 +156,8 @@ clkintr(struct clockframe *frame) clkintr_pending = 0; mtx_unlock_spin(&clock_lock); } - if (!using_lapic_timer) - hardclock(frame); + KASSERT(!using_lapic_timer, ("clk interrupt enabled with lapic timer")); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } int @@ -212,17 +213,17 @@ release_timer2() * in the statistics, but the stat clock will no longer stop. */ static void -rtcintr(struct clockframe *frame) +rtcintr(struct trapframe *frame) { while (rtcin(RTC_INTR) & RTCIR_PERIOD) { if (profprocs != 0) { if (--pscnt == 0) pscnt = psdiv; - profclock(frame); + profclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } if (pscnt == psdiv) - statclock(frame); + statclock(TRAPF_USERMODE(frame)); } } diff --git a/sys/arm/arm/intr.c b/sys/arm/arm/intr.c index 5c9c5816a80b..13b7222e4207 100644 --- a/sys/arm/arm/intr.c +++ b/sys/arm/arm/intr.c @@ -55,7 +55,7 @@ static int intrcnt_tab[NIRQ]; static int intrcnt_index = 0; static int last_printed = 0; -void arm_handler_execute(void *, int); +void arm_handler_execute(struct trapframe *, int); void arm_setup_irqhandler(const char *name, void (*hand)(void*), void *arg, @@ -99,7 +99,7 @@ dosoftints(void) } void -arm_handler_execute(void *frame, int irqnb) +arm_handler_execute(struct trapframe *frame, int irqnb) { struct intr_event *event; struct intr_handler *ih; diff --git a/sys/arm/include/cpu.h b/sys/arm/include/cpu.h index dc9ce0242205..f672c6a520fb 100644 --- a/sys/arm/include/cpu.h +++ b/sys/arm/include/cpu.h @@ -29,10 +29,7 @@ get_cyclecount(void) #define CPU_MAXID 6 /* number of valid machdep ids */ -#define CLKF_USERMODE(frame) ((frame->if_spsr & PSR_MODE) == PSR_USR32_MODE) - #define TRAPF_USERMODE(frame) ((frame->tf_spsr & PSR_MODE) == PSR_USR32_MODE) -#define CLKF_PC(frame) (frame->if_pc) #define TRAPF_PC(tfp) ((tfp)->tf_pc) diff --git a/sys/arm/include/frame.h b/sys/arm/include/frame.h index 4d70c20843dc..0a038293eebf 100644 --- a/sys/arm/include/frame.h +++ b/sys/arm/include/frame.h @@ -137,28 +137,6 @@ typedef struct irqframe { unsigned int if_pc; } irqframe_t; -typedef struct clockframe { - unsigned int if_spsr; - unsigned int if_r0; - unsigned int if_r1; - unsigned int if_r2; - unsigned int if_r3; - unsigned int if_r4; - unsigned int if_r5; - unsigned int if_r6; - unsigned int if_r7; - unsigned int if_r8; - unsigned int if_r9; - unsigned int if_r10; - unsigned int if_r11; - unsigned int if_r12; - unsigned int if_usr_sp; - unsigned int if_usr_lr; - unsigned int if_svc_sp; - unsigned int if_svc_lr; - unsigned int if_pc; -} clockframe_t; - /* * Switch frame */ diff --git a/sys/arm/sa11x0/sa11x0_ost.c b/sys/arm/sa11x0/sa11x0_ost.c index 25241af6ac3b..45c8f90f8b13 100644 --- a/sys/arm/sa11x0/sa11x0_ost.c +++ b/sys/arm/sa11x0/sa11x0_ost.c @@ -54,7 +54,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include @@ -144,7 +146,7 @@ static void clockintr(arg) void *arg; { - struct clockframe *frame = arg; + struct trapframe *frame = arg; u_int32_t oscr, nextmatch, oldmatch; int s; @@ -179,7 +181,7 @@ clockintr(arg) saost_sc->sc_clock_count = nextmatch; bus_space_write_4(saost_sc->sc_iot, saost_sc->sc_ioh, SAOST_MR0, nextmatch); - hardclock(frame); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); #if 0 mtx_unlock_spin(&clock_lock); #endif @@ -190,7 +192,7 @@ static void statintr(arg) void *arg; { - struct clockframe *frame = arg; + struct trapframe *frame = arg; u_int32_t oscr, nextmatch, oldmatch; int s; @@ -225,7 +227,7 @@ statintr(arg) } saost_sc->sc_statclock_count = nextmatch; - statclock(frame); + statclock(TRAPF_USERMODE(frame)); } #endif diff --git a/sys/arm/xscale/i80321/i80321_timer.c b/sys/arm/xscale/i80321/i80321_timer.c index c309cc032047..53a28788f8f7 100644 --- a/sys/arm/xscale/i80321/i80321_timer.c +++ b/sys/arm/xscale/i80321/i80321_timer.c @@ -53,7 +53,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include #include #include @@ -377,11 +379,11 @@ DELAY(int n) void clockhandler(void *arg) { - struct clockframe *frame = arg; + struct trapframe *frame = arg; ticked++; tisr_write(TISR_TMR0); - hardclock(frame); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); if (i80321_hardclock_hook != NULL) (*i80321_hardclock_hook)(); diff --git a/sys/i386/i386/local_apic.c b/sys/i386/i386/local_apic.c index f2d96b572179..ddd7d32bb453 100644 --- a/sys/i386/i386/local_apic.c +++ b/sys/i386/i386/local_apic.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -619,7 +620,7 @@ lapic_handle_intr(int vector, struct trapframe frame) } void -lapic_handle_timer(struct clockframe frame) +lapic_handle_timer(struct trapframe frame) { struct lapic *la; @@ -636,16 +637,16 @@ lapic_handle_timer(struct clockframe frame) if (la->la_hard_ticks >= lapic_timer_hz) { la->la_hard_ticks -= lapic_timer_hz; if (PCPU_GET(cpuid) == 0) - hardclock(&frame); + hardclock(TRAPF_USERMODE(&frame), TRAPF_PC(&frame)); else - hardclock_process(&frame); + hardclock_cpu(TRAPF_USERMODE(&frame)); } /* Fire statclock at stathz. */ la->la_stat_ticks += stathz; if (la->la_stat_ticks >= lapic_timer_hz) { la->la_stat_ticks -= lapic_timer_hz; - statclock(&frame); + statclock(TRAPF_USERMODE(&frame)); } /* Fire profclock at profhz, but only when needed. */ @@ -653,7 +654,7 @@ lapic_handle_timer(struct clockframe frame) if (la->la_prof_ticks >= lapic_timer_hz) { la->la_prof_ticks -= lapic_timer_hz; if (profprocs != 0) - profclock(&frame); + profclock(TRAPF_USERMODE(&frame), TRAPF_PC(&frame)); } critical_exit(); } diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index ab30a3061198..95928a1d6bfb 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -1117,7 +1117,7 @@ smp_masked_invlpg_range(u_int mask, vm_offset_t addr1, vm_offset_t addr2) } void -ipi_bitmap_handler(struct clockframe frame) +ipi_bitmap_handler(struct trapframe frame) { int cpu = PCPU_GET(cpuid); u_int ipi_bitmap; diff --git a/sys/i386/include/apicvar.h b/sys/i386/include/apicvar.h index 0c00b3cec726..8102567d45f1 100644 --- a/sys/i386/include/apicvar.h +++ b/sys/i386/include/apicvar.h @@ -201,7 +201,7 @@ void lapic_ipi_raw(register_t icrlo, u_int dest); void lapic_ipi_vectored(u_int vector, int dest); int lapic_ipi_wait(int delay); void lapic_handle_intr(int vector, struct trapframe frame); -void lapic_handle_timer(struct clockframe frame); +void lapic_handle_timer(struct trapframe frame); void lapic_set_logical_id(u_int apic_id, u_int cluster, u_int cluster_id); int lapic_set_lvt_mask(u_int apic_id, u_int lvt, u_char masked); int lapic_set_lvt_mode(u_int apic_id, u_int lvt, u_int32_t mode); diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h index 8a14df3c34ee..bb6f5e574f78 100644 --- a/sys/i386/include/clock.h +++ b/sys/i386/include/clock.h @@ -29,7 +29,6 @@ extern int wall_cmos_clock; /* * Driver to clock driver interface. */ -struct clockframe; int acquire_timer2(int mode); int release_timer2(void); diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h index ec9ecd3c33b8..fec27e1232cf 100644 --- a/sys/i386/include/cpu.h +++ b/sys/i386/include/cpu.h @@ -59,10 +59,6 @@ ((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM)) #define TRAPF_PC(framep) ((framep)->tf_eip) -#define CLKF_USERMODE(framep) \ - ((ISPL((framep)->cf_cs) == SEL_UPL) || ((framep)->cf_eflags & PSL_VM)) -#define CLKF_PC(framep) ((framep)->cf_eip) - /* * CTL_MACHDEP definitions. */ diff --git a/sys/i386/include/frame.h b/sys/i386/include/frame.h index 26c5c9eedb5e..3558b98d14c1 100644 --- a/sys/i386/include/frame.h +++ b/sys/i386/include/frame.h @@ -97,29 +97,4 @@ struct trapframe_vm86 { int tf_vm86_gs; }; -/* frame of clock (same as trap frame) */ - -struct clockframe { - int cf_fs; - int cf_es; - int cf_ds; - int cf_edi; - int cf_esi; - int cf_ebp; - int :32; - int cf_ebx; - int cf_edx; - int cf_ecx; - int cf_eax; - int :32; /* for compat with trap frame - trapno */ - int :32; /* for compat with trap frame - err */ - /* below portion defined in 386 hardware */ - int cf_eip; - int cf_cs; - int cf_eflags; - /* below only when crossing rings (e.g. user to kernel) */ - int cf_esp; - int cf_ss; -}; - #endif /* _MACHINE_FRAME_H_ */ diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index e197fb2ed462..bd67a33ca5fa 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -61,7 +61,7 @@ void ipi_selected(u_int cpus, u_int ipi); void ipi_all(u_int ipi); void ipi_all_but_self(u_int ipi); void ipi_self(u_int ipi); -void ipi_bitmap_handler(struct clockframe frame); +void ipi_bitmap_handler(struct trapframe frame); u_int mp_bootaddress(u_int); int mp_grab_cpu_hlt(void); void mp_topology(void); diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 7a75cfb0befc..f785849faca5 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -155,7 +156,7 @@ static struct timecounter i8254_timecounter = { }; static void -clkintr(struct clockframe *frame) +clkintr(struct trapframe *frame) { if (timecounter->tc_get_timecount == i8254_get_timecount) { @@ -169,8 +170,8 @@ clkintr(struct clockframe *frame) clkintr_pending = 0; mtx_unlock_spin(&clock_lock); } - if (!using_lapic_timer) - hardclock(frame); + KASSERT(!using_lapic_timer, ("clk interrupt enabled with lapic timer")); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); #ifdef DEV_MCA /* Reset clock interrupt by asserting bit 7 of port 0x61 */ if (MCA_system) @@ -231,17 +232,17 @@ release_timer2() * in the statistics, but the stat clock will no longer stop. */ static void -rtcintr(struct clockframe *frame) +rtcintr(struct trapframe *frame) { while (rtcin(RTC_INTR) & RTCIR_PERIOD) { if (profprocs != 0) { if (--pscnt == 0) pscnt = psdiv; - profclock(frame); + profclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } if (pscnt == psdiv) - statclock(frame); + statclock(TRAPF_USERMODE(frame)); } } diff --git a/sys/ia64/ia64/interrupt.c b/sys/ia64/ia64/interrupt.c index 1a0c3d162bba..dbd3d6867e6e 100644 --- a/sys/ia64/ia64/interrupt.c +++ b/sys/ia64/ia64/interrupt.c @@ -173,12 +173,12 @@ interrupt(u_int64_t vector, struct trapframe *tf) while (delta >= ia64_clock_reload) { /* Only the BSP runs the real clock */ if (PCPU_GET(cpuid) == 0) - hardclock((struct clockframe *)tf); + hardclock(TRAPF_USERMODE(tf), TRAPF_PC(tf)); else - hardclock_process((struct clockframe *)tf); + hardclock_cpu(TRAPF_USERMODE(tf)); if (profprocs != 0) - profclock((struct clockframe *)tf); - statclock((struct clockframe *)tf); + profclock(TRAPF_USERMODE(tf), TRAPF_PC(tf)); + statclock(TRAPF_USERMODE(tf)); delta -= ia64_clock_reload; clk += ia64_clock_reload; if (adj != 0) diff --git a/sys/ia64/include/cpu.h b/sys/ia64/include/cpu.h index 424360acf825..982733d88a2c 100644 --- a/sys/ia64/include/cpu.h +++ b/sys/ia64/include/cpu.h @@ -44,17 +44,6 @@ #include -/* - * Arguments to hardclock and gatherstats encapsulate the previous machine - * state in an opaque clockframe. - */ -struct clockframe { - struct trapframe cf_tf; -}; -#define CLKF_PC(cf) ((cf)->cf_tf.tf_special.iip) -#define CLKF_CPL(cf) ((cf)->cf_tf.tf_special.psr & IA64_PSR_CPL) -#define CLKF_USERMODE(cf) (CLKF_CPL(cf) != IA64_PSR_CPL_KERN) - #define TRAPF_PC(tf) ((tf)->tf_special.iip) #define TRAPF_CPL(tf) ((tf)->tf_special.psr & IA64_PSR_CPL) #define TRAPF_USERMODE(tf) (TRAPF_CPL(tf) != IA64_PSR_CPL_KERN) diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index 7a75cfb0befc..f785849faca5 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -155,7 +156,7 @@ static struct timecounter i8254_timecounter = { }; static void -clkintr(struct clockframe *frame) +clkintr(struct trapframe *frame) { if (timecounter->tc_get_timecount == i8254_get_timecount) { @@ -169,8 +170,8 @@ clkintr(struct clockframe *frame) clkintr_pending = 0; mtx_unlock_spin(&clock_lock); } - if (!using_lapic_timer) - hardclock(frame); + KASSERT(!using_lapic_timer, ("clk interrupt enabled with lapic timer")); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); #ifdef DEV_MCA /* Reset clock interrupt by asserting bit 7 of port 0x61 */ if (MCA_system) @@ -231,17 +232,17 @@ release_timer2() * in the statistics, but the stat clock will no longer stop. */ static void -rtcintr(struct clockframe *frame) +rtcintr(struct trapframe *frame) { while (rtcin(RTC_INTR) & RTCIR_PERIOD) { if (profprocs != 0) { if (--pscnt == 0) pscnt = psdiv; - profclock(frame); + profclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } if (pscnt == psdiv) - statclock(frame); + statclock(TRAPF_USERMODE(frame)); } } diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 4ffa978e1fa4..33336b9669cd 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -65,8 +65,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #ifdef GPROF #include #endif @@ -189,12 +187,11 @@ initclocks(dummy) /* * Each time the real-time timer fires, this function is called on all CPUs. - * Note that hardclock() calls hardclock_process() for the boot CPU, so only + * Note that hardclock() calls hardclock_cpu() for the boot CPU, so only * the other CPUs in the system need to call this function. */ void -hardclock_process(frame) - register struct clockframe *frame; +hardclock_cpu(int usermode) { struct pstats *pstats; struct thread *td = curthread; @@ -208,7 +205,7 @@ hardclock_process(frame) /* XXXKSE What to do? */ } else { pstats = p->p_stats; - if (CLKF_USERMODE(frame) && + if (usermode && timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) && itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) { p->p_sflag |= PS_ALRMPEND; @@ -232,12 +229,11 @@ hardclock_process(frame) * The real-time timer, interrupting hz times per second. */ void -hardclock(frame) - register struct clockframe *frame; +hardclock(int usermode, uintfptr_t pc) { int need_softclock = 0; - hardclock_process(frame); + hardclock_cpu(usermode); tc_ticktock(); /* @@ -246,8 +242,8 @@ hardclock(frame) * XXX: this only works for UP */ if (stathz == 0) { - profclock(frame); - statclock(frame); + profclock(usermode, pc); + statclock(usermode); } #ifdef DEVICE_POLLING @@ -401,8 +397,7 @@ stopprofclock(p) * This should be called by all active processors. */ void -statclock(frame) - register struct clockframe *frame; +statclock(int usermode) { struct rusage *ru; struct vmspace *vm; @@ -414,7 +409,7 @@ statclock(frame) p = td->td_proc; mtx_lock_spin_flags(&sched_lock, MTX_QUIET); - if (CLKF_USERMODE(frame)) { + if (usermode) { /* * Charge the time as appropriate. */ @@ -473,8 +468,7 @@ statclock(frame) } void -profclock(frame) - register struct clockframe *frame; +profclock(int usermode, uintfptr_t pc) { struct thread *td; #ifdef GPROF @@ -483,7 +477,7 @@ profclock(frame) #endif td = curthread; - if (CLKF_USERMODE(frame)) { + if (usermode) { /* * Came from user mode; CPU was in user state. * If this process is being profiled, record the tick. @@ -491,7 +485,7 @@ profclock(frame) * bother trying to count it. */ if (td->td_proc->p_flag & P_PROFIL) - addupc_intr(td, CLKF_PC(frame), 1); + addupc_intr(td, pc, 1); } #ifdef GPROF else { @@ -499,11 +493,10 @@ profclock(frame) * Kernel statistics are just like addupc_intr, only easier. */ g = &_gmonparam; - if (g->state == GMON_PROF_ON && CLKF_PC(frame) >= g->lowpc) { - i = PC_TO_I(g, CLKF_PC(frame)); + if (g->state == GMON_PROF_ON && pc >= g->lowpc) { + i = PC_TO_I(g, pc); if (i < g->textsize) { - i /= HISTFRACTION * sizeof(*g->kcount); - g->kcount[i]++; + KCOUNT(g, i)++; } } } diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c index 0260e7bf2cbe..979a3a0369e9 100644 --- a/sys/pc98/cbus/clock.c +++ b/sys/pc98/cbus/clock.c @@ -149,7 +149,7 @@ static struct timecounter i8254_timecounter = { }; static void -clkintr(struct clockframe *frame) +clkintr(struct trapframe *frame) { if (timecounter->tc_get_timecount == i8254_get_timecount) { @@ -163,8 +163,8 @@ clkintr(struct clockframe *frame) clkintr_pending = 0; mtx_unlock_spin(&clock_lock); } - if (!using_lapic_timer) - hardclock(frame); + KASSERT(!using_lapic_timer, ("clk interrupt enabled with lapic timer")); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } int diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c index 0260e7bf2cbe..979a3a0369e9 100644 --- a/sys/pc98/cbus/pcrtc.c +++ b/sys/pc98/cbus/pcrtc.c @@ -149,7 +149,7 @@ static struct timecounter i8254_timecounter = { }; static void -clkintr(struct clockframe *frame) +clkintr(struct trapframe *frame) { if (timecounter->tc_get_timecount == i8254_get_timecount) { @@ -163,8 +163,8 @@ clkintr(struct clockframe *frame) clkintr_pending = 0; mtx_unlock_spin(&clock_lock); } - if (!using_lapic_timer) - hardclock(frame); + KASSERT(!using_lapic_timer, ("clk interrupt enabled with lapic timer")); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } int diff --git a/sys/powerpc/aim/clock.c b/sys/powerpc/aim/clock.c index 8d738ec14d09..3bff3dd5ddd2 100644 --- a/sys/powerpc/aim/clock.c +++ b/sys/powerpc/aim/clock.c @@ -183,7 +183,7 @@ resettodr() } void -decr_intr(struct clockframe *frame) +decr_intr(struct trapframe *frame) { u_long tb; long tick; @@ -225,10 +225,10 @@ decr_intr(struct clockframe *frame) */ #if 0 while (--nticks > 0) { - hardclock(frame); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } #endif - hardclock(frame); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } void diff --git a/sys/powerpc/aim/interrupt.c b/sys/powerpc/aim/interrupt.c index 08a43b719e14..04a450678d5d 100644 --- a/sys/powerpc/aim/interrupt.c +++ b/sys/powerpc/aim/interrupt.c @@ -72,7 +72,7 @@ ext_intr_install(void (*new_extint)(void)) powerpc_extintr_handler = new_extint; } -extern void decr_intr(struct clockframe *); +extern void decr_intr(struct trapframe *); extern void trap(struct trapframe *); /* @@ -84,7 +84,6 @@ void powerpc_interrupt(struct trapframe *framep) { struct thread *td; - struct clockframe ckframe; td = curthread; @@ -97,9 +96,7 @@ powerpc_interrupt(struct trapframe *framep) case EXC_DECR: atomic_add_int(&td->td_intr_nesting_level, 1); - ckframe.srr0 = framep->srr0; - ckframe.srr1 = framep->srr1; - decr_intr(&ckframe); + decr_intr(framep); atomic_subtract_int(&td->td_intr_nesting_level, 1); break; diff --git a/sys/powerpc/include/clock.h b/sys/powerpc/include/clock.h index fb4525927a99..a0918c901fa4 100644 --- a/sys/powerpc/include/clock.h +++ b/sys/powerpc/include/clock.h @@ -19,7 +19,7 @@ int sysbeep(int pitch, int period); int acquire_timer2(int mode); int release_timer2(void); -void decr_intr(struct clockframe *); +void decr_intr(struct trapframe *); #endif diff --git a/sys/powerpc/include/cpu.h b/sys/powerpc/include/cpu.h index 73a882b402b0..913c910bba5d 100644 --- a/sys/powerpc/include/cpu.h +++ b/sys/powerpc/include/cpu.h @@ -39,11 +39,6 @@ #include #include -#define CLKF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) -#define CLKF_BASEPRI(frame) ((frame)->pri == 0) -#define CLKF_PC(frame) ((frame)->srr0) -#define CLKF_INTR(frame) ((frame)->depth > 0) - #define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) #define TRAPF_PC(frame) ((frame)->srr0) diff --git a/sys/powerpc/include/frame.h b/sys/powerpc/include/frame.h index 096ed673c015..09b7a9517771 100644 --- a/sys/powerpc/include/frame.h +++ b/sys/powerpc/include/frame.h @@ -65,13 +65,6 @@ struct trapframe { #define FRAMELEN roundup(sizeof(struct trapframe) + 8, 16) #define trapframe(td) ((td)->td_frame) -struct clockframe { - register_t srr1; - register_t srr0; - int pri; - int depth; -}; - /* * Call frame for PowerPC used during fork. */ diff --git a/sys/powerpc/powerpc/clock.c b/sys/powerpc/powerpc/clock.c index 8d738ec14d09..3bff3dd5ddd2 100644 --- a/sys/powerpc/powerpc/clock.c +++ b/sys/powerpc/powerpc/clock.c @@ -183,7 +183,7 @@ resettodr() } void -decr_intr(struct clockframe *frame) +decr_intr(struct trapframe *frame) { u_long tb; long tick; @@ -225,10 +225,10 @@ decr_intr(struct clockframe *frame) */ #if 0 while (--nticks > 0) { - hardclock(frame); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } #endif - hardclock(frame); + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } void diff --git a/sys/powerpc/powerpc/interrupt.c b/sys/powerpc/powerpc/interrupt.c index 08a43b719e14..04a450678d5d 100644 --- a/sys/powerpc/powerpc/interrupt.c +++ b/sys/powerpc/powerpc/interrupt.c @@ -72,7 +72,7 @@ ext_intr_install(void (*new_extint)(void)) powerpc_extintr_handler = new_extint; } -extern void decr_intr(struct clockframe *); +extern void decr_intr(struct trapframe *); extern void trap(struct trapframe *); /* @@ -84,7 +84,6 @@ void powerpc_interrupt(struct trapframe *framep) { struct thread *td; - struct clockframe ckframe; td = curthread; @@ -97,9 +96,7 @@ powerpc_interrupt(struct trapframe *framep) case EXC_DECR: atomic_add_int(&td->td_intr_nesting_level, 1); - ckframe.srr0 = framep->srr0; - ckframe.srr1 = framep->srr1; - decr_intr(&ckframe); + decr_intr(framep); atomic_subtract_int(&td->td_intr_nesting_level, 1); break; diff --git a/sys/sparc64/include/cpu.h b/sys/sparc64/include/cpu.h index 4dfe1e9af0fa..f15078b7fe65 100644 --- a/sys/sparc64/include/cpu.h +++ b/sys/sparc64/include/cpu.h @@ -40,9 +40,6 @@ #include #include -#define CLKF_USERMODE(cfp) TRAPF_USERMODE(&(cfp)->cf_tf) -#define CLKF_PC(cfp) TRAPF_PC(&(cfp)->cf_tf) - #define TRAPF_PC(tfp) ((tfp)->tf_tpc) #define TRAPF_USERMODE(tfp) (((tfp)->tf_tstate & TSTATE_PRIV) == 0) diff --git a/sys/sparc64/include/frame.h b/sys/sparc64/include/frame.h index 500a38fafe26..a82d4aa3ee92 100644 --- a/sys/sparc64/include/frame.h +++ b/sys/sparc64/include/frame.h @@ -62,10 +62,6 @@ struct trapframe { tf->tf_tnpc += 4; \ } while (0) -struct clockframe { - struct trapframe cf_tf; -}; - struct frame { u_long fr_local[8]; u_long fr_in[8]; diff --git a/sys/sparc64/sparc64/tick.c b/sys/sparc64/sparc64/tick.c index 64de96b7e076..09ba1f124198 100644 --- a/sys/sparc64/sparc64/tick.c +++ b/sys/sparc64/sparc64/tick.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -62,7 +63,7 @@ static int adjust_ticks = 0; SYSCTL_INT(_machdep_tick, OID_AUTO, adjust_ticks, CTLFLAG_RD, &adjust_ticks, 0, "total number of tick interrupts with adjustment"); -static void tick_hardclock(struct clockframe *); +static void tick_hardclock(struct trapframe *); void cpu_initclocks(void) @@ -73,20 +74,20 @@ cpu_initclocks(void) } static __inline void -tick_process(struct clockframe *cf) +tick_process(struct trapframe *tf) { if (PCPU_GET(cpuid) == 0) - hardclock(cf); + hardclock(TRAPF_USERMODE(tf), TRAPF_PC(tf)); else - hardclock_process(cf); + hardclock_cpu(TRAPF_USERMODE(tf)); if (profprocs != 0) - profclock(cf); - statclock(cf); + profclock(TRAPF_USERMODE(tf), TRAPF_PC(tf)); + statclock(TRAPF_USERMODE(tf)); } static void -tick_hardclock(struct clockframe *cf) +tick_hardclock(struct trapframe *tf) { u_long adj, s, tick, ref; long delta; @@ -108,7 +109,7 @@ tick_hardclock(struct clockframe *cf) delta = tick - ref; count = 0; while (delta >= tick_increment) { - tick_process(cf); + tick_process(tf); delta -= tick_increment; ref += tick_increment; if (adj != 0) @@ -163,8 +164,7 @@ tick_start(void) u_long base, s; if (PCPU_GET(cpuid) == 0) - intr_setup(PIL_TICK, (ih_func_t *)tick_hardclock, -1, NULL, - NULL); + intr_setup(PIL_TICK, tick_hardclock, -1, NULL, NULL); /* * Try to make the tick interrupts as synchronously as possible on diff --git a/sys/sys/systm.h b/sys/sys/systm.h index cbd95ee316ff..400758c90dfb 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -112,7 +112,6 @@ extern char **kenvp; * General function declarations. */ -struct clockframe; struct malloc_type; struct mtx; struct proc; @@ -207,11 +206,11 @@ intptr_t casuptr(intptr_t *p, intptr_t old, intptr_t new); void realitexpire(void *); -void hardclock(struct clockframe *frame); -void hardclock_process(struct clockframe *frame); +void hardclock(int usermode, uintfptr_t pc); +void hardclock_cpu(int usermode); void softclock(void *); -void statclock(struct clockframe *frame); -void profclock(struct clockframe *frame); +void statclock(int usermode); +void profclock(int usermode, uintfptr_t pc); void startprofclock(struct proc *); void stopprofclock(struct proc *);