Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / os / stand / probe.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: probe.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\ @(#)probe.fth 2.10 04/10/06
43\ Copyright 1985-1994 Bradley Forthware
44\ Copyright 1994-2002,2004 Sun Microsystems, Inc. All Rights Reserved
45\ Copyright Use is subject to license terms.
46
47\ Test locations for accessability.
48\ X is c , w , or l for 8, 16, or 32-bit access.
49\
50\ Xprobe ( adr -- flag )
51\ Read location, return false if bus error, otherwise return true.
52\ Xpeek ( adr -- false | value true )
53\ Read location, return false if bus error, otherwise return data
54\ and true.
55\ Xpoke ( value adr -- flag )
56\ Write location, return false if bus error, otherwise return true.
57
58headers
59
60\ tos = operation
61\ 0 = c@
62\ 1 = w@
63\ 2 = l@
64\ 3 = x@
65\ 4 = c!
66\ 5 = w!
67\ 6 = l!
68\ 7 = x!
69
70code safe-touch
71 %g0 tos scr add \ get operation
72 scr 3 scr sllx \ shift left for offset
73 sp tos pop
74 never if \ never1
75 sc2 rdpc \ delay
76 scr h# 8 %g0 jmpl \ just before never2
77 tos 0 tos ldub \ c@
78 scr h# 8 %g0 jmpl \ just before never2
79 tos 0 tos lduh \ w@
80 scr h# 8 %g0 jmpl \ just before never2
81 tos 0 tos ld \ l@
82 scr h# 8 %g0 jmpl \ just before never2
83 tos 0 tos ldx \ x@
84 scr h# 10 %g0 jmpl \ just after never2
85 sc3 tos 0 stb \ c!
86 scr h# 10 %g0 jmpl \ just after never2
87 sc3 tos 0 sth \ w!
88 scr h# 10 %g0 jmpl \ just after never2
89 sc3 tos 0 st \ l!
90 scr h# 10 %g0 jmpl \ just after never2
91 sc3 tos 0 stx \ x!
92 then
93 sc2 h# 4 sc2 add \ after the rdpc
94 sc2 scr scr jmpl \ jump into never1
95 sp 0 sc3 ldx \ for the !s
96 never if \ never2
97 #sync membar \ (delay) sync on read too
98 sp 1 /n* tos ldx \ complete then get rid of
99 sp 2 /n* sp add \ the two stack items
100 then
101c;
102
103only forth also hidden also
104hidden definitions
105headerless
106: peeker ( adr acf -- value true | false)
107 guarded-execute dup 0= if nip nip then
108;
109: prober ( adr acf -- flag ) guarded-execute nip dup 0= if nip then ;
110: poker ( value adr acf -- flag ) \ Flag is true if success
111 guarded-execute dup 0= if nip nip nip then
112;
113
114
115headers
116forth definitions
117: cpeek ( adr -- false | value true ) 0 ['] safe-touch peeker ;
118: wpeek ( adr -- false | value true ) 1 ['] safe-touch peeker ;
119: lpeek ( adr -- false | value true ) 2 ['] safe-touch peeker ;
12064\ : xpeek ( adr -- false | value true ) 3 ['] safe-touch peeker ;
121
122\ : peek ( adr -- false | value true ) ['] @ peeker ;
123
124: cprobe ( adr -- present-flag ) 0 ['] safe-touch prober ;
125: wprobe ( adr -- present-flag ) 1 ['] safe-touch prober ;
126: lprobe ( adr -- present-flag ) 2 ['] safe-touch prober ;
12764\ : xprobe ( adr -- present-flag ) 3 ['] safe-touch prober ;
128
129\ : probe ( adr -- present-flag ) peek probe-fix ;
130
131: cpoke ( value adr -- flag ) 4 ['] safe-touch poker ;
132: wpoke ( value adr -- flag ) 5 ['] safe-touch poker ;
133: lpoke ( value adr -- flag ) 6 ['] safe-touch poker ;
13464\ : xpoke ( value adr -- flag ) 7 ['] safe-touch poker ;
135only forth also definitions