Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / os / sun / symcif.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: symcif.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: @(#)symcif.fth 1.2 95/09/11
43purpose: sym-to-name and name-to-sym callbacks into client program.
44copyright: Copyright 1995 Sun Microsystems, Inc. All Rights Reserved
45
46headerless
470 value sym-to-value
480 value value-to-sym
49
500 value prev-s2v
510 value prev-v2s
52
53: sym-to-value-str ( -- adr,len ) " sym-to-value" drop ;
54: value-to-sym-str ( -- adr,len ) " value-to-sym" drop ;
55
56h# 80 constant /symname-buf
57/symname-buf buffer: symname-buf
586 /n* buffer: cif-symbol-array
59
60: do-sym-to-value ( adr,len -- n true | adr,len false )
61 sym-to-value if
62 2dup 2>r
63 sym-to-value-str cif-symbol-array 0 na+ !
64 1 cif-symbol-array 1 na+ !
65 2 cif-symbol-array 2 na+ !
66 symname-buf /symname-buf erase
67 symname-buf swap /symname-buf min cmove
68 symname-buf cif-symbol-array 3 na+ !
69 -1 cif-symbol-array 4 na+ !
70 0 cif-symbol-array 5 na+ !
71 cif-symbol-array sym-to-value call 2drop
72 2r>
73 cif-symbol-array 4 na+ @ if false exit then
74 2drop cif-symbol-array 5 na+ @ true exit
75 then false
76;
77
78: do-value-to-sym ( n -- offset adr,len true | n false )
79 value-to-sym if
80 dup >r
81 value-to-sym-str cif-symbol-array 0 na+ !
82 1 cif-symbol-array 1 na+ !
83 2 cif-symbol-array 2 na+ !
84 ( n ) cif-symbol-array 3 na+ !
85 -1 cif-symbol-array 4 na+ !
86 0 cif-symbol-array 5 na+ !
87 cif-symbol-array value-to-sym call 2drop
88 r>
89 cif-symbol-array 4 na+ @ l->n -1 = if false exit then
90 drop
91 cif-symbol-array 4 na+ @
92 cif-symbol-array 5 na+ @ cscount true exit
93 then false
94;
95
96headers
97: symbol-lookup-off ( -- )
98 sym-to-value ?dup if to prev-s2v then
99 value-to-sym ?dup if to prev-v2s then
100 0 to sym-to-value 0 to value-to-sym
101;
102: symbol-lookup-on ( -- )
103 prev-s2v ?dup if to sym-to-value then
104 prev-v2s ?dup if to value-to-sym then
105;
106
107headerless
108create err-sym-not-found ," symbol not found "
109headers
110defer sym>value ( adr,len -- adr,len false | n true )
111: sym ( "name " -- n )
112 parse-word sym>value 0= if
113 err-sym-not-found throw
114 then
115;
116
117' do-sym-to-value is sym>value
118
119headers
120also client-services definitions
121: set-symbol-lookup ( value-to-sym sym-to-value -- old-v2s old-s2v )
122 value-to-sym sym-to-value 2swap ( old-v2s old-s2v v2s s2v )
123 is sym-to-value is value-to-sym ( old-v2s old-s2v )
124 0 to prev-s2v 0 to prev-v2s ( old-v2s old-s2v )
125;
126previous definitions