diff options
-rw-r--r-- | board-qemu/slof/vio-vscsi-device.fs | 9 | ||||
-rw-r--r-- | board-qemu/slof/vio-vscsi.fs | 11 |
2 files changed, 17 insertions, 3 deletions
diff --git a/board-qemu/slof/vio-vscsi-device.fs b/board-qemu/slof/vio-vscsi-device.fs index 1c48706..842d7b5 100644 --- a/board-qemu/slof/vio-vscsi-device.fs +++ b/board-qemu/slof/vio-vscsi-device.fs @@ -50,12 +50,17 @@ INSTANCE VARIABLE deblocker : open ( -- true | false ) my-unit " set-address" $call-parent is_cdrom IF " dev-prep-cdrom" ELSE " dev-prep-disk" THEN $call-parent - " dev-get-capacity" $call-parent to max-block-num to block-size " dev-max-transfer" $call-parent to max-transfer + " dev-get-capacity" $call-parent to max-block-num to block-size + max-block-num 0= block-size 0= OR IF + ." Failed to get disk capacity!" cr + FALSE EXIT + THEN + 0 0 " deblocker" $open-package dup deblocker ! dup IF " disk-label" find-package IF - my-args rot interpose + my-args rot interpose THEN THEN 0<> ; diff --git a/board-qemu/slof/vio-vscsi.fs b/board-qemu/slof/vio-vscsi.fs index 92ffe33..4333b21 100644 --- a/board-qemu/slof/vio-vscsi.fs +++ b/board-qemu/slof/vio-vscsi.fs @@ -467,7 +467,12 @@ CREATE sector d# 512 allot ; : dev-get-capacity ( -- blocksize #blocks ) - read-capacity not IF 0 0 EXIT THEN + \ Make sure that there are zeros in the buffer in case something goes wrong: + sector 10 erase + \ Now issue the read-capacity command + read-capacity not IF + 0 0 EXIT + THEN sector scsi-get-capacity-10 ; @@ -560,6 +565,10 @@ CREATE sector d# 512 allot ; : dev-prep-disk ( -- ) + initial-test-unit-ready 0= IF + ." Disk not ready!" cr + 3drop + THEN ; : vscsi-create-disk ( lun id -- ) |