📄 gx.c
字号:
*/ (*slu.mouse_init)(); /* * Perform a self-test */ (*slu.mouse_putc)(SELF_TEST); /* * Wait for the first byte of the self-test report */ id_byte1 = (*slu.mouse_getc)(); if (id_byte1 < 0) { mprintf("\ngx: Timeout on 1st byte of self-test report\n"); goto OUT; } /* * Wait for the hardware ID (the second byte returned by the * self-test report) */ id_byte2 = (*slu.mouse_getc)(); if (id_byte2 < 0) { mprintf("\ngx: Timeout on 2nd byte of self-test report\n"); goto OUT; } /* * Wait for the third byte returned by the self-test report) */ id_byte3 = (*slu.mouse_getc)(); if (id_byte3 < 0) { mprintf("\ngx: Timeout on 3rd byte of self-test report\n"); goto OUT; } /* * Wait for the fourth byte returned by the self-test report) */ id_byte4 = (*slu.mouse_getc)(); if (id_byte4 < 0) { mprintf("\ngx: Timeout on 4th byte of self-test report\n"); goto OUT; } /* * Set the operating mode * * We set the mode for both mouse and the tablet to * "Incremental stream mode". */ if ((id_byte2 & 0x0f) == MOUSE_ID) pointer_id = MOUSE_ID; else pointer_id = TABLET_ID; (*slu.mouse_putc)(INCREMENTAL); OUT: GX_DEBUG(GX_BLAB, gx_puts(")\n"); ); return(0);}/* end gx_init_mouse *//****************************************************************** ** gx_load_cursor(): ** ** Routine to load the cursor 64x64 sprite pattern ** ** ** ******************************************************************/#define BT459_CUREND (BT459_CUR_RAM+(0x010*BT459_CURH))int total_VDAC_cursor_errors = 0;gx_load_cursor(){ register int i, x, y, s; volatile int *vdac_data = &_gx_vdac->data; int current_round = 0; int got_it_right = 0; GX_DEBUG(GX_SILENT, if (GX_CURH != BT459_CURH || GX_CURW != BT459_CURW) panic("gx_load_cursor"); ); GX_DEBUG(GX_BLAB, gx_printf("gx_load_cursor: 0x%x msk=0x%x\n", _gx_vdac, gx_planemask); ); Rewrite_Cursor: if (current_round >= BT459_MAXERR) goto Done_Cursor; IPLTTY(s); /* turn cursor off while we load the cursor RAM to reduce flicker */ BT459_SETADDR(_gx_vdac, BT459_CUR_CMD); *vdac_data = 0x0; WBFLUSH(); BT459_SETADDR(_gx_vdac, GX_CURBEG); for (y = i = 0; y < BT459_CURH; y++) { for (x = 0; x < (BT459_CURW/4); x++, i++) { *vdac_data = _DUPBYTE0(gx_cursor[i]); WBFLUSH(); } } splx(s); current_round++; IPLTTY(s); BT459_SETADDR(_gx_vdac, GX_CURBEG); for (y = i = 0; y < BT459_CURH; y++) { for (x = 0; x < (BT459_CURW/4); x++, i++) { if (VDAC_RDAT != (_DUPBYTE0(gx_cursor[i]) & gx_planemask)) { splx(s); goto Rewrite_Cursor; } } } splx(s); got_it_right = 1; Done_Cursor: total_VDAC_cursor_errors += current_round; GX_DEBUG(GX_GAB, gx_printf("gx_load_cursor: %d retries\n", current_round); ); GX_DEBUG(GX_TERSE, gx_check_vdac(0); ); if (!got_it_right) { printf("gx_load_cursor: %d retries exceeded\n", current_round); return (-1); } /* turn cursor back on */ BT459_SETADDR(_gx_vdac, BT459_CUR_CMD); *vdac_data = 0xC0C0C0; WBFLUSH(); return (0);}/* end gx_load_cursor() *//************************************************************************* * Console text cursor pattern. Put cursor's <x,y> at northwest corner. * *************************************************************************/gx_load_defcursor(){ static int toggle = 1; GX_DEBUG(GX_BLAB, gx_puts("gx_load_defcursor()\n"); ); bzero(gx_cursor, GX_CURSORBYTES); /* * Assume at least 16x16 cursor */ if (toggle) { register u_char *bits; bits = gx_cursor; *bits++ = 0x00; *bits++ = 0xff; *bits = 0x00; bits = gx_cursor + (GX_CURW/4); *bits++ = 0x03; *bits++ = 0xff; *bits = 0xc0; bits = gx_cursor + (2*(GX_CURW/4)); *bits++ = 0x0f; *bits++ = 0xff; *bits = 0xf0; bits = gx_cursor + (3*(GX_CURW/4)); *bits++ = 0x3f; *bits++ = 0xff; *bits = 0xfc; } else { register int i; register u_char *bits = gx_cursor; for (i = 0; i < (4*(GX_CURW/4)); i += (GX_CURW/4)) { bits[i+0] = 0x3f; bits[i+1] = 0xff; bits[i+2] = 0xfc; } } toggle ^= 0x1; gx_load_cursor();}/* end gx_load_defcursor */gx_load_ccolor(){ register int s; register volatile int *vdac_data = &_gx_vdac->data; int retries = 3; GX_DEBUG(GX_BLAB, gx_printf("gx_load_ccolor(fg 0x%x bg 0x%x)\n", gxp->curs_fg, gxp->curs_bg); ); IPLTTY(s); BT459_SETADDR(_gx_vdac, BT459_CUR_COLOR2); *vdac_data = _DUPBYTE2(gxp->curs_bg); WBFLUSH(); *vdac_data = _DUPBYTE1(gxp->curs_bg); WBFLUSH(); *vdac_data = _DUPBYTE0(gxp->curs_bg); WBFLUSH(); *vdac_data = _DUPBYTE2(gxp->curs_fg); WBFLUSH(); *vdac_data = _DUPBYTE1(gxp->curs_fg); WBFLUSH(); *vdac_data = _DUPBYTE0(gxp->curs_fg); WBFLUSH(); splx(s);# ifdef GX_MULTIOPEN for (s = 1; s < GX_MAX_INFOS; s++) { gx_infos[s].info.curs_bg = gxp->curs_bg; gx_infos[s].info.curs_fg = gxp->curs_fg; }# endif GX_DEBUG(GX_TERSE, gx_check_vdac(0); ); }/* end gx_load_ccolor */gx_init_colormap(){ register int i; GX_DEBUG(GX_BLAB, gx_puts("gx_init_colormap()\n"); ); gx_colormap[0] = 0x0; for (i = 1; i < 256 ; i++) gx_colormap[i] = 0xffffff; gxp->curs_fg = gxp->curs_bg = _TEXT_CFG; gxp->cmap_index = 000; gxp->cmap_count = 256; gxp->flags |= (GX_F_NEW_CMAP| GX_F_VIDEO_ON); gx_load_colormap(); /* load color palette */ gx_load_ccolor(); /* load cursor color regs */}/* end gx_init_colormap */gx_load_colormap(){ int white = 0x1; int black = 0x0; int lval = 0xffffff; int hval = 0x000000; GX_DEBUG(GX_GAB, if (gxp->flags & GX_F_VIDEO_ON) { gx_printf("gx_load_colormap(ent %d cnt %d)\n", gxp->cmap_index, gxp->cmap_count); } else { gx_printf("gx_load_colormap(screen saver on)\n"); } ); if ((gxp->flags & (GX_F_NEW_CMAP|GX_F_VIDEO_ON)) == (GX_F_NEW_CMAP|GX_F_VIDEO_ON)) { register int s; register int entry, count; register volatile int *vdac_cmap = &_gx_vdac->cmap; entry = gxp->cmap_index; count = gxp->cmap_count; IPLTTY(s); BT459_SETADDR(_gx_vdac, BT459_PIX_COLOR + entry); for ( ; count > 0; count--, entry++) { *vdac_cmap = _DUPBYTE2(gx_colormap[entry]); WBFLUSH(); *vdac_cmap = _DUPBYTE1(gx_colormap[entry]); WBFLUSH(); *vdac_cmap = _DUPBYTE0(gx_colormap[entry]); WBFLUSH(); } gxp->flags &= ~GX_F_NEW_CMAP; splx(s); /* * Now select the console text foreground/background pixels * based on the new colormap... */ for (entry = 0; entry < 256; entry++) { if (gx_colormap[entry] > hval) { hval = gx_colormap[entry]; white = entry; } if (gx_colormap[entry] < lval) { lval = gx_colormap[entry]; black = entry; } } gx_textfg = _DUPBYTE0(white); gx_textbg = _DUPBYTE0(black); }}/* end gx_load_colormap */gx_config(qp) gxInfo *qp;{ int modtype; GX_DEBUG(GX_GAB, gx_printf("gx_config: qp=0x%x\n", svtophy(qp)); ); bzero(qp, sizeof(gxInfo)); /* * Screen parameters for the <XXX> monitors. These determine the max * size in pixel and character units for the display and cursor positions. * Notice that the mouse defaults to original square algorithm, but X * will change to its defaults once implemented. * Local variables for the driver. Initialized for <XXX> screen * so that it can be used during the boot process. */ qp->max_row = _TEXT_ROWS+1; qp->max_col = _TEXT_COLS; qp->max_x = BT459_MAXX+1; qp->max_y = BT459_MAXY+1; qp->max_cur_x = GX_CURMAXX; qp->max_cur_y = GX_CURMAXY; qp->min_cur_x = GX_CURMINX; qp->min_cur_y = GX_CURMINY; qp->version = 11; qp->mthreshold = 4; qp->mscale = 2; qp->qe.eSize = PMMAXEVQ; qp->qe.tcSize = MOTION_BUFFER_SIZE; qp->flags = GX_F_VIDEO_ON | 0xff; qp->qe.events = gx_events; qp->qe.tcs = gx_tcs; /*qp->curs_bits = gx_cursor;*/ /*qp->colormap = gx_colormap;*/ qp->gram = NULL; modtype = gx_decode_option(qp); (*_gx_config)(qp, modtype); GX_DEBUG(GX_YAK, gx_printf("gx_config: w/h/poll=%d/%d/0x%x\n", qp->stamp_width, qp->stamp_height, qp->stic_dma_rb); ); qp->qe.timestamp_ms = TOY;}/****************************************************************** ** ** ** Routine to do the board specific setup. ** ** ** ******************************************************************/gx_setup(){ register int i, j; /* * Set the line parameters on SLU line for * the LK201 keyboard: 4800 BPS, 8-bit char, 1 stop bit, no parity. */ (*slu.kbd_init)(); GX_DEBUG(GX_BLAB, gx_puts("gx_setup(beg)\n"); ); for (i = 0; i < GX_MAX_INFOS; i++) { gx_infos[i].pid = -1; gx_infos[i].shmat = 0; gx_config(&gx_infos[i].info); } gx_init(); gx_clearbitmap(); /* * Initialize the mouse */ gx_init_mouse(); v_consputc = gxputc; v_consgetc = gxgetc; vs_gdopen = gxopen; vs_gdclose = gxclose; vs_gdselect = gxselect; vs_gdioctl = gxioctl; vs_gdkint = gxkint; vs_gdstop = gxstop; GX_DEBUG(GX_BLAB, gx_puts("gx_setup(end)\n"); );}/* end gx_setup */gx_init_stic(){ int modtype, xconfig, yconfig, config; GX_DEBUG(GX_GAB, gx_printf("gx_init_stic: stic=0x%x\n", _gx_stic); ); /* * initialize STIC registers (bmk) */ _gx_stic->sticsr = 0x00000030; /* sticcsr */ wbflush(); DELAY(4000); /* 4mS */ _gx_stic->sticsr = 0x00000000; /* sticcsr */ _gx_stic->buscsr = 0xffffffff; /* buscsr */ DELAY(20000); /* long time... */ gx_init_vdac(); /* * Initialize Stamp config register */ modtype = _gx_stic->modcl; xconfig = (modtype & 0x800) >> 11; yconfig = (modtype & 0x600) >> 9; config = (yconfig << 1) | xconfig; /* stamp0 config */ *(int *)(_gx_stamp+0x000b0) = config; *(int *)(_gx_stamp+0x000b4) = 0x0; if (yconfig > 0) { /* stamp1 config */ *(int *)(_gx_stamp+0x100b0) = 0x8|config; *(int *)(_gx_stamp+0x100b4) = 0x0; if (yconfig > 1) { /* stamp 2 & 3 config */ } } /* * Initialize STIC video registers */ _gx_stic->vblank = (1024 << 16) | 1063; /* vblank */ _gx_stic->vsync = (1027 << 16) | 1030; /* vsync */ _gx_stic->hblank = (255 << 16) | 340; /* hblank */ _gx_stic->hsync2 = 245; /* hsync2 */ _gx_stic->hsync = (261 << 16) | 293; /* hsync */ _gx_stic->ipdvint = STIC_INT_CLR; /* ipdvint */ _gx_stic->sticsr = 0x00000008; /* sticcsr */ wbflush();}/* end gx_init_stic */static int_allzero(ip, msk, cnt) register u_int *ip; register u_int msk, cnt;{ int is0 = 1; GX_DEBUG(GX_YAK, gx_printf("_allzero: 0x%x msk 0x%x cnt %d\n", ip, msk, cnt); ); for ( ; cnt--; ip++) { if (*ip & msk) { is0 = 0; GX_DEBUG(GX_TERSE, gx_printf("_allzero: @ 0x%x = 0x%x\n", ip, *ip); ); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -