* [PATCH 1 of 5]
@ 2014-11-09 18:58 Juan Perez-Sanchez
2014-11-16 14:21 ` Jody Bruchon
0 siblings, 1 reply; 3+ messages in thread
From: Juan Perez-Sanchez @ 2014-11-09 18:58 UTC (permalink / raw)
To: linux-8086; +Cc: Jody Bruchon
[-- Attachment #1: Type: text/plain, Size: 516 bytes --]
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
[-- Attachment #2: elks-2a.patch --]
[-- Type: text/x-patch, Size: 4350 bytes --]
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;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1 of 5]
2014-11-09 18:58 [PATCH 1 of 5] Juan Perez-Sanchez
@ 2014-11-16 14:21 ` Jody Bruchon
2014-11-16 17:05 ` Gregg Levine
0 siblings, 1 reply; 3+ messages in thread
From: Jody Bruchon @ 2014-11-16 14:21 UTC (permalink / raw)
To: linux-8086
All five patches applied. Thanks a lot! The fork() patch especially was
a great find. Your work on ELKS is very greatly appreciated, Juan.
By the way, since I'm subscribed to linux-8086, you don't have to CC me ;-)
Thanks again!
-Jody Bruchon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1 of 5]
2014-11-16 14:21 ` Jody Bruchon
@ 2014-11-16 17:05 ` Gregg Levine
0 siblings, 0 replies; 3+ messages in thread
From: Gregg Levine @ 2014-11-16 17:05 UTC (permalink / raw)
To: ELKS
Hello!
That's called habit.Some e-mail clients do that automatically. This
one does, and I took it out because it wasn't necessary.
-----
Gregg C Levine gregg.drwho8@gmail.com
"This signature fought the Time Wars, time and again."
On Sun, Nov 16, 2014 at 9:21 AM, Jody Bruchon <jody@jodybruchon.com> wrote:
> All five patches applied. Thanks a lot! The fork() patch especially was a
> great find. Your work on ELKS is very greatly appreciated, Juan.
>
> By the way, since I'm subscribed to linux-8086, you don't have to CC me ;-)
>
> Thanks again!
>
> -Jody Bruchon
> --
> To unsubscribe from this list: send the line "unsubscribe linux-8086" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-16 17:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-09 18:58 [PATCH 1 of 5] Juan Perez-Sanchez
2014-11-16 14:21 ` Jody Bruchon
2014-11-16 17:05 ` Gregg Levine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox