1 \ *****************************************************************************
2 \ * Copyright (c) 2011 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
13 \ ." Populating " pwd cr
17 FALSE VALUE initialized?
19 \ Required interface for deblocker
22 8000 CONSTANT max-transfer
24 INSTANCE VARIABLE deblocker
26 virtio-setup-vd VALUE virtiodev
28 \ Quiesce the virtqueue of this device so that no more background
29 \ transactions can be pending.
32 my-phandle node>path open-dev ?dup IF
33 virtiodev virtio-blk-shutdown
40 \ Basic device initialization - which has only to be done once
42 virtiodev virtio-blk-init to block-size
44 ['] shutdown add-quiesce-xt
47 \ Read multiple blocks - called by deblocker package
48 : read-blocks ( addr block# #blocks -- #read )
49 virtiodev virtio-blk-read
52 \ Standard node "open" function
54 open 0= IF false EXIT THEN
55 dup initialized? 0= AND IF
58 0 0 s" deblocker" $open-package dup deblocker ! dup IF
59 s" disk-label" find-package IF
66 \ Standard node "close" function
68 deblocker @ close-package
72 \ Standard node "seek" function
73 : seek ( pos.lo pos.hi -- status )
74 s" seek" deblocker @ $call-method
77 \ Standard node "read" function
78 : read ( addr len -- actual )
79 s" read" deblocker @ $call-method
82 \ Set disk alias if none is set yet
84 s" disk" get-next-alias ?dup IF
85 get-node node>path set-alias