Replace spl protection in rtcin() and writertc() with spinlocks

using the existing clock_lock mutex.
This commit is contained in:
Matthew N. Dodd 2005-04-12 20:49:31 +00:00
parent 55ec9ed408
commit 93fa9a8d72
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=144965
2 changed files with 12 additions and 12 deletions

View file

@ -111,6 +111,8 @@ u_int timer_freq = TIMER_FREQ;
int timer0_max_count;
int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
struct mtx clock_lock;
#define RTC_LOCK mtx_lock_spin(&clock_lock)
#define RTC_UNLOCK mtx_unlock_spin(&clock_lock)
static int beeping = 0;
static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
@ -415,30 +417,28 @@ int
rtcin(reg)
int reg;
{
int s;
u_char val;
s = splhigh();
RTC_LOCK;
outb(IO_RTC, reg);
inb(0x84);
val = inb(IO_RTC + 1);
inb(0x84);
splx(s);
RTC_UNLOCK;
return (val);
}
static __inline void
writertc(u_char reg, u_char val)
{
int s;
s = splhigh();
RTC_LOCK;
inb(0x84);
outb(IO_RTC, reg);
inb(0x84);
outb(IO_RTC + 1, val);
inb(0x84); /* XXX work around wrong order in rtcin() */
splx(s);
RTC_UNLOCK;
}
static __inline int

View file

@ -111,6 +111,8 @@ u_int timer_freq = TIMER_FREQ;
int timer0_max_count;
int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
struct mtx clock_lock;
#define RTC_LOCK mtx_lock_spin(&clock_lock)
#define RTC_UNLOCK mtx_unlock_spin(&clock_lock)
static int beeping = 0;
static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
@ -415,30 +417,28 @@ int
rtcin(reg)
int reg;
{
int s;
u_char val;
s = splhigh();
RTC_LOCK;
outb(IO_RTC, reg);
inb(0x84);
val = inb(IO_RTC + 1);
inb(0x84);
splx(s);
RTC_UNLOCK;
return (val);
}
static __inline void
writertc(u_char reg, u_char val)
{
int s;
s = splhigh();
RTC_LOCK;
inb(0x84);
outb(IO_RTC, reg);
inb(0x84);
outb(IO_RTC + 1, val);
inb(0x84); /* XXX work around wrong order in rtcin() */
splx(s);
RTC_UNLOCK;
}
static __inline int