From: dlg Date: Thu, 18 Dec 2014 10:45:29 +0000 (+0000) Subject: replace splhigh and a simplelock with a mutex. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a76f4a8d79c3921668a2282135f349ab3ff7eaaa;p=openbsd replace splhigh and a simplelock with a mutex. slight tweak and testing by deraadt@ ok miod@ --- 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 #include #include -#include #include #include +#include #include #include @@ -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 *);