Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / slof / fs / usb / usb-static.fs
1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2011, 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 \ Load dev hci
14 : load-dev-hci ( num name-str name-len )
15    s" dev-hci.fs" INCLUDED
16 ;
17
18 0 VALUE ohci-init
19 0 VALUE ehci-init
20 0 VALUE xhci-init
21 0 VALUE usb-alias-num
22
23 : get-usb-alias-num
24   usb-alias-num dup 1+ to usb-alias-num
25 ;
26
27 \ create a new ohci device alias for the current node
28 : set-ohci-alias  (  -- )
29     1 to ohci-init 
30     get-usb-alias-num       ( num )
31     s" ohci" 1 load-dev-hci
32 ;
33
34 \ create a new ehci device alias for the current node
35 : set-ehci-alias  (  -- )
36     1 to ehci-init
37     get-usb-alias-num       ( num )
38     s" ehci" 2 load-dev-hci
39 ;
40
41 \ create a new xhci device alias for the current node
42 : set-xhci-alias  (  -- )
43     1 to xhci-init 
44     get-usb-alias-num       ( num )
45     s" xhci" 3 load-dev-hci
46 ;
47
48 : usb-enumerate ( hcidev -- )
49     USB-HCD-INIT
50 ;
51
52 : usb-scan ( -- )
53     ." Scanning USB " cr
54     ohci-init 1 = IF USB-OHCI-REGISTER THEN
55     ehci-init 1 = IF USB-EHCI-REGISTER THEN
56     xhci-init 1 = IF USB-XHCI-REGISTER THEN
57
58     usb-alias-num 0 ?DO
59         " usb" i $cathex find-device
60         " get-hci-dev" get-node find-method
61         IF
62             execute usb-enumerate
63         ELSE
64             ." get-base-address method not found for usb@" i . 
65             ."  Device type: "
66             " device_type" get-node get-property 0= IF decode-string type cr 2drop THEN
67         THEN
68     LOOP
69     0 set-node     \ FIXME Setting it back
70 ;