2001-11-29 00:13:03

by James Simmons

[permalink] [raw]
Subject: [PATCH] vc_tty addition


These patches seem trival but they are very important for my new console
lock patch coming soon. Basically I have made the console lock more finer
grain. Each individual console is locked instead of all consoles when
printk is called. Their is no reason to block the serial console when say
the printk is currently writting to the VT console. This small patch is
the first step toward that. Also tusing vc_tty will be needed in
keyboard.c when it handles more than one keyboard.

diff -urN linux-2.5.0/drivers/char/console.c linux/drivers/char/console.c
--- linux-2.5.0/drivers/char/console.c Tue Nov 27 11:56:43 2001
+++ linux/drivers/char/console.c Wed Nov 28 16:24:54 2001
@@ -2377,6 +2377,7 @@

vt_cons[currcons]->vc_num = currcons;
tty->driver_data = vt_cons[currcons];
+ vc_cons[currcons].d->vc_tty = tty;

if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
tty->winsize.ws_row = video_num_lines;
diff -urN linux-2.5.0/drivers/char/keyboard.c linux/drivers/char/keyboard.c
--- linux-2.5.0/drivers/char/keyboard.c Tue Nov 27 11:56:43 2001
+++ linux/drivers/char/keyboard.c Wed Nov 28 16:30:31 2001
@@ -36,6 +36,7 @@
#include <asm/keyboard.h>
#include <asm/bitops.h>

+#include <linux/console_struct.h>
#include <linux/kbd_kern.h>
#include <linux/kbd_diacr.h>
#include <linux/vt_kern.h>
@@ -98,7 +99,6 @@
static unsigned char diacr;
static char rep; /* flag telling character repeat */
struct kbd_struct kbd_table[MAX_NR_CONSOLES];
-static struct tty_struct **ttytab;
static struct kbd_struct * kbd = kbd_table;
static struct tty_struct * tty;

@@ -207,7 +207,8 @@
pm_access(pm_kbd);
add_keyboard_randomness(scancode | up_flag);

- tty = ttytab? ttytab[fg_console]: NULL;
+ tty = vc_cons[fg_console].d->vc_tty;
+
if (tty && (!tty->driver_data)) {
/*
* We touch the tty structure via the ttytab array
@@ -919,7 +920,6 @@
{
int i;
struct kbd_struct kbd0;
- extern struct tty_driver console_driver;

kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS;
kbd0.ledmode = LED_SHOW_FLAGS;
@@ -930,8 +930,6 @@

for (i = 0 ; i < MAX_NR_CONSOLES ; i++)
kbd_table[i] = kbd0;
-
- ttytab = console_driver.table;

kbd_init_hw();

diff -urN linux-2.5.0/include/linux/console_struct.h linux/include/linux/console_struct.h
--- linux-2.5.0/include/linux/console_struct.h Tue Nov 27 11:56:33 2001
+++ linux/include/linux/console_struct.h Wed Nov 28 16:21:51 2001
@@ -33,6 +33,7 @@
unsigned int vc_top, vc_bottom; /* Scrolling region */
unsigned int vc_state; /* Escape sequence parser state */
unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
+ struct tty_struct *vc_tty; /* TTY we are attached to */
unsigned long vc_origin; /* [!] Start of real screen */
unsigned long vc_scr_end; /* [!] End of real screen */
unsigned long vc_visible_origin; /* [!] Top of visible window */


2001-11-29 00:17:53

by Alan

[permalink] [raw]
Subject: Re: [PATCH] vc_tty addition

> the printk is currently writting to the VT console. This small patch is
> the first step toward that. Also tusing vc_tty will be needed in
> keyboard.c when it handles more than one keyboard.

What happens when you have no tty bound to your console - and its just for
messages (eg the printer port console) ?

2001-11-29 00:40:13

by James Simmons

[permalink] [raw]
Subject: Re: [PATCH] vc_tty addition


> > the printk is currently writting to the VT console. This small patch is
> > the first step toward that. Also tusing vc_tty will be needed in
> > keyboard.c when it handles more than one keyboard.
>
> What happens when you have no tty bound to your console - and its just for
> messages (eg the printer port console) ?

What? What happens when you open /dev/console then? The tty layer
redirects the console to some tty normally.

If this is the case then I will do it the way I started out. Having the
lock in struct console and sharing it with the tty layer. I was thinking
about a tty_driver just for the struct console list anyways. Currently
accessing /dev/console only effects the first console in the list instead
of all of them. If this is true then that means /dev/consoel can exist
without /dev/tty which could be a good thing.


2001-11-29 00:45:33

by James Simmons

[permalink] [raw]
Subject: Re: [PATCH] vc_tty addition


> > accessing /dev/console only effects the first console in the list instead
> > of all of them. If this is true then that means /dev/consoel can exist
> > without /dev/tty which could be a good thing.
>
> Currently the "console" doesn't need to include a tty device - if its only
> being hit with printk output.

Then should we make TTY console aka /dev/console support a option?


2001-11-29 00:44:33

by Alan

[permalink] [raw]
Subject: Re: [PATCH] vc_tty addition

> accessing /dev/console only effects the first console in the list instead
> of all of them. If this is true then that means /dev/consoel can exist
> without /dev/tty which could be a good thing.

Currently the "console" doesn't need to include a tty device - if its only
being hit with printk output.