Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb-devices / interface / node.fth
CommitLineData
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 ============================================
42id: @(#)node.fth 1.12 00/05/09
43purpose:
44copyright: Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved
45
46: find-fcode ( adr1 len1 -- adr2 len2 true | false )
47 " sunw,find-fcode" get-inherited-property drop
48 decode-int nip nip
49 execute
50;
51
52: find-hub-fcode ( -- addr len ) " hub" find-fcode drop ;
53
54: find-kbd-fcode ( -- addr len ) " kbd" find-fcode drop ;
55
56: disabled-prop ( -- ) " disabled" encode-string " status" property ;
57
58: create-reg ( -- )
59 my-address my-space
60 encode-int rot encode-int encode+
61 " reg" property
62;
63
64: my-name? ( adr len -- my-name? )
65 " name" get-my-property drop
66 decode-string 2swap 2drop
67 rot over = if
68 comp 0=
69 else 2drop drop false
70 then
71;
72
73: hub? ( -- hub? ) " hub" my-name? ;
74
75: kbd? ( -- kbd? ) " keyboard" my-name? ;
76
77: mouse? ( -- mouse? ) " mouse" my-name? ;
78
79: bogus-properties ( -- )
80 kbd? if 0 0 " keyboard" property then
81 mouse? if 0 0 " mouse" property then
82;
83
84\ XXX don't activate this until hub code works for interface hubs:
85: make-hub ( -- )
86\ find-hub-fcode
87\ over 1 byte-load
88\ dma-free
89;
90
91: make-kbd ( -- )
92 find-kbd-fcode
93 over 1 byte-load
94 dma-free
95;
96
97: make-node ( -- )
98 create-reg
99 " interface get-ints" diag-crtype \ XXX debug
100 " 0max-packet" get-inherited-property \ must be present
101 drop decode-int to 0max-packet
102 2drop
103 my-speed my-usb-adr my-space
104 get-int#-descriptor
105 ?dup if \ hw-err found; already printed
106 drop
107 dma-free
108 interface-name
109 disabled-prop \ XXX not really; interface can't
110 \ be disabled by itself
111 exit
112 else stall-or-nak? if
113 dma-free
114 interface-name
115 disabled-prop \ XXX not really; interface can't
116 \ be disabled by itself
117 exit
118 then
119 then
120 2dup >r >r drop
121 dup create-interface-name
122 " interface get-config1" diag-crtype \ XXX debug
123 my-speed my-usb-adr get-config1-descrip
124 ( iadr cadr ccnt hw-err | stat 0 )
125 ( R: icnt iadr )
126 ?dup if \ hw-err found; already printed
127 drop
128 r> r> dma-free dma-free
129 drop
130 disabled-prop \ XXX not really; interface can't
131 \ be disabled by itself
132 exit
133 else stall-or-nak? if
134 r> r> dma-free dma-free
135 drop
136 disabled-prop \ XXX not really; interface can't
137 \ be disabled by itself
138 exit
139 then
140 then
141 2dup >r >r drop ( iadr cadr ) ( R: icnt iadr ccnt cadr )
142 " interface get-dev" diag-crtype \ XXX debug
143 my-speed my-usb-adr get-dev-descrip
144 ( iadr cadr dadr dcnt hw-err? | stat 0 )
145 ( R: icnt iadr ccnt cadr )
146 ?dup if
147 drop
148 r> r> r> r> dma-free dma-free dma-free
149 2drop
150 disabled-prop \ XXX not really; interface can't
151 \ be disabled by itself
152 exit
153 else stall-or-nak? if
154 r> r> r> r> dma-free dma-free dma-free
155 2drop
156 disabled-prop \ XXX not really; interface can't
157 \ be disabled by itself
158 exit
159 then
160 then
161 2dup >r >r drop
162 create-interface-compat
163 r> r> r> r> r> r>
164 dma-free dma-free dma-free
165 " interface endpoints" diag-crtype \ XXX debug
166 publish-endpoints if
167 hub? if make-hub
168 else kbd? if make-kbd
169 then
170 then
171 bogus-properties \ For bad coupling to main OBP and OS
172 then
173 " interface made" diag-crtype \ XXX debug
174;
175
176make-node