summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2014-12-18 10:45:30 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2014-12-18 10:45:30 +0000
commitb93258f9cfe5a1418eba08a3b7061df80a9d8861 (patch)
tree166b74aa924032f7f4c0cd09cc6936f543730202 /sys/arch
parent70392a849d6c70b0013a0a715a6ccade9d7b5de3 (diff)
replace splhigh and a simplelock with a mutex.
slight tweak and testing by deraadt@ ok miod@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/alpha/prom.c49
-rw-r--r--sys/arch/alpha/include/prom.h5
2 files changed, 21 insertions, 33 deletions
diff --git a/sys/arch/alpha/alpha/prom.c b/sys/arch/alpha/alpha/prom.c
index 32a7d8e4e6f..387fb2c4a56 100644
--- a/sys/arch/alpha/alpha/prom.c
+++ b/sys/arch/alpha/alpha/prom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: prom.c,v 1.13 2002/03/14 01:26:26 millert Exp $ */
+/* $OpenBSD: prom.c,v 1.14 2014/12/18 10:45:29 dlg Exp $ */
/* $NetBSD: prom.c,v 1.39 2000/03/06 21:36:05 thorpej Exp $ */
/*
@@ -29,9 +29,9 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <uvm/uvm_extern.h>
-#include <sys/lock.h>
#include <sys/proc.h>
#include <sys/user.h>
+#include <sys/mutex.h>
#include <machine/cpu.h>
#include <machine/rpb.h>
@@ -49,7 +49,10 @@ int alpha_console;
extern struct prom_vec prom_dispatch_v;
-struct simplelock prom_slock;
+struct mutex prom_lock = MUTEX_INITIALIZER(IPL_HIGH);
+
+void prom_enter(void);
+void prom_leave(void);
#ifdef _PMAP_MAY_USE_PROM_CONSOLE
int prom_mapped = 1; /* Is PROM still mapped? */
@@ -81,8 +84,6 @@ init_prom_interface(rpb)
prom_dispatch_v.routine_arg = c->crb_v_dispatch;
prom_dispatch_v.routine = c->crb_v_dispatch->entry_va;
-
- simple_lock_init(&prom_slock);
}
void
@@ -103,13 +104,10 @@ init_bootstrap_console()
static void prom_cache_sync(void);
#endif
-int
-prom_enter()
+void
+prom_enter(void)
{
- int s;
-
- s = splhigh();
- simple_lock(&prom_slock);
+ mtx_enter(&prom_lock);
#ifdef _PMAP_MAY_USE_PROM_CONSOLE
/*
@@ -130,14 +128,11 @@ prom_enter()
prom_cache_sync(); /* XXX */
}
#endif
- return s;
}
void
-prom_leave(s)
- int s;
+prom_leave(void)
{
-
#ifdef _PMAP_MAY_USE_PROM_CONSOLE
/*
* See comment above.
@@ -154,8 +149,8 @@ prom_leave(s)
prom_cache_sync(); /* XXX */
}
#endif
- simple_unlock(&prom_slock);
- splx(s);
+
+ mtx_leave(&prom_lock);
}
#ifdef _PMAP_MAY_USE_PROM_CONSOLE
@@ -184,16 +179,15 @@ promcnputc(dev, c)
{
prom_return_t ret;
unsigned char *to = (unsigned char *)0x20000000;
- int s;
- s = prom_enter(); /* splhigh() and map prom */
+ prom_enter(); /* lock and map prom */
*to = c;
do {
ret.bits = prom_putstr(alpha_console, to, 1);
} while ((ret.u.retval & 1) == 0);
- prom_leave(s); /* unmap prom and splx(s) */
+ prom_leave(); /* unmap prom and unlock */
}
/*
@@ -206,12 +200,11 @@ promcngetc(dev)
dev_t dev;
{
prom_return_t ret;
- int s;
for (;;) {
- s = prom_enter();
+ prom_enter();
ret.bits = prom_getc(alpha_console);
- prom_leave(s);
+ prom_leave();
if (ret.u.status == 0 || ret.u.status == 1)
return (ret.u.retval);
}
@@ -228,11 +221,10 @@ promcnlookc(dev, cp)
char *cp;
{
prom_return_t ret;
- int s;
- s = prom_enter();
+ prom_enter();
ret.bits = prom_getc(alpha_console);
- prom_leave(s);
+ prom_leave();
if (ret.u.status == 0 || ret.u.status == 1) {
*cp = ret.u.retval;
return 1;
@@ -247,12 +239,11 @@ prom_getenv(id, buf, len)
{
unsigned char *to = (unsigned char *)0x20000000;
prom_return_t ret;
- int s;
- s = prom_enter();
+ prom_enter();
ret.bits = prom_getenv_disp(id, to, len);
bcopy(to, buf, len);
- prom_leave(s);
+ prom_leave();
if (ret.u.status & 0x4)
ret.u.retval = 0;
diff --git a/sys/arch/alpha/include/prom.h b/sys/arch/alpha/include/prom.h
index 82743511d69..1a99707c27b 100644
--- a/sys/arch/alpha/include/prom.h
+++ b/sys/arch/alpha/include/prom.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: prom.h,v 1.9 2009/09/30 19:41:54 miod Exp $ */
+/* $OpenBSD: prom.h,v 1.10 2014/12/18 10:45:29 dlg Exp $ */
/* $NetBSD: prom.h,v 1.12 2000/06/08 03:10:06 thorpej Exp $ */
/*
@@ -112,9 +112,6 @@ void hwrpb_restart_setup(void);
#ifndef ASSEMBLER
#ifdef _KERNEL
-int prom_enter(void);
-void prom_leave(int);
-
void promcnputc(dev_t, int);
int promcngetc(dev_t);
int promcnlookc(dev_t, char *);