diff options
author | 2013-05-31 22:07:45 +0000 | |
---|---|---|
committer | 2013-05-31 22:07:45 +0000 | |
commit | 8246049a8030892a0e8188866f8ca1e0dc7c83db (patch) | |
tree | 41e076f86903403c49e1055f8d6bc5374e3d222c /sys | |
parent | The name "struct tbl" was badly misleading for two reasons: (diff) | |
download | wireguard-openbsd-8246049a8030892a0e8188866f8ca1e0dc7c83db.tar.xz wireguard-openbsd-8246049a8030892a0e8188866f8ca1e0dc7c83db.zip |
Replace shutdownhooks with activate functions, properly doing those
operations only if device is console
ok kettenis
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc/dev/cgfourteen.c | 37 | ||||
-rw-r--r-- | sys/arch/sparc/dev/cgtwelve.c | 40 | ||||
-rw-r--r-- | sys/arch/sparc/dev/p9100.c | 24 | ||||
-rw-r--r-- | sys/arch/sparc/dev/tcx.c | 37 | ||||
-rw-r--r-- | sys/arch/sparc/dev/zx.c | 39 | ||||
-rw-r--r-- | sys/dev/sbus/cgtwelve.c | 40 |
6 files changed, 154 insertions, 63 deletions
diff --git a/sys/arch/sparc/dev/cgfourteen.c b/sys/arch/sparc/dev/cgfourteen.c index 895b6cb9b0b..78447bd825e 100644 --- a/sys/arch/sparc/dev/cgfourteen.c +++ b/sys/arch/sparc/dev/cgfourteen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgfourteen.c,v 1.36 2008/12/26 22:30:21 miod Exp $ */ +/* $OpenBSD: cgfourteen.c,v 1.37 2013/05/31 22:07:49 deraadt Exp $ */ /* $NetBSD: cgfourteen.c,v 1.7 1997/05/24 20:16:08 pk Exp $ */ /* @@ -137,6 +137,7 @@ struct cgfourteen_softc { int sc_rev; /* VSIMM revision */ int sc_32; /* can do 32bit at this resolution */ size_t sc_vramsize; /* total video memory size */ + int sc_isconsole; struct intrhand sc_ih; }; @@ -150,7 +151,7 @@ int cgfourteen_getcmap(union cgfourteen_cmap *, struct wsdisplay_cmap *); int cgfourteen_intr(void *); void cgfourteen_loadcmap_deferred(struct cgfourteen_softc *, u_int, u_int); void cgfourteen_loadcmap_immediate(struct cgfourteen_softc *, u_int, u_int); -void cgfourteen_prom(void *); +void cgfourteen_prom(struct cgfourteen_softc *); int cgfourteen_putcmap(union cgfourteen_cmap *, struct wsdisplay_cmap *); void cgfourteen_setcolor(void *, u_int, u_int8_t, u_int8_t, u_int8_t); @@ -169,9 +170,11 @@ struct wsdisplay_accessops cgfourteen_accessops = { void cgfourteenattach(struct device *, struct device *, void *); int cgfourteenmatch(struct device *, void *, void *); +int cgfourteenactivate(struct device *, int); struct cfattach cgfourteen_ca = { - sizeof(struct cgfourteen_softc), cgfourteenmatch, cgfourteenattach + sizeof(struct cgfourteen_softc), cgfourteenmatch, cgfourteenattach, + NULL, cgfourteenactivate }; struct cfdriver cgfourteen_cd = { @@ -221,7 +224,6 @@ cgfourteenattach(struct device *parent, struct device *self, void *args) struct confargs *ca = args; int node, pri, i; u_int32_t *lut; - int isconsole; char *nam; pri = ca->ca_ra.ra_intr[0].int_pri; @@ -250,7 +252,7 @@ cgfourteenattach(struct device *parent, struct device *self, void *args) if (*nam != '\0') printf("%s, ", nam); - isconsole = node == fbnode; + sc->sc_isconsole = node == fbnode; /* * Map in the 8 useful pages of registers @@ -322,15 +324,29 @@ cgfourteenattach(struct device *parent, struct device *self, void *args) cgfourteen_burner(sc, 1, 0); sc->sc_sunfb.sf_ro.ri_hw = sc; - fbwscons_init(&sc->sc_sunfb, isconsole); + fbwscons_init(&sc->sc_sunfb, sc->sc_isconsole); fbwscons_setcolormap(&sc->sc_sunfb, cgfourteen_setcolor); - if (isconsole) { + if (sc->sc_isconsole) fbwscons_console_init(&sc->sc_sunfb, -1); - shutdownhook_establish(cgfourteen_prom, sc); + + fbwscons_attach(&sc->sc_sunfb, &cgfourteen_accessops, sc->sc_isconsole); +} + +int +cgfourteenactivate(struct device *self, int act) +{ + struct cgfourteen_softc *sc = (struct cgfourteen_softc *)self; + int ret = 0; + + switch (act) { + case DVACT_POWERDOWN: + if (sc->sc_isconsole) + cgfourteen_prom(sc); + break; } - fbwscons_attach(&sc->sc_sunfb, &cgfourteen_accessops, isconsole); + return (ret); } int @@ -482,9 +498,8 @@ cgfourteen_reset(struct cgfourteen_softc *sc, int depth) } void -cgfourteen_prom(void *v) +cgfourteen_prom(struct cgfourteen_softc *sc) { - struct cgfourteen_softc *sc = v; extern struct consdev consdev_prom; if (sc->sc_sunfb.sf_depth != 8) { diff --git a/sys/arch/sparc/dev/cgtwelve.c b/sys/arch/sparc/dev/cgtwelve.c index a3f2c126800..7cb63cfbb4f 100644 --- a/sys/arch/sparc/dev/cgtwelve.c +++ b/sys/arch/sparc/dev/cgtwelve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgtwelve.c,v 1.17 2008/12/26 22:30:21 miod Exp $ */ +/* $OpenBSD: cgtwelve.c,v 1.18 2013/05/31 22:07:49 deraadt Exp $ */ /* * Copyright (c) 2002, 2003 Miodrag Vallat. All rights reserved. @@ -85,11 +85,12 @@ struct cgtwelve_softc { volatile u_long *sc_inten; /* true color plane */ int sc_highres; + int sc_isconsole; }; int cgtwelve_ioctl(void *, u_long, caddr_t, int, struct proc *); paddr_t cgtwelve_mmap(void *, off_t, int); -void cgtwelve_prom(void *); +void cgtwelve_prom(struct cgtwelve_softc *); static __inline__ void cgtwelve_ramdac_wraddr(struct cgtwelve_softc *, u_int32_t); void cgtwelve_reset(struct cgtwelve_softc *, int); @@ -109,9 +110,11 @@ struct wsdisplay_accessops cgtwelve_accessops = { int cgtwelvematch(struct device *, void *, void *); void cgtwelveattach(struct device *, struct device *, void *); +int cgtwelveactivate(struct device *, int); struct cfattach cgtwelve_ca = { - sizeof(struct cgtwelve_softc), cgtwelvematch, cgtwelveattach + sizeof(struct cgtwelve_softc), cgtwelvematch, cgtwelveattach, + NULL, cgtwelveactivate }; struct cfdriver cgtwelve_cd = { @@ -138,7 +141,6 @@ cgtwelveattach(struct device *parent, struct device *self, void *args) struct cgtwelve_softc *sc = (struct cgtwelve_softc *)self; struct confargs *ca = args; int node; - int isconsole = 0; char *ps; node = ca->ca_ra.ra_node; @@ -149,7 +151,7 @@ cgtwelveattach(struct device *parent, struct device *self, void *args) printf(" (%s)", ps); printf("\n"); - isconsole = node == fbnode; + sc->sc_isconsole = node == fbnode; sc->sc_phys = ca->ca_ra.ra_reg[0]; @@ -194,12 +196,10 @@ cgtwelveattach(struct device *parent, struct device *self, void *args) sc->sc_sunfb.sf_ro.ri_bits = (void *)sc->sc_overlay; sc->sc_sunfb.sf_ro.ri_hw = sc; - fbwscons_init(&sc->sc_sunfb, isconsole); + fbwscons_init(&sc->sc_sunfb, sc->sc_isconsole); - if (isconsole) { + if (sc->sc_isconsole) fbwscons_console_init(&sc->sc_sunfb, -1); - shutdownhook_establish(cgtwelve_prom, sc); - } printf("%s: %dx%d", self->dv_xname, sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); @@ -208,7 +208,23 @@ cgtwelveattach(struct device *parent, struct device *self, void *args) printf(", microcode rev. %s", ps); printf("\n"); - fbwscons_attach(&sc->sc_sunfb, &cgtwelve_accessops, isconsole); + fbwscons_attach(&sc->sc_sunfb, &cgtwelve_accessops, sc->sc_isconsole); +} + +int +cgtwelveactivate(struct device *self, int act) +{ + struct cgtwelve_softc *sc = (struct cgtwelve_softc *)self; + int ret = 0; + + switch (act) { + case DVACT_POWERDOWN: + if (sc->sc_isconsole) + cgtwelve_prom(sc); + break; + } + + return (ret); } int @@ -401,10 +417,8 @@ cgtwelve_ramdac_wraddr(struct cgtwelve_softc *sc, u_int32_t addr) * so that the PROM prompt is visible again. */ void -cgtwelve_prom(v) - void *v; +cgtwelve_prom(struct cgtwelve_softc *sc) { - struct cgtwelve_softc *sc = v; extern struct consdev consdev_prom; if (sc->sc_sunfb.sf_depth != 1) { diff --git a/sys/arch/sparc/dev/p9100.c b/sys/arch/sparc/dev/p9100.c index 4fb7d553970..7b5d7fee149 100644 --- a/sys/arch/sparc/dev/p9100.c +++ b/sys/arch/sparc/dev/p9100.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p9100.c,v 1.50 2011/05/31 17:40:19 miod Exp $ */ +/* $OpenBSD: p9100.c,v 1.51 2013/05/31 22:07:49 deraadt Exp $ */ /* * Copyright (c) 2003, 2005, 2006, 2008, Miodrag Vallat. @@ -156,9 +156,11 @@ void p9100_ras_init(struct p9100_softc *); int p9100match(struct device *, void *, void *); void p9100attach(struct device *, struct device *, void *); +int p9100activate(struct device *, int); struct cfattach pnozz_ca = { - sizeof (struct p9100_softc), p9100match, p9100attach + sizeof (struct p9100_softc), p9100match, p9100attach, + NULL, p9100activate }; struct cfdriver pnozz_cd = { @@ -387,14 +389,26 @@ p9100attach(struct device *parent, struct device *self, void *args) /* enable video */ p9100_burner(sc, 1, 0); - if (isconsole) { + if (isconsole) fbwscons_console_init(&sc->sc_sunfb, -1); + + fbwscons_attach(&sc->sc_sunfb, &p9100_accessops, isconsole); +} + +int +p9100activate(struct device *self, int act) +{ + int ret = 0; + + switch (act) { + case DVACT_POWERDOWN: #if NTCTRL > 0 - shutdownhook_establish(p9100_prom, sc); + p9100_prom(self); #endif + break; } - fbwscons_attach(&sc->sc_sunfb, &p9100_accessops, isconsole); + return (ret); } int diff --git a/sys/arch/sparc/dev/tcx.c b/sys/arch/sparc/dev/tcx.c index 0dd33b47dcf..6500a9c62d5 100644 --- a/sys/arch/sparc/dev/tcx.c +++ b/sys/arch/sparc/dev/tcx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcx.c,v 1.45 2010/05/13 20:35:43 miod Exp $ */ +/* $OpenBSD: tcx.c,v 1.46 2013/05/31 22:07:49 deraadt Exp $ */ /* $NetBSD: tcx.c,v 1.8 1997/07/29 09:58:14 fair Exp $ */ /* @@ -94,6 +94,7 @@ struct tcx_softc { paddr_t sc_cplane; /* S24 control plane PA */ union bt_cmap sc_cmap; /* Brooktree color map */ struct intrhand sc_ih; + int sc_isconsole; /* acceleration parts */ paddr_t sc_stipple; /* Stipple space PA */ @@ -116,7 +117,7 @@ int tcx_ioctl(void *, u_long, caddr_t, int, struct proc *); static __inline__ void tcx_loadcmap_deferred(struct tcx_softc *, u_int, u_int); paddr_t tcx_mmap(void *, off_t, int); -void tcx_prom(void *); +void tcx_prom(struct tcx_softc *); int tcx_putchar(void *, int, int, u_int, long); void tcx_reset(struct tcx_softc *, int); void tcx_s24_reset(struct tcx_softc *, int); @@ -138,9 +139,11 @@ struct wsdisplay_accessops tcx_accessops = { int tcxmatch(struct device *, void *, void *); void tcxattach(struct device *, struct device *, void *); +int tcxactivate(struct device *, int); const struct cfattach tcx_ca = { - sizeof(struct tcx_softc), tcxmatch, tcxattach + sizeof(struct tcx_softc), tcxmatch, tcxattach, + NULL, tcxactivate }; struct cfdriver tcx_cd = { @@ -191,7 +194,6 @@ tcxattach(struct device *parent, struct device *self, void *args) struct tcx_softc *sc = (struct tcx_softc *)self; struct confargs *ca = args; int node, pri; - int isconsole = 0; char *nam = NULL; vaddr_t thc_offset; @@ -199,7 +201,7 @@ tcxattach(struct device *parent, struct device *self, void *args) printf(" pri %d: ", pri); node = ca->ca_ra.ra_node; - isconsole = node == fbnode; + sc->sc_isconsole = node == fbnode; if (ca->ca_ra.ra_nreg < TCX_NREG) { printf("expected %d registers, got %d\n", @@ -282,7 +284,7 @@ tcxattach(struct device *parent, struct device *self, void *args) sc->sc_sunfb.sf_ro.ri_hw = sc; sc->sc_sunfb.sf_ro.ri_bits = (void *)sc->sc_dfb8; - fbwscons_init(&sc->sc_sunfb, isconsole); + fbwscons_init(&sc->sc_sunfb, sc->sc_isconsole); fbwscons_setcolormap(&sc->sc_sunfb, tcx_setcolor); /* @@ -294,12 +296,26 @@ tcxattach(struct device *parent, struct device *self, void *args) sc->sc_ih.ih_arg = sc; intr_establish(pri, &sc->sc_ih, IPL_FB, self->dv_xname); - if (isconsole) { + if (sc->sc_isconsole) fbwscons_console_init(&sc->sc_sunfb, -1); - shutdownhook_establish(tcx_prom, sc); + + fbwscons_attach(&sc->sc_sunfb, &tcx_accessops, sc->sc_isconsole); +} + +int +tcxactivate(struct device *self, int act) +{ + struct tcx_softc *sc = (struct tcx_softc *)self; + int ret = 0; + + switch (act) { + case DVACT_POWERDOWN: + if (sc->sc_isconsole) + tcx_prom(sc); + break; } - fbwscons_attach(&sc->sc_sunfb, &tcx_accessops, isconsole); + return (ret); } int @@ -408,9 +424,8 @@ tcx_reset(struct tcx_softc *sc, int depth) } void -tcx_prom(void *v) +tcx_prom(struct tcx_softc *sc) { - struct tcx_softc *sc = v; extern struct consdev consdev_prom; if (sc->sc_sunfb.sf_depth != 8) { diff --git a/sys/arch/sparc/dev/zx.c b/sys/arch/sparc/dev/zx.c index 1627474f2ff..f8405c9b01b 100644 --- a/sys/arch/sparc/dev/zx.c +++ b/sys/arch/sparc/dev/zx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zx.c,v 1.23 2009/09/05 14:09:35 miod Exp $ */ +/* $OpenBSD: zx.c,v 1.24 2013/05/31 22:07:49 deraadt Exp $ */ /* $NetBSD: zx.c,v 1.5 2002/10/02 16:52:46 thorpej Exp $ */ /* @@ -117,12 +117,13 @@ struct zx_softc { volatile struct zx_cursor *sc_zcu; int sc_mode; + int sc_isconsole; }; void zx_burner(void *, u_int, u_int); int zx_ioctl(void *, u_long, caddr_t, int, struct proc *); paddr_t zx_mmap(void *v, off_t offset, int prot); -void zx_prom(void *); +void zx_prom(struct zx_softc *); void zx_reset(struct zx_softc *, u_int); void zx_setcolor(void *, u_int, u_int8_t, u_int8_t, u_int8_t); @@ -152,6 +153,7 @@ struct wsdisplay_accessops zx_accessops = { void zx_attach(struct device *, struct device *, void *); int zx_match(struct device *, void *, void *); +int zx_activate(struct device *, int); void zx_copyrect(struct rasops_info *, int, int, int, int, int, int); int zx_cross_loadwid(struct zx_softc *, u_int, u_int, u_int); @@ -168,7 +170,8 @@ int zx_eraserows(void *, int, int, long); int zx_putchar(void *, int, int, u_int, long); struct cfattach zx_ca = { - sizeof(struct zx_softc), zx_match, zx_attach + sizeof(struct zx_softc), zx_match, zx_attach, + NULL, zx_activate }; struct cfdriver zx_cd = { @@ -193,7 +196,7 @@ zx_attach(struct device *parent, struct device *self, void *args) struct zx_softc *sc = (struct zx_softc *)self; struct confargs *ca = args; struct rasops_info *ri; - int node, isconsole = 0; + int node; const char *nam; ri = &sc->sc_sunfb.sf_ro; @@ -225,7 +228,7 @@ zx_attach(struct device *parent, struct device *self, void *args) nam = ca->ca_ra.ra_name; printf(": %s", nam); - isconsole = node == fbnode; + sc->sc_isconsole = node == fbnode; /* * The console is using the 8-bit overlay plane, while the prom @@ -247,7 +250,7 @@ zx_attach(struct device *parent, struct device *self, void *args) ZX_OFF_SS0, round_page(sc->sc_sunfb.sf_fbsize)); ri->ri_hw = sc; - fbwscons_init(&sc->sc_sunfb, isconsole); + fbwscons_init(&sc->sc_sunfb, sc->sc_isconsole); /* * Watch out! rasops_init() invoked via fbwscons_init() did not @@ -275,10 +278,9 @@ zx_attach(struct device *parent, struct device *self, void *args) ri->ri_ops.putchar = zx_putchar; ri->ri_do_cursor = zx_do_cursor; - if (isconsole) { + if (sc->sc_isconsole) { /* zx_reset() below will clear screen, so restart at 1st row */ fbwscons_console_init(&sc->sc_sunfb, 0); - shutdownhook_establish(zx_prom, sc); } /* reset cursor & frame buffer controls */ @@ -288,7 +290,23 @@ zx_attach(struct device *parent, struct device *self, void *args) /* enable video */ zx_burner(sc, 1, 0); - fbwscons_attach(&sc->sc_sunfb, &zx_accessops, isconsole); + fbwscons_attach(&sc->sc_sunfb, &zx_accessops, sc->sc_isconsole); +} + +int +zx_activate(struct device *self, int act) +{ + struct zx_softc *sc = (struct zx_softc *)self; + int ret = 0; + + switch (act) { + case DVACT_POWERDOWN: + if (sc->sc_isconsole) + zx_prom(sc); + break; + } + + return (ret); } int @@ -770,9 +788,8 @@ zx_putchar(void *cookie, int row, int col, u_int uc, long attr) } void -zx_prom(void *v) +zx_prom(struct zx_softc *sc) { - struct zx_softc *sc = v; extern struct consdev consdev_prom; if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) { diff --git a/sys/dev/sbus/cgtwelve.c b/sys/dev/sbus/cgtwelve.c index b298ef7358a..3b1f5856216 100644 --- a/sys/dev/sbus/cgtwelve.c +++ b/sys/dev/sbus/cgtwelve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgtwelve.c,v 1.6 2008/12/27 17:23:03 miod Exp $ */ +/* $OpenBSD: cgtwelve.c,v 1.7 2013/05/31 22:07:45 deraadt Exp $ */ /* * Copyright (c) 2002, 2003 Miodrag Vallat. All rights reserved. @@ -86,12 +86,13 @@ struct cgtwelve_softc { int sc_highres; int sc_nscreens; + int sc_isconsole; }; int cgtwelve_ioctl(void *, u_long, caddr_t, int, struct proc *); paddr_t cgtwelve_mmap(void *, off_t, int); void cgtwelve_reset(struct cgtwelve_softc *, int); -void cgtwelve_prom(void *); +void cgtwelve_prom(struct cgtwelve_softc *); static __inline__ void cgtwelve_ramdac_wraddr(struct cgtwelve_softc *sc, u_int32_t addr); @@ -110,9 +111,11 @@ struct wsdisplay_accessops cgtwelve_accessops = { int cgtwelvematch(struct device *, void *, void *); void cgtwelveattach(struct device *, struct device *, void *); +int cgtwelveactivate(struct device *, int); struct cfattach cgtwelve_ca = { - sizeof(struct cgtwelve_softc), cgtwelvematch, cgtwelveattach + sizeof(struct cgtwelve_softc), cgtwelvematch, cgtwelveattach, + NULL, cgtwelveactivate }; struct cfdriver cgtwelve_cd = { @@ -145,7 +148,7 @@ cgtwelveattach(struct device *parent, struct device *self, void *args) struct sbus_attach_args *sa = args; bus_space_tag_t bt; bus_space_handle_t bh; - int node, isconsole = 0; + int node; char *ps; bt = sa->sa_bustag; @@ -157,7 +160,7 @@ cgtwelveattach(struct device *parent, struct device *self, void *args) printf(" (%s)", ps); printf("\n"); - isconsole = node == fbnode; + sc->sc_isconsole = node == fbnode; if (sa->sa_nreg == 0) { printf("%s: no SBus registers!\n", self->dv_xname); @@ -232,12 +235,10 @@ cgtwelveattach(struct device *parent, struct device *self, void *args) sc->sc_sunfb.sf_ro.ri_bits = (void *)sc->sc_overlay; sc->sc_sunfb.sf_ro.ri_hw = sc; - fbwscons_init(&sc->sc_sunfb, 0, isconsole); + fbwscons_init(&sc->sc_sunfb, 0, sc->sc_isconsole); - if (isconsole) { + if (sc->sc_isconsole) fbwscons_console_init(&sc->sc_sunfb, -1); - shutdownhook_establish(cgtwelve_prom, sc); - } printf("%s: %dx%d", self->dv_xname, sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); @@ -246,7 +247,23 @@ cgtwelveattach(struct device *parent, struct device *self, void *args) printf(", microcode rev. %s", ps); printf("\n"); - fbwscons_attach(&sc->sc_sunfb, &cgtwelve_accessops, isconsole); + fbwscons_attach(&sc->sc_sunfb, &cgtwelve_accessops, sc->sc_isconsole); +} + +int +cgtwelveactivate(struct device *self, int act) +{ + struct cgtwelve_softc *sc = (struct cgtwelve_softc *)self; + int ret = 0; + + switch (act) { + case DVACT_POWERDOWN: + if (sc->sc_isconsole) + cgtwelve_prom(sc); + break; + } + + return (ret); } int @@ -445,9 +462,8 @@ cgtwelve_ramdac_wraddr(struct cgtwelve_softc *sc, u_int32_t addr) * so that the PROM prompt is visible again. */ void -cgtwelve_prom(void *v) +cgtwelve_prom(struct cgtwelve_softc *sc) { - struct cgtwelve_softc *sc = v; extern struct consdev consdev_prom; if (sc->sc_sunfb.sf_depth != 1) { |