#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();
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();
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)));
}