Tweak how the MD code calls the fooclock() methods some. Instead of

passing a pointer to an opaque clockframe structure and requiring the
MD code to supply CLKF_FOO() macros to extract needed values out of the
opaque structure, just pass the needed values directly.  In practice this
means passing the pair (usermode, pc) to hardclock() and profclock() and
passing the boolean (usermode) to hardclock_cpu() and hardclock_process().
Other details:
- Axe clockframe and CLKF_FOO() macros on all architectures.  Basically,
  all the archs were taking a trapframe and converting it into a clockframe
  one way or another.  Now they can just extract the PC and usermode values
  directly out of the trapframe and pass it to fooclock().
- Renamed hardclock_process() to hardclock_cpu() as the latter is more
  accurate.
- On Alpha, we now run profclock() at hz (profhz == hz) rather than at
  the slower stathz.
- On Alpha, for the TurboLaser machines that don't have an 8254
  timecounter, call hardclock() directly.  This removes an extra
  conditional check from every clock interrupt on Alpha on the BSP.
  There is probably room for even further pruning here by changing Alpha
  to use the simplified timecounter we use on x86 with the lapic timer
  since we don't get interrupts from the 8254 on Alpha anyway.
- On x86, clkintr() shouldn't ever be called now unless using_lapic_timer
  is false, so add a KASSERT() to that affect and remove a condition
  to slightly optimize the non-lapic case.
- Change prototypeof  arm_handler_execute() so that it's first arg is a
  trapframe pointer rather than a void pointer for clarity.
- Use KCOUNT macro in profclock() to lookup the kernel profiling bucket.

Tested on:	alpha, amd64, arm, i386, ia64, sparc64
Reviewed by:	bde (mostly)
This commit is contained in:
jhb 2005-12-22 22:16:09 +00:00
parent fdec22285a
commit cb0d490ebe
42 changed files with 135 additions and 276 deletions

View File

@ -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

View File

@ -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();
}
}

View File

@ -48,21 +48,10 @@
#include <machine/frame.h>
/*
* 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.
*/

View File

@ -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);

View File

@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>
#include <machine/apicreg.h>
#include <machine/cpu.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
#include <machine/intr_machdep.h>
@ -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();
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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.
*/

View File

@ -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_ */

View File

@ -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);

View File

@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
#include <sys/power.h>
#include <machine/clock.h>
#include <machine/cpu.h>
#include <machine/frame.h>
#include <machine/intr_machdep.h>
#include <machine/md_var.h>
@ -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));
}
}

View File

@ -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;

View File

@ -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)

View File

@ -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
*/

View File

@ -54,7 +54,9 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <machine/intr.h>
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <machine/frame.h>
#include <machine/katelib.h>
@ -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

View File

@ -53,7 +53,9 @@ __FBSDID("$FreeBSD$");
#include <sys/timetc.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <machine/frame.h>
#include <machine/resource.h>
#include <machine/intr.h>
#include <arm/xscale/i80321/i80321reg.h>
@ -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)();

View File

@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>
#include <machine/apicreg.h>
#include <machine/cpu.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
#include <machine/intr_machdep.h>
@ -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();
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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.
*/

View File

@ -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_ */

View File

@ -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);

View File

@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
#include <sys/power.h>
#include <machine/clock.h>
#include <machine/cpu.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
#include <machine/intr_machdep.h>
@ -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));
}
}

View File

@ -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)

View File

@ -44,17 +44,6 @@
#include <machine/frame.h>
/*
* 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)

View File

@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
#include <sys/power.h>
#include <machine/clock.h>
#include <machine/cpu.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
#include <machine/intr_machdep.h>
@ -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));
}
}

View File

@ -65,8 +65,6 @@ __FBSDID("$FreeBSD$");
#include <sys/limits.h>
#include <sys/timetc.h>
#include <machine/cpu.h>
#ifdef GPROF
#include <sys/gmon.h>
#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)++;
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -39,11 +39,6 @@
#include <machine/pcb.h>
#include <machine/psl.h>
#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)

View File

@ -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.
*/

View File

@ -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

View File

@ -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;

View File

@ -40,9 +40,6 @@
#include <machine/frame.h>
#include <machine/tstate.h>
#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)

View File

@ -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];

View File

@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/timetc.h>
#include <machine/clock.h>
#include <machine/cpu.h>
#include <machine/frame.h>
#include <machine/intr_machdep.h>
#include <machine/tick.h>
@ -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

View File

@ -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 *);