📄 newport_con.c
字号:
npregs->set.xyendi = ((xpos + 7) << 16); newport_wait(); /* Go, baby, go... */ RENDER(npregs, p);}static void newport_putcs(struct vc_data *vc, const unsigned short *s, int count, int ypos, int xpos){ int i; int charattr; unsigned char *p; charattr = (scr_readw(s) >> 8) & 0xff; xpos <<= 3; ypos <<= 4; if (!logo_active) /* Clear the area behing the string */ newport_render_background(xpos, ypos, xpos + ((count - 1) << 3), ypos, (charattr & 0xf0) >> 4); newport_wait(); /* Set the color and drawing mode. */ npregs->set.colori = charattr & 0xf; npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB | NPORT_DMODE0_L32); for (i = 0; i < count; i++, xpos += 8) { p = &font_data[vc->vc_num][(scr_readw(s++) & 0xff) << 4]; newport_wait(); /* Set coordinates for bitmap operation. */ npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff); npregs->set.xyendi = ((xpos + 7) << 16); /* Go, baby, go... */ RENDER(npregs, p); }}static void newport_cursor(struct vc_data *vc, int mode){ unsigned short treg; int xcurs, ycurs; switch (mode) { case CM_ERASE: treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg & ~(VC2_CTRL_ECDISP))); break; case CM_MOVE: case CM_DRAW: treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg | VC2_CTRL_ECDISP)); xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2; ycurs = ((xcurs / vc->vc_cols) << 4) + 31; xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction; newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs); newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs); }}static int newport_switch(struct vc_data *vc){ static int logo_drawn = 0; topscan = 0; npregs->cset.topscan = 0x3ff; if (!logo_drawn) { newport_show_logo(); logo_drawn = 1; logo_active = 1; } return 1;}static int newport_blank(struct vc_data *c, int blank){ unsigned short treg; if (blank == 0) { /* unblank console */ treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg | VC2_CTRL_EDISP)); } else { /* blank console */ treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg & ~(VC2_CTRL_EDISP))); } return 1;}static int newport_set_font(int unit, struct console_font_op *op){ int w = op->width; int h = op->height; int size = h * op->charcount; int i; unsigned char *new_data, *data = op->data, *p; /* ladis: when I grow up, there will be a day... and more sizes will * be supported ;-) */ if ((w != 8) || (h != 16) || (op->charcount != 256 && op->charcount != 512)) return -EINVAL; if (!(new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER))) return -ENOMEM; new_data += FONT_EXTRA_WORDS * sizeof(int); FNTSIZE(new_data) = size; FNTCHARCNT(new_data) = op->charcount; REFCOUNT(new_data) = 0; /* usage counter */ p = new_data; for (i = 0; i < op->charcount; i++) { memcpy(p, data, h); data += 32; p += h; } /* check if font is already used by other console */ for (i = 0; i < MAX_NR_CONSOLES; i++) { if (font_data[i] != FONT_DATA && FNTSIZE(font_data[i]) == size && !memcmp(font_data[i], new_data, size)) { kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); /* current font is the same as the new one */ if (i == unit) return 0; new_data = font_data[i]; break; } } /* old font is user font */ if (font_data[unit] != FONT_DATA) { if (--REFCOUNT(font_data[unit]) == 0) kfree(font_data[unit] - FONT_EXTRA_WORDS * sizeof(int)); } REFCOUNT(new_data)++; font_data[unit] = new_data; return 0;}static int newport_set_def_font(int unit, struct console_font_op *op){ if (font_data[unit] != FONT_DATA) { if (--REFCOUNT(font_data[unit]) == 0) kfree(font_data[unit] - FONT_EXTRA_WORDS * sizeof(int)); font_data[unit] = FONT_DATA; } return 0;}static int newport_font_op(struct vc_data *vc, struct console_font_op *op){ int unit = vc->vc_num; switch (op->op) { case KD_FONT_OP_SET: return newport_set_font(unit, op); case KD_FONT_OP_SET_DEFAULT: return newport_set_def_font(unit, op); default: return -ENOSYS; }}static int newport_set_palette(struct vc_data *vc, unsigned char *table){ return -EINVAL;}static int newport_scrolldelta(struct vc_data *vc, int lines){ /* there is (nearly) no off-screen memory, so we can't scroll back */ return 0;}static int newport_scroll(struct vc_data *vc, int t, int b, int dir, int lines){ int count, x, y; unsigned short *s, *d; unsigned short chattr; logo_active = 0; /* it's time to disable the logo now.. */ if (t == 0 && b == vc->vc_rows) { if (dir == SM_UP) { topscan = (topscan + (lines << 4)) & 0x3ff; newport_clear_lines(vc->vc_rows - lines, vc->vc_rows - 1, (vc->vc_color & 0xf0) >> 4); } else { topscan = (topscan + (-lines << 4)) & 0x3ff; newport_clear_lines(0, lines - 1, (vc->vc_color & 0xf0) >> 4); } npregs->cset.topscan = (topscan - 1) & 0x3ff; return 0; } count = (b - t - lines) * vc->vc_cols; if (dir == SM_UP) { x = 0; y = t; s = (unsigned short *) (vc->vc_origin + vc->vc_size_row * (t + lines)); d = (unsigned short *) (vc->vc_origin + vc->vc_size_row * t); while (count--) { chattr = scr_readw(s++); if (chattr != scr_readw(d)) { newport_putc(vc, chattr, y, x); scr_writew(chattr, d); } d++; if (++x == vc->vc_cols) { x = 0; y++; } } d = (unsigned short *) (vc->vc_origin + vc->vc_size_row * (b - lines)); x = 0; y = b - lines; for (count = 0; count < (lines * vc->vc_cols); count++) { if (scr_readw(d) != vc->vc_video_erase_char) { newport_putc(vc, vc->vc_video_erase_char, y, x); scr_writew(vc->vc_video_erase_char, d); } d++; if (++x == vc->vc_cols) { x = 0; y++; } } } else { x = vc->vc_cols - 1; y = b - 1; s = (unsigned short *) (vc->vc_origin + vc->vc_size_row * (b - lines) - 2); d = (unsigned short *) (vc->vc_origin + vc->vc_size_row * b - 2); while (count--) { chattr = scr_readw(s--); if (chattr != scr_readw(d)) { newport_putc(vc, chattr, y, x); scr_writew(chattr, d); } d--; if (x-- == 0) { x = vc->vc_cols - 1; y--; } } d = (unsigned short *) (vc->vc_origin + vc->vc_size_row * t); x = 0; y = t; for (count = 0; count < (lines * vc->vc_cols); count++) { if (scr_readw(d) != vc->vc_video_erase_char) { newport_putc(vc, vc->vc_video_erase_char, y, x); scr_writew(vc->vc_video_erase_char, d); } d++; if (++x == vc->vc_cols) { x = 0; y++; } } } return 1;}static void newport_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, int h, int w){ short xs, ys, xe, ye, xoffs, yoffs, tmp; xs = sx << 3; xe = ((sx + w) << 3) - 1; /* * as bmove is only used to move stuff around in the same line * (h == 1), we don't care about wrap arounds caused by topscan != 0 */ ys = ((sy << 4) + topscan) & 0x3ff; ye = (((sy + h) << 4) - 1 + topscan) & 0x3ff; xoffs = (dx - sx) << 3; yoffs = (dy - sy) << 4; if (xoffs > 0) { /* move to the right, exchange starting points */ tmp = xe; xe = xs; xs = tmp; } newport_wait(); npregs->set.drawmode0 = (NPORT_DMODE0_S2S | NPORT_DMODE0_BLOCK | NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX | NPORT_DMODE0_STOPY); npregs->set.xystarti = (xs << 16) | ys; npregs->set.xyendi = (xe << 16) | ye; npregs->go.xymove = (xoffs << 16) | yoffs;}static int newport_dummy(struct vc_data *c){ return 0;}#define DUMMY (void *) newport_dummyconst struct consw newport_con = { con_startup: newport_startup, con_init: newport_init, con_deinit: newport_deinit, con_clear: newport_clear, con_putc: newport_putc, con_putcs: newport_putcs, con_cursor: newport_cursor, con_scroll: newport_scroll, con_bmove: newport_bmove, con_switch: newport_switch, con_blank: newport_blank, con_font_op: newport_font_op, con_set_palette: newport_set_palette, con_scrolldelta: newport_scrolldelta, con_set_origin: DUMMY, con_save_screen: DUMMY};#ifdef MODULEstatic int __init newport_console_init(void){ take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1); return 0;}static void __exit newport_console_exit(void){ give_up_console(&newport_con);}module_init(newport_console_init);module_exit(newport_console_exit);#endifMODULE_LICENSE("GPL");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -