promcon.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:12k
- /* $Id: promcon.c,v 1.17 2000/07/26 23:02:52 davem Exp $
- * Console driver utilizing PROM sun terminal emulation
- *
- * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
- * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
- */
- #include <linux/config.h>
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/errno.h>
- #include <linux/string.h>
- #include <linux/mm.h>
- #include <linux/tty.h>
- #include <linux/slab.h>
- #include <linux/delay.h>
- #include <linux/console.h>
- #include <linux/console_struct.h>
- #include <linux/vt_kern.h>
- #include <linux/selection.h>
- #include <linux/fb.h>
- #include <linux/init.h>
- #include <linux/kd.h>
- #include <asm/oplib.h>
- #include <asm/uaccess.h>
- static short pw = 80 - 1, ph = 34 - 1;
- static short px, py;
- static unsigned long promcon_uni_pagedir[2];
- extern u8 promfont_unicount[];
- extern u16 promfont_unitable[];
- #define PROMCON_COLOR 0
- #if PROMCON_COLOR
- #define inverted(s) ((((s) & 0x7700) == 0x0700) ? 0 : 1)
- #else
- #define inverted(s) (((s) & 0x0800) ? 1 : 0)
- #endif
- static __inline__ void
- promcon_puts(char *buf, int cnt)
- {
- prom_printf("%*.*s", cnt, cnt, buf);
- }
- static int
- promcon_start(struct vc_data *conp, char *b)
- {
- unsigned short *s = (unsigned short *)
- (conp->vc_origin + py * conp->vc_size_row + (px << 1));
- u16 cs;
- cs = scr_readw(s);
- if (px == pw) {
- unsigned short *t = s - 1;
- u16 ct = scr_readw(t);
- if (inverted(cs) && inverted(ct))
- return sprintf(b, "b 33[7m%cb 33[@%c 33[m", cs,
- ct);
- else if (inverted(cs))
- return sprintf(b, "b 33[7m%c 33[mb 33[@%c", cs,
- ct);
- else if (inverted(ct))
- return sprintf(b, "b%cb 33[@ 33[7m%c 33[m", cs,
- ct);
- else
- return sprintf(b, "b%cb 33[@%c", cs, ct);
- }
- if (inverted(cs))
- return sprintf(b, "