Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / docs / vcpu / vcpu.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
<TITLE></TITLE>
<META NAME="GENERATOR" CONTENT="StarOffice 8 (Solaris Sparc)">
<META NAME="CREATED" CONTENT="20060130;15381900">
<META NAME="CHANGEDBY" CONTENT="Alex Tsirfa">
<META NAME="CHANGED" CONTENT="20070530;12161400">
<STYLE>
<!--
@page { size: 8.5in 11in; margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</STYLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<P STYLE="margin-bottom: 0in"><FONT SIZE=5><B>SPARC Architectural
Model : VCPU Interface</B> </FONT>
</P>
<P STYLE="margin-bottom: 0in"><FONT SIZE=4><B>Introduction</B></FONT></P>
<P STYLE="margin-bottom: 0in">Vcpu hides the details of the cpu
specific implementation.
</P>
<P STYLE="margin-bottom: 0in">It presents an abstract interface to
the &quot;virtual cpu&quot; - for cpu with multiple strands, it
represents each strand; for cpu without strands, it represent the
cpu.</P>
<P STYLE="margin-bottom: 0in">A few instances of cpu objects could be
created; each cpu object may have a few cpu cores, each core may have
a few strands.
</P>
<P STYLE="margin-bottom: 0in">CPU cores could run on separate threads
of the host machine.
</P>
<P STYLE="margin-bottom: 0in">The interface is defined in vcpu.h
file. It allows a hook up for an external source level debugger or
user interface frontend module. Cpu module is built as a shared
library. Vcpu interface has the following components, see <A HREF="#interface" TARGET="_top">Figure
1</A> below.
</P>
<P>- control interface<BR>- system interface (Memory and IO)<BR>-
trace interface</P>
<P STYLE="margin-bottom: 0in">Exported interface &ndash; routines in
the CPU module which is called from outside of the module. Pointers
to the routines exposed by the CPU module are defined in
VCPU_ExInterface structure.</P>
<P STYLE="margin-bottom: 0in">Imported interface &ndash; routines
which CPU module calls to get access to the rest of the system.
</P>
<P STYLE="margin-bottom: 0in">It is defined by VCPU_ImpIntf structure
- set of pointers that CPU module uses to send a request to the
system modules.</P>
<P STYLE="margin-bottom: 0in">Control interface constitute an
exported interface; system and trace interfaces constitute an
imported interface.
</P>
<P STYLE="margin-bottom: 0in">Memory is represented by an abstract
interface to allow it to model different levels of memory hierarchy,
including L2/L3 caches. Cache models are not included.
</P>
<P STYLE="margin-bottom: 0in">Currently, there are sparse memory
models and flat memory models. Due to performance consideration, the
memory model option is defined at build time instead of at run time.
</P>
<P STYLE="margin-bottom: 0in">Tracer is represented by an abstract
interface which allows hook up of different analyzers and performance
models. Vtracer interface is defined in vtracer.h header file.
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">The Cpu model
calls Vtracer methods to output complete information about the
architecture state change for every instruction. The information for
every instruction is accumulated in VCPU_Instruction structure. Trap
information is collected in VCPU_Trap structure, VCPU_TLB is for tlb
information.
</P>
<P STYLE="margin-bottom: 0in"><IMG SRC="vcpu_html_21db4c1f.gif" NAME="graphics1" ALIGN=LEFT WIDTH=645 HEIGHT=867 BORDER=0><BR CLEAR=LEFT><BR>
</P>
<P STYLE="margin-bottom: 0in"><A NAME="overview"></A><FONT SIZE=4><B>VCPU
Interface Overview.</B></FONT></P>
<P STYLE="margin-bottom: 0in"><B>Cpu module instantiation.</B>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<UL>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#ex_interface">get_ex_interface</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#create">create</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#destroy">destroy</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#reset">reset</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#save">save</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#restore">restore</A></P>
</UL>
<P STYLE="margin-bottom: 0in"><B>Control interface. </B>
</P>
<UL>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#vcpu id">id</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#stepi">step</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#stick" NAME="update stick">update
stick</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#interrupt">interrupt</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#ireg">access integer
register</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#freg">access floating
point register</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#preg">access privileged
register</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#asr">access ancillary
register</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#trapreg">access trap
specific register</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#hpreg">access hyper
privileged register</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#read mem">read_mem</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#write mem">write_mem</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#set break">set
breakpoint</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#delete break">delete
breakpoint</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#reconfig">reconfig</A></P>
</UL>
<P STYLE="margin-bottom: 0in"><B>Memory interface. </B>
</P>
<UL>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#mem">mem</A></P>
</UL>
<P STYLE="margin-bottom: 0in"><B>Physical IO interface.</B>
</P>
<UL>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#access io">access_io</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#access asi">access_asi</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#access serial">access_serial</A></P>
</UL>
<P STYLE="margin-bottom: 0in"><B>Tracer interface. </B>
</P>
<UL>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#instr">instr</A></P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#trap">trap</A></P>
</UL>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="ex_interface"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U>get_ex_interface</U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">get_ex_interface - Get exported
interface from the cpu module</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;
</P>
<P STYLE="margin-bottom: 0in">extern &quot;C&quot; int
get_ex_interface
</P>
<P STYLE="margin-bottom: 0in">(
</P>
<P STYLE="margin-bottom: 0in">VCPU_ExInterface *intf // pointer to
the interface structure</P>
<P STYLE="margin-bottom: 0in">);</P>
<P STYLE="margin-bottom: 0in">typedef int (*VCPU_GetIntfFn )(
VCPU_ExInterface *intf );
</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIBTION</B></P>
<P STYLE="margin-bottom: 0in">To get exported interface from the cpu
shared library get_ ex_interface () method should be used. It takes a
pointer to the VCPU_ExInterface structure and assigns the function
pointers inside this structure to the addresses of the corresponding
routines implemented in the CPU module.
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">0 - success;
</P>
<P STYLE="margin-bottom: 0in">1 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">// open shared library, lib_name is the
name of cpu shared libriry.
</P>
<P STYLE="margin-bottom: 0in">void *cpu_lib_handle = dlopen
(lib_name, RTLD_LAZY|RTLD_GLOBAL|RTLD_PARENT);</P>
<P STYLE="margin-bottom: 0in">// extract cpu lib exported interface
</P>
<P STYLE="margin-bottom: 0in">VCPU_GetIntfFn get_interface =
(VCPU_GetIntfFn)dlsym ( cpu_lib_handle, &quot;get_ex_interface&quot;
);</P>
<P STYLE="margin-bottom: 0in">// obtain exported cpu interface</P>
<P STYLE="margin-bottom: 0in">VCPU_ExInterface g_cpu_ex_intf;</P>
<P STYLE="margin-bottom: 0in">get_interface ( &amp;g_cpu_ex_intf);</P>
<P STYLE="margin-bottom: 0in">//Create a vcpu instance</P>
<P STYLE="margin-bottom: 0in">Vcpu * vcpu =
(Vcpu*)g_cpu_ex_intf.create( &amp;config_info, imp_intf );
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="create"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ExInterface::create</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">create - Create and configure a vcpu
instance.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">void * (*create ) // new cpu module</P>
<P STYLE="margin-bottom: 0in">(
</P>
<P STYLE="margin-bottom: 0in">VCPU_Config *cinfo, // cpu config
params
</P>
<P STYLE="margin-bottom: 0in">VCPU_ImpIntf *intf // interface to the
system
</P>
<P STYLE="margin-bottom: 0in">);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This function pointer is a member of
VCPU_ExInterface structure.
</P>
<P STYLE="margin-bottom: 0in">Pointer to the routine to create and
configure a vcpu instance.
</P>
<P STYLE="margin-bottom: 0in">The routine takes a pointer to the set
of vcpu parameters and a pointer to the imported interface structure.
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">return a pointer to the vcpu class.
</P>
<P STYLE="margin-bottom: 0in">NULL if fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">Create a vcpu instance. Cpu module
implementation may choose to create all core/strand objects at once
and this call may simply return a pointer to the next available vcpu
object.
</P>
<P STYLE="margin-bottom: 0in">This call should be made only once for
each vcpu</P>
<P STYLE="margin-bottom: 0in">A set of parameters describing vcpu
configuration options are defined in
</P>
<P STYLE="margin-bottom: 0in">VCPU_Config structure.
</P>
<P STYLE="margin-bottom: 0in">Vcpu * vcpu =
(Vcpu*)g_cpu_ex_intf.create( &amp;config_info, imp_intf );
</P>
<P STYLE="margin-bottom: 0in">After vcpu instance is created vcpu id
is assigned in sequential order &ndash; in the order create() calls
are made, starting from 0.</P>
<P STYLE="margin-bottom: 0in">From this point vcpu methods which are
defined by Vcpu abstract class could be used.
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="destroy"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ExInterface::destroy</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">destroy - Destroy all vcpu instances.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">int (*destroy ) ();</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This function pointer is a member of
VCPU_ExInterface structure.
</P>
<P STYLE="margin-bottom: 0in">Pointer to the routine to destroy all
vcpu instances.
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;</P>
<P STYLE="margin-bottom: 0in">0 - fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">int status = g_cpu_ex_intf.destroy();
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="reset"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ExInterface::reset</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">reset - Reset cpu module.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">int (*reset ) ();</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This function pointer is a member of
VCPU_ExInterface structure.
</P>
<P STYLE="margin-bottom: 0in">Pointer to the routine to reset
architecture visible CPU state.
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;</P>
<P STYLE="margin-bottom: 0in">0 - fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">int status = g_cpu_ex_intf.reset();
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="save"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ExInterface::save</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">save - Save complete simulation state
for the cpu module.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">int (*save ) (char *dir_name);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This function pointer is a member of
VCPU_ExInterface structure.
</P>
<P STYLE="margin-bottom: 0in">Pointer to the routine to save complete
simulation state for the CPU module.
</P>
<P STYLE="margin-bottom: 0in">The state is saved to the directory
dir_name.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;</P>
<P STYLE="margin-bottom: 0in">0 - fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">int status =
g_cpu_ex_intf.save(dir_name);
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="restore"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ExInterface::restore</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">restore - Restore complete simulation
state for the cpu module.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">int (*restore ) (char *dir_name);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This function pointer is a member of
VCPU_ExInterface structure.
</P>
<P STYLE="margin-bottom: 0in">Pointer to the routine to restore
complete simulation state for the CPU module.
</P>
<P STYLE="margin-bottom: 0in">The state is restored from the
directory dir_name.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;</P>
<P STYLE="margin-bottom: 0in">0 - fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">int status =
g_cpu_ex_intf.restore(dir_name);
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="vcpu id"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu:: id</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::id - Get vcpu id</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;
</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::id();</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual method of Vcpu class which is
used to get vcpu id. The id is used as an argument to other routines
to identify the vcpu instance.
</P>
<P STYLE="margin-bottom: 0in"> &quot;Unique&quot; platform dependent
id of a cpu. The id is the one that is to be used for cpu cross calls
and identifying cpu target for device interrupts. Typically function
Vcpu *get_vcpu(int id), defined in cpu_interface.h is used to get the
target Vcpu pointer given its id. The id's may or may not by
sequential, they are defined by cpu sysconf cpu parameter &quot;id&quot;.
If the parameter is not present on cpu config line, id's are assigned
in sequential order.
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">vcpu id value</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">Create a vcpu instance, this call
should be made only once for each vcpu</P>
<P STYLE="margin-bottom: 0in">Vcpu * vcpu =
(Vcpu*)g_cpu_ex_intf.create( &amp;config_info, imp_intf );
</P>
<P STYLE="margin-bottom: 0in">After vcpu instance is created the id
is assigned in sequential order &ndash; in the order create() calls
are made, starting from 0.</P>
<P STYLE="margin-bottom: 0in">From this point vcpu methods which are
defined by Vcpu abstract class could be used.
</P>
<P STYLE="margin-bottom: 0in">...</P>
<P STYLE="margin-bottom: 0in">printf(&ldquo;vcpu id is : %i \n&rdquo;)
vcpu-&gt;id();
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="stepi"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu::stepi</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::stepi - Step n number of
instructions
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::stepi ( int64_t n=1
);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual method of Vcpu class - step n
number of instructions.</P>
<P STYLE="margin-bottom: 0in">Each Vcpu can be called from a separate
working thread of the host machine. Vcpu's that belong to the same
core may need to be on the same working thread to reduce needs of
locking for MT safaty
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">....</P>
<P STYLE="margin-bottom: 0in">Step 100 number of instructions</P>
<P STYLE="margin-bottom: 0in">int n = 100;
</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;stepi(n);
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><BR>
</P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="delete break11"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu::update_stick</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::update_stick&ndash; increment
stick reg value;
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual void Vcpu::update_stick(int64_t
stickincr);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to
increment stick reg value by stickincr amount.
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">none</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">// increment stick reg value by 10</P>
<P STYLE="margin-bottom: 0in">g_vcpu[cpu_id]-&gt;update_stick(10);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><FONT SIZE=4 STYLE="font-size: 16pt"><U><A HREF="#overview"><SPAN STYLE="font-weight: medium"><FONT SIZE=3>back
to overview</FONT></SPAN></A></U></FONT></P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><A NAME="interrupt"></A><FONT SIZE=4 STYLE="font-size: 16pt"><B><U>Vcpu::interrupt</U>
</B></FONT>
</P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::interrupt - Signal an interrupt
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::interrupt (
VCPU_InterruptRequest *signal );</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual method of Vcpu class to signal
an interrupt. The interrupt message is described by the structure
VCPU_InterruptRequest</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">VCPU_InterruptRequest signal;</P>
<P STYLE="margin-bottom: 0in">signal.isid = src_aid;</P>
<P STYLE="margin-bottom: 0in">signal.itid = dst_aid;</P>
<P STYLE="margin-bottom: 0in">signal.data[0] = idata[0];
</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;interrupt(&amp;signal);
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="ireg"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu:: access integer
register </B></U></FONT>
</P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::get_ireg - Read integer register</P>
<P STYLE="margin-bottom: 0in">Vcpu::set_ireg - Write integer register</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::get_ireg (int wp, int
regnum, uint64_t &amp; regvalue);</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::set_ireg (int wp, int
regnum, uint64_t value);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to
read/write an integer register.
</P>
<P STYLE="margin-bottom: 0in">For SPARC V9 registers access</P>
<P STYLE="margin-bottom: 0in">regnum = 0-7 (globals); wp = 0 (normal)
, 1 (alternate) , 2 (mmu), 3 (interrupt)</P>
<P STYLE="margin-bottom: 0in">regnum = 8-31; wp = -1 (current), wp &gt;=
0 (window number)</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">int reg_idx = 16;</P>
<P STYLE="margin-bottom: 0in">uint64_t value = 0;</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_ireg(VCPU_ACC_CUR ,
reg_idx, value);</P>
<P STYLE="margin-bottom: 0in">value &amp;= 0xff;</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;set_ireg(VCPU_ACC_CUR ,
reg_idx, value);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="freg"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu:: access floating
point register</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::get_freg - Read floating point
register</P>
<P STYLE="margin-bottom: 0in">Vcpu::set_freg - Write floating point
register</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::get_freg (int
issingle, int regnum, uint64_t &amp; regvalue);</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::set_freg (int
issingle, int regnum, uint64_t value);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to
read/write a floating point register.
</P>
<P STYLE="margin-bottom: 0in">If issingle == 1 &ndash; single
precision 32 bit floating point register;
</P>
<P STYLE="margin-bottom: 0in">issingle == 0 &ndash; double precision
64 bit floating point register;</P>
<P STYLE="margin-bottom: 0in">regnum is defined according to SPARC V9
and core specific implementation.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">int reg_idx = 16;</P>
<P STYLE="margin-bottom: 0in">uint32_t value32 = 0;</P>
<P STYLE="margin-bottom: 0in">// single precision value</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_freg(1, reg_idx, value32);</P>
<P STYLE="margin-bottom: 0in">// double precision value</P>
<P STYLE="margin-bottom: 0in">#define SWAP_BIT_5_0(I) ((( (I) &amp;
0x01e ) | ( ((I) &amp; 0x020) &gt;&gt; 5 )) &amp; 0x1f)</P>
<P STYLE="margin-bottom: 0in">uint64_t value64 = 0;</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_freg(0,
SWAP_BIT_5_0(reg_idx), value64);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="preg"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu:: access privileged
register</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::get_pr - Read privileged register</P>
<P STYLE="margin-bottom: 0in">Vcpu::set_pr - Write privileged
register</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::get_pr(int regnum,
uint64_t &amp; value);</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::set_pr(int regnum,
uint64_t value);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to
read/write a privileged register.
</P>
<P STYLE="margin-bottom: 0in">For trap-level specific registers,
get/set_pr functions use the current trap_level.</P>
<P STYLE="margin-bottom: 0in">regnum = 0...31, it is defined
according to SPARC V9 and core specific implementation.
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">uint64_t value = 0;</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_pr(VCPU_PR_PSTATE, value);</P>
<P STYLE="margin-bottom: 0in">printf (&ldquo;PSTATE = %llx&rdquo;,
value);</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_pr(VCPU_PR_CWP, value);</P>
<P STYLE="margin-bottom: 0in">printf(&ldquo;CWP = %llx&rdquo;,
value);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="asr"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu:: access ancillary
register</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::get_acr - Read ancillary register</P>
<P STYLE="margin-bottom: 0in">Vcpu::set_asr - Write ancillary
register</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::get_asr(int regnum,
uint64_t &amp; value);</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::set_asr(int regnum,
uint64_t value);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to
read/write an ancillary register.
</P>
<P STYLE="margin-bottom: 0in">regnum is defined according to SPARC V9
and core specific implementation.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">uint64_t value = 0;</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_asr(VCPU_ASR_PC, value)</P>
<P STYLE="margin-bottom: 0in">printf (&ldquo;PC = %llx&rdquo;,
value);</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_asr(VCPU_ASR_ASI, value);</P>
<P STYLE="margin-bottom: 0in">printf(&ldquo;ASI = %llx&rdquo;,
value);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="trapreg"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu:: access trap
specific registers</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::get_trapreg - Read trap-level
specific register</P>
<P STYLE="margin-bottom: 0in">Vcpu::set_trapreg - Write trap-level
specific register</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::get_trapreg(int tl,
int regnum, uint64_t &amp; value);</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::set_trapreg(int tl,
int regnum, uint64_t value);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to
read/write a trap-level specific register,
</P>
<P STYLE="margin-bottom: 0in">where tl is a trap level;</P>
<P STYLE="margin-bottom: 0in">regnum could be one of
</P>
<P STYLE="margin-bottom: 0in">VCPU_PR_TPC = 0x0,
</P>
<P STYLE="margin-bottom: 0in">VCPU_PR_TNPC = 0x1,</P>
<P STYLE="margin-bottom: 0in">VCPU_PR_TSTATE = 0x2,</P>
<P STYLE="margin-bottom: 0in">VCPU_PR_TT = 0x3.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">uint64_t value = 0;</P>
<P STYLE="margin-bottom: 0in">int tl = 1;
</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_trapreg(1, VCPU_PR_TPC,
value)</P>
<P STYLE="margin-bottom: 0in">printf (&ldquo;trap level = %i, tpc =
%llx&rdquo;, tl, value);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="hpreg"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu:: access hyper
privileged register</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::get_hpr - Read hyper privileged
register</P>
<P STYLE="margin-bottom: 0in">Vcpu::set_hpr - Write hyper privileged
register</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::get_hpr(int regnum,
uint64_t &amp; value);</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::set_hpr(int regnum,
uint64_t value);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to
read/write a hyper privileged register.
</P>
<P STYLE="margin-bottom: 0in">regnum is defined according to core
specific implementation.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">uint64_t value = 0;</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;get_hpr(VCPU_HPR_HPSTATE,
value);</P>
<P STYLE="margin-bottom: 0in">printf (&ldquo;HPSTATE = %llx&rdquo;,
value);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="read mem"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu::read_mem</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::read_mem &ndash; Read memory in
the current CPU state</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::read_mem
</P>
<P STYLE="margin-bottom: 0in">(
</P>
<P STYLE="margin-bottom: 0in">uint64_t addr, // byte address</P>
<P STYLE="margin-bottom: 0in">uint64_t *value, // value to load
</P>
<P STYLE="margin-bottom: 0in">int size, // number of bytes</P>
<P STYLE="margin-bottom: 0in">int asi= 0x82, // ASI_PRIMARY_NO_FAULT</P>
<P STYLE="margin-bottom: 0in">int is_physical=0 // 1-physical
address, 0-virtual address</P>
<P STYLE="margin-bottom: 0in">);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to read
memory is used if caches or write buffer are present;</P>
<P STYLE="margin-bottom: 0in">address could be virtuall or physical;
</P>
<P STYLE="margin-bottom: 0in">little or big endian access is defined
by current state;
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">// read from the double word aligned
address</P>
<P STYLE="margin-bottom: 0in">uint64_t addr8 = addr &amp;
~uint64_t(7);</P>
<P STYLE="margin-bottom: 0in">uint64_t value = 0;</P>
<P STYLE="margin-bottom: 0in">if ( g_vcpu[cpu_id]-&gt;read_mem(addr8,
&amp;value, 8) != 0 )</P>
<P STYLE="margin-bottom: 0in">{</P>
<P STYLE="margin-bottom: 0in">reply_error (1);
</P>
<P STYLE="margin-bottom: 0in">return 1;</P>
<P STYLE="margin-bottom: 0in">}</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="write mem"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu::write_mem</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::write_mem &ndash; Write memory in
the current CPU state</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::write_mem
</P>
<P STYLE="margin-bottom: 0in">(
</P>
<P STYLE="margin-bottom: 0in">uint64_t addr, // byte address</P>
<P STYLE="margin-bottom: 0in">uint64_t value, // value to write
</P>
<P STYLE="margin-bottom: 0in">int size, // number of bytes</P>
<P STYLE="margin-bottom: 0in">int asi= 0x82, // ASI_PRIMARY_NO_FAULT</P>
<P STYLE="margin-bottom: 0in">int is_physical=0 // 1-physical
address, 0-virtual address</P>
<P STYLE="margin-bottom: 0in">);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to write
memory is used if caches or write buffer are present;</P>
<P STYLE="margin-bottom: 0in">address could be virtuall or physical;
</P>
<P STYLE="margin-bottom: 0in">little or big endian access is defined
by current state;
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">// write 0 value to the double word
aligned address</P>
<P STYLE="margin-bottom: 0in">uint64_t addr8 = addr &amp;
~uint64_t(7);</P>
<P STYLE="margin-bottom: 0in">uint64_t value = 0;</P>
<P STYLE="margin-bottom: 0in">if ( g_vcpu[cpu_id]-&gt;write_mem(addr8,
value, 8) != 0 )</P>
<P STYLE="margin-bottom: 0in">{</P>
<P STYLE="margin-bottom: 0in">reply_error (1);
</P>
<P STYLE="margin-bottom: 0in">return 1;</P>
<P STYLE="margin-bottom: 0in">}</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="set break"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu::set_breakpoint</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::set_breakpoint &ndash; Set a
breakpoint</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">typedef int (*VCPU_BpActionFn)( int
bp_id, int vcpu_id );</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::set_breakpoint
</P>
<P STYLE="margin-bottom: 0in">(
</P>
<P STYLE="margin-bottom: 0in">int *bp_id, // return breakpoint id;
</P>
<P STYLE="margin-bottom: 0in">VCPU_BpType type, // breakpoint type</P>
<P STYLE="margin-bottom: 0in">uint64_t value, // opcode, instruction
or data address</P>
<P STYLE="margin-bottom: 0in">VCPU_BpActionFn action, // call this
function on breakpoint hit</P>
<P STYLE="margin-bottom: 0in">uint64_t mask= ~(uint64_t(0)) //
optional data or addr mask
</P>
<P STYLE="margin-bottom: 0in">);
</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to set of
breakpoint of specified type.</P>
<P STYLE="margin-bottom: 0in">Address could be virtuall or physical.
Action() routine is called by cpu module when breakpoint is reached,
current instruction is not committed</P>
<P STYLE="margin-bottom: 0in">Breakpoint type
</P>
<P STYLE="margin-bottom: 0in">typedef enum</P>
<P STYLE="margin-bottom: 0in">{
</P>
<P STYLE="margin-bottom: 0in">VCPU_BP_INSTR_ADDR = 0,</P>
<P STYLE="margin-bottom: 0in">VCPU_BP_DATA_READ_ADDR,</P>
<P STYLE="margin-bottom: 0in">VCPU_BP_DATA_WRITE_ADDR,</P>
<P STYLE="margin-bottom: 0in">VCPU_BP_OPCODE,
</P>
<P STYLE="margin-bottom: 0in">VCPU_N_BP_TYPES</P>
<P STYLE="margin-bottom: 0in">} VCPU_BpType;
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">VCPU_BpType type = VCPU_BP_INSTR_ADDR;</P>
<P STYLE="margin-bottom: 0in">uint64_t addr = 0xfff00000;</P>
<P STYLE="margin-bottom: 0in">int bp_id;
</P>
<P STYLE="margin-bottom: 0in">extern int bp_action ( int bp_id, int
vcpu_id );</P>
<P STYLE="margin-bottom: 0in">vcpu-&gt;set_breakpoint( &amp;bp_id,type,
addr, bp_action );
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><A NAME="delete break"></A>
<FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu::delete_breakpoint</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::delete_breakpoint &ndash; Delete
a breakpoint</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::delete_breakpoint (
int bp_id = ~(0) );</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to remote
breakpoint with bp_id.</P>
<P STYLE="margin-bottom: 0in">If bp_id is ~(0) - remove all
breakpoints.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">// remove all breakpoints</P>
<P STYLE="margin-bottom: 0in">g_vcpu[cpu_id]-&gt;delete_breakpoint();</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><BR>
</P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vcpu::reconfig</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vcpu::reconfig&ndash; set new
parameters for vcpu configuration;
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">virtual int Vcpu::reconfig(VCPU_Config
conf );</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual methods of Vcpu class to change
cpu configuration parameters.
</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;
</P>
<P STYLE="margin-bottom: 0in">0 &ndash; fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">// update cpu config parameters</P>
<P STYLE="margin-bottom: 0in">g_vcpu[cpu_id]-&gt;reconfig(new_conf);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><FONT SIZE=4 STYLE="font-size: 16pt"><U><A HREF="#overview"><SPAN STYLE="font-weight: medium"><FONT SIZE=3>back
to overview</FONT></SPAN></A></U></FONT></P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ImpIntf::mem</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">mem - Pointer to the memory object.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">#include &ldquo;Memory.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">class SMemory *mem;</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in">This pointer is a member of
VCPU_ImpIntf structure.
</P>
<P STYLE="margin-bottom: 0in">CPU module uses this pointer internally
to access physical memory.
</P>
<P STYLE="margin-bottom: 0in">Currently we support two types of
simulated memory &ndash; flat memory and sparse memory.
</P>
<P STYLE="margin-bottom: 0in">For speed consideration the type of the
memory is defined at build time.
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in">The SMemory object should be
instantiated outside the CPU module and the pointer to the object is
assigned in VCPU_ImpIntf structure and passed to the create() vcpu
routine.
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ImpIntf::access_io</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">access_io - Access physical IO
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">int (*access_io)
</P>
<P STYLE="margin-bottom: 0in">(
</P>
<P STYLE="margin-bottom: 0in">int vcpu_id, // cpu id</P>
<P STYLE="margin-bottom: 0in">int operation, // operation code- load,
store and etc</P>
<P STYLE="margin-bottom: 0in">uint64_t paddr, // physical address</P>
<P STYLE="margin-bottom: 0in">uint32_t size, // access size</P>
<P STYLE="margin-bottom: 0in">uint64_t &amp;data, // 64 bit value to
read/write</P>
<P STYLE="margin-bottom: 0in">uint64_t bytemask // access byte mask</P>
<P STYLE="margin-bottom: 0in">);
</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This function pointer is a member of
VCPU_ImpIntf structure.
</P>
<P STYLE="margin-bottom: 0in">Pointer to the routine to access
physical io space from the CPU module.
</P>
<P STYLE="margin-bottom: 0in">Parameter operation is defined in
VCPU_Operation.</P>
<P STYLE="margin-bottom: 0in">CPU module uses this pointer internally
to access physical IO space.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;</P>
<P STYLE="margin-bottom: 0in">0 - fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">The routine should be defined outside
the CPU module and the pointer to the routine is assigned in
VCPU_ImpIntf structure and passed to the Create vcpu routine.
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ImpIntf::access_asi</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">access_asi - Optional interface to
access devices that mapped to asi ring
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">int (*access_asi)
</P>
<P STYLE="margin-bottom: 0in">(</P>
<P STYLE="margin-bottom: 0in">int vcpu_id, // cpu id
</P>
<P STYLE="margin-bottom: 0in">int operation, // operation code-
load,store and etc.</P>
<P STYLE="margin-bottom: 0in">uint32_t asi, // asi value</P>
<P STYLE="margin-bottom: 0in">uint64_t vaddr, // virtual address</P>
<P STYLE="margin-bottom: 0in">int32_t size, // access size</P>
<P STYLE="margin-bottom: 0in">uint64_t &amp;buf // 64 bit data value</P>
<P STYLE="margin-bottom: 0in">);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This function pointer is a member of
VCPU_ImpIntf structure.
</P>
<P STYLE="margin-bottom: 0in">Pointer to the routine to access device
control registers mapped to the asi ring from the CPU module.
Parameter operation is defined in VCPU_Operation.</P>
<P STYLE="margin-bottom: 0in">CPU module uses this pointer internally
to access asi mapped address space.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;</P>
<P STYLE="margin-bottom: 0in">0 - fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">The routine should be defined outside
the CPU module and the pointer to the routine is assigned in
VCPU_ImpIntf structure and passed to the Create vcpu routine.
</P>
<P STYLE="margin-bottom: 0in">NULL if not used.
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ImpIntf::access_serial</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">access_serial - Optional interface to
access serial devices
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">//
</P>
<P STYLE="margin-bottom: 0in">int (*access_serial)</P>
<P STYLE="margin-bottom: 0in">(</P>
<P STYLE="margin-bottom: 0in">uint8_t *c, // character to read/write</P>
<P STYLE="margin-bottom: 0in">bool_t wr // 0 - read, 1 - write</P>
<P STYLE="margin-bottom: 0in">);</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This function pointer is a member of
VCPU_ImpIntf structure.
</P>
<P STYLE="margin-bottom: 0in">Pointer to the routine to access serial
device for software bring up and debugging from the CPU module. CPU
module uses this pointer internally to access simulated serial
device.</P>
<P STYLE="margin-bottom: 0in"><B>RETURN VALUES</B></P>
<P STYLE="margin-bottom: 0in">1 &ndash; success;</P>
<P STYLE="margin-bottom: 0in">0 - fail.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">The routine should be defined outside
the CPU module and the pointer to the routine is assigned in
VCPU_ImpIntf structure and passed to the Create vcpu routine.
</P>
<P STYLE="margin-bottom: 0in">NULL if not used.
</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><FONT SIZE=4 STYLE="font-size: 16pt"><U><B>VCPU_ImpIntf::vtrace</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">vtrace - Pointer to the vtracer object.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vtracer.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">class VTracer *vtrace;
</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">This pointer is a member of
VCPU_ImpIntf structure.
</P>
<P STYLE="margin-bottom: 0in">CPU module uses this pointer internally
to output instruction trace.
</P>
<P STYLE="margin-bottom: 0in">VTracer is an abstract class
representing any analyzer which could be hooked up the CPU module.
Cpu model calles Vtracer methods to output a complete information
about architecture state change for every instruction. The
information for every instruction is accumulated in VCPU_Instruction
structure.
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">Trap information
is collected in VCPU_Trap structure, VCPU_TLB is for tlb information.
</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in">The Vtracer object should be
instantiated outside the CPU module, pointer to the object is
assigned in VCPU_ImpIntf structure and passed to the Create vcpu
routine.
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">A tracer module
must NOT define a static vtracer object. The</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">vtracer object
must be created by the vtracer_init() function</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">provided by the
module code and called by the simulator. Also, the</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">module must
provide a function called vtracer_fini() which should</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">clean up before
the module is unloaded (un-register ui commands, free</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">memory etc.)</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">Instruction
information VCPU_Instruction - provides information
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">about the
instruction been executed.</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">Fields in this
structure are arranged according to the
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">order in which
they are used during instruction lifetime.</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vtracer::instr</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vtracer::instr - Send an instruction
info message.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vtracer.h&rdquo;</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">virtual int
Vtracer::instr ( VCPU_Instruction *i );</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual method of Vtracer class &ndash;
output an instruction information.
</P>
<P STYLE="margin-bottom: 0in">VTracer is an abstract class
representing any analyzer which could be hooked up the CPU module.
VCPU_Instruction - provides information about the instruction been
executed.</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">Fields in this
structure are arranged according to the
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">order in which
they are used during instruction lifetime.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in; font-weight: medium">// collect trace
record</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">VCPU_Instruction
*i;</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;nregs = 0;</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;ld_num = 0;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;st_num = 0;</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;itype =
VCPU_UNKNOWN_ITYPE;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;cpuid =
cpuid;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;pc_va =
pc_va;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;pc_pa =
pc_pa;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;npc_va =
npc_va;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;opcode = iw;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;annul = an;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">i-&gt;taken =
(npc_va != (pc_va + 4));
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">// call tracer</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">g_ni_vcpu[cpuid]-&gt;sys_intf.vtrace-&gt;instr(i);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
<P STYLE="margin-bottom: 0in; page-break-before: always"><FONT SIZE=4 STYLE="font-size: 16pt"><U><B>Vtracer::trap</B></U></FONT></P>
<P STYLE="margin-bottom: 0in"><B>NAME</B></P>
<P STYLE="margin-bottom: 0in">Vtracer::instr - Send a trap info
message.
</P>
<P STYLE="margin-bottom: 0in"><B>SYNOPSIS</B></P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vcpu.h&rdquo;</P>
<P STYLE="margin-bottom: 0in">#include &ldquo;vtracer.h&rdquo;</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">virtual int
Vtracer::trap ( VCPU_Trap *t );</P>
<P STYLE="margin-bottom: 0in"><B>DESCRIPTION</B></P>
<P STYLE="margin-bottom: 0in">Virtual method of Vtracer class &ndash;
output trap information.
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">VCPU_Trap -
provides information about the trap been taken.</P>
<P STYLE="margin-bottom: 0in"><B>USAGE</B></P>
<P STYLE="margin-bottom: 0in; font-weight: medium">Sam::VCPU_Trap *t;</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">t-&gt;pc_va =
tr_pc;</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">t-&gt;npc_va =
tr_npc;</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">t-&gt;tno = tno;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">t-&gt;cpuid = id;
</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">//call tracer</P>
<P STYLE="margin-bottom: 0in; font-weight: medium">g_ni_vcpu[id]-&gt;sys_intf.vtrace-&gt;trap(t);</P>
<P STYLE="margin-bottom: 0in"><B>SEE ALSO</B></P>
<P STYLE="margin-bottom: 0in"><A HREF="#overview">back to overview</A></P>
</BODY>
</HTML>