kern

changeset 35:06172322fb76

- made interrupt number - irq mapping macros public in intr.h - disabled the interrupts in various vga driver functions
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 09 Jun 2011 05:09:49 +0300
parents 17433fcaa563
children e70b1ab9613e
files src/intr.c src/intr.h src/term.c src/timer.c src/vid.c
diffstat 5 files changed, 26 insertions(+), 14 deletions(-) [+]
line diff
     1.1 --- a/src/intr.c	Thu Jun 09 02:45:49 2011 +0300
     1.2 +++ b/src/intr.c	Thu Jun 09 05:09:49 2011 +0300
     1.3 @@ -12,14 +12,6 @@
     1.4  #define GATE_DEFAULT	(1 << 11)
     1.5  #define GATE_PRESENT	(1 << 15)
     1.6  
     1.7 -/* offset used to remap IRQ numbers (+32) */
     1.8 -#define IRQ_OFFSET		32
     1.9 -/* conversion macros between IRQ and interrupt numbers */
    1.10 -#define IRQ_TO_INTR(x)	((x) + IRQ_OFFSET)
    1.11 -#define INTR_TO_IRQ(x)	((x) - IRQ_OFFSET)
    1.12 -/* checks whether a particular interrupt is an remapped IRQ */
    1.13 -#define IS_IRQ(n)	((n) >= IRQ_OFFSET && (n) < IRQ_OFFSET + 16)
    1.14 -
    1.15  /* PIC command and data ports */
    1.16  #define PIC1_CMD	0x20
    1.17  #define PIC1_DATA	0x21
     2.1 --- a/src/intr.h	Thu Jun 09 02:45:49 2011 +0300
     2.2 +++ b/src/intr.h	Thu Jun 09 05:09:49 2011 +0300
     2.3 @@ -4,6 +4,15 @@
     2.4  #include <inttypes.h>
     2.5  #include "asmops.h"
     2.6  
     2.7 +/* offset used to remap IRQ numbers (+32) */
     2.8 +#define IRQ_OFFSET		32
     2.9 +/* conversion macros between IRQ and interrupt numbers */
    2.10 +#define IRQ_TO_INTR(x)	((x) + IRQ_OFFSET)
    2.11 +#define INTR_TO_IRQ(x)	((x) - IRQ_OFFSET)
    2.12 +/* checks whether a particular interrupt is an remapped IRQ */
    2.13 +#define IS_IRQ(n)	((n) >= IRQ_OFFSET && (n) < IRQ_OFFSET + 16)
    2.14 +
    2.15 +
    2.16  typedef void (*intr_func_t)(int, uint32_t);
    2.17  
    2.18  
     3.1 --- a/src/term.c	Thu Jun 09 02:45:49 2011 +0300
     3.2 +++ b/src/term.c	Thu Jun 09 05:09:49 2011 +0300
     3.3 @@ -29,7 +29,6 @@
     3.4  
     3.5  /* output a single character, handles formatting, cursor advancement
     3.6   * and scrolling the screen when we reach the bottom.
     3.7 - * TODO make visible cursor actually move.
     3.8   */
     3.9  int putchar(int c)
    3.10  {
     4.1 --- a/src/timer.c	Thu Jun 09 02:45:49 2011 +0300
     4.2 +++ b/src/timer.c	Thu Jun 09 05:09:49 2011 +0300
     4.3 @@ -57,10 +57,8 @@
     4.4  	outb(reload_count & 0xff, PORT_DATA0);
     4.5  	outb((reload_count >> 8) & 0xff, PORT_DATA0);
     4.6  
     4.7 -	nticks = 0;
     4.8 -
     4.9  	/* set the timer interrupt handler */
    4.10 -	interrupt(32, intr_handler);
    4.11 +	interrupt(IRQ_TO_INTR(0), intr_handler);
    4.12  }
    4.13  
    4.14  /* This will be called by the interrupt dispatcher approximately
     5.1 --- a/src/vid.c	Thu Jun 09 02:45:49 2011 +0300
     5.2 +++ b/src/vid.c	Thu Jun 09 05:09:49 2011 +0300
     5.3 @@ -1,5 +1,6 @@
     5.4  #include <string.h>
     5.5  #include "vid.h"
     5.6 +#include "intr.h"
     5.7  #include "asmops.h"
     5.8  
     5.9  /* height of our virtual console text buffer */
    5.10 @@ -27,10 +28,15 @@
    5.11  
    5.12  void clear_scr(void)
    5.13  {
    5.14 +	int istate = get_intr_state();
    5.15 +	disable_intr();
    5.16 +
    5.17  	memset16(vmem, VMEM_CHAR(' ', LTGRAY, BLACK), WIDTH * HEIGHT);
    5.18  	start_line = 0;
    5.19  	set_start_line(0);
    5.20  	set_cursor(0, 0);
    5.21 +
    5.22 +	set_intr_state(istate);
    5.23  }
    5.24  
    5.25  void set_char(char c, int x, int y, int fg, int bg)
    5.26 @@ -41,6 +47,8 @@
    5.27  void set_cursor(int x, int y)
    5.28  {
    5.29  	int loc;
    5.30 +	int istate = get_intr_state();
    5.31 +	disable_intr();
    5.32  
    5.33  	if(x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT) {
    5.34  		loc = 0xffff;
    5.35 @@ -52,10 +60,15 @@
    5.36  	outb(loc, CRTC_DATA);
    5.37  	outb(CRTC_CURSOR_HIGH, CRTC_ADDR);
    5.38  	outb(loc >> 8, CRTC_DATA);
    5.39 +
    5.40 +	set_intr_state(istate);
    5.41  }
    5.42  
    5.43  void scroll_scr(void)
    5.44  {
    5.45 +	int new_line, istate = get_intr_state();
    5.46 +	disable_intr();
    5.47 +
    5.48  	if(++start_line > VIRT_HEIGHT - HEIGHT) {
    5.49  		/* The bottom of the visible range reached the end of our text buffer.
    5.50  		 * Copy the rest of the lines to the top and reset start_line.
    5.51 @@ -65,10 +78,11 @@
    5.52  	}
    5.53  
    5.54  	/* clear the next line that will be revealed by scrolling */
    5.55 -	int new_line = start_line + HEIGHT - 1;
    5.56 +	new_line = start_line + HEIGHT - 1;
    5.57  	memset16(vmem + new_line * WIDTH, VMEM_CHAR(' ', LTGRAY, BLACK), WIDTH);
    5.58 +	set_start_line(start_line);
    5.59  
    5.60 -	set_start_line(start_line);
    5.61 +	set_intr_state(istate);
    5.62  }
    5.63  
    5.64  static void set_start_line(int line)