PERFORCE change 132587 for review
John Birrell
jb at FreeBSD.org
Sat Jan 5 13:59:26 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=132587
Change 132587 by jb at jb_freebsd1 on 2008/01/05 21:59:02
Update to match the amd64 implementation.
Affected files ...
.. //depot/projects/dtrace/src/sys/cddl/i386/cyclic_machdep.c#7 edit
Differences ...
==== //depot/projects/dtrace/src/sys/cddl/i386/cyclic_machdep.c#7 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright 2006 John Birrell <jb at FreeBSD.org>
+ * Copyright 2007-2008 John Birrell <jb at FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,193 +26,104 @@
*
*/
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/interrupt.h>
-#include <sys/kernel.h>
-#include <sys/pcpu.h>
-#include <sys/cyclic_impl.h>
-
-extern cyclic_clock_func_t lapic_cyclic_clock_func;
-
-static cyb_arg_t configure(cpu_t *);
-static void unconfigure(cyb_arg_t);
static void enable(cyb_arg_t);
static void disable(cyb_arg_t);
static void reprogram(cyb_arg_t, hrtime_t);
-static void softint(cyb_arg_t, cyc_level_t);
-static cyc_cookie_t set_level(cyb_arg_t, cyc_level_t);
-static void restore_level(cyb_arg_t, cyc_cookie_t);
static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *);
-static void suspend(cyb_arg_t);
-static void resume(cyb_arg_t);
static cyc_backend_t be = {
- configure,
- unconfigure,
+ NULL, /* cyb_configure */
+ NULL, /* cyb_unconfigure */
enable,
disable,
reprogram,
- softint,
- set_level,
- restore_level,
xcall,
- suspend,
- resume,
NULL /* cyb_arg_t cyb_arg */
};
-static hrtime_t resolution;
-static int hpet_present = 0;
-static void *cyclic_lock_ih;
-static void *cyclic_low_ih;
-
-/*
- * Software interrupt callbacks.
- */
static void
-cyclic_swi_low(void *dummy)
+cyclic_ap_start(void *dummy)
{
- cpu_t *c = pcpu_find(curcpu);
-
- c->pc_intr_actv |= (1 << CY_LOW_LEVEL);
-
- cyclic_softint(c, CY_LOW_LEVEL);
-
- c->pc_intr_actv &= ~(1 << CY_LOW_LEVEL);
+ /* Initialise the rest of the CPUs. */
+ cyclic_mp_init();
}
-static void
-cyclic_swi_lock(void *dummy)
-{
- cpu_t *c = pcpu_find(curcpu);
-
- c->pc_intr_actv |= (1 << CY_LOCK_LEVEL);
+SYSINIT(cyclic_ap_start, SI_SUB_SMP, SI_ORDER_ANY, cyclic_ap_start, NULL);
- cyclic_softint(c, CY_LOCK_LEVEL);
-
- c->pc_intr_actv &= ~(1 << CY_LOCK_LEVEL);
-}
-
/*
* Machine dependent cyclic subsystem initialisation.
*/
-void
-cyclic_machdep_init()
+static void
+cyclic_machdep_init(void)
{
- /* Default the resolution. */
- resolution = ticks * 1000000;
-
- /* XXX Need to check here if the HPET is available. */
-
- /*
- * Add a software interrupt handlers for low priority cyclic
- * events.
- */
- swi_add(&clk_intr_event, "low cyclic", cyclic_swi_low, NULL,
- SWI_TQ, 0, &cyclic_low_ih);
- swi_add(&clk_intr_event, "lock cyclic", cyclic_swi_lock, NULL,
- SWI_TQ_FAST, 0, &cyclic_lock_ih);
-
/* Register the cyclic backend. */
- cyclic_init(&be, resolution);
-
- /* If the HPET isn't present, use the slow method. */
- if (!hpet_present)
- /* Register the cyclic clock callback function. */
- lapic_cyclic_clock_func = cyclic_clock;
+ cyclic_init(&be);
}
-void
-cyclic_machdep_uninit()
+static void
+cyclic_machdep_uninit(void)
{
- /* Reset the cyclic clock callback hook. */
- lapic_cyclic_clock_func = NULL;
+ int i;
+
+ for (i = 0; i <= mp_maxid; i++)
+ /* Reset the cyclic clock callback hook. */
+ lapic_cyclic_clock_func[i] = NULL;
/* De-register the cyclic backend. */
cyclic_uninit();
+}
- /* Remove the software interrupt handlers. */
- swi_remove(cyclic_low_ih);
- swi_remove(cyclic_lock_ih);
-}
+static hrtime_t exp_due[SMP_MAXCPU];
-static cyb_arg_t configure(cpu_t *c)
+/*
+ * This function is the one registered by the machine dependent
+ * initialiser as the callback for high speed timer events.
+ */
+static void
+cyclic_clock(struct trapframe *frame)
{
- /* XXX Configure the HPET if it is present. */
+ cpu_t *c = &solaris_cpu[curcpu];
- return (NULL);
-}
+ if (c->cpu_cyclic != NULL && gethrtime() >= exp_due[curcpu]) {
+ if (TRAPF_USERMODE(frame)) {
+ c->cpu_profile_pc = 0;
+ c->cpu_profile_upc = TRAPF_PC(frame);
+ } else {
+ c->cpu_profile_pc = TRAPF_PC(frame);
+ c->cpu_profile_upc = 0;
+ }
-static void unconfigure(cyb_arg_t arg)
-{
- /* XXX Unconfigure the HPET if it is present. */
-
+ /* Fire any timers that are due. */
+ cyclic_fire(c);
+ }
}
static void enable(cyb_arg_t arg)
{
- /* XXX Enable the HPET if it is present. */
+ /* Register the cyclic clock callback function. */
+ lapic_cyclic_clock_func[curcpu] = cyclic_clock;
}
static void disable(cyb_arg_t arg)
{
- /* XXX Disable the HPET if it is present. */
+ /* Reset the cyclic clock callback function. */
+ lapic_cyclic_clock_func[curcpu] = NULL;
}
-static void reprogram(cyb_arg_t arg, hrtime_t interval)
+static void reprogram(cyb_arg_t arg, hrtime_t exp)
{
- /* XXX Reprogram the HPET if it is present. */
+ exp_due[curcpu] = exp;
}
-static void softint(cyb_arg_t arg, cyc_level_t level)
-{
- /*
- * Schedule the software interrupt processing at the
- * requested level.
- */
- switch (level) {
- case CY_LOW_LEVEL:
- swi_sched(cyclic_low_ih, 0);
- break;
- case CY_LOCK_LEVEL:
- swi_sched(cyclic_lock_ih, 0);
- break;
- default:
- printf("%s:%s(%d): unexpected soft level %d\n",__FUNCTION__,__FILE__,__LINE__,level);
- break;
- }
-}
-
-static cyc_cookie_t set_level(cyb_arg_t arg, cyc_level_t level)
-{
- return (intr_disable());
-}
-
-static void restore_level(cyb_arg_t arg, cyc_cookie_t cookie)
-{
- intr_restore(cookie);
-}
-
static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param)
{
/*
* If the target CPU is the current one, just call the
* function. This covers the non-SMP case.
*/
- if (c == pcpu_find(curcpu))
+ if (c == &solaris_cpu[curcpu])
(*func)(param);
else
- printf("%s:%s(%d): Need to have a way to execute the function on another CPU\n",__FUNCTION__,__FILE__,__LINE__);
-}
-
-static void suspend(cyb_arg_t arg)
-{
+ smp_rendezvous_cpus((cpumask_t) (1 << c->cpuid), NULL,
+ func, smp_no_rendevous_barrier, param);
}
-
-static void resume(cyb_arg_t arg)
-{
-}
-
More information about the p4-projects
mailing list