summaryrefslogtreecommitdiffstats
path: root/sys/pc98/cbus
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2007-03-04 11:36:16 +0000
committernyan <nyan@FreeBSD.org>2007-03-04 11:36:16 +0000
commit39b83fbf36a44f016b84bf4ae6045139e4f03ff1 (patch)
treefb0abfed9586e115864bd37d358eff9dcc48f193 /sys/pc98/cbus
parent38eadf93ffb5ad4ea95274a0d1eef609471c4d7d (diff)
downloadFreeBSD-src-39b83fbf36a44f016b84bf4ae6045139e4f03ff1.zip
FreeBSD-src-39b83fbf36a44f016b84bf4ae6045139e4f03ff1.tar.gz
- Use mtx_{lock,unlock}_spin rather than {disable,enable}_intr.
- Remove unnecessary findcpuspeed() function. - Initialize the timer_freq in i8254_init(). - Fix inittodr() and resettodr(). These are broken by rev.1.154.
Diffstat (limited to 'sys/pc98/cbus')
-rw-r--r--sys/pc98/cbus/clock.c44
-rw-r--r--sys/pc98/cbus/pcrtc.c44
2 files changed, 30 insertions, 58 deletions
diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c
index 5c0155f..7b8e982 100644
--- a/sys/pc98/cbus/clock.c
+++ b/sys/pc98/cbus/clock.c
@@ -362,9 +362,9 @@ sysbeep(int pitch, int period)
splx(x);
return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
}
- disable_intr();
+ mtx_lock_spin(&clock_lock);
spkr_set_pitch(pitch);
- enable_intr();
+ mtx_unlock_spin(&clock_lock);
if (!beeping) {
/* enable counter1 output to speaker */
ppi_spkr_on();
@@ -375,24 +375,6 @@ sysbeep(int pitch, int period)
return (0);
}
-
-unsigned int delaycount;
-#define FIRST_GUESS 0x2000
-static void findcpuspeed(void)
-{
- int i;
- int remainder;
-
- /* Put counter in count down mode */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_16BIT | TIMER_RATEGEN);
- outb(TIMER_CNTR0, 0xff);
- outb(TIMER_CNTR0, 0xff);
- for (i = FIRST_GUESS; i; i--)
- ;
- remainder = getit();
- delaycount = (FIRST_GUESS * TIMER_DIV(1000)) / (0xffff - remainder);
-}
-
static u_int
calibrate_clocks(void)
{
@@ -515,6 +497,12 @@ i8254_init(void)
{
mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_NOPROFILE);
+
+ if (pc98_machine_type & M_8M)
+ timer_freq = 1996800L; /* 1.9968 MHz */
+ else
+ timer_freq = 2457600L; /* 2.4576 MHz */
+
set_timer_freq(timer_freq, hz);
}
@@ -523,12 +511,6 @@ startrtclock()
{
u_int delta, freq;
- findcpuspeed();
- if (pc98_machine_type & M_8M)
- timer_freq = 1996800L; /* 1.9968 MHz */
- else
- timer_freq = 2457600L; /* 2.4576 MHz */
-
freq = calibrate_clocks();
#ifdef CLK_CALIBRATION_LOOP
if (bootverbose) {
@@ -633,6 +615,7 @@ inittodr(time_t base)
{
struct timespec ts;
struct clocktime ct;
+ int i;
if (base) {
ts.tv_sec = base;
@@ -648,12 +631,15 @@ inittodr(time_t base)
ct.sec = bcd2bin(rtc_inb() & 0xff); /* sec */
ct.min = bcd2bin(rtc_inb() & 0xff); /* min */
ct.hour = bcd2bin(rtc_inb() & 0xff); /* hour */
- ct.day = bcd2bin(rtc_inb() & 0xff) - 1; /* date */
- ct.mon = (rtc_inb() >> 4) & 0x0f; /* month */
+ ct.day = bcd2bin(rtc_inb() & 0xff); /* date */
+ i = rtc_inb();
+ ct.dow = i & 0x0f; /* dow */
+ ct.mon = (i >> 4) & 0x0f; /* month */
ct.year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */
if (ct.year < 1995)
ct.year += 100;
clock_ct_to_ts(&ct, &ts);
+ ts.tv_sec += utc_offset();
tc_setclock(&ts);
}
@@ -680,7 +666,7 @@ resettodr()
rtc_outb(bin2bcd(ct.hour)); /* Write back Hours */
rtc_outb(bin2bcd(ct.day)); /* Write back Day */
- rtc_outb((ct.mon << 4) | (ct.dow + 1)); /* Write back Month and DOW */
+ rtc_outb((ct.mon << 4) | ct.dow); /* Write back Month and DOW */
rtc_outb(bin2bcd(ct.year % 100)); /* Write back Year */
rtc_serialcom(0x02); /* Time set & Counter hold command. */
diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c
index 5c0155f..7b8e982 100644
--- a/sys/pc98/cbus/pcrtc.c
+++ b/sys/pc98/cbus/pcrtc.c
@@ -362,9 +362,9 @@ sysbeep(int pitch, int period)
splx(x);
return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
}
- disable_intr();
+ mtx_lock_spin(&clock_lock);
spkr_set_pitch(pitch);
- enable_intr();
+ mtx_unlock_spin(&clock_lock);
if (!beeping) {
/* enable counter1 output to speaker */
ppi_spkr_on();
@@ -375,24 +375,6 @@ sysbeep(int pitch, int period)
return (0);
}
-
-unsigned int delaycount;
-#define FIRST_GUESS 0x2000
-static void findcpuspeed(void)
-{
- int i;
- int remainder;
-
- /* Put counter in count down mode */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_16BIT | TIMER_RATEGEN);
- outb(TIMER_CNTR0, 0xff);
- outb(TIMER_CNTR0, 0xff);
- for (i = FIRST_GUESS; i; i--)
- ;
- remainder = getit();
- delaycount = (FIRST_GUESS * TIMER_DIV(1000)) / (0xffff - remainder);
-}
-
static u_int
calibrate_clocks(void)
{
@@ -515,6 +497,12 @@ i8254_init(void)
{
mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_NOPROFILE);
+
+ if (pc98_machine_type & M_8M)
+ timer_freq = 1996800L; /* 1.9968 MHz */
+ else
+ timer_freq = 2457600L; /* 2.4576 MHz */
+
set_timer_freq(timer_freq, hz);
}
@@ -523,12 +511,6 @@ startrtclock()
{
u_int delta, freq;
- findcpuspeed();
- if (pc98_machine_type & M_8M)
- timer_freq = 1996800L; /* 1.9968 MHz */
- else
- timer_freq = 2457600L; /* 2.4576 MHz */
-
freq = calibrate_clocks();
#ifdef CLK_CALIBRATION_LOOP
if (bootverbose) {
@@ -633,6 +615,7 @@ inittodr(time_t base)
{
struct timespec ts;
struct clocktime ct;
+ int i;
if (base) {
ts.tv_sec = base;
@@ -648,12 +631,15 @@ inittodr(time_t base)
ct.sec = bcd2bin(rtc_inb() & 0xff); /* sec */
ct.min = bcd2bin(rtc_inb() & 0xff); /* min */
ct.hour = bcd2bin(rtc_inb() & 0xff); /* hour */
- ct.day = bcd2bin(rtc_inb() & 0xff) - 1; /* date */
- ct.mon = (rtc_inb() >> 4) & 0x0f; /* month */
+ ct.day = bcd2bin(rtc_inb() & 0xff); /* date */
+ i = rtc_inb();
+ ct.dow = i & 0x0f; /* dow */
+ ct.mon = (i >> 4) & 0x0f; /* month */
ct.year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */
if (ct.year < 1995)
ct.year += 100;
clock_ct_to_ts(&ct, &ts);
+ ts.tv_sec += utc_offset();
tc_setclock(&ts);
}
@@ -680,7 +666,7 @@ resettodr()
rtc_outb(bin2bcd(ct.hour)); /* Write back Hours */
rtc_outb(bin2bcd(ct.day)); /* Write back Day */
- rtc_outb((ct.mon << 4) | (ct.dow + 1)); /* Write back Month and DOW */
+ rtc_outb((ct.mon << 4) | ct.dow); /* Write back Month and DOW */
rtc_outb(bin2bcd(ct.year % 100)); /* Write back Year */
rtc_serialcom(0x02); /* Time set & Counter hold command. */
OpenPOWER on IntegriCloud