📄 fbcon.c
字号:
/* * linux/arch/m68knommu/console/fbcon.c -- Low level frame buffer based console * driver * * Modifications to support 4-bit wide monochrome fonts * -- Kenneth Albanowski <kjahds@kjahds.com> * * Copyright (C) 1998,1999 Kenneth Albanowski <kjahds@kjahds.com>, * The Silver Hammer Group, Ltd. * * Based on: * * linux/arch/m68k/console/fbcon.c -- Low level frame buffer based console * driver * * Copyright (C) 1995 Geert Uytterhoeven * * * This file is based on the original Amiga console driver (amicon.c): * * Copyright (C) 1993 Hamish Macdonald * Greg Harp * Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk] * * with work by William Rucklidge (wjr@cs.cornell.edu) * Geert Uytterhoeven * Jes Sorensen (jds@kom.auc.dk) * Martin Apel * * and on the original Atari console driver (atacon.c): * * Copyright (C) 1993 Bjoern Brauel * Roman Hodek * * with work by Guenther Kelleter * Martin Schaller * Andreas Schwab * * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. *//* * To do: * - Implement 16 plane mode. * - Add support for 16/24/32 bit packed pixels * - Hardware cursor */#include <linux/types.h>#include <linux/fs.h>#include <linux/kernel.h>#include <linux/tty.h>#include <linux/console.h>#include <linux/string.h>#include <linux/config.h>#include <linux/kd.h>#include <linux/malloc.h>#include <asm/irq.h>#ifdef CONFIG_AMIGA#include <asm/amigahw.h>#include <asm/amigaints.h>#endif /* CONFIG_AMIGA */#ifdef CONFIG_ATARI#include <asm/atariints.h>#endif#ifdef CONFIG_FB_CYBER#include "../amiga/s3blit.h"#endif /* CONFIG_FB_CYBER */#include <linux/fb.h>#include <asm/font.h>#include <asm/machdep.h>#include <asm/system.h>#include "../../../drivers/char/vt_kern.h" /* vt_cons and vc_resize_con() */extern struct fb_info *mc68328_fb_init(long *mem_start);/* Import console_blanked from console.c */extern int console_blanked; /* * The following symbols select what modes are supported. They should * be settable by the user ("make config") later. *//* Clear all definitions */#undef CONFIG_FBCON_MONO#undef CONFIG_FBCON_ILBM#undef CONFIG_FBCON_PLANES#undef CONFIG_FBCON_2PLANE#undef CONFIG_FBCON_4PLANE#undef CONFIG_FBCON_8PLANE#undef CONFIG_FBCON_8PACKED#undef CONFIG_FBCON_16PACKED#undef CONFIG_FBCON_24PACKED#undef CONFIG_FBCON_32PACKED#undef CONFIG_FBCON_CYBER/* Monochrome is default */#define CONFIG_FBCON_MONO/* Amiga support */#ifdef CONFIG_AMIGA#ifndef CONFIG_FBCON_ILBM#define CONFIG_FBCON_ILBM#endif#ifndef CONFIG_FBCON_PLANES#define CONFIG_FBCON_PLANES#endif/* Cybervision Graphics Board */#ifdef CONFIG_FB_CYBER#ifndef CONFIG_FBCON_CYBER#define CONFIG_FBCON_CYBER#endif#endif /* CONFIG_FB_CYBER */#endif /* CONFIG_AMIGA *//* Atari support */#ifdef CONFIG_ATARI#ifndef CONFIG_FBCON_2PLANE#define CONFIG_FBCON_2PLANE#endif#ifndef CONFIG_FBCON_4PLANE#define CONFIG_FBCON_4PLANE#endif#ifndef CONFIG_FBCON_8PLANE#define CONFIG_FBCON_8PLANE#endif#ifndef CONFIG_FBCON_8PACKED#define CONFIG_FBCON_8PACKED#endif#ifndef CONFIG_FBCON_16PACKED#define CONFIG_FBCON_16PACKED#endif#endif /* CONFIG_ATARI *//* Extra definitions to make the code more readable */#if defined(CONFIG_FBCON_2PLANE) || defined(CONFIG_FBCON_4PLANE) || \ defined(CONFIG_FBCON_8PLANE)#define CONFIG_FBCON_IPLAN2#else#undef CONFIG_FBCON_IPLAN2#endif#if defined(CONFIG_FBCON_CYBER) || defined(CONFIG_FBCON_8PACKED) || \ defined(CONFIG_FBCON_16PACKED) || defined(CONFIG_FBCON_24PACKED) || \ defined(CONFIG_FBCON_32PACKED)#define CONFIG_FBCON_PACKED#else#undef CONFIG_FBCON_PACKED#endifstruct fb_info *fb_info;struct display *disp;/* ++Geert: Sorry, no hardware cursor support at the moment; use Atari alike software cursor */static int cursor_drawn = 0;#define CURSOR_DRAW_DELAY (2)/* # VBL ints between cursor state changes */#define AMIGA_CURSOR_BLINK_RATE (20)#define ATARI_CURSOR_BLINK_RATE (42)static int vbl_cursor_cnt = 0;static int cursor_on = 0;static int cursor_blink_rate;static __inline__ int CURSOR_UNDRAWN(void){ int cursor_was_drawn; vbl_cursor_cnt = 0; cursor_was_drawn = cursor_drawn; cursor_drawn = 0; return(cursor_was_drawn);} /* * Attribute Decoding *//* Color */#define attr_fgcol(p,conp) \ (((conp)->vc_attr >> ((p)->inverse ? 4 : 0)) & 0x0f)#define attr_bgcol(p,conp) \ (((conp)->vc_attr >> ((p)->inverse ? 0 : 4)) & 0x0f)#define attr_bgcol_ec(p,conp) \ (((conp)->vc_video_erase_char >> ((p)->inverse ? 8 : 12)) & 0x0f)/* Monochrome */#define attr_bold(p,conp) \ (((conp)->vc_attr & 3) == 2)#define attr_reverse(p,conp) \ (((conp)->vc_attr & 8) ^ ((p)->inverse ? 8 : 0))#define attr_underline(p,conp) \ (((conp)->vc_attr) & 4) /* * Scroll Method */#define SCROLL_YWRAP (0)#define SCROLL_YPAN (1)#define SCROLL_YMOVE (2)#define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1) /* * Interface used by the world */static u_long fbcon_startup(u_long kmem_start, char **display_desc);static void fbcon_init(struct vc_data *conp);static int fbcon_deinit(struct vc_data *conp);static int fbcon_changevar(int con);static int fbcon_clear(struct vc_data *conp, int sy, int sx, int height, int width);static int fbcon_putc(struct vc_data *conp, int c, int y, int x);static int fbcon_putcs(struct vc_data *conp, const char *s, int count, int y, int x);static int fbcon_cursor(struct vc_data *conp, int mode);static int fbcon_scroll(struct vc_data *conp, int t, int b, int dir, int count);static int fbcon_bmove(struct vc_data *conp, int sy, int sx, int dy, int dx, int height, int width);static int fbcon_switch(struct vc_data *conp);static int fbcon_blank(int blank); /* * Internal routines */static void fbcon_setup(int con, int setcol, int cls);static __inline__ void *mymemclear_small(void *s, size_t count);static __inline__ void *mymemclear(void *s, size_t count);static __inline__ void *mymemset(void *s, size_t count);static __inline__ void *mymemmove(void *d, void *s, size_t count);static __inline__ void fast_memmove(char *dst, char *src, size_t size);static __inline__ void memclear_4p_col(void *d, size_t h, u_long val, int bpr);static __inline__ void memset_even_4p(void *d, size_t count, u_long val1, u_long val2);static __inline__ void memmove_4p_col(void *d, void *s, int h, int bpr);static __inline__ u_long expand4l(u_char c);static __inline__ void expand4dl(u_char c, u_long *ret1, u_long *ret2);static __inline__ u_long dup4l(u_char c);static __inline__ void memclear_8p_col(void *d, size_t h, u_long val1, u_long val2, int bpr);static __inline__ void memset_even_8p(void *d, size_t count, u_long val1, u_long val2, u_long val3, u_long val4);static __inline__ void memmove_8p_col(void *d, void *s, int h, int bpr);static __inline__ void expand8dl(u_char c, u_long *ret1, u_long *ret2);static __inline__ void memclear_2p_col(void *d, size_t h, u_short val, int bpr);static __inline__ void memset_even_2p(void *d, size_t count, u_long val);static __inline__ void memmove_2p_col(void *d, void *s, int h, int bpr);static __inline__ u_short expand2w(u_char c);static __inline__ u_long expand2l(u_char c);static __inline__ u_short dup2w(u_char c);static __inline__ int real_y(struct display *p, int y);static void fbcon_vbl_handler(int irq, struct pt_regs *fp, void *dummy);static void fbcon_bmove_rec(struct display *p, int sy, int sx, int dy, int dx, int height, int width, u_int y_break); /* * Monochrome */#ifdef CONFIG_FBCON_MONOstatic void bmove_mono(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_mono(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_mono(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_mono(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_mono(struct display *p, int x, int y);#endif /* CONFIG_FBCON_MONO */ /* * Color Interleaved Planes */#ifdef CONFIG_FBCON_ILBMstatic void bmove_ilbm(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_ilbm(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_ilbm(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_ilbm(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_ilbm(struct display *p, int x, int y);#endif /* CONFIG_FBCON_ILBM */ /* * Color Planes */#ifdef CONFIG_FBCON_PLANESstatic void bmove_plan(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_plan(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_plan(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_plan(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_plan(struct display *p, int x, int y);#endif /* CONFIG_FBCON_PLANES */ /* * 2 Planes (2-bytes interleave) */#ifdef CONFIG_FBCON_2PLANEstatic void bmove_2_plane(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_2_plane(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_2_plane(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_2_plane(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_2_plane(struct display *display, int x, int y);#endif /* CONFIG_FBCON_2PLANE */ /* * 4 Planes (2-bytes interleave) */#ifdef CONFIG_FBCON_4PLANEstatic void bmove_4_plane(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_4_plane(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_4_plane(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_4_plane(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_4_plane(struct display *p, int x, int y);#endif /* CONFIG_FBCON_4PLANE */ /* * 8 Planes (2-bytes interleave) */#ifdef CONFIG_FBCON_8PLANEstatic void bmove_8_plane(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_8_plane(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_8_plane(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_8_plane(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_8_plane(struct display *display, int x, int y);#endif /* CONFIG_FBCON_8PLANE */ /* * 8 bpp Packed Pixels */#ifdef CONFIG_FBCON_8PACKEDstatic void bmove_8_packed(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_8_packed(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_8_packed(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_8_packed(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_8_packed(struct display *p, int x, int y);#endif /* CONFIG_FBCON_8PACKED */ /* * 16 bpp Packed Pixels */#ifdef CONFIG_FBCON_16PACKEDstatic void bmove_16_packed(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_16_packed(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_16_packed(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_16_packed(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_16_packed(struct display *p, int x, int y);#endif */ CONFIG_FBCON_8PACKED */ /* * Cybervision (accelerated) */#ifdef CONFIG_FBCON_CYBERstatic void bmove_cyber(struct display *p, int sy, int sx, int dy, int dx, int height, int width);static void clear_cyber(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width);static void putc_cyber(struct vc_data *conp, struct display *p, int c, int y, int x);static void putcs_cyber(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x);static void rev_char_cyber(struct display *p, int x, int y);extern void Cyber_WaitQueue(u_short fifo);extern void Cyber_WaitBlit(void);extern void Cyber_BitBLT(u_short curx, u_short cury, u_short destx, u_short desty, u_short width, u_short height, u_short mode);extern void Cyber_RectFill(u_short x, u_short y, u_short width, u_short height, u_short mode, u_short color);extern void Cyber_MoveCursor(u_short x, u_short y);#endif /* CONFIG_FBCON_CYBER */ /* * `switch' for the Low Level Operations */struct display_switch { void (*bmove)(struct display *p, int sy, int sx, int dy, int dx, int height, int width); void (*clear)(struct vc_data *conp, struct display *p, int sy, int sx, int height, int width); void (*putc)(struct vc_data *conp, struct display *p, int c, int y, int x); void (*putcs)(struct vc_data *conp, struct display *p, const char *s, int count, int y, int x); void (*rev_char)(struct display *p, int x, int y);};#ifdef CONFIG_FBCON_MONOstruct display_switch dispsw_mono = {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -