コード例 #1
0
ファイル: fb.c プロジェクト: repos-holder/openbsd-patches
void
fbwscons_init(struct sunfb *sf, int flags)
{
	struct rasops_info *ri = &sf->sf_ro;
	int cols, rows;

	/* ri_hw and ri_bits must have already been setup by caller */
	ri->ri_flg = RI_CENTER | RI_FULLCLEAR | flags;
	ri->ri_depth = sf->sf_depth;
	ri->ri_stride = sf->sf_linebytes;
	ri->ri_width = sf->sf_width;
	ri->ri_height = sf->sf_height;

	rows = a2int(getpropstring(optionsnode, "screen-#rows"), 34);
	cols = a2int(getpropstring(optionsnode, "screen-#columns"), 80);

	rasops_init(ri, rows, cols);

	if (sf->sf_depth == 8) {
		/*
		 * If we are running with an indexed palette, compensate
		 * the swap of black and white through ri_devcmap.
		 */
		ri->ri_devcmap[WSCOL_SUN_BLACK] = 0;
		ri->ri_devcmap[WSCOL_SUN_WHITE] = 0xffffffff;
	} else if (sf->sf_depth > 8) {
		/*
		 * If we are running on a direct color frame buffer,
		 * make the ``normal'' white the same as the highlighted
		 * white.
		 */
		ri->ri_devcmap[WSCOL_WHITE] = ri->ri_devcmap[WSCOL_WHITE + 8];
	}
}
コード例 #2
0
ファイル: fb.c プロジェクト: avsm/openbsd-xen-sys
void
fbwscons_init(struct sunfb *sf, int flags)
{
	struct rasops_info *ri = &sf->sf_ro;
	int cols, rows;

	/* ri_hw and ri_bits must have already been setup by caller */
	ri->ri_flg = RI_CENTER | RI_FULLCLEAR | flags;
	ri->ri_depth = sf->sf_depth;
	ri->ri_stride = sf->sf_linebytes;
	ri->ri_width = sf->sf_width;
	ri->ri_height = sf->sf_height;

#if defined(SUN4C) || defined(SUN4M)
	if (CPU_ISSUN4COR4M) {
		rows = a2int(getpropstring(optionsnode, "screen-#rows"), 34);
		cols = a2int(getpropstring(optionsnode, "screen-#columns"), 80);
	}
#endif
#if defined(SUN4)
	if (CPU_ISSUN4) {
		struct eeprom *ep = (struct eeprom *)eeprom_va;

		if (ep != NULL) {
			rows = (u_short)ep->eeTtyRows;
			cols = (u_short)ep->eeTtyCols;
			/* deal with broken nvram contents... */
			if (rows <= 0)
				rows = 34;
			if (cols <= 0)
				cols = 80;
		} else {
			rows = 34;
			cols = 80;
		}
	}
#endif

	rasops_init(ri, rows, cols);

	if (sf->sf_depth == 8) {
		/*
		 * If we are running with an indexed palette, compensate
		 * the swap of black and white through ri_devcmap.
		 */
		ri->ri_devcmap[WSCOL_SUN_BLACK] = 0;
		ri->ri_devcmap[WSCOL_SUN_WHITE] = 0xffffffff;
	} else if (sf->sf_depth > 8) {
		/*
		 * If we are running on a direct color frame buffer,
		 * make the ``normal'' white the same as the hilighted
		 * white.
		 */
		ri->ri_devcmap[WSCOL_WHITE] = ri->ri_devcmap[WSCOL_WHITE + 8];
	}
}
コード例 #3
0
ファイル: inst.c プロジェクト: ryo/netbsd-src
/*
 * Copy a miniroot image from an NFS server or tape to the `b' partition
 * of the specified disk.  Note, this assumes 512 byte sectors.
 */
void
miniroot(void)
{
    int sfd, dfd, i, nblks;
    char diskname[64], minirootname[128];
    char block[DEV_BSIZE];
    char tapename[64];
    int fileno, ignoreshread, eof, len;
    struct stat st;
    size_t xfersize;
    struct open_file *disk_ofp;
    extern struct open_file files[];

    /* Error message printed by opendisk() */
    if (opendisk("Disk for miniroot?", diskname, sizeof(diskname),
                 'b', &dfd))
        return;

    disk_ofp = &files[dfd];

getsource:
    printf("Source? (N)FS, (t)ape, (d)one > ");
    memset(line, 0, sizeof(line));
    kgets(line, sizeof(line));
    if (line[0] == '\0')
        goto getsource;

    switch (line[0]) {
    case 'n':
    case 'N':
name_of_nfs_miniroot:
        printf("Name of miniroot file? ");
        memset(line, 0, sizeof(line));
        memset(minirootname, 0, sizeof(minirootname));
        kgets(line, sizeof(line));
        if (line[0] == '\0')
            goto name_of_nfs_miniroot;
        (void)strcat(minirootname, "le0a:");
        (void)strcat(minirootname, line);
        if ((sfd = open(minirootname, 0)) < 0) {
            printf("can't open %s\n", line);
            return;
        }

        /*
         * Find out how big the miniroot is... we can't
         * check for size because it may be compressed.
         */
        ignoreshread = 1;
        if (fstat(sfd, &st) < 0) {
            printf("can't stat %s\n", line);
            goto done;
        }
        nblks = (int)(st.st_size / sizeof(block));

        printf("Copying miniroot from %s to %s...", line,
               diskname);
        break;

    case 't':
    case 'T':
name_of_tape_miniroot:
        printf("Which tape device? ");
        memset(line, 0, sizeof(line));
        memset(minirootname, 0, sizeof(minirootname));
        memset(tapename, 0, sizeof(tapename));
        kgets(line, sizeof(line));
        if (line[0] == '\0')
            goto name_of_tape_miniroot;
        strcat(minirootname, line);
        strcat(tapename, line);

        printf("File number (first == 1)? ");
        memset(line, 0, sizeof(line));
        kgets(line, sizeof(line));
        fileno = a2int(line);
        if (fileno < 1 || fileno > 8) {
            printf("Invalid file number: %s\n", line);
            goto getsource;
        }
        for (i = 0; i < sizeof(minirootname); ++i) {
            if (minirootname[i] == '\0')
                break;
        }
        if (i == sizeof(minirootname) ||
                (sizeof(minirootname) - i) < 8) {
            printf("Invalid device name: %s\n", tapename);
            goto getsource;
        }
        minirootname[i++] = 'a' + (fileno - 1);
        minirootname[i++] = ':';
        strcat(minirootname, "XXX");	/* lameness in open() */

        ignoreshread = 0;
        printf("Copy how many %d byte blocks? ", DEV_BSIZE);
        memset(line, 0, sizeof(line));
        kgets(line, sizeof(line));
        nblks = a2int(line);
        if (nblks < 0) {
            printf("Invalid block count: %s\n", line);
            goto getsource;
        } else if (nblks == 0) {
            printf("Zero blocks?  Ok, aborting.\n");
            return;
        }

        if ((sfd = open(minirootname, 0)) < 0) {
            printf("can't open %s file %c\n", tapename, fileno);
            return;
        }

        printf("Copying %s file %d to %s...", tapename, fileno,
               diskname);
        break;

    case 'd':
    case 'D':
        return;

    default:
        printf("Unknown source: %s\n", line);
        goto getsource;
    }

    /*
     * Copy loop...
     * This is fairly slow... if someone wants to speed it
     * up, they'll get no complaints from me.
     */
    for (i = 0, eof = 0; i < nblks || ignoreshread == 0; i++) {
        if ((len = read(sfd, block, sizeof(block))) < 0) {
            printf("Read error, errno = %d\n", errno);
            goto out;
        }

        /*
         * Check for end-of-file.
         */
        if (len == 0)
            goto done;
        else if (len < sizeof(block))
            eof = 1;

        if ((*disk_ofp->f_dev->dv_strategy)(disk_ofp->f_devdata,
                                            F_WRITE, i, len, block, &xfersize) || xfersize != len) {
            printf("Bad write at block %d, errno = %d\n",
                   i, errno);
            goto out;
        }

        if (eof)
            goto done;
    }
done:
    printf("done\n");

    printf("Successfully copied miniroot image.\n");

out:
    close(sfd);
    close(dfd);
}
コード例 #4
0
ファイル: fb.c プロジェクト: ajinkya93/OpenBSD
void
fbwscons_init(struct sunfb *sf, int flags, int isconsole)
{
	struct rasops_info *ri = &sf->sf_ro;
	int cols, rows, fw, fh, wt, wl;

	/* ri_hw and ri_bits must have already been setup by caller */
	ri->ri_flg = RI_FULLCLEAR | flags;
	ri->ri_depth = sf->sf_depth;
	ri->ri_stride = sf->sf_linebytes;
	ri->ri_width = sf->sf_width;
	ri->ri_height = sf->sf_height;

	rows = a2int(getpropstring(optionsnode, "screen-#rows"), 34);
	cols = a2int(getpropstring(optionsnode, "screen-#columns"), 80);

	/*
	 * If the framebuffer width is under 960 pixels, rasops will
	 * switch from the 12x22 font to the more adequate 8x16 font
	 * here.
	 * If we are the console device, we need to adjust two things:
	 * - the display row should be overrided from the current PROM
	 *   metrics, since it will not match the PROM reality anymore.
	 * - the screen needs to be cleared.
	 *
	 * However, to accommodate laptops with specific small fonts,
	 * it is necessary to compare the resolution with the actual
	 * font metrics.
	 */

	if (isconsole) {
		if (fb_get_console_metrics(&fw, &fh, &wt, &wl) != 0) {
			/*
			 * Assume a 12x22 prom font and a centered
			 * 80x34 console window.
			 */
			fw = 12; fh = 22;
			wt = wl = 0;
		} else {
			/*
			 * Make sure window-top and window-left
			 * values are consistent with the font metrics.
			 */
			if (wt <= 0 || wt > sf->sf_height - rows * fh ||
			    wl <= 0 || wl > sf->sf_width - cols * fw)
				wt = wl = 0;
		}
		if (wt == 0 /* || wl == 0 */) {
			ri->ri_flg |= RI_CENTER;

			/*
			 * Since the console window might not be
			 * centered (e.g. on a 1280x1024 vigra
			 * VS-12 frame buffer), have rasops
			 * clear the margins even if the screen is
			 * not cleared.
			 */
			ri->ri_flg |= RI_CLEARMARGINS;
		}

		if (ri->ri_wsfcookie != 0) {
			/* driver handles font issues. do nothing. */
		} else {
			/*
			 * If the PROM uses a different font than the
			 * one we are expecting it to use, or if the
			 * display is shorter than 960 pixels wide,
			 * we'll force a screen clear.
			 */
			if (fw != 12 || sf->sf_width < 12 * 80)
				ri->ri_flg |= RI_CLEAR | RI_CENTER;
		}
	} else {
		ri->ri_flg |= RI_CLEAR | RI_CENTER;
	}

	/* ifb(4) doesn't set ri_bits at the moment */
	if (ri->ri_bits == NULL)
		ri->ri_flg &= ~(RI_CLEAR | RI_CLEARMARGINS);

	rasops_init(ri, rows, cols);

	/*
	 * If this is the console display and there is no font change,
	 * adjust our terminal window to the position of the PROM
	 * window - in case it is not exactly centered.
	 */
	if ((ri->ri_flg & RI_CENTER) == 0) {
		/* code above made sure wt and wl are initialized */
		ri->ri_bits += wt * ri->ri_stride;
		if (ri->ri_depth >= 8)	/* for 15bpp to compute ok */
			ri->ri_bits += wl * ri->ri_pelbytes;
		else
			ri->ri_bits += (wl * ri->ri_depth) >> 3;

		ri->ri_xorigin = wl;
		ri->ri_yorigin = wt;
	}