block word is not a block number, actually its an allocated host
address. Rename it to disk-buf along with a associated
size(disk-buf-size=4096) for using during allocation/free.
Also renaming the helper routine read-sector to read-disk-buf. This
routine assumes the address to be disk-buf and only takes sector number
as argument.
Signed-off-by: Nikunj A Dadhania nik...@linux.vnet.ibm.com
---
slof/fs/packages/disk-label.fs | 78 ++
1 file changed, 41 insertions(+), 37 deletions(-)
diff --git a/slof/fs/packages/disk-label.fs b/slof/fs/packages/disk-label.fs
index 8c93cfb..0995808 100644
--- a/slof/fs/packages/disk-label.fs
+++ b/slof/fs/packages/disk-label.fs
@@ -33,7 +33,8 @@ s disk-label device-name
0 INSTANCE VALUE dos-logical-partitions
0 INSTANCE VALUE block-size
-0 INSTANCE VALUE block
+0 INSTANCE VALUE disk-buf
+d# 4096VALUE disk-buf-size
0 INSTANCE VALUE args
0 INSTANCE VALUE args-len
@@ -126,11 +127,11 @@ CONSTANT /gpt-part-entry
;
-\ read sector to array block
-: read-sector ( sector-number -- )
+\ read sector to array disk-buf
+: read-disk-buf ( sector-number -- )
\ block-size is 0x200 on disks, 0x800 on cdrom drives
block-size * 0 seek drop \ seek to sector
- block block-size read drop\ read sector
+ disk-buf block-size read drop\ read sector
;
: (.part-entry) ( part-entry )
@@ -149,35 +150,35 @@ CONSTANT /gpt-part-entry
: (.name) r@ begin cell - dup @ colon = UNTIL xtname cr type space ;
-: init-block ( -- )
+: init-disk-buf ( -- )
s block-size ['] $call-parent CATCH IF ABORT parent has no block-size.
THEN
to block-size
- d# 4096 alloc-mem
- dup d# 4096 erase
- to block
+ disk-buf-size alloc-mem
+ dup disk-buf-size erase
+ to disk-buf
debug-disk-label? IF
- . init-block: block-size= block-size .d . block=0x block u. cr
+ . init-disk-buf: block-size= block-size .d . disk-buf=0x disk-buf u.
cr
THEN
;
: partitionpart-entry ( partition -- part-entry )
- 1- /partition-entry * block mbrpartition-table +
+ 1- /partition-entry * disk-buf mbrpartition-table +
;
: partitionstart-sector ( partition -- sector-offset )
partitionpart-entry part-entrysector-offset l@-le
;
-\ This word returns true if the currently loaded block has _NO_ MBR magic
+\ This word returns true if the currently loaded disk-buf has _NO_ MBR magic
: no-mbr? ( -- true|false )
- 0 read-sector
+ 0 read-disk-buf
1 partitionpart-entry part-entryid c@ ee = IF TRUE EXIT THEN \ GPT
partition found
- block mbrmagic w@-le aa55
+ disk-buf mbrmagic w@-le aa55
;
-\ This word returns true if the currently loaded block has _NO_ GPT partition
id
+\ This word returns true if the currently loaded disk-buf has _NO_ GPT
partition id
: no-gpt? ( -- true|false )
- 0 read-sector
+ 0 read-disk-buf
1 partitionpart-entry part-entryid c@ ee
;
@@ -197,7 +198,7 @@ CONSTANT /gpt-part-entry
part-entrysector-offset l@-le( current sector )
dup to part-start to lpart-start ( current )
BEGIN
-part-start read-sector \ read EBR
+part-start read-disk-buf \ read EBR
1 partitionstart-sector IF
\ . Logical Partition found at part-start .d cr
1+
@@ -240,7 +241,7 @@ CONSTANT /gpt-part-entry
part-entrysector-offset l@-le( log-part current sector )
dup to part-start to lpart-start ( log-part current )
BEGIN
- part-start read-sector \ read EBR
+ part-start read-disk-buf \ read EBR
1 partitionstart-sector IF\ first partition entry
1+ 2dup = IF( log-part current )
2drop
@@ -306,13 +307,13 @@ CONSTANT /gpt-part-entry
: has-iso9660-filesystem ( -- TRUE|FALSE )
\ Seek to the beginning of logical 2048-byte sector 16
\ refer to Chapter C.11.1 in PAPR 2.0 Spec
- \ was: 10 read-sector, but this might cause trouble if you
+ \ was: 10 read-disk-buf, but this might cause trouble if you
\ try booting an ISO image from a device with 512b sectors.
10 800 * 0 seek drop \ seek to sector
- block 800 read drop \ read sector
+ disk-buf 800 read drop \ read sector
\ Check for CD-ROM volume magic:
- block c@ 1 =
- block 1+ 5 s CD001 str=
+ disk-buf c@ 1 =
+ disk-buf 1+ 5 s CD001 str=
and
dup IF 800 to block-size THEN
;
@@ -361,7 +362,7 @@ C612CONSTANT GPT-PREP-PARTITION-2
AA268B49521E5A8BCONSTANT GPT-PREP-PARTITION-4
: gpt-prep-partition? ( -- true|false )
- block gpt-part-entrypart-type-guid
+ disk-buf gpt-part-entrypart-type-guid
dup l@-le GPT-PREP-PARTITION-1 IF drop false EXIT THEN
dup 4 + w@-le GPT-PREP-PARTITION-2 IF drop false EXIT THEN
dup 6 + w@-le GPT-PREP-PARTITION-3 IF drop false EXIT