📄 fg.c
字号:
fgstop(tp, flag) register struct tty *tp;{ register int s;/* * Block interrupts while modifying the state. */ s = spl6(); if (tp->t_state & TS_BUSY) if ((tp->t_state&TS_TTSTOP)==0) tp->t_state |= TS_FLUSH; else tp->t_state &= ~TS_BUSY; splx(s);}/****************************************************************** ** ** ** Routine to output a character to the screen ** ** ** ******************************************************************/fg_blitc( c )register u_char c;{ register int i; register u_short *font_row; register u_long *pixel; register u_long *pixel1; register u_long mask; register int shift; c &= 0xff; switch ( c ) { case '\t': /* tab */ for (i = 8 - ((cursor.x >> CHAR_WIDTH) & 0x07); i > 0; --i) { fg_blitc( ' ' ); } return(0); case '\r': /* return */ fg_pos_cursor(cursor.x, cursor.y); cursor.x = 0;/* if (!(fgflags.inuse & GRAPHIC_DEV)) ioctl(fd, FG_POSCURSOR, &cursor);*/ return(0); case '\b': /* backspace */ if (cursor.x > 0) { fg_pos_cursor(cursor.x, cursor.y); cursor.x -= CHAR_WIDTH; fg_pos_cursor(cursor.x, cursor.y);/* if (!(sgflags.inuse & GRAPHIC_DEV)) ioctl(fd, FG_POSCURSOR, &cursor);*/ } return(0); case '\n': /* linefeed */ if ((cursor.y += CHAR_HEIGHT) > (MAX_CUR_Y - CHAR_HEIGHT)) { if (fg_mouseon == 1) cursor.y = 0; else { cursor.y -= CHAR_HEIGHT; fg_scroll_up(); } }/* if (!(sgflags.inuse & GRAPHIC_DEV)) ioctl(fd, FG_POSCURSOR, &cursor);*/ fg_pos_cursor(cursor.x, cursor.y); return(0); default: /*---------------------------------------------------------- * Weed out unprintable characters. Printable characters fall * between space (0x20) and tilde (0x7E). For 8-bit support * another range of printable characters are those between * 0xA1 and 0xFD. */ if ((c < ' ') || (c > 0xFD) || (c < 0xA1 && c > '~')) return(0); } i = c - ' '; if (i < 0 || i > 221) i = 0; else { if (c > '~') c -= 34; /* These are to skip the (32) 8-bit control chars. as well as DEL and 0xA0 which aren't printable */ i *= CHAR_HEIGHT; }/* * Initialize character cell with background pixel value */ font_row = (u_short *)(fg_font + i); pixel = (u_long *)(fgmap.i_vram) + cursor.x + cursor.y*2048; for (i = 0, pixel1 = pixel; i < CHAR_WIDTH; i++, pixel1++ ) *pixel1 = fg_bgpixel; for (i = 1, pixel1 = pixel + 2048; i < CHAR_HEIGHT; i++, pixel1+=2048 ) bcopy ((char *)(pixel), (char *)(pixel1), CHAR_WIDTH*4);/* * Set respective bits in character cell with foreground pixel value */ for (i = 0; i < CHAR_HEIGHT; i++, font_row++, pixel+=2048 ) { if (*font_row != 0) { shift = ffs(*font_row) - 1; pixel1 = pixel + shift; *pixel1 = fg_fgpixel; for (shift++; shift < CHAR_WIDTH; shift++) { mask = 1 << shift; if ((mask & *font_row) != 0) { pixel1 = pixel + shift; *pixel1 = fg_fgpixel; } } } }/* * update console cursor coordinates */ cursor.x += CHAR_WIDTH;/* if (!(sgflags.inuse & GRAPHIC_DEV)) ioctl(fd, FG_POSCURSOR, &cursor);*/ if (cursor.x > (MAX_CUR_X - CHAR_WIDTH)) { fg_blitc( '\r' ); fg_blitc( '\n' ); } fg_pos_cursor(cursor.x, cursor.y);}/****************************************************************** ** ** ** Routine to scroll up the screen one character height ** ** ** ******************************************************************/fg_scroll_up(){ register struct dchip *fgdchip; register struct achip *fgachip; int y_value; int temp; int i; u_long save_reg[4]; fgdchip = (struct dchip *) fgmap.dchip; fgachip = (struct achip *) fgmap.achip; fg_wait_done(); y_value = CHAR_HEIGHT; fgachip->achip_x_a = Fixed(0); fgachip->achip_x_size = Width; fgachip->achip_y_size = 1 ; fgachip->achip_x_i = 0; fgachip->achip_y_i = 0; fgachip->achip_x_offset_dst = 0; fgachip->achip_y_offset_dst = -CHAR_HEIGHT; fgachip->achip_x_offset_src= 0; fgachip->achip_y_offset_src = 0; fgachip->achip_width_src = 0; fgachip->achip_width_dst = 0; fgachip->achip_offset_src = 0; fgachip->achip_offset_dst = 0; fgdchip->dchip_control_src = 0x0001; fgdchip->dchip_logical_z_0 = -1; fgdchip->dchip_logical_z_1 = -1; fgdchip->dchip_logical_z_2 = 0; fgdchip->dchip_logical_z_3 = 0; for( i = 0; i < (Height - CHAR_HEIGHT); i++) { fgachip->achip_y_a = Fixed(y_value); fgachip->achip_csr = 0; fgachip->achip_counter = 1; fg_wait_done(); y_value++; }/* * Save logical registers *//* save_reg[0] = fgdchip->dchip_logical_z_0; save_reg[1] = fgdchip->dchip_logical_z_1; save_reg[2] = fgdchip->dchip_logical_z_2; save_reg[3] = fgdchip->dchip_logical_z_3;*//* Blank the last line */ save_logic[0] = 1; save_logic[1] = 1; save_logic[2] = 0; save_logic[3] = 0; fgdchip->dchip_logical_z_0 = 0; fgdchip->dchip_logical_z_1 = 0; fgdchip->dchip_logical_z_2 = 0; fgdchip->dchip_logical_z_3 = 0; temp = cursor.y + CHAR_HEIGHT; fg_wait_done(); /* Finish the current operation */ fgachip->achip_y_a = Fixed(temp); fgachip->achip_y_size = CHAR_HEIGHT; fgachip->achip_csr = 0; fgachip->achip_counter = 1; fg_wait_done(); /* Finish the current operation *//* * Restore logical registers */ fgdchip->dchip_logical_z_0 = save_logic[0]; fgdchip->dchip_logical_z_1 = save_logic[1]; fgdchip->dchip_logical_z_2 = save_logic[2]; fgdchip->dchip_logical_z_3 = save_logic[3];}/******************************************************************** ** ** ** Routine to direct kernel console output to display destination ** ** ** ********************************************************************/fgputc( c )register char c;{ register struct tty *tp0; register struct tchip *fgtchip;/* * This routine may be called in physical mode by the dump code * so we change the driver into physical mode. * One way change, can't go back to virtual mode. */ if( (mfpr(MAPEN) & 1) == 0 ) { fg_physmode = 1; fg_mouseon = 0; fgmap.boot_rom = (char *) FG_PHYS_BOOT_ROM; fgmap.weitek_code = fgmap.boot_rom + WEITEK; fgmap.dram = fgmap.boot_rom + DRAM; fgmap.achip = fgmap.boot_rom + ACHIP; fgmap.dchip = fgmap.boot_rom + DCHIP; fgmap.tchip = fgmap.boot_rom + TCHIP; fgmap.fbic = fgmap.boot_rom + FBIC; fgmap.i_vram = fgmap.boot_rom + I_VRAM; fgmap.x_vram = fgmap.boot_rom + X_VRAM; fgmap.i_pattern_mem = fgmap.boot_rom + I_PATTERN; fgmap.x_pattern_mem = fgmap.boot_rom + X_PATTERN; fgmap.console = fgmap.boot_rom + FG_CONSOLE; fgmap.scb = fgmap.boot_rom + FG_SCB; fgtchip = (struct tchip *) fgmap.tchip; fgtchip->tchip_csr |= TCHIP_UNBLANK; /* turn the video on */ fg_blitc(c & 0xff); return; }/* * direct kernel output char to the proper place */ tp0 = &sm_tty; if (fgflags.kernel_loop != 0 && tp0->t_state & TS_ISOPEN) { (*linesw[tp0->t_line].l_rint)(c, tp0); } else { fg_blitc(c & 0xff); }}/****************************************************************** ** ** ** Routine to get a character from LK201. ** ** ** ******************************************************************/fggetc(){ int c; u_short data;/* * Get a character from the keyboard, */loop: data = fcgetc();/* * Check for various keyboard errors */ if( data == LK_POWER_ERROR || data == LK_KDOWN_ERROR || data == LK_INPUT_ERROR || data == LK_OUTPUT_ERROR) { mprintf(" fg0: Keyboard error, code = %x\n",data); return(0); } if( data < LK_LOWEST ) return(0);/* * See if its a state change key */ switch ( data ) { case LOCK: fg_keyboard.lock ^= 0xffff; /* toggle */ if( fg_keyboard.lock ) fg_key_out( LK_LED_ENABLE ); else fg_key_out( LK_LED_DISABLE ); fg_key_out( LED_3 ); goto loop; case SHIFT: fg_keyboard.shift ^= 0xffff; goto loop; case CNTRL: fg_keyboard.cntrl ^= 0xffff; goto loop; case ALLUP: fg_keyboard.cntrl = fg_keyboard.shift = 0; goto loop; case REPEAT: c = fg_keyboard.last; break; default:/* * Test for control characters. If set, see if the character * is elligible to become a control character. */ if( fg_keyboard.cntrl ) { c = q_key[ data ]; if( c >= ' ' && c <= '~' ) c &= 0x1f; } else if( fg_keyboard.lock || fg_keyboard.shift ) c = q_shift_key[ data ]; else c = q_key[ data ]; break; } fg_keyboard.last = c;/* * Check for special function keys */ if( c & 0x80 ) return (0); else return (c);}/********************************************************************* ** ** ** Routine to initialize virtual console. This routine sets up the ** ** graphic device so that it can be used as the system console. It ** ** is invoked before autoconfig and has to do everything necessary ** ** to allow the device to serve as the system console. ** ** ** *********************************************************************/extern (*vs_gdopen)();extern (*vs_gdclose)();extern (*vs_gdread)();extern (*vs_gdwrite)();extern (*vs_gdselect)();extern (*vs_gdkint)();extern (*vs_gdioctl)();extern (*vs_gdstop)();fgcons_init(){ register struct fc_regs *fcaddr = (struct fc_regs *)ffcons; register struct nb5_regs *fgaddr = (struct nb5_regs *)fgmem; register struct achip *fgachip; register struct dchip *fgdchip; register struct tchip *fgtchip; register fg_commarea_desc *fgdescr;/* * Set the line parameters on SLU line 0 for * the LK201 keyboard: 4800 BPS, 8-bit char, 1 stop bit, no parity. */ fcaddr->fclpr = (SER_RXENAB | SER_KBD | SER_SPEED | SER_CHARW);/* * Set the hardware register for save routine. The save routine will be * called as the console program enters/exits its console display * (halting the cpu). * * NOTE: SYSTEM SCRATCH RAM IS MAPPED IN SS.C */ ctsi->ct_save_p = (char *) svtophy((int *)fg_save)+2; ctsi->ct_restore_p = (char *) svtophy((int *)fg_restore)+2; fg_phys_fcaddr = (struct fc_regs *) svtophy(fcaddr);/* * Load fgmap structure with the virtual addresses of the Firefox. */ fgbase = (caddr_t) ((u_long)fgaddr); fgmap.boot_rom = fgbase; fgmap.weitek_code = fgbase + WEITEK; fgmap.dram = fgbase + DRAM; fgmap.achip = fgbase + ACHIP; fgmap.dchip = fgbase + DCHIP; fgmap.tchip = fgba
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -