diff options
author | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2013-07-24 14:26:09 +0530 |
---|---|---|
committer | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2013-07-24 14:46:22 +0530 |
commit | 2fe02a36df57e7d41ccb46fa7eb9d2497dfa2080 (patch) | |
tree | 0aa739135f2a9707011378c5efb9883207c7a1f2 /board-qemu/slof | |
parent | eaa4930e5cf5548c7f831a9b238e7de72fe502e5 (diff) | |
download | SLOF-2fe02a36df57e7d41ccb46fa7eb9d2497dfa2080.zip SLOF-2fe02a36df57e7d41ccb46fa7eb9d2497dfa2080.tar.gz SLOF-2fe02a36df57e7d41ccb46fa7eb9d2497dfa2080.tar.bz2 |
scsi: unify scsi probing code
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Diffstat (limited to 'board-qemu/slof')
-rw-r--r-- | board-qemu/slof/Makefile | 1 | ||||
-rw-r--r-- | board-qemu/slof/vio-vscsi.fs | 77 | ||||
-rw-r--r-- | board-qemu/slof/virtio-scsi.fs | 80 |
3 files changed, 9 insertions, 149 deletions
diff --git a/board-qemu/slof/Makefile b/board-qemu/slof/Makefile index bbf0ca4..62c3995 100644 --- a/board-qemu/slof/Makefile +++ b/board-qemu/slof/Makefile @@ -81,6 +81,7 @@ OF_FFS_FILES = \ $(SLOFCMNDIR)/fs/xmodem.fs \ $(SLOFCMNDIR)/fs/scsi-disk.fs \ $(SLOFCMNDIR)/fs/scsi-host-helpers.fs \ + $(SLOFCMNDIR)/fs/scsi-probe-helpers.fs \ $(SLOFCMNDIR)/fs/scsi-support.fs \ $(SLOFBRDDIR)/default-font.bin \ $(SLOFBRDDIR)/pci-phb.fs \ diff --git a/board-qemu/slof/vio-vscsi.fs b/board-qemu/slof/vio-vscsi.fs index 3fbe291..572c482 100644 --- a/board-qemu/slof/vio-vscsi.fs +++ b/board-qemu/slof/vio-vscsi.fs @@ -504,83 +504,12 @@ TRUE VALUE first-time-init? 10000 \ Larger value seem to have problems with some CDROMs ; -\ FIXME: Most of the stuff below should be made common - -: wrapped-inquiry ( -- true | false ) - inquiry 0= IF false EXIT THEN - \ Skip devices with PQ != 0 - sector inquiry-data>peripheral c@ e0 and 0 = -; - 8 CONSTANT #dev - -: vscsi-read-lun ( addr -- lun true | false ) - dup c@ C0 AND CASE - 40 OF w@-be 3FFF AND TRUE ENDOF - 0 OF w@-be TRUE ENDOF - dup dup OF ." Unsupported LUN format = " . cr FALSE ENDOF - ENDCASE -; - -: get-max-target ( -- #dev ) +: dev-max-target ( -- #max-target ) #dev ; -: vscsi-report-luns ( -- array ndev ) - \ array of pointers, up to 8 devices - get-max-target 3 << alloc-mem dup - 0 ( devarray devcur ndev ) - get-max-target 0 DO - i 0 dev-generate-srplun (set-target) - report-luns nip IF - sector l@ ( devarray devcur ndev size ) - sector 8 + swap ( devarray devcur ndev lunarray size ) - dup 8 + dup alloc-mem ( devarray devcur ndev lunarray size size+ mem ) - dup rot 0 fill ( devarray devcur ndev lunarray size mem ) - dup >r swap move r> ( devarray devcur ndev mem ) - dup sector l@ 3 >> 0 DO ( devarray devcur ndev mem memcur ) - dup dup vscsi-read-lun IF - j swap dev-generate-srplun swap x! 8 + - ELSE - 2drop - THEN - LOOP drop - rot ( devarray ndev mem devcur ) - dup >r x! r> 8 + ( devarray ndev devcur ) - swap 1 + - THEN - LOOP - nip -; - -: vscsi-find-disks ( -- ) - ." VSCSI: Looking for devices" cr - vscsi-report-luns - 0 ?DO - dup x@ - BEGIN - dup x@ - dup 0= IF drop TRUE ELSE - (set-target) wrapped-inquiry IF - ." " current-target (u.) type ." " - \ XXX FIXME: Check top bits to ignore unsupported units - \ and maybe provide better printout & more cases - \ XXX FIXME: Actually check for LUNs - sector inquiry-data>peripheral c@ CASE - 0 OF ." DISK : " " disk" current-target make-disk-alias ENDOF - 5 OF ." CD-ROM : " " cdrom" current-target make-disk-alias ENDOF - 7 OF ." OPTICAL : " " cdrom" current-target make-disk-alias ENDOF - e OF ." RED-BLOCK: " " disk" current-target make-disk-alias ENDOF - dup dup OF ." ? (" . 8 emit 29 emit 5 spaces ENDOF - ENDCASE - sector .inquiry-text cr - THEN - 8 + FALSE - THEN - UNTIL drop - 8 + - LOOP drop -; +" scsi-probe-helpers.fs" included \ Remove scsi functions from word list scsi-close @@ -599,7 +528,7 @@ scsi-close my-self >r dup to my-self \ Scan the VSCSI bus: - vscsi-find-disks + scsi-find-disks setup-alias \ Close the temporary instance: close-node diff --git a/board-qemu/slof/virtio-scsi.fs b/board-qemu/slof/virtio-scsi.fs index c87ef14..a94fb7f 100644 --- a/board-qemu/slof/virtio-scsi.fs +++ b/board-qemu/slof/virtio-scsi.fs @@ -157,82 +157,12 @@ scsi-open lxjoin (set-target) ; -\ FIXME Remove use of "sector" -: wrapped-inquiry ( -- true | false ) - inquiry dup 0= IF drop false EXIT THEN - \ Skip devices with PQ != 0 - inquiry-data>peripheral c@ e0 and 0 = +100 CONSTANT #target +: dev-max-target ( -- #target ) + #target ; -\ Get rid of that when report-lun returns an allocated buffer -CREATE sectorlun d# 512 allot - -100 CONSTANT #targets -: virtio-scsi-read-lun ( addr -- lun true | false ) - dup c@ C0 AND CASE - 40 OF w@-be 3FFF AND TRUE ENDOF - 0 OF w@-be TRUE ENDOF - dup dup OF ." Unsupported LUN format = " . cr FALSE ENDOF - ENDCASE -; - -: virtio-scsi-report-luns ( -- array ndev ) - ." VIRTIO-SCSI: report luns " - \ virtiodev 0 vs-cfg>max-target 4 virtio-get-config . cr - #targets 3 << alloc-mem dup - 0 - #targets 0 DO - ." Looping " i . cr - i 0 dev-generate-srplun (set-target) - report-luns nip IF - sector l@ ( devarray devcur ndev size ) - sector 8 + swap ( devarray devcur ndev lunarray size ) - dup 8 + dup alloc-mem ( devarray devcur ndev lunarray size size+ mem ) - dup rot 0 fill ( devarray devcur ndev lunarray size mem ) - dup >r swap move r> ( devarray devcur ndev mem ) - dup sector l@ 3 >> 0 DO ( devarray devcur ndev mem memcur ) - dup dup virtio-scsi-read-lun IF - j dev-generate-srplun swap x! 8 + - ELSE - 2drop - THEN - LOOP drop - rot ( devarray ndev mem devcur ) - dup >r x! r> 8 + ( devarray ndev devcur ) - swap 1 + - THEN - LOOP - nip -; - -: virtio-scsi-find-disks ( -- ) - ." VIRTIO-SCSI: Looking for devices" cr - virtio-scsi-report-luns - 0 ?DO - dup x@ - BEGIN - dup x@ - dup 0= IF drop TRUE ELSE - (set-target) wrapped-inquiry IF - ." " current-target (u.) type ." " - \ XXX FIXME: Check top bits to ignore unsupported units - \ and maybe provide better printout & more cases - \ XXX FIXME: Actually check for LUNs - sector inquiry-data>peripheral c@ CASE - 0 OF ." DISK : " " disk" current-target make-disk-alias ENDOF - 5 OF ." CD-ROM : " " cdrom" current-target make-disk-alias ENDOF - 7 OF ." OPTICAL : " " cdrom" current-target make-disk-alias ENDOF - e OF ." RED-BLOCK: " " disk" current-target make-disk-alias ENDOF - dup dup OF ." ? (" . 8 emit 29 emit 5 spaces ENDOF - ENDCASE - sector .inquiry-text cr - THEN - 8 + FALSE - THEN - UNTIL drop - 8 + - LOOP drop -; +" scsi-probe-helpers.fs" included scsi-close \ no further scsi words required @@ -279,7 +209,7 @@ scsi-close \ no further scsi words required virtiodev virtio-scsi-init 0= IF setup-virt-queues - virtio-scsi-find-disks + scsi-find-disks setup-alias TRUE to initialized? ['] virtio-scsi-shutdown add-quiesce-xt |