Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: probehub.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)probehub.fth 1.1 07/01/04 | |
43 | purpose: USB Hub Probing Code | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved | |
45 | \ See license at end of file | |
46 | ||
47 | hex | |
48 | ||
49 | [ifndef] set-usb20-char | |
50 | : set-usb20-char ( port dev -- ) 2drop ; | |
51 | [then] | |
52 | ||
53 | : power-hub-port ( port -- ) PORT_POWER DR_PORT set-feature drop ; | |
54 | : reset-hub-port ( dev port -- ) PORT_RESET DR_PORT set-feature drop d# 20 ms ; | |
55 | ||
56 | : probe-hub-port ( hub-dev port -- ) | |
57 | swap set-target ( port ) | |
58 | dup reset-hub-port ( port ) | |
59 | ||
60 | gen-desc-buf 4 2 pick DR_PORT get-status nip if | |
61 | ." Failed to get port status for port " u. cr | |
62 | exit | |
63 | then ( port ) | |
64 | ||
65 | gen-desc-buf c@ 1 and 0= if drop exit then \ No device connected | |
66 | ok-to-add-device? 0= if drop exit then \ Can't add another device | |
67 | ||
68 | new-address ( port dev ) | |
69 | gen-desc-buf le-w@ h# 600 and 9 >> over di-speed! | |
70 | ( port dev ) | |
71 | 2dup set-usb20-char ( port dev ) | |
72 | ||
73 | 0 set-target ( port dev ) \ Address it as device 0 | |
74 | dup set-address if 2drop exit then ( port dev ) \ Assign it usb addr dev | |
75 | dup set-target ( port dev ) \ Address it as device dev | |
76 | make-device-node ( ) | |
77 | ; | |
78 | ||
79 | external | |
80 | : probe-hub ( dev -- ) | |
81 | dup set-target ( hub-dev ) | |
82 | gen-desc-buf 8 0 0 HUB DR_HUB get-desc nip if | |
83 | ." Failed to get hub descriptor" cr | |
84 | exit | |
85 | then | |
86 | ||
87 | gen-desc-buf dup 5 + c@ swap ( hub-dev #2ms adr ) | |
88 | 2 + c@ 1+ ( hub-dev #2ms #ports ) | |
89 | ||
90 | " configuration#" get-int-property set-config ( hub-dev #2ms #ports usberr ) | |
91 | if 2drop ." Failed to set config for hub at " u. cr exit then | |
92 | ||
93 | tuck 1 ?do i power-hub-port loop 2* ms | |
94 | ( hub-dev #ports ) | |
95 | d# 100 ms | |
96 | ||
97 | ( hub-dev #ports ) 1 ?do | |
98 | dup i ['] probe-hub-port catch if | |
99 | 2drop | |
100 | ." Failed to probe hub port " i u. cr | |
101 | then | |
102 | loop drop | |
103 | ; | |
104 | ||
105 | : probe-hub-xt ( -- adr ) ['] probe-hub ; | |
106 | ||
107 | \ Sun Note - create PCI compatible property for hcd. | |
108 | ||
109 | fload ${BP}/dev/pci/compatible.fth | |
110 | fload ${BP}/dev/pci/compatible-prop.fth | |
111 | ||
112 | make-compatible-property | |
113 | ||
114 | headers | |
115 | ||
116 | \ LICENSE_BEGIN | |
117 | \ Copyright (c) 2006 FirmWorks | |
118 | \ | |
119 | \ Permission is hereby granted, free of charge, to any person obtaining | |
120 | \ a copy of this software and associated documentation files (the | |
121 | \ "Software"), to deal in the Software without restriction, including | |
122 | \ without limitation the rights to use, copy, modify, merge, publish, | |
123 | \ distribute, sublicense, and/or sell copies of the Software, and to | |
124 | \ permit persons to whom the Software is furnished to do so, subject to | |
125 | \ the following conditions: | |
126 | \ | |
127 | \ The above copyright notice and this permission notice shall be | |
128 | \ included in all copies or substantial portions of the Software. | |
129 | \ | |
130 | \ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
131 | \ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
132 | \ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
133 | \ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
134 | \ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
135 | \ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
136 | \ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
137 | \ | |
138 | \ LICENSE_END |