# HG changeset patch # User John Tsiombikas # Date 1307585389 -10800 # Node ID 06172322fb76d319b4b5307b27cdb5b5d803df97 # Parent 17433fcaa563a77c946ecc34dcf987cc822fa093 - made interrupt number - irq mapping macros public in intr.h - disabled the interrupts in various vga driver functions diff -r 17433fcaa563 -r 06172322fb76 src/intr.c --- a/src/intr.c Thu Jun 09 02:45:49 2011 +0300 +++ b/src/intr.c Thu Jun 09 05:09:49 2011 +0300 @@ -12,14 +12,6 @@ #define GATE_DEFAULT (1 << 11) #define GATE_PRESENT (1 << 15) -/* offset used to remap IRQ numbers (+32) */ -#define IRQ_OFFSET 32 -/* conversion macros between IRQ and interrupt numbers */ -#define IRQ_TO_INTR(x) ((x) + IRQ_OFFSET) -#define INTR_TO_IRQ(x) ((x) - IRQ_OFFSET) -/* checks whether a particular interrupt is an remapped IRQ */ -#define IS_IRQ(n) ((n) >= IRQ_OFFSET && (n) < IRQ_OFFSET + 16) - /* PIC command and data ports */ #define PIC1_CMD 0x20 #define PIC1_DATA 0x21 diff -r 17433fcaa563 -r 06172322fb76 src/intr.h --- a/src/intr.h Thu Jun 09 02:45:49 2011 +0300 +++ b/src/intr.h Thu Jun 09 05:09:49 2011 +0300 @@ -4,6 +4,15 @@ #include #include "asmops.h" +/* offset used to remap IRQ numbers (+32) */ +#define IRQ_OFFSET 32 +/* conversion macros between IRQ and interrupt numbers */ +#define IRQ_TO_INTR(x) ((x) + IRQ_OFFSET) +#define INTR_TO_IRQ(x) ((x) - IRQ_OFFSET) +/* checks whether a particular interrupt is an remapped IRQ */ +#define IS_IRQ(n) ((n) >= IRQ_OFFSET && (n) < IRQ_OFFSET + 16) + + typedef void (*intr_func_t)(int, uint32_t); diff -r 17433fcaa563 -r 06172322fb76 src/term.c --- a/src/term.c Thu Jun 09 02:45:49 2011 +0300 +++ b/src/term.c Thu Jun 09 05:09:49 2011 +0300 @@ -29,7 +29,6 @@ /* output a single character, handles formatting, cursor advancement * and scrolling the screen when we reach the bottom. - * TODO make visible cursor actually move. */ int putchar(int c) { diff -r 17433fcaa563 -r 06172322fb76 src/timer.c --- a/src/timer.c Thu Jun 09 02:45:49 2011 +0300 +++ b/src/timer.c Thu Jun 09 05:09:49 2011 +0300 @@ -57,10 +57,8 @@ outb(reload_count & 0xff, PORT_DATA0); outb((reload_count >> 8) & 0xff, PORT_DATA0); - nticks = 0; - /* set the timer interrupt handler */ - interrupt(32, intr_handler); + interrupt(IRQ_TO_INTR(0), intr_handler); } /* This will be called by the interrupt dispatcher approximately diff -r 17433fcaa563 -r 06172322fb76 src/vid.c --- a/src/vid.c Thu Jun 09 02:45:49 2011 +0300 +++ b/src/vid.c Thu Jun 09 05:09:49 2011 +0300 @@ -1,5 +1,6 @@ #include #include "vid.h" +#include "intr.h" #include "asmops.h" /* height of our virtual console text buffer */ @@ -27,10 +28,15 @@ void clear_scr(void) { + int istate = get_intr_state(); + disable_intr(); + memset16(vmem, VMEM_CHAR(' ', LTGRAY, BLACK), WIDTH * HEIGHT); start_line = 0; set_start_line(0); set_cursor(0, 0); + + set_intr_state(istate); } void set_char(char c, int x, int y, int fg, int bg) @@ -41,6 +47,8 @@ void set_cursor(int x, int y) { int loc; + int istate = get_intr_state(); + disable_intr(); if(x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT) { loc = 0xffff; @@ -52,10 +60,15 @@ outb(loc, CRTC_DATA); outb(CRTC_CURSOR_HIGH, CRTC_ADDR); outb(loc >> 8, CRTC_DATA); + + set_intr_state(istate); } void scroll_scr(void) { + int new_line, istate = get_intr_state(); + disable_intr(); + if(++start_line > VIRT_HEIGHT - HEIGHT) { /* The bottom of the visible range reached the end of our text buffer. * Copy the rest of the lines to the top and reset start_line. @@ -65,10 +78,11 @@ } /* clear the next line that will be revealed by scrolling */ - int new_line = start_line + HEIGHT - 1; + new_line = start_line + HEIGHT - 1; memset16(vmem + new_line * WIDTH, VMEM_CHAR(' ', LTGRAY, BLACK), WIDTH); + set_start_line(start_line); - set_start_line(start_line); + set_intr_state(istate); } static void set_start_line(int line)