From owner-p4-projects@FreeBSD.ORG Sat Jan 5 21:59:26 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6555E16A469; Sat, 5 Jan 2008 21:59:26 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2AC7116A41A for ; Sat, 5 Jan 2008 21:59:26 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 24F5D13C458 for ; Sat, 5 Jan 2008 21:59:26 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m05LxQ09035370 for ; Sat, 5 Jan 2008 21:59:26 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m05LxPAh035367 for perforce@freebsd.org; Sat, 5 Jan 2008 21:59:25 GMT (envelope-from jb@freebsd.org) Date: Sat, 5 Jan 2008 21:59:25 GMT Message-Id: <200801052159.m05LxPAh035367@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 132587 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jan 2008 21:59:26 -0000 http://perforce.freebsd.org/chv.cgi?CH=132587 Change 132587 by jb@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 + * Copyright 2007-2008 John Birrell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,193 +26,104 @@ * */ -#include -#include -#include -#include -#include -#include -#include -#include - -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) -{ -} -