\ ========== Copyright Header Begin ==========================================
\ Hypervisor Software File: debugm.fth
\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
\ - Do no alter or remove copyright notices
\ - Redistribution and use of this software in source and binary forms, with
\ or without modification, are permitted provided that the following
\ - Redistribution of source code must retain the above copyright notice,
\ this list of conditions and the following disclaimer.
\ - Redistribution in binary form must reproduce the above copyright notice,
\ this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
\ Neither the name of Sun Microsystems, Inc. or the names of contributors
\ may be used to endorse or promote products derived from this software
\ without specific prior written permission.
\ This software is provided "AS IS," without a warranty of any kind.
\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\ You acknowledge that this software is not designed, licensed or
\ intended for use in the design, construction, operation or maintenance of
\ ========== Copyright Header End ============================================
id: @(#)debugm.fth 1.14 07/06/05 10:54:49
copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
copyright: Use is subject to license terms.
\ Copyright 1990 Bradley Forthware
\ Machine-dependent support routines for Forth debugger.
: low-dictionary-adr ( -- adr ) origin ;
nuser debug-next \ Pointer to "next"
vocabulary bug bug also definitions
nuser 'debug \ code field for high level trace
nuser <ip \ lower limit of ip
nuser ip> \ upper limit of ip
nuser cnt \ how many times thru debug next
label _flush_cache ( -- )
label _disable_cache ( -- )
\ Change all the next routines in the indicated range to jump through
code slow-next ( high low -- )
\ \dtc _disable_cache call nop
\dtc \ Low address in tos
\dtc sp scr pop \ High address in scr
\dtc h# e006e000 sc2 set \ First word of "next":
\dtc h# 81c40002 sc3 set \ Second word of "next":
\dtc 64\ h# e058e000 sc4 set \ Template for first word of replacement "next"
\dtc 32\ h# e000e000 sc4 set \ Template for first word of replacement "next"
\dtc sc4 'user# debug-next sc4 add \ add user number (up nnn scr ld)
\dtc h# 81c42000 sc5 set \ Second word of replacement "next" (scr jmpl):
\dtc h# 80000000 sc7 set \ Third word of replacement "next" (nop):
\dtc tos scr cmp \ Loop over addresses from low to high
\dtc sc4 tos 0 st tos 0 iflush
\dtc sc5 tos 4 st tos 4 iflush
\dtc sc7 tos 8 st tos 8 iflush
\ \dtc _flush_cache call nop
\ Change all the next routines in the indicated range to perform the
code fast-next ( high low -- )
\ \dtc _disable_cache call nop
\dtc \ Low address in tos
\dtc sp scr pop \ High address in scr
\dtc h# e006e000 sc2 set \ First word of "next":
\dtc h# 81c40002 sc3 set \ Second word of "next":
\dtc 64\ h# e058e000 sc4 set \ Template for first word of replacement "next":
\dtc 32\ h# e000e000 sc4 set \ Template for first word of replacement "next":
\dtc sc4 'user# debug-next sc4 add \ add user number (up nnn scr ld)
\dtc h# 81c42000 sc5 set \ Second word of replacement "next" (scr jmpl):
\dtc h# b606e004 sc7 set \ Third word of "next":
\dtc tos scr cmp \ Loop over addresses from low to high
\dtc sc2 tos 0 st tos 0 iflush
\dtc sc3 tos 4 st tos 4 iflush
\dtc sc7 tos 8 st tos 8 iflush
\ \dtc _flush_cache call nop
\ This is slightly different from the normal next (the order of
\ the registers in the jmpl instruction is reversed) so that it
\ won't be clobbered by slow-next
normal-next origin - scr set \ Relative address
scr base scr add \ Absolute address
scr 'user debug-next nput
'user 'debug scr ld \ This is a token, not absolute
\ This is slightly different from the normal next (the order of
\ the registers in the jmpl instruction is reversed) so that it
\ won't be clobbered by slow-next
\ Fix the next routine to use the debug version
: pnext (s -- ) debnext debug-next ! ;
: unbug (s -- ) normal-next debug-next ! ;