Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: vpci.tok | |
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: @(#)vpci.tok 1.5 07/08/06 | |
43 | purpose: | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | fcode-version3 | |
48 | ||
49 | headerless | |
50 | fload ${BP}/dev/sun4v-devices/utilities/md-parse.fth | |
51 | fload ${BP}/dev/sun4v-devices/vpci/hv-iface.fth | |
52 | fload ${BP}/dev/sun4v-devices/vpci/common.fth | |
53 | fload ${BP}/dev/sun4v-devices/iommu/iommu.fth | |
54 | fload ${BP}/dev/sun4v-devices/vpci/msi-props.fth | |
55 | fload ${BP}/dev/sun4v-devices/vpci/bus-ops.fth | |
56 | fload ${BP}/dev/pci/pcibus.fth | |
57 | fload ${BP}/dev/pci/map64.fth | |
58 | ||
59 | [ifdef] N2-ERRATUM-106 | |
60 | ||
61 | \ The code dealing with erratum 106 can be removed once we | |
62 | \ decommision support for N2 1.x parts | |
63 | [message] VPCI driver still supporting 1.x N2 parts | |
64 | ||
65 | 0 value n2-erratum-106? | |
66 | ||
67 | create get-hver | |
68 | \ First setup the RDHPR opcode to read the HVER reg (see | |
69 | \ UltraSPARC Architecture 2006 document) | |
70 | \ '8' is %o0 | |
71 | \ '6' is for HVER | |
72 | b# 10 d# 30 << 8 d# 25 << or b# 10.1001 d# 19 << or 6 d# 14 << or l, | |
73 | \ Now we setup the DONE opcode as required by the diagnostic API | |
74 | b# 10 d# 30 << b# 11.1110 d# 19 << or l, | |
75 | ||
76 | : check-n2-erratum-106 ( -- ) | |
77 | \ First attempt to negotiate the diagnostic API. This will succeed if | |
78 | \ the SP NVRAM variable 'sc_ssqamode' is true, or if we are using a N2 1.x part. | |
79 | \ 0x300 negotiates the diagnostic API | |
80 | \ 1 is the major version | |
81 | \ 0 is the minor version | |
82 | \ 3 is the number of input args | |
83 | \ 0 is the number of output args (we don't care about them) | |
84 | \ 0 is the API_SET_VERSION function number | |
85 | \ 0xff is the CORE_TRAP group | |
86 | h# 300 1 0 3 0 0 h# ff htrap ( ) | |
87 | ||
88 | get-hver >physical drop ( RA ) | |
89 | \ HV-ENOACCESS (0xa) will be returned if we can't use the diagnostic APIs, | |
90 | \ so check that the return status is zero before moving on. 0x200 translates | |
91 | \ the real address to a physical address | |
92 | 1 2 h# 200 h# 80 htrap 0= if ( PA | x ) | |
93 | \ 0x201 invokes the diagnostic API | |
94 | 1 1 h# 201 h# 80 htrap ( HVER ) | |
95 | d# 28 >> h# f and 1 = if ( ) | |
96 | true to n2-erratum-106? ( ) | |
97 | cmn-note[ ( ) | |
98 | " Downrev N2 part (v1.x) detected. Setting erratum 106 flag" | |
99 | ]cmn-end ( ) | |
100 | then ( ) | |
101 | else ( x ) | |
102 | drop ( ) | |
103 | then ( ) | |
104 | ; | |
105 | ||
106 | check-n2-erratum-106 | |
107 | ||
108 | [then] \ N2-ERRATUM-106 | |
109 | ||
110 | : enx+ ( xdr,len x -- xdr,len ) xlsplit swap >r en+ r> en+ ; | |
111 | ||
112 | 0 h# 8000.0000 lxjoin constant 4v-io-type | |
113 | ||
114 | : make-reg-prop ( -- ) | |
115 | 0 0 encode-bytes | |
116 | 0 my-space lxjoin enx+ 0 enx+ \ cfg-handle | |
117 | " reg" property | |
118 | ; | |
119 | ||
120 | : make-ranges ( I/O /io Mem32 /mem32 Mem64 /mem64-- ) | |
121 | >r >r ( I/O /io Mem32 /mem32) | |
122 | >r >r ( I/O /io ) | |
123 | >r >r ( -- ) | |
124 | 0 0 encode-bytes ( xdr,len ) | |
125 | ||
126 | h# 0100.0000 en+ 0 en+ | |
127 | ||
128 | [ifdef] N2-ERRATUM-106 | |
129 | n2-erratum-106? if h# 1000.0000 else 0 then | |
130 | [else] | |
131 | 0 | |
132 | [then] | |
133 | ||
134 | en+ \ PCI I/O | |
135 | r> 4v-io-type or enx+ r> enx+ \ Offset, len | |
136 | ||
137 | h# 0200.0000 en+ 0 en+ 0 en+ \ PCI Mem 32 | |
138 | r> 4v-io-type or enx+ r> enx+ \ Offset, len | |
139 | ||
140 | h# 0300.0000 en+ 0 en+ 0 en+ \ PCI Mem 64 | |
141 | r> 4v-io-type or enx+ r> enx+ \ Offset, len | |
142 | ||
143 | " ranges" property ( -- ) | |
144 | ; | |
145 | ||
146 | fload ${BP}/dev/sun4v-devices/vpci/methods.fth | |
147 | ||
148 | pci-iobase pci-iosize \ IO spaces | |
149 | pci-mem32base pci-mem32size \ memory spaces | |
150 | pci-mem64base pci-mem64size | |
151 | make-ranges | |
152 | ||
153 | make-reg-prop | |
154 | ||
155 | fload ${BP}/pkg/asr/pci-prober-support.fth | |
156 | ||
157 | 1meg pci-mem32size over - my-memlist free-memrange | |
158 | 1 d# 32 << pci-mem64size my-mem64list free-memrange | |
159 | ||
160 | [ifdef] N2-ERRATUM-106 | |
161 | n2-erratum-106? if | |
162 | h# 1000.0000 pci-iosize | |
163 | else | |
164 | 0 pci-iosize | |
165 | then | |
166 | [else] | |
167 | 0 pci-iosize | |
168 | [then] | |
169 | ||
170 | my-io-list free-memrange | |
171 | ||
172 | end0 |