Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc/stand/bootblk Major overhaul:
details: https://anonhg.NetBSD.org/src/rev/23728461c462
branches: trunk
changeset: 752096:23728461c462
user: eeh <eeh%NetBSD.org@localhost>
date: Sat Feb 13 23:38:17 2010 +0000
description:
Major overhaul:
1) Add support for multiple filesystems including ffsv1, ffsv2, lfsv1 and lfsv2.
(ffsv1 and lfsv2 are known to work. ffv2 support needs more work. lfsv1 is
probably untested.)
2) Only 32-bit Fcodes are used. All 64-bit math uses two cells. This means it
should work on 32-bit machines.
Additional work to consider:
1) Rename genfth.cf to genffs.cf, or keep it and move the ffs symbols to genffs.cf
2) Move the ffs code and the lfs code to different source files so you can
selectively fload the just the filesystems you want.
3) Add code to load ELF files directly instead of relying on the host firmware
ELF support. But, since the binary is now 7250 bytes there may not be room.
diffstat:
sys/arch/sparc/stand/bootblk/Makefile | 19 +-
sys/arch/sparc/stand/bootblk/bootblk.fth | 1043 ++++++++++++++++++-----------
sys/arch/sparc/stand/bootblk/genfth.cf | 23 +-
sys/arch/sparc/stand/bootblk/genlfs.cf | 77 ++
4 files changed, 738 insertions(+), 424 deletions(-)
diffs (truncated from 1374 to 300 lines):
diff -r cb855f3931a1 -r 23728461c462 sys/arch/sparc/stand/bootblk/Makefile
--- a/sys/arch/sparc/stand/bootblk/Makefile Sat Feb 13 22:57:03 2010 +0000
+++ b/sys/arch/sparc/stand/bootblk/Makefile Sat Feb 13 23:38:17 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.12 2009/04/06 12:43:26 tsutsui Exp $
+# $NetBSD: Makefile,v 1.13 2010/02/13 23:38:17 eeh Exp $
CURDIR= ${.CURDIR}
S= ${CURDIR}/../../../..
@@ -10,7 +10,7 @@
PROG= bootblk
SRCS= bootblk.fth
OBJS=
-CLEANFILES= assym.fth.h assym.fth.h.tmp machine sparc \
+CLEANFILES= ffs.fth.h lfs.fth.h assym.fth.h.tmp machine sparc \
bootblk bootblk.text bootblk.text.tmp
NOMAN= # defined
@@ -32,17 +32,22 @@
machine:
ln -s ${.CURDIR}/../../../${MACHINE}/include machine
-assym.fth.h: genfth.cf machine sparc
+ffs.fth.h: genfth.cf machine sparc
${TOOL_GENASSYM} -f -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
- <${.CURDIR}/genfth.cf >assym.fth.h.tmp && \
- mv -f assym.fth.h.tmp assym.fth.h
+ <${.CURDIR}/genfth.cf >ffs.fth.h.tmp && \
+ mv -f ffs.fth.h.tmp ffs.fth.h
-bootblk.text: bootblk.fth assym.fth.h
+lfs.fth.h: genlfs.cf machine sparc
+ ${TOOL_GENASSYM} -f -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
+ <${.CURDIR}/genlfs.cf >lfs.fth.h.tmp && \
+ mv -f lfs.fth.h.tmp lfs.fth.h
+
+bootblk.text: bootblk.fth ffs.fth.h lfs.fth.h
${TOOL_AWK} '/fload/ { print "#include \"" $$2 "\"" }; !/fload/' \
${.CURDIR}/bootblk.fth | /usr/bin/cpp -P >bootblk.text.tmp &&
mv -f bootblk.text.tmp bootblk.text
-bootblk: bootblk.fth assym.fth.h
+bootblk: bootblk.fth ffs.fth.h lfs.fth.h
${TOOL_FGEN} -o bootblk ${.CURDIR}/bootblk.fth
beforedepend:
diff -r cb855f3931a1 -r 23728461c462 sys/arch/sparc/stand/bootblk/bootblk.fth
--- a/sys/arch/sparc/stand/bootblk/bootblk.fth Sat Feb 13 22:57:03 2010 +0000
+++ b/sys/arch/sparc/stand/bootblk/bootblk.fth Sat Feb 13 23:38:17 2010 +0000
@@ -1,11 +1,11 @@
-\ $NetBSD: bootblk.fth,v 1.9 2009/10/19 18:12:37 snj Exp $
+\ $NetBSD: bootblk.fth,v 1.10 2010/02/13 23:38:17 eeh Exp $
\
\ IEEE 1275 Open Firmware Boot Block
\
\ Parses disklabel and UFS and loads the file called `ofwboot'
\
\
-\ Copyright (c) 1998 Eduardo Horvath.
+\ Copyright (c) 1998-2010 Eduardo Horvath.
\ All rights reserved.
\
\ Redistribution and use in source and binary forms, with or without
@@ -55,15 +55,15 @@
\ defer cif-peer ( phandle -- phandle )
\ defer cif-getprop ( len adr cstr phandle -- )
-: find-cif-method ( method,len -- xf )
+: find-cif-method ( method len -- xf )
cif-phandle find-method drop
;
-" claim" find-cif-method to cif-claim
-" open" find-cif-method to cif-open
-" close" find-cif-method to cif-close
-" read" find-cif-method to cif-read
-" seek" find-cif-method to cif-seek
+" claim" find-cif-method to cif-claim
+" open" find-cif-method to cif-open
+" close" find-cif-method to cif-close
+" read" find-cif-method to cif-read
+" seek" find-cif-method to cif-seek
: twiddle ( -- ) ." ." ; \ Need to do this right. Just spit out periods for now.
@@ -71,8 +71,49 @@
\ Support routines
\
+\ 64-bit math support
+
+here h# ffff over l! <w@ constant little-endian?
+: ul>d ( l -- d.lo d.hi ) 0 ;
+: l>d ( l -- d.lo d.hi ) dup 0< if -1 else 0 then ;
+: d>l ( d.lo d.hi -- l ) drop ;
+: d@ ( addr -- d.lo d.hi ) dup l@ swap la1+ l@ little-endian? invert if swap then ;
+: d! ( d.lo d.hi addr -- )
+ little-endian? invert if -rot swap rot then tuck la1+ l! l! ;
+: d-and ( d1 d2 -- d1-and-d2 ) rot and -rot and swap ;
+: d*u ( d1 u -- d2 ) tuck um* drop -rot um* rot + ;
+: d<< ( d1 n -- d1<<n ) \ Hope this works
+ tuck << ( d.lo n d.hi' )
+ -rot 2dup << ( d.hi' d.lo n d.lo' )
+ -rot d# 32 swap - >> ( d.hi' d.lo' lo.hi )
+ rot +
+;
+: d>> ( d1 n -- d1>>n ) \ Hope this works
+ rot over >> -rot ( d.lo' d.hi n )
+ 2dup >> -rot ( d.lo' d.hi' d.hi n )
+ d# 32 swap - << rot + swap
+;
+: d> ( d1 d2 -- d1>d2? )
+ rot swap 2dup = if
+ 2drop > exit
+ then
+ > nip nip
+;
+: d>= ( d1 d2 -- d1>=d2? )
+ rot swap 2dup = if
+ 2drop >= exit
+ then
+ >= nip nip
+;
+: d< ( d1 d2 -- d1<d2? ) d>= invert ;
+: d= ( d1 d2 -- d1=d2? ) rot = -rot = and ;
+: d<> ( d1 d2 -- d1<>d2? ) d= invert ;
+
+
+\ String support
+
: strcmp ( s1 l1 s2 l2 -- true:false )
- rot tuck <> if 3drop false exit then
+ rot tuck <> if 3drop false exit then
comp 0=
;
@@ -112,91 +153,181 @@
;
\
-\ BSD FFS parameters
+\ BSD UFS parameters
\
-fload assym.fth.h
+fload ffs.fth.h
+fload lfs.fth.h
sbsize buffer: sb-buf
-1 value boot-ihandle
dev_bsize value bsize
0 value raid-offset \ Offset if it's a raid-frame partition
-false value force-raid \ Force reads from raid offset
+
+: strategy ( addr size db.lo db.hi -- nread )
+ raid-offset l>d d+ ( addr size db.lo' db.hi' )
+ bsize d*u ( addr size sector.lo sector.hi )
+ " seek" boot-ihandle $call-method -1 = if
+ ." strategy: Seek failed" cr
+ abort
+ then ( addr size )
+ " read" boot-ihandle $call-method
+;
+
+
+\
+\ Multi-FS support
+\
+\ XXX Maybe the different filesystems should be segregated into separate files
+\ XXX that are individually fload-ed.
+\
+
+defer fs-size
+defer di-size
+defer di-mode
+defer /dino
+defer cgstart
+defer di-db@
+defer di-ib@
+defer ib-ib@
+defer fs-bsize
+defer fsbtodb
+defer blksize
+defer lblkno
+defer blkoff
+defer read-inode
+\ LFS ifile
+defer /ifile
+defer if_daddr
+
+\
+\ FFS Cylinder group macros
+\
+
+: cgdmin ( cg fs -- d-1st-data-block ) dup fs_dblkno l@ l>d 2swap cgstart d+ ;
+: cgimin ( cg fs -- d-inode-block ) dup fs_iblkno l@ l>d 2swap cgstart d+ ;
+: cgsblock ( cg fs -- d-super-block ) dup fs_sblkno l@ l>d 2swap cgstart d+ ;
+: cgstod ( cg fs -- d-cg-block ) dup fs_cblkno l@ l>d 2swap cgstart d+ ;
+
+\
+\ FFS Block and frag position macros
+\
-: strategy ( addr size start -- nread )
- raid-offset + bsize * 0 " seek" boot-ihandle $call-method
- -1 = if
- ." strategy: Seek failed" cr
- abort
+: ffs-blkoff ( pos.lo pos.hi fs -- off.lo off.hi ) fs_qbmask d@ d-and ;
+\ : ffs-fragoff ( pos.lo pos.hi fs -- off.lo off.hi ) fs_qfmask d@ d-and ;
+\ : ffs-lblktosize ( blk fs -- off.lo off.hi ) 0 fs_bshift l@ d<< ;
+: ffs-lblkno ( pos.lo pos.hi fs -- off.lo off.hi ) fs_bshift l@ d>> ;
+: ffs-numfrags ( pos.lo pos.hi fs -- off.lo off.hi ) fs_fshift l@ d>> ;
+: ffs-blkroundup ( pos.lo pos.hi fs -- off.lo off.hi )
+ >r r@ fs_qbmask d@ d+ r> fs_bmask l@ l>d d-and
+;
+: ffs-fragroundup ( pos.lo pos.hi fs -- off.lo off.hi )
+ >r r@ fs_qfmask d@ d+ r> fs_fmask l@ l>d d-and
+;
+: ffs-fragstoblks ( pos.lo pos.hi fs -- off.lo off.hi ) fs_fragshift l@ d>> ;
+: ffs-blkstofrags ( blk fs -- frag ) fs_fragshift l@ << ;
+\ : ffs-fragnum ( fsb fs -- off ) fs_frag l@ 1- and ;
+\ : ffs-blknum ( fsb fs -- off ) fs_frag l@ 1- not and ;
+: ffs-dblksize ( lbn.lo lbn.hi inodep fs -- size )
+ >r -rot 2dup ndaddr l>d d> ( inop d-lbn >ndaddr? )
+ -rot 1 0 d+ ( inop >ndaddr? d-lbn+1 )
+ r@ fs_bshift l@ d<< ( inop >ndaddr? d-lbn+1<<bshift )
+ 2swap >r di-size d@ ( d-lbn+1<<bshift d-size )
+ 2swap 2over d< r> or if ( d-size )
+ 2drop r> fs-bsize l@ exit
+ then
+ r@ ffs-blkoff ( size.lo size.hi )
+ r> ffs-fragroundup d>l ( size )
+;
+
+: ino-to-cg ( ino fs -- cg ) fs_ipg l@ / ;
+: ino-to-fsbo ( ino fs -- fsb0 ) fs_inopb l@ mod ;
+: ino-to-fsba ( ino fs -- ba.lo ba.hi ) \ Need to remove the stupid stack diags someday
+ 2dup ( ino fs ino fs )
+ ino-to-cg ( ino fs cg )
+ over ( ino fs cg fs )
+ cgimin ( ino fs inode-blk.lo inode-blk.hi )
+ 2swap ( d-inode-blk ino fs )
+ tuck ( d-inode-blk fs ino fs )
+ fs_ipg l@ ( d-inode-blk fs ino ipg )
+ mod ( d-inode-blk fs mod )
+ swap ( d-inode-blk mod fs )
+ dup ( d-inode-blk mod fs fs )
+ fs_inopb l@ ( d-inode-blk mod fs inopb )
+ rot ( d-inode-blk fs inopb mod )
+ swap ( d-inode-blk fs mod inopb )
+ / ( d-inode-blk fs div )
+ swap ( d-inode-blk div fs )
+ ffs-blkstofrags ( d-inode-blk frag )
+ 0 d+
+;
+: ffs-fsbtodb ( fsb.lo fsb.hi fs -- db.lo db.hi )
+ fs_fsbtodb l@ d<<
+;
+
+
+\
+\ LFS suff
+\
+: lfs-blkoff ( pos.lo pos.hi fs -- off.lo off.hi ) lfs_bmask d@ d-and ;
+\ : lfs-fragoff ( pos.lo pos.hi fs -- off.lo off.hi ) lfs_ffmask d@ d-and ;
+\ : lfs-lblktosize ( blk fs -- off.lo off.hi ) 0 lfs_bshift l@ d<< ;
+: lfs-lblkno ( pos.lo pos.hi fs -- off.lo off.hi ) lfs_bshift l@ d>> ;
+: lfs-numfrags ( pos.lo pos.hi fs -- off.lo off.hi ) lfs_ffshift l@ d>> ;
+: lfs-roundup ( pos.lo pos.hi mask.lo mask.hi )
+ 2swap 2over d+ 2swap ( d-pos* d-mask )
+ invert swap invert swap d-and
+;
+: lfs-blkroundup ( pos.lo pos.hi fs -- off.lo off.hi ) lfs_bmask d@ lfs-roundup ;
+: lfs-fragroundup ( pos.lo pos.hi fs -- off.lo off.hi ) lfs_ffmask d@ lfs-roundup ;
+: lfs-fragstoblks ( pos.lo pos.hi fs -- off.lo off.hi ) lfs_fbshift l@ d>> ;
+: lfs-dblksize ( lbn.lo lbn.hi inodep fs -- size )
+ >r -rot 2dup ndaddr l>d d> ( inop d-lbn >ndaddr? )
+ -rot 1 0 d+ ( inop >ndaddr? d-lbn+1 )
+ r@ fs_bshift l@ d<< ( inop >ndaddr? d-lbn+1<<bshift )
+ 2swap >r di-size d@ ( d-lbn+1<<bshift d-size )
+ 2swap 2over d< r> or if ( d-size )
+ 2drop r> fs-bsize l@ exit
then
- " read" boot-ihandle $call-method
+ r@ lfs-blkoff ( size.lo size.hi )
+ r> lfs-fragroundup d>l ( size )
+;
+: lfs-fsbtodb ( fsb.lo fsb.hi fs -- db.lo db.hi )
+ lfs_fsbtodb l@ d<<
+;
+
+\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+\
+\ The rest of the multi-filesystem stuff
+\
+\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+
+\
+\ FFS v1
Home |
Main Index |
Thread Index |
Old Index