"devtype=%x, rev=%x;%d, gid=%x%x, font=%x, mss=%x\n" "end=%x, mmap=%x, msto=%x, timo=%d, mont=%x, ua=%x\n" "memrq=%x, pwr=%d, bus=%x, ebus=%x, altt=%x, cfb=%x\n"
"devtype=%x, rev=%x;%d, altt=%x, gid=%016llx, font=%x, mss=%x\n" "end=%x, regions=%x, msto=%x, timo=%d, mont=%x, user=%x[%x]\n" "memrq=%x, pwr=%d, bus=%x, ebus=%x, cfb=%x\n"
sti_attach_common(sc)	struct sti_softc *sc;{	struct sti_inqconfout cfg;	bus_space_handle_t fbh;	struct sti_dd *dd;	struct sti_cfg *cc;	int error, size, i;	/* { extern int pmapdebug; pmapdebug = 0xfffff; } */	dd = &sc->sc_dd;	if (sc->sc_devtype == STI_DEVTYPE1) {#define	parseshort(o) \	((bus_space_read_1(sc->memt, sc->romh, (o) + 3) <<  8) | \	 (bus_space_read_1(sc->memt, sc->romh, (o) + 7)))#define	parseword(o) \	((bus_space_read_1(sc->memt, sc->romh, (o) +  3) << 24) | \	 (bus_space_read_1(sc->memt, sc->romh, (o) +  7) << 16) | \	 (bus_space_read_1(sc->memt, sc->romh, (o) + 11) <<  8) | \	 (bus_space_read_1(sc->memt, sc->romh, (o) + 15)))		dd->dd_type  = bus_space_read_1(sc->memt, sc->romh, 3);		dd->dd_nmon  = bus_space_read_1(sc->memt, sc->romh, 7);		dd->dd_grrev = bus_space_read_1(sc->memt, sc->romh, 11);		dd->dd_lrrev = bus_space_read_1(sc->memt, sc->romh, 15);		dd->dd_grid[0] = parseword(0x10);		dd->dd_grid[1] = parseword(0x20);		dd->dd_fntaddr = parseword(0x30) & ~3;		dd->dd_maxst   = parseword(0x40);		dd->dd_romend  = parseword(0x50) & ~3;		dd->dd_reglst  = parseword(0x60) & ~3;		dd->dd_maxreent= parseshort(0x70);		dd->dd_maxtimo = parseshort(0x78);				/* what happened to 0x80 ? */		dd->dd_montbl  = parseword(0x90);		dd->dd_udaddr  = parseword(0xa0) & ~3;		dd->dd_stimemreq=parseword(0xb0);		dd->dd_udsize  = parseword(0xc0);		dd->dd_pwruse  = parseshort(0xd0);		dd->dd_bussup  = bus_space_read_1(sc->memt, sc->romh, 0xdb);		dd->dd_ebussup = bus_space_read_1(sc->memt, sc->romh, 0xdf);		dd->dd_altcodet= bus_space_read_1(sc->memt, sc->romh, 0xe3);		dd->dd_cfbaddr = parseword(0xf0) & ~3;		dd->dd_pacode[0x0] = parseword(0x100) & ~3;		dd->dd_pacode[0x1] = parseword(0x110) & ~3;		dd->dd_pacode[0x2] = parseword(0x120) & ~3;		dd->dd_pacode[0x3] = parseword(0x130) & ~3;		dd->dd_pacode[0x4] = parseword(0x140) & ~3;		dd->dd_pacode[0x5] = parseword(0x150) & ~3;		dd->dd_pacode[0x6] = parseword(0x160) & ~3;		dd->dd_pacode[0x7] = parseword(0x170) & ~3;		dd->dd_pacode[0x8] = parseword(0x180) & ~3;		dd->dd_pacode[0x9] = parseword(0x190) & ~3;		dd->dd_pacode[0xa] = parseword(0x1a0) & ~3;		dd->dd_pacode[0xb] = parseword(0x1b0) & ~3;		dd->dd_pacode[0xc] = parseword(0x1c0) & ~3;		dd->dd_pacode[0xd] = parseword(0x1d0) & ~3;		dd->dd_pacode[0xe] = parseword(0x1e0) & ~3;		dd->dd_pacode[0xf] = parseword(0x1f0) & ~3;	} else	/* STI_DEVTYPE4 */		bus_space_read_region_4(sc->memt, sc->romh, 0, (u_int32_t *)dd,		    sizeof(*dd) / 4);#ifdef STIDEBUG	printf("dd:\n"	    "devtype=%x, rev=%x;%d, gid=%x%x, font=%x, mss=%x\n"	    "end=%x, mmap=%x, msto=%x, timo=%d, mont=%x, ua=%x\n"	    "memrq=%x, pwr=%d, bus=%x, ebus=%x, altt=%x, cfb=%x\n"	    "code=",	    dd->dd_type & 0xff, dd->dd_grrev, dd->dd_lrrev,	    dd->dd_grid[0], dd->dd_grid[1],	    dd->dd_fntaddr, dd->dd_maxst, dd->dd_romend,	    dd->dd_reglst, dd->dd_maxreent,	    dd->dd_maxtimo, dd->dd_montbl, dd->dd_udaddr,	    dd->dd_stimemreq, dd->dd_udsize, dd->dd_pwruse,	    dd->dd_bussup, dd->dd_altcodet, dd->dd_cfbaddr);	printf("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\n",	    dd->dd_pacode[0x0], dd->dd_pacode[0x1], dd->dd_pacode[0x2],	    dd->dd_pacode[0x3], dd->dd_pacode[0x4], dd->dd_pacode[0x5],	    dd->dd_pacode[0x6], dd->dd_pacode[0x7], dd->dd_pacode[0x8],	    dd->dd_pacode[0x9], dd->dd_pacode[0xa], dd->dd_pacode[0xb],	    dd->dd_pacode[0xc], dd->dd_pacode[0xd], dd->dd_pacode[0xe],	    dd->dd_pacode[0xf]);#endif	/* divine code size, could be less than STI_END entries */	for (i = STI_END; !dd->dd_pacode[i]; i--);	size = dd->dd_pacode[i] - dd->dd_pacode[STI_BEGIN];	if (sc->sc_devtype == STI_DEVTYPE1)		size = (size + 3) / 4;	if (!(sc->sc_code = uvm_km_alloc1(kernel_map, round_page(size), 0))) {		printf(": cannot allocate %u bytes for code\n", size);		return;	}#ifdef STIDEBUG	printf("code=0x%x[%x]\n", sc->sc_code, size);#endif	/* copy code into memory */	if (sc->sc_devtype == STI_DEVTYPE1) {		u_int8_t *p = (u_int8_t *)sc->sc_code;		u_int32_t addr, eaddr;		for (addr = dd->dd_pacode[STI_BEGIN], eaddr = addr + size * 4;		    addr < eaddr; addr += 4 )			*p++ = bus_space_read_4(sc->memt, sc->romh, addr) & 0xff;	} else	/* STI_DEVTYPE4 */		bus_space_read_region_4(sc->memt, sc->romh,		    dd->dd_pacode[STI_BEGIN], (u_int32_t *)sc->sc_code,		    size / 4);#define	O(i)	(dd->dd_pacode[(i)]? (sc->sc_code + \	(dd->dd_pacode[(i)] - dd->dd_pacode[0]) / \	(sc->sc_devtype == STI_DEVTYPE1? 4 : 1)) : NULL)	sc->init	= (sti_init_t)	O(STI_INIT_GRAPH);	sc->mgmt	= (sti_mgmt_t)	O(STI_STATE_MGMT);	sc->unpmv	= (sti_unpmv_t)	O(STI_FONT_UNPMV);	sc->blkmv	= (sti_blkmv_t)	O(STI_BLOCK_MOVE);	sc->test	= (sti_test_t)	O(STI_SELF_TEST);	sc->exhdl	= (sti_exhdl_t)	O(STI_EXCEP_HDLR);	sc->inqconf	= (sti_inqconf_t)O(STI_INQ_CONF);	sc->scment	= (sti_scment_t)O(STI_SCM_ENT);	sc->dmac	= (sti_dmac_t)	O(STI_DMA_CTRL);	sc->flowc	= (sti_flowc_t)	O(STI_FLOW_CTRL);	sc->utiming	= (sti_utiming_t)O(STI_UTIMING);	sc->pmgr	= (sti_pmgr_t)	O(STI_PROC_MGR);	sc->util	= (sti_util_t)	O(STI_UTIL);	if ((error = uvm_map_protect(kernel_map, sc->sc_code,	    sc->sc_code + round_page(size), UVM_PROT_RX, FALSE))) {		printf(": uvm_map_protect failed (%d)\n", error);		uvm_km_free(kernel_map, sc->sc_code, round_page(size));		return;	}	cc = &sc->sc_cfg;	bzero(cc, sizeof (*cc));	{		int i = dd->dd_reglst;		u_int32_t *p;		struct sti_region r;#ifdef STIDEBUG		printf("stiregions @%p:\n", i);#endif		r.last = 0;		for (p = cc->regions; !r.last &&		     p < &cc->regions[STI_REGION_MAX]; p++) {			if (sc->sc_devtype == STI_DEVTYPE1)				*(u_int *)&r = parseword(i), i+= 16;			else				*(u_int *)&r = bus_space_read_4(sc->memt, sc->romh, i), i += 4;			*p = (p == cc->regions? sc->romh : sc->ioh) +			    (r.offset << PGSHIFT);#ifdef STIDEBUG			printf("%x @ 0x%x%s%s%s%s\n",			    r.length << PGSHIFT, *p, r.sys_only? " sys" : "",			    r.cache? " cache" : "", r.btlb? " btlb" : "",			    r.last? " last" : "");#endif			/* rom has already been mapped */			if (p != cc->regions) {				if (bus_space_map(sc->memt, *p,				    r.length << PGSHIFT, 0, &fbh)) {#ifdef STIDEBUG					printf("already mapped region\n");#endif				} else if (p - cc->regions == 1)					sc->fbh = fbh;			}		}	}	if ((error = sti_init(sc, 0))) {		printf(": can not initialize (%d)\n", error);		return;	}	if ((error = sti_inqcfg(sc, &cfg))) {		printf(": error %d inquiring config\n", error);		return;	}	if ((error = sti_init(sc, STI_TEXTMODE))) {		printf(": can not initialize (%d)\n", error);		return;	}	sc->sc_wsmode = WSDISPLAYIO_MODE_EMUL;	printf(": %s rev %d.%02d;%d, ID 0x%016llX\n"	    "%s: %dx%d frame buffer, %dx%dx%d display, offset %dx%d\n",	    cfg.name, dd->dd_grrev >> 4, dd->dd_grrev & 0xf, dd->dd_lrrev,	    *(u_int64_t *)dd->dd_grid,	    sc->sc_dev.dv_xname, cfg.fbwidth, cfg.fbheight,	    cfg.width, cfg.height, cfg.bpp, cfg.owidth, cfg.oheight);	if ((error = sti_fetchfonts(sc, &cfg, dd->dd_fntaddr))) {		printf("%s: cannot fetch fonts (%d)\n",		    sc->sc_dev.dv_xname, error);		return;	}	/*	 * parse screen descriptions:	 *	figure number of fonts supported;	 *	allocate wscons structures;	 *	calculate dimentions.	 */	sti_default_screen.ncols = cfg.width / sc->sc_curfont.width;	sti_default_screen.nrows = cfg.height / sc->sc_curfont.height;	sti_default_screen.fontwidth = sc->sc_curfont.width;	sti_default_screen.fontheight = sc->sc_curfont.height;#if NWSDISPLAY > 0	startuphook_establish(sti_attach_deferred, sc);#endif	/* { extern int pmapdebug; pmapdebug = 0; } */}