Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: vebus.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: @(#)vebus.tok 1.4 07/06/22 | |
43 | purpose: Sun4v ebus node | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | Fcode-version3 | |
48 | ||
49 | h# 10 buffer: unit$ | |
50 | h# 20 buffer: device$ | |
51 | ||
52 | : en+ ( xdr,len int -- xdr,len ) encode-int encode+ ; | |
53 | ||
54 | : enx+ ( xdr,len x -- xdr,len ) xlsplit swap >r en+ r> en+ ; | |
55 | ||
56 | external | |
57 | ||
58 | my-args decode-int nip nip constant my-node | |
59 | ||
60 | : open ( -- true ) true ; | |
61 | ||
62 | : close ( -- ) ; | |
63 | ||
64 | : encode-unit ( pa.lo pa.hi -- adr,len ) | |
65 | swap <# u#s drop ascii , hold u#s u#> unit$ pack count | |
66 | ; | |
67 | ||
68 | : decode-unit ( adr len -- pa.lo pa.hi ) parse-2int ; | |
69 | ||
70 | headerless | |
71 | ||
72 | : required-prop ( name$ -- val ) | |
73 | 2dup my-node -rot ascii v md-find-prop ?dup if | |
74 | md-decode-prop drop nip nip | |
75 | else | |
76 | [ifndef] RELEASE | |
77 | cmn-fatal[ " Missing MD property: %s " ]cmn-end | |
78 | [else] | |
79 | 2drop | |
80 | [then] | |
81 | then | |
82 | ; | |
83 | ||
84 | ||
85 | " ebus" name | |
86 | " SUNW,sun4v-ebus" encode-string " compatible" property | |
87 | 2 encode-int " #address-cells" property | |
88 | 1 encode-int " #size-cells" property | |
89 | ||
90 | " membase" required-prop constant mem-base | |
91 | " memsize" required-prop constant mem-size | |
92 | ||
93 | 0 0 encode-bytes 0 en+ 0 en+ mem-base enx+ mem-size en+ " ranges" property | |
94 | ||
95 | 0 0 encode-bytes 0 my-space lxjoin enx+ 0 enx+ " reg" property | |
96 | ||
97 | external | |
98 | ||
99 | : map-in ( pa.lo pa.hi size -- va ) | |
100 | >r lxjoin mem-base + xlsplit r> " map-in" $call-parent | |
101 | ; | |
102 | ||
103 | : map-out ( virtual size -- ) " map-out" $call-parent ; | |
104 | ||
105 | headerless | |
106 | ||
107 | fload ${BP}/dev/utilities/swapped-access.fth | |
108 | fload ${BP}/dev/utilities/probe.fth | |
109 | fload ${BP}/dev/ebus/ebus.fth | |
110 | fload ${BP}/dev/sun4v-devices/utilities/md-parse.fth | |
111 | ||
112 | : build-ebus | |
113 | setup-swapped-fcodes | |
114 | build-probed-nodes | |
115 | restore-fcodes | |
116 | ; | |
117 | ||
118 | \ For each child, add an entry into the probe table. | |
119 | : add-child ( node -- ) | |
120 | >r ( )( R: node ) | |
121 | r@ " parent-device-path" md-get-required-prop drop ( $parent ) | |
122 | find-package if is my-interrupt-parent then ( ) | |
123 | r@ " child-unit-address" md-get-required-prop 2drop ( addr ) | |
124 | dup x@ swap /x + x@ ( my-space my-addr ) | |
125 | true ( my-space my-addr probe? ) | |
126 | r@ " child-interrupt" md-get-required-prop drop ( my-space my-addr probe? intr ) | |
127 | r> " parent-interrupt" md-get-required-prop drop ( my-space my-addr probe? intr ino ) | |
128 | " " probe-table! ( ) | |
129 | ; | |
130 | ||
131 | \ Build the ebus probe table by scanning the fwd links from the ebus node | |
132 | \ in the MD. | |
133 | : build-ebus-probe-table ( -- ) | |
134 | 0 begin ( node ) | |
135 | " wart" md-find-node ?dup ( node node| ) | |
136 | while ( node| ) | |
137 | dup " device-type" ascii s md-find-prop ?dup if ( node prop| ) | |
138 | md-decode-prop drop " vebus" $= if ( node ) | |
139 | ['] add-child over md-applyto-fwds ( node ) | |
140 | dup " #interrupt-cells" md-get-required-prop drop ( node x1 ) | |
141 | encode-int " #interrupt-cells" property ( node ) | |
142 | " interrupt-map-mask" md-get-required-prop drop ( data,len ) | |
143 | encode-md-prop-data ( prop,len ) | |
144 | " interrupt-map-mask" property ( ) | |
145 | exit ( ) | |
146 | then ( node ) | |
147 | then ( node ) | |
148 | repeat ( node ) | |
149 | ; | |
150 | ||
151 | build-ebus-probe-table | |
152 | build-ebus | |
153 | ||
154 | ||
155 | end0 |