Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb-devices / interface / endpoints.fth
CommitLineData
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 ============================================
42id: @(#)endpoints.fth 1.4 03/05/12
43purpose:
44copyright: Copyright 1999-2000, 2003 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47\ Get endpoint descriptors for this interface. 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-inherited-property drop
77 decode-int nip nip
78;
79
80\ uses string1 for a string buffer
81
82: publish-endpoints ( -- went-ok? )
83 string1 h# 1000 erase
84 0max-packet
85 h# 30 string1 c! \ always report endpoint 0
86 string1 1 \ string so far
87 ,append
88 #append
89 my-speed my-usb-adr my-space get-int#-descriptor
90 ( string1 len int-desc icnt hw-err? | stat 0 )
91 ?dup if
92 drop
93 dma-free
94 2drop
95 " disabled" encode-string " status" property \ XXX not really; can't disable
96 \ an interface by itself
97 false exit
98 else stall-or-nak? if
99 dma-free
100 2drop
101 " disabled" encode-string " status" property \ XXX still not really
102 false exit
103 then
104 then
105 >r dup >r -rot
106 r@ i-descript-#endpoints c@ ( int-desc $addr cnt #enpts ) ( R: icnt int-desc )
107 0 ?do ( int-desc $addr cnt ) ( R: icnt int-desc )
108 ,append
109 2 pick i read-ith-endpoint#
110 >r -rot #append ,append \ endpoint
111 r> -rot #append \ max-packet
112 loop ( int-desc string1 cnt ) ( R: icnt int-desc )
113 r> r> dma-free \ dump all the memory used.
114 encode-string " endpoints" property
115 drop
116 true
117;