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 Support booting an ELF kernel, plus n...



details:   https://anonhg.NetBSD.org/src/rev/e151fe290ca9
branches:  trunk
changeset: 499859:e151fe290ca9
user:      scw <scw%NetBSD.org@localhost>
date:      Thu Nov 30 22:26:26 2000 +0000

description:
Support booting an ELF kernel, plus numerous tweaks due to
the gas.new/ELF transition.

diffstat:

 sys/arch/mvme68k/stand/Makefile.booters  |    7 +-
 sys/arch/mvme68k/stand/bootst/Makefile   |    6 +-
 sys/arch/mvme68k/stand/libbug/bugcrt.c   |   10 +-
 sys/arch/mvme68k/stand/libsa/Makefile    |    6 +-
 sys/arch/mvme68k/stand/libsa/SRT0.S      |   42 ++++---
 sys/arch/mvme68k/stand/libsa/exec_mvme.c |  165 ++++--------------------------
 sys/arch/mvme68k/stand/netboot/Makefile  |    9 +-
 sys/arch/mvme68k/stand/sboot/Makefile    |   10 +-
 sys/arch/mvme68k/stand/sboot/oc_cksum.s  |  129 ++++++++++++------------
 sys/arch/mvme68k/stand/sboot/start.s     |   42 +++---
 10 files changed, 160 insertions(+), 266 deletions(-)

diffs (truncated from 673 to 300 lines):

diff -r b0c45a01b23f -r e151fe290ca9 sys/arch/mvme68k/stand/Makefile.booters
--- a/sys/arch/mvme68k/stand/Makefile.booters   Thu Nov 30 22:07:24 2000 +0000
+++ b/sys/arch/mvme68k/stand/Makefile.booters   Thu Nov 30 22:26:26 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.booters,v 1.3 2000/11/20 19:35:31 scw Exp $
+#      $NetBSD: Makefile.booters,v 1.4 2000/11/30 22:26:26 scw Exp $
 
 S?=            ${.CURDIR}/../../../..
 MDEC_DIR?=     /usr/mdec
@@ -17,7 +17,8 @@
 
 INCPATH=-I${.OBJDIR} -I${.CURDIR} -I${.CURDIR}/../libsa -I${.CURDIR}/../libbug \
         -I${.CURDIR}/../../include -I${S} -I${S}/lib/libsa
-CFLAGS= -nostdinc -m68020-60 -Wa,-m68030 -D_STANDALONE ${INCPATH} ${DEFS}
+CFLAGS= -nostdinc -m68020-60 -Wa,-m68030 -D_STANDALONE \
+       -DLIBSA_USE_MEMSET -DLIBSA_USE_MEMCPY ${INCPATH} ${DEFS}
 BINDIR= ${MDEC_DIR}
 
 .if exists(${.CURDIR}/version)
@@ -46,7 +47,7 @@
 .else
 
 ${PROG}: machine m68k ${OBJS} ${LIBS} ${BUGCRT} ${SRTOBJ}
-       ${LD} -N -T ${RELOC} -o $@ ${BUGCRT} ${SRTOBJ} ${OBJS} ${LIBS}
+       ${LD} -N -Ttext ${RELOC} -o $@ ${SRTOBJ} ${BUGCRT} ${OBJS} ${LIBS}
 
 LIB_SA_DIR=    ${.CURDIR}/../libsa
 LIBSA_DIR!=cd ${LIB_SA_DIR}; \
diff -r b0c45a01b23f -r e151fe290ca9 sys/arch/mvme68k/stand/bootst/Makefile
--- a/sys/arch/mvme68k/stand/bootst/Makefile    Thu Nov 30 22:07:24 2000 +0000
+++ b/sys/arch/mvme68k/stand/bootst/Makefile    Thu Nov 30 22:26:26 2000 +0000
@@ -1,5 +1,5 @@
 #      from: @(#)Makefile      8.1 (Berkeley) 6/10/93
-#      $NetBSD: Makefile,v 1.10 2000/07/28 20:08:21 scw Exp $
+#      $NetBSD: Makefile,v 1.11 2000/11/30 22:26:27 scw Exp $
 
 CLEANFILES+=stboot bootst bootst.bug
 
@@ -10,8 +10,8 @@
 DPADD= ${WRTVID}
 
 bootst stboot: ${PROG} ${WRTVID}
-       @size bootst.bug
-       @strip bootst.bug
+       @${SIZE} bootst.bug
+       @${STRIP} bootst.bug
        @${WRTVID} bootst.bug # creates bootst  and stboot
 
 proginstall::
diff -r b0c45a01b23f -r e151fe290ca9 sys/arch/mvme68k/stand/libbug/bugcrt.c
--- a/sys/arch/mvme68k/stand/libbug/bugcrt.c    Thu Nov 30 22:07:24 2000 +0000
+++ b/sys/arch/mvme68k/stand/libbug/bugcrt.c    Thu Nov 30 22:26:26 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bugcrt.c,v 1.1 2000/07/24 18:39:41 jdolecek Exp $      */
+/*     $NetBSD: bugcrt.c,v 1.2 2000/11/30 22:26:27 scw Exp $   */
 
 #include <sys/types.h>
 #include <machine/prom.h>
@@ -8,9 +8,15 @@
 struct mvmeprom_args bugargs = { 1 };  /* not in BSS */
 
        asm (".text");
+
        asm (".long _start-0x10");
        asm (".long _start");
+
+#ifndef __ELF__
 start()
+#else
+_start()
+#endif
 {
        register int dev_lun asm (MVMEPROM_REG_DEVLUN);
        register int ctrl_lun asm (MVMEPROM_REG_CTRLLUN);
@@ -42,7 +48,7 @@
        if ( bugargs.arg_end )
                *bugargs.arg_end = 0;
 
-       bzero(&edata, (int)&end-(int)&edata);
+       memset(&edata, 0, (int)&end-(int)&edata);
        id = mvmeprom_getbrdid();
        bugargs.cputyp = id->model;
        main();
diff -r b0c45a01b23f -r e151fe290ca9 sys/arch/mvme68k/stand/libsa/Makefile
--- a/sys/arch/mvme68k/stand/libsa/Makefile     Thu Nov 30 22:07:24 2000 +0000
+++ b/sys/arch/mvme68k/stand/libsa/Makefile     Thu Nov 30 22:26:26 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.14 2000/11/11 11:36:17 scw Exp $
+#      $NetBSD: Makefile,v 1.15 2000/11/30 22:26:27 scw Exp $
 
 LIB=sa
 
@@ -10,10 +10,10 @@
         bootparam.c rarp.c
 
 
-SRC_sa = alloc.c bcopy.c bcmp.c memcpy.c close.c exit.c getfile.c gets.c \
+SRC_sa = alloc.c memcpy.c memset.c close.c exit.c getfile.c gets.c \
         open.c printf.c read.c strerror.c ufs.c globals.c lseek.c panic.c \
         closeall.c dev.c dkcksum.c nullfs.c fstat.c twiddle.c sprintf.c \
-        subr_prf.c intoa.c bzero.c udp.c
+        subr_prf.c intoa.c udp.c memcmp.c bcmp.c loadfile.c
 
 SRC_kern= ashrdi3.c strcmp.c strlen.c
 
diff -r b0c45a01b23f -r e151fe290ca9 sys/arch/mvme68k/stand/libsa/SRT0.S
--- a/sys/arch/mvme68k/stand/libsa/SRT0.S       Thu Nov 30 22:07:24 2000 +0000
+++ b/sys/arch/mvme68k/stand/libsa/SRT0.S       Thu Nov 30 22:26:26 2000 +0000
@@ -1,4 +1,4 @@
-|      $NetBSD: SRT0.S,v 1.2 1996/05/17 20:53:49 chuck Exp $
+|      $NetBSD: SRT0.S,v 1.3 2000/11/30 22:26:27 scw Exp $
 
 | Copyright (c) 1995 Gordon W. Ross
 | All rights reserved.
@@ -32,45 +32,47 @@
 |      code to the correct place before exec()ing.
 
 |      SRT0.S - Stand-alone Run-Time startup code, part 0
+
+#include <m68k/asm.h>
+
        .file   "SRT0.S"
        .text
-       .globl  __estack
-__estack:
-       .globl  xstart
+GLOBAL(_estack)
+
 xstart:
 | first, relocate code to correct place without touching critical regs
 | (args are in: d0, d1, d4, a0, a1, a2, a3, a4, a5, a6)
 |      [a3 and a4 only when netbooting]
-       movl    a3, d3                  | SAVE a3 in d3
-       movl    a4, d5                  | SAVE a4 in d5
-       lea     pc@(xstart:w), a3       | a3 = current addr (could be anywhere)
-       lea     xstart:l, a4            | a4 = desired location (LINKADDR)
-       cmpl    a3, a4                  | already there?
+       movl    %a3, %d3                | SAVE a3 in d3
+       movl    %a4, %d5                | SAVE a4 in d5
+       lea     %pc@(xstart:w), %a3     | a3 = current addr (could be anywhere)
+       lea     xstart:l, %a4           | a4 = desired location (LINKADDR)
+       cmpl    %a3, %a4                | already there?
        beqs    restart                 | short-circuit out
 
                                        | Relocate the code and data 
-       movl    #_edata,d2              | Desired end of program
-       subl    a4,d2                   | Calculate length, round up.
-       lsrl    #2,d2
+       movl    #_C_LABEL(edata),%d2    | Desired end of program
+       subl    %a4,%d2                 | Calculate length, round up.
+       lsrl    #2,%d2
 Lcp:
-       movl    a3@+, a4@+
-       dbra    d2, Lcp
+       movl    %a3@+, %a4@+
+       dbra    %d2, Lcp
 
 | Force a long jump to the relocated code (not pc-relative)
-       lea     restart:l, a3
-       jmp     a3@
+       lea     restart:l, %a3
+       jmp     %a3@
 
 restart:
 | now in the relocated code
 
 | Set up stack (just before relocated text)
-       lea     __estack:l, a3
-       movl    a3, sp
+       lea     _C_LABEL(_estack):l, %a3
+       movl    %a3, %sp
 
 | now that we have relocated, call the bugcrt  (note we skip over the special
 |      bug header which has a PC and SP in it)
-       movl    d3, a3                  | RESTORE a3
-       movl    d5, a4                  | RESTORE a4
+       movl    %d3, %a3                | RESTORE a3
+       movl    %d5, %a4                | RESTORE a4
        jmp     _start
 
 | The end.
diff -r b0c45a01b23f -r e151fe290ca9 sys/arch/mvme68k/stand/libsa/exec_mvme.c
--- a/sys/arch/mvme68k/stand/libsa/exec_mvme.c  Thu Nov 30 22:07:24 2000 +0000
+++ b/sys/arch/mvme68k/stand/libsa/exec_mvme.c  Thu Nov 30 22:26:26 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_mvme.c,v 1.9 2000/07/24 18:39:46 jdolecek Exp $ */
+/*     $NetBSD: exec_mvme.c,v 1.10 2000/11/30 22:26:27 scw Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -38,13 +38,15 @@
 #include <sys/param.h>
 #include <sys/reboot.h>
 #include <machine/prom.h>
-#include <sys/exec_aout.h>
+
+#include "loadfile.h"
 
 #include "stand.h"
 #include "libsa.h"
 
-/* This must agree with what locore.s expects */
-typedef void (*kentry_t)(int, u_int, u_int, u_int, int, char *);
+/* These must agree with what locore.s expects */
+#define        KERN_LOADADDR   0x0
+typedef void (*kentry_t)(int, u_int, u_int, u_int, int, u_long);
 
 
 /*ARGSUSED*/
@@ -54,150 +56,29 @@
        int     flag;
        int     part;
 {
-       char *loadaddr;
-       int io;
-       struct exec x;
-       int cc, magic;
-       kentry_t *entry;
-       char *cp;
-       int *ip;
-
-#ifdef DEBUG
-       printf("exec_mvme: partition=%d, file=%s flag=0x%x\n", part, file, flag);
-#endif
-
-       io = open(file, 0);
-       if (io < 0)
-               return;
-
-       /*
-        * Read in the exec header, and validate it.
-        */
-       if (read(io, (void *)&x, sizeof(x)) != sizeof(x))
-               goto shread;
-       if (N_BADMAG(x)) {
-               errno = EFTYPE;
-               goto closeout;
-       }
+       kentry_t        entry;
+       u_long          marks[MARK_MAX];
+       int             fd;
+       int             lflags;
 
-       /*
-        * note: on the mvme ports, the kernel is linked in such a way that 
-        * its entry point is the first item in .text, and thus a_entry can 
-        * be used to determine both the load address and the entry point.
-        * (also note that we make use of the fact that the kernel will live
-        *  in a VA == PA range of memory ... otherwise we would take 
-        *  loadaddr as a parameter and let the kernel relocate itself!)
-        *
-        * note that ZMAGIC files included the a.out header in the text area
-        * so we must mask that off (has no effect on the other formats
-        */
-       loadaddr = (void *)(x.a_entry & ~sizeof(x));
-
-       cp = loadaddr;
-       magic = (int)N_GETMAGIC(x);
-       if (magic == ZMAGIC)
-               cp += sizeof(x);
-       /*LINTED*/
-       entry = (kentry_t *) cp;
-
-       /*
-        * Leave a copy of the exec header before the text.
-        * The sun3 kernel uses this to verify that the
-        * symbols were loaded by this boot program.
-        */
-       bcopy(&x, cp - sizeof(x), sizeof(x));
-
-       /*
-        * Read in the text segment.
-        */
-       printf("%ld", x.a_text);
-       cc = (int)x.a_text;
-       if (magic == ZMAGIC) 
-               cc = cc - sizeof(x); /* a.out header part of text in zmagic */
-       if (read(io, cp, (size_t)cc) != (size_t)cc)
-               goto shread;
-       cp += cc;
+       lflags = LOAD_KERNEL;
+       if ((flag & RB_NOSYM) == 0 )
+               lflags &= ~LOAD_SYM;
 
-       /*
-        * NMAGIC may have a gap between text and data.
-        */
-       if (magic == NMAGIC) {
-               int mask = N_PAGSIZ(x) - 1;
-               /*LINTED*/
-               while ((int)cp & mask)
-                       *cp++ = 0;
-       }
-
-       /*
-        * Read in the data segment.
-        */
-       printf("+%ld", x.a_data);
-       if (read(io, cp, (size_t)x.a_data) != (size_t)x.a_data)
-               goto shread;



Home | Main Index | Thread Index | Old Index