Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: unit.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: @(#)unit.fth 1.2 97/10/14 | |
43 | purpose: PCI bus package | |
44 | copyright: Copyright 1994 FirmWorks All Rights Reserved | |
45 | copyright: Copyright 1997 Sun Microsystems Inc All Rights Reserved | |
46 | ||
47 | \ The encode/decode unit methods | |
48 | ||
49 | headerless | |
50 | h# 40 buffer: unit-string | |
51 | ||
52 | : ?p ( adr len phys -- adr' len' phys' ) | |
53 | over 1 >= if ( adr len phys ) | |
54 | 2 pick c@ upc ascii P = if ( adr len phys ) | |
55 | h# 4000.0000 + >r 1 /string r> ( adr' len' phys' ) | |
56 | then | |
57 | then | |
58 | ; | |
59 | : ?t ( adr len phys -- adr' len' phys' ) | |
60 | over 1 >= if ( adr len phys ) | |
61 | 2 pick c@ upc ascii T = if ( adr len phys ) | |
62 | h# 2000.0000 + >r 1 /string r> ( adr' len' phys' ) | |
63 | then | |
64 | then | |
65 | ; | |
66 | ||
67 | : pci-decode-unit ( adr len -- phys.lo phys.mid phys.hi ) | |
68 | dup 0= if 2drop 0 0 0 exit then ( adr len ) | |
69 | 0 >r | |
70 | over c@ upc ascii N = if r> h# 8000.0000 + >r 1 /string then ( adr len ) | |
71 | over c@ upc case | |
72 | ascii I of r> h# 0100.0000 + >r 1 /string r> ?t >r endof | |
73 | ascii M of r> h# 0200.0000 + >r 1 /string r> ?t ?p >r endof | |
74 | ascii X of r> h# 0300.0000 + >r 1 /string r> ?p >r endof | |
75 | ( default ) | |
76 | endcase | |
77 | ||
78 | \ XX do range checks | |
79 | ||
80 | ascii , left-parse-string ( rem$ DD$ ) | |
81 | $hnumber if 0 then h# 1f and d# 11 lshift r> + >r ( rem$ ) | |
82 | dup 0= if 2drop 0 0 r> exit then ( rem$ ) | |
83 | ||
84 | ascii , left-parse-string ( rem$ F$ ) | |
85 | $hnumber if 0 then h# f and d# 8 lshift r> + >r ( rem$ ) | |
86 | dup 0= if 2drop 0 0 r> exit then ( rem$ ) | |
87 | ||
88 | ascii , left-parse-string ( rem$ RR$ ) | |
89 | $hnumber if 0 then h# ff and r> + >r ( rem$ ) | |
90 | dup 0= if 2drop 0 0 r> exit then ( rem$ ) | |
91 | ||
92 | \ Parse the remaining digits as a number, forcing the result to | |
93 | \ be a double number by pushing zeroes as needed | |
94 | $hdnumber? ( 0 | n 1 | d 2 ) 2 swap ?do 0 loop r> | |
95 | ; | |
96 | headerless | |
97 | ||
98 | : convert-device ( phys.hi -- phys.hi ) | |
99 | dup d# 11 >> h# 1f and u#s drop | |
100 | ; | |
101 | : convert-function ( phys.hi -- phys.hi ) | |
102 | dup 8 >> 7 and u# ascii , hold drop | |
103 | ; | |
104 | : convert-high ( phys.hi -- phys.hi ) | |
105 | dup h# 700 and if convert-function then | |
106 | convert-device | |
107 | ; | |
108 | : convert-rr ( phys.hi -- phys.hi ) | |
109 | ascii , hold | |
110 | dup h# ff and u# u#s drop ( phys.hi ) \ RR field | |
111 | ascii , hold | |
112 | convert-function convert-device | |
113 | ; | |
114 | : ?tpn ( phys.hi char -- 0 ) | |
115 | over h# 2000.0000 and if ascii t hold then | |
116 | over h# 4000.0000 and if ascii p hold then | |
117 | hold | |
118 | h# 8000.0000 and if ascii n hold then | |
119 | ; | |
120 | ||
121 | : pci-encode-unit ( phys.lo phys.mid phys.hi -- adr len ) | |
122 | push-hex | |
123 | <# | |
124 | dup d# 24 >> 3 and case ( phys.low phys.mid phys.hi ) | |
125 | 0 of nip nip convert-high drop endof \ Configuration space | |
126 | 1 of \ I/O space | |
127 | nip swap ( phys.hi phys.low ) | |
128 | u# u#s drop ( phys.hi ) | |
129 | convert-rr ( phys.hi ) | |
130 | ascii i ?tpn ( ) | |
131 | endof | |
132 | 2 of \ Memory-32 space | |
133 | nip swap ( phys.hi phys.low ) | |
134 | u# u#s drop ( phys.hi ) | |
135 | convert-rr ( phys.hi ) | |
136 | ascii m ?tpn ( ) | |
137 | endof | |
138 | 3 of \ Memory-64 space | |
139 | -rot ( phys.hi phys.low phys.mid ) | |
140 | # #s 2drop ( phys.hi ) | |
141 | convert-rr ( phys.hi ) | |
142 | ascii x ?tpn ( ) | |
143 | endof | |
144 | endcase | |
145 | 0 u#> unit-string $save | |
146 | pop-base | |
147 | ; |