Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: node.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: @(#)node.fth 1.13 02/12/11 | |
43 | purpose: | |
44 | copyright: Copyright 1998-2002 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | : find-fcode ( adr1 len1 -- adr2 len2 true | false ) | |
48 | " sunw,find-fcode" get-inherited-property drop | |
49 | decode-int nip nip | |
50 | execute | |
51 | ; | |
52 | ||
53 | : find-hub-fcode ( -- addr len ) " hub" find-fcode drop ; | |
54 | ||
55 | : find-kbd-fcode ( -- addr len ) " kbd" find-fcode drop ; | |
56 | ||
57 | : create-reg ( -- ) my-space encode-int " reg" property ; | |
58 | ||
59 | : my-0max-packet ( -- ) \ must be there | |
60 | " 0max-packet" get-my-property drop | |
61 | decode-int nip nip | |
62 | to 0max-packet | |
63 | ; | |
64 | ||
65 | \ XXX really bad code | |
66 | : finish-node ( -- went-ok? ) | |
67 | " combined finish" diag-crtype \ XXX debug | |
68 | create-reg | |
69 | my-0max-packet | |
70 | my-speed my-usb-adr | |
71 | get-dev-descrip ( dadr dcnt hw-err? | stat 0 ) | |
72 | ?dup if | |
73 | data-overrun-error <> if \ data-over benign here | |
74 | dma-free | |
75 | device-name | |
76 | disabled-prop \ XXX wrong, actually, since the | |
77 | \ hub has it still enabled. | |
78 | false exit | |
79 | then | |
80 | else stall-or-nak? if | |
81 | dma-free | |
82 | device-name | |
83 | disabled-prop \ XXX wrong, actually, since the | |
84 | \ hub has it still enabled. | |
85 | false exit | |
86 | then | |
87 | then | |
88 | over d-descript-maxpkt c@ | |
89 | to 0max-packet | |
90 | dma-free | |
91 | " combined d-desc" diag-crtype \ XXX debug | |
92 | my-speed my-usb-adr | |
93 | get-dev-descrip ( dadr dcnt hw-err? | stat 0 ) | |
94 | ?dup if \ hw-err found; already printed | |
95 | drop | |
96 | dma-free | |
97 | device-name | |
98 | disabled-prop \ XXX wrong, actually, since the | |
99 | \ hub has it still enabled. | |
100 | false exit | |
101 | else stall-or-nak? if | |
102 | dma-free | |
103 | device-name | |
104 | disabled-prop \ XXX wrong, actually, since the | |
105 | \ hub has it still enabled. | |
106 | false exit | |
107 | then | |
108 | then | |
109 | >r dup >r ( dadr ) ( R: dcnt dadr ) | |
110 | " combined int-desc" diag-crtype \ XXX debug | |
111 | my-speed my-usb-adr | |
112 | get-int-descrip ( dadr iadr icnt hw-err? | stat 0 ) ( R: dcnt dadr ) | |
113 | ?dup if | |
114 | drop | |
115 | r> r> dma-free dma-free | |
116 | drop | |
117 | device-name | |
118 | disabled-prop \ XXX wrong, actually, since the | |
119 | \ hub has it still enabled. | |
120 | false exit | |
121 | else stall-or-nak? if | |
122 | r> r> dma-free dma-free | |
123 | drop | |
124 | device-name | |
125 | disabled-prop \ XXX wrong, actually, since the | |
126 | \ hub has it still enabled. | |
127 | false exit | |
128 | then | |
129 | then ( dadr iadr icnt ) ( R: dcnt dadr ) | |
130 | >r dup >r ( dadr iadr ) ( R: dcnt dadr icnt iadr ) | |
131 | " combined name" diag-crtype \ XXX debug | |
132 | 2dup create-combined-name | |
133 | swap create-combined-compat | |
134 | r> r> dma-free | |
135 | r> r> dma-free | |
136 | " combined endpts" diag-crtype \ XXX debug | |
137 | publish-endpoints | |
138 | " combined published" diag-crtype \ XXX debug | |
139 | ; | |
140 | ||
141 | : my-name? ( adr len -- my-name? ) | |
142 | " name" get-my-property drop | |
143 | decode-string 2swap 2drop | |
144 | rot over = if | |
145 | comp 0= | |
146 | else 2drop drop false | |
147 | then | |
148 | ; | |
149 | ||
150 | : hub? ( -- hub? ) " hub" my-name? ; | |
151 | ||
152 | : kbd? ( -- kbd? ) " keyboard" my-name? ; | |
153 | ||
154 | : mouse? ( -- mouse? ) " mouse" my-name? ; | |
155 | ||
156 | : bogus-properties ( -- ) | |
157 | kbd? if 0 0 " keyboard" property then | |
158 | mouse? if 0 0 " mouse" property then | |
159 | ; | |
160 | ||
161 | : make-hub ( -- ) | |
162 | find-hub-fcode | |
163 | over 1 byte-load | |
164 | dma-free | |
165 | ; | |
166 | ||
167 | : make-kbd ( -- ) | |
168 | find-kbd-fcode | |
169 | over 1 byte-load | |
170 | dma-free | |
171 | ; | |
172 | ||
173 | : make-node ( -- ) | |
174 | finish-node if | |
175 | hub? if make-hub | |
176 | else kbd? if make-kbd | |
177 | then | |
178 | then | |
179 | bogus-properties \ For bad coupling to main OBP and OS | |
180 | then | |
181 | ; | |
182 | ||
183 | make-node | |
184 | ||
185 | \ Parent creates low-speed, assigned-address properties. | |
186 | \ This stuff creates name, compatible, reg, endpoints, and conditionally | |
187 | \ executes hub or kbd fcode. |