diff --git a/elks/arch/i86/defconfig b/elks/arch/i86/defconfig index 3923224cc..dc6932063 100644 --- a/elks/arch/i86/defconfig +++ b/elks/arch/i86/defconfig @@ -112,6 +112,7 @@ CONFIG_CONSOLE_DIRECT=y # CONFIG_CONSOLE_BIOS is not set # CONFIG_CONSOLE_HEADLESS is not set CONFIG_KEYBOARD_SCANCODE=y +# CONFIG_CONSOLE_DUAL is not set # CONFIG_CONSOLE_SERIAL is not set CONFIG_EMUL_ANSI=y # CONFIG_KEYMAP_BE is not set diff --git a/elks/arch/i86/drivers/char/config.in b/elks/arch/i86/drivers/char/config.in index bcde5cb59..ba8e7d39e 100644 --- a/elks/arch/i86/drivers/char/config.in +++ b/elks/arch/i86/drivers/char/config.in @@ -12,7 +12,7 @@ mainmenu_option next_comment Headless CONFIG_CONSOLE_HEADLESS" Direct if [ "$CONFIG_CONSOLE_DIRECT" = "y" ]; then bool ' Scancode keyboard driver' CONFIG_KEYBOARD_SCANCODE y - bool ' Dual-screen console support' CONFIG_CONSOLE_DUAL n + bool ' Dual-screen console support' CONFIG_CONSOLE_DUAL n fi bool 'Serial Console' CONFIG_CONSOLE_SERIAL n if [[ "$CONFIG_CONSOLE_DIRECT" = "y" || "$CONFIG_CONSOLE_BIOS" = "y" ]]; then diff --git a/elks/arch/i86/drivers/char/conio-pc98-asm.h b/elks/arch/i86/drivers/char/conio-pc98-asm.h index f130939ea..4b5208b63 100644 --- a/elks/arch/i86/drivers/char/conio-pc98-asm.h +++ b/elks/arch/i86/drivers/char/conio-pc98-asm.h @@ -1,7 +1,7 @@ /* conio functions for PC-98 */ /* put character on text vram */ -void early_putchar(int c); +/*void early_putchar(int c);*/ /* get character data from keyboard */ int bios_getchar(void); diff --git a/elks/arch/i86/drivers/char/conio-pc98.c b/elks/arch/i86/drivers/char/conio-pc98.c index e09b40616..fdc65177d 100644 --- a/elks/arch/i86/drivers/char/conio-pc98.c +++ b/elks/arch/i86/drivers/char/conio-pc98.c @@ -3,7 +3,7 @@ */ #include -#include +#include #include "conio-pc98-asm.h" void conio_init() diff --git a/elks/arch/i86/drivers/char/console-bios.c b/elks/arch/i86/drivers/char/console-bios.c index 03a9e6ff6..7509139bf 100644 --- a/elks/arch/i86/drivers/char/console-bios.c +++ b/elks/arch/i86/drivers/char/console-bios.c @@ -47,15 +47,14 @@ struct console; typedef struct console Console; struct console { + int Width, Height; int cx, cy; /* cursor position */ - void (*fsm)(Console *, int); unsigned char display; unsigned char attr; /* current attribute */ unsigned char XN; /* delayed newline on column 80 */ unsigned char color; /* fg/bg attr */ + void (*fsm)(Console *, int); int pageno; /* video ram page # */ - unsigned short Width; - unsigned short Height; #ifdef CONFIG_EMUL_ANSI int savex, savey; /* saved cursor position */ unsigned char *parmptr; /* ptr to params */ @@ -90,9 +89,10 @@ static void PositionCursor(register Console * C) bios_setcursor (x, y, p); } -static void PositionCursorGet (int * x, int * y) +static void PositionCursorGet(int * x, int * y) { byte_t col, row; + bios_getcursor (&col, &row); *x = col; *y = row; @@ -174,10 +174,9 @@ struct tty_ops bioscon_ops = { void INITPROC console_init(void) { - Console *C; + Console *C = &Con[0]; int i; - C = Con; C->Width = SETUP_VID_COLS; C->Height = SETUP_VID_LINES; diff --git a/elks/arch/i86/drivers/char/console-direct-pc98.c b/elks/arch/i86/drivers/char/console-direct-pc98.c index bd9f5fe45..2ef51c806 100644 --- a/elks/arch/i86/drivers/char/console-direct-pc98.c +++ b/elks/arch/i86/drivers/char/console-direct-pc98.c @@ -54,15 +54,15 @@ struct console; typedef struct console Console; struct console { + int Width, Height; int cx, cy; /* cursor position */ - void (*fsm)(Console *, int); unsigned char display; + unsigned char unused; unsigned char attr; /* current attribute */ unsigned char XN; /* delayed newline on column 80 */ + void (*fsm)(Console *, int); unsigned int vseg; /* vram for this console page */ - int vseg_offset; /* vram offset of vseg for this console page */ - unsigned short Width; - unsigned short Height; + unsigned int vseg_offset; /* vram offset of vseg for this console page */ #ifdef CONFIG_EMUL_ANSI int savex, savey; /* saved cursor position */ unsigned char *parmptr; /* ptr to params */ @@ -95,7 +95,7 @@ static void SetDisplayPage(register Console * C) static void PositionCursor(register Console * C) { - int Pos; + unsigned int Pos; Pos = C->cx + C->Width * C->cy + C->vseg_offset; cursor_set(Pos * 2); @@ -144,7 +144,7 @@ static void VideoWrite(register Console * C, int c) static void ClearRange(register Console * C, int x, int y, int xx, int yy) { - register __u16 *vp; + __u16 *vp; word_t attr; attr = (C->attr == A_DEFAULT) ? A98_DEFAULT : conv_pcattr(C->attr); @@ -163,8 +163,8 @@ static void ClearRange(register Console * C, int x, int y, int xx, int yy) static void ScrollUp(register Console * C, int y) { __u16 *vp; - unsigned short MaxRow = C->Height - 1; - unsigned short MaxCol = C->Width - 1; + int MaxRow = C->Height - 1; + int MaxCol = C->Width - 1; vp = (__u16 *)((__u16)(y * C->Width) << 1); if ((unsigned int)y < MaxRow) { @@ -178,8 +178,8 @@ static void ScrollUp(register Console * C, int y) static void ScrollDown(register Console * C, int y) { __u16 *vp; - unsigned short MaxRow = C->Height - 1; - unsigned short MaxCol = C->Width - 1; + int MaxRow = C->Height - 1; + int MaxCol = C->Width - 1; int yy = MaxRow; vp = (__u16 *)((__u16)(yy * C->Width) << 1); @@ -221,7 +221,7 @@ struct tty_ops dircon_ops = { void INITPROC console_init(void) { - Console *C; + Console *C = &Con[0]; int i; unsigned PageSizeW; @@ -233,7 +233,6 @@ void INITPROC console_init(void) AttributeSeg = 0xE200; } - C = Con; C->Width = 80; C->Height = 25; diff --git a/elks/arch/i86/drivers/char/console-direct.c b/elks/arch/i86/drivers/char/console-direct.c index 8b7459d46..31e467634 100644 --- a/elks/arch/i86/drivers/char/console-direct.c +++ b/elks/arch/i86/drivers/char/console-direct.c @@ -53,16 +53,15 @@ struct console; typedef struct console Console; struct console { + int Width, Height; int cx, cy; /* cursor position */ - void (*fsm)(Console *, int); unsigned char display; unsigned char type; unsigned char attr; /* current attribute */ unsigned char XN; /* delayed newline on column 80 */ + void (*fsm)(Console *, int); unsigned int vseg; /* vram for this console page */ - int vseg_offset; /* vram offset of vseg for this console page */ - unsigned short Width; - unsigned short Height; + unsigned int vseg_offset; /* vram offset of vseg for this console page */ unsigned short crtc_base; /* 6845 CRTC base I/O address */ #ifdef CONFIG_EMUL_ANSI int savex, savey; /* saved cursor position */ @@ -77,8 +76,8 @@ static Console *Visible[MAX_DISPLAYS]; static Console Con[MAX_CONSOLES]; static int NumConsoles; +unsigned int VideoSeg = 0xb800; int Current_VCminor; -unsigned VideoSeg; int kraw; #ifdef CONFIG_EMUL_ANSI @@ -128,7 +127,7 @@ static void VideoWrite(register Console * C, int c) static void ClearRange(register Console * C, int x, int y, int x2, int y2) { - register int vp; + int vp; x2 = x2 - x + 1; vp = (x + y * C->Width) << 1; @@ -143,9 +142,9 @@ static void ClearRange(register Console * C, int x, int y, int x2, int y2) static void ScrollUp(register Console * C, int y) { - register int vp; - unsigned short MaxRow = C->Height - 1; - unsigned short MaxCol = C->Width - 1; + int vp; + int MaxRow = C->Height - 1; + int MaxCol = C->Width - 1; vp = y * (C->Width << 1); if ((unsigned int)y < MaxRow) @@ -157,7 +156,7 @@ static void ScrollUp(register Console * C, int y) #ifdef CONFIG_EMUL_ANSI static void ScrollDown(register Console * C, int y) { - register int vp; + int vp; int yy = C->Height - 1; vp = yy * (C->Width << 1); @@ -202,24 +201,19 @@ struct tty_ops dircon_ops = { #ifndef CONFIG_CONSOLE_DUAL void INITPROC console_init(void) { - Console *C; - unsigned char output_type; - unsigned short boot_crtc; + Console *C = &Con[0]; int i; int Width, Height; unsigned int PageSizeW; - - output_type = OT_EGA; - C = &Con[0]; + unsigned short boot_crtc; + unsigned char output_type = OT_EGA; Width = peekb(0x4a, 0x40); /* BIOS data segment */ - /* Trust this. Cga does not support peeking at 0x40:0x84. */ Height = 25; boot_crtc = peekw(0x63, 0x40); PageSizeW = ((unsigned int)peekw(0x4C, 0x40) >> 1); - VideoSeg = 0xb800; NumConsoles = MAX_CONSOLES - 1; if (peekb(0x49, 0x40) == 7) { VideoSeg = 0xB000; @@ -264,22 +258,34 @@ void INITPROC console_init(void) kbd_name, Width, Height, NumConsoles); } #else + +#ifdef DEBUG +static const char *type_string[] = { + "MDA", + "CGA", + "EGA", + "VGA", +}; +#endif + void INITPROC console_init(void) { - Console *C; + Console *C = &Con[0]; int i, j, dev; + int screens = 0; unsigned short boot_crtc; - unsigned char boot_type; - unsigned char screens = 0; unsigned char cur_display = 0; - boot_crtc = peekw(0x63, 0x40); - for (i = 0; i < N_DEVICETYPES; ++i) - if (crtc_params[i].crtc_base == boot_crtc) boot_type = i; + unsigned char boot_type; - C = &Con[0]; + boot_crtc = peekw(0x63, 0x40); + for (i = 0; i < N_DEVICETYPES; ++i) { + if (crtc_params[i].crtc_base == boot_crtc) + boot_type = i; + } for (i = 0; i < N_DEVICETYPES; ++i) { dev = (i + boot_type) % N_DEVICETYPES; - if (!crtc_probe(crtc_params[dev].crtc_base)) continue; + if (!crtc_probe(crtc_params[dev].crtc_base)) + continue; screens++; crtc_init(dev); for (j = 0; j < crtc_params[dev].max_pages; ++j) { @@ -312,9 +318,10 @@ void INITPROC console_init(void) VideoSeg = Visible[0]->vseg; kbd_init(); - printk("Direct console %s kbd"TERM_TYPE"(%d screens, %i consoles)\n", kbd_name, screens, NumConsoles); + printk("Direct console %s kbd"TERM_TYPE"(%d screens, %d consoles)\n", + kbd_name, screens, NumConsoles); for (i = 0; i < NumConsoles; ++i) { - debug("/dev/tty%i, %s, %ux%u\n", i + 1, type_string[Con[i].type], Con[i].Width, Con[i].Height); + debug("/dev/tty%d, %s, %ux%u\n", i + 1, type_string[Con[i].type], Con[i].Width, Con[i].Height); } } #endif diff --git a/elks/arch/i86/drivers/char/console.c b/elks/arch/i86/drivers/char/console.c index cd20028c4..22b1e991d 100644 --- a/elks/arch/i86/drivers/char/console.c +++ b/elks/arch/i86/drivers/char/console.c @@ -23,7 +23,7 @@ void Console_conout(dev_t dev, int Ch) void Console_conin(unsigned char Key) { - register struct tty *ttyp = &ttys[Current_VCminor]; + struct tty *ttyp = &ttys[Current_VCminor]; if (!tty_intcheck(ttyp, Key)) chq_addch(&ttyp->inq, Key); @@ -32,9 +32,9 @@ void Console_conin(unsigned char Key) #ifdef CONFIG_EMUL_ANSI static void Console_gotoxy(register Console * C, int x, int y) { - register int xp = x; - unsigned short MaxRow = C->Height - 1; - unsigned short MaxCol = C->Width - 1; + int xp = x; + int MaxRow = C->Height - 1; + int MaxCol = C->Width - 1; C->cx = (xp >= MaxCol) ? MaxCol : (xp < 0) ? 0 : xp; xp = y; @@ -82,8 +82,8 @@ static unsigned char ega_color[16] = { 0, 4, 2, 6, 1, 5, 3, 7, static void AnsiCmd(register Console * C, int c) { int n; - unsigned short MaxRow = C->Height - 1; - unsigned short MaxCol = C->Width - 1; + int MaxRow = C->Height - 1; + int MaxCol = C->Width - 1; /* ANSI param gathering and processing */ if (C->parmptr < &C->params[MAXPARMS - 1]) @@ -254,8 +254,9 @@ static void esc_char(register Console * C, int c) /* Normal character processing */ static void std_char(register Console * C, int c) { - unsigned short MaxRow = C->Height - 1; - unsigned short MaxCol = C->Width - 1; + int MaxRow = C->Height - 1; + int MaxCol = C->Width - 1; + switch(c) { case BEL: bell(); @@ -319,7 +320,7 @@ static void std_char(register Console * C, int c) static int Console_ioctl(struct tty *tty, int cmd, char *arg) { - register Console *C = &Con[tty->minor]; + Console *C = &Con[tty->minor]; switch (cmd) { case DCGET_GRAPH: @@ -367,7 +368,7 @@ static int Console_ioctl(struct tty *tty, int cmd, char *arg) static int Console_write(register struct tty *tty) { - register Console *C = &Con[tty->minor]; + Console *C = &Con[tty->minor]; int cnt = 0; while ((tty->outq.len > 0) && !glock) { diff --git a/elks/arch/i86/drivers/char/crtc-6845.c b/elks/arch/i86/drivers/char/crtc-6845.c index abdd0cfe1..c1b98f46e 100644 --- a/elks/arch/i86/drivers/char/crtc-6845.c +++ b/elks/arch/i86/drivers/char/crtc-6845.c @@ -21,31 +21,55 @@ #define CRTC_CSEL 0x5 #define CRTC_STAT 0x6 +struct hw_params crtc_params[N_DEVICETYPES] = { + { 80, 25, 0x3B4, 0xB000, 0x1000, 2000, 1, 16, /* MDA */ + { + 0x61, 0x50, 0x52, 0x0F, + 0x19, 0x06, 0x19, 0x19, + 0x02, 0x0D, 0x0B, 0x0C, + 0x00, 0x00, 0x00, 0x00, + } + }, + { 80, 25, 0x3D4, 0xB800, 0x4000, 2000, 3, 16, /* CGA */ + { + /* CO80 */ + 0x71, 0x50, 0x5A, 0x0A, + 0x1F, 0x06, 0x19, 0x1C, + 0x02, 0x07, 0x06, 0x07, + 0x00, 0x00, 0x00, 0x00, + } + } + /* EGA (TODO) */ +}; + /* Check to see if this CRTC is present */ int INITPROC crtc_probe(unsigned short crtc_base) { int i; unsigned char test = 0x55; + unsigned char original, value; + /* We'll try writing a value to cursor address LSB reg (0x0F), then reading it back */ outb(0x0F, crtc_base + CRTC_INDX); - unsigned char original = inb(crtc_base + CRTC_DATA); - if (original == test) test += 0x10; + original = inb(crtc_base + CRTC_DATA); + if (original == test) + test += 0x10; outb(0x0F, crtc_base + CRTC_INDX); - outb(test, crtc_base + CRTC_DATA); - /* Now wait a bit */ - for (i = 0; i < 100; ++i) {} // TODO: Verify this doesn't get optimized out + outb_p(test, crtc_base + CRTC_DATA); outb(0x0F, crtc_base + CRTC_INDX); - unsigned char value = inb(crtc_base + CRTC_DATA); - if (value != test) return 0; + value = inb(crtc_base + CRTC_DATA); + if (value != test) + return 0; outb(0x0F, crtc_base + CRTC_INDX); outb(original, crtc_base + CRTC_DATA); return 1; } -int INITPROC crtc_init(unsigned int t) +void INITPROC crtc_init(int dev) { int i; - struct hw_params *p = &crtc_params[t]; + struct hw_params *p = &crtc_params[dev]; + /* Set 80x25 mode, video off */ outb(0x01, p->crtc_base + CRTC_MODE); /* Program CRTC regs */ @@ -54,16 +78,16 @@ int INITPROC crtc_init(unsigned int t) outb(p->init_bytes[i], p->crtc_base + CRTC_DATA); } - /* Check & clear vram */ + /* Clear vram */ +#if 0 //FIXME remove: return value never checked, useless code for (i = 0; i < p->vseg_bytes; i += 2) pokew(i, p->vseg_base, 0x5555); for (i = 0; i < p->vseg_bytes; i += 2) if (peekw(i, p->vseg_base) != 0x5555) return 1; +#endif for (i = 0; i < p->vseg_bytes; i += 2) - pokew(i, p->vseg_base, 0x7 << 8 | ' '); + pokew(i, p->vseg_base, 0x07 << 8 | ' '); /* Enable video */ outb(0x09, p->crtc_base + CRTC_MODE); - return 0; } - diff --git a/elks/arch/i86/drivers/char/crtc-6845.h b/elks/arch/i86/drivers/char/crtc-6845.h index 216c594f0..e9042410b 100644 --- a/elks/arch/i86/drivers/char/crtc-6845.h +++ b/elks/arch/i86/drivers/char/crtc-6845.h @@ -5,51 +5,16 @@ #define N_DEVICETYPES 2 -#ifdef DEBUG -static const char *type_string[] = { - "MDA", - "CGA", - "EGA", - "VGA", -}; -#endif - struct hw_params { - unsigned short w; - unsigned short h; + int w; + int h; unsigned short crtc_base; - unsigned vseg_base; + unsigned short vseg_base; int vseg_bytes; - unsigned char max_pages; unsigned short page_words; + unsigned char max_pages; unsigned char n_init_bytes; unsigned char init_bytes[16]; }; -#ifdef CONFIG_CONSOLE_DUAL -static struct hw_params crtc_params[N_DEVICETYPES] = { - { 80, 25, 0x3B4, 0xB000, 0x1000, 1, 2000, 16, - { - 0x61, 0x50, 0x52, 0x0F, - 0x19, 0x06, 0x19, 0x19, - 0x02, 0x0D, 0x0B, 0x0C, - 0x00, 0x00, 0x00, 0x00, - } - }, /* MDA */ - { 80, 25, 0x3D4, 0xB800, 0x4000, 3, 2000, 16, - { - /* CO80 */ - 0x71, 0x50, 0x5A, 0x0A, - 0x1F, 0x06, 0x19, 0x1C, - 0x02, 0x07, 0x06, 0x07, - 0x00, 0x00, 0x00, 0x00, - } - }, /* CGA */ - // TODO - //{ 0 }, /* EGA */ - //{ 0 }, /* VGA */ -}; - -int INITPROC crtc_probe(unsigned short crtc_base); -int INITPROC crtc_init(unsigned int t); -#endif +extern struct hw_params crtc_params[N_DEVICETYPES]; diff --git a/elks/include/linuxmt/init.h b/elks/include/linuxmt/init.h index d606be425..1a1e0a817 100644 --- a/elks/include/linuxmt/init.h +++ b/elks/include/linuxmt/init.h @@ -65,6 +65,9 @@ extern void INITPROC meta_init(void); extern void INITPROC pty_init(void); extern void INITPROC tcpdev_init(void); +extern int INITPROC crtc_probe(unsigned short crtc_base); +extern void INITPROC crtc_init(int dev); + extern void kfork_proc(void (*addr)()); extern void arch_setup_user_stack(struct task_struct *, word_t entry); diff --git a/elks/include/linuxmt/ntty.h b/elks/include/linuxmt/ntty.h index c918d0a05..7ee573739 100644 --- a/elks/include/linuxmt/ntty.h +++ b/elks/include/linuxmt/ntty.h @@ -23,7 +23,11 @@ /* Predefined maximum number of tty character devices */ +#ifdef CONFIG_CONSOLE_DUAL #define MAX_CONSOLES 4 +#else +#define MAX_CONSOLES 3 +#endif #define MAX_PTYS 4 #define TTY_MINOR_OFFSET 0 diff --git a/elkscmd/rootfs_template/bin/sys b/elkscmd/rootfs_template/bin/sys index b13a0dbea..7f78d6af2 100755 --- a/elkscmd/rootfs_template/bin/sys +++ b/elkscmd/rootfs_template/bin/sys @@ -54,7 +54,6 @@ create_dev_dir() mknod $MNT/dev/rd1 b 1 1 mknod $MNT/dev/tty2 c 4 1 mknod $MNT/dev/tty3 c 4 2 - mknod $MNT/dev/tty4 c 4 3 mknod $MNT/dev/ttyS2 c 4 66 mknod $MNT/dev/ttyS3 c 4 67 mknod $MNT/dev/ttyp1 c 4 9