patch-2.4.0-test3 linux/drivers/char/console.c
Next file: linux/drivers/char/drm/proc.c
Previous file: linux/drivers/char/Makefile
Back to the patch index
Back to the overall index
- Lines: 185
- Date:
Thu Jul 6 20:12:54 2000
- Orig file:
v2.4.0-test2/linux/drivers/char/console.c
- Orig date:
Fri Jun 23 21:55:08 2000
diff -u --recursive --new-file v2.4.0-test2/linux/drivers/char/console.c linux/drivers/char/console.c
@@ -66,6 +66,9 @@
*
* Resurrected character buffers in videoram plus lots of other trickery
* by Martin Mares <mj@atrey.karlin.mff.cuni.cz>, July 1998
+ *
+ * Removed old-style timers, introduced console_timer, made timer
+ * deletion SMP-safe. 17Jun00, Andrew Morton <andrewm@uow.edu.au>
*/
#include <linux/module.h>
@@ -139,7 +142,7 @@
static int con_open(struct tty_struct *, struct file *);
static void vc_init(unsigned int console, unsigned int rows,
unsigned int cols, int do_clear);
-static void blank_screen(void);
+static void blank_screen(unsigned long dummy);
static void gotoxy(int currcons, int new_x, int new_y);
static void save_cur(int currcons);
static void reset_terminal(int currcons, int do_clear);
@@ -147,6 +150,7 @@
static void set_vesa_blanking(unsigned long arg);
static void set_cursor(int currcons);
static void hide_cursor(int currcons);
+static void unblank_screen_t(unsigned long dummy);
static int printable = 0; /* Is console ready for printing? */
@@ -196,6 +200,8 @@
*/
int (*console_blank_hook)(int) = NULL;
+static struct timer_list console_timer;
+
/*
* Low-Level Functions
*/
@@ -581,10 +587,11 @@
if (redraw) {
set_origin(currcons);
- set_palette(currcons);
- if (sw->con_switch(vc_cons[currcons].d) && vcmode != KD_GRAPHICS)
+ if (sw->con_switch(vc_cons[currcons].d) && vcmode != KD_GRAPHICS) {
/* Update the screen contents */
+ set_palette(currcons);
do_update_region(currcons, origin, screenbuf_size/2);
+ }
}
set_cursor(currcons);
if (is_switch) {
@@ -2417,19 +2424,16 @@
if (tty_register_driver(&console_driver))
panic("Couldn't register console driver\n");
- timer_table[BLANK_TIMER].fn = blank_screen;
- timer_table[BLANK_TIMER].expires = 0;
+ init_timer(&console_timer);
+ console_timer.function = blank_screen;
if (blankinterval) {
- timer_table[BLANK_TIMER].expires = jiffies + blankinterval;
- timer_active |= 1<<BLANK_TIMER;
+ mod_timer(&console_timer, jiffies + blankinterval);
}
/*
* kmalloc is not running yet - we use the bootmem allocator.
*/
for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
- int j, k ;
-
vc_cons[currcons].d = (struct vc_data *)
alloc_bootmem(sizeof(struct vc_data));
vt_cons[currcons] = (struct vt_struct *)
@@ -2439,11 +2443,6 @@
kmalloced = 0;
vc_init(currcons, video_num_lines, video_num_columns,
currcons || !sw->con_save_screen);
- for (j=k=0; j<16; j++) {
- vc_cons[currcons].d->vc_palette[k++] = default_red[j] ;
- vc_cons[currcons].d->vc_palette[k++] = default_grn[j] ;
- vc_cons[currcons].d->vc_palette[k++] = default_blu[j] ;
- }
}
currcons = fg_console = 0;
master_display_fg = vc_cons[currcons].d;
@@ -2589,15 +2588,14 @@
}
}
-static void vesa_powerdown_screen(void)
+static void vesa_powerdown_screen(unsigned long dummy)
{
- timer_active &= ~(1<<BLANK_TIMER);
- timer_table[BLANK_TIMER].fn = unblank_screen;
+ console_timer.function = unblank_screen_t; /* I don't have a clue why this is necessary */
vesa_powerdown();
}
-void do_blank_screen(int entering_gfx)
+static void timer_do_blank_screen(int entering_gfx, int from_timer_handler)
{
int currcons = fg_console;
int i;
@@ -2622,13 +2620,15 @@
}
hide_cursor(currcons);
+ if (!from_timer_handler)
+ del_timer_sync(&console_timer);
if (vesa_off_interval) {
- timer_table[BLANK_TIMER].fn = vesa_powerdown_screen;
- timer_table[BLANK_TIMER].expires = jiffies + vesa_off_interval;
- timer_active |= (1<<BLANK_TIMER);
+ console_timer.function = vesa_powerdown_screen;
+ mod_timer(&console_timer, jiffies + vesa_off_interval);
} else {
- timer_active &= ~(1<<BLANK_TIMER);
- timer_table[BLANK_TIMER].fn = unblank_screen;
+ if (!from_timer_handler)
+ del_timer_sync(&console_timer);
+ console_timer.function = unblank_screen_t;
}
save_screen(currcons);
@@ -2644,6 +2644,16 @@
sw->con_blank(vc_cons[currcons].d, vesa_blank_mode + 1);
}
+void do_blank_screen(int entering_gfx)
+{
+ timer_do_blank_screen(entering_gfx, 0);
+}
+
+static void unblank_screen_t(unsigned long dummy)
+{
+ unblank_screen();
+}
+
void unblank_screen(void)
{
int currcons;
@@ -2655,10 +2665,9 @@
printk("unblank_screen: tty %d not allocated ??\n", fg_console+1);
return;
}
- timer_table[BLANK_TIMER].fn = blank_screen;
+ console_timer.function = blank_screen;
if (blankinterval) {
- timer_table[BLANK_TIMER].expires = jiffies + blankinterval;
- timer_active |= 1<<BLANK_TIMER;
+ mod_timer(&console_timer, jiffies + blankinterval);
}
currcons = fg_console;
@@ -2671,23 +2680,21 @@
set_cursor(fg_console);
}
-static void blank_screen(void)
+static void blank_screen(unsigned long dummy)
{
- do_blank_screen(0);
+ timer_do_blank_screen(0, 1);
}
void poke_blanked_console(void)
{
- timer_active &= ~(1<<BLANK_TIMER);
+ del_timer(&console_timer); /* Can't use _sync here: called from tasklet */
if (vt_cons[fg_console]->vc_mode == KD_GRAPHICS)
return;
if (console_blanked) {
- timer_table[BLANK_TIMER].fn = unblank_screen;
- timer_table[BLANK_TIMER].expires = jiffies; /* Now */
- timer_active |= 1<<BLANK_TIMER;
+ console_timer.function = unblank_screen_t;
+ mod_timer(&console_timer, jiffies); /* Now */
} else if (blankinterval) {
- timer_table[BLANK_TIMER].expires = jiffies + blankinterval;
- timer_active |= 1<<BLANK_TIMER;
+ mod_timer(&console_timer, jiffies + blankinterval);
}
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)