static int wsfontioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { char nbuf[16]; void *buf; int res; switch (cmd) { case WSDISPLAYIO_LDFONT: #define d ((struct wsdisplay_font *)data) if (d->name) { res = copyinstr(d->name, nbuf, sizeof(nbuf), 0); if (res) return (res); d->name = nbuf; } else d->name = "loaded"; /* ??? */ buf = malloc(d->fontheight * d->stride * d->numchars, M_DEVBUF, M_WAITOK); res = copyin(d->data, buf, d->fontheight * d->stride * d->numchars); if (res) { free(buf, M_DEVBUF); return (res); } d->data = buf; res = wsfont_add(d, 1); free(buf, M_DEVBUF); #undef d return (res); default: return (EINVAL); } }
int p9100_pick_romfont(struct p9100_softc *sc) { struct rasops_info *ri = &sc->sc_sunfb.sf_ro; int *romwidth, *romheight; u_int8_t **romaddr; char buf[200]; /* * This code currently only works for PROM >= 2.9; see * autoconf.c romgetcursoraddr() for details. */ if (promvec->pv_romvec_vers < 2 || promvec->pv_printrev < 0x00020009) return (1); /* * Get the PROM font metrics and address */ if (snprintf(buf, sizeof buf, "stdout @ is my-self " "addr char-height %lx ! addr char-width %lx ! addr font-base %lx !", (vaddr_t)&romheight, (vaddr_t)&romwidth, (vaddr_t)&romaddr) >= sizeof buf) return (1); romheight = romwidth = NULL; rominterpret(buf); if (romheight == NULL || romwidth == NULL || romaddr == NULL || *romheight == 0 || *romwidth == 0 || *romaddr == NULL) return (1); p9100_romfont.fontwidth = *romwidth; p9100_romfont.fontheight = *romheight; p9100_romfont.stride = howmany(*romwidth, NBBY); p9100_romfont.data = *romaddr; #ifdef DEBUG printf("%s: PROM font %dx%d @%p", sc->sc_sunfb.sf_dev.dv_xname, *romwidth, *romheight, *romaddr); #endif /* * Build and add a wsfont structure */ wsfont_init(); /* if not done before */ if (wsfont_add(&p9100_romfont, 0) != 0) return (1); /* * Select this very font in our rasops structure */ ri->ri_wsfcookie = wsfont_find(ROMFONTNAME, 0, 0, 0); if (wsfont_lock(ri->ri_wsfcookie, &ri->ri_font, WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R) <= 0) { ri->ri_wsfcookie = 0; return (1); } return (0); }