📄 fbcon.c
字号:
bmove_mono, clear_mono, putc_mono, putcs_mono, rev_char_mono};#endif /* CONFIG_FBCON_MONO */#ifdef CONFIG_FBCON_ILBMstruct display_switch dispsw_ilbm = { bmove_ilbm, clear_ilbm, putc_ilbm, putcs_ilbm, rev_char_ilbm};#endif /* CONFIG_FBCON_ILBM */#ifdef CONFIG_FBCON_PLANESstruct display_switch dispsw_plan = { bmove_plan, clear_plan, putc_plan, putcs_plan, rev_char_plan};#endif /* CONFIG_FBCON_PLANES */#ifdef CONFIG_FBCON_2PLANEstruct display_switch dispsw_2_plane = { bmove_2_plane, clear_2_plane, putc_2_plane, putcs_2_plane, rev_char_2_plane};#endif /* CONFIG_FBCON_2PLANE */#ifdef CONFIG_FBCON_4PLANEstruct display_switch dispsw_4_plane = { bmove_4_plane, clear_4_plane, putc_4_plane, putcs_4_plane, rev_char_4_plane};#endif /* CONFIG_FBCON_4PLANE */#ifdef CONFIG_FBCON_8PLANEstruct display_switch dispsw_8_plane = { bmove_8_plane, clear_8_plane, putc_8_plane, putcs_8_plane, rev_char_8_plane};#endif /* CONFIG_FBCON_8PLANE */#ifdef CONFIG_FBCON_8PACKEDstruct display_switch dispsw_8_packed = { bmove_8_packed, clear_8_packed, putc_8_packed, putcs_8_packed, rev_char_8_packed};#endif /* CONFIG_FBCON_8PACKED */#ifdef CONFIG_FBCON_16PACKEDstruct display_switch dispsw_16_packed = { bmove_16_packed, clear_16_packed, putc_16_packed, putcs_16_packed, rev_char_16_packed};#endif /* CONFIG_FBCON_16PACKED */#ifdef CONFIG_FBCON_CYBERstruct display_switch dispsw_cyber = { bmove_cyber, clear_cyber, putc_cyber, putcs_cyber, rev_char_cyber};#endif /* CONFIG_FBCON_CYBER */static u_long fbcon_startup(u_long kmem_start, char **display_desc){ int irqres = 0; fb_info = mc68328_fb_init(&kmem_start); disp = fb_info->disp; *display_desc = fb_info->modename; fb_info->changevar = &fbcon_changevar;#ifdef CONFIG_AMIGA if (MACH_IS_AMIGA) { cursor_blink_rate = AMIGA_CURSOR_BLINK_RATE; irqres = add_isr(IRQ_AMIGA_VERTB, fbcon_vbl_handler, 0, NULL, "console/cursor"); }#endif /* CONFIG_AMIGA */#ifdef CONFIG_ATARI if (MACH_IS_ATARI) { cursor_blink_rate = ATARI_CURSOR_BLINK_RATE; irqres = add_isr(IRQ_AUTO_4, fbcon_vbl_handler, IRQ_TYPE_PRIO, NULL, "console/cursor"); }#endif /* CONFIG_ATARI */#if defined(CONFIG_AMIGA) || defined(CONFIG_ATARI) if (!irqres) panic("fbcon_startup: Couldn't add vblank interrupt");#endif return(kmem_start);}static void fbcon_init(struct vc_data *conp){ int unit = conp->vc_num; if (unit) disp[unit] = disp[0]; disp[unit].conp = conp; fbcon_setup(unit, 1, 0);}static int fbcon_deinit(struct vc_data *conp){ disp[conp->vc_num].conp = 0; return(0);}static int fbcon_changevar(int con){ fbcon_setup(con, 1, 1); return(0);}static void fbcon_setup(int con, int setcol, int cls){ struct display *p = &disp[con]; struct vc_data *conp = p->conp; p->var.xoffset = p->var.yoffset = p->yscroll = 0; /* reset wrap/pan */ if (!fb_info->fontname[0] || !findsoftfont(fb_info->fontname, &p->fontwidth, &p->fontheight, &p->fontdata)) getdefaultfont(p->var.xres, p->var.yres, NULL, &p->fontwidth, &p->fontheight, &p->fontdata); if (divides(p->ywrapstep, p->fontheight) && divides(p->fontheight, p->var.yres_virtual)) p->scrollmode = SCROLL_YWRAP; else if (divides(p->ypanstep, p->fontheight) && p->var.yres_virtual >= p->var.yres+p->fontheight) p->scrollmode = SCROLL_YPAN; else p->scrollmode = SCROLL_YMOVE; conp->vc_cols = p->var.xres/p->fontwidth; conp->vc_rows = p->var.yres/p->fontheight; p->vrows = p->var.yres_virtual/p->fontheight; conp->vc_can_do_color = p->var.bits_per_pixel != 1;#ifdef CONFIG_FBCON_MONO if (p->var.bits_per_pixel == 1) { if (p->line_length) p->next_line = p->line_length; else p->next_line = p->var.xres_virtual/8; p->next_plane = 0; p->dispsw = &dispsw_mono; } else#endif /* CONFIG_FBCON_MONO */#ifdef CONFIG_FBCON_IPLAN2 if (p->type == FB_TYPE_INTERLEAVED_PLANES && p->type_aux == 2) { p->next_line = p->var.xres_virtual*p->var.bits_per_pixel>>3; p->next_plane = 0;#ifdef CONFIG_FBCON_2PLANE if (p->var.bits_per_pixel == 2) p->dispsw = &dispsw_2_plane; else#endif /* CONFIG_FBCON_2PLANE */#ifdef CONFIG_FBCON_4PLANE if (p->var.bits_per_pixel == 4) p->dispsw = &dispsw_4_plane; else#endif /* CONFIG_FBCON_4PLANE */#ifdef CONFIG_FBCON_8PLANE if (p->var.bits_per_pixel == 8) p->dispsw = &dispsw_8_plane; else#endif /* CONFIG_FBCON_8PLANE */ goto fail; } else#endif /* CONFIG_FBCON_IPLAN2 */#ifdef CONFIG_FBCON_ILBM if (p->type == FB_TYPE_INTERLEAVED_PLANES && p->type_aux != 2) { if (p->line_length) { p->next_line = p->line_length*p->var.bits_per_pixel; p->next_plane = p->line_length; } else { p->next_line = p->type_aux; p->next_plane = p->type_aux/p->var.bits_per_pixel; } p->dispsw = &dispsw_ilbm; } else#endif /* CONFIG_FBCON_ILBM */#ifdef CONFIG_FBCON_PLANES if (p->type == FB_TYPE_PLANES) { if (p->line_length) p->next_line = p->line_length; else p->next_line = p->var.xres_virtual>>3; p->next_plane = p->var.yres_virtual*p->next_line; p->dispsw = &dispsw_plan; } else#endif /* CONFIG_FBCON_PLANES */#ifdef CONFIG_FBCON_PACKED if (p->type == FB_TYPE_PACKED_PIXELS) { p->next_line = p->var.xres_virtual*p->var.bits_per_pixel>>3; p->next_plane = 0;#ifdef CONFIG_FBCON_CYBER if (p->var.accel == FB_ACCEL_CYBERVISION) p->dispsw = &dispsw_cyber; else#endif /* CONFIG_FBCON_CYBER */#ifdef CONFIG_FBCON_8PACKED if (p->var.bits_per_pixel == 8) p->dispsw = &dispsw_8_packed; else#endif /* CONFIG_FBCON_8PACKED */#ifdef CONFIG_FBCON_16PACKED if (p->var.bits_per_pixel == 16) p->dispsw = &dispsw_16_packed; else#endif /* CONFIG_FBCON_16PACKED */#ifdef CONFIG_FBCON_24PACKED if (p->var.bits_per_pixel == 24) p->dispsw = &dispsw_24_packed; else#endif /* CONFIG_FBCON_24PACKED */#ifdef CONFIG_FBCON_32PACKED if (p->var.bits_per_pixel == 32) p->dispsw = &dispsw_32_packed; else#endif /* CONFIG_FBCON_32PACKED */ goto fail; } else#endif /* CONFIG_FBCON_PACKED */ {fail:#ifdef CONFIG_FBCON_MONO printk("fbcon_setup: type %d (aux %d) not supported, trying mono\n", p->type, p->type_aux); if (p->line_length) p->next_line = p->line_length; else p->next_line = p->var.xres_virtual/8; p->next_plane = 0; p->var.bits_per_pixel = 1; p->dispsw = &dispsw_mono;#else /* CONFIG_FBCON_MONO */ panic("fbcon_setup: no default driver");#endif /* CONFIG_FBCON_MONO */ } if ((p->dispsw != &dispsw_mono) && (p->fontwidth != 8)) panic("fbcon_setup: No support for fontwidth != 8 on non-monochrome targets"); if ((p->dispsw == &dispsw_mono) && (p->fontwidth != 8) && (p->fontwidth != 4) ) panic("fbcon_setup: No support for fontwidth != 8/4 on monochrome targets"); if (setcol) { p->fgcol = p->var.bits_per_pixel > 2 ? 7 : (1<<p->var.bits_per_pixel)-1; p->bgcol = 0; } if (cls) vc_resize_con(conp->vc_rows, conp->vc_cols, con);}/* ================================================================= *//* Utility Assembler Functions *//* ================================================================= *//* ====================================================================== *//* Those of a delicate disposition might like to skip the next couple of * pages. * * These functions are drop in replacements for memmove and * memset(_, 0, _). However their five instances add at least a kilobyte * to the object file. You have been warned. * * Not a great fan of assembler for the sake of it, but I think * that these routines are at least 10 times faster than their C * equivalents for large blits, and that's important to the lowest level of * a graphics driver. Question is whether some scheme with the blitter * would be faster. I suspect not for simple text system - not much * asynchrony. * * Code is very simple, just gruesome expansion. Basic strategy is to * increase data moved/cleared at each step to 16 bytes to reduce * instruction per data move overhead. movem might be faster still * For more than 15 bytes, we try to align the write direction on a * longword boundary to get maximum speed. This is even more gruesome. * Unaligned read/write used requires 68020+ - think this is a problem? * * Sorry! *//* ++roman: I've optimized Robert's original versions in some minor * aspects, e.g. moveq instead of movel, let gcc choose the registers, * use movem in some places... * For other modes than 1 plane, lots of more such assembler functions * were needed (e.g. the ones using movep or expanding color values). *//* ++andreas: more optimizations: subl #65536,d0 replaced by clrw d0; subql #1,d0 for dbcc addal is faster than addaw movep is rather expensive compared to ordinary move's some functions rewritten in C for clarity, no speed loss */static __inline__ void *mymemclear_small(void *s, size_t count){ if (!count) return(0); __asm__ __volatile__( "lsrl #1,%1 ; jcc 1f ; moveb %2,%0@-\n\t" "1: lsrl #1,%1 ; jcc 1f ; movew %2,%0@-\n\t" "1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@-\n\t" "1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@- ; movel %2,%0@-\n\t" "1: subql #1,%1 ; jcs 3f\n\t" "2: moveml %2/%3/%4/%5,%0@-\n\t" "dbra %1,2b\n\t" "3:" : "=a" (s), "=d" (count) : "d" (0), "d" (0), "d" (0), "d" (0), "0" ((char *)s+count), "1" (count) ); return(0);}static __inline__ void *mymemclear(void *s, size_t count){ if (!count) return(0); if (count < 16) { __asm__ __volatile__( "lsrl #1,%1 ; jcc 1f ; clrb %0@+\n\t" "1: lsrl #1,%1 ; jcc 1f ; clrw %0@+\n\t" "1: lsrl #1,%1 ; jcc 1f ; clrl %0@+\n\t" "1: lsrl #1,%1 ; jcc 1f ; clrl %0@+ ; clrl %0@+\n\t" "1:" : "=a" (s), "=d" (count) : "0" (s), "1" (count) ); } else { long tmp; __asm__ __volatile__( "movel %1,%2\n\t" "lsrl #1,%2 ; jcc 1f ; clrb %0@+ ; subqw #1,%1\n\t" "lsrl #1,%2 ; jcs 2f\n\t" /* %0 increased=>bit 2 switched*/ "clrw %0@+ ; subqw #2,%1 ; jra 2f\n\t" "1: lsrl #1,%2 ; jcc 2f\n\t" "clrw %0@+ ; subqw #2,%1\n\t" "2: movew %1,%2; lsrl #2,%1 ; jeq 6f\n\t" "lsrl #1,%1 ; jcc 3f ; clrl %0@+\n\t" "3: lsrl #1,%1 ; jcc 4f ; clrl %0@+ ; clrl %0@+\n\t" "4: subql #1,%1 ; jcs 6f\n\t" "5: clrl %0@+; clrl %0@+ ; clrl %0@+ ; clrl %0@+\n\t" "dbra %1,5b ; clrw %1; subql #1,%1; jcc 5b\n\t" "6: movew %2,%1; btst #1,%1 ; jeq 7f ; clrw %0@+\n\t" "7: ; btst #0,%1 ; jeq 8f ; clrb %0@+\n\t" "8:" : "=a" (s), "=d" (count), "=d" (tmp) : "0" (s), "1" (count) ); } return(0);}static __inline__ void *mymemset(void *s, size_t count){ if (!count) return(0); __asm__ __volatile__( "lsrl #1,%1 ; jcc 1f ; moveb %2,%0@-\n\t" "1: lsrl #1,%1 ; jcc 1f ; movew %2,%0@-\n\t" "1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@-\n\t" "1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@- ; movel %2,%0@-\n\t" "1: subql #1,%1 ; jcs 3f\n\t" "2: moveml %2/%3/%4/%5,%0@-\n\t" "dbra %1,2b\n\t" "3:" : "=a" (s), "=d" (count) : "d" (-1), "d" (-1), "d" (-1), "d" (-1), "0" ((char *) s + count), "1" (count) ); return(0);}static __inline__ void *mymemmove(void *d, void *s, size_t count){ if (d < s) { if (count < 16) { __asm__ __volatile__( "lsrl #1,%2 ; jcc 1f ; moveb %1@+,%0@+\n\t" "1: lsrl #1,%2 ; jcc 1f ; movew %1@+,%0@+\n\t" "1: lsrl #1,%2 ; jcc 1f ; movel %1@+,%0@+\n\t" "1: lsrl #1,%2 ; jcc 1f ; movel %1@+,%0@+ ; movel %1@+,%0@+\n\t" "1:" : "=a" (d), "=a" (s), "=d" (count) : "0" (d), "1" (s), "2" (count) ); } else { long tmp; __asm__ __volatile__( "movel %0,%3\n\t" "lsrl #1,%3 ; jcc 1f ; moveb %1@+,%0@+ ; subqw #1,%2\n\t" "lsrl #1,%3 ; jcs 2f\n\t" /* %0 increased=>bit 2 switched*/ "movew %1@+,%0@+ ; subqw #2,%2 ; jra 2f\n\t" "1: lsrl #1,%3 ; jcc 2f\n\t" "movew %1@+,%0@+ ; subqw #2,%2\n\t" "2: movew %2,%-; lsrl #2,%2 ; jeq 6f\n\t" "lsrl #1,%2 ; jcc 3f ; movel %1@+,%0@+\n\t" "3: lsrl #1,%2 ; jcc 4f ; movel %1@+,%0@+ ; movel %1@+,%0@+\n\t" "4: subql #1,%2 ; jcs 6f\n\t" "5: movel %1@+,%0@+;movel %1@+,%0@+\n\t" "movel %1@+,%0@+;movel %1@+,%0@+\n\t" "dbra %2,5b ; clrw %2; subql #1,%2; jcc 5b\n\t" "6: movew %+,%2; btst #1,%2 ; jeq 7f ; movew %1@+,%0@+\n\t" "7: ; btst #0,%2 ; jeq 8f ; moveb %1@+,%0@+\n\t" "8:" : "=a" (d), "=a" (s), "=d" (count), "=d" (tmp) : "0" (d), "1" (s), "2" (count) ); } } else { if (count < 16) { __asm__ __volatile__( "lsrl #1,%2 ; jcc 1f ; moveb %1@-,%0@-\n\t" "1: lsrl #1,%2 ; jcc 1f ; movew %1@-,%0@-\n\t" "1: lsrl #1,%2 ; jcc 1f ; movel %1@-,%0@-\n\t" "1: lsrl #1,%2 ; jcc 1f ; movel %1@-,%0@- ; movel %1@-,%0@-\n\t" "1:" : "=a" (d), "=a" (s), "=d" (count) : "0" ((char *) d + count), "1" ((char *) s + count), "2" (count) ); } else { long tmp; __asm__ __volatile__( "movel %0,%3\n\t" "lsrl #1,%3 ; jcc 1f ; moveb %1@-,%0@- ; subqw #1,%2\n\t" "lsrl #1,%3 ; jcs 2f\n\t" /* %0 increased=>bit 2 switched*/ "movew %1@-,%0@- ; subqw #2,%2 ; jra 2f\n\t" "1: lsrl #1,%3 ; jcc 2f\n\t" "movew %1@-,%0@- ; subqw #2,%2\n\t" "2: movew %2,%-; lsrl #2,%2 ; jeq 6f\n\t" "lsrl #1,%2 ; jcc 3f ; movel %1@-,%0@-\n\t" "3: lsrl #1,%2 ; jcc 4f ; movel %1@-,%0@- ; movel %1@-,%0@-\n\t" "4: subql #1,%2 ; jcs 6f\n\t" "5: movel %1@-,%0@-;movel %1@-,%0@-\n\t" "movel %1@-,%0@-;movel %1@-,%0@-\n\t" "dbra %2,5b ; clrw %2; subql #1,%2; jcc 5b\n\t" "6: movew %+,%2; btst #1,%2 ; jeq 7f ; movew %1@-,%0@-\n\t" "7: ; btst #0,%2 ; jeq 8f ; moveb %1@-,%0@-\n\t" "8:" : "=a" (d), "=a" (s), "=d" (count), "=d" (tmp) : "0" ((char *) d + count), "1" ((char *) s + count), "2" (count) ); } } return(0);}/* ++andreas: Simple and fast version of memmove, assumes size is divisible by 16, suitable for moving the whole screen bitplane */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -