From owner-p4-projects@FreeBSD.ORG Tue Jul 17 14:19:29 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8943316A406; Tue, 17 Jul 2007 14:19:29 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 26F6A16A405 for ; Tue, 17 Jul 2007 14:19:29 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 1824C13C4B8 for ; Tue, 17 Jul 2007 14:19:29 +0000 (UTC) (envelope-from attilio@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 l6HEJSwp018606 for ; Tue, 17 Jul 2007 14:19:28 GMT (envelope-from attilio@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6HEJSw6018602 for perforce@freebsd.org; Tue, 17 Jul 2007 14:19:28 GMT (envelope-from attilio@FreeBSD.org) Date: Tue, 17 Jul 2007 14:19:28 GMT Message-Id: <200707171419.l6HEJSw6018602@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to attilio@FreeBSD.org using -f From: Attilio Rao To: Perforce Change Reviews Cc: Subject: PERFORCE change 123652 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: Tue, 17 Jul 2007 14:19:30 -0000 http://perforce.freebsd.org/chv.cgi?CH=123652 Change 123652 by attilio@attilio_xen on 2007/07/17 14:18:39 - Sort macro, variables and functions in the style-suggested way - Give the correctlty needed linkage to variables - Make xen_disable_rtc_set as sysctl tunable - Remove unuseful rtc_statusb - Rename fast_gettimeoffset_quotient in cached_gtm since it is too long - Introduce i8254_init() for xen too since it should handle mutex building. XXX: Xen is still no MP safe. Affected files ... .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/clock.c#16 edit .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#16 edit Differences ... ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/clock.c#16 (text+ko) ==== @@ -93,48 +93,41 @@ #define LEAPYEAR(y) (!((y) % 4)) #define DAYSPERYEAR (28+30*4+31*7) -int adjkerntz; /* local offset from GMT in seconds */ -int clkintr_pending; -int xen_disable_rtc_set = 1; /* disable resettodr() if != 0 */ -int pscnt = 1; -int psdiv = 1; -int statclock_disable; #ifndef TIMER_FREQ -#define TIMER_FREQ 1193182 +#define TIMER_FREQ 1193182 #endif -int wall_cmos_clock; -int independent_wallclock; -u_int timer_freq = TIMER_FREQ; -struct mtx clock_lock; -#define RTC_LOCK mtx_lock_spin(&clock_lock) -#define RTC_UNLOCK mtx_unlock_spin(&clock_lock) - -static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; -static u_char rtc_statusb = RTCSB_24HR; - /* Values for timerX_state: */ #define RELEASED 0 #define RELEASE_PENDING 1 #define ACQUIRED 2 #define ACQUIRE_PENDING 3 -static u_char timer2_state; +#define RTC_LOCK_INIT mtx_init(&clock_lock, "clk", NULL, MTX_SPIN); +#define RTC_LOCK mtx_lock_spin(&clock_lock) +#define RTC_UNLOCK mtx_unlock_spin(&clock_lock) -/* Cached *multiplier* to convert TSC counts to microseconds. - * (see the equation below). - * Equal to 2^32 * (1 / (clocks per usec) ). - * Initialized in time_init. - */ -static unsigned long fast_gettimeoffset_quotient; - -/* These are peridically updated in shared_info, and then copied here. */ +int adjkerntz; /* local offset from GMT in seconds */ +int clkintr_pending; +int pscnt = 1; +int psdiv = 1; +int statclock_disable; +int wall_cmos_clock; +u_int timer_freq = TIMER_FREQ; +static int independent_wallclock; +static int xen_disable_rtc_set; +static u_long cached_gtm; /* cached quotient for TSC -> microseconds */ +static u_char timer2_state = RELEASED; static struct timespec shadow_tv; +static uint32_t shadow_tv_version; /* XXX: lazy locking */ +static struct mtx clock_lock; -uint32_t shadow_tv_version; +static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; SYSCTL_INT(_machdep, OID_AUTO, independent_wallclock, - CTLFLAG_RW, &independent_wallclock, 0, ""); + CTLFLAG_RW, &independent_wallclock, 0, ""); +SYSCTL_INT(_machdep, OID_AUTO, xen_disable_rtc_set, + CTLFLAG_RW, &xen_disable_rtc_set, 1, ""); #define do_div(n,base) ({ \ @@ -356,6 +349,16 @@ /* + * XXX: timer needs more SMP work. + */ +void +i8254_init(void) +{ + + RTC_LOCK_INIT; +} + +/* * Wait "n" microseconds. * Relies on timer 1 counting down from (timer_freq / hz) * Note: timer had better have been programmed before this is first used! @@ -500,7 +503,7 @@ { unsigned long eax=0, edx=1000; __asm__("divl %2" - :"=a" (fast_gettimeoffset_quotient), "=d" (edx) + :"=a" (cached_gtm), "=d" (edx) :"r" (cpu_khz), "0" (eax), "1" (edx)); } @@ -763,7 +766,7 @@ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */ /* Reenable RTC updates and interrupts. */ - writertc(RTC_STATUSB, rtc_statusb); + writertc(RTC_STATUSB, RTCSB_24HR); rtcin(RTC_INTR); } @@ -889,7 +892,7 @@ eax -= shadow_tsc_stamp; /* - * Time offset = (tsc_low delta) * fast_gettimeoffset_quotient + * Time offset = (tsc_low delta) * cached_gtm * = (tsc_low delta) * (usecs_per_clock) * = (tsc_low delta) * (usecs_per_jiffy / clocks_per_jiffy) * @@ -899,7 +902,7 @@ __asm__("mull %2" :"=a" (eax), "=d" (edx) - :"rm" (fast_gettimeoffset_quotient), + :"rm" (cached_gtm), "0" (eax)); /* our adjusted time offset in microseconds */ ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#16 (text+ko) ==== @@ -2389,6 +2389,8 @@ } #endif /* XBOX */ + i8254_init(); + /* * Initialize the console before we print anything out. */