From fad180960fbec05b38ac0a3644f13c8701b64895 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Thu, 12 May 2005 16:03:43 +0000 Subject: [PATCH] added code to un-register tty's interrupt at exit time; fixed compiler warnings --- drivers/tty/keyboard.c | 5 +++-- drivers/tty/pty.c | 16 ++++++++-------- drivers/tty/tty.c | 7 +++++++ drivers/tty/tty.h | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index a8bf03aa1..5aaacced7 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -18,6 +18,8 @@ #include "../../kernel/kernel.h" #include "../../kernel/proc.h" +int irq_hook_id = -1; + /* Standard and AT keyboard. (PS/2 MCA implies AT throughout.) */ #define KEYBD 0x60 /* I/O port for keyboard data */ @@ -363,7 +365,6 @@ tty_t *tp; { /* Initialize the keyboard driver. */ static int count = 0; - int irq_hook_id; int i; tp->tty_devread = kb_read; /* input function */ @@ -381,7 +382,7 @@ tty_t *tp; /* Set interrupt handler and enable keyboard IRQ. */ if ((i=sys_irqsetpolicy(KEYBOARD_IRQ, IRQ_REENABLE, &irq_hook_id)) != OK) - server_panic("TTY", "Couldn't set keyboard IRQ policy", i); + server_panic("TTY", "Couldn't set keyboard IRQ policy", i); if ((i=sys_irqenable(&irq_hook_id)) != OK) server_panic("TTY", "Couldn't enable keyboard IRQs", i); } diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index def5b1453..e5e74ef1c 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -100,7 +100,7 @@ message *m_ptr; if (numap_local(m_ptr->PROC_NR, (vir_bytes) m_ptr->ADDRESS, m_ptr->COUNT) == 0) { #else - if ((r = sys_umap(m_ptr->PROC_NR, D, m_ptr->ADDRESS, + if ((r = sys_umap(m_ptr->PROC_NR, D, (vir_bytes) m_ptr->ADDRESS, m_ptr->COUNT, &p)) != OK) { #endif break; @@ -142,7 +142,7 @@ message *m_ptr; m_ptr->COUNT) == 0) { r = EFAULT; #else - if ((r = sys_umap(m_ptr->PROC_NR, D, m_ptr->ADDRESS, + if ((r = sys_umap(m_ptr->PROC_NR, D, (vir_bytes) m_ptr->ADDRESS, m_ptr->COUNT, &p)) != OK) { #endif break; @@ -234,8 +234,8 @@ tty_t *tp; user_phys = proc_vir2phys(proc_addr(tp->tty_outproc), tp->tty_out_vir); phys_copy(user_phys, vir2phys(pp->ohead), (phys_bytes) count); #else - if((s = sys_vircopy(tp->tty_outproc, D, tp->tty_out_vir, - SELF, D, pp->ohead, (phys_bytes) count)) != OK) { + if((s = sys_vircopy(tp->tty_outproc, D, (vir_bytes) tp->tty_out_vir, + SELF, D, (vir_bytes) pp->ohead, (phys_bytes) count)) != OK) { printf("pty tty%d: copy failed (error %d)\n", s); break; } @@ -314,8 +314,8 @@ pty_t *pp; user_phys = proc_vir2phys(proc_addr(pp->rdproc), pp->rdvir); phys_copy(vir2phys(pp->otail), user_phys, (phys_bytes) count); #endif - if((s = sys_vircopy(SELF, D, pp->otail, - pp->rdproc, D, pp->rdvir, (phys_bytes) count)) != OK) { + if((s = sys_vircopy(SELF, D, (vir_bytes)pp->otail, + (vir_bytes) pp->rdproc, D, (vir_bytes) pp->rdvir, (phys_bytes) count)) != OK) { printf("pty tty%d: copy failed (error %d)\n", s); break; } @@ -376,8 +376,8 @@ tty_t *tp; user_phys = proc_vir2phys(proc_addr(pp->wrproc), pp->wrvir); phys_copy(user_phys, vir2phys(&c), 1L); #endif - if((s = sys_vircopy(pp->wrproc, D, pp->wrvir, - SELF, D, &c, (phys_bytes) 1)) != OK) { + if((s = sys_vircopy(pp->wrproc, D, (vir_bytes) pp->wrvir, + SELF, D, (vir_bytes) &c, (phys_bytes) 1)) != OK) { printf("pty: copy failed (error %d)\n", s); break; } diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 77ab6ad4e..03b527077 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -66,6 +66,8 @@ #endif #include "tty.h" +extern int irq_hook_id; + /* Address of a tty structure. */ #define tty_addr(line) (&tty_table[line]) @@ -204,6 +206,11 @@ PUBLIC void main(void) if (! stop++) { cons_stop(); /* first switch to primary console */ } else { + if(irq_hook_id != -1) { + int r; + r = sys_irqdisable(&irq_hook_id); + r = sys_irqrmpolicy(KEYBOARD_IRQ, &irq_hook_id); + } printf("[DONE]\n"); printf("MINIX will now be shutdown.\n"); sys_exit(0); /* then exit TTY */ diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index f28b4930e..d931cb4fa 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -75,6 +75,7 @@ typedef struct tty { /* Memory allocated in tty.c, so extern here. */ extern tty_t tty_table[NR_CONS+NR_RS_LINES+NR_PTYS]; extern int ccurrent; /* currently visible console */ +extern int irq_hook_id; /* hook id for keyboard irq */ /* Values for the fields. */ #define NOT_ESCAPED 0 /* previous character is not LNEXT (^V) */ -- 2.44.0