Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / board-js2x / slof / bcm57xx.fs
1 \ *****************************************************************************
2 \ * Copyright (c) 2013 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 \ Handle bcm57xx device
14
15 s" network" device-type
16
17 my-space pci-alias-net
18
19 VARIABLE obp-tftp-package
20
21 0 VALUE bcm57xx-priv
22 0 VALUE open-count
23
24 : open  ( -- okay? )
25    open-count 0= IF
26       open IF
27          bcm57xx-open dup not IF ." bcm57xx-open failed" EXIT THEN
28          drop dup TO bcm57xx-priv
29          6 encode-bytes s" local-mac-address" property
30          true
31       ELSE
32          false
33       THEN
34    ELSE
35       true
36    THEN
37    my-args s" obp-tftp" $open-package obp-tftp-package !
38    open-count 1 + to open-count
39 ;
40
41
42 : close  ( -- )
43     open-count 0> IF
44       open-count 1 - dup to open-count
45       0= IF
46          bcm57xx-priv bcm57xx-close
47          close
48       THEN
49    THEN
50    s" close" obp-tftp-package @ $call-method
51 ;
52
53 : read ( buf len -- actual )
54    dup IF
55       bcm57xx-read
56    ELSE  
57       nip
58    THEN
59 ;
60
61 : write ( buf len -- actual )
62    dup IF
63       bcm57xx-write
64    ELSE
65       nip
66    THEN
67 ;
68
69 : load  ( addr -- len )
70    s" load" obp-tftp-package @ $call-method
71 ;
72
73 : ping  ( -- )
74    s" ping" obp-tftp-package @ $call-method
75 ;