Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: endpoints.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: @(#)endpoints.fth 1.8 03/05/12 | |
43 | purpose: | |
44 | copyright: Copyright 1999-2000, 2003 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | \ Get endpoint descriptors for this combined device. Using the information, | |
48 | \ construct the value of the endpoints property and publish it. | |
49 | \ One particular use is for the usb keyboard stuff, so that it can work | |
50 | \ with an interface as well as a combined device. Similarly for the hub | |
51 | \ interfaces. | |
52 | ||
53 | \ endpoints property value is a string of pairs separated by a , character. | |
54 | \ Each pair is a hex endpoint number, followed by a , character, followed | |
55 | \ by the max-packet value for that endpoint. The whole property starts | |
56 | \ with endpoint 0. The whole property value is string-encoded. | |
57 | \ E.g., "0,8,1,40" shows endpoint 0 with max-packet 8, followed by | |
58 | \ endpoint 1 with max-packet h# 40. | |
59 | ||
60 | \ read ith endpoint descriptor | |
61 | \ extract the endpoint # and its max-packet | |
62 | : read-ith-endpoint# ( int-desc i -- endpoint# max-pkt ) | |
63 | find-ith-endpoint-start dup | |
64 | e-descript-endpoint-id c@ swap | |
65 | e-descript-max-pkt le-w@ | |
66 | ; | |
67 | ||
68 | : my-speed ( -- lo-speed? ) | |
69 | " low-speed" get-my-property if | |
70 | false | |
71 | else 2drop true | |
72 | then | |
73 | ; | |
74 | ||
75 | : my-usb-adr ( -- usb-address ) | |
76 | " assigned-address" get-my-property drop | |
77 | decode-int nip nip | |
78 | ; | |
79 | ||
80 | : disabled-prop ( -- ) " disabled" encode-string " status" property ; | |
81 | ||
82 | \ uses string1 for a string buffer | |
83 | ||
84 | \ also publishes interface# | |
85 | : publish-endpoints ( -- went-ok? ) | |
86 | string1 h# 1000 erase | |
87 | 0max-packet | |
88 | h# 30 string1 c! \ always report endpoint 0 | |
89 | string1 1 \ string so far | |
90 | ,append | |
91 | #append ( string1 len ) | |
92 | my-speed my-usb-adr | |
93 | \ XXX not for combined device: my-space | |
94 | \ only one interface for combined device | |
95 | get-int-descrip ( string1 len int-desc icnt hw-err? | stat 0 ) | |
96 | ?dup if \ hw-err? found | |
97 | drop | |
98 | dma-free | |
99 | 2drop | |
100 | disabled-prop \ XXX not really; hub still enables | |
101 | false exit | |
102 | else stall-or-nak? if | |
103 | dma-free | |
104 | 2drop | |
105 | disabled-prop \ XXX not really; hub still enables | |
106 | false exit | |
107 | then | |
108 | then | |
109 | " combined int-desc2" diag-crtype \ XXX debug | |
110 | >r dup >r -rot | |
111 | r@ i-descript-interface-id c@ \ publish interface# for myself | |
112 | encode-int " interface#" property | |
113 | r@ i-descript-#endpoints c@ ( int-desc $addr cnt #enpts ) ( R: icnt iadr ) | |
114 | 0 ?do ( int-desc $addr cnt ) ( R: icnt int-desc ) | |
115 | ,append | |
116 | 2 pick i read-ith-endpoint# | |
117 | >r -rot #append ,append \ endpoint | |
118 | r> -rot #append \ max-packet | |
119 | loop ( int-desc string1 cnt ) ( R: icnt int-desc ) | |
120 | r> r> dma-free \ dump all the memory used. | |
121 | encode-string " endpoints" property | |
122 | drop | |
123 | true | |
124 | ; |