[PATCH 1 of 5]

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

 



Hi,

This patch makes:

-Claim 768 bytes memory used for the stack of task 0 during startup.
This task has 1 Kbytes reserved for stack in its task-struct, but
instead used a memory space reserved in file arch/i86/boot/ctr0.S.

-Cleans a bit the mess of conditional compilation statements in
file arch/i86/boot/ctr0.S.

-Removes unneeded function redirect_main() in file kernel/printk.c.
See comments in file arch/i86/boot/crt0.S.

-Code size gets reduced by 64 bytes and data reduced by 768 bytes.

Greetings,

Juan
diff -Nur elks.orig/arch/i86/boot/crt0.S elks/arch/i86/boot/crt0.S
--- elks.orig/arch/i86/boot/crt0.S	2014-04-26 22:12:31.000000000 -0500
+++ elks/arch/i86/boot/crt0.S	2014-10-08 12:57:55.000000000 -0500
@@ -3,6 +3,7 @@
 #define __ASSEMBLY__
 
 #include <linuxmt/config.h>
+#include <arch/asm-offsets.h>
 
 !	Assembler boot strap hooks. This is called by setup
 
@@ -16,36 +17,56 @@
 
 	.extern _kernel_restarted
 	br _kernel_restarted
-	
-!	Setup passes these on the stack	
+
+!	Setup passes these on the stack
 !	Setup patched to pass parameters in registers to avoid clobbering the
 !	kernel when using the 286pmode extender.
 
 _main:
 #ifdef CONFIG_ROMCODE
-	pop	ax
-	mov	__endtext, ax
-	pop	ax
-	mov	__enddata, ax
+	mov	cx,ds
 	pop	bx
-	add	ax,bx
-	mov	__endbss, ax
-#else
+	pop	si
+	pop	dx
+#endif
+
+! Setup.S already initialized DS and ES (but not SS)
+! In addition, registers contain:
+!   BX, Text size
+!   SI, Data size
+!   DX, BSS size
+!   CX, Kernel DS
+!
 	mov	__endtext, bx
 	mov	__enddata, si
 	add	si, dx
 	mov	__endbss, si
-#endif
-       
+
+! Start cleaning BSS. Still using setup.S stack
+
+	mov	di,__enddata	! start of BSS
+	xchg	cx,dx		! CX = BSS size, DX = Kernel DS
+	xor	ax,ax
+	shr	cx,#1
+	cld
+	rep
+	stosw
+
+! End cleaning BSS
+
 #ifndef CONFIG_ROMCODE
-	mov	ax,ds           ! in ROMCODE stack is ready placed
-	mov	ss,ax
-	mov	sp,#_bootstack
+	mov	ss,dx		! in ROMCODE stack is ready placed
+	mov	sp,#(_task + TASK_KSTKTOP)
 #endif
 
+! Space for temporary stack space _bootstack removed!!
+! Saved 768 byte boot stack.
+! Print sp in wake_up and you'll see that more than 512 bytes of stack are used!
+! Must be in data as its in use when we wipe the BSS
+
 !  overwrite start of main with a jmp to kernel_restarted()
 !  this will give is a call stack trace instead of the "timer bug" message
-!  no longer nessecary due to pmode fix. -AJB
+!  no longer necessary due to pmode fix. -AJB
 
 !	.extern _redirect_main
 !	call	_redirect_main
@@ -54,21 +75,13 @@
 	call	_start_kernel	! Break point if it returns
 	int	3
 
-!	Segment beginnings	
+!	Segment beginnings
 
 	.data
 	.globl __endtext
 	.globl __enddata
 	.globl __endbss
-	
-#ifndef CONFIG_ROMCODE
-	.zerow	384
-_bootstack:
-#endif
-
-! 768 byte boot stack. Print sp in wake_up and you'll see that more than
-! 512 bytes of stack are used! 
-! Must be in data as its in use when we wipe the BSS
+	.extern _task
 
 __endtext:
 	.word	0
diff -Nur elks.orig/arch/i86/boot/crt1.c elks/arch/i86/boot/crt1.c
--- elks.orig/arch/i86/boot/crt1.c	2014-04-26 22:12:31.000000000 -0500
+++ elks/arch/i86/boot/crt1.c	2014-10-08 12:25:37.000000000 -0500
@@ -1,44 +1,10 @@
 /*
  *	Architecture specific C bootstrap
  */
- 
-#include <arch/segment.h>
- 
-#ifdef USE_C
 
 void arch_boot(void)
 {
     /*
-     *	Wipe the BSS
+     *	Nothing for i86
      */
-    short *ptr = _enddata;
-
-    while(ptr < _endbss)
-	*ptr++ = 0;
 }
-
-#else
-
-#ifndef S_SPLINT_S
-#asm
-
-    .globl _arch_boot
-
-    .text
-
-_arch_boot:
-    push di
-    mov di,__enddata
-    mov cx,__endbss
-    sub cx,di
-    xor ax,ax
-    shr cx,#1
-    rep
-    stosw
-    pop di
-    ret
-
-#endasm
-#endif
-
-#endif
diff -Nur elks.orig/kernel/printk.c elks/kernel/printk.c
--- elks.orig/kernel/printk.c	2014-04-26 22:12:31.000000000 -0500
+++ elks/kernel/printk.c	2014-10-08 12:46:10.000000000 -0500
@@ -94,7 +94,7 @@
 	bp2 = Upper ? hex_string : hex_lower;
     do {
 	    *--bp = *(bp2 + (v % base));	/* Store digit */
-	} while ((v /= base));
+    } while ((v /= base));
 
     if (useSign && !Zero)
 	*--bp = '-';
@@ -238,9 +238,3 @@
 {
     panic("kernel restarted\n");
 }
-
-void redirect_main(void)
-{
-    pokeb(get_cs(), 0, 0xe9);
-    pokew(get_cs(), 1, ((__u16) kernel_restarted) - 3);
-}
diff -Nur elks.orig/kernel/sched.c elks/kernel/sched.c
--- elks.orig/kernel/sched.c	2014-04-26 22:12:31.000000000 -0500
+++ elks/kernel/sched.c	2014-10-08 13:01:38.000000000 -0500
@@ -1,9 +1,9 @@
 /*
  *  kernel/sched.c
- *  (C) 1995 Chad Page 
- *  
+ *  (C) 1995 Chad Page
+ *
  *  This is the main scheduler - hopefully simpler than Linux's at present.
- * 
+ *
  *
  */
 
@@ -278,7 +278,6 @@
  *	Now create task 0 to be ourself.
  */
     taskp = &init_task;
-    memset(taskp, 0, sizeof(struct task_struct));
     taskp->state = TASK_RUNNING;
     taskp->next_run = taskp->prev_run = taskp;
 

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

  Powered by Linux