Make the bootblocks build with ELF assembler.

This commit is contained in:
thomas 2001-09-05 19:48:12 +00:00
parent ff5f5ea027
commit 42f770df19
7 changed files with 596 additions and 550 deletions

View File

@ -1,14 +1,14 @@
# $NetBSD: Makefile.inc,v 1.3 1997/05/09 07:50:29 mycroft Exp $
# $NetBSD: Makefile.inc,v 1.4 2001/09/05 19:48:12 thomas Exp $
BINDIR= /usr/mdec
BINMODE= ${NONBINMODE}
STRIPFLAG=
LDFLAGS= -nostdlib -static -Wl,-T0,-N
LDFLAGS= -nostdlib -static -Wl,-x,-Ttext,0,-N
CPPFLAGS+= -I- -I. -I..
beforeinstall:
dd if=${PROG} of=${PROG}X bs=32 skip=1 count=16 2>/dev/null
objcopy -O binary ${PROG} ${PROG}X
@mv -f ${PROG} ${PROG}XX
@mv -f ${PROG}X ${PROG}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdb00t.ahdi.s,v 1.2 1996/12/28 23:38:00 leo Exp $ */
/* $NetBSD: sdb00t.ahdi.s,v 1.3 2001/09/05 19:48:12 thomas Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens
@ -32,143 +32,151 @@
#include "xxboot.h"
#ifdef __ELF__
.globl _start, main, fill, end
.text
_start: bras main
#else
.globl start, main, fill, end
.text
start: bras main
#endif
bra rds0
main: bclr #2,(_drvbits+3):w
clrl pun_ptr:w
movml d3/d5,sp@-
movw #-1,sp@-
movw #Kbshift,sp@-
movml %d3/%d5,%sp@-
movw #-1,%sp@-
movw #Kbshift,%sp@-
trap #BIOS
addql #4,sp
btst #3,d0 | Alternate?
addql #4,%sp
btst #3,%d0 | Alternate?
bnes exit
movq #3,d0
lea pc@(p0_dsc),a0
cmpl #0x444d4172,d3 | SCSI bootdev?
movq #3,%d0
lea %pc@(p0_dsc),%a0
cmpl #0x444d4172,%d3 | SCSI bootdev?
beqs 0f
movq #-1,d4 | no, ACSI
movq #0,d5
0: movb d5,d1 | NVRAM bootpref
movq #-1,%d4 | no, ACSI
movq #0,%d5
0: movb %d5,%d1 | NVRAM bootpref
bnes 1f
| The Hades bios does not provide a bootprev. In case
| of doubt, we fetch it ourselves.
movb #BOOTPREF,rtcrnr:w
movb rtcdat:w,d1
movb rtcdat:w,%d1
bnes 1f
movq #-8,d1 | bootpref = any
movq #-8,%d1 | bootpref = any
1: movb a0@,d2 | bootflags
btst #0,d2
1: movb %a0@,%d2 | bootflags
btst #0,%d2
beqs 2f
andb d1,d2
andb %d1,%d2
bnes boot
2: lea a0@(12),a0
dbra d0,1b
2: lea %a0@(12),%a0
dbra %d0,1b
exit: movml sp@+,d3/d5
exit: movml %sp@+,%d3/%d5
tostst: clrw _bootdev:w
movl _sysbase:w,a0
movl a0@(24),d0
swap d0
cmpl #0x19870422,d0 | old TOS?
movl _sysbase:w,%a0
movl %a0@(24),%d0
swap %d0
cmpl #0x19870422,%d0 | old TOS?
bccs 0f | no
movw #0xe0,d7
movw #0xe0,%d7
0: rts
boot: movl a0@(4),d6
movq #1,d5
lea pc@(end),a4
boot: movl %a0@(4),%d6
movq #1,%d5
lea %pc@(end),%a4
bsrs rds0
tstw d0
tstw %d0
bnes exit
movl a4,a0
movw #0xff,d0
movq #0,d1
0: addw a0@+,d1
dbra d0,0b
cmpw #0x1234,d1
movl %a4,%a0
movw #0xff,%d0
movq #0,%d1
0: addw %a0@+,%d1
dbra %d0,0b
cmpw #0x1234,%d1
bnes exit
lea pc@(rds0),a3
lea pc@(tostst),a5
movml sp@+,d3/d5
jmp a4@ | start bootsector code
lea %pc@(rds0),%a3
lea %pc@(tostst),%a5
movml %sp@+,%d3/%d5
jmp %a4@ | start bootsector code
/*
* in: d4/d7 (target) d5 (count), d6 (offset), a4 (buffer)
* out: d0 (<= 0)
* mod: d0, d1, d2, a0, a1, a5, a6
*/
rds0: tstl d4
rds0: tstl %d4
bmis 0f
movw d4,sp@- | device
pea a4@ | buffer
movw d5,sp@- | count
movl d6,sp@- | offset
movw #DMAread,sp@-
movw %d4,%sp@- | device
pea %a4@ | buffer
movw %d5,%sp@- | count
movl %d6,%sp@- | offset
movw #DMAread,%sp@-
trap #XBIOS
lea sp@(14),sp
lea %sp@(14),%sp
rts
0: st flock:w
movl _hz_200:w,d0
addql #2,d0
1: cmpl _hz_200:w,d0
movl _hz_200:w,%d0
addql #2,%d0
1: cmpl _hz_200:w,%d0
bccs 1b
movml d6/a4,sp@-
lea dmahi:w,a6
movb sp@(7),a6@(4)
movb sp@(6),a6@(2)
movb sp@(5),a6@
lea pc@(r0com),a6
movb sp@(1),a6@(1)
movb sp@(2),a6@(5)
movb sp@(3),a6@(9)
movb d5,a6@(13)
addql #8,sp
lea dmodus:w,a6
lea daccess:w,a5
movw #0x198,a6@
movw #0x098,a6@
movw d5,a5@
movw #0x88,a6@
movq #0,d0
movb d7,d0
orb #0x08,d0
swap d0
movw #0x8a,d0
movml %d6/%a4,%sp@-
lea dmahi:w,%a6
movb %sp@(7),%a6@(4)
movb %sp@(6),%a6@(2)
movb %sp@(5),%a6@
lea %pc@(r0com),%a6
movb %sp@(1),%a6@(1)
movb %sp@(2),%a6@(5)
movb %sp@(3),%a6@(9)
movb %d5,%a6@(13)
addql #8,%sp
lea dmodus:w,%a6
lea daccess:w,%a5
movw #0x198,%a6@
movw #0x098,%a6@
movw %d5,%a5@
movw #0x88,%a6@
movq #0,%d0
movb %d7,%d0
orb #0x08,%d0
swap %d0
movw #0x8a,%d0
bsrs shake
lea pc@(r0com),a0
movq #3,d2
2: movl a0@+,d0
lea %pc@(r0com),%a0
movq #3,%d2
2: movl %a0@+,%d0
bsrs shake
dbra d2,2b
movq #0x0a,d0
movl d0,a5@
movl #0x190,d1
dbra %d2,2b
movq #0x0a,%d0
movl %d0,%a5@
movl #0x190,%d1
bsrs wait
movw #0x8a,a6@
movw a5@,d0
andw #0xff,d0
movw #0x8a,%a6@
movw %a5@,%d0
andw #0xff,%d0
beqs 0f
r0err: movq #-1,d0
0: movw #0x80,a6@
r0err: movq #-1,%d0
0: movw #0x80,%a6@
clrb flock:w
r0ret: rts
shake: movl d0,a5@
movq #0x0a,d1
wait: addl _hz_200:w,d1
shake: movl %d0,%a5@
movq #0x0a,%d1
wait: addl _hz_200:w,%d1
0: btst #5,gpip:w
beqs r0ret
cmpl _hz_200:w,d1
cmpl _hz_200:w,%d1
bccs 0b
addql #4,sp
addql #4,%sp
bras r0err
r0com: .long 0x0000008a

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdb00t.ahdi.s,v 1.3 1996/12/28 23:38:01 leo Exp $ */
/* $NetBSD: wdb00t.ahdi.s,v 1.4 2001/09/05 19:48:12 thomas Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens
@ -32,139 +32,147 @@
#include "xxboot.h"
#ifdef __ELF__
.globl _start, main, fill, end
.text
_start: bras main
#else
.globl start, main, fill, end
.text
start: bras main
#endif
bra rds0
main: bclr #2,(_drvbits+3):w
clrl pun_ptr:w
movml d3/d5,sp@-
movw #-1,sp@-
movw #Kbshift,sp@-
movml %d3/%d5,%sp@-
movw #-1,%sp@-
movw #Kbshift,%sp@-
trap #BIOS
addql #4,sp
btst #3,d0 | Alternate?
addql #4,%sp
btst #3,%d0 | Alternate?
bnes exit
movq #3,d0
lea pc@(p0_dsc),a0
movb d5,d1 | NVRAM bootpref
movq #3,%d0
lea %pc@(p0_dsc),%a0
movb %d5,%d1 | NVRAM bootpref
bnes 0f
| The Hades bios does not provide a bootprev. In case
| of doubt, we fetch it ourselves.
movb #BOOTPREF,rtcrnr:w
movb rtcdat:w,d1
movb rtcdat:w,%d1
bnes 0f
movq #-8,d1 | bootpref = any
movq #-8,%d1 | bootpref = any
0: movb a0@,d2 | bootflags
btst #0,d2
0: movb %a0@,%d2 | bootflags
btst #0,%d2
beqs 1f
andb d1,d2
andb %d1,%d2
bnes boot
1: lea a0@(12),a0
dbra d0,0b
1: lea %a0@(12),%a0
dbra %d0,0b
exit: movml sp@+,d3/d5
exit: movml %sp@+,%d3/%d5
tostst: clrw _bootdev:w
movl _sysbase:w,a0
movl a0@(24),d0
swap d0
cmpl #0x19870422,d0 | old TOS?
movl _sysbase:w,%a0
movl %a0@(24),%d0
swap %d0
cmpl #0x19870422,%d0 | old TOS?
bccs 0f | no
movw #0xe0,d7
movw #0xe0,%d7
0: rts
boot: movl a0@(4),d6
movq #1,d5
lea pc@(end),a4
boot: movl %a0@(4),%d6
movq #1,%d5
lea %pc@(end),%a4
bsrs rds0
tstw d0
tstw %d0
bnes exit
movl a4,a0
movw #0xff,d0
movq #0,d1
0: addw a0@+,d1
dbra d0,0b
cmpw #0x1234,d1
movl %a4,%a0
movw #0xff,%d0
movq #0,%d1
0: addw %a0@+,%d1
dbra %d0,0b
cmpw #0x1234,%d1
bnes exit
lea pc@(rds0),a3
lea pc@(tostst),a5
movml sp@+,d3/d5
jmp a4@ | start bootsector code
lea %pc@(rds0),%a3
lea %pc@(tostst),%a5
movml %sp@+,%d3/%d5
jmp %a4@ | start bootsector code
/*
* in: d4 (target) d5 (count), d6 (offset), a4 (buffer)
* out: d0 (<= 0)
* mod: d0, d1, d2, a0, a1, a5, a6
*/
rds0: lea pc@(dpar),a6
tstb a6@
rds0: lea %pc@(dpar),%a6
tstb %a6@
bnes 0f
movb d4,d0
andb #1,d0
aslb #4,d0
orb #0xa0,d0
movb d0,idesdh:l
movl a4,a0
movq #0,d1
movb %d4,%d0
andb #1,%d0
aslb #4,%d0
orb #0xa0,%d0
movb %d0,idesdh:l
movl %a4,%a0
movq #0,%d1
movb #0,idedor:l
movb #0xec,idecr:l | IDENTIFY DRIVE
bsrs wait
bnes err
movb a4@(7),a6@ | tracks/cylinder
movb a4@(13),a6@(1) | sectors/track
0: movl d6,d1
movq #0,d0
movb a6@(1),d0
movq #0,d2
movb a6@,d2
mulu d0,d2
divu d2,d1
movb d1,idecl:l
lsrl #8,d1
movb d1,idech:l
lsrl #8,d1
divu d0,d1
movb d4,d0
andb #1,d0
aslb #4,d0
orb d0,d1
orb #0xa0,d1
movb d1,idesdh:l
swap d1
addqw #1,d1
movb d1,idesn:l
movl a4,a0
movb d5,idesc:l
movw d5,d1
subqw #1,d1
movb %a4@(7),%a6@ | tracks/cylinder
movb %a4@(13),%a6@(1) | sectors/track
0: movl %d6,%d1
movq #0,%d0
movb %a6@(1),%d0
movq #0,%d2
movb %a6@,%d2
mulu %d0,%d2
divu %d2,%d1
movb %d1,idecl:l
lsrl #8,%d1
movb %d1,idech:l
lsrl #8,%d1
divu %d0,%d1
movb %d4,%d0
andb #1,%d0
aslb #4,%d0
orb %d0,%d1
orb #0xa0,%d1
movb %d1,idesdh:l
swap %d1
addqw #1,%d1
movb %d1,idesn:l
movl %a4,%a0
movb %d5,idesc:l
movw %d5,%d1
subqw #1,%d1
movb #0,idedor:l
movb #0x20,idecr:l
wait: movl #0x7d0,d0
addl _hz_200:w,d0
wait: movl #0x7d0,%d0
addl _hz_200:w,%d0
2: btst #5,gpip:w
beqs 3f
cmpl _hz_200:w,d0
cmpl _hz_200:w,%d0
bhis 2b
err: movq #-1,d0
err: movq #-1,%d0
rts
3: movb idesr:l,d0
btst #0,d0
3: movb idesr:l,%d0
btst #0,%d0
bnes err
btst #3,d0
btst #3,%d0
beqs err
movq #63,d0
lea idedr:l,a1
4: movw a1@,a0@+
movw a1@,a0@+
movw a1@,a0@+
movw a1@,a0@+
dbra d0,4b
dbra d1,wait
movq #0,d0
movq #63,%d0
lea idedr:l,%a1
4: movw %a1@,%a0@+
movw %a1@,%a0@+
movw %a1@,%a0@+
movw %a1@,%a0@+
dbra %d0,4b
dbra %d1,wait
movq #0,%d0
rts
fill: .space 52

View File

@ -1,4 +1,4 @@
/* $NetBSD: xxboot.ahdi.s,v 1.4 1997/01/08 12:57:22 leo Exp $ */
/* $NetBSD: xxboot.ahdi.s,v 1.5 2001/09/05 19:48:13 thomas Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens.
@ -32,11 +32,19 @@
#include "xxboot.h"
#ifdef __ELF__
.globl _start, main, fill, end
.text
_start: bras main
#else
.globl start, main, fill, end
.text
start: bras main
#endif
/*
* Fake gemdos-fs bootsector, to keep TOS away.
*/
@ -61,129 +69,129 @@ start: bras main
* d7: ACSI target a3: pointer to readsector()
* a4: pointer to `start' a5: pointer to back-to-ROM
*/
main: movml d3-d7/a3-a5,sp@-
lea pc@(regsav),a0
movl sp,a0@
main: movml %d3-%d7/%a3-%a5,%sp@-
lea %pc@(regsav),%a0
movl %sp,%a0@
movw #-1,sp@-
movw #Kbshift,sp@-
movw #-1,%sp@-
movw #Kbshift,%sp@-
trap #BIOS
addql #4,sp
subql #1,d0
movl d0,a5 | autoboot flag
addql #4,%sp
subql #1,%d0
movl %d0,%a5 | autoboot flag
lea pc@(m_bot),a6
movl _membot:w,d3
lea MAXBOT,a4
cmpl a4,d3
lea %pc@(m_bot),%a6
movl _membot:w,%d3
lea MAXBOT,%a4
cmpl %a4,%d3
bhis exit | membot > MAXBOT
lea pc@(m_top),a6
movl _memtop:w,d3
cmpl #MINTOP,d3
lea %pc@(m_top),%a6
movl _memtop:w,%d3
cmpl #MINTOP,%d3
blts exit | memtop < MINTOP
andw #-4,d3
movl d3,a0
movl sp,a0@-
movl a0,sp | set new stack
andw #-4,%d3
movl %d3,%a0
movl %sp,%a0@-
movl %a0,%sp | set new stack
/*
* Load secondary boot loader and disklabel.
*/
movml a4/a5,sp@-
movq #NSEC,d3 | # of sectors
addql #1,d6 | first sector
movml %a4/%a5,%sp@-
movq #NSEC,%d3 | # of sectors
addql #1,%d6 | first sector
bsr rds1
lea pc@(m_rds),a6
movml sp@+,a4/a5
lea %pc@(m_rds),%a6
movml %sp@+,%a4/%a5
bnes 0f | I/O error
/*
* int bootxx(readsector, disklabel, autoboot)
*/
pea a5@ | autoboot
pea a4@(LBLST-MAXBOT) | disklabel
pea pc@(rds2) | readsector
jsr a4@(BXXST-MAXBOT)
lea pc@(m_sbl),a6 | NetBSD not booted
lea sp@(12),sp
pea %a5@ | autoboot
pea %a4@(LBLST-MAXBOT) | disklabel
pea %pc@(rds2) | readsector
jsr %a4@(BXXST-MAXBOT)
lea %pc@(m_sbl),%a6 | NetBSD not booted
lea %sp@(12),%sp
0: movl sp@,sp | restore BIOS stack
movl d0,d3
0: movl %sp@,%sp | restore BIOS stack
movl %d0,%d3
bmis exit
movml sp@+,d3-d7/a3-a5
movl d0,d5 | new boot preference
jmp a4@(-0x200)
movml %sp@+,%d3-%d7/%a3-%a5
movl %d0,%d5 | new boot preference
jmp %a4@(-0x200)
exit: bsrs puts | display error
lea pc@(m_key),a6
lea %pc@(m_key),%a6
bsrs puts | wait for key
movml sp@+,d3-d7/a3-a5
jmp a5@
movml %sp@+,%d3-%d7/%a3-%a5
jmp %a5@
/*
* puts (in: a6, d3)
*/
0: cmpw #35,d0 | '#'
0: cmpw #35,%d0 | '#'
bnes 1f
bsrs puti
bras puts
1: cmpw #64,d0 | '@'
1: cmpw #64,%d0 | '@'
bnes 2f
movw #2,sp@-
movw #Bconin,sp@-
movw #2,%sp@-
movw #Bconin,%sp@-
trap #BIOS
addql #4,sp
addql #4,%sp
bras puts
2: bsrs putc
puts: movq #0,d0
movb a6@+,d0
puts: movq #0,%d0
movb %a6@+,%d0
bnes 0b
rts
puti: swap d3
puti: swap %d3
bsrs 0f
swap d3
0: rorw #8,d3
swap %d3
0: rorw #8,%d3
bsrs 1f
rorw #8,d3
1: rorb #4,d3
rorw #8,%d3
1: rorb #4,%d3
bsrs 2f
rorb #4,d3
2: movw d3,d0
andw #15,d0
addw #48,d0
cmpw #58,d0
rorb #4,%d3
2: movw %d3,%d0
andw #15,%d0
addw #48,%d0
cmpw #58,%d0
bcss putc
addw #39,d0
putc: movw d0,sp@-
movw #2,sp@-
movw #Bconout,sp@-
addw #39,%d0
putc: movw %d0,%sp@-
movw #2,%sp@-
movw #Bconout,%sp@-
trap #BIOS
addql #6,sp
addql #6,%sp
rts
/*
* int readsec (void *buffer, u_int offset, u_int count);
*/
rds2: movml d2-d7/a2-a6,sp@-
movl pc@(regsav),a0
movml a0@,d3-d7/a3-a5
movl sp@(48),a4 | buffer
movl sp@(52),d6 | offset
movl sp@(56),d3 | count
rds2: movml %d2-%d7/%a2-%a6,%sp@-
movl %pc@(regsav),%a0
movml %a0@,%d3-%d7/%a3-%a5
movl %sp@(48),%a4 | buffer
movl %sp@(52),%d6 | offset
movl %sp@(56),%d3 | count
bsrs rds1
movml sp@+,d2-d7/a2-a6
movml %sp@+,%d2-%d7/%a2-%a6
rts
rds1: movl #255,d5
cmpl d5,d3
rds1: movl #255,%d5
cmpl %d5,%d3
bccs 0f
movl d3,d5
0: jsr a3@
tstl d0
movl %d3,%d5
0: jsr %a3@
tstl %d0
bnes 1f
addl #(255*512),a4
addl d5,d6
subl d5,d3
addl #(255*512),%a4
addl %d5,%d6
subl %d5,%d3
bnes rds1
1: rts

View File

@ -1,4 +1,4 @@
/* $NetBSD: fdboot.s,v 1.3 1996/12/28 23:38:06 leo Exp $ */
/* $NetBSD: fdboot.s,v 1.4 2001/09/05 19:48:13 thomas Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens.
@ -32,11 +32,19 @@
#include "xxboot.h"
#ifdef __ELF__
.globl _start, main, fill, end
.text
_start: bras main
#else
.globl start, main, fill, end
.text
start: bras main
#endif
/*
* Fake gemdos-fs bootsector, to keep TOS away.
*/
@ -57,156 +65,156 @@ start: bras main
/*
* ROM loader does not save any register!
*/
main: movml d1-d7/a0-a6,sp@-
main: movml %d1-%d7/%a0-%a6,%sp@-
lea pc@(m_bot),a3
movl _membot:w,d3
lea MAXBOT,a6
cmpl a6,d3
lea %pc@(m_bot),%a3
movl _membot:w,%d3
lea MAXBOT,%a6
cmpl %a6,%d3
bhis exit | membot > MAXBOT
lea pc@(m_top),a3
movl _memtop:w,d3
cmpl #MINTOP,d3
lea %pc@(m_top),%a3
movl _memtop:w,%d3
cmpl #MINTOP,%d3
blts exit | memtop < MINTOP
andw #-4,d3
movl d3,a0
movl sp,a0@-
movl a0,sp | set new stack
andw #-4,%d3
movl %d3,%a0
movl %sp,%a0@-
movl %a0,%sp | set new stack
/*
* Determine the number of sectors per cylinder.
*/
movq #0,d3
0: movl a6,a3 | buffer
movq #1,d0 | count
movq #0,d1 | side
movl d1,d2 | track
addw d0,d3 | sector
movq #0,%d3
0: movl %a6,%a3 | buffer
movq #1,%d0 | count
movq #0,%d1 | side
movl %d1,%d2 | track
addw %d0,%d3 | sector
bsr rds0
beqs 0b
subqw #1,d3
addw d3,d3
lea pc@(secpercyl),a0
movw d3,a0@
subqw #1,%d3
addw %d3,%d3
lea %pc@(secpercyl),%a0
movw %d3,%a0@
/*
* Load secondary boot loader and disklabel.
*/
movq #NSEC,d5 | # of sectors
movq #1,d4 | first sector
movl a6,a3 | load address
movq #NSEC,%d5 | # of sectors
movq #1,%d4 | first sector
movl %a6,%a3 | load address
bsr rds1
lea pc@(m_rds),a3
lea %pc@(m_rds),%a3
bnes 0f | I/O error
/*
* int bootxx(readsector, disklabel, autoboot)
*/
clrl sp@- | no autoboot
pea a6@(LBLST-MAXBOT) | disklabel
pea pc@(rds2) | readsector
jsr a6@(BXXST-MAXBOT)
lea pc@(m_sbl),a3 | NetBSD not booted
lea sp@(12),sp
0: movl sp@,sp | restore BIOS stack
movl d0,d3
clrl %sp@- | no autoboot
pea %a6@(LBLST-MAXBOT) | disklabel
pea %pc@(rds2) | readsector
jsr %a6@(BXXST-MAXBOT)
lea %pc@(m_sbl),%a3 | NetBSD not booted
lea %sp@(12),%sp
0: movl %sp@,%sp | restore BIOS stack
movl %d0,%d3
exit: bsrs puts | display error
lea pc@(m_key),a3
lea %pc@(m_key),%a3
bsrs puts | wait for key
0: movml sp@+,d1-d7/a0-a6
movq #0,d0
0: movml %sp@+,%d1-%d7/%a0-%a6
movq #0,%d0
rts
/*
* puts (in: a3, d3)
*/
0: cmpw #35,d0 | '#'
0: cmpw #35,%d0 | '#'
bnes 1f
bsrs puti
bras puts
1: cmpw #64,d0 | '@'
1: cmpw #64,%d0 | '@'
bnes 2f
movw #2,sp@-
movw #Bconin,sp@-
movw #2,%sp@-
movw #Bconin,%sp@-
trap #BIOS
addql #4,sp
addql #4,%sp
bras puts
2: bsrs putc
puts: movq #0,d0
movb a3@+,d0
puts: movq #0,%d0
movb %a3@+,%d0
bnes 0b
rts
puti: swap d3
puti: swap %d3
bsrs 0f
swap d3
0: rorw #8,d3
swap %d3
0: rorw #8,%d3
bsrs 1f
rorw #8,d3
1: rorb #4,d3
rorw #8,%d3
1: rorb #4,%d3
bsrs 2f
rorb #4,d3
2: movw d3,d0
andw #15,d0
addw #48,d0
cmpw #58,d0
rorb #4,%d3
2: movw %d3,%d0
andw #15,%d0
addw #48,%d0
cmpw #58,%d0
bcss putc
addw #39,d0
putc: movw d0,sp@-
movw #2,sp@-
movw #Bconout,sp@-
addw #39,%d0
putc: movw %d0,%sp@-
movw #2,%sp@-
movw #Bconout,%sp@-
trap #BIOS
addql #6,sp
addql #6,%sp
rts
/*
* int readsec (void *buffer, u_int offset, u_int count);
*/
rds2: movml d2-d5/a2-a3,sp@-
movl sp@(28),a3 | buffer
movl sp@(32),d4 | offset
movl sp@(36),d5 | count
rds2: movml %d2-%d5/%a2-%a3,%sp@-
movl %sp@(28),%a3 | buffer
movl %sp@(32),%d4 | offset
movl %sp@(36),%d5 | count
bsrs rds1
movml sp@+,d2-d5/a2-a3
movml %sp@+,%d2-%d5/%a2-%a3
rts
rds1: bsrs 1f
bnes 0f
tstl d5
tstl %d5
bnes rds1
0: rts
1: movq #0,d0
movw pc@(secpercyl),d0
movl d4,d3
divuw d0,d3
movw d3,d2 | track
clrw d3
swap d3
lsrw #1,d0
divuw d0,d3
movw d3,d1 | side
swap d3
subw d3,d0
addqw #1,d3 | sector
cmpl d0,d5
1: movq #0,%d0
movw %pc@(secpercyl),%d0
movl %d4,%d3
divuw %d0,%d3
movw %d3,%d2 | track
clrw %d3
swap %d3
lsrw #1,%d0
divuw %d0,%d3
movw %d3,%d1 | side
swap %d3
subw %d3,%d0
addqw #1,%d3 | sector
cmpl %d0,%d5
bccs rds0
movw d5,d0
movw %d5,%d0
rds0: movw d0,sp@- | count
movw d1,sp@- | side
movw d2,sp@- | track
movw d3,sp@- | sector
movw _bootdev:w,sp@- | device
clrl sp@- | filler
movl a3,sp@- | buffer
addl d0,d4
subl d0,d5
lsll #8,d0
addl d0,d0
addl d0,a3
movw #Floprd,sp@-
rds0: movw %d0,%sp@- | count
movw %d1,%sp@- | side
movw %d2,%sp@- | track
movw %d3,%sp@- | sector
movw _bootdev:w,%sp@- | device
clrl %sp@- | filler
movl %a3,%sp@- | buffer
addl %d0,%d4
subl %d0,%d5
lsll #8,%d0
addl %d0,%d0
addl %d0,%a3
movw #Floprd,%sp@-
trap #XBIOS
lea sp@(20),sp
tstl d0
lea %sp@(20),%sp
tstl %d0
rts
secpercyl:

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdboot.s,v 1.3 1996/12/28 23:38:07 leo Exp $ */
/* $NetBSD: sdboot.s,v 1.4 2001/09/05 19:48:13 thomas Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens
@ -32,165 +32,172 @@
#include "xxboot.h"
#ifdef __ELF__
.globl _start, main, fill, end
.text
_start:
#else
.globl start, main, fill, end
.text
start:
#endif
/*
* in: d3 ('DMAr' flag), d4 (SCSI target), d5 (boot pref), d7 (ACSI target)
*/
start:
main: lea pc@(regsav),a0
movml d3-d5/d7,sp@-
movl sp,a0@
main: lea %pc@(regsav),%a0
movml %d3-%d5/%d7,%sp@-
movl %sp,%a0@
movw #-1,sp@-
movw #Kbshift,sp@-
movw #-1,%sp@-
movw #Kbshift,%sp@-
trap #BIOS
addql #4,sp
addql #4,%sp
cmpl #0x444d4172,d3 | SCSI bootdev?
cmpl #0x444d4172,%d3 | SCSI bootdev?
beqs 0f
movq #-1,d4 | no, ACSI
movq #-1,%d4 | no, ACSI
bras 1f
0: tstb d5
0: tstb %d5
beqs 1f | no boot preference
cmpb #0x20,d5
cmpb #0x20,%d5
bnes exit | bootpref != NetBSD
1: btst #3,d0 | Alternate?
1: btst #3,%d0 | Alternate?
bnes exit
subql #1,d0
movl d0,a3 | autoboot flag
subql #1,%d0
movl %d0,%a3 | autoboot flag
movl _membot:w,d0
lea MAXBOT,a4
cmpl a4,d0
movl _membot:w,%d0
lea MAXBOT,%a4
cmpl %a4,%d0
bhis exit | membot > MAXBOT
movl _memtop:w,d0
cmpl #MINTOP,d0
movl _memtop:w,%d0
cmpl #MINTOP,%d0
blts exit | memtop < MINTOP
andw #-4,d0
movl d0,a0
movl sp,a0@-
movl a0,sp | set new stack
andw #-4,%d0
movl %d0,%a0
movl %sp,%a0@-
movl %a0,%sp | set new stack
movq #NSEC,d5 | sector count
movq #1,d6 | first sector
movq #NSEC,%d5 | sector count
movq #1,%d6 | first sector
bsrs rds0
tstl d0
tstl %d0
bnes 0f
/*
* loader (readsector, disklabel, autoboot)
*/
pea a3@ | autoboot
pea a4@(LBLST-MAXBOT) | disklabel
pea pc@(rds1) | readsector
jsr a4@(BXXST-MAXBOT)
lea sp@(12),sp | NetBSD not booted
pea %a3@ | autoboot
pea %a4@(LBLST-MAXBOT) | disklabel
pea %pc@(rds1) | readsector
jsr %a4@(BXXST-MAXBOT)
lea %sp@(12),%sp | NetBSD not booted
0: movl sp@,sp | restore BIOS stack
tstl d0
0: movl %sp@,%sp | restore BIOS stack
tstl %d0
bmis exit
movl d0,sp@(8) | new boot preference
movl %d0,%sp@(8) | new boot preference
exit: movml sp@+,d3-d5/d7
exit: movml %sp@+,%d3-%d5/%d7
rts
/*
* int readsec (void *buffer, u_int offset, u_int count);
*/
rds1: movml d2-d7/a2-a6,sp@-
movl pc@(regsav),a0
movml a0@,d3-d5/d7
movl sp@(48),a4 | buffer
movl sp@(52),d6 | offset
movl sp@(56),d3 | count
0: movl #255,d5
cmpl d5,d3
rds1: movml %d2-%d7/%a2-%a6,%sp@-
movl %pc@(regsav),%a0
movml %a0@,%d3-%d5/%d7
movl %sp@(48),%a4 | buffer
movl %sp@(52),%d6 | offset
movl %sp@(56),%d3 | count
0: movl #255,%d5
cmpl %d5,%d3
bccs 1f
movl d3,d5
movl %d3,%d5
1: bsrs rds0
tstl d0
tstl %d0
bnes 2f
addl #(255*512),a4
addl d5,d6
subl d5,d3
addl #(255*512),%a4
addl %d5,%d6
subl %d5,%d3
bnes 0b
2: movml sp@+,d2-d7/a2-a6
2: movml %sp@+,%d2-%d7/%a2-%a6
rts
/*
* in: d4/d7 (target) d5 (count), d6 (offset), a4 (buffer)
* out: d0 (<= 0)
* mod: d0, d1, d2, a0, a5, a6
*/
rds0: tstl d4
rds0: tstl %d4
bmis 0f
movw d4,sp@- | device
pea a4@ | buffer
movw d5,sp@- | count
movl d6,sp@- | offset
movw #DMAread,sp@-
movw %d4,%sp@- | device
pea %a4@ | buffer
movw %d5,%sp@- | count
movl %d6,%sp@- | offset
movw #DMAread,%sp@-
trap #XBIOS
lea sp@(14),sp
lea %sp@(14),%sp
rts
0: st flock:w
movl _hz_200:w,d0
addql #2,d0
1: cmpl _hz_200:w,d0
movl _hz_200:w,%d0
addql #2,%d0
1: cmpl _hz_200:w,%d0
bccs 1b
movml d6/a4,sp@-
lea dmahi:w,a6
movb sp@(7),a6@(4)
movb sp@(6),a6@(2)
movb sp@(5),a6@
lea pc@(r0com),a6
movb sp@(1),a6@(1)
movb sp@(2),a6@(5)
movb sp@(3),a6@(9)
movb d5,a6@(13)
addql #8,sp
lea dmodus:w,a6
lea daccess:w,a5
movw #0x198,a6@
movw #0x098,a6@
movw d5,a5@
movw #0x88,a6@
movq #0,d0
movb d7,d0
orb #0x08,d0
swap d0
movw #0x8a,d0
movml %d6/%a4,%sp@-
lea dmahi:w,%a6
movb %sp@(7),%a6@(4)
movb %sp@(6),%a6@(2)
movb %sp@(5),%a6@
lea %pc@(r0com),%a6
movb %sp@(1),%a6@(1)
movb %sp@(2),%a6@(5)
movb %sp@(3),%a6@(9)
movb %d5,%a6@(13)
addql #8,%sp
lea dmodus:w,%a6
lea daccess:w,%a5
movw #0x198,%a6@
movw #0x098,%a6@
movw %d5,%a5@
movw #0x88,%a6@
movq #0,%d0
movb %d7,%d0
orb #0x08,%d0
swap %d0
movw #0x8a,%d0
bsrs shake
lea pc@(r0com),a0
movq #3,d2
2: movl a0@+,d0
lea %pc@(r0com),%a0
movq #3,%d2
2: movl %a0@+,%d0
bsrs shake
dbra d2,2b
movq #0x0a,d0
movl d0,a5@
movl #0x190,d1
dbra %d2,2b
movq #0x0a,%d0
movl %d0,%a5@
movl #0x190,%d1
bsrs wait
movw #0x8a,a6@
movw a5@,d0
andw #0xff,d0
movw #0x8a,%a6@
movw %a5@,%d0
andw #0xff,%d0
beqs 0f
r0err: movq #-1,d0
0: movw #0x80,a6@
r0err: movq #-1,%d0
0: movw #0x80,%a6@
clrb flock:w
r0ret: rts
shake: movl d0,a5@
movq #0x0a,d1
wait: addl _hz_200:w,d1
shake: movl %d0,%a5@
movq #0x0a,%d1
wait: addl _hz_200:w,%d1
0: btst #5,gpip:w
beqs r0ret
cmpl _hz_200:w,d1
cmpl _hz_200:w,%d1
bccs 0b
addql #4,sp
addql #4,%sp
bras r0err
r0com: .long 0x0000008a

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdboot.s,v 1.4 1996/12/28 23:38:09 leo Exp $ */
/* $NetBSD: wdboot.s,v 1.5 2001/09/05 19:48:13 thomas Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens
@ -32,160 +32,167 @@
#include "xxboot.h"
#ifdef __ELF__
.globl _start, main, fill, end
.text
_start:
#else
.globl start, main, fill, end
.text
start:
#endif
/*
* in: d3 ('DMAr' flag), d4 (SCSI target), d5 (boot pref), d7 (ACSI target)
*/
start:
main: lea pc@(regsav),a0
movml d3-d5/d7,sp@-
movl sp,a0@
main: lea %pc@(regsav),%a0
movml %d3-%d5/%d7,%sp@-
movl %sp,%a0@
movw #-1,sp@-
movw #Kbshift,sp@-
movw #-1,%sp@-
movw #Kbshift,%sp@-
trap #BIOS
addql #4,sp
addql #4,%sp
tstb d5
tstb %d5
beqs 0f | no boot preference
cmpb #0x20,d5
cmpb #0x20,%d5
bnes exit | bootpref != NetBSD
0: btst #3,d0 | Alternate?
0: btst #3,%d0 | Alternate?
bnes exit
subql #1,d0
movl d0,a3 | autoboot flag
subql #1,%d0
movl %d0,%a3 | autoboot flag
movl _membot:w,d3
lea MAXBOT,a4
cmpl a4,d3
movl _membot:w,%d3
lea MAXBOT,%a4
cmpl %a4,%d3
bhis exit | membot > MAXBOT
movl _memtop:w,d3
cmpl #MINTOP,d3
movl _memtop:w,%d3
cmpl #MINTOP,%d3
blts exit | memtop < MINTOP
andw #-4,d3
movl d3,a0
movl sp,a0@-
movl a0,sp | set new stack
andw #-4,%d3
movl %d3,%a0
movl %sp,%a0@-
movl %a0,%sp | set new stack
movq #NSEC,d5 | sector count
movq #1,d6 | first sector
movq #NSEC,%d5 | sector count
movq #1,%d6 | first sector
bsrs rds0
tstl d0
tstl %d0
bnes 0f
/*
* loader (readsector, disklabel, autoboot)
*/
pea a3@ | autoboot
pea a4@(LBLST-MAXBOT) | disklabel
pea pc@(rds1) | readsector
jsr a4@(BXXST-MAXBOT)
lea sp@(12),sp | NetBSD not booted
pea %a3@ | autoboot
pea %a4@(LBLST-MAXBOT) | disklabel
pea %pc@(rds1) | readsector
jsr %a4@(BXXST-MAXBOT)
lea %sp@(12),%sp | NetBSD not booted
0: movl sp@,sp | restore BIOS stack
tstl d0
0: movl %sp@,%sp | restore BIOS stack
tstl %d0
bmis exit
movl d0,sp@(8) | new boot preference
movl %d0,%sp@(8) | new boot preference
exit: movml sp@+,d3-d5/d7
exit: movml %sp@+,%d3-%d5/%d7
rts
/*
* int readsec (void *buffer, u_int offset, u_int count);
*/
rds1: movml d2-d7/a2-a6,sp@-
movl pc@(regsav),a0
movml a0@,d3-d5/d7
movl sp@(48),a4 | buffer
movl sp@(52),d6 | offset
movl sp@(56),d3 | count
0: movl #255,d5
cmpl d5,d3
rds1: movml %d2-%d7/%a2-%a6,%sp@-
movl %pc@(regsav),%a0
movml %a0@,%d3-%d5/%d7
movl %sp@(48),%a4 | buffer
movl %sp@(52),%d6 | offset
movl %sp@(56),%d3 | count
0: movl #255,%d5
cmpl %d5,%d3
bccs 1f
movl d3,d5
movl %d3,%d5
1: bsrs rds0
tstl d0
tstl %d0
bnes 2f
addl #(255*512),a4
addl d5,d6
subl d5,d3
addl #(255*512),%a4
addl %d5,%d6
subl %d5,%d3
bnes 0b
2: movml sp@+,d2-d7/a2-a6
2: movml %sp@+,%d2-%d7/%a2-%a6
rts
/*
* in: d4 (target) d5 (count), d6 (offset), a4 (buffer)
* out: d0 (<= 0)
* mod: d0, d1, d2, a0, a1, a5, a6
*/
rds0: lea pc@(dpar),a6
tstb a6@
rds0: lea %pc@(dpar),%a6
tstb %a6@
bnes 0f
movb d4,d0
andb #1,d0
aslb #4,d0
orb #0xa0,d0
movb d0,idesdh:l
movl a4,a0
movq #0,d1
movb %d4,%d0
andb #1,%d0
aslb #4,%d0
orb #0xa0,%d0
movb %d0,idesdh:l
movl %a4,%a0
movq #0,%d1
movb #0,idedor:l
movb #0xec,idecr:l | IDENTIFY DRIVE
bsrs wait
bnes err
movb a4@(7),a6@ | tracks/cylinder
movb a4@(13),a6@(1) | sectors/track
0: movl d6,d1
movq #0,d0
movb a6@(1),d0
movq #0,d2
movb a6@,d2
mulu d0,d2
divu d2,d1
movb d1,idecl:l
lsrl #8,d1
movb d1,idech:l
lsrl #8,d1
divu d0,d1
movb d4,d0
andb #1,d0
aslb #4,d0
orb d0,d1
orb #0xa0,d1
movb d1,idesdh:l
swap d1
addqw #1,d1
movb d1,idesn:l
movl a4,a0
movb d5,idesc:l
movw d5,d1
subqw #1,d1
movb %a4@(7),%a6@ | tracks/cylinder
movb %a4@(13),%a6@(1) | sectors/track
0: movl %d6,%d1
movq #0,%d0
movb %a6@(1),%d0
movq #0,%d2
movb %a6@,%d2
mulu %d0,%d2
divu %d2,%d1
movb %d1,idecl:l
lsrl #8,%d1
movb %d1,idech:l
lsrl #8,%d1
divu %d0,%d1
movb %d4,%d0
andb #1,%d0
aslb #4,%d0
orb %d0,%d1
orb #0xa0,%d1
movb %d1,idesdh:l
swap %d1
addqw #1,%d1
movb %d1,idesn:l
movl %a4,%a0
movb %d5,idesc:l
movw %d5,%d1
subqw #1,%d1
movb #0,idedor:l
movb #0x20,idecr:l
wait: movl #0x7d0,d0
addl _hz_200:w,d0
wait: movl #0x7d0,%d0
addl _hz_200:w,%d0
2: btst #5,gpip:w
beqs 3f
cmpl _hz_200:w,d0
cmpl _hz_200:w,%d0
bhis 2b
err: movq #-1,d0
err: movq #-1,%d0
rts
3: movb idesr:l,d0
btst #0,d0
3: movb idesr:l,%d0
btst #0,%d0
bnes err
btst #3,d0
btst #3,%d0
beqs err
movq #63,d0
lea idedr:l,a1
4: movw a1@,a0@+
movw a1@,a0@+
movw a1@,a0@+
movw a1@,a0@+
dbra d0,4b
dbra d1,wait
movq #0,d0
movq #63,%d0
lea idedr:l,%a1
4: movw %a1@,%a0@+
movw %a1@,%a0@+
movw %a1@,%a0@+
movw %a1@,%a0@+
dbra %d0,4b
dbra %d1,wait
movq #0,%d0
rts
regsav: .long 0