1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2008 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 \ ****************************************************************************/
14 ( max-#blocks rsrc id -- )
18 lwsplit swap wbsplit rot set-unit
20 s" disk" device-name s" block" device-type
24 get-parent CONSTANT ppack
27 : our-disk-read ( lba count addr -- )
28 >r >r >r resource-id r> r> r> s" do-read" ppack $call-static ;
32 \ Requiered interface for deblocker
34 200 CONSTANT block-size
35 40000 CONSTANT max-transfer
37 : read-blocks ( addr block# #blocks -- #read )
38 \ my-unit s" dev-read-blocks" $call-parent
39 \ check if the read is within max-#blocks
40 2dup + max-#blocks 1 + > IF
41 \ 2drop drop 0 \ return 0
42 \ returning 0 would be correct (maybe?) but it confuses the deblocker...
43 \ so i erase whatever would have been read and return the "expected" #read
45 swap drop \ drop block# (not needed)
46 block-size * erase \ erase at addr #blocks * block-size
49 dup >r rot our-disk-read r>
53 INSTANCE VARIABLE deblocker
56 0 0 s" deblocker" $open-package dup deblocker ! dup IF
57 s" disk-label" find-package IF
63 deblocker @ close-package ;
65 : seek ( pos.lo pos.hi -- status )
66 2dup lxjoin max-#blocks 1 + block-size * > IF
67 \ illegal seek, return -1
70 s" seek" deblocker @ $call-method
74 : read ( addr len -- actual )
75 s" read" deblocker @ $call-method ;