Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x68k/stand/xxboot Initial support for xxboot (cdboo...



details:   https://anonhg.NetBSD.org/src/rev/107c74862ff9
branches:  trunk
changeset: 778238:107c74862ff9
user:      minoura <minoura%NetBSD.org@localhost>
date:      Tue Mar 20 13:01:32 2012 +0000

description:
Initial support for xxboot (cdboot_cd9660, specifically).

diffstat:

 sys/arch/x68k/stand/xxboot/Makefile               |    5 +
 sys/arch/x68k/stand/xxboot/Makefile.xxboot        |  116 +++++
 sys/arch/x68k/stand/xxboot/boot.S                 |  474 ++++++++++++++++++++++
 sys/arch/x68k/stand/xxboot/bootmain.c             |  135 ++++++
 sys/arch/x68k/stand/xxboot/cdboot_cd9660/Makefile |   13 +
 sys/arch/x68k/stand/xxboot/conf.c                 |   32 +
 sys/arch/x68k/stand/xxboot/consio1.c              |   52 ++
 sys/arch/x68k/stand/xxboot/version                |    7 +
 sys/arch/x68k/stand/xxboot/xx.c                   |   57 ++
 sys/arch/x68k/stand/xxboot/xxboot.ldscript        |   49 ++
 sys/arch/x68k/stand/xxboot/xxboot_ffsv1/Makefile  |   10 +
 sys/arch/x68k/stand/xxboot/xxboot_ffsv2/Makefile  |   10 +
 sys/arch/x68k/stand/xxboot/xxboot_lfsv1/Makefile  |   10 +
 sys/arch/x68k/stand/xxboot/xxboot_lfsv2/Makefile  |   10 +
 14 files changed, 980 insertions(+), 0 deletions(-)

diffs (truncated from 1036 to 300 lines):

diff -r 5a3b0526d627 -r 107c74862ff9 sys/arch/x68k/stand/xxboot/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x68k/stand/xxboot/Makefile       Tue Mar 20 13:01:32 2012 +0000
@@ -0,0 +1,5 @@
+#      $NetBSD: Makefile,v 1.15 2012/03/20 13:01:32 minoura Exp $
+
+SUBDIR=        cdboot_cd9660 xxboot_ffsv1 xxboot_ffsv2 xxboot_lfsv1 xxboot_lfsv2
+
+.include <bsd.subdir.mk>
diff -r 5a3b0526d627 -r 107c74862ff9 sys/arch/x68k/stand/xxboot/Makefile.xxboot
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x68k/stand/xxboot/Makefile.xxboot        Tue Mar 20 13:01:32 2012 +0000
@@ -0,0 +1,116 @@
+#      $NetBSD: Makefile.xxboot,v 1.1 2012/03/20 13:01:32 minoura Exp $
+
+NOMAN=         # defined
+
+.include <bsd.own.mk>
+
+BOOT=  $(DEV)boot_$(FS)
+VERSIONFILE=   ${.CURDIR}/../version
+VERSION!=      ${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \
+                       END { print it }' ${VERSIONFILE}
+NEWVERSWHAT=   "${BOOT}"
+
+# text and bss addresses in hex
+TEXT=          0f0000          # Primary (me)
+TEXTDATASIZE=    2000          # 8KB for UFS at maximum
+                               # 30KB (=(16-1)*2048) for ISO9660 at max.
+BOOT_TEXT=     006000          # Secondary (/boot)
+
+PROG=          $(BOOT)
+BINDIR=                /usr/mdec
+STRIPFLAG=
+BINMODE=       444
+
+S=             ${.CURDIR}/../../../../..
+M=             $S/arch/x68k
+.PATH:         ${.CURDIR}/..
+SRCS=  boot.S bootmain.c conf.c consio1.c $(DEVDRV).c
+
+SRCS+=         vers.c
+CLEANFILES+=   vers.c
+vers.c:        ${VERSIONFILE}
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${S}/conf/newvers_stand.sh ${.ALLSRC} ${MACHINE} ${NEWVERSWHAT}
+
+CFLAGS=        -Os -fomit-frame-pointer
+#CFLAGS+= -Wall
+CPPFLAGS+= -D_STANDALONE
+CPPFLAGS+= -DTEXTADDR="0x$(TEXT)" -DBOOT_TEXTADDR="0x$(BOOT_TEXT)"
+CPPFLAGS+= -DTDSIZE="0x$(TEXTDATASIZE)"
+CPPFLAGS+= -DPROG=\"$(PROG)\" -DBOOT_VERS=\"$(VERSION)\"
+CPPFLAGS+= -DBOOT_STAGE1 $(BOOTCPPFLAGS)
+CPPFLAGS+= -nostdinc -I${.OBJDIR} -I${S}
+CPPFLAGS+= -I$M/stand/libiocs -I$M/stand/libsa -I$M/stand/common
+AFLAGS=           ${CFLAGS:M-[ID]*}
+.if ${OBJECT_FMT} == "ELF"
+LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript -M
+LINKFLAGS+=  -noinhibit-exec   # XXX
+.else
+LINKFLAGS=   -n -Bstatic -Ttext ${TEXT} -M
+OBJCOPY?=  objcopy
+.endif
+LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
+LIBSA!=          cd $M/stand/libsa && ${PRINTOBJDIR}
+LDLIBS=          -L${LIBSA}/lib/sa -lsa -L ${LIBSA}/lib/kern -lkern
+LDLIBS+=  -L${LIBIOCS} -liocs
+
+.PATH: $S/lib/libsa
+CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=$(FS)
+CPPFLAGS+= -DLIBSA_SINGLE_DEVICE=$(DEV)
+CPPFLAGS+= -DLIBSA_NO_TWIDDLE -DLIBSA_NO_FD_CHECKING -DLIBSA_NO_RAW_ACCESS -DLIBSA_NO_FS_WRITE
+SRCS+= open.c close.c read.c lseek.c loadfile.c loadfile_aout.c alloc.c
+SRCS+=  $(FS).c
+
+.PATH: $M/stand/common
+SRCS+= exec_image.S
+
+.include "${.CURDIR}/../../Makefile.booters"
+
+CLEANFILES+=   ${PROG}.x $(PROG).map ${PROG}
+
+
+${PROG}: $(OBJS)
+       ${_MKTARGET_LINK}
+       $(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
+       @grep first_kbyte $(PROG).map
+.if ${OBJECT_FMT} == "ELF"
+       @if [ `(echo ibase=16;                                             \
+           ${TOOL_SED} -n                                                 \
+               's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'    \
+               $(PROG).map |                                              \
+           tr a-f A-F) | bc` -gt 0 ];                                     \
+       then echo '$(BOOT): first_kbyte exceeds the first killobyte';      \
+           rm $(PROG) ; exit 1;                                           \
+       fi
+       @if [ `(echo ibase=16;                                             \
+           ${TOOL_SED} -n                                                 \
+               's/^.*0x\([0-9a-f]*\).* _edata *= *\.$$/\1-$(TEXT)-$(TEXTDATASIZE)/p' \
+               $(PROG).map |                                              \
+           tr a-f A-F) | bc` -gt 0 ];                                     \
+       then echo '$(BOOT): text+data is too large';                       \
+           rm $(PROG) ; exit 1;                                           \
+       fi
+.else
+       mv $(PROG) $(PROG).x
+       $(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG)
+       @rm -f $(PROG).x
+       @if [ `(echo ibase=16;                                             \
+           ${TOOL_SED} -n                                                 \
+               's/  first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p'         \
+               $(PROG).map |                                              \
+           tr a-f A-F) | bc` -gt 0 ];                                     \
+       then echo '$(BOOT): first_kbyte exceeds the first killobyte';      \
+           rm $(PROG) ; exit 1;                                           \
+       fi
+       @if [ `(echo ibase=16;                                             \
+           ${TOOL_SED} -n                                                 \
+               's/  _edata:.*0x\(.*\),.*$$/\1-$(TEXT)-$(TEXTDATASIZE)/p'  \
+               $(PROG).map |                                              \
+           tr a-f A-F) | bc` -gt 0 ];                                     \
+       then echo '$(BOOT): text+data is too large';                       \
+           rm $(PROG) ; exit 1;                                           \
+       fi
+.endif
+       ${TOUCHPROG}
+
+.include <bsd.prog.mk>
diff -r 5a3b0526d627 -r 107c74862ff9 sys/arch/x68k/stand/xxboot/boot.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x68k/stand/xxboot/boot.S Tue Mar 20 13:01:32 2012 +0000
@@ -0,0 +1,474 @@
+| file: boot.S
+| author: chapuni(webmaster%chapuni.com@localhost)
+|         Yasha(itohy%NetBSD.org@localhost)
+|
+| $NetBSD: boot.S,v 1.1 2012/03/20 13:01:32 minoura Exp $
+
+#include <machine/asm.h>
+#include "iocscall.h"
+
+#define SCSI_ADHOC_BOOTPART
+
+#define BASEOFF                0x8000
+#define BASEPTR_A      (TEXTADDR+BASEOFF)
+#define BASEPTR_R      %pc@(top+BASEOFF:W)
+
+#define SRAM           0x00ED0000      /* SRAM stat addr */
+#define SRAM_MEMSZ     (SRAM + 8)      /* (L) size of main memory */
+#define MINMEM         0x00400000      /* at least 4MB required */
+
+#define BOOT_ERROR(s)  jbsr boot_error; .asciz s; .even
+
+       .globl  _C_LABEL(bootufs)
+       .text
+ASENTRY_NOPROFILE(start)
+ASENTRY_NOPROFILE(top)
+               bras    _ASM_LABEL(entry0)
+               .ascii  "SHARP/"
+               .ascii  "X680x0"
+               .word   0x8199,0x94e6,0x82ea,0x82bd
+               .word   0x8e9e,0x82c9,0x82cd,0x8cbb
+               .word   0x8ec0,0x93a6,0x94f0,0x8149
+               .word   0
+| 0x2000 (FD), 0x2400 (SASI/SCSI) (¤â¤·¤¯¤Ï 0x0f0000)
+| d4 ¤Ë¤Ï¤¹¤Ç¤Ë SCSI ID ¤¬Æþ¤Ã¤Æ¤¤¤ë
+| ¤³¤³¤«¤é jmp ¤Þ¤Ç¤Ï¥ê¥í¥±¡¼¥¿¥Ö¥ë¤Ë½ñ¤«¤Í¤Ð¤Ê¤é¤Ê¤¤¡£
+ASENTRY_NOPROFILE(entry0)
+               moveml  %d0-%d7/%a0-%a7,_C_LABEL(startregs)
+               lea     BASEPTR_A:l,%a5         | set base ptr
+#define _RELOC(adr)    %a5@(((adr)-(BASEPTR_A&0xffff)):W)
+#define ASRELOC(var)   _RELOC(_ASM_LABEL(var))
+#define RELOC(var)     _RELOC(_C_LABEL(var))
+
+               lea     RELOC(edata),%a1
+               bra     _ASM_LABEL(entry)
+
+|      Disklabel= 404bytes
+|      Since LABELLOFFSET in <machine/disklabel.h> is 0x40,
+|      entry must be after 0x000001d4 (0x000f01d4)
+               nop
+disklabel:
+               .space  404
+
+ASENTRY_NOPROFILE(entry)
+               movew   #_end-1,%d0     | bss end (low word only)
+
+               | clear out bss  (must be <= 64KB)
+               subw    %a1,%d0
+clrbss:                clrb    %a1@+
+               dbra    %d0,clrbss
+
+               movel   %d4,RELOC(ID)   | SCSI ID (if booted from SCSI)
+
+               | set system stack
+               lea     ASRELOC(top),%a1 | set stack pointer to 0x000F0000
+               lea     %a1@,%sp        | a1 will be used later for IOCS calls
+
+               | we use 68020 instructions, and check MPU beforehand
+               |
+               | here d1.w = -1, and the above "subw a1,d0" = 0x9049, and
+               |       if MPU <= 010   loads 0x49,
+               |       if MPU >= 020   loads 0x90.
+               | This is a move, not a tst instruction
+               | because pc-relative tsts are not availble on 000/010.
+chkmpu:                moveb   %pc@(clrbss-chkmpu-2:B,%d0:W:2),%d0     | 103B 02xx
+               jmi     mpuok           | MC68020 or later
+               BOOT_ERROR("MPU 68000?")
+mpuok:         | XXX check for MMU?
+
+               IOCS(__BOOTINF)
+               lsll    #8,%d0          | clear MSByte
+               lsrl    #8,%d0          |
+               movel   %d0,RELOC(BOOT_INFO)
+
+               |
+               | 0x80...0x8F           SASI
+               | 0x90...0x93           Floppy
+               | 0xED0000...0xED3FFE   SRAM
+               | others                ROM (SCSI?)
+               |
+               movel   %d0,%d1
+               clrb    %d1
+               tstl    %d1
+               jne     boot_ram_rom
+               |
+               | SASI or Floppy
+               |
+               movel   %d0,%d2
+               andib   #0xFC,%d0
+               cmpib   #0x90,%d0
+               jne     boot_dev_unsupported    | boot from SASI?
+               |
+               | Floppy
+               |
+               moveb   %d2,%d0
+               andib   #0x03,%d0               | drive # (head=0)
+               jbsr    check_fd_format
+               moveml  %d0-%d1,RELOC(FDSECMINMAX) | min and max sec #
+               lslw    #8,%d2
+               moveq   #0x70,%d1
+               orw     %d2,%d1         | PDA*256 + MODE
+               movel   %d1,RELOC(FDMODE)
+               movel   %d0,%d2         | read position (first sector)
+               movel   #8192,%d3       | read bytes
+               IOCS(__B_READ)
+               jra     boot_read_done
+
+#include "chkfmt.s"
+
+boot_ram_rom:
+               movel   %d0,%d1
+               swap    %d1
+               cmpiw   #0x00ED,%d1
+               jne     boot_SCSI
+               | boot from SRAM?
+
+boot_dev_unsupported:
+               BOOT_ERROR("unsupported boot device")
+
+|
+| volatile void BOOT_ERROR(const char *msg);
+|      print error message, wait for key press and reboot
+|
+booterr_msg:   .asciz  "\r\n\n"
+reboot_msg:    .asciz  "\r\n[Hit key to reboot]"
+               .even
+
+ENTRY_NOPROFILE(BOOT_ERROR)
+               addql   #4,%sp
+
+boot_error:    lea     %pc@(booterr_msg),%a1
+               IOCS(__B_PRINT)
+               moveal  %sp@+,%a1
+               IOCS(__B_PRINT)
+ENTRY_NOPROFILE(exit)
+ENTRY_NOPROFILE(_rtt)
+               lea     %pc@(reboot_msg),%a1
+               IOCS(__B_PRINT)
+
+               | wait for a key press (or release of a modifier)
+               IOCS(__B_KEYINP)
+
+               | issue software reset
+               trap    #10
+               | NOTREACHED
+
+
+               |
+               | ROM boot ... probably from SCSI
+               |
+boot_SCSI:
+#ifdef SCSI_ADHOC_BOOTPART
+               |
+               | Find out boot partition in an ad hoc manner.
+               |
+
+               | get block length of the SCSI disk
+               SCSIIOCS(__S_READCAP)   | using buffer at a1



Home | Main Index | Thread Index | Old Index