[PATCH 5/5] Removal of inline assembly in several functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Removed inline assembly in function run_init_process() in file
arch/i86/kernel/process.c

Function setup_mm() in file arch/i86/mm/init.c gets memory
parameters from its caller instead of determining them again.
(These were already determined by function start_kernel()).

file arch/i86/kernel/timer.c converted to all C file.

Code size was reduced by 112 bytes.

Juan
diff -Nur elks.orig/arch/i86/kernel/process.c elks/arch/i86/kernel/process.c
--- elks.orig/arch/i86/kernel/process.c	2015-05-13 13:18:43.000000000 -0500
+++ elks/arch/i86/kernel/process.c	2015-05-08 16:57:38.000000000 -0500
@@ -19,9 +19,9 @@
 #asm
 
     .text
-  
+
 /*
- *  This code is either in code segment or CONFIG_ROM_IRQ_DATA 
+ *  This code is either in code segment or CONFIG_ROM_IRQ_DATA
  *  The CS-Code must always be placed in irqtab.c, because the
  *  linker doesnt store them in block.
  */
@@ -222,21 +222,11 @@
     *pip++ = 0;
     *pip++ = (unsigned short int) &ar[6];
     *pip++ = 0;
-    if(num = sys_execve(cmd, ar, 18)) {
-	printk("sys_execve(\"%s\", args, 18) => %d.\n", cmd, -num);
-	return num;
+    if(!(num = sys_execve(cmd, ar, 18))) {
+	ret_from_syscall();
     }
-#ifndef S_SPLINT_S
-    /* Brackets round the following code are required as a work around
-     * for a bug in the compiler which causes it to jump past the asm
-     * code if they are not there.
-     */
-    {
-#asm
-        br  _ret_from_syscall
-#endasm
-    }
-#endif
+    printk("sys_execve(\"%s\", args, 18) => %d.\n", cmd, -num);
+    return num;
 }
 
 /*
@@ -382,8 +372,6 @@
  * registers suitably for
  */
 
-extern void ret_from_syscall();		/* our return address */
-
 void arch_build_stack(struct task_struct *t, char *addr)
 {
     register __u16 *tsp = (__u16 *)(t->t_kstack + KSTACK_BYTES - 10);
diff -Nur elks.orig/arch/i86/kernel/system.c elks/arch/i86/kernel/system.c
--- elks.orig/arch/i86/kernel/system.c	2015-05-13 13:18:43.000000000 -0500
+++ elks/arch/i86/kernel/system.c	2015-05-10 12:34:01.000000000 -0500
@@ -8,7 +8,9 @@
 #include <arch/segment.h>
 
 int arch_cpu;			/* Processor type */
+#ifdef CONFIG_ARCH_SIBO
 extern long int basmem;
+#endif
 
 /* Stubs for functions needed elsewhere */
 
@@ -41,6 +43,10 @@
  *	Fill in the MM numbers - really ought to be in mm not kernel ?
  */
 
+/*
+ *      This computes the 640K - _endbss
+ */
+
 #ifndef CONFIG_ARCH_SIBO
 
     *end = (seg_t)(setupw(0x2a) << 6 - RAM_REDUCE);
diff -Nur elks.orig/arch/i86/kernel/timer.c elks/arch/i86/kernel/timer.c
--- elks.orig/arch/i86/kernel/timer.c	2015-04-26 11:39:15.000000000 -0500
+++ elks/arch/i86/kernel/timer.c	2015-05-12 00:02:37.000000000 -0500
@@ -1,8 +1,10 @@
 #include <linuxmt/config.h>
+#include <linuxmt/mm.h>
 #include <linuxmt/timer.h>
 #include <linuxmt/timex.h>
 
 #include <arch/io.h>
+#include <arch/irq.h>
 
 /*
  *	Timer tick routine
@@ -49,18 +51,8 @@
 
 #ifndef CONFIG_ARCH_SIBO
 
-#ifndef S_SPLINT_S
 #if 0
-#asm
-	! rotate the 20th character on the 3rd screen line
-	push es
-	mov ax,#0xb80a
-	mov es,ax
-	seg es
-	inc 40
-	pop es
-#endasm
-#endif
+    pokew(0xb80a, 40, peekw(0xb80a, 40)+1);
 #endif
 
 #ifdef CONFIG_DEBUG_TIMER
@@ -69,19 +61,14 @@
 
 #else
 
-	/* As we are now responsible for clearing interrupt */
-#ifndef S_SPLINT_S
-#asm
-	cli
-	mov ax, #0x0000
-
-	out 0x0a, al
-	out 0x0c, al
-	
-	out 0x10, al
-	sti
-#endasm
-#endif
+    /* As we are now responsible for clearing interrupt */
+    clr_irq();
+
+    outb(0x0, 0x0A);
+    outb(0x0, 0x0C);
+    outb(0x0, 0x10);
+
+    set_irq();
 
     keyboard_irq(1, regs, NULL);
 
diff -Nur elks.orig/arch/i86/mm/init.c elks/arch/i86/mm/init.c
--- elks.orig/arch/i86/mm/init.c	2015-05-13 13:18:43.000000000 -0500
+++ elks/arch/i86/mm/init.c	2015-05-12 00:56:03.000000000 -0500
@@ -28,14 +28,13 @@
 char cpuid[17], proc_name[17];
 __u16 kernel_cs, kernel_ds;
 
-void setup_mm(void)
+void setup_mm(seg_t start, seg_t end)
 {
-    long memstart, memend;
     register char *pi;
-    __u16 basemem = setupw(0x2a);
 #ifdef CONFIG_XMS
     __u16 xms = setupw(2);		/* Fetched by boot code */
 #endif
+
     pi = 0;
     do {
 	proc_name[(int)pi] = setupb(0x30 + (int)pi);
@@ -45,19 +44,19 @@
 
 #ifdef CONFIG_ARCH_SIBO
 
-    printk("Psion Series 3a machine, %s CPU\n%dK base"
+    printk("Psion Series 3a machine, %s CPU\n%uK base"
 	   ", CPUID `NEC V30'",
 	   proc_name, basemem, cpuid);
 
 #else
 
-    printk("PC/%cT class machine, %s CPU\n%dK base RAM",
-	   arch_cpu > 5 ? 'A' : 'X', proc_name, basemem);
+    printk("PC/%cT class machine, %s CPU\n%uK base RAM",
+	   arch_cpu > 5 ? 'A' : 'X', proc_name, setupw(0x2a));
 #ifdef CONFIG_XMS
     if (arch_cpu < 6)
 	xms = 0;		/* XT bios hasn't got xms interrupt */
     else
-	printk(", %dK extended memory (XMS)", xms);
+	printk(", %uK extended memory (XMS)", xms);
 #endif
     if (*cpuid)
 	printk(", CPUID `%s'", cpuid);
@@ -70,25 +69,8 @@
 	   (unsigned)_endbss - (unsigned)_enddata,
 	   kernel_cs, kernel_ds);
 
-    /*
-     *      This computes the 640K - _endbss
-     */
-
-#ifdef CONFIG_ARCH_SIBO
-
-    memend = ((long) basemem) << 10;
-
-#else
-
-    memend = (((long) basemem) << 10L) - (RAM_REDUCE << 4L);
-
-#endif
-
-    memstart = ((long) kernel_ds) << 4;
-    memstart += (unsigned int) _endbss + 15;
-
-    printk("%d K of memory for user processes.\n",
-	   (int) ((memend - memstart) >> 10));
+    printk("%u K of memory for user processes.\n",
+	   (int) ((end - start) >> 6));
 
     if (setupb(0x1ff) == 0xAA && arch_cpu > 5)
 	printk("ps2: PS/2 pointing device detected\n");
diff -Nur elks.orig/arch/i86/mm/Makefile elks/arch/i86/mm/Makefile
--- elks.orig/arch/i86/mm/Makefile	2015-05-13 13:56:39.000000000 -0500
+++ elks/arch/i86/mm/Makefile	2015-05-10 23:28:41.000000000 -0500
@@ -17,15 +17,15 @@
 
 USEBCC 		= Y
 
-CLEANDEP	= 
+CLEANDEP	=
 
-CLEANME 	= 
+CLEANME 	=
 
-DEPEND  	= 
+DEPEND  	=
 
-DISTFILES	= 
+DISTFILES	=
 
-NOINDENT	= segment.c user.c
+NOINDENT	= user.c
 
 #########################################################################
 # Include the standard commands.
@@ -35,7 +35,7 @@
 #########################################################################
 # Objects to be compiled.
 
-OBJS  = init.o segment.o malloc.o user.o
+OBJS  = init.o malloc.o user.o
 
 #########################################################################
 # Commands.
diff -Nur elks.orig/arch/i86/mm/malloc.c elks/arch/i86/mm/malloc.c
--- elks.orig/arch/i86/mm/malloc.c	2015-04-26 11:39:15.000000000 -0500
+++ elks/arch/i86/mm/malloc.c	2015-05-09 00:27:02.000000000 -0500
@@ -455,7 +455,7 @@
         return -ENOMEM;
     if (currentp->t_begstack > currentp->t_endbrk)
         if(len > currentp->t_endseg - 0x1000) {
-		printk("sys_brk failed: len %d > endseg %d\n", len, (currentp->t_endseg - 0x1000));
+		printk("sys_brk failed: len %u > endseg %u\n", len, (currentp->t_endseg - 0x1000));
             return -ENOMEM;
 	}
 
diff -Nur elks.orig/arch/i86/sibo/crt1.c elks/arch/i86/sibo/crt1.c
--- elks.orig/arch/i86/sibo/crt1.c	2015-04-26 11:39:15.000000000 -0500
+++ elks/arch/i86/sibo/crt1.c	2015-05-10 23:21:32.000000000 -0500
@@ -5,7 +5,7 @@
 #include <arch/segment.h>
  
 extern char proc_name[15] = "Series 3a";
-extern long int basmem = 512;
+long int basmem = 512;
 
 void arch_boot(void)
 {
diff -Nur elks.orig/include/arch/io.h elks/include/arch/io.h
--- elks.orig/include/arch/io.h	2015-04-26 11:39:15.000000000 -0500
+++ elks/include/arch/io.h	2015-05-08 15:46:38.000000000 -0500
@@ -1,6 +1,7 @@
 #ifndef LX86_ARCH_IO_H
 #define LX86_ARCH_IO_H
 
+#ifdef __BCC__
 extern void outb(unsigned char, void *);
 extern void outb_p(unsigned char, void *);
 extern void outw(unsigned short int, void *);
@@ -13,5 +14,61 @@
 extern unsigned short int inw_p(void *);
 
 extern void bell(void);
+#endif
+
+#ifdef __WATCOMC__
+extern void outb(unsigned char value, void *port);
+#pragma aux outb = \
+    "out dx,al"    \
+    parm [al] [dx];
+
+extern void outb_p(unsigned char value, void *port);
+#pragma aux outb_p = \
+    "in  al,80h"   \
+    "mov al,ah"    \
+    "out dx,al"    \
+    parm [ah] [dx] \
+    modify [al];
+
+extern void outw(unsigned short int value, void *port);
+#pragma aux outb = \
+    "out dx,ax"    \
+    parm [ax] [dx];
+
+extern void outw_p(unsigned short int value, void *port);
+#pragma aux outb_p = \
+    "push ax"       \
+    "in   al,80h"   \
+    "pop  ax"       \
+    "out  dx,ax"    \
+    parm [ax] [dx];
+
+extern unsigned char inb(void *port);
+#pragma aux outb = \
+    "in  al,dx"    \
+    value [al]     \
+    parm [dx];
+
+extern unsigned char inb_p(void *port);
+#pragma aux outb_p = \
+    "in  al,80h"   \
+    "in  al,dx"    \
+    value [al]     \
+    parm [dx];
+
+extern unsigned short int inw(void *port);
+#pragma aux outb = \
+    "in  ax,dx"    \
+    value [ax]     \
+    parm [dx];
+
+extern unsigned short int inw_p(void *port);
+#pragma aux outb_p = \
+    "in  al,80h"   \
+    "in  ax,dx"    \
+    value [ax]     \
+    parm [dx];
+
+#endif
 
 #endif
diff -Nur elks.orig/include/linuxmt/init.h elks/include/linuxmt/init.h
--- elks.orig/include/linuxmt/init.h	2015-04-26 11:39:15.000000000 -0500
+++ elks/include/linuxmt/init.h	2015-05-10 12:26:07.000000000 -0500
@@ -32,7 +32,7 @@
 extern void xtk_init(void);
 
 extern void init_console(void);
-extern void setup_mm(void);
+extern void setup_mm(seg_t,seg_t);
 extern void device_setup(void);
 
 extern void kfork_proc(void ());
diff -Nur elks.orig/init/main.c elks/init/main.c
--- elks.orig/init/main.c	2015-05-13 13:37:11.000000000 -0500
+++ elks/init/main.c	2015-05-10 12:26:56.000000000 -0500
@@ -51,7 +51,7 @@
     calibrate_delay();
 #endif
 
-    setup_mm();			/* Architecture specifics */
+    setup_mm(base, end);		/* Architecture specifics */
     tty_init();
     buffer_init();
 

[Index of Archives]     [Kernel]     [Linux ia64]     [DCCP]     [Linux for ARM]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux