static void
et_inittextmode(struct ite_softc *ip, et_sv_reg_t *etregs, int loadfont)
{
	volatile u_char *ba;
	font_info	*fd;
	u_char		*fb;
	u_char		*c, *f, tmp;
	u_short		z, y;
	int		s;
	view_t		*v   = viewview(ip->grf->g_viewdev);
	et_sv_reg_t	loc_regs;

	if (etregs == NULL) {
		etregs = &loc_regs;
		et_hwsave(etregs);
	}

	ba = ((ipriv_t*)ip->priv)->regkva;
	fb = v->bitmap->plane;

#if defined(KFONT_8X8)
	fd = &font_info_8x8;
#else
	fd = &font_info_8x16;
#endif

	if (loadfont) { /* XXX: We should set the colormap */
		/*
		 * set colors (B&W)
		 */
		vgaw(ba, VDAC_ADDRESS_W, 0);
		for (z = 0; z < 256; z++) {
			y = (z & 1) ? ((z > 7) ? 2 : 1) : 0;
    
			vgaw(ba, VDAC_DATA, etconscolors[y][0]);
			vgaw(ba, VDAC_DATA, etconscolors[y][1]);
			vgaw(ba, VDAC_DATA, etconscolors[y][2]);
		}

		/*
		 * Enter a suitable mode to download the font. This
		 * basically means sequential addressing mode
		 */
		s = splhigh();

		WAttr(ba, 0x20 | ACT_ID_ATTR_MODE_CNTL, 0x0a);
		WSeq(ba, SEQ_ID_MAP_MASK,	 0x04);
		WSeq(ba, SEQ_ID_MEMORY_MODE,	 0x06);
		WGfx(ba, GCT_ID_READ_MAP_SELECT, 0x02);
		WGfx(ba, GCT_ID_GRAPHICS_MODE,	 0x00);
		WGfx(ba, GCT_ID_MISC,		 0x04);
		splx(s);
	
		/*
		 * load text font into beginning of display memory. Each
		 * character cell is 32 bytes long (enough for 4 planes)
		 */
		for (z = 0, c = fb; z < 256 * 32; z++)
			*c++ = 0;

		c = (unsigned char *) (fb) + (32 * fd->font_lo);
		f = fd->font_p;
		z = fd->font_lo;
		for (; z <= fd->font_hi; z++, c += (32 - fd->height))
			for (y = 0; y < fd->height; y++) {
				*c++ = *f++;
			}
	}

	/*
	 * Odd/Even addressing
	 */
	etregs->seq[SEQ_ID_MAP_MASK]        = 0x03;
	etregs->seq[SEQ_ID_MEMORY_MODE]     = 0x03;
	etregs->grf[GCT_ID_READ_MAP_SELECT] = 0x00;
	etregs->grf[GCT_ID_GRAPHICS_MODE]   = 0x10;
	etregs->grf[GCT_ID_MISC]            = 0x06;

	/*
	 * Font height + underline location
	 */
	tmp = etregs->crt[CRT_ID_MAX_ROW_ADDRESS] & 0xe0;
	etregs->crt[CRT_ID_MAX_ROW_ADDRESS] = tmp | (fd->height - 1);
	tmp = etregs->crt[CRT_ID_UNDERLINE_LOC] & 0xe0;
	etregs->crt[CRT_ID_UNDERLINE_LOC] = tmp | (fd->height - 1);

	/*
	 * Cursor setup
	 */
	etregs->crt[CRT_ID_CURSOR_START]    = 0x00;
	etregs->crt[CRT_ID_CURSOR_END]      = fd->height - 1;
	etregs->crt[CRT_ID_CURSOR_LOC_HIGH] = 0x00;
	etregs->crt[CRT_ID_CURSOR_LOC_LOW]  = 0x00;

	/*
	 * Enter text mode
	 */
	etregs->crt[CRT_ID_MODE_CONTROL]    = 0xa3;
	etregs->attr[ACT_ID_ATTR_MODE_CNTL] = 0x0a;

#if 1
	if (loadfont || (etregs == &loc_regs))
#else
	if (etregs == &loc_regs)
#endif
		et_hwrest(etregs);
}
Beispiel #2
0
/*
 * Go look for a VGA card on the PCI-bus. This search is a
 * stripped down version of the PCI-probe. It only looks on
 * bus0 for VGA cards. The first card found is used.
 */
int
check_for_vga()
{
    pci_chipset_tag_t	pc = NULL; /* XXX */
    pcitag_t		tag;
    int			device, found, id, maxndevs, i, j;
    volatile u_char		*regs;
    u_char			*fb;
    char			*nbd = "NetBSD/Atari";

    found    = 0;
    tag      = 0;
    id       = 0;
    maxndevs = pci_bus_maxdevs(pc, 0);

    /*
     * These are setup in atari_init.c
     */
    regs = (volatile caddr_t)pci_io_addr;
    fb   = (caddr_t)pci_mem_addr;

    for (device = 0; !found && (device < maxndevs); device++) {

        tag = pci_make_tag(pc, 0, device, 0);
        id  = pci_conf_read(pc, tag, PCI_ID_REG);
        if (id == 0 || id == 0xffffffff)
            continue;
        switch (id = PCI_PRODUCT(id)) {

        /*
         * XXX Make the inclusion of the cases dependend
         *     on config options!
         */
        case PCI_PRODUCT_TSENG_ET6000:
        case PCI_PRODUCT_TSENG_ET4000_W32P_A:
        case PCI_PRODUCT_TSENG_ET4000_W32P_B:
        case PCI_PRODUCT_TSENG_ET4000_W32P_C:
        case PCI_PRODUCT_TSENG_ET4000_W32P_D:
            tseng_init(pc, tag, id, regs, fb);
            found = 1;
            break;
        default:
            break;
        }
    }
    if (!found)
        return (0);

    /*
     * Generic parts of the initialization...
     */

    /* B&W colors */
    vgaw(regs, VDAC_ADDRESS_W, 0);
    for (i = 0; i < 256; i++) {
        j = (i & 1) ? ((i > 7) ? 2 : 1) : 0;
        vgaw(regs, VDAC_DATA, conscolors[j][0]);
        vgaw(regs, VDAC_DATA, conscolors[j][1]);
        vgaw(regs, VDAC_DATA, conscolors[j][2]);
    }

    loadfont(regs, fb);

    /*
     * Clear the screen and print a message. The latter
     * is of diagnostic/debug use only.
     */
    for (i = 50 * 80; i >= 0; i -= 2) {
        fb[i] = 0x20;
        fb[i+1] = 0x07;
    }
    for (i = 56; *nbd; i += 2)
        fb[i] = *nbd++;

    return (1);
}
void
grfclattach(device_t parent, device_t self, void *aux)
{
	static struct grf_softc congrf;
	struct zbus_args *zap;
	struct grf_softc *gp;
	struct device temp;
	static char attachflag = 0;

	zap = aux;

	printf("\n");

	/* make sure both halves have matched */
	if (!cl_regaddr || !cl_fbaddr)
		return;

	/* do all that messy console/grf stuff */
	if (self == NULL) {
		gp = &congrf;
		gp->g_device = &temp;
		temp.dv_private = gp;
	} else {
		gp = device_private(self);
		gp->g_device = self;
	}

	if (self != NULL && congrf.g_regkva != 0) {
		/*
		 * inited earlier, just copy (not device struct)
		 */
		memcpy(&gp->g_display, &congrf.g_display,
		    (char *) &gp[1] - (char *) &gp->g_display);
	} else {
		gp->g_regkva = (volatile void *) cl_regaddr;
		gp->g_fbkva = (volatile void *) cl_fbaddr;

		gp->g_unit = GRF_CL5426_UNIT;
		gp->g_mode = cl_mode;
#if NITE > 0
		gp->g_conpri = grfcl_cnprobe();
#endif
		gp->g_flags = GF_ALIVE;

		/* wakeup the board */
		cl_boardinit(gp);
#ifdef CL5426CONSOLE
#if NITE > 0
		grfcl_iteinit(gp);
#endif
		(void) cl_load_mon(gp, &clconsole_mode);
#endif

	}

	/*
	 * attach grf (once)
	 */
	if (amiga_config_found(cfdata, gp->g_device, gp, grfclprint)) {
		attachflag = 1;
		printf("grfcl: %dMB ", cl_fbsize / 0x100000);
		switch (cltype) {
		    case PICASSO:
			if (cl_64bit == 1) {
				printf("Picasso IV");
				/* 135MHz will be supported if we
				 * have a palette doubling mode.
				 */
				cl_maxpixelclock = 86000000;
			}
			else {
				printf("Picasso II");

				/* check for PicassoII+ (crest) */
				if(zap->serno == 0x00100000)
				    printf("+");

				/* determine used Gfx/chipset (crest) */
				vgaw(gp->g_regkva, CRT_ADDRESS, 0x27); /* Chip ID */
				switch(vgar(gp->g_regkva, CRT_ADDRESS_R)>>2) {
				    case 0x24:
					printf(" (with CL-GD5426)");
					break;
				    case 0x26:
					printf(" (with CL-GD5428)");
					break;
				    case 0x27:
					printf(" (with CL-GD5429)");
					break;
				}
	                        cl_maxpixelclock = 86000000;
			}
			break;
		    case SPECTRUM:
			printf("Spectrum");
                        cl_maxpixelclock = 90000000;
			break;
		    case PICCOLO:
			if (cl_64bit == 1) {
				printf("Piccolo SD64");
				/* 110MHz will be supported if we
				 * have a palette doubling mode.
				 */
				cl_maxpixelclock = 90000000;
			} else {
				printf("Piccolo");
				cl_maxpixelclock = 90000000;
			}
			break;
		}
		printf(" being used\n");
#ifdef CL_OVERCLOCK
                cl_maxpixelclock = 115000000;
#endif
	} else {