Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / slof / fs / generic-disk.fs
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
8 \ *
9 \ * Contributors:
10 \ *     IBM Corporation - initial implementation
11 \ ****************************************************************************/
12
13
14 \ Generic disk support
15
16 \ Input:
17 \        name of device ( e.g. "disk", "cdrom", ... )
18 \        dev# 
19
20 \ Needs from parent in device tree:
21 \        dev-read-blocks ( addr block# #blocks phys.lo ... phys.hi -- #read )
22 \        block-size
23 \        max-transfer
24
25 \ Provides:
26 \        open ( -- okay? )
27 \        close ( -- )
28 \        read ( addr len -- actual )
29 \        seek ( pos.lo pos.hi -- status )
30 \        read-blocks ( addr block# #blocks -- #read )
31 \ Uses:
32 \        disk-label package interpose for partition and file systems support
33 \        deblocker package for byte read support
34
35 ( str len phys.lo ... phys.hi -- )
36 new-device set-unit                                          ( str len )
37   2dup device-name 
38   s" 0 pci-alias-" 2swap $cat evaluate
39   s" block" device-type      
40
41 \ Requiered interface for deblocker
42
43    s" block-size" $call-parent   CONSTANT block-size
44    s" max-transfer" $call-parent CONSTANT max-transfer 
45
46 : read-blocks ( addr block# #blocks -- #read )
47    my-unit s" dev-read-blocks" $call-parent
48 ;    
49
50 INSTANCE VARIABLE deblocker
51
52 : open ( -- okay? )
53    0 0 s" deblocker" $open-package dup deblocker ! dup IF 
54       s" disk-label" find-package IF
55          my-args rot interpose
56       THEN
57    THEN 0<> ;
58
59 : close ( -- )
60    deblocker @ close-package ;
61
62 : seek ( pos.lo pos.hi -- status )
63    s" seek" deblocker @ $call-method ;
64
65 : read ( addr len -- actual )
66    s" read" deblocker @ $call-method ;
67
68 finish-device