Module Name: src
Committed By: minoura
Date: Tue Mar 20 13:01:33 UTC 2012
Added Files:
src/sys/arch/x68k/stand/xxboot: Makefile Makefile.xxboot boot.S
bootmain.c conf.c consio1.c version xx.c xxboot.ldscript
src/sys/arch/x68k/stand/xxboot/cdboot_cd9660: Makefile
src/sys/arch/x68k/stand/xxboot/xxboot_ffsv1: Makefile
src/sys/arch/x68k/stand/xxboot/xxboot_ffsv2: Makefile
src/sys/arch/x68k/stand/xxboot/xxboot_lfsv1: Makefile
src/sys/arch/x68k/stand/xxboot/xxboot_lfsv2: Makefile
Log Message:
Initial support for xxboot (cdboot_cd9660, specifically).
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.15 src/sys/arch/x68k/stand/xxboot/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot \
src/sys/arch/x68k/stand/xxboot/boot.S \
src/sys/arch/x68k/stand/xxboot/bootmain.c \
src/sys/arch/x68k/stand/xxboot/conf.c \
src/sys/arch/x68k/stand/xxboot/consio1.c \
src/sys/arch/x68k/stand/xxboot/version \
src/sys/arch/x68k/stand/xxboot/xx.c \
src/sys/arch/x68k/stand/xxboot/xxboot.ldscript
cvs rdiff -u -r0 -r1.1 src/sys/arch/x68k/stand/xxboot/cdboot_cd9660/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/x68k/stand/xxboot/xxboot_ffsv1/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/x68k/stand/xxboot/xxboot_ffsv2/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/x68k/stand/xxboot/xxboot_lfsv1/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/x68k/stand/xxboot/xxboot_lfsv2/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Added files:
Index: src/sys/arch/x68k/stand/xxboot/Makefile
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/Makefile:1.15
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/Makefile Tue Mar 20 13:01:32 2012
@@ -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>
Index: src/sys/arch/x68k/stand/xxboot/Makefile.xxboot
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/Makefile.xxboot Tue Mar 20 13:01:32 2012
@@ -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>
Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/boot.S:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/boot.S Tue Mar 20 13:01:32 2012
@@ -0,0 +1,474 @@
+| file: boot.S
+| author: chapuni([email protected])
+| Yasha([email protected])
+|
+| $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
+ tstl %d0
+ jeq 1f
+ BOOT_ERROR("READCAP failed")
+1: moveq #0,%d5
+ moveb %a1@(6),%d5 | 1: 256, 2: 512, 4: 1024, 8: 2048
+ lsrb #1,%d5 | 0: 256, 1: 512, 2: 1024, 4: 2048
+ movel %d5,RELOC(SCSI_BLKLEN)
+
+ | find out the start position of the boot partition
+ | XXX VERY AD HOC
+ |
+ | ROM firmware:
+ | pass read pos (in block #) in d2
+ | Human68k-style partition table does not exist
+ | d2 is 4 at the maximum
+ | SCSI IPLs (genuine and SxSI):
+ | pass read pos (in kilobytes) in d2
+ | d2 is bigger than 0x20
+ | partition table on the memory is destroyed
+ | BOOT MENU Ver.2.22:
+ | passes partition table entry address in a0
+ | d2 is cleared to zero
+ | No other IPL is supported. XXX FIXME
+ tstl %d2
+ jne sc1
+ | no information in d2 -- probably from BOOT MENU
+ | a0 points the partiion table entry
+ movel %a0@(0x0008),%d2 | in KByte
+sc1: cmpl #0x20,%d2
+ jcs sc2
+ lsll #8,%d2 | clear MSByte
+ lsrl #7,%d2 | in 512 byte block
+ divul %d5,%d2 | in sector
+sc2:
+ | read entire boot
+ moveq #TDSIZE/512,%d3 | size is TDSIZE byte
+ divul %d5,%d3 | in sector
+ jbsr scsiread | read at %a1
+
+ cmpil #5,%d2
+ bcc sc3
+ movql #0,%d2
+sc3: movel %d2,RELOC(SCSI_PARTTOP)
+#else
+ moveq #1,%d5 | 512bytes/sec
+ movel %d5,%sp@-
+ moveq #8192/512,%d3 | �ɤ߹������祵����
+ moveq #0x40,%d2 | ���������Ǥ�(sd*a �Τ�)
+ SCSIIOCS(__S_READ)
+#endif
+
+boot_read_done:
+ jmp first_kbyte
+
+read_error: BOOT_ERROR("read error")
+
+#undef RELOC /* base register a5 is no longer available */
+#undef ASRELOC
+#undef _RELOC
+
+|
+| read SCSI
+|
+| input: d2.l: pos in sector
+| d3.l: len in sector
+| d4: target SCSI ID
+| d5: sector length (1: 512, 2: 1024, 4: 2048)
+| a1: buffer address
+| destroy:
+| d0, d1, a1
+|
+scsiread:
+ moveml %d2-%d3/%d6-%d7/%a2,%sp@-
+ | if (pos >= 0x200000 || (len > 255 && pos + len >= 0x200000))
+ | use READEXT
+ | else
+ | use READ
+ moveq #0x20,%d0
+ swap %d0 | d0.l = 0x00200000
+ moveq #0,%d6
+ subqb #1,%d6 | d6.l = 255
+ movel %d5,%d7
+ lsll #8,%d7
+ lsll #1,%d7 | d7 = sector length (byte)
+ cmpl %d0,%d2
+ jcc scsiread_ext
+ moveq #__S_READ,%d1
+ cmpl %d3,%d6
+ jcc scsiread_noext
+ subl %d2,%d0 | d0.0 = 0x200000 - pos
+ cmpl %d0,%d3 | <= len
+ jcs scsiread_noext | no
+
+scsiread_ext: | use READEXT
+ extw %d6 | d6.l = 65535
+ moveq #__S_READEXT,%d1
+
+scsiread_noext: | use READ
+loop_scsiread:
+ | d1: SCSI IOCS call #
+ | d6: max sector count at a time
+ movel %d3,%a2 | save original len in a2
+ cmpl %d3,%d6
+ jcc 1f
+ movel %d6,%d3
+1: IOCS(__SCSIDRV) | SCSIIOCS(d1)
+ tstl %d0
+ jne read_error
+ movel %d3,%d0
+ mulul %d7,%d0
+ addl %d0,%a1
+ exg %d3,%a2 | restore original len to d3
+ addl %a2,%d2 | pos += read count
+ subl %a2,%d3 | len -= read count
+ jne loop_scsiread
+ moveml %sp@+,%d2-%d3/%d6-%d7/%a2
+ rts
+
+|
+| The former part must reside in the first 1KB.
+|
+ .globl first_kbyte
+first_kbyte:
+|--------------------------------------------------------------------------
+|
+| The latter text+data part is not accessible at the first boot time.
+| PC-relative can be used from here.
+|
+ jmp _C_LABEL(bootmain) | 0x0Fxxxx ������Ǥ椯
+
+ .word 0
+
+| int badbaddr __P((void *adr));
+| check if the given address is valid for byte read
+| return: 0: valid, 1: not valid
+
+ENTRY_NOPROFILE(badbaddr)
+ lea 0x0008:W,%a1 | MPU Bus Error vector
+ moveq #1,%d0
+ lea %pc@(badr1),%a0
+ movew %sr,%sp@-
+ oriw #0x0700,%sr | keep out interrupts
+ movel %a1@,%sp@-
+ movel %a0,%a1@ | set bus error vector
+ movel %sp,%d1 | save sp
+ moveal %sp@(10),%a0
+ tstb %a0@ | try read...
+ moveq #0,%d0 | this is skipped on bus error
+badr1: moveal %d1,%sp | restore sp
+ movel %sp@+,%a1@
+ movew %sp@+,%sr
+ rts
+
+| void RAW_READ __P((void *buf, u_int32_t blkpos, size_t bytelen));
+| inputs:
+| buf: input buffer address
+| blkpos: read start position in the partition in 512byte-blocks
+| bytelen: read length in bytes
+
+Lraw_read_buf=4+(4*11)
+Lraw_read_pos_=Lraw_read_buf+4
+Lraw_read_len=Lraw_read_buf+8
+
+#ifdef SCSI_ADHOC_BOOTPART
+| RAW_READ of physical disk
+ENTRY_NOPROFILE(RAW_READ0)
+ moveq #0,%d0
+ jra raw_read1
+#endif
+
+ENTRY_NOPROFILE(RAW_READ)
+#ifdef SCSI_ADHOC_BOOTPART
+ movel _C_LABEL(SCSI_PARTTOP),%d0
+raw_read1:
+#endif
+ moveml %d2-%d7/%a2-%a6,%sp@-
+ moveml %sp@(Lraw_read_buf),%d1-%d3
+ movel %d1,%a1
+ | d2.l: pos in 512byte-blocks
+ | d3.l: length in bytes
+ | a1 (=d1): buffer address
+
+ lea BASEPTR_R,%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))
+
+ tstb _RELOC(_C_LABEL(BOOT_INFO)+1) | simple check. may be incorrect!
+ beqs raw_read_floppy
+
+raw_read_scsi:
+ movel RELOC(ID),%d4 | SCSI ID
+#ifdef SCSI_ADHOC_BOOTPART
+ movel RELOC(SCSI_BLKLEN),%d5 | sector size: 0-2
+ | XXX length must be sector aligned
+ lsrl #8,%d3 | size in 256byte-blocks
+ lsrl #1,%d3
+ divul %d5,%d3 | size in sector
+ beqs read_half | minimal error check
+ divul %d5,%d2 | pos in sector
+ addl %d0,%d2 | physical pos in sector
+#else
+ moveq #1,%d5 | 512bytes/sec
+ moveq #9,%d0 | shift count
+ addl #511,%d3
+ lsrl %d0,%d3
+ bcss read_half | minimal error check
+
+ addl #0x40,%d2 | 'a' partition starts here
+#endif
+| jcc 1f
+| BOOT_ERROR("out of seek") | pos exceeds 32bit
+|1:
+ jbsr scsiread
+ bras raw_read_end
+
+raw_read_floppy:
+ |
+ | Floppy read routine
+ |
+
+ | convert to seek position
+
+ asll #2,%d2 | size in 128byte-blocks
+
+ | sec = raw_read_pos (d2)
+ | sec >>= 7 + (sector length: 0-3)
+
+ lea RELOC(FDSECMINMAX),%a0
+ moveq #0,%d1
+ moveb %a0@,%d1 | d1: sector length (0-3)
+ lsrl %d1,%d2 | d2: pos in sector
+ bcss read_half | error check
+
+ | trk = sec / (# sectors)
+ | sec = sec % (# sectors)
+
+ moveb %a0@(7),%d1 | d1: max sector #
+ subb %a0@(3),%d1 | - min sector #
+ addqb #1,%d1 | d1: # sectors
+ divu %d1,%d2 | d2: (sec << 16) | track
+
+ | position = (sec length << 24) | (track/2 << 16)
+ | | (track%2 << 8) | (min sec # + sec)
+
+ movel %a0@,%d0 | d0: (sec len << 24) | min sec #
+ lsrw #1,%d2 | d2: (sec << 16) | (track / 2)
+ jcc 1f
+ bset #8,%d0 | |= (track % 2) << 8
+1: swap %d2 | d2: ((track / 2) << 16) | sec
+ addl %d0,%d2 | d2: position
+
+ | read
+ movel RELOC(FDMODE),%d1 | PDA*256 + MODE
+
+ | B_READ (for floppy)
+ | d1.w: PDA x 256 + MODE
+ | PDA: 0x90 (drive 0) ... 0x93 (drive 3)
+ | MODE: bit6: MFM
+ | bit5: retry
+ | bit4: seek
+ | d2.l: position
+ | bit31-24: sector length (0: 128, 1: 256, 2: 512, 3: 1K)
+ | bit23-16: track # (0-79)
+ | bit15-08: side (0 or 1)
+ | bit07-00: sector # (1-)
+ | d3.l: read bytes
+ | a1: read address
+ | return:
+ | d0: bit 31-24 ST0
+ | bit 23-16 ST1
+ | bit 15- 8 ST2
+ | bit 7- 0 C
+ | -1 on parameter error
+ | destroy: d0, d2, d3, a1
+ IOCS(__B_READ)
+ andil #0xf8ffff00,%d0 | check status (must be zero)
+ jne read_error
+
+raw_read_end:
+ moveml %sp@+,%a2-%a6/%d2-%d7
+ rts
+#undef _RELOC /* base register a5 is no longer available */
+#undef ASRELOC
+#undef RELOC
+
+read_half: BOOT_ERROR("read half of block")
+
+
+|
+| global variables
+|
+ BSS(ID, 4) | SCSI ID
+ BSS(BOOT_INFO, 4) | result of IOCS(__BOOTINF)
+ BSS(FDMODE, 4) | Floppy access mode: PDA x 256 + MODE
+ BSS(FDSECMINMAX, 8) | +0: (min sector) sector length
+ | +1: (min sector) track #
+ | +2: (min sector) side
+ | +3: (min sector) sector #
+ | +4: (max sector) sector length
+ | +5: (max sector) track #
+ | +6: (max sector) side
+ | +7: (max sector) sector #
+#ifdef SCSI_ADHOC_BOOTPART
+ BSS(SCSI_PARTTOP, 4) | start sector of boot partition
+ BSS(SCSI_BLKLEN ,4) | sector len 0: 256, 1: 512, 2: 1024
+#endif
Index: src/sys/arch/x68k/stand/xxboot/bootmain.c
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/bootmain.c:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/bootmain.c Tue Mar 20 13:01:32 2012
@@ -0,0 +1,135 @@
+/* $NetBSD: bootmain.c,v 1.1 2012/03/20 13:01:32 minoura Exp $ */
+
+/*-
+ * Copyright (c) 1993, 1994 Takumi Nakamura.
+ * Copyright (c) 1999, 2000 Itoh Yasufumi.
+ * Copyright (c) 2001 Minoura Makoto.
+ *
+ * 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 Takumi Nakamura.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 <sys/param.h>
+#include <sys/types.h>
+#include <machine/bootinfo.h>
+#include <lib/libsa/stand.h>
+#include <lib/libsa/loadfile.h>
+
+#include "libx68k.h"
+#include "iocs.h"
+#include "exec_image.h"
+
+#define EXSCSI_BDID ((void*) 0x00ea0001)
+
+/* boot_cd9660.S */
+extern int badbaddr __P((volatile void *adr));
+extern unsigned int ID; /* target SCSI ID */
+extern unsigned int BOOT_INFO; /* result of IOCS(__BOOTINF) */
+
+/* for debug */
+unsigned int startregs[16];
+
+static int get_scsi_host_adapter (char *);
+void bootmain (void) __attribute__ ((__noreturn__));
+
+/*
+ * Check the type of SCSI interface
+ */
+static int
+get_scsi_host_adapter(devstr)
+ char *devstr;
+{
+ char *bootrom;
+ int ha;
+
+ *(int *)devstr = '/' << 24 | 's' << 16 | 'p' << 8 | 'c';
+ *(int *)(devstr + 4) = '@' << 24 | '0' << 16 | '/' << 8 | 'c';
+ *(int *)(devstr + 8) = 'd' << 24 | '@' << 16 | '0' << 8 | ',';
+ *(int *)(devstr + 12) = '0' << 24 | ':' << 16 | 'a' << 8 | '\0';
+
+ bootrom = (char *) (BOOT_INFO & 0x00ffffe0);
+ /*
+ * bootrom+0x24 "SCSIIN" ... Internal SCSI (spc@0)
+ * "SCSIEX" ... External SCSI (spc@1 or mha@0)
+ */
+ if (*(u_short *)(bootrom + 0x24 + 4) == 0x494e) { /* "IN" */
+ ha = (X68K_BOOT_SCSIIF_SPC << 4) | 0;
+ } else if (badbaddr(EXSCSI_BDID)) {
+ ha = (X68K_BOOT_SCSIIF_MHA << 4) | 0;
+ *(int *)devstr = '/' << 24 | 'm' << 16 | 'h' << 8 | 'a';
+ } else {
+ ha = (X68K_BOOT_SCSIIF_SPC << 4) | 1;
+ devstr[5] = '1';
+ }
+
+ return ha;
+}
+
+extern const char bootprog_name[], bootprog_rev[];
+
+void
+bootmain(void)
+{
+ int bootdev, ha, fd;
+ char bootdevstr[16];
+ u_long marks[MARK_MAX];
+
+#ifdef DEBUG
+ printf("%s rev.%s\n", bootprog_name, bootprog_rev);
+#endif
+
+ ha = get_scsi_host_adapter(bootdevstr);
+ bootdevstr[10] = '0' + (ID & 7);
+ bootdevstr[14] = 'a';
+ bootdev = X68K_MAKESCSIBOOTDEV(X68K_MAJOR_CD, ha >> 4, ha & 15,
+ ID & 7, 0, 0);
+#ifdef DEBUG
+ printf(" boot device: %s\n", bootdevstr);
+#endif
+
+ marks[MARK_START] = BOOT_TEXTADDR;
+ fd = loadfile("x68k/boot", marks, LOAD_TEXT|LOAD_DATA|LOAD_BSS);
+ if (fd < 0)
+ fd = loadfile("boot", marks, LOAD_TEXT|LOAD_DATA|LOAD_BSS);
+ if (fd >= 0) {
+ close(fd);
+ exec_image(BOOT_TEXTADDR, /* image loaded at */
+ BOOT_TEXTADDR, /* image executed at */
+ BOOT_TEXTADDR, /* XXX: entry point */
+ 0, /* XXX: image size */
+ bootdev, 0); /* arguments */
+ }
+ IOCS_B_PRINT("can't load the secondary bootstrap.");
+ exit(0);
+}
+
+extern int xxboot(struct open_file *);
+int
+devopen(struct open_file *f, const char *fname, char **file)
+{
+ return xxopen(f);
+}
Index: src/sys/arch/x68k/stand/xxboot/conf.c
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/conf.c:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/conf.c Tue Mar 20 13:01:32 2012
@@ -0,0 +1,32 @@
+/* $NetBSD: conf.c,v 1.1 2012/03/20 13:01:32 minoura Exp $ */
+
+/*
+ * Copyright (c) 2001,2010 Minoura Makoto
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 AUTHOR 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 <sys/param.h>
+#include <lib/libsa/stand.h>
+
+struct open_file files[SOPEN_MAX];
Index: src/sys/arch/x68k/stand/xxboot/consio1.c
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/consio1.c:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/consio1.c Tue Mar 20 13:01:32 2012
@@ -0,0 +1,52 @@
+/* $NetBSD: consio1.c,v 1.1 2012/03/20 13:01:32 minoura Exp $ */
+
+/*
+ * Copyright (c) 2001,2010 MINOURA Makoto.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <sys/stdarg.h>
+#include <lib/libkern/libkern.h>
+#include <lib/libsa/stand.h>
+
+#include "libx68k.h"
+
+#include "iocs.h"
+#include "consio.h"
+
+int
+getchar(void)
+{
+ int r;
+
+ while ((r = IOCS_B_KEYINP () & 0xff) == 0);
+ return r;
+}
+
+void
+putchar(int c)
+{
+ if (c == '\n')
+ putchar('\r');
+ IOCS_B_PUTC (c);
+}
Index: src/sys/arch/x68k/stand/xxboot/version
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/version:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/version Tue Mar 20 13:01:32 2012
@@ -0,0 +1,7 @@
+$NetBSD: version,v 1.1 2012/03/20 13:01:32 minoura Exp $
+
+NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
+file is important - make sure the entries are appended on end, last item
+is taken as the current.
+
+1.0: Initial revision.
Index: src/sys/arch/x68k/stand/xxboot/xx.c
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/xx.c:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/xx.c Tue Mar 20 13:01:32 2012
@@ -0,0 +1,57 @@
+/* $NetBSD: xx.c,v 1.1 2012/03/20 13:01:32 minoura Exp $ */
+
+/*
+ * Copyright (c) 2010 MINOURA Makoto.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <sys/param.h>
+
+struct open_file;
+extern void RAW_READ __P((void *buf, u_int32_t blkpos, size_t bytelen));
+int xxopen(struct open_file *);
+int xxclose(struct open_file *);
+int xxstrategy(void *, int, daddr_t, size_t, void *, size_t *);
+
+int
+xxopen(struct open_file *f)
+{
+ return 0;
+}
+
+int
+xxclose(struct open_file *f)
+{
+ return 0;
+}
+
+extern unsigned int SCSI_BLKLEN;
+int
+xxstrategy(void *arg, int rw, daddr_t dblk, size_t size,
+ void *buf, size_t *rsize)
+{
+ RAW_READ(buf, (u_int32_t)dblk, size);
+ if (rsize)
+ *rsize = size;
+ return 0;
+}
Index: src/sys/arch/x68k/stand/xxboot/xxboot.ldscript
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/xxboot.ldscript Tue Mar 20 13:01:32 2012
@@ -0,0 +1,49 @@
+OUTPUT_FORMAT("binary", "binary", "binary")
+OUTPUT_ARCH(m68k)
+ENTRY(start)
+SEARCH_DIR(/usr/lib);
+/*__DYNAMIC = 0; */
+PROVIDE (__stack = 0);
+SECTIONS
+{
+ . = 0x000f0000;
+ .text :
+ {
+ CREATE_OBJECT_SYMBOLS
+ *(.text)
+ *(.rodata)
+ /* The next six sections are for SunOS dynamic linking. The order
+ is important. */
+ *(.dynrel)
+ *(.hash)
+ *(.dynsym)
+ *(.dynstr)
+ *(.rules)
+ *(.need)
+ etext = .;
+ _etext = .;
+ }
+/* . = ALIGN(0x2000); */
+ .data :
+ {
+ /* The first three sections are for SunOS dynamic linking. */
+ *(.dynamic)
+ *(.got)
+ *(.plt)
+ *(.data)
+ *(.linux-dynamic) /* For Linux dynamic linking. */
+ CONSTRUCTORS
+ edata = .;
+ _edata = .;
+ }
+ . = 0x0f2000;
+ .bss :
+ {
+ __bss_start = .;
+ *(.bss)
+ *(COMMON)
+ end = ALIGN(4) ;
+ _end = ALIGN(4) ;
+ }
+ /DISCARD/ : { *(.ident) *(.stab) *(.stabstr) }
+}
Index: src/sys/arch/x68k/stand/xxboot/cdboot_cd9660/Makefile
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/cdboot_cd9660/Makefile:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/cdboot_cd9660/Makefile Tue Mar 20 13:01:32 2012
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2012/03/20 13:01:32 minoura Exp $
+
+DEV= xx
+DEVDRV= xx
+FS= cd9660
+BOOTCPPFLAGS= -DCDBOOT -DFDBOOT -DSDBOOT
+
+TOUCHPROG= \
+ ( ( echo -n X68SCSI1 | dd bs=2048 conv=sync ) ; \
+ ( cat ${PROG} | dd bs=2048 conv=sync ) ) > ${PROG}.n ; \
+ mv ${PROG}.n ${PROG}
+
+.include "../Makefile.xxboot"
Index: src/sys/arch/x68k/stand/xxboot/xxboot_ffsv1/Makefile
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/xxboot_ffsv1/Makefile:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/xxboot_ffsv1/Makefile Tue Mar 20 13:01:33 2012
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2012/03/20 13:01:33 minoura Exp $
+
+DEV= xx
+DEVDRV= xx
+FS= ffsv1
+BOOTCPPFLAGS= -DSDBOOT
+
+TOUCHPROG=
+
+.include "../Makefile.xxboot"
Index: src/sys/arch/x68k/stand/xxboot/xxboot_ffsv2/Makefile
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/xxboot_ffsv2/Makefile:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/xxboot_ffsv2/Makefile Tue Mar 20 13:01:33 2012
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2012/03/20 13:01:33 minoura Exp $
+
+DEV= xx
+DEVDRV= xx
+FS= ffsv2
+BOOTCPPFLAGS= -DSDBOOT
+
+TOUCHPROG=
+
+.include "../Makefile.xxboot"
Index: src/sys/arch/x68k/stand/xxboot/xxboot_lfsv1/Makefile
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/xxboot_lfsv1/Makefile:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/xxboot_lfsv1/Makefile Tue Mar 20 13:01:33 2012
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2012/03/20 13:01:33 minoura Exp $
+
+DEV= xx
+DEVDRV= xx
+FS= lfsv1
+BOOTCPPFLAGS= -DSDBOOT
+
+TOUCHPROG=
+
+.include "../Makefile.xxboot"
Index: src/sys/arch/x68k/stand/xxboot/xxboot_lfsv2/Makefile
diff -u /dev/null src/sys/arch/x68k/stand/xxboot/xxboot_lfsv2/Makefile:1.1
--- /dev/null Tue Mar 20 13:01:33 2012
+++ src/sys/arch/x68k/stand/xxboot/xxboot_lfsv2/Makefile Tue Mar 20 13:01:33 2012
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2012/03/20 13:01:33 minoura Exp $
+
+DEV= xx
+DEVDRV= xx
+FS= lfsv2
+BOOTCPPFLAGS= -DSDBOOT
+
+TOUCHPROG=
+
+.include "../Makefile.xxboot"