From 7abf49d2f22af633f2fb3546f9f9fd818cef25df Mon Sep 17 00:00:00 2001 From: kaashoek Date: Sun, 3 Sep 2006 15:39:29 +0000 Subject: [PATCH] remove duplication don't use the same name for two different pieces of code --- asm.h | 4 ++-- bootasm.S | 6 +++--- bootother.S | 6 +++--- console.c | 1 + ide.c | 1 + picirq.c | 1 + traps.h | 2 ++ x86.h | 9 --------- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/asm.h b/asm.h index b5fca66..c9d7c1d 100644 --- a/asm.h +++ b/asm.h @@ -2,10 +2,10 @@ // macros to create x86 segments from assembler // -#define SEG_NULL \ +#define SEG_NULLASM \ .word 0, 0; \ .byte 0, 0, 0, 0 -#define SEG(type,base,lim) \ +#define SEG_ASM(type,base,lim) \ .word (((lim) >> 12) & 0xffff), ((base) & 0xffff); \ .byte (((base) >> 16) & 0xff), (0x90 | (type)), \ (0xC0 | (((lim) >> 28) & 0xf)), (((base) >> 24) & 0xff) diff --git a/bootasm.S b/bootasm.S index c2a3c3e..f776b83 100644 --- a/bootasm.S +++ b/bootasm.S @@ -87,9 +87,9 @@ spin: jmp spin # ..but in case it does, spin .p2align 2 # force 4 byte alignment gdt: - SEG_NULL # null seg - SEG(STA_X|STA_R, 0x0, 0xffffffff) # code seg - SEG(STA_W, 0x0, 0xffffffff) # data seg + SEG_NULLASM # null seg + SEG_ASM(STA_X|STA_R, 0x0, 0xffffffff) # code seg + SEG_ASM(STA_W, 0x0, 0xffffffff) # data seg gdtdesc: .word 0x17 # sizeof(gdt) - 1 diff --git a/bootother.S b/bootother.S index 2bdfdb2..99e4713 100644 --- a/bootother.S +++ b/bootother.S @@ -70,9 +70,9 @@ protcseg: .p2align 2 # force 4 byte alignment gdt: - SEG_NULL # null seg - SEG(STA_X|STA_R, 0x0, 0xffffffff) # code seg - SEG(STA_W, 0x0, 0xffffffff) # data seg + SEG_NULLASM # null seg + SEG_ASM(STA_X|STA_R, 0x0, 0xffffffff) # code seg + SEG_ASM(STA_W, 0x0, 0xffffffff) # data seg gdtdesc: .word 0x17 # sizeof(gdt) - 1 diff --git a/console.c b/console.c index 803a896..1a64122 100644 --- a/console.c +++ b/console.c @@ -1,5 +1,6 @@ #include "types.h" #include "x86.h" +#include "traps.h" #include "defs.h" #include "spinlock.h" #include "dev.h" diff --git a/ide.c b/ide.c index b999786..dfbc605 100644 --- a/ide.c +++ b/ide.c @@ -8,6 +8,7 @@ #include "proc.h" #include "defs.h" #include "x86.h" +#include "traps.h" #include "spinlock.h" #define IDE_BSY 0x80 diff --git a/picirq.c b/picirq.c index ab3e7b9..86d1d1d 100644 --- a/picirq.c +++ b/picirq.c @@ -2,6 +2,7 @@ #include "types.h" #include "x86.h" +#include "traps.h" #include "defs.h" // I/O Addresses of the two 8259A programmable interrupt controllers diff --git a/traps.h b/traps.h index 4b2d368..d093be0 100644 --- a/traps.h +++ b/traps.h @@ -27,6 +27,8 @@ #define IRQ_OFFSET 32 // IRQ 0 corresponds to int IRQ_OFFSET +#define IRQ_KBD 1 +#define IRQ_IDE 14 #define IRQ_TIMER 18 #define IRQ_ERROR 19 #define IRQ_SPURIOUS 31 diff --git a/x86.h b/x86.h index 7d3452d..f9e2261 100644 --- a/x86.h +++ b/x86.h @@ -151,12 +151,3 @@ struct trapframe { ushort ss; ushort padding4; }; - -#define MAX_IRQS 16 // Number of IRQs - -#define IRQ_OFFSET 32 // IRQ 0 corresponds to int IRQ_OFFSET - -#define IRQ_KBD 1 -#define IRQ_IDE 14 -#define IRQ_ERROR 19 -#define IRQ_SPURIOUS 31