summaryrefslogtreecommitdiff
path: root/usr/src/psm
diff options
context:
space:
mode:
authorJohn Johnson <John.Johnson@Sun.COM>2009-06-22 15:54:04 -0700
committerJohn Johnson <John.Johnson@Sun.COM>2009-06-22 15:54:04 -0700
commitc713350eb0c205161e2a4ab06cd996300721ac78 (patch)
tree49ec41a3cde4109d1cf01ada70956404128730ae /usr/src/psm
parent1de082f7b7fd4b6629e14b0f9b8f94f6c0bda3c2 (diff)
downloadillumos-joyent-c713350eb0c205161e2a4ab06cd996300721ac78.tar.gz
6798238 SPARC ZFS bootblk can not read a GANG block
6752677 "boot -" doesn't work on S10U6 6803195 extraneous error message when bootblk fcode aborts 6802047 remove conditional header code from bootblks 6804446 hg nits complains about bootblk code 6804838 Stop-A / send break does not interrupt a boot to ZFS root
Diffstat (limited to 'usr/src/psm')
-rw-r--r--usr/src/psm/stand/bootblks/common/boot.fth39
-rw-r--r--usr/src/psm/stand/bootblks/common/util.fth12
-rw-r--r--usr/src/psm/stand/bootblks/hsfs/common/boot-hsfs.fth12
-rw-r--r--usr/src/psm/stand/bootblks/hsfs/common/hsfs.fth11
-rw-r--r--usr/src/psm/stand/bootblks/ufs/common/boot-ufs.fth14
-rw-r--r--usr/src/psm/stand/bootblks/ufs/common/ufs.fth10
-rw-r--r--usr/src/psm/stand/bootblks/zfs/common/boot-zfs.fth13
-rw-r--r--usr/src/psm/stand/bootblks/zfs/common/fs-zfs.fth15
-rw-r--r--usr/src/psm/stand/bootblks/zfs/common/zfs.fth117
9 files changed, 127 insertions, 116 deletions
diff --git a/usr/src/psm/stand/bootblks/common/boot.fth b/usr/src/psm/stand/bootblks/common/boot.fth
index 6ec46f5a3c..ef0fd83940 100644
--- a/usr/src/psm/stand/bootblks/common/boot.fth
+++ b/usr/src/psm/stand/bootblks/common/boot.fth
@@ -19,14 +19,12 @@
\ CDDL HEADER END
\
\
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
\ Use is subject to license terms.
\
-id: %Z%%M% %I% %E% SMI
purpose: boot block for OBP systems
-copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
headerless
@@ -148,18 +146,15 @@ headerless
create spin-data
ascii | c, ascii / c, ascii - c, ascii \ c,
-0 instance variable spindex
+variable spindex
+headers
: spinner ( -- )
spindex @ 3 and spin-data + ( c-adr )
c@ emit (cr
1 spindex +!
;
-: spin-on ( -- ) ['] spinner d# 1000 alarm ;
-: spin-off ( -- ) ['] spinner 0 alarm ;
-
-headers
\ allocate and return physical allocation size
: vmem-alloc-prop ( size virt -- alloc-size virt )
2dup ['] vmem-alloc catch if ( size virt ??? ??? )
@@ -178,6 +173,24 @@ headers
swap
;
+\ read file in chunks so we can toggle the spinner
+: read-file ( virt size fd -- failed? )
+ >r ( virt sz-left r: fd )
+ begin dup while
+ spinner
+ dup 4meg min ( virt sz-left read-sz r: fd )
+ 3dup nip r@ fs-read ( virt sz-left read-sz size-read r: fd )
+ over <> if ( virt sz-left read-sz r: fd )
+ r> 2drop 2drop ( )
+ true exit ( failed )
+ then
+ rot over + ( sz-left read-sz virt' r: fd )
+ -rot - ( virt' sz-left' r: fd )
+ repeat
+ r> 3drop ( )
+ false ( succeeded )
+;
+
\ read in file and return buffer
\ if base==0, vmem-alloc will allocate virt
\ NB returned size is 8k rounded since the
@@ -185,9 +198,8 @@ headers
: get-file ( base fd -- [ alloc-sz virt size ] failed? )
dup >r fs-size ( base size r: fd )
dup rot vmem-alloc-prop ( size alloc-sz virt r: fd )
- rot 2dup tuck r> ( alloc-sz virt size size virt size fd )
- spin-on fs-read spin-off ( alloc-sz virt size size size-rd )
- <> if ( alloc-sz virt size )
+ rot 2dup ( alloc-sz virt size virt size r: fd )
+ r> read-file if ( alloc-sz virt size )
3drop true exit ( failed )
then
h# 2000 roundup ( alloc-sz virt size' )
@@ -437,8 +449,9 @@ headers
dup >r 2swap r> - ( adr' len' s-adr s-len )
;
+\ next char or 0 if eol
: next-c ( adr len -- adr' len' c )
- over c@ >r str++ r>
+ dup if over c@ >r str++ r> else 0 then
;
false value halt?
diff --git a/usr/src/psm/stand/bootblks/common/util.fth b/usr/src/psm/stand/bootblks/common/util.fth
index 3bbcd62499..33e0597553 100644
--- a/usr/src/psm/stand/bootblks/common/util.fth
+++ b/usr/src/psm/stand/bootblks/common/util.fth
@@ -19,22 +19,14 @@
\ CDDL HEADER END
\
\
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
\ Use is subject to license terms.
\
-id: %Z%%M% %I% %E% SMI
purpose: utility words
-copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
-[ifdef] doheaders
-headers
-[else]
-headerless
-[then]
-
d# 256 constant /buf-len
\
diff --git a/usr/src/psm/stand/bootblks/hsfs/common/boot-hsfs.fth b/usr/src/psm/stand/bootblks/hsfs/common/boot-hsfs.fth
index 4328400421..2c81d1afb1 100644
--- a/usr/src/psm/stand/bootblks/hsfs/common/boot-hsfs.fth
+++ b/usr/src/psm/stand/bootblks/hsfs/common/boot-hsfs.fth
@@ -1,7 +1,3 @@
-
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-\ Use is subject to license terms.
\
\ CDDL HEADER START
\
@@ -23,13 +19,13 @@
\ CDDL HEADER END
\
\
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
-id: %Z%%M% %I% %E% SMI
purpose: HSFS file system support package for NewBoot
-copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
-\ add headers
-create doheaders
: fs-pkg$ " hsfs-file-system" ;
: fs-type$ " hsfs" ;
diff --git a/usr/src/psm/stand/bootblks/hsfs/common/hsfs.fth b/usr/src/psm/stand/bootblks/hsfs/common/hsfs.fth
index 8a513fdbf3..b911fe421b 100644
--- a/usr/src/psm/stand/bootblks/hsfs/common/hsfs.fth
+++ b/usr/src/psm/stand/bootblks/hsfs/common/hsfs.fth
@@ -1,7 +1,3 @@
-
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-\ Use is subject to license terms.
\
\ CDDL HEADER START
\
@@ -23,10 +19,13 @@
\ CDDL HEADER END
\
\
+\
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
-id: %Z%%M% %I% %E% SMI
purpose: HSFS file system support package for NewBoot
-copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
\ High Sierra, Rock Ridge (CD-ROM) file system reader and boot block
diff --git a/usr/src/psm/stand/bootblks/ufs/common/boot-ufs.fth b/usr/src/psm/stand/bootblks/ufs/common/boot-ufs.fth
index 7deb242e70..17b3dd0094 100644
--- a/usr/src/psm/stand/bootblks/ufs/common/boot-ufs.fth
+++ b/usr/src/psm/stand/bootblks/ufs/common/boot-ufs.fth
@@ -1,8 +1,3 @@
-
-
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-\ Use is subject to license terms.
\
\ CDDL HEADER START
\
@@ -23,14 +18,15 @@
\
\ CDDL HEADER END
\
+\
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
-id: %Z%%M% %I% %E% SMI
purpose: UFS bootblock for sun4u platforms
-copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
-\ add headers
-create doheaders
: fs-pkg$ " ufs-file-system" ;
: fs-type$ " ufs" ;
diff --git a/usr/src/psm/stand/bootblks/ufs/common/ufs.fth b/usr/src/psm/stand/bootblks/ufs/common/ufs.fth
index 25531ecd78..e07cf2ba45 100644
--- a/usr/src/psm/stand/bootblks/ufs/common/ufs.fth
+++ b/usr/src/psm/stand/bootblks/ufs/common/ufs.fth
@@ -1,7 +1,3 @@
-
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-\ Use is subject to license terms.
\
\ CDDL HEADER START
\
@@ -23,11 +19,13 @@
\ CDDL HEADER END
\
\
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
-id: %Z%%M% %I% %E% SMI
purpose: UFS file system support package
-copyright: Copyright 1995 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
headers
" /packages" get-package push-package
diff --git a/usr/src/psm/stand/bootblks/zfs/common/boot-zfs.fth b/usr/src/psm/stand/bootblks/zfs/common/boot-zfs.fth
index a3ba4b790a..2b3f5dd2d6 100644
--- a/usr/src/psm/stand/bootblks/zfs/common/boot-zfs.fth
+++ b/usr/src/psm/stand/bootblks/zfs/common/boot-zfs.fth
@@ -1,8 +1,3 @@
-
-
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2008 Sun Microsystems, Inc. All rights reserved.
-\ Use is subject to license terms.
\
\ CDDL HEADER START
\
@@ -23,14 +18,16 @@
\
\ CDDL HEADER END
\
+\
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
-id: %Z%%M% %I% %E% SMI
purpose: ZFS bootblock
-copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
\ big bootblk
-create doheaders
create bigbootblk
d# 8192 constant /fs-fcode
diff --git a/usr/src/psm/stand/bootblks/zfs/common/fs-zfs.fth b/usr/src/psm/stand/bootblks/zfs/common/fs-zfs.fth
index 986dabf003..e85e42ef8f 100644
--- a/usr/src/psm/stand/bootblks/zfs/common/fs-zfs.fth
+++ b/usr/src/psm/stand/bootblks/zfs/common/fs-zfs.fth
@@ -1,8 +1,3 @@
-
-
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-\ Use is subject to license terms.
\
\ CDDL HEADER START
\
@@ -23,15 +18,15 @@
\
\ CDDL HEADER END
\
+\
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
-id: %Z%%M% %I% %E% SMI
purpose: ZFS debug fs reader
-copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
-\ add headers
-create doheaders
-create bigbootblk
: fs-pkg$ " zfs-file-system" ;
: fs-type$ " zfs" ;
diff --git a/usr/src/psm/stand/bootblks/zfs/common/zfs.fth b/usr/src/psm/stand/bootblks/zfs/common/zfs.fth
index c1553aed57..8fe5a55cdd 100644
--- a/usr/src/psm/stand/bootblks/zfs/common/zfs.fth
+++ b/usr/src/psm/stand/bootblks/zfs/common/zfs.fth
@@ -1,7 +1,3 @@
-
-\ ident "%Z%%M% %I% %E% SMI"
-\ Copyright 2008 Sun Microsystems, Inc. All rights reserved.
-\ Use is subject to license terms.
\
\ CDDL HEADER START
\
@@ -23,17 +19,13 @@
\ CDDL HEADER END
\
\
-
-[ifdef] doheaders
-headers
-[else]
-headerless
-[then]
+\ Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
-id: %Z%%M% %I% %E% SMI
purpose: ZFS file system support package
-copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
+copyright: Copyright 2009 Sun Microsystems, Inc. All Rights Reserved
" /packages" get-package push-package
@@ -172,12 +164,22 @@ new-device
\ ZFS block (SPA) routines
\
+ 1 constant def-comp#
2 constant no-comp#
+ 3 constant lzjb-comp#
+
h# 2.0000 constant /max-bsize
d# 512 constant /disk-block
d# 128 constant /blkp
- : blk_offset ( bp -- n ) h# 8 + x@ -1 h# 8fff.ffff lxjoin and ;
+ alias /gang-block /disk-block
+
+ \ the ending checksum is larger than 1 byte, but that
+ \ doesn't affect the math here
+ /gang-block 1-
+ /blkp / constant #blks/gang
+
+ : blk_offset ( bp -- n ) h# 8 + x@ -1 h# 7fff.ffff lxjoin and ;
: blk_gang ( bp -- n ) h# 8 + x@ xlsplit nip d# 31 rshift ;
: blk_comp ( bp -- n ) h# 33 + c@ ;
: blk_psize ( bp -- n ) h# 34 + w@ ;
@@ -194,47 +196,74 @@ new-device
: bp-dsize ( bp -- dsize ) blk_psize fsz>dsz ;
: bp-lsize ( bp -- lsize ) blk_lsize fsz>dsz ;
- : (read-bp) ( adr len bp -- )
+ : (read-dva) ( adr len dva -- )
blk_offset foff>doff dev-ih read-disk
;
- : gang-read ( adr len bp -- )
+ : gang-read ( adr len bp gb-adr -- ) tokenizer[ reveal ]tokenizer
\ read gang block
- gang-space /disk-block rot ( adr len gb-adr gb-len bp )
- (read-bp) ( adr len )
+ tuck /gang-block rot (read-dva) ( adr len gb-adr )
- \ read gang indirected blocks to blk-space
- \ and copy requested len from there
- blk-space gang-space ( adr len tmp-adr bp0 )
- dup /blkp 3 * + bounds do ( adr len tmp-adr )
+ \ loop through indirected bp's
+ dup /blkp #blks/gang * ( adr len gb-adr bp-list bp-list-len )
+ bounds do ( adr len gb-adr )
i blk_offset x0= ?leave
- i bp-dsize ( adr len tmp-adr rd-len )
- 2dup i (read-bp)
- + ( adr len tmp-adr' )
+
+ \ calc subordinate read len
+ over i bp-dsize min ( adr len gb-adr sub-len )
+ 2swap swap ( gb-adr sub-len len adr )
+
+ \ nested gang block - recurse with new gang block area
+ i blk_gang if
+ 2swap ( len adr gb-adr sub-len )
+ 3dup swap /gang-block + ( len adr gb-adr sub-len adr sub-len gb-adr' )
+ i swap gang-read ( len adr gb-adr sub-len )
+ 2swap ( gb-adr sub-len len adr )
+ else
+ 3dup nip swap ( gb-adr sub-len len adr adr sub-len )
+ i (read-dva) ( gb-adr sub-len len adr )
+ then ( gb-adr sub-len len adr )
+
+ \ adjust adr,len and check if done
+ -rot over - ( gb-adr adr sub-len len' )
+ -rot + swap ( gb-adr adr' len' )
+ dup 0= ?leave
+ rot ( adr' len' gb-adr )
/blkp +loop
- drop ( adr len )
- blk-space -rot move ( )
+ 3drop ( )
+ ;
+
+ : read-dva ( adr len dva -- )
+ dup blk_gang if
+ gang-space gang-read
+ else
+ (read-dva)
+ then
;
\ block read that check for holes, gangs, compression, etc
: read-bp ( adr len bp -- )
\ sparse block?
dup blk_birth x0= if
- drop erase exit ( )
+ drop erase exit ( )
then
- \ gang block?
- dup blk_gang if
- gang-read exit ( )
+
+ \ no compression?
+ dup blk_comp no-comp# = if
+ read-dva exit ( )
then
- \ compression?
- dup blk_comp no-comp# <> if
- blk-space over bp-dsize ( adr len bp b-adr rd-len )
- rot (read-bp) ( adr len )
- blk-space -rot lzjb exit ( )
+
+ \ only do lzjb
+ dup blk_comp dup lzjb-comp# <> ( adr len bp comp lzjb? )
+ swap def-comp# <> and if ( adr len bp )
+ " only lzjb supported" die
then
- \ boring direct block
- (read-bp) ( )
+
+ \ read into blk-space and de-compress
+ blk-space over bp-dsize ( adr len bp blk-adr rd-len )
+ rot read-dva ( adr len )
+ blk-space -rot lzjb ( )
;
\
@@ -685,7 +714,6 @@ new-device
;
[then]
-[ifdef] bigbootblk
: fz-print ( dn le -- false )
entry-name$ type cr false
;
@@ -710,7 +738,6 @@ new-device
endcase ( false )
drop ( )
;
-[then]
\
@@ -1116,13 +1143,13 @@ new-device
;
- /max-bsize 5 *
- /uber-block +
- /dnode 6 * +
- /disk-block + ( size )
+ /max-bsize 5 *
+ /uber-block +
+ /dnode 6 * +
+ /disk-block 6 * + ( size )
\ ugh - sg proms can't free 512k allocations
\ that aren't a multiple of 512k in size
- h# 8.0000 roundup ( size' )
+ h# 8.0000 roundup ( size' )
constant alloc-size
@@ -1291,7 +1318,6 @@ new-device
;
-[ifdef] bigbootblk
: chdir ( dir$ -- )
current-obj# -rot ( obj# dir$ )
lookup if ( obj# )
@@ -1308,7 +1334,6 @@ new-device
current-obj# get-fs-dnode
dnode zap-print
;
-[then]
finish-device
pop-package