Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
#
# Video configuration
#
menu "Console display driver support"
config VGA_CONSOLE
bool "VGA text console" if EXPERT || !X86
depends on !4xx && !PPC_8xx && !SPARC && !M68K && !PARISC && !SUPERH && \
(!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER) && \
!ARM64 && !ARC && !MICROBLAZE && !OPENRISC && !NDS32 && !S390
default y
help
Saying Y here will allow you to use Linux in text mode through a
display that complies with the generic VGA standard. Virtually
everyone wants that.
The program SVGATextMode can be used to utilize SVGA video cards to
their full potential in text mode. Download it from
<ftp://ibiblio.org/pub/Linux/utils/console/>.
Say Y.
config MDA_CONSOLE
depends on !M68K && !PARISC && ISA
tristate "MDA text console (dual-headed)"
---help---
Say Y here if you have an old MDA or monochrome Hercules graphics
adapter in your system acting as a second head ( = video card). You
will then be able to use two monitors with your Linux system. Do not
say Y here if your MDA card is the primary card in your system; the
normal VGA driver will handle it.
To compile this driver as a module, choose M here: the
module will be called mdacon.
If unsure, say N.
config SGI_NEWPORT_CONSOLE
tristate "SGI Newport Console support"
depends on SGI_IP22 && HAS_IOMEM
select FONT_SUPPORT
help
Say Y here if you want the console on the Newport aka XL graphics
card of your Indy. Most people say Y here.
config DUMMY_CONSOLE
bool
depends on VGA_CONSOLE!=y || SGI_NEWPORT_CONSOLE!=y
default y
config DUMMY_CONSOLE_COLUMNS
int "Initial number of console screen columns"
depends on DUMMY_CONSOLE && !ARM
default 160 if PARISC
default 80
help
On PA-RISC, the default value is 160, which should fit a 1280x1024
monitor.
Select 80 if you use a 640x480 resolution by default.
config DUMMY_CONSOLE_ROWS
int "Initial number of console screen rows"
depends on DUMMY_CONSOLE && !ARM
default 64 if PARISC
default 25
help
On PA-RISC, the default value is 64, which should fit a 1280x1024
monitor.
Select 25 if you use a 640x480 resolution by default.
config FRAMEBUFFER_CONSOLE
bool "Framebuffer Console support"
depends on FB && !UML
select VT_HW_CONSOLE_BINDING
select CRC32
select FONT_SUPPORT
help
Low-level framebuffer-based console driver.
config FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
bool "Map the console to the primary display device"
depends on FRAMEBUFFER_CONSOLE
default n
---help---
If this option is selected, the framebuffer console will
automatically select the primary display device (if the architecture
supports this feature). Otherwise, the framebuffer console will
always select the first framebuffer driver that is loaded. The latter
is the default behavior.
You can always override the automatic selection of the primary device
by using the fbcon=map: boot option.
If unsure, select n.
config FRAMEBUFFER_CONSOLE_ROTATION
bool "Framebuffer Console Rotation"
depends on FRAMEBUFFER_CONSOLE
help
Enable display rotation for the framebuffer console. This is done
in software and may be significantly slower than a normally oriented
display. Note that the rotation is done at the console level only
such that other users of the framebuffer will remain normally
oriented.
config FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
bool "Framebuffer Console Deferred Takeover"
depends on FB=y && FRAMEBUFFER_CONSOLE && DUMMY_CONSOLE
help
If enabled this defers the framebuffer console taking over the
console from the dummy console until the first text is displayed on
the console. This is useful in combination with the "quiet" kernel
commandline option to keep the framebuffer contents initially put up
by the firmware in place, rather then replacing the contents with a
black screen as soon as fbcon loads.
config STI_CONSOLE
bool "STI text console"
depends on PARISC && HAS_IOMEM
select FONT_SUPPORT
default y
help
The STI console is the builtin display/keyboard on HP-PARISC
machines. Say Y here to build support for it into your kernel.
The alternative is to use your primary serial port as a console.
endmenu
+12
View File
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: GPL-2.0
# Makefile for the Linux graphics to console drivers.
# 5 Aug 1999, James Simmons, <mailto:jsimmons@users.sf.net>
# Rewritten to use lists instead of if-statements.
obj-$(CONFIG_DUMMY_CONSOLE) += dummycon.o
obj-$(CONFIG_SGI_NEWPORT_CONSOLE) += newport_con.o
obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o
obj-$(CONFIG_VGA_CONSOLE) += vgacon.o
obj-$(CONFIG_MDA_CONSOLE) += mdacon.o
obj-$(CONFIG_FB_STI) += sticore.o
+159
View File
@@ -0,0 +1,159 @@
/*
* linux/drivers/video/dummycon.c -- A dummy console driver
*
* To be used if there's no other console driver (e.g. for plain VGA text)
* available, usually until fbcon takes console over.
*/
#include <linux/types.h>
#include <linux/kdev_t.h>
#include <linux/console.h>
#include <linux/vt_kern.h>
#include <linux/screen_info.h>
#include <linux/init.h>
#include <linux/module.h>
/*
* Dummy console driver
*/
#if defined(__arm__)
#define DUMMY_COLUMNS screen_info.orig_video_cols
#define DUMMY_ROWS screen_info.orig_video_lines
#else
/* set by Kconfig. Use 80x25 for 640x480 and 160x64 for 1280x1024 */
#define DUMMY_COLUMNS CONFIG_DUMMY_CONSOLE_COLUMNS
#define DUMMY_ROWS CONFIG_DUMMY_CONSOLE_ROWS
#endif
#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
/* These are both protected by the console_lock */
static RAW_NOTIFIER_HEAD(dummycon_output_nh);
static bool dummycon_putc_called;
void dummycon_register_output_notifier(struct notifier_block *nb)
{
raw_notifier_chain_register(&dummycon_output_nh, nb);
if (dummycon_putc_called)
nb->notifier_call(nb, 0, NULL);
}
void dummycon_unregister_output_notifier(struct notifier_block *nb)
{
raw_notifier_chain_unregister(&dummycon_output_nh, nb);
}
static void dummycon_putc(struct vc_data *vc, int c, int ypos, int xpos)
{
dummycon_putc_called = true;
raw_notifier_call_chain(&dummycon_output_nh, 0, NULL);
}
static void dummycon_putcs(struct vc_data *vc, const unsigned short *s,
int count, int ypos, int xpos)
{
int i;
if (!dummycon_putc_called) {
/* Ignore erases */
for (i = 0 ; i < count; i++) {
if (s[i] != vc->vc_video_erase_char)
break;
}
if (i == count)
return;
dummycon_putc_called = true;
}
raw_notifier_call_chain(&dummycon_output_nh, 0, NULL);
}
static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)
{
/* Redraw, so that we get putc(s) for output done while blanked */
return 1;
}
#else
static void dummycon_putc(struct vc_data *vc, int c, int ypos, int xpos) { }
static void dummycon_putcs(struct vc_data *vc, const unsigned short *s,
int count, int ypos, int xpos) { }
static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)
{
return 0;
}
#endif
static const char *dummycon_startup(void)
{
return "dummy device";
}
static void dummycon_init(struct vc_data *vc, int init)
{
vc->vc_can_do_color = 1;
if (init) {
vc->vc_cols = DUMMY_COLUMNS;
vc->vc_rows = DUMMY_ROWS;
} else
vc_resize(vc, DUMMY_COLUMNS, DUMMY_ROWS);
}
static void dummycon_deinit(struct vc_data *vc) { }
static void dummycon_clear(struct vc_data *vc, int sy, int sx, int height,
int width) { }
static void dummycon_cursor(struct vc_data *vc, int mode) { }
static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
unsigned int bottom, enum con_scroll dir,
unsigned int lines)
{
return false;
}
static int dummycon_switch(struct vc_data *vc)
{
return 0;
}
static int dummycon_font_set(struct vc_data *vc, struct console_font *font,
unsigned int flags)
{
return 0;
}
static int dummycon_font_default(struct vc_data *vc,
struct console_font *font, char *name)
{
return 0;
}
static int dummycon_font_copy(struct vc_data *vc, int con)
{
return 0;
}
/*
* The console `switch' structure for the dummy console
*
* Most of the operations are dummies.
*/
const struct consw dummy_con = {
.owner = THIS_MODULE,
.con_startup = dummycon_startup,
.con_init = dummycon_init,
.con_deinit = dummycon_deinit,
.con_clear = dummycon_clear,
.con_putc = dummycon_putc,
.con_putcs = dummycon_putcs,
.con_cursor = dummycon_cursor,
.con_scroll = dummycon_scroll,
.con_switch = dummycon_switch,
.con_blank = dummycon_blank,
.con_font_set = dummycon_font_set,
.con_font_default = dummycon_font_default,
.con_font_copy = dummycon_font_copy,
};
EXPORT_SYMBOL_GPL(dummy_con);
+576
View File
@@ -0,0 +1,576 @@
/*
* linux/drivers/video/mdacon.c -- Low level MDA based console driver
*
* (c) 1998 Andrew Apted <ajapted@netspace.net.au>
*
* including portions (c) 1995-1998 Patrick Caulfield.
*
* slight improvements (c) 2000 Edward Betts <edward@debian.org>
*
* This file is based on the VGA console driver (vgacon.c):
*
* Created 28 Sep 1997 by Geert Uytterhoeven
*
* Rewritten by Martin Mares <mj@ucw.cz>, July 1998
*
* and on the old console.c, vga.c and vesa_blank.c drivers:
*
* Copyright (C) 1991, 1992 Linus Torvalds
* 1995 Jay Estabrook
*
* 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.
*
* Changelog:
* Paul G. (03/2001) Fix mdacon= boot prompt to use __setup().
*/
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/console.h>
#include <linux/string.h>
#include <linux/kd.h>
#include <linux/vt_kern.h>
#include <linux/vt_buffer.h>
#include <linux/selection.h>
#include <linux/spinlock.h>
#include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <asm/io.h>
#include <asm/vga.h>
static DEFINE_SPINLOCK(mda_lock);
/* description of the hardware layout */
static u16 *mda_vram_base; /* Base of video memory */
static unsigned long mda_vram_len; /* Size of video memory */
static unsigned int mda_num_columns; /* Number of text columns */
static unsigned int mda_num_lines; /* Number of text lines */
static unsigned int mda_index_port; /* Register select port */
static unsigned int mda_value_port; /* Register value port */
static unsigned int mda_mode_port; /* Mode control port */
static unsigned int mda_status_port; /* Status and Config port */
static unsigned int mda_gfx_port; /* Graphics control port */
/* current hardware state */
static int mda_cursor_loc=-1;
static int mda_cursor_size_from=-1;
static int mda_cursor_size_to=-1;
static enum { TYPE_MDA, TYPE_HERC, TYPE_HERCPLUS, TYPE_HERCCOLOR } mda_type;
static char *mda_type_name;
/* console information */
static int mda_first_vc = 13;
static int mda_last_vc = 16;
static struct vc_data *mda_display_fg = NULL;
module_param(mda_first_vc, int, 0);
MODULE_PARM_DESC(mda_first_vc, "First virtual console. Default: 13");
module_param(mda_last_vc, int, 0);
MODULE_PARM_DESC(mda_last_vc, "Last virtual console. Default: 16");
/* MDA register values
*/
#define MDA_CURSOR_BLINKING 0x00
#define MDA_CURSOR_OFF 0x20
#define MDA_CURSOR_SLOWBLINK 0x60
#define MDA_MODE_GRAPHICS 0x02
#define MDA_MODE_VIDEO_EN 0x08
#define MDA_MODE_BLINK_EN 0x20
#define MDA_MODE_GFX_PAGE1 0x80
#define MDA_STATUS_HSYNC 0x01
#define MDA_STATUS_VSYNC 0x80
#define MDA_STATUS_VIDEO 0x08
#define MDA_CONFIG_COL132 0x08
#define MDA_GFX_MODE_EN 0x01
#define MDA_GFX_PAGE_EN 0x02
/*
* MDA could easily be classified as "pre-dinosaur hardware".
*/
static void write_mda_b(unsigned int val, unsigned char reg)
{
unsigned long flags;
spin_lock_irqsave(&mda_lock, flags);
outb_p(reg, mda_index_port);
outb_p(val, mda_value_port);
spin_unlock_irqrestore(&mda_lock, flags);
}
static void write_mda_w(unsigned int val, unsigned char reg)
{
unsigned long flags;
spin_lock_irqsave(&mda_lock, flags);
outb_p(reg, mda_index_port); outb_p(val >> 8, mda_value_port);
outb_p(reg+1, mda_index_port); outb_p(val & 0xff, mda_value_port);
spin_unlock_irqrestore(&mda_lock, flags);
}
#ifdef TEST_MDA_B
static int test_mda_b(unsigned char val, unsigned char reg)
{
unsigned long flags;
spin_lock_irqsave(&mda_lock, flags);
outb_p(reg, mda_index_port);
outb (val, mda_value_port);
udelay(20); val = (inb_p(mda_value_port) == val);
spin_unlock_irqrestore(&mda_lock, flags);
return val;
}
#endif
static inline void mda_set_cursor(unsigned int location)
{
if (mda_cursor_loc == location)
return;
write_mda_w(location >> 1, 0x0e);
mda_cursor_loc = location;
}
static inline void mda_set_cursor_size(int from, int to)
{
if (mda_cursor_size_from==from && mda_cursor_size_to==to)
return;
if (from > to) {
write_mda_b(MDA_CURSOR_OFF, 0x0a); /* disable cursor */
} else {
write_mda_b(from, 0x0a); /* cursor start */
write_mda_b(to, 0x0b); /* cursor end */
}
mda_cursor_size_from = from;
mda_cursor_size_to = to;
}
#ifndef MODULE
static int __init mdacon_setup(char *str)
{
/* command line format: mdacon=<first>,<last> */
int ints[3];
str = get_options(str, ARRAY_SIZE(ints), ints);
if (ints[0] < 2)
return 0;
if (ints[1] < 1 || ints[1] > MAX_NR_CONSOLES ||
ints[2] < 1 || ints[2] > MAX_NR_CONSOLES)
return 0;
mda_first_vc = ints[1];
mda_last_vc = ints[2];
return 1;
}
__setup("mdacon=", mdacon_setup);
#endif
static int mda_detect(void)
{
int count=0;
u16 *p, p_save;
u16 *q, q_save;
/* do a memory check */
p = mda_vram_base;
q = mda_vram_base + 0x01000 / 2;
p_save = scr_readw(p);
q_save = scr_readw(q);
scr_writew(0xAA55, p);
if (scr_readw(p) == 0xAA55)
count++;
scr_writew(0x55AA, p);
if (scr_readw(p) == 0x55AA)
count++;
scr_writew(p_save, p);
if (count != 2) {
return 0;
}
/* check if we have 4K or 8K */
scr_writew(0xA55A, q);
scr_writew(0x0000, p);
if (scr_readw(q) == 0xA55A)
count++;
scr_writew(0x5AA5, q);
scr_writew(0x0000, p);
if (scr_readw(q) == 0x5AA5)
count++;
scr_writew(p_save, p);
scr_writew(q_save, q);
if (count == 4) {
mda_vram_len = 0x02000;
}
/* Ok, there is definitely a card registering at the correct
* memory location, so now we do an I/O port test.
*/
#ifdef TEST_MDA_B
/* Edward: These two mess `tests' mess up my cursor on bootup */
/* cursor low register */
if (!test_mda_b(0x66, 0x0f))
return 0;
/* cursor low register */
if (!test_mda_b(0x99, 0x0f))
return 0;
#endif
/* See if the card is a Hercules, by checking whether the vsync
* bit of the status register is changing. This test lasts for
* approximately 1/10th of a second.
*/
p_save = q_save = inb_p(mda_status_port) & MDA_STATUS_VSYNC;
for (count = 0; count < 50000 && p_save == q_save; count++) {
q_save = inb(mda_status_port) & MDA_STATUS_VSYNC;
udelay(2);
}
if (p_save != q_save) {
switch (inb_p(mda_status_port) & 0x70) {
case 0x10:
mda_type = TYPE_HERCPLUS;
mda_type_name = "HerculesPlus";
break;
case 0x50:
mda_type = TYPE_HERCCOLOR;
mda_type_name = "HerculesColor";
break;
default:
mda_type = TYPE_HERC;
mda_type_name = "Hercules";
break;
}
}
return 1;
}
static void mda_initialize(void)
{
write_mda_b(97, 0x00); /* horizontal total */
write_mda_b(80, 0x01); /* horizontal displayed */
write_mda_b(82, 0x02); /* horizontal sync pos */
write_mda_b(15, 0x03); /* horizontal sync width */
write_mda_b(25, 0x04); /* vertical total */
write_mda_b(6, 0x05); /* vertical total adjust */
write_mda_b(25, 0x06); /* vertical displayed */
write_mda_b(25, 0x07); /* vertical sync pos */
write_mda_b(2, 0x08); /* interlace mode */
write_mda_b(13, 0x09); /* maximum scanline */
write_mda_b(12, 0x0a); /* cursor start */
write_mda_b(13, 0x0b); /* cursor end */
write_mda_w(0x0000, 0x0c); /* start address */
write_mda_w(0x0000, 0x0e); /* cursor location */
outb_p(MDA_MODE_VIDEO_EN | MDA_MODE_BLINK_EN, mda_mode_port);
outb_p(0x00, mda_status_port);
outb_p(0x00, mda_gfx_port);
}
static const char *mdacon_startup(void)
{
mda_num_columns = 80;
mda_num_lines = 25;
mda_vram_len = 0x01000;
mda_vram_base = (u16 *)VGA_MAP_MEM(0xb0000, mda_vram_len);
mda_index_port = 0x3b4;
mda_value_port = 0x3b5;
mda_mode_port = 0x3b8;
mda_status_port = 0x3ba;
mda_gfx_port = 0x3bf;
mda_type = TYPE_MDA;
mda_type_name = "MDA";
if (! mda_detect()) {
printk("mdacon: MDA card not detected.\n");
return NULL;
}
if (mda_type != TYPE_MDA) {
mda_initialize();
}
/* cursor looks ugly during boot-up, so turn it off */
mda_set_cursor(mda_vram_len - 1);
printk("mdacon: %s with %ldK of memory detected.\n",
mda_type_name, mda_vram_len/1024);
return "MDA-2";
}
static void mdacon_init(struct vc_data *c, int init)
{
c->vc_complement_mask = 0x0800; /* reverse video */
c->vc_display_fg = &mda_display_fg;
if (init) {
c->vc_cols = mda_num_columns;
c->vc_rows = mda_num_lines;
} else
vc_resize(c, mda_num_columns, mda_num_lines);
/* make the first MDA console visible */
if (mda_display_fg == NULL)
mda_display_fg = c;
}
static void mdacon_deinit(struct vc_data *c)
{
/* con_set_default_unimap(c->vc_num); */
if (mda_display_fg == c)
mda_display_fg = NULL;
}
static inline u16 mda_convert_attr(u16 ch)
{
u16 attr = 0x0700;
/* Underline and reverse-video are mutually exclusive on MDA.
* Since reverse-video is used for cursors and selected areas,
* it takes precedence.
*/
if (ch & 0x0800) attr = 0x7000; /* reverse */
else if (ch & 0x0400) attr = 0x0100; /* underline */
return ((ch & 0x0200) << 2) | /* intensity */
(ch & 0x8000) | /* blink */
(ch & 0x00ff) | attr;
}
static u8 mdacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
u8 blink, u8 underline, u8 reverse, u8 italic)
{
/* The attribute is just a bit vector:
*
* Bit 0..1 : intensity (0..2)
* Bit 2 : underline
* Bit 3 : reverse
* Bit 7 : blink
*/
return (intensity & 3) |
((underline & 1) << 2) |
((reverse & 1) << 3) |
(!!italic << 4) |
((blink & 1) << 7);
}
static void mdacon_invert_region(struct vc_data *c, u16 *p, int count)
{
for (; count > 0; count--) {
scr_writew(scr_readw(p) ^ 0x0800, p);
p++;
}
}
static inline u16 *mda_addr(unsigned int x, unsigned int y)
{
return mda_vram_base + y * mda_num_columns + x;
}
static void mdacon_putc(struct vc_data *c, int ch, int y, int x)
{
scr_writew(mda_convert_attr(ch), mda_addr(x, y));
}
static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
int count, int y, int x)
{
u16 *dest = mda_addr(x, y);
for (; count > 0; count--) {
scr_writew(mda_convert_attr(scr_readw(s++)), dest++);
}
}
static void mdacon_clear(struct vc_data *c, int y, int x,
int height, int width)
{
u16 *dest = mda_addr(x, y);
u16 eattr = mda_convert_attr(c->vc_video_erase_char);
if (width <= 0 || height <= 0)
return;
if (x==0 && width==mda_num_columns) {
scr_memsetw(dest, eattr, height*width*2);
} else {
for (; height > 0; height--, dest+=mda_num_columns)
scr_memsetw(dest, eattr, width*2);
}
}
static int mdacon_switch(struct vc_data *c)
{
return 1; /* redrawing needed */
}
static int mdacon_blank(struct vc_data *c, int blank, int mode_switch)
{
if (mda_type == TYPE_MDA) {
if (blank)
scr_memsetw(mda_vram_base,
mda_convert_attr(c->vc_video_erase_char),
c->vc_screenbuf_size);
/* Tell console.c that it has to restore the screen itself */
return 1;
} else {
if (blank)
outb_p(0x00, mda_mode_port); /* disable video */
else
outb_p(MDA_MODE_VIDEO_EN | MDA_MODE_BLINK_EN,
mda_mode_port);
return 0;
}
}
static void mdacon_cursor(struct vc_data *c, int mode)
{
if (mode == CM_ERASE) {
mda_set_cursor(mda_vram_len - 1);
return;
}
mda_set_cursor(c->vc_y*mda_num_columns*2 + c->vc_x*2);
switch (c->vc_cursor_type & 0x0f) {
case CUR_LOWER_THIRD: mda_set_cursor_size(10, 13); break;
case CUR_LOWER_HALF: mda_set_cursor_size(7, 13); break;
case CUR_TWO_THIRDS: mda_set_cursor_size(4, 13); break;
case CUR_BLOCK: mda_set_cursor_size(1, 13); break;
case CUR_NONE: mda_set_cursor_size(14, 13); break;
default: mda_set_cursor_size(12, 13); break;
}
}
static bool mdacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,
enum con_scroll dir, unsigned int lines)
{
u16 eattr = mda_convert_attr(c->vc_video_erase_char);
if (!lines)
return false;
if (lines > c->vc_rows) /* maximum realistic size */
lines = c->vc_rows;
switch (dir) {
case SM_UP:
scr_memmovew(mda_addr(0, t), mda_addr(0, t + lines),
(b-t-lines)*mda_num_columns*2);
scr_memsetw(mda_addr(0, b - lines), eattr,
lines*mda_num_columns*2);
break;
case SM_DOWN:
scr_memmovew(mda_addr(0, t + lines), mda_addr(0, t),
(b-t-lines)*mda_num_columns*2);
scr_memsetw(mda_addr(0, t), eattr, lines*mda_num_columns*2);
break;
}
return false;
}
/*
* The console `switch' structure for the MDA based console
*/
static const struct consw mda_con = {
.owner = THIS_MODULE,
.con_startup = mdacon_startup,
.con_init = mdacon_init,
.con_deinit = mdacon_deinit,
.con_clear = mdacon_clear,
.con_putc = mdacon_putc,
.con_putcs = mdacon_putcs,
.con_cursor = mdacon_cursor,
.con_scroll = mdacon_scroll,
.con_switch = mdacon_switch,
.con_blank = mdacon_blank,
.con_build_attr = mdacon_build_attr,
.con_invert_region = mdacon_invert_region,
};
int __init mda_console_init(void)
{
int err;
if (mda_first_vc > mda_last_vc)
return 1;
console_lock();
err = do_take_over_console(&mda_con, mda_first_vc-1, mda_last_vc-1, 0);
console_unlock();
return err;
}
static void __exit mda_console_exit(void)
{
give_up_console(&mda_con);
}
module_init(mda_console_init);
module_exit(mda_console_exit);
MODULE_LICENSE("GPL");
+761
View File
@@ -0,0 +1,761 @@
/*
* newport_con.c: Abscon for newport hardware
*
* (C) 1998 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
* (C) 1999 Ulf Carlsson (ulfc@thepuffingruop.com)
*
* This driver is based on sgicons.c and cons_newport.
*
* Copyright (C) 1996 David S. Miller (davem@davemloft.net)
* Copyright (C) 1997 Miguel de Icaza (miguel@nuclecu.unam.mx)
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/kd.h>
#include <linux/selection.h>
#include <linux/console.h>
#include <linux/vt_kern.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <asm/io.h>
#include <linux/uaccess.h>
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/gio_device.h>
#include <video/newport.h>
#include <linux/linux_logo.h>
#include <linux/font.h>
#define NEWPORT_LEN 0x10000
#define FONT_DATA ((unsigned char *)font_vga_8x16.data)
static unsigned char *font_data[MAX_NR_CONSOLES];
static struct newport_regs *npregs;
static unsigned long newport_addr;
static int logo_active;
static int topscan;
static int xcurs_correction = 29;
static int newport_xsize;
static int newport_ysize;
static int newport_has_init;
static int newport_set_def_font(int unit, struct console_font *op);
#define BMASK(c) (c << 24)
#define RENDER(regs, cp) do { \
(regs)->go.zpattern = BMASK((cp)[0x0]); (regs)->go.zpattern = BMASK((cp)[0x1]); \
(regs)->go.zpattern = BMASK((cp)[0x2]); (regs)->go.zpattern = BMASK((cp)[0x3]); \
(regs)->go.zpattern = BMASK((cp)[0x4]); (regs)->go.zpattern = BMASK((cp)[0x5]); \
(regs)->go.zpattern = BMASK((cp)[0x6]); (regs)->go.zpattern = BMASK((cp)[0x7]); \
(regs)->go.zpattern = BMASK((cp)[0x8]); (regs)->go.zpattern = BMASK((cp)[0x9]); \
(regs)->go.zpattern = BMASK((cp)[0xa]); (regs)->go.zpattern = BMASK((cp)[0xb]); \
(regs)->go.zpattern = BMASK((cp)[0xc]); (regs)->go.zpattern = BMASK((cp)[0xd]); \
(regs)->go.zpattern = BMASK((cp)[0xe]); (regs)->go.zpattern = BMASK((cp)[0xf]); \
} while(0)
#define TESTVAL 0xdeadbeef
#define XSTI_TO_FXSTART(val) (((val) & 0xffff) << 11)
static inline void newport_render_background(int xstart, int ystart,
int xend, int yend, int ci)
{
newport_wait(npregs);
npregs->set.wrmask = 0xffffffff;
npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
| NPORT_DMODE0_STOPY);
npregs->set.colori = ci;
npregs->set.xystarti =
(xstart << 16) | ((ystart + topscan) & 0x3ff);
npregs->go.xyendi =
((xend + 7) << 16) | ((yend + topscan + 15) & 0x3ff);
}
static inline void newport_init_cmap(void)
{
unsigned short i;
for (i = 0; i < 16; i++) {
newport_bfwait(npregs);
newport_cmap_setaddr(npregs, color_table[i]);
newport_cmap_setrgb(npregs,
default_red[i],
default_grn[i], default_blu[i]);
}
}
static const struct linux_logo *newport_show_logo(void)
{
#ifdef CONFIG_LOGO_SGI_CLUT224
const struct linux_logo *logo = fb_find_logo(8);
const unsigned char *clut;
const unsigned char *data;
unsigned long i;
if (!logo)
return NULL;
clut = logo->clut;
data = logo->data;
for (i = 0; i < logo->clutsize; i++) {
newport_bfwait(npregs);
newport_cmap_setaddr(npregs, i + 0x20);
newport_cmap_setrgb(npregs, clut[0], clut[1], clut[2]);
clut += 3;
}
newport_wait(npregs);
npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
NPORT_DMODE0_CHOST);
npregs->set.xystarti = ((newport_xsize - logo->width) << 16) | (0);
npregs->set.xyendi = ((newport_xsize - 1) << 16);
newport_wait(npregs);
for (i = 0; i < logo->width*logo->height; i++)
npregs->go.hostrw0 = *data++ << 24;
return logo;
#endif /* CONFIG_LOGO_SGI_CLUT224 */
}
static inline void newport_clear_screen(int xstart, int ystart, int xend,
int yend, int ci)
{
if (logo_active)
return;
newport_wait(npregs);
npregs->set.wrmask = 0xffffffff;
npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
| NPORT_DMODE0_STOPY);
npregs->set.colori = ci;
npregs->set.xystarti = (xstart << 16) | ystart;
npregs->go.xyendi = (xend << 16) | yend;
}
static inline void newport_clear_lines(int ystart, int yend, int ci)
{
ystart = ((ystart << 4) + topscan) & 0x3ff;
yend = ((yend << 4) + topscan + 15) & 0x3ff;
newport_clear_screen(0, ystart, 1280 + 63, yend, ci);
}
static void newport_reset(void)
{
unsigned short treg;
int i;
newport_wait(npregs);
treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
newport_vc2_set(npregs, VC2_IREG_CONTROL,
(treg | VC2_CTRL_EVIDEO));
treg = newport_vc2_get(npregs, VC2_IREG_CENTRY);
newport_vc2_set(npregs, VC2_IREG_RADDR, treg);
npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
NPORT_DMODE_W2 | VC2_PROTOCOL);
for (i = 0; i < 128; i++) {
newport_bfwait(npregs);
if (i == 92 || i == 94)
npregs->set.dcbdata0.byshort.s1 = 0xff00;
else
npregs->set.dcbdata0.byshort.s1 = 0x0000;
}
newport_init_cmap();
/* turn off popup plane */
npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
XM9_CRS_CONFIG | NPORT_DMODE_W1);
npregs->set.dcbdata0.bybytes.b3 &= ~XM9_PUPMODE;
npregs->set.dcbmode = (DCB_XMAP1 | R_DCB_XMAP9_PROTOCOL |
XM9_CRS_CONFIG | NPORT_DMODE_W1);
npregs->set.dcbdata0.bybytes.b3 &= ~XM9_PUPMODE;
topscan = 0;
npregs->cset.topscan = 0x3ff;
npregs->cset.xywin = (4096 << 16) | 4096;
/* Clear the screen. */
newport_clear_screen(0, 0, 1280 + 63, 1024, 0);
}
/*
* calculate the actual screen size by reading
* the video timing out of the VC2
*/
static void newport_get_screensize(void)
{
int i, cols;
unsigned short ventry, treg;
unsigned short linetable[128]; /* should be enough */
ventry = newport_vc2_get(npregs, VC2_IREG_VENTRY);
newport_vc2_set(npregs, VC2_IREG_RADDR, ventry);
npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
NPORT_DMODE_W2 | VC2_PROTOCOL);
for (i = 0; i < 128; i++) {
newport_bfwait(npregs);
linetable[i] = npregs->set.dcbdata0.byshort.s1;
}
newport_xsize = newport_ysize = 0;
for (i = 0; i < ARRAY_SIZE(linetable) - 1 && linetable[i + 1]; i += 2) {
cols = 0;
newport_vc2_set(npregs, VC2_IREG_RADDR, linetable[i]);
npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
NPORT_DMODE_W2 | VC2_PROTOCOL);
do {
newport_bfwait(npregs);
treg = npregs->set.dcbdata0.byshort.s1;
if ((treg & 1) == 0)
cols += (treg >> 7) & 0xfe;
if ((treg & 0x80) == 0) {
newport_bfwait(npregs);
treg = npregs->set.dcbdata0.byshort.s1;
}
} while ((treg & 0x8000) == 0);
if (cols) {
if (cols > newport_xsize)
newport_xsize = cols;
newport_ysize += linetable[i + 1];
}
}
printk("NG1: Screensize %dx%d\n", newport_xsize, newport_ysize);
}
static void newport_get_revisions(void)
{
unsigned int tmp;
unsigned int board_rev;
unsigned int rex3_rev;
unsigned int vc2_rev;
unsigned int cmap_rev;
unsigned int xmap9_rev;
unsigned int bt445_rev;
unsigned int bitplanes;
rex3_rev = npregs->cset.status & NPORT_STAT_VERS;
npregs->set.dcbmode = (DCB_CMAP0 | NCMAP_PROTOCOL |
NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
tmp = npregs->set.dcbdata0.bybytes.b3;
cmap_rev = tmp & 7;
board_rev = (tmp >> 4) & 7;
bitplanes = ((board_rev > 1) && (tmp & 0x80)) ? 8 : 24;
npregs->set.dcbmode = (DCB_CMAP1 | NCMAP_PROTOCOL |
NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
tmp = npregs->set.dcbdata0.bybytes.b3;
if ((tmp & 7) < cmap_rev)
cmap_rev = (tmp & 7);
vc2_rev = (newport_vc2_get(npregs, VC2_IREG_CONFIG) >> 5) & 7;
npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
XM9_CRS_REVISION | NPORT_DMODE_W1);
xmap9_rev = npregs->set.dcbdata0.bybytes.b3 & 7;
npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
BT445_CSR_ADDR_REG | NPORT_DMODE_W1);
npregs->set.dcbdata0.bybytes.b3 = BT445_REVISION_REG;
npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
BT445_CSR_REVISION | NPORT_DMODE_W1);
bt445_rev = (npregs->set.dcbdata0.bybytes.b3 >> 4) - 0x0a;
#define L(a) (char)('A'+(a))
printk
("NG1: Revision %d, %d bitplanes, REX3 revision %c, VC2 revision %c, xmap9 revision %c, cmap revision %c, bt445 revision %c\n",
board_rev, bitplanes, L(rex3_rev), L(vc2_rev), L(xmap9_rev),
L(cmap_rev ? (cmap_rev + 1) : 0), L(bt445_rev));
#undef L
if (board_rev == 3) /* I don't know all affected revisions */
xcurs_correction = 21;
}
static void newport_exit(void)
{
int i;
/* free memory used by user font */
for (i = 0; i < MAX_NR_CONSOLES; i++)
newport_set_def_font(i, NULL);
}
/* Can't be __init, do_take_over_console may call it later */
static const char *newport_startup(void)
{
int i;
npregs->cset.config = NPORT_CFG_GD0;
if (newport_wait(npregs))
goto out_unmap;
npregs->set.xstarti = TESTVAL;
if (npregs->set._xstart.word != XSTI_TO_FXSTART(TESTVAL))
goto out_unmap;
for (i = 0; i < MAX_NR_CONSOLES; i++)
font_data[i] = FONT_DATA;
newport_reset();
newport_get_revisions();
newport_get_screensize();
newport_has_init = 1;
return "SGI Newport";
out_unmap:
return NULL;
}
static void newport_init(struct vc_data *vc, int init)
{
int cols, rows;
cols = newport_xsize / 8;
rows = newport_ysize / 16;
vc->vc_can_do_color = 1;
if (init) {
vc->vc_cols = cols;
vc->vc_rows = rows;
} else
vc_resize(vc, cols, rows);
}
static void newport_deinit(struct vc_data *c)
{
if (!con_is_bound(&newport_con) && newport_has_init) {
newport_exit();
newport_has_init = 0;
}
}
static void newport_clear(struct vc_data *vc, int sy, int sx, int height,
int width)
{
int xend = ((sx + width) << 3) - 1;
int ystart = ((sy << 4) + topscan) & 0x3ff;
int yend = (((sy + height) << 4) + topscan - 1) & 0x3ff;
if (logo_active)
return;
if (ystart < yend) {
newport_clear_screen(sx << 3, ystart, xend, yend,
(vc->vc_color & 0xf0) >> 4);
} else {
newport_clear_screen(sx << 3, ystart, xend, 1023,
(vc->vc_color & 0xf0) >> 4);
newport_clear_screen(sx << 3, 0, xend, yend,
(vc->vc_color & 0xf0) >> 4);
}
}
static void newport_putc(struct vc_data *vc, int charattr, int ypos,
int xpos)
{
unsigned char *p;
p = &font_data[vc->vc_num][(charattr & 0xff) << 4];
charattr = (charattr >> 8) & 0xff;
xpos <<= 3;
ypos <<= 4;
newport_render_background(xpos, ypos, xpos, ypos,
(charattr & 0xf0) >> 4);
/* Set the color and drawing mode. */
newport_wait(npregs);
npregs->set.colori = charattr & 0xf;
npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB |
NPORT_DMODE0_L32);
/* Set coordinates for bitmap operation. */
npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff);
npregs->set.xyendi = ((xpos + 7) << 16);
newport_wait(npregs);
/* 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(npregs);
/* 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(npregs);
/* 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) {
if (newport_show_logo()) {
logo_drawn = 1;
logo_active = 1;
}
}
return 1;
}
static int newport_blank(struct vc_data *c, int blank, int mode_switch)
{
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)
{
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 */
FNTSUM(new_data) = 0;
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)
{
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_default(struct vc_data *vc, struct console_font *op, char *name)
{
return newport_set_def_font(vc->vc_num, op);
}
static int newport_font_set(struct vc_data *vc, struct console_font *font, unsigned flags)
{
return newport_set_font(vc->vc_num, font);
}
static bool newport_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
enum con_scroll dir, unsigned 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 false;
}
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 true;
}
static int newport_set_origin(struct vc_data *vc)
{
return 0;
}
static void newport_save_screen(struct vc_data *vc) { }
const struct consw newport_con = {
.owner = THIS_MODULE,
.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_switch = newport_switch,
.con_blank = newport_blank,
.con_font_set = newport_font_set,
.con_font_default = newport_font_default,
.con_set_origin = newport_set_origin,
.con_save_screen = newport_save_screen
};
static int newport_probe(struct gio_device *dev,
const struct gio_device_id *id)
{
int err;
if (!dev->resource.start)
return -EINVAL;
if (npregs)
return -EBUSY; /* we only support one Newport as console */
newport_addr = dev->resource.start + 0xF0000;
if (!request_mem_region(newport_addr, NEWPORT_LEN, "Newport"))
return -ENODEV;
npregs = (struct newport_regs *)/* ioremap cannot fail */
ioremap(newport_addr, sizeof(struct newport_regs));
console_lock();
err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
console_unlock();
if (err) {
iounmap((void *)npregs);
release_mem_region(newport_addr, NEWPORT_LEN);
}
return err;
}
static void newport_remove(struct gio_device *dev)
{
give_up_console(&newport_con);
iounmap((void *)npregs);
release_mem_region(newport_addr, NEWPORT_LEN);
}
static struct gio_device_id newport_ids[] = {
{ .id = 0x7e },
{ .id = 0xff }
};
MODULE_ALIAS("gio:7e");
static struct gio_driver newport_driver = {
.name = "newport",
.id_table = newport_ids,
.probe = newport_probe,
.remove = newport_remove,
};
int __init newport_console_init(void)
{
return gio_register_driver(&newport_driver);
}
void __exit newport_console_exit(void)
{
gio_unregister_driver(&newport_driver);
}
module_init(newport_console_init);
module_exit(newport_console_exit);
MODULE_LICENSE("GPL");
+367
View File
@@ -0,0 +1,367 @@
/*
* linux/drivers/video/console/sticon.c - console driver using HP's STI firmware
*
* Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
* Copyright (C) 2002 Helge Deller <deller@gmx.de>
*
* Based on linux/drivers/video/vgacon.c and linux/drivers/video/fbcon.c,
* which were
*
* Created 28 Sep 1997 by Geert Uytterhoeven
* Rewritten by Martin Mares <mj@ucw.cz>, July 1998
* Copyright (C) 1991, 1992 Linus Torvalds
* 1995 Jay Estabrook
* Copyright (C) 1995 Geert Uytterhoeven
* Copyright (C) 1993 Bjoern Brauel
* Roman Hodek
* 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
* with work by Guenther Kelleter
* Martin Schaller
* Andreas Schwab
* Emmanuel Marty (core@ggi-project.org)
* Jakub Jelinek (jj@ultra.linux.cz)
* Martin Mares <mj@ucw.cz>
*
* 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.
*
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/console.h>
#include <linux/errno.h>
#include <linux/vt_kern.h>
#include <linux/kd.h>
#include <linux/selection.h>
#include <linux/module.h>
#include <asm/io.h>
#include "../fbdev/sticore.h"
/* switching to graphics mode */
#define BLANK 0
static int vga_is_gfx;
/* this is the sti_struct used for this console */
static struct sti_struct *sticon_sti;
/* Software scrollback */
static unsigned long softback_buf, softback_curr;
static unsigned long softback_in;
static unsigned long /* softback_top, */ softback_end;
static int softback_lines;
/* software cursor */
static int cursor_drawn;
#define CURSOR_DRAW_DELAY (1)
#define DEFAULT_CURSOR_BLINK_RATE (20)
static int vbl_cursor_cnt;
static inline void cursor_undrawn(void)
{
vbl_cursor_cnt = 0;
cursor_drawn = 0;
}
static const char *sticon_startup(void)
{
return "STI console";
}
static void sticon_putc(struct vc_data *conp, int c, int ypos, int xpos)
{
int redraw_cursor = 0;
if (vga_is_gfx || console_blanked)
return;
if (conp->vc_mode != KD_TEXT)
return;
#if 0
if ((p->cursor_x == xpos) && (p->cursor_y == ypos)) {
cursor_undrawn();
redraw_cursor = 1;
}
#endif
sti_putc(sticon_sti, c, ypos, xpos);
if (redraw_cursor)
vbl_cursor_cnt = CURSOR_DRAW_DELAY;
}
static void sticon_putcs(struct vc_data *conp, const unsigned short *s,
int count, int ypos, int xpos)
{
int redraw_cursor = 0;
if (vga_is_gfx || console_blanked)
return;
if (conp->vc_mode != KD_TEXT)
return;
#if 0
if ((p->cursor_y == ypos) && (xpos <= p->cursor_x) &&
(p->cursor_x < (xpos + count))) {
cursor_undrawn();
redraw_cursor = 1;
}
#endif
while (count--) {
sti_putc(sticon_sti, scr_readw(s++), ypos, xpos++);
}
if (redraw_cursor)
vbl_cursor_cnt = CURSOR_DRAW_DELAY;
}
static void sticon_cursor(struct vc_data *conp, int mode)
{
unsigned short car1;
car1 = conp->vc_screenbuf[conp->vc_x + conp->vc_y * conp->vc_cols];
switch (mode) {
case CM_ERASE:
sti_putc(sticon_sti, car1, conp->vc_y, conp->vc_x);
break;
case CM_MOVE:
case CM_DRAW:
switch (conp->vc_cursor_type & 0x0f) {
case CUR_UNDERLINE:
case CUR_LOWER_THIRD:
case CUR_LOWER_HALF:
case CUR_TWO_THIRDS:
case CUR_BLOCK:
sti_putc(sticon_sti, (car1 & 255) + (0 << 8) + (7 << 11),
conp->vc_y, conp->vc_x);
break;
}
break;
}
}
static bool sticon_scroll(struct vc_data *conp, unsigned int t,
unsigned int b, enum con_scroll dir, unsigned int count)
{
struct sti_struct *sti = sticon_sti;
if (vga_is_gfx)
return false;
sticon_cursor(conp, CM_ERASE);
switch (dir) {
case SM_UP:
sti_bmove(sti, t + count, 0, t, 0, b - t - count, conp->vc_cols);
sti_clear(sti, b - count, 0, count, conp->vc_cols, conp->vc_video_erase_char);
break;
case SM_DOWN:
sti_bmove(sti, t, 0, t + count, 0, b - t - count, conp->vc_cols);
sti_clear(sti, t, 0, count, conp->vc_cols, conp->vc_video_erase_char);
break;
}
return false;
}
static void sticon_init(struct vc_data *c, int init)
{
struct sti_struct *sti = sticon_sti;
int vc_cols, vc_rows;
sti_set(sti, 0, 0, sti_onscreen_y(sti), sti_onscreen_x(sti), 0);
vc_cols = sti_onscreen_x(sti) / sti->font_width;
vc_rows = sti_onscreen_y(sti) / sti->font_height;
c->vc_can_do_color = 1;
if (init) {
c->vc_cols = vc_cols;
c->vc_rows = vc_rows;
} else {
/* vc_rows = (c->vc_rows > vc_rows) ? vc_rows : c->vc_rows; */
/* vc_cols = (c->vc_cols > vc_cols) ? vc_cols : c->vc_cols; */
vc_resize(c, vc_cols, vc_rows);
/* vc_resize_con(vc_rows, vc_cols, c->vc_num); */
}
}
static void sticon_deinit(struct vc_data *c)
{
}
static void sticon_clear(struct vc_data *conp, int sy, int sx, int height,
int width)
{
if (!height || !width)
return;
sti_clear(sticon_sti, sy, sx, height, width, conp->vc_video_erase_char);
}
static int sticon_switch(struct vc_data *conp)
{
return 1; /* needs refreshing */
}
static int sticon_set_origin(struct vc_data *conp)
{
return 0;
}
static int sticon_blank(struct vc_data *c, int blank, int mode_switch)
{
if (blank == 0) {
if (mode_switch)
vga_is_gfx = 0;
return 1;
}
sticon_set_origin(c);
sti_clear(sticon_sti, 0,0, c->vc_rows, c->vc_cols, BLANK);
if (mode_switch)
vga_is_gfx = 1;
return 1;
}
static u16 *sticon_screen_pos(struct vc_data *conp, int offset)
{
int line;
unsigned long p;
if (conp->vc_num != fg_console || !softback_lines)
return (u16 *)(conp->vc_origin + offset);
line = offset / conp->vc_size_row;
if (line >= softback_lines)
return (u16 *)(conp->vc_origin + offset - softback_lines * conp->vc_size_row);
p = softback_curr + offset;
if (p >= softback_end)
p += softback_buf - softback_end;
return (u16 *)p;
}
static unsigned long sticon_getxy(struct vc_data *conp, unsigned long pos,
int *px, int *py)
{
int x, y;
unsigned long ret;
if (pos >= conp->vc_origin && pos < conp->vc_scr_end) {
unsigned long offset = (pos - conp->vc_origin) / 2;
x = offset % conp->vc_cols;
y = offset / conp->vc_cols;
if (conp->vc_num == fg_console)
y += softback_lines;
ret = pos + (conp->vc_cols - x) * 2;
} else if (conp->vc_num == fg_console && softback_lines) {
unsigned long offset = pos - softback_curr;
if (pos < softback_curr)
offset += softback_end - softback_buf;
offset /= 2;
x = offset % conp->vc_cols;
y = offset / conp->vc_cols;
ret = pos + (conp->vc_cols - x) * 2;
if (ret == softback_end)
ret = softback_buf;
if (ret == softback_in)
ret = conp->vc_origin;
} else {
/* Should not happen */
x = y = 0;
ret = conp->vc_origin;
}
if (px) *px = x;
if (py) *py = y;
return ret;
}
static u8 sticon_build_attr(struct vc_data *conp, u8 color, u8 intens,
u8 blink, u8 underline, u8 reverse, u8 italic)
{
u8 attr = ((color & 0x70) >> 1) | ((color & 7));
if (reverse) {
color = ((color >> 3) & 0x7) | ((color & 0x7) << 3);
}
return attr;
}
static void sticon_invert_region(struct vc_data *conp, u16 *p, int count)
{
int col = 1; /* vga_can_do_color; */
while (count--) {
u16 a = scr_readw(p);
if (col)
a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | (((a) & 0x0700) << 4);
else
a = ((a & 0x0700) == 0x0100) ? 0x7000 : 0x7700;
scr_writew(a, p++);
}
}
static void sticon_save_screen(struct vc_data *conp)
{
}
static const struct consw sti_con = {
.owner = THIS_MODULE,
.con_startup = sticon_startup,
.con_init = sticon_init,
.con_deinit = sticon_deinit,
.con_clear = sticon_clear,
.con_putc = sticon_putc,
.con_putcs = sticon_putcs,
.con_cursor = sticon_cursor,
.con_scroll = sticon_scroll,
.con_switch = sticon_switch,
.con_blank = sticon_blank,
.con_set_origin = sticon_set_origin,
.con_save_screen = sticon_save_screen,
.con_build_attr = sticon_build_attr,
.con_invert_region = sticon_invert_region,
.con_screen_pos = sticon_screen_pos,
.con_getxy = sticon_getxy,
};
static int __init sticonsole_init(void)
{
int err;
/* already initialized ? */
if (sticon_sti)
return 0;
sticon_sti = sti_get_rom(0);
if (!sticon_sti)
return -ENODEV;
if (conswitchp == &dummy_con) {
printk(KERN_INFO "sticon: Initializing STI text console.\n");
console_lock();
err = do_take_over_console(&sti_con, 0, MAX_NR_CONSOLES - 1, 1);
console_unlock();
return err;
}
return 0;
}
module_init(sticonsole_init);
MODULE_LICENSE("GPL");
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff