/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This 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 OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
+ * 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
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
#include <kern/spl.h>
#include <kern/processor.h>
#include <kern/misc_protos.h>
+#include <i386/cpu_data.h>
+#include <i386/cpu_number.h>
#include <i386/pio.h>
#include <i386/AT386/rtc.h>
#include <i386/AT386/bbclock_entries.h>
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.
*/
printf("battery clock configured\n");
else
printf("WARNING: Battery Clock Failure!\n");
-#if NCPUS > 1 && AT386
mp_enable_preemption();
-#endif
return (BbcFlag);
}
spl_t s;
thread_t thread;
-#if NCPUS > 1 && AT386
if ((thread = current_thread()) != THREAD_NULL) {
thread_bind(thread, master_processor);
mp_disable_preemption();
if (current_processor() != master_processor) {
mp_enable_preemption();
- thread_block((void (*)) 0);
+ thread_block(THREAD_CONTINUE_NULL);
} else {
mp_enable_preemption();
}
}
-#endif
+
s = LOCK_BBC();
rtcget(&rtclk);
sec = hexdectodec(rtclk.rtc_sec);
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);
}
spl_t s;
thread_t thread;
-#if NCPUS > 1 && AT386
if ((thread = current_thread()) != THREAD_NULL) {
thread_bind(thread, master_processor);
mp_disable_preemption();
if (current_processor() != master_processor) {
mp_enable_preemption();
- thread_block((void (*)) 0);
+ thread_block(THREAD_CONTINUE_NULL);
} else {
mp_enable_preemption();
}
}
-#endif
+
s = LOCK_BBC();
rtcget(&rtclk);
diff = 0;
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)
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);
}
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 */
yeartoday(
int year)
{
- year += 1900;
+ year += 1900;
return((year % 4) ? 365 :
((year % 100) ? 366 : ((year % 400) ? 365: 366)));
}