Home | History | Annotate | Line # | Download | only in dev
nextdisplay.c revision 1.16.2.1
      1  1.16.2.1      kent /* $NetBSD: nextdisplay.c,v 1.16.2.1 2005/04/29 11:28:18 kent Exp $ */
      2       1.2       dbj 
      3       1.1       dbj /*
      4       1.1       dbj  * Copyright (c) 1998 Matt DeBergalis
      5       1.1       dbj  * All rights reserved.
      6       1.1       dbj  *
      7       1.1       dbj  * Redistribution and use in source and binary forms, with or without
      8       1.1       dbj  * modification, are permitted provided that the following conditions
      9       1.1       dbj  * are met:
     10       1.1       dbj  * 1. Redistributions of source code must retain the above copyright
     11       1.1       dbj  *    notice, this list of conditions and the following disclaimer.
     12       1.1       dbj  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1       dbj  *    notice, this list of conditions and the following disclaimer in the
     14       1.1       dbj  *    documentation and/or other materials provided with the distribution.
     15       1.1       dbj  * 3. All advertising materials mentioning features or use of this software
     16       1.1       dbj  *    must display the following acknowledgement:
     17       1.1       dbj  *      This product includes software developed by Matt DeBergalis
     18       1.1       dbj  * 4. The name of the author may not be used to endorse or promote products
     19       1.1       dbj  *    derived from this software without specific prior written permission
     20       1.1       dbj  *
     21       1.1       dbj  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22       1.1       dbj  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23       1.1       dbj  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24       1.1       dbj  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25       1.1       dbj  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26       1.1       dbj  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27       1.1       dbj  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28       1.1       dbj  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29       1.1       dbj  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30       1.1       dbj  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31       1.1       dbj  */
     32      1.13     lukem 
     33      1.13     lukem #include <sys/cdefs.h>
     34  1.16.2.1      kent __KERNEL_RCSID(0, "$NetBSD: nextdisplay.c,v 1.16.2.1 2005/04/29 11:28:18 kent Exp $");
     35       1.1       dbj 
     36       1.1       dbj #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     37       1.1       dbj 
     38       1.1       dbj #include <sys/param.h>
     39       1.1       dbj #include <sys/systm.h>
     40       1.1       dbj #include <sys/kernel.h>
     41       1.1       dbj #include <sys/device.h>
     42       1.1       dbj #include <sys/malloc.h>
     43       1.1       dbj 
     44       1.9   mycroft #include <machine/bus.h>
     45       1.1       dbj #include <machine/cpu.h>
     46       1.1       dbj 
     47       1.2       dbj #include <next68k/next68k/nextrom.h>
     48      1.14   mycroft #include <next68k/next68k/isr.h>
     49       1.2       dbj 
     50       1.9   mycroft #include <next68k/dev/intiovar.h>
     51       1.1       dbj #include <next68k/dev/nextdisplayvar.h>
     52       1.1       dbj #include <dev/wscons/wsconsio.h>
     53       1.1       dbj 
     54       1.1       dbj #include <dev/rcons/raster.h>
     55       1.1       dbj #include <dev/wscons/wscons_raster.h>
     56       1.1       dbj #include <dev/wscons/wsdisplayvar.h>
     57       1.1       dbj 
     58       1.9   mycroft extern int turbo;
     59       1.9   mycroft 
     60  1.16.2.1      kent int nextdisplay_match(struct device *, struct cfdata *, void *);
     61  1.16.2.1      kent void nextdisplay_attach(struct device *, struct device *, void *);
     62       1.1       dbj 
     63      1.12   thorpej CFATTACH_DECL(nextdisplay, sizeof(struct nextdisplay_softc),
     64      1.12   thorpej     nextdisplay_match, nextdisplay_attach, NULL, NULL);
     65       1.1       dbj 
     66       1.1       dbj const struct wsdisplay_emulops nextdisplay_mono_emulops = {
     67       1.1       dbj 	rcons_cursor,
     68       1.1       dbj 	rcons_mapchar,
     69       1.1       dbj 	rcons_putchar,
     70       1.1       dbj 	rcons_copycols,
     71       1.1       dbj 	rcons_erasecols,
     72       1.1       dbj 	rcons_copyrows,
     73       1.1       dbj 	rcons_eraserows,
     74       1.8  junyoung 	rcons_allocattr
     75       1.1       dbj };
     76       1.1       dbj 
     77       1.1       dbj struct wsscreen_descr nextdisplay_mono = {
     78       1.2       dbj 	"mono",
     79       1.1       dbj 	0, 0, /* will be filled in -- XXX shouldn't, it's global */
     80       1.1       dbj 	&nextdisplay_mono_emulops,
     81       1.1       dbj 	0, 0
     82       1.1       dbj };
     83       1.1       dbj 
     84       1.2       dbj struct wsscreen_descr nextdisplay_color = {
     85       1.2       dbj         "color",
     86       1.2       dbj         0, 0, /* again, filled in */
     87       1.2       dbj         &nextdisplay_mono_emulops,
     88       1.2       dbj         0, 0
     89       1.2       dbj };
     90       1.2       dbj 
     91       1.1       dbj const struct wsscreen_descr *_nextdisplay_scrlist_mono[] = {
     92       1.1       dbj 	&nextdisplay_mono,
     93       1.1       dbj };
     94       1.1       dbj 
     95       1.2       dbj const struct wsscreen_descr *_nextdisplay_scrlist_color[] = {
     96       1.2       dbj         &nextdisplay_color,
     97       1.2       dbj };
     98       1.2       dbj 
     99       1.1       dbj const struct wsscreen_list nextdisplay_screenlist_mono = {
    100       1.1       dbj 	sizeof(_nextdisplay_scrlist_mono) / sizeof(struct wsscreen_descr *),
    101       1.1       dbj 	_nextdisplay_scrlist_mono
    102       1.1       dbj };
    103       1.1       dbj 
    104       1.2       dbj const struct wsscreen_list nextdisplay_screenlist_color = {
    105       1.2       dbj 	sizeof(_nextdisplay_scrlist_color) / sizeof(struct wsscreen_descr *),
    106       1.2       dbj 	_nextdisplay_scrlist_color
    107       1.2       dbj };
    108       1.2       dbj 
    109  1.16.2.1      kent static int	nextdisplay_ioctl(void *, u_long, caddr_t, int, struct proc *);
    110  1.16.2.1      kent static paddr_t	nextdisplay_mmap(void *, off_t, int);
    111  1.16.2.1      kent static int	nextdisplay_alloc_screen(void *, const struct wsscreen_descr *,
    112  1.16.2.1      kent 		void **, int *, int *, long *);
    113  1.16.2.1      kent static void	nextdisplay_free_screen(void *, void *);
    114  1.16.2.1      kent static int	nextdisplay_show_screen(void *, void *, int,
    115  1.16.2.1      kent 					void (*) (void *, int, int), void *);
    116  1.16.2.1      kent static int	nextdisplay_load_font(void *, void *, struct wsdisplay_font *);
    117       1.1       dbj 
    118       1.1       dbj const struct wsdisplay_accessops nextdisplay_accessops = {
    119       1.1       dbj 	nextdisplay_ioctl,
    120       1.1       dbj 	nextdisplay_mmap,
    121       1.1       dbj 	nextdisplay_alloc_screen,
    122       1.1       dbj 	nextdisplay_free_screen,
    123       1.1       dbj 	nextdisplay_show_screen,
    124       1.1       dbj 	nextdisplay_load_font
    125       1.1       dbj };
    126       1.1       dbj 
    127       1.2       dbj void nextdisplay_init(struct nextdisplay_config *, int);
    128  1.16.2.1      kent int nextdisplay_intr(void *);
    129       1.1       dbj 
    130      1.14   mycroft vaddr_t nextdisplay_consaddr;
    131  1.16.2.1      kent static int nextdisplay_is_console(vaddr_t);
    132       1.1       dbj 
    133       1.1       dbj static struct nextdisplay_config nextdisplay_console_dc;
    134       1.1       dbj 
    135       1.1       dbj static int
    136      1.14   mycroft nextdisplay_is_console(vaddr_t addr)
    137       1.1       dbj {
    138       1.1       dbj 	return (nextdisplay_console_dc.isconsole
    139       1.1       dbj 			&& (addr == nextdisplay_consaddr));
    140       1.1       dbj }
    141       1.1       dbj 
    142       1.1       dbj int
    143  1.16.2.1      kent nextdisplay_match(struct device *parent, struct cfdata *match, void *aux)
    144       1.1       dbj {
    145      1.14   mycroft 	if (rom_machine_type == NeXT_WARP9 ||
    146      1.14   mycroft 	    rom_machine_type == NeXT_X15 ||
    147      1.14   mycroft 	    rom_machine_type == NeXT_WARP9C ||
    148      1.14   mycroft 	    rom_machine_type == NeXT_TURBO_MONO ||
    149      1.14   mycroft 	    rom_machine_type == NeXT_TURBO_COLOR)
    150       1.2       dbj 		return (1);
    151       1.2       dbj 	else
    152       1.2       dbj 		return (0);
    153       1.1       dbj }
    154       1.1       dbj 
    155       1.1       dbj void
    156  1.16.2.1      kent nextdisplay_init(struct nextdisplay_config *dc, int color)
    157       1.1       dbj {
    158       1.1       dbj 	struct raster *rap;
    159       1.1       dbj 	struct rcons *rcp;
    160       1.1       dbj 	int i;
    161       1.1       dbj 
    162       1.1       dbj 	/* printf("in nextdisplay_init\n"); */
    163       1.1       dbj 
    164      1.14   mycroft 	if (color) {
    165      1.14   mycroft 		dc->dc_vaddr = colorbase;
    166      1.14   mycroft 		dc->dc_paddr = COLORBASE;
    167      1.14   mycroft 		dc->dc_size = NEXT_P_C16_VIDEOSIZE;
    168      1.14   mycroft 	} else {
    169      1.14   mycroft 		dc->dc_vaddr = monobase;
    170      1.14   mycroft 		dc->dc_paddr = MONOBASE;
    171      1.14   mycroft 		dc->dc_size = NEXT_P_VIDEOSIZE;
    172      1.14   mycroft 	}
    173       1.1       dbj 
    174       1.9   mycroft 	dc->dc_wid = 1120;
    175       1.9   mycroft 	dc->dc_ht = 832;
    176       1.5    deberg 	dc->dc_depth = color ? 16 : 2;
    177       1.9   mycroft 	dc->dc_rowbytes = (turbo ? 1120 : 1152) * dc->dc_depth / 8;
    178       1.1       dbj 
    179       1.1       dbj 	dc->dc_videobase = dc->dc_vaddr;
    180       1.1       dbj 
    181       1.1       dbj #if 0
    182       1.1       dbj 	printf("intiobase at: %08x\n", intiobase);
    183       1.1       dbj 	printf("intiolimit at: %08x\n", intiolimit);
    184       1.2       dbj 	printf("videobase at: %08x\n", color ? colorbase : monobase);
    185       1.2       dbj 	printf("videolimit at: %08x\n", color ? colorlimit : monolimit);
    186       1.1       dbj 
    187       1.1       dbj 	printf("virtual fb at: %08x\n", dc->dc_vaddr);
    188       1.1       dbj 	printf("physical fb at: %08x\n", dc->dc_paddr);
    189       1.1       dbj 	printf("fb size: %08x\n", dc->dc_size);
    190       1.1       dbj 
    191       1.1       dbj 	printf("dc_wid: %08x\n", dc->dc_wid);
    192       1.1       dbj 	printf("dc_ht: %08x\n", dc->dc_ht);
    193       1.1       dbj 	printf("dc_depth: %08x\n", dc->dc_depth);
    194       1.1       dbj 	printf("dc_rowbytes: %08x\n", dc->dc_rowbytes);
    195       1.1       dbj 	printf("dc_videobase: %08x\n", dc->dc_videobase);
    196       1.1       dbj #endif
    197       1.1       dbj 
    198       1.1       dbj 	/* clear the screen */
    199       1.1       dbj 	for (i = 0; i < dc->dc_ht * dc->dc_rowbytes; i += sizeof(u_int32_t))
    200       1.5    deberg 		*(u_int32_t *)(dc->dc_videobase + i) =
    201       1.5    deberg 			(color ? 0x0 : 0xffffffff);
    202       1.5    deberg 
    203       1.1       dbj 	rap = &dc->dc_raster;
    204       1.1       dbj 	rap->width = dc->dc_wid;
    205       1.1       dbj 	rap->height = dc->dc_ht;
    206       1.5    deberg 	rap->depth = color ? 16 : 2;
    207       1.1       dbj 	rap->linelongs = dc->dc_rowbytes / sizeof(u_int32_t);
    208       1.1       dbj 	rap->pixels = (u_int32_t *)dc->dc_videobase;
    209       1.1       dbj 
    210       1.1       dbj 	/* initialize the raster console blitter */
    211       1.1       dbj 	rcp = &dc->dc_rcons;
    212       1.1       dbj 	rcp->rc_sp = rap;
    213       1.1       dbj 	rcp->rc_crow = rcp->rc_ccol = -1;
    214       1.1       dbj 	rcp->rc_crowp = &rcp->rc_crow;
    215       1.1       dbj 	rcp->rc_ccolp = &rcp->rc_ccol;
    216       1.1       dbj 	rcons_init(rcp, 34, 80);
    217       1.1       dbj 
    218       1.2       dbj 	if (color) {
    219       1.2       dbj 		nextdisplay_color.nrows = dc->dc_rcons.rc_maxrow;
    220       1.2       dbj 		nextdisplay_color.ncols = dc->dc_rcons.rc_maxcol;
    221       1.2       dbj 	} else {
    222       1.2       dbj 		nextdisplay_mono.nrows = dc->dc_rcons.rc_maxrow;
    223       1.2       dbj 		nextdisplay_mono.ncols = dc->dc_rcons.rc_maxcol;
    224       1.2       dbj 	}
    225       1.1       dbj }
    226       1.1       dbj 
    227       1.1       dbj void
    228  1.16.2.1      kent nextdisplay_attach(struct device *parent, struct device *self, void *aux)
    229       1.1       dbj {
    230      1.14   mycroft 	struct nextdisplay_softc *sc = (void *)self;
    231       1.1       dbj 	struct wsemuldisplaydev_attach_args waa;
    232       1.1       dbj 	int isconsole;
    233       1.2       dbj 	int iscolor;
    234       1.2       dbj 	paddr_t addr;
    235       1.1       dbj 
    236      1.14   mycroft 	if (rom_machine_type == NeXT_WARP9C ||
    237      1.14   mycroft 	    rom_machine_type == NeXT_TURBO_COLOR) {
    238       1.2       dbj 		iscolor = 1;
    239      1.14   mycroft 		addr = colorbase;
    240       1.2       dbj 	} else {
    241       1.2       dbj 		iscolor = 0;
    242      1.14   mycroft 		addr = monobase;
    243       1.2       dbj 	}
    244       1.1       dbj 
    245       1.2       dbj 	isconsole = nextdisplay_is_console(addr);
    246       1.1       dbj 
    247       1.2       dbj 	if (isconsole) {
    248       1.1       dbj 		sc->sc_dc = &nextdisplay_console_dc;
    249       1.1       dbj 		sc->nscreens = 1;
    250       1.1       dbj 	} else {
    251       1.1       dbj 		sc->sc_dc = (struct nextdisplay_config *)
    252       1.1       dbj 				malloc(sizeof(struct nextdisplay_config), M_DEVBUF, M_WAITOK);
    253       1.2       dbj 		nextdisplay_init(sc->sc_dc, iscolor);
    254       1.1       dbj 	}
    255       1.1       dbj 
    256       1.2       dbj 	printf(": %d x %d, %dbpp\n", sc->sc_dc->dc_wid, sc->sc_dc->dc_ht,
    257       1.2       dbj 	       sc->sc_dc->dc_depth);
    258       1.2       dbj 
    259      1.14   mycroft 	if (iscolor) {
    260      1.14   mycroft #if 0
    261      1.14   mycroft 		uint8_t x;
    262      1.14   mycroft 
    263      1.14   mycroft 		x = *(volatile uint8_t *)IIOV(NEXT_P_C16_CMD_REG);
    264      1.14   mycroft 		printf("%s: cmd=%02x\n", sc->sc_dev.dv_xname, x);
    265      1.14   mycroft #endif
    266      1.14   mycroft 		*(volatile uint8_t *)IIOV(NEXT_P_C16_CMD_REG) = 0x05;
    267      1.14   mycroft 		isrlink_autovec(nextdisplay_intr, sc, NEXT_I_IPL(NEXT_I_C16_VIDEO), 1, NULL);
    268      1.14   mycroft 		INTR_ENABLE(NEXT_I_C16_VIDEO);
    269      1.14   mycroft 	}
    270      1.14   mycroft 
    271       1.1       dbj 	/* initialize the raster */
    272       1.1       dbj 	waa.console = isconsole;
    273       1.2       dbj 	waa.scrdata = iscolor ? &nextdisplay_screenlist_color : &nextdisplay_screenlist_mono;
    274       1.1       dbj 	waa.accessops = &nextdisplay_accessops;
    275       1.1       dbj 	waa.accesscookie = sc;
    276       1.2       dbj #if 0
    277       1.2       dbj 	printf("nextdisplay: access cookie is %p\n", sc);
    278       1.2       dbj #endif
    279       1.1       dbj 	config_found(self, &waa, wsemuldisplaydevprint);
    280       1.1       dbj }
    281       1.1       dbj 
    282      1.14   mycroft int
    283  1.16.2.1      kent nextdisplay_intr(void *arg)
    284      1.14   mycroft {
    285      1.14   mycroft #if 0
    286      1.14   mycroft 	uint8_t x;
    287      1.14   mycroft #endif
    288      1.14   mycroft 
    289      1.14   mycroft 	if (!INTR_OCCURRED(NEXT_I_C16_VIDEO))
    290      1.14   mycroft 		return (0);
    291      1.14   mycroft #if 0
    292      1.14   mycroft 	x = *(volatile uint8_t *)IIOV(NEXT_P_C16_CMD_REG);
    293      1.14   mycroft 	printf("I%02x", x);
    294      1.14   mycroft #endif
    295      1.15   mycroft 	*(volatile uint8_t *)IIOV(NEXT_P_C16_CMD_REG) = 0x05;
    296      1.14   mycroft 	return (1);
    297      1.14   mycroft }
    298       1.1       dbj 
    299       1.1       dbj int
    300  1.16.2.1      kent nextdisplay_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
    301       1.1       dbj {
    302       1.1       dbj 	struct nextdisplay_softc *sc = v;
    303       1.1       dbj 	struct nextdisplay_config *dc = sc->sc_dc;
    304       1.1       dbj 
    305       1.1       dbj 	switch (cmd) {
    306       1.1       dbj 	case WSDISPLAYIO_GTYPE:
    307       1.1       dbj 		*(int *)data = dc->dc_type;
    308       1.1       dbj 		return 0;
    309       1.1       dbj 
    310       1.1       dbj 	case WSDISPLAYIO_SCURSOR:
    311       1.1       dbj 		printf("nextdisplay_ioctl: wsdisplayio_scursor\n");
    312       1.7    atatat 		return EPASSTHROUGH;
    313       1.1       dbj 
    314       1.1       dbj 	case WSDISPLAYIO_SCURPOS:
    315       1.1       dbj 		printf("nextdisplay_ioctl: wsdisplayio_scurpos\n");
    316       1.7    atatat 		return EPASSTHROUGH;
    317       1.1       dbj 
    318       1.1       dbj 	case WSDISPLAYIO_GINFO:
    319       1.1       dbj 	case WSDISPLAYIO_GETCMAP:
    320       1.1       dbj 	case WSDISPLAYIO_PUTCMAP:
    321       1.1       dbj 	case WSDISPLAYIO_GVIDEO:
    322       1.1       dbj 	case WSDISPLAYIO_SVIDEO:
    323       1.1       dbj 	case WSDISPLAYIO_GCURPOS:
    324       1.1       dbj 	case WSDISPLAYIO_GCURMAX:
    325       1.1       dbj 	case WSDISPLAYIO_GCURSOR:
    326       1.1       dbj 		printf("nextdisplay_ioctl: listed but unsupported ioctl\n");
    327       1.7    atatat 		return EPASSTHROUGH;
    328       1.1       dbj 	}
    329       1.2       dbj 
    330       1.7    atatat 	return EPASSTHROUGH;
    331       1.1       dbj }
    332       1.1       dbj 
    333       1.4    simonb static paddr_t
    334  1.16.2.1      kent nextdisplay_mmap(void *v, off_t offset, int prot)
    335       1.1       dbj {
    336       1.1       dbj 
    337       1.1       dbj 	/* XXX */
    338       1.2       dbj 	printf("nextdisplay_mmap: failed\n");
    339       1.1       dbj 	return -1;
    340       1.1       dbj }
    341       1.1       dbj 
    342       1.1       dbj int
    343  1.16.2.1      kent nextdisplay_alloc_screen(void *v, const struct wsscreen_descr *type,
    344  1.16.2.1      kent     void **cookiep, int *curxp, int *curyp, long *defattrp)
    345       1.1       dbj {
    346       1.1       dbj 	struct nextdisplay_softc *sc = v;
    347       1.1       dbj 	long defattr;
    348       1.1       dbj 
    349       1.2       dbj 	/* only allow one screen */
    350       1.1       dbj 	if (sc->nscreens > 0)
    351       1.1       dbj 		return (ENOMEM);
    352       1.1       dbj 
    353       1.1       dbj 	*cookiep = &sc->sc_dc->dc_rcons; /* one and only for now */
    354       1.1       dbj 	*curxp = 0;
    355       1.1       dbj 	*curyp = 0;
    356       1.8  junyoung 	rcons_allocattr(&sc->sc_dc->dc_rcons, 0, 0,
    357       1.8  junyoung 			(strcmp(type->name, "color") == 0)
    358       1.8  junyoung 			? 0
    359       1.8  junyoung 			: WSATTR_REVERSE, &defattr);
    360       1.1       dbj 	*defattrp = defattr;
    361       1.1       dbj 	sc->nscreens++;
    362       1.2       dbj #if 0
    363       1.2       dbj 	printf("nextdisplay: allocating screen\n");
    364       1.2       dbj #endif
    365       1.1       dbj 	return (0);
    366       1.1       dbj }
    367       1.1       dbj 
    368       1.1       dbj void
    369  1.16.2.1      kent nextdisplay_free_screen(void *v, void *cookie)
    370       1.1       dbj {
    371       1.1       dbj 	struct nextdisplay_softc *sc = v;
    372       1.1       dbj 
    373       1.1       dbj 	if (sc->sc_dc == &nextdisplay_console_dc)
    374       1.2       dbj 		panic("nextdisplay_free_screen: console");
    375       1.1       dbj 
    376       1.1       dbj 	sc->nscreens--;
    377       1.1       dbj }
    378       1.1       dbj 
    379       1.3  drochner int
    380  1.16.2.1      kent nextdisplay_show_screen(void *v, void *cookie, int waitok,
    381  1.16.2.1      kent     void (*cb)(void *, int, int), void *cbarg)
    382       1.1       dbj {
    383       1.3  drochner 
    384       1.3  drochner 	return (0);
    385       1.1       dbj }
    386       1.1       dbj 
    387       1.1       dbj static int
    388  1.16.2.1      kent nextdisplay_load_font(void *v, void *cookie, struct wsdisplay_font *font)
    389       1.1       dbj {
    390       1.7    atatat 	return (EPASSTHROUGH);
    391       1.1       dbj }
    392       1.1       dbj 
    393       1.1       dbj int
    394       1.2       dbj nextdisplay_cnattach(void)
    395       1.1       dbj {
    396       1.1       dbj 	struct nextdisplay_config *dc = &nextdisplay_console_dc;
    397       1.1       dbj 	long defattr;
    398       1.2       dbj 	int iscolor;
    399       1.2       dbj 
    400      1.14   mycroft 	if (rom_machine_type == NeXT_WARP9C ||
    401      1.14   mycroft 	    rom_machine_type == NeXT_TURBO_COLOR)
    402       1.2       dbj 		iscolor = 1;
    403      1.14   mycroft 	else
    404       1.2       dbj 		iscolor = 0;
    405       1.1       dbj 
    406       1.1       dbj 	/* set up the display */
    407       1.2       dbj 	nextdisplay_init(&nextdisplay_console_dc, iscolor);
    408      1.14   mycroft 	nextdisplay_consaddr = nextdisplay_console_dc.dc_vaddr;
    409       1.1       dbj 
    410       1.8  junyoung 	rcons_allocattr(&dc->dc_rcons, 0, 0,
    411       1.8  junyoung 			iscolor ? 0 : WSATTR_REVERSE, &defattr);
    412       1.1       dbj 
    413       1.2       dbj 	wsdisplay_cnattach(iscolor ? &nextdisplay_color : &nextdisplay_mono,
    414       1.2       dbj 			   &dc->dc_rcons, 0, 0, defattr);
    415       1.1       dbj 
    416       1.1       dbj 	dc->isconsole = 1;
    417       1.1       dbj 	return (0);
    418       1.1       dbj }
    419