Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / pkg / fcode / chkfcod.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: chkfcod.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: @(#)chkfcod.fth 1.6 06/02/16 19:20:03
43purpose:
44copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47\ Verify token addresses match FCodes
48
49\ This is a post process step after we dispose all transient defs
50\ so we need to reload the brackif support and the restored headers.
51\
52fload ${BP}/fm/lib/headless.fth
53fload ${BP}/fm/lib/brackif.fth
54[defined] kernel-hdr-file included
55
56variable exp-fcode
570 exp-fcode !
58
59
60headerless
61\ If a word is not immediate, get-token returns 0 and $find returns -1
62\ otherwise, get-token returns some non-zero and $find returns a 1.
63
64: immediate-mismatch? ( get-tok-imm $find-imm -- mismatch? )
65 1 = swap ( $find-imm=imm? get-tok-imm )
66 0<> ( $find-imm=imm? get-tok-imm=imm? )
67 xor
68;
69
70: .not-match-ferror ( $adr,len -- )
71 ." FCode " exp-fcode @ .x ." does not match ferror's " type cr
72 (compile-time-warning)
73;
74
75\ Verify all unimplemented fcodes point to ferror
76: check-ferror ( -- )
77 exp-fcode @ get-token swap ['] ferror <> if ( immediate? )
78 " address" .not-match-ferror
79 then
80 ['] ferror immediate? <> if
81 " immediate field" .not-match-ferror
82 then
83;
84
85: byte-code: \ name ( code# table# -- )
86
87 bwjoin ( fcode )
88
89 \ Any fcodes skipped between byte-code: calls means it is an unimplemented fcode
90 begin dup exp-fcode @ > while ( fcode )
91 check-ferror
92 1 exp-fcode +!
93 repeat
94
95 \ get address and immediate field for current fcode and the token and verify
96 \ token exists
97 dup get-token swap ( fcode immediate? xt )
98
99 safe-parse-word $find ?dup 0= if ( fcode immediate? xt adr len )
100 ." token " type 2drop ( fcode )
101 ." at FCode " dup .x ." does not exist" cr
102 (compile-time-warning)
103 else ( fcode immediate? xt acf n )
104 \ addresses should match
105 -rot 2swap 2>r 2>r 2r@ <> if ( fcode ) ( r: immediate? n xt acf )
106 r@ ['] obsolete-fcode <> if
107 ." FCode " dup .x 2r@ swap .name ." isn't the same as " .name cr
108 (compile-time-warning)
109 then
110 then ( fcode ) ( r: immediate? n )
111 2r> 2r> immediate-mismatch? if ( fcode xt acf )
112 rot ." FCode " .x ( xt acf )
113 ." has immediate-field mismatch with token " .name cr ( xt )
114 (compile-time-warning) ( xt )
115 else ( fcode xt acf )
116 2drop ( fcode )
117 then ( fcode )
118 then drop ( )
119
120 \ make sure exp-fcode points to next expected fcode
121 1 exp-fcode +!
122;
123
124." Checking FCodes ...." cr
125
126fload ${BP}/pkg/fcode/primlist.fth \ Primitive (1-byte) fcodes
127fload ${BP}/pkg/fcode/sysprims.fth \ Basic system fcodes
12864\ fload ${BP}/pkg/fcode/sysprm64.fth \ 64-bit fcodes
129
130[ifdef] OBDIAG-SUPPORT
131fload ${BP}/pkg/fcode/vfcodes/obdiag.fth \ obdiag vfcodes
132[then]
133
134[ifdef] SUN4V
135fload ${BP}/pkg/fcode/vfcodes/sun4v.fth \ sun4v vfcodes
136[then]
137
138fload ${BP}/pkg/fcode/vfcodes/cmn-msg.fth \ cmn messaging vfcodes
139
140headers
141