[PATCH 4 of 5]

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

 



Hi,

This patch makes:

-Some functions still used peek*/poke* to access userspace. Those
were replaced by architecture neutral get_user_*/put_user_*.

-Unused functions peekd, pokeb, poked, get_bp, get_sp were removed.
Files for the first 3 functions remain in the source tree, together
with many other unused files. Unused variables "end" (in function
stack_check), "arch_segs", "marker" (in file sleepwake.c) and code
to initialize their never used contents was removed

-Messages for printing startup errors were moved from init_task()
to a single print statement in function run_init_process().

-Code size was reduced by 160 bytes and data reduced by 124 bytes.

Greetings,

Juan
diff -Nur elks.orig/arch/i86/drivers/char/ntty.c elks/arch/i86/drivers/char/ntty.c
--- elks.orig/arch/i86/drivers/char/ntty.c	2014-04-26 22:12:31.000000000 -0500
+++ elks/arch/i86/drivers/char/ntty.c	2014-10-14 12:03:22.000000000 -0500
@@ -175,7 +175,7 @@
     pi = (char *)len;
     while ((int)(pi--)) {
 	tty_charout(tty,
-	   (unsigned char) peekb(current->t_regs.ds, (__u16)(data++))
+	    get_user_char((void *)(data++))
 	   /* , blocking */ );
     }
     return len;
@@ -207,12 +207,12 @@
 	    if (!rawmode && (j == 04))	/* CTRL-D */
 		break;
 	    if (rawmode || (j != '\b')) {
-		pokeb(current->t_regs.ds, (__u16) (data + ((int)pi)), ch);
+		put_user_char(ch, (void *)(data++));
 		++pi;
 		tty_echo(tty, ch);
 	    } else if (((int)pi) > 0) {
 		--pi;
-		k = ((peekb(current->t_regs.ds, (__u16) (data + ((int)pi)))
+		k = ((get_user_char((void *)(data++))
 		      == '\t') ? TAB_SPACES : 1);
 		do {
 		    tty_echo(tty, ch);
@@ -248,10 +248,10 @@
 	if (!rawmode && (j == 04))	/* CTRL-D */
 	    break;
 	if (rawmode || (j != '\b')) {
-	    pokeb(current->t_regs.ds, (__u16) (data + i++), ch);
+	    put_user_char(ch, (void *)(data + i++));
 	    tty_echo(tty, ch);
 	} else if (i > 0) {
-	    lch = ((peekb(current->t_regs.ds, (__u16) (data + --i)) == '\t')
+	    lch = ((get_user_char((void *)(data + --i)) == '\t')
 			? TAB_SPACES : 1);
 	    for (k = 0; k < lch; k++)
 		tty_echo(tty, ch);
diff -Nur elks.orig/arch/i86/drivers/char/pty.c elks/arch/i86/drivers/char/pty.c
--- elks.orig/arch/i86/drivers/char/pty.c	2014-04-26 22:12:31.000000000 -0500
+++ elks/arch/i86/drivers/char/pty.c	2014-10-14 12:03:22.000000000 -0500
@@ -110,7 +110,7 @@
 	    } else
 		break;
 	debug2(" rc[%u,%u]", (int)pi, len);
-	pokeb(current->t_regs.ds, (__u16) (data + ((int)pi)), ch);
+	put_user_char(ch, (void *)(data++));
 	++pi;
     }
     debug1("{%u}\n", (int)pi);
@@ -132,7 +132,7 @@
     l = (file->f_flags & O_NONBLOCK) ? 0 : 1;
     pi = 0;
     while (((int)pi) < len) {
-	ch = (unsigned char) peekb(current->t_regs.ds, (__u16) (data + ((int)pi)));
+	ch = get_user_char((void *)(data++));
 	if (chq_addch(&tty->inq, ch, l) == -1)
 	    if (l) {
 		debug("failed: INTR\n");
diff -Nur elks.orig/arch/i86/kernel/process.c elks/arch/i86/kernel/process.c
--- elks.orig/arch/i86/kernel/process.c	2014-10-14 11:28:39.000000000 -0500
+++ elks/arch/i86/kernel/process.c	2014-10-14 12:13:50.000000000 -0500
@@ -222,8 +222,10 @@
     *pip++ = 0;
     *pip++ = (unsigned short int) &ar[6];
     *pip++ = 0;
-    if(num = sys_execve(cmd, ar, 18))
+    if(num = sys_execve(cmd, ar, 18)) {
+	printk("sys_execve(\"%s\", args, 18) => %d.\n", cmd, -num);
 	return num;
+    }
 #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
@@ -244,16 +246,17 @@
 void stack_check(void)
 {
     register __ptask currentp = current;
-    register segext_t end;
+/*    register segext_t end;*/ /* Unused variable "end" */
+
     if ((currentp->t_begstack > currentp->t_enddata) &&
 	(currentp->t_regs.sp < currentp->t_endbrk)) {
-	end = currentp->t_endbrk;
+/*	end = currentp->t_endbrk;*/
 	goto stack_overflow;
     }
-#ifdef CONFIG_EXEC_ELKS 
-    else if (currentp->t_regs.sp > currentp->t_endseg){
-        end = 0xffff;
-	goto stack_overflow; 
+#ifdef CONFIG_EXEC_ELKS
+    else if(currentp->t_regs.sp > currentp->t_endseg) {
+/*        end = 0xffff;*/
+	goto stack_overflow;
     }
 #endif
     return;
diff -Nur elks.orig/arch/i86/kernel/system.c elks/arch/i86/kernel/system.c
--- elks.orig/arch/i86/kernel/system.c	2014-10-14 11:28:39.000000000 -0500
+++ elks/arch/i86/kernel/system.c	2014-10-14 12:03:22.000000000 -0500
@@ -7,7 +7,6 @@
 
 #include <arch/segment.h>
 
-__arch_mminit arch_segs;
 int arch_cpu;			/* Processor type */
 extern long int basmem;
 
@@ -28,29 +27,6 @@
 
 void setup_arch(seg_t *start, seg_t *end)
 {
-#ifndef S_SPLINT_S
-/*
- *	Save segments
- */
-#asm
-	mov bx, #_arch_segs
-        mov [bx], cs
-	mov [bx+2], di
-        mov [bx+8], ss
-	mov [bx+6], si
-
-!	This is out of order to save a segment load and a few bytes :)
-
-        mov [bx+4], ds
-	mov [bx+10], dx
-
-!	mov ds, ax
-
-#endasm
-#endif
-
-    arch_segs.lowss = arch_segs.endss;
-
 #ifdef CONFIG_COMPAQ_FAST
 
 /*
diff -Nur elks.orig/arch/i86/lib/Makefile elks/arch/i86/lib/Makefile
--- elks.orig/arch/i86/lib/Makefile	2014-10-14 11:34:03.000000000 -0500
+++ elks/arch/i86/lib/Makefile	2014-10-14 12:03:22.000000000 -0500
@@ -38,7 +38,7 @@
 # miscellaneous
 
 JOBJS		=inport.o inportb.o outport.o outportb.o \
-		 peekb.o peekw.o peekd.o pokeb.o pokew.o poked.o bitops.o \
+		 peekb.o peekw.o pokew.o bitops.o \
 		 memmove.o string.o fmemset.o border.o
 #		 ntohl.o ntohs.o
 
diff -Nur elks.orig/arch/i86/mm/segment.c elks/arch/i86/mm/segment.c
--- elks.orig/arch/i86/mm/segment.c	2014-04-26 22:12:31.000000000 -0500
+++ elks/arch/i86/mm/segment.c	2014-10-14 12:03:22.000000000 -0500
@@ -1,23 +1,17 @@
 /*
  *	Fetch segment registers
- */ 
+ */
 
 #include <arch/segment.h>
 
 #ifndef S_SPLINT_S
 #asm
 
-	.globl  _get_bp
 	.globl	_get_cs
 	.globl	_get_ds
 	.globl	_get_es
-	.globl  _get_sp
 	.globl	_get_ss
 
-_get_bp:
-	mov 	ax, bp
-	ret
-
 _get_cs:
 	mov	ax, cs
 	ret
@@ -30,10 +24,6 @@
 	mov	ax, es
 	ret
 
-_get_sp:
-	mov	ax, sp
-	ret
-
 _get_ss:
 	mov	ax, ss
 	ret
diff -Nur elks.orig/arch/i86/mm/user.c elks/arch/i86/mm/user.c
--- elks.orig/arch/i86/mm/user.c	2014-04-26 22:12:31.000000000 -0500
+++ elks/arch/i86/mm/user.c	2014-10-14 12:03:22.000000000 -0500
@@ -233,7 +233,7 @@
     int c = 0;
 
     while (len-- && !c)
-	c = peekb(current->t_regs.ds, (__u16) p1++) - *p2++;
+	c = get_user_char((void *)(p1++)) - *p2++;
 
     return c;
 }
diff -Nur elks.orig/include/arch/segment.h elks/include/arch/segment.h
--- elks.orig/include/arch/segment.h	2014-04-26 22:12:31.000000000 -0500
+++ elks/include/arch/segment.h	2014-10-14 12:03:22.000000000 -0500
@@ -6,7 +6,6 @@
 #if 1
 
 extern __u16 get_cs(void), get_ds(void), get_es(void), get_ss(void);
-extern __u16 get_bp(void);
 
 #else
 
@@ -16,7 +15,6 @@
 #define get_ds()	asm("mov ax,ds")
 #define get_es()	asm("mov ax,es")
 #define get_ss()	asm("mov ax,ss")
-#define get_bp()	asm("mov ax,bp")
 
 #endif
 
diff -Nur elks.orig/include/arch/types.h elks/include/arch/types.h
--- elks.orig/include/arch/types.h	2014-04-26 22:12:31.000000000 -0500
+++ elks/include/arch/types.h	2014-10-14 12:03:22.000000000 -0500
@@ -40,15 +40,6 @@
 
 typedef __u16			__pptr;
 
-struct _mminit {
-    __u16	cs, endcs,
-		ds, endds,
-		ss, endss,
-		    lowss;
-};
-
-typedef struct _mminit		__arch_mminit, *__parch_mminit;
-
 /*@+namechecks@*/
 
 #ifndef NULL
diff -Nur elks.orig/include/linuxmt/mm.h elks/include/linuxmt/mm.h
--- elks.orig/include/linuxmt/mm.h	2014-04-26 22:12:31.000000000 -0500
+++ elks/include/linuxmt/mm.h	2014-10-14 12:03:22.000000000 -0500
@@ -49,13 +49,10 @@
 extern int do_swapper_run(struct task_struct *);
 extern unsigned int mm_get_usage(int,int);
 
-extern void pokeb(__u16,__u16,__u8);
 extern void pokew(__u16,__u16,__u16);
-extern void poked(__u16,__u16,__u32);
 
 extern __u8  peekb(__u16,__u16);
 extern __u16 peekw(__u16,__u16);
-extern __u32 peekd(__u16,__u16);
 
 extern void fmemcpy(__u16,__u16,__u16,__u16,__u16);
 extern void fmemset(__u16,__u16,__u16,__u16);
diff -Nur elks.orig/init/main.c elks/init/main.c
--- elks.orig/init/main.c	2014-10-14 11:28:39.000000000 -0500
+++ elks/init/main.c	2014-10-14 12:03:22.000000000 -0500
@@ -1,4 +1,4 @@
-/* $Header$ 
+/* $Header$
  */
 
 #include <linuxmt/config.h>
@@ -68,7 +68,7 @@
     kfork_proc(init_task);
     wake_up_process(&task[1]);
 
-    /* 
+    /*
      * We are now the idle task. We won't run unless no other process can run.
      */
     while (1){
@@ -103,30 +103,26 @@
      * So, I've modified the ELKS kernel to follow this tradition.
      */
 
-    num = run_init_process("/sbin/init", args);
-	printk("sys_execve(\"/sbin/init\",args,18) => %d.\n",num);
-	num = run_init_process("/etc/init", args);
-	    printk("sys_execve(\"/etc/init\",args,18) => %d.\n",num);
-	    num = run_init_process("/bin/init", args);
-		printk("sys_execve(\"/bin/init\",args,18) => %d.\n",num);
+    run_init_process("/etc/init", args);
+    run_init_process("/sbin/init", args);
+    run_init_process("/bin/init", args);
 
 #ifdef CONFIG_CONSOLE_SERIAL
-		num = sys_open("/dev/ttyS0", 2, 0);
+	num = sys_open("/dev/ttyS0", 2, 0);
 #else
-		num = sys_open("/dev/tty0", 2, 0);
+	num = sys_open("/dev/tty0", 2, 0);
 #endif
-		if (num < 0)
-		    printk("Unable to open /dev/tty (error %u)\n", -num);
+	if (num < 0)
+	    printk("Unable to open /dev/tty (error %u)\n", -num);
 
-		if (sys_dup(num) != 1)
-	    	printk("dup failed\n");
-		sys_dup(num);
-		sys_dup(num);
-		printk("No init - running /bin/sh\n");
-
-		num = run_init_process("/bin/sash", args);
-		printk("sys_execve(\"/bin/sh\",args,18) => %d.\n",num);
-	    	    panic("No init or sh found");
+	if (sys_dup(num) != 1)
+	    printk("dup failed\n");
+	sys_dup(num);
+	sys_dup(num);
+	printk("No init - running /bin/sh\n");
+
+    run_init_process("/bin/sash", args);
+    panic("No init or sh found");
 }
 
 /*
diff -Nur elks.orig/kernel/sleepwake.c elks/kernel/sleepwake.c
--- elks.orig/kernel/sleepwake.c	2014-04-26 22:12:31.000000000 -0500
+++ elks/kernel/sleepwake.c	2014-10-14 12:03:22.000000000 -0500
@@ -37,15 +37,13 @@
     pcurrent->waitpt = NULL;
 }
 
-int marker;
-
 static void __sleep_on(register struct wait_queue *p, __s16 state)
 {
     register __ptask pcurrent = current;
 
     if (pcurrent == &task[0]) {
 	printk("task[0] trying to sleep ");
-	panic("from %x", marker);
+	panic("from %x", (int)p);
     }
     pcurrent->state = state;
     wait_set(p);
@@ -55,7 +53,6 @@
 
 void sleep_on(struct wait_queue *p)
 {
-    marker = (int) peekw(get_ds(), get_bp() + 2);
     __sleep_on(p, TASK_UNINTERRUPTIBLE);
 }
 

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

  Powered by Linux