Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb / required.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: required.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: @(#)required.fth 1.22 06/02/01
43purpose:
44copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47create bad-number \ "Bad number syntax"
48 d# 17 c,
49 ascii B c, ascii a c, ascii d c, bl c, ascii n c,
50 ascii u c, ascii m c, ascii b c, ascii e c, ascii r c,
51 bl c, ascii s c, ascii y c, ascii n c, ascii t c,
52 ascii a c, ascii x c, 0 c,
53
54: $>number ( adr len -- n ) $number if bad-number throw then ;
55
560 value saved-self \ used by fcode-finder -- probe-time only; global ok
57
580 value open-count \ must be global
59
6010 buffer: unit-address \ must be global; used when no instance active.
61
62defer bless-done-q \ switching between polled and 10ms tick
63
64external
65
66: decode-unit ( adr len -- port )
67 base @ >r hex
68 dup if $>number else 2drop 0 then
69 r> base !
70;
71
72: encode-unit ( port -- adr len )
73 unit-address 10 erase
74 base @ >r hex
75 <# u#s u#>
76 dup >r
77 unit-address swap move
78 unit-address r>
79 r> base !
80;
81
82\ XXX control list left enabled by probe.
83\ XXX keyboard signals resume -- port status word.
84: open ( -- ok? )
85 open-count 0= if \ do stuff that happens only on first open
86 get-mem new-mem-table
87 map-regs
88 make-structs set-regs if
89 dump-structs unmap-regs
90 false exit
91 then
92 usb-resume
93 usb-operational
94 ['] quit-take-done-q to bless-done-q \ XXX who cares about it when closing?
95 ['] alarm-take-done-q 1 alarm
96 then
97 open-count 1+ to open-count
98\ my-self to saved-self \ instance for published method if needed.
99\ d# 64 to max-packet \ default -- read dev descriptor for good value
100 true
101;
102
103\ XXX on last close, close should check over the q's to find out if there
104\ are any endpoints and transfers left hanging. There shouldn't be any.
105\ close should toss them with a warning in diag-mode.
106: close ( -- )
107 open-count 1- to open-count
108 open-count 0= if \ do stuff that happens only on last close
109 ['] alarm-take-done-q 0 alarm
110\ toss transfer-d's and endpoint-d's (except dummies). Should only need to
111\ look through index.
112 toss-controller give-mem
113 then
114;
115
116: reset ( -- ) ;
117
118headers