From: Juan Perez-Sanchez <lithoxs@gmail.com>
To: linux-8086 <linux-8086@vger.kernel.org>
Cc: Jody Bruchon <jody@jodybruchon.com>
Subject: [PATCH 1 of 5]
Date: Sun, 9 Nov 2014 12:58:26 -0600 [thread overview]
Message-ID: <CAD6VGubncPY5jibHRjVz=ohLO0HnP48CFzG+-dHRpoKGR7xU=Q@mail.gmail.com> (raw)
[-- 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;
next reply other threads:[~2014-11-09 18:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-09 18:58 Juan Perez-Sanchez [this message]
2014-11-16 14:21 ` [PATCH 1 of 5] Jody Bruchon
2014-11-16 17:05 ` Gregg Levine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAD6VGubncPY5jibHRjVz=ohLO0HnP48CFzG+-dHRpoKGR7xU=Q@mail.gmail.com' \
--to=lithoxs@gmail.com \
--cc=jody@jodybruchon.com \
--cc=linux-8086@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).