Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / slof / fs / usb / dev-hci.fs
1 \ *****************************************************************************
2 \ * Copyright (c) 2006, 2012, 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 \ * [OEX]HCI functions
14 \ *
15 \ ****************************************************************************
16
17 \ ( num $name type )
18
19 VALUE usb_type \ USB type
20
21 \ Open Firmware Properties
22 device-type
23 " usb" 2dup device-name
24
25 rot
26 VALUE usb_num                           \ controller number
27 usb_num $cathex strdup                  \ create alias name
28 2dup find-alias 0= IF
29    get-node node>path set-alias
30 ELSE 3drop THEN
31
32 /hci-dev BUFFER: hcidev
33 usb_num hcidev usb-setup-hcidev
34 TRUE VALUE first-time-init?
35 0 VALUE open-count
36
37 false VALUE dev-hci-debug?
38
39 1 encode-int s" #address-cells" property
40 0 encode-int s" #size-cells" property
41
42 \ converts physical address to text unit string
43 : encode-unit ( port -- unit-str unit-len ) 1 hex-encode-unit ;
44
45 \ Converts text unit string to phyical address
46 : decode-unit ( addr len -- port ) 1 hex-decode-unit ;
47
48 : get-hci-dev ( -- hcidev )
49     hcidev
50 ;
51
52 : hc-cleanup ( -- )
53     my-phandle set-node
54     dev-hci-debug? IF ." USB-HCI: Cleaning up " pwd cr THEN
55     hcidev USB-HCD-EXIT
56     0 set-node
57 ;
58
59 : open   ( -- true | false )
60     true
61 ;
62
63 : close
64 ;
65
66 \ create a new entry to cleanup and suspend HCI
67 \ after first init
68 first-time-init? IF
69    ['] hc-cleanup add-quiesce-xt
70    false to first-time-init?
71 THEN