-/* $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 $ */
/*
#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>
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? */
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
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
/*
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.
prom_cache_sync(); /* XXX */
}
#endif
- simple_unlock(&prom_slock);
- splx(s);
+
+ mtx_leave(&prom_lock);
}
#ifdef _PMAP_MAY_USE_PROM_CONSOLE
{
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 */
}
/*
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);
}
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;
{
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;
-/* $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 $ */
/*
#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 *);