[PATCH 1 of 6]

Juan Perez-Sanchez <[email protected]>
Newsgroups org.kernel.vger.linux-8086
Message-ID <CAD6VGub7eGQD2iaVJEM=4=4cfOD7nnqq8Lbm17502bv4vHZwvg@mail.gmail.com>
Hi,

Attached is a patch to:

 A small modification to reduce interrupt latency time.

 Code cleanup in file arch/i86/kernel/irqtab.c.

 Code size reduced by 16 bytes.

 The Image builded without errors. The kernel was tested with QEMU and
dioscuri emulators. Also in a PPro pc booting from floppy.

Greetings,

Juan
elksU.patch (application/octet-stream, 5.2 KB)
diff -Nurb elks.orig/arch/i86/kernel/irq.c elks/arch/i86/kernel/irq.c
--- elks.orig/arch/i86/kernel/irq.c	2012-12-11 23:26:18.000000000 -0600
+++ elks/arch/i86/kernel/irq.c	2013-02-06 21:19:48.000000000 -0600
@@ -33,7 +33,21 @@
 	void *dev_id;
 };
 
-static struct irqaction irq_action[32];
+static void default_handler(int i, void *regs, void *dev);
+
+static struct irqaction irq_action[32] = {
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL}, {default_handler, NULL},
+    {default_handler, NULL}, {default_handler, NULL},
+};
 
 unsigned char cache_21 = 0xff, cache_A1 = 0xff;
 
@@ -122,9 +136,11 @@
 {
     register struct irqaction *irq = irq_action + i;
 
-    if (irq->handler != NULL)
-	irq->handler(i,regs,irq->dev_id);
-    else
+    irq->handler(i, regs, irq->dev_id);
+}
+
+static void default_handler(int i, void *regs, void *dev)
+{
 	if(i > 15)
 	    printk("Unexpected trap: %u\n", i-16);
 	else
@@ -175,7 +191,7 @@
 	return -EINVAL;
 		
     action = irq_action + irq;
-    if (action->handler)
+    if (action->handler != default_handler)
 	return -EBUSY;
 
     if (!handler)
@@ -205,7 +221,7 @@
 	printk("Trying to free IRQ%u\n",irq);
 	return;
     }
-    if (!action->handler) {
+    if (action->handler == default_handler) {
 	printk("Trying to free free IRQ%u\n",irq);
 	return;
     }
@@ -214,7 +230,7 @@
 
     disable_irq(irq);
 
-    action->handler = NULL;
+    action->handler = default_handler;
     action->dev_id = NULL;
 /*    action->flags = 0;
     action->name = NULL;*/
diff -Nurb elks.orig/arch/i86/kernel/irqtab.c elks/arch/i86/kernel/irqtab.c
--- elks.orig/arch/i86/kernel/irqtab.c	2012-12-11 23:26:18.000000000 -0600
+++ elks/arch/i86/kernel/irqtab.c	2013-02-06 21:11:13.000000000 -0600
@@ -2,6 +2,10 @@
 #include <arch/asm-offsets.h>
 #include <linuxmt/config.h>
 
+static int bios_call_cnt_l = 5;
+static long stashed_irq0_l;
+int intr_count = 0;
+
 /*
  *	Easy way to store our kernel DS
  */
@@ -17,18 +21,15 @@
 /  the offset is constant per #define
 /-------------------------------------------------------*/
 
-   #define SEG_IRQ_DATA es
    #define stashed_ds       [0]
 
 #else
- #define SEG_IRQ_DATA cs
 
 #ifndef S_SPLINT_S
 #asm
+        .text
         .globl stashed_ds
-
         .even
-
 stashed_ds:
 	.word	0
 
@@ -45,72 +46,57 @@
 #asm
 
 ; CS points to this kernel code segment
-; ES points to page 0  (interrupt table)
-; DS points to the kernel data segment
+; DS points to page 0  (interrupt table)
+; ES points to the kernel data segment
 
         cli
         
+        mov bx,ds
 #ifdef CONFIG_ROMCODE
         mov ax,#CONFIG_ROM_IRQ_DATA
-        mov es,ax
+        mov ds,ax
+#else
+        seg cs
 #endif        
-        
-        seg SEG_IRQ_DATA
-	mov stashed_ds,ds
-	mov bios_call_cnt_l,#5
-        mov _intr_count,#0
+        mov stashed_ds,bx
+        mov es,bx
 
         xor ax,ax
-        mov es,ax      ;intr table
+        mov ds,ax      ;intr table
 
-	seg es
 	mov ax,[32]
-	mov off_stashed_irq0_l, ax   ; the old timer intr
 	seg es
+        mov _stashed_irq0_l, ax  ; the old timer intr
 	mov ax,[34]
-	mov seg_stashed_irq0_l, ax
-
 	seg es
+        mov [_stashed_irq0_l+2], ax
+
 	mov [32],#_irq0   ;timer
-	seg es
 	mov [34],cs
 
 #ifndef CONFIG_CONSOLE_BIOS
-	seg es
         mov [36],#_irq1   ;keyboard
-	seg es
         mov [38],cs
 #endif
 
 #if 0	
-	lea ax,_irq2
-	seg es
-	mov [40],ax
-	mov ax,cs
-	seg es
-	mov [42],ax
+        mov [40],#_irq2
+        mov [42],cs
 #endif	
 
-	seg es
         mov [44],#_irq3   ;com2
-	seg es
         mov [46],cs
 	
-	seg es
 	mov [48],#_irq4   ;com1
-	seg es
 	mov [50],cs
 	
 
 ! Setup INT 0x80 (for syscall)
-	seg es
 	mov [512],#_syscall_int
-	seg es
 	mov [514],cs
 ! Tidy up
 
-        mov dx,ds      ;the original value
-        mov es,dx      ;just here
+        mov ds,bx      ;the original value just here
 	sti
         
 #endasm
@@ -468,11 +454,11 @@
 !
 !        IRQ 0 (timer) has to go on to the bios for some systems
 !
-        dec     bios_call_cnt_l	! Will call bios int?
+        dec     _bios_call_cnt_l ! Will call bios int?
         jne     a4
-        mov     bios_call_cnt_l,#5
+        mov     _bios_call_cnt_l,#5
         pushf
-        callf   [off_stashed_irq0_l]
+        callf   [_stashed_irq0_l]
         jmp     was_trap
 a4:
         cmp     ax,#8
@@ -552,17 +538,7 @@
 	iret
 
 	.data
-        .globl  _intr_count
-_intr_count:
-        .word 0
-
-off_stashed_irq0_l:
-	.word	0
-seg_stashed_irq0_l:
-	.word	0
-bios_call_cnt_l:
-	.word	0
-
+        .even
 	.zerow	256		! (was) 128 byte interrupt stack
 _intstack:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.