X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/43866e378188c25dd1e2208016ab3cbeb086ae6c..8ad349bb6ed4a0be06e34c92be0d98b92e078db4:/osfmk/i386/AT386/bbclock.c diff --git a/osfmk/i386/AT386/bbclock.c b/osfmk/i386/AT386/bbclock.c index 25564bb58..cefba6930 100644 --- a/osfmk/i386/AT386/bbclock.c +++ b/osfmk/i386/AT386/bbclock.c @@ -1,26 +1,31 @@ /* * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the + * License may not be used to create, or enable the creation or + * redistribution of, unlawful or unlicensed copies of an Apple operating + * system, or to circumvent, violate, or enable the circumvention or + * violation of, any terms of an Apple operating system software license + * agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ + * + * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ @@ -54,6 +59,8 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include +#include #include #include #include @@ -84,13 +91,12 @@ bbc_config(void) int BbcFlag; struct rtc_st rtclk; -#if NCPUS > 1 && AT386 mp_disable_preemption(); if (cpu_number() != master_cpu) { mp_enable_preemption(); return(1); } -#endif + /* * Setup device. */ @@ -107,9 +113,7 @@ bbc_config(void) printf("battery clock configured\n"); else printf("WARNING: Battery Clock Failure!\n"); -#if NCPUS > 1 && AT386 mp_enable_preemption(); -#endif return (BbcFlag); } @@ -127,7 +131,6 @@ bbc_gettime( spl_t s; thread_t thread; -#if NCPUS > 1 && AT386 if ((thread = current_thread()) != THREAD_NULL) { thread_bind(thread, master_processor); mp_disable_preemption(); @@ -138,7 +141,7 @@ bbc_gettime( mp_enable_preemption(); } } -#endif + s = LOCK_BBC(); rtcget(&rtclk); sec = hexdectodec(rtclk.rtc_sec); @@ -162,10 +165,8 @@ bbc_gettime( cur_time->tv_nsec = 0; UNLOCK_BBC(s); -#if NCPUS > 1 && AT386 if (thread != THREAD_NULL) thread_bind(thread, PROCESSOR_NULL); -#endif return (KERN_SUCCESS); } @@ -182,7 +183,6 @@ bbc_settime( spl_t s; thread_t thread; -#if NCPUS > 1 && AT386 if ((thread = current_thread()) != THREAD_NULL) { thread_bind(thread, master_processor); mp_disable_preemption(); @@ -193,7 +193,7 @@ bbc_settime( mp_enable_preemption(); } } -#endif + s = LOCK_BBC(); rtcget(&rtclk); diff = 0; @@ -204,7 +204,7 @@ bbc_settime( rtclk.rtc_hr = dectohexdec(n/60); n = (new_time->tv_sec - diff) / (3600 * 24); /* days */ rtclk.rtc_dow = (n + 4) % 7; /* 1/1/70 is Thursday */ - for (j = 1970; n >= (i = yeartoday(j)); j++) + for (j = 70; n >= (i = yeartoday(j)); j++) n -= i; rtclk.rtc_yr = dectohexdec(j % 100); if (yeartoday(j) == 366) @@ -217,39 +217,9 @@ bbc_settime( rtcput(&rtclk); UNLOCK_BBC(s); -#if NCPUS > 1 && AT386 if (thread != THREAD_NULL) thread_bind(current_thread(), PROCESSOR_NULL); -#endif - return (KERN_SUCCESS); -} -/* - * Get clock device attributes. - */ -kern_return_t -bbc_getattr( - clock_flavor_t flavor, - clock_attr_t attr, /* OUT */ - mach_msg_type_number_t *count) /* IN/OUT */ -{ - if (*count != 1) - return (KERN_FAILURE); - switch (flavor) { - - case CLOCK_GET_TIME_RES: /* >0 res */ - *(clock_res_t *) attr = NSEC_PER_SEC; - break; - - case CLOCK_ALARM_CURRES: /* =0 no alarm */ - case CLOCK_ALARM_MINRES: - case CLOCK_ALARM_MAXRES: - *(clock_res_t *) attr = 0; - break; - - default: - return (KERN_INVALID_VALUE); - } return (KERN_SUCCESS); } @@ -261,7 +231,7 @@ rtcget( struct rtc_st * regs) { outb(RTC_ADDR, RTC_D); - if (inb(RTC_DATA) & RTC_VRT == 0) + if ((inb(RTC_DATA) & RTC_VRT) == 0) return (-1); outb(RTC_ADDR, RTC_A); while (inb(RTC_DATA) & RTC_UIP) /* busy wait */ @@ -289,7 +259,7 @@ int yeartoday( int year) { - year += 1900; + year += 1900; return((year % 4) ? 365 : ((year % 100) ? 366 : ((year % 400) ? 365: 366))); }