From 019bff13a2eca0f7be3b6d44c7988ff9c0f39544 Mon Sep 17 00:00:00 2001 From: mickey Date: Tue, 15 Apr 1997 20:01:55 +0000 Subject: [PATCH] no more assembly setup. all the gung is ok already in srt0.S this is what we were talking about, toby (; and this shaves a couple of dozens of bytes! --- sys/arch/i386/stand/libsa/Makefile | 4 +- sys/arch/i386/stand/libsa/exec_i386.c | 99 ++++++++++++--------------- sys/arch/i386/stand/libsa/startprog.S | 48 ------------- 3 files changed, 46 insertions(+), 105 deletions(-) delete mode 100644 sys/arch/i386/stand/libsa/startprog.S diff --git a/sys/arch/i386/stand/libsa/Makefile b/sys/arch/i386/stand/libsa/Makefile index 6c38f6acf73..5e757fc4f5c 100644 --- a/sys/arch/i386/stand/libsa/Makefile +++ b/sys/arch/i386/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.7 1997/04/05 21:29:49 mickey Exp $ +# $OpenBSD: Makefile,v 1.8 1997/04/15 20:01:55 mickey Exp $ LIB= sa @@ -40,7 +40,7 @@ SRCS+= debug.c debug_aout.c debug_i386.S # i386 stuff SRCS+= asm.S bioscom.S biosdev.c biosdisk.S bioskbd.S biostime.S biosmem.S \ dev_i386.c gateA20.c memprobe.c real_prot.S unixsys.S exec_i386.c \ - startprog.S gidt.S + gidt.S NOPROFILE=noprofile NOPIC=nopic diff --git a/sys/arch/i386/stand/libsa/exec_i386.c b/sys/arch/i386/stand/libsa/exec_i386.c index 908a9ddfb61..61451c487cb 100644 --- a/sys/arch/i386/stand/libsa/exec_i386.c +++ b/sys/arch/i386/stand/libsa/exec_i386.c @@ -1,83 +1,72 @@ - -/* $OpenBSD: exec_i386.c,v 1.6 1997/04/11 19:14:18 weingart Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.7 1997/04/15 20:01:56 mickey Exp $ */ + +/* + * Copyright (c) 1997 Michael Shalayeff + * Copyright (c) 1997 Tobias Weingartner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Michael Shalayeff. + * This product includes software developed by Tobias Weingartner. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ #include #include #include #include -#include - -int startprog(void *, void *); static int bootdev; #define round_to_size(x) (((int)(x) + sizeof(int) - 1) & ~(sizeof(int) - 1)) - void machdep_start(startaddr, howto, loadaddr, ssym, esym) char *startaddr, *loadaddr, *ssym, *esym; int howto; { - static int argv[9]; - #ifdef DEBUG struct exec *x; x = (void *)loadaddr; - printf("exec {\n"); - printf(" a_midmag = %lx\n", x->a_midmag); - printf(" a_text = %lx\n", x->a_text); - printf(" a_data = %lx\n", x->a_data); - printf(" a_bss = %lx\n", x->a_bss); - printf(" a_syms = %lx\n", x->a_syms); - printf(" a_entry = %lx\n", x->a_entry); - printf(" a_trsize = %lx\n", x->a_trsize); - printf(" a_drsize = %lx\n", x->a_drsize); - printf("}\n"); + printf("exec {\n\ta_midmag = %lx\n\ta_text = %lx\n\ta_data = %lx\n" + "\ta_bss = %lx\n\ta_syms = %lx\n\ta_entry = %lx\n" + "\ta_trsize = %lx\n\ta_drsize = %lx\n}\n", + x->a_midmag, x->a_text, x->a_data, x->a_bss, x->a_syms, + x->a_entry, x->a_trsize, x->a_drsize); getchar(); #endif (int)startaddr &= 0xffffff; - /* - * We now pass the various bootstrap parameters to the loaded - * image via the argument list - * - * arg0 = 8 (magic) - * arg1 = boot flags - * arg2 = boot device - * arg3 = start of symbol table (0 if not loaded) - * arg4 = end of symbol table (0 if not loaded) - * arg5 = transfer address from image - * arg6 = transfer address for next image pointer - * arg7 = conventional memory size (640) - * arg8 = extended memory size (8196) - */ - argv[0] = 8; - argv[1] = howto; - argv[2] = bootdev; - argv[3] = (int)ssym; - argv[4] = (int)round_to_size(esym); - argv[5] = (int)startaddr; - argv[6] = 0; - argv[7] = cnvmem; - argv[8] = extmem; - -#ifdef DEBUG - { int i; - for(i = 0; i <= argv[0]; i++) - printf("argv[%d] = %x\n", i, argv[i]); - - getchar(); - } -#endif - - /****************************************************************/ - /* copy that first page and overwrite any BIOS variables */ - /****************************************************************/ printf("entry point at 0x%x\n", (int)startaddr); - startprog(startaddr, argv); + /* stack and the gung is ok at this point, so, no need for asm setup */ + (*(int __attribute__((noreturn))(*)(int,int,int,int,int,int))startaddr)( + howto, bootdev, 0, round_to_size(esym), extmem, cnvmem); + /* not reached */ } diff --git a/sys/arch/i386/stand/libsa/startprog.S b/sys/arch/i386/stand/libsa/startprog.S deleted file mode 100644 index b8e248f561f..00000000000 --- a/sys/arch/i386/stand/libsa/startprog.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: startprog.S,v 1.4 1997/04/04 17:23:31 weingart Exp $ */ - -#include - - -/* - * startprog(phyaddr, argv) - * start the program on protected mode where phyaddr is the entry point - */ -ENTRY(startprog) - pushl %ebp - movl %esp, %ebp - - # get things we need into registers - movl 8(%ebp), %ecx # entry offset - movl 12(%ebp), %eax # &argv - - # make a new stack at 0:0x90000 (big segs) - movl $0x10, %ebx - movw %bx, %ss - movl $0x90000, %ebx - movl %ebx, %esp - - # push some number of args onto the stack - pushl 28(%eax) # argv[7] = cnvmem - pushl 32(%eax) # argv[8] = extmem - pushl 16(%eax) # argv[4] = esym - pushl 12(%eax) # argv[3] = cyl offset - pushl 8(%eax) # argv[2] = bootdev - pushl 4(%eax) # argv[1] = howto - pushl $0 # dummy 'return' address - - # push on our entry address - movl $0x8, %ebx # segment - pushl %ebx - pushl %ecx - - # convert over the other data segs - movl $0x10, %ebx - movl %bx, %ds - movl %bx, %es - movl %bx, %ss - movl %bx, %fs - movl %bx, %gs - - # convert the PC (and code seg) - lret - -- 2.20.1