Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mvme68k/stand/libbug Replace the startup C code wit...



details:   https://anonhg.NetBSD.org/src/rev/f0e04bda8410
branches:  trunk
changeset: 500120:f0e04bda8410
user:      scw <scw%NetBSD.org@localhost>
date:      Tue Dec 05 21:54:33 2000 +0000

description:
Replace the startup C code with assembler, which avoids having to
explicitly tell the compiler what registers the Bug args come in on.

diffstat:

 sys/arch/mvme68k/stand/libbug/Makefile   |  19 +++----
 sys/arch/mvme68k/stand/libbug/bugcrt.c   |  78 ++-----------------------------
 sys/arch/mvme68k/stand/libbug/bugstart.s |  55 ++++++++++++++++++++++
 sys/arch/mvme68k/stand/libbug/libbug.h   |   6 +-
 4 files changed, 73 insertions(+), 85 deletions(-)

diffs (218 lines):

diff -r ea83a0b9db08 -r f0e04bda8410 sys/arch/mvme68k/stand/libbug/Makefile
--- a/sys/arch/mvme68k/stand/libbug/Makefile    Tue Dec 05 21:51:38 2000 +0000
+++ b/sys/arch/mvme68k/stand/libbug/Makefile    Tue Dec 05 21:54:33 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.11 2000/12/04 18:35:16 scw Exp $
+#      $NetBSD: Makefile,v 1.12 2000/12/05 21:54:33 scw Exp $
 
 LIB=bug
 
@@ -9,22 +9,21 @@
 S=${.CURDIR}/../../../..
 DIR_SA=$S/lib/libsa
 
-SRCS=  delay.c diskrd.c diskwr.c getbrdid.c inchr.c instat.c outln.c \
-       outstr.c putchar.c return.c rtc_rd.c
-CLEANFILES+= bugcrt.o bugcrt.o.tmp
+SRCS=  bugcrt.c delay.c diskrd.c diskwr.c getbrdid.c inchr.c instat.c \
+       outln.c outstr.c putchar.c return.c rtc_rd.c
+CLEANFILES+= bugstart.o
 
 .include "../Makefile.booters"
 
 # only needed during build
 libinstall::
 
-# separate rule for bugcrt.c - NEED NOT BE COMPILED WITH -O2
+# separate rule for bugstart.c
 # this is build separately from rest of libbug
-bugcrt.o: bugcrt.c
-       ${CC} -fomit-frame-pointer -nostdinc ${INCPATH} -D_STANDALONE \
-           -o ${.TARGET}.tmp -c ${.IMPSRC}
-       ${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
+bugstart.o: bugstart.s
+       ${CC} -x assembler-with-cpp -traditional-cpp -nostdinc ${INCPATH} \
+       -D_STANDALONE -c ${.IMPSRC}
 
-all realall: lib${LIB}.a bugcrt.o
+all realall: lib${LIB}.a bugstart.o
 
 .include <bsd.lib.mk>
diff -r ea83a0b9db08 -r f0e04bda8410 sys/arch/mvme68k/stand/libbug/bugcrt.c
--- a/sys/arch/mvme68k/stand/libbug/bugcrt.c    Tue Dec 05 21:51:38 2000 +0000
+++ b/sys/arch/mvme68k/stand/libbug/bugcrt.c    Tue Dec 05 21:54:33 2000 +0000
@@ -1,46 +1,15 @@
-/*     $NetBSD: bugcrt.c,v 1.2 2000/11/30 22:26:27 scw Exp $   */
+/*     $NetBSD: bugcrt.c,v 1.3 2000/12/05 21:54:33 scw Exp $   */
 
 #include <sys/types.h>
 #include <machine/prom.h>
 
 #include "libbug.h"
 
-struct mvmeprom_args bugargs = { 1 };  /* not in BSS */
-
-       asm (".text");
-
-       asm (".long _start-0x10");
-       asm (".long _start");
-
-#ifndef __ELF__
-start()
-#else
-_start()
-#endif
+void
+_bugstart(void)
 {
-       register int dev_lun asm (MVMEPROM_REG_DEVLUN);
-       register int ctrl_lun asm (MVMEPROM_REG_CTRLLUN);
-       register int flags asm (MVMEPROM_REG_FLAGS);
-       register int ctrl_addr asm (MVMEPROM_REG_CTRLADDR);
-       register int entry asm (MVMEPROM_REG_ENTRY);
-       register int conf_blk asm (MVMEPROM_REG_CONFBLK);
-       register char *arg_start asm (MVMEPROM_REG_ARGSTART);
-       register char *arg_end asm (MVMEPROM_REG_ARGEND);
-       register char *nbarg_start asm (MVMEPROM_REG_NBARGSTART);
-       register char *nbarg_end asm (MVMEPROM_REG_NBARGEND);
-       extern int edata, end;
-       struct mvmeprom_brdid *id, *mvmeprom_getbrdid();
-
-       bugargs.dev_lun = dev_lun;
-       bugargs.ctrl_lun = ctrl_lun;
-       bugargs.flags = flags;
-       bugargs.ctrl_addr = ctrl_addr;
-       bugargs.entry = entry;
-       bugargs.conf_blk = conf_blk;
-       bugargs.arg_start = arg_start;
-       bugargs.arg_end = arg_end;
-       bugargs.nbarg_start = nbarg_start;
-       bugargs.nbarg_end = nbarg_end;
+       extern void main(void);
+       struct mvmeprom_brdid *id;
 
        /*
         * Be sure not to de-reference NULL
@@ -48,46 +17,9 @@
        if ( bugargs.arg_end )
                *bugargs.arg_end = 0;
 
-       memset(&edata, 0, (int)&end-(int)&edata);
        id = mvmeprom_getbrdid();
        bugargs.cputyp = id->model;
        main();
        _rtt();
        /* NOTREACHED */
 }
-
-__main()
-{
-}
-
-
-void
-bugexec(addr)
-
-void (*addr)();
-
-{
-       register int dev_lun asm (MVMEPROM_REG_DEVLUN);
-       register int ctrl_lun asm (MVMEPROM_REG_CTRLLUN);
-       register int flags asm (MVMEPROM_REG_FLAGS);
-       register int ctrl_addr asm (MVMEPROM_REG_CTRLADDR);
-       register int entry asm (MVMEPROM_REG_ENTRY);
-       register int conf_blk asm (MVMEPROM_REG_CONFBLK);
-       register char *arg_start asm (MVMEPROM_REG_ARGSTART);
-       register char *arg_end asm (MVMEPROM_REG_ARGEND);
-
-       dev_lun = bugargs.dev_lun;
-       ctrl_lun = bugargs.ctrl_lun;
-       flags = bugargs.flags;
-       ctrl_addr = bugargs.ctrl_addr;
-       entry = bugargs.entry;
-       conf_blk = bugargs.conf_blk;
-       arg_start = bugargs.arg_start;
-       arg_end = bugargs.arg_end;
-
-       (*addr)();
-       printf("bugexec: 0x%x returned!\n", addr);
-
-       _rtt();
-}
-
diff -r ea83a0b9db08 -r f0e04bda8410 sys/arch/mvme68k/stand/libbug/bugstart.s
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mvme68k/stand/libbug/bugstart.s  Tue Dec 05 21:54:33 2000 +0000
@@ -0,0 +1,55 @@
+/*     $NetBSD: bugstart.s,v 1.1 2000/12/05 21:54:33 scw Exp $ */
+
+#define _LOCORE
+#include <machine/prom.h>
+#undef _LOCORE
+#include <machine/asm.h>
+
+       .data
+       .even
+
+GLOBAL(bugargs)
+       .space  MVMEPROM_ARGS_MAX*4
+
+       .text
+       .even
+
+       .long   _C_LABEL(start) - 0x10
+       .long   _C_LABEL(start)
+
+#define        BUG_ARG(which)  _C_LABEL(bugargs) + (which)
+
+ENTRY_NOPROFILE(_start)
+ENTRY_NOPROFILE(start)
+       movl    MVMEPROM_REG_DEVLUN, BUG_ARG(MVMEPROM_ARGS_DEVLUN)
+       movl    MVMEPROM_REG_CTRLLUN, BUG_ARG(MVMEPROM_ARGS_CTRLLUN)
+       movl    MVMEPROM_REG_FLAGS, BUG_ARG(MVMEPROM_ARGS_FLAGS)
+       movl    MVMEPROM_REG_CTRLADDR, BUG_ARG(MVMEPROM_ARGS_CTRLADDR)
+       movl    MVMEPROM_REG_ENTRY, BUG_ARG(MVMEPROM_ARGS_ENTRY)
+       movl    MVMEPROM_REG_CONFBLK, BUG_ARG(MVMEPROM_ARGS_CONFBLK)
+       movl    MVMEPROM_REG_NBARGSTART, BUG_ARG(MVMEPROM_ARGS_NBARGSTART)
+       movl    MVMEPROM_REG_NBARGEND, BUG_ARG(MVMEPROM_ARGS_NBARGEND)
+       movl    MVMEPROM_REG_ARGSTART, BUG_ARG(MVMEPROM_ARGS_ARGSTART)
+       movl    MVMEPROM_REG_ARGEND, BUG_ARG(MVMEPROM_ARGS_ARGEND)
+       lea     _C_LABEL(edata),%a0
+       movl    #_C_LABEL(end) - 4,%d0
+       subl    %a0,%d0
+       lsrl    #2,%d0
+1:     clrl    %a0@+
+       dbra    %d0,1b
+       jmp     _C_LABEL(_bugstart)
+
+ENTRY_NOPROFILE(bugexec)
+       addql   #4,%sp
+       movl    BUG_ARG(MVMEPROM_ARGS_DEVLUN), MVMEPROM_REG_DEVLUN
+       movl    BUG_ARG(MVMEPROM_ARGS_CTRLLUN), MVMEPROM_REG_CTRLLUN
+       movl    BUG_ARG(MVMEPROM_ARGS_FLAGS), MVMEPROM_REG_FLAGS
+       movl    BUG_ARG(MVMEPROM_ARGS_CTRLADDR), MVMEPROM_REG_CTRLADDR
+       movl    BUG_ARG(MVMEPROM_ARGS_ENTRY), MVMEPROM_REG_ENTRY
+       movl    BUG_ARG(MVMEPROM_ARGS_CONFBLK), MVMEPROM_REG_CONFBLK
+       movl    BUG_ARG(MVMEPROM_ARGS_NBARGSTART), MVMEPROM_REG_NBARGSTART
+       movl    BUG_ARG(MVMEPROM_ARGS_NBARGEND), MVMEPROM_REG_NBARGEND
+       movl    BUG_ARG(MVMEPROM_ARGS_ARGSTART), MVMEPROM_REG_ARGSTART
+       movl    BUG_ARG(MVMEPROM_ARGS_ARGEND), MVMEPROM_REG_ARGEND
+ENTRY_NOPROFILE(__main)
+       rts
diff -r ea83a0b9db08 -r f0e04bda8410 sys/arch/mvme68k/stand/libbug/libbug.h
--- a/sys/arch/mvme68k/stand/libbug/libbug.h    Tue Dec 05 21:51:38 2000 +0000
+++ b/sys/arch/mvme68k/stand/libbug/libbug.h    Tue Dec 05 21:54:33 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libbug.h,v 1.2 2000/07/24 18:39:41 jdolecek Exp $      */
+/*     $NetBSD: libbug.h,v 1.3 2000/12/05 21:54:33 scw Exp $   */
 
 /*
  * prototypes and such.   note that get/put char are in stand.h
@@ -20,4 +20,6 @@
 
 extern struct mvmeprom_args bugargs;
 
-void   bugexec __P((void (*)(void)));
+extern void    _bugstart __P((void));
+extern void    bugexec __P((void (*)(void)));
+extern void _rtt(void);



Home | Main Index | Thread Index | Old Index