Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: applcode.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: @(#)applcode.fth 2.31 03/12/08 13:22:46 | |
43 | purpose: Miscellaneous FCode functions | |
44 | copyright: Copyright 1990-2003 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headerless | |
48 | : 4-byte-id ( -- ) ; \ version 1 token | |
49 | ||
50 | headers | |
51 | \ FCode version | |
52 | h# 3.0000 constant fcode-revision ( -- n ) | |
53 | alias fcode-version fcode-revision ( -- n ) | |
54 | alias version fcode-revision ( -- n ) | |
55 | ||
56 | major-release# d# 16 << minor-release# + constant firmware-version | |
57 | ||
58 | \ 5 constant processor-type | |
59 | ||
60 | alias v1 noop \ Include version 1 FCode support | |
61 | alias v2 noop \ Include version 2.0 FCode support | |
62 | alias v2.1 noop \ Include version 2.1 FCode support | |
63 | alias v2.2 noop \ Include version 2.2 FCode support | |
64 | alias v2.3 noop \ Include version 2.3 FCode support | |
65 | alias v3 noop \ Include version 3 FCode support | |
66 | ||
67 | : (is-user-word) ( adr len acf -- ) | |
68 | also forth definitions | |
69 | -rot $create -1 setalias | |
70 | previous definitions | |
71 | ; | |
72 | ||
73 | -1 constant -1 | |
74 | ||
75 | : suspend-fcode ( -- ) ; | |
76 | ||
77 | : map-low ( offset size -- virtual ) my-space swap " map-in" $call-parent ; | |
78 | ||
79 | : encode-intr ( int-level vector -- ) | |
80 | >r sbus-intr>cpu encode-int r> encode-int encode+ | |
81 | ; | |
82 | ||
83 | also magic-properties definitions | |
84 | : intr ( value-str name-str -- value-str name-str ) | |
85 | \ Create an "interrupts" property unless one already exists | |
86 | " interrupts" get-my-property if ( value$ name$ ) | |
87 | 2over 0 0 encode-bytes 2swap bounds ?do ( value$ name$ prop$ ) | |
88 | i /l get-encoded-int encode-int encode+ ( value$ name$ prop$' ) | |
89 | 2 /l* +loop " interrupts" property | |
90 | else ( value$ name$ prop-adr,len ) | |
91 | 2drop ( value$ name$ ) | |
92 | then ( value$ name$ ) | |
93 | ; | |
94 | previous definitions | |
95 | ||
96 | alias name device-name | |
97 | : model ( adr len -- ) " model" string-property ; | |
98 | : reg ( adr space size -- ) encode-reg " reg" property ; | |
99 | : intr ( int-level vector -- ) encode-intr " intr" property ; | |
100 | ||
101 | [ifnexist] wbflips | |
102 | : wbflip ( n1 -- n2 ) wbsplit swap bwjoin ; | |
103 | : wbflips ( adr len -- ) | |
104 | bounds ?do | |
105 | i unaligned-w@ wbflip i unaligned-w! | |
106 | /w +loop | |
107 | ; | |
108 | ||
109 | : lwflip ( n1 -- n2 ) lwsplit swap wljoin ; | |
110 | : lwflips ( adr len -- ) | |
111 | bounds ?do | |
112 | i unaligned-l@ lwflip i unaligned-l! | |
113 | /l +loop | |
114 | ; | |
115 | ||
116 | : lbflip ( n1 -- n2 ) lbsplit swap 2swap swap bljoin ; | |
117 | : lbflips ( adr len -- ) | |
118 | bounds ?do | |
119 | i unaligned-l@ lbflip i unaligned-l! | |
120 | /l +loop | |
121 | ; | |
122 | ||
123 | : xbflip ( x -- x' ) xlsplit lbflip swap lbflip lxjoin ; | |
124 | : xlflip ( x -- x' ) xlsplit swap lxjoin ; | |
125 | : xwflip ( x -- x' ) xlsplit lwflip swap lwflip lxjoin ; | |
126 | ||
127 | : xbflips ( adr,len -- ) | |
128 | bounds ?do | |
129 | i unaligned-@ xbflip i unaligned-! | |
130 | /x +loop | |
131 | ; | |
132 | : xlflips ( adr,len -- ) | |
133 | bounds ?do | |
134 | i unaligned-@ xlflip i unaligned-! | |
135 | /x +loop | |
136 | ; | |
137 | : xwflips ( adr,len -- ) | |
138 | bounds ?do | |
139 | i unaligned-@ xwflip i unaligned-! | |
140 | /x +loop | |
141 | ; | |
142 | ||
143 | [then] | |
144 | \ alias wflips wbflips | |
145 | \ alias lflips lwflips |