Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / board-qemu / slof / vio-veth.fs
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
8 \ *
9 \ * Contributors:
10 \ *     IBM Corporation - initial implementation
11 \ ****************************************************************************/
12
13 ." Populating " pwd cr
14
15 " network" device-type
16
17 INSTANCE VARIABLE obp-tftp-package
18 0 VALUE veth-priv
19 0 VALUE open-count
20
21 : open  ( -- okay? )
22    open-count 0= IF
23       my-unit 1 rtas-set-tce-bypass
24       s" local-mac-address" get-node get-property not
25       s" reg" get-node get-property not 3 pick and IF
26          >r nip r>
27          libveth-open dup not IF ." libveth-open failed" EXIT THEN
28          drop TO veth-priv
29       THEN
30    THEN
31    my-args s" obp-tftp" $open-package obp-tftp-package !
32    open-count 1 + to open-count
33    true
34 ;
35
36 : close  ( -- )
37    open-count 0> IF
38       open-count 1 - dup to open-count
39       0= IF
40          veth-priv libveth-close
41          my-unit 0 rtas-set-tce-bypass
42       THEN
43    THEN
44    s" close" obp-tftp-package @ $call-method
45 ;
46
47 : read ( buf len -- actual )
48    dup IF
49       veth-priv libveth-read
50    ELSE
51       nip
52    THEN
53 ;
54
55 : write ( buf len -- actual )
56    dup IF
57       veth-priv libveth-write
58    ELSE
59       nip
60    THEN
61 ;
62
63 : load  ( addr -- len )
64     s" load" obp-tftp-package @ $call-method 
65 ;
66
67 : ping  ( -- )
68     s" ping" obp-tftp-package @ $call-method
69 ;
70
71 : setup-alias
72     " net" get-next-alias ?dup IF
73         get-node node>path set-alias
74     THEN
75 ;
76 setup-alias