public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
From: Ben Elliston <bje@redhat.com>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: sid@sources.redhat.com
Subject: Re: CPU disassembler-memory accessor
Date: Fri, 31 May 2002 13:35:00 -0000	[thread overview]
Message-ID: <15607.56973.58661.290693@tooth.toronto.redhat.com> (raw)
In-Reply-To: <20020529115301.C17962@redhat.com>

>>>>> "FChE" == Frank Ch Eigler <fche@redhat.com> writes:

  FChE> Yes, just one.  The read_disasm_memory_1 function is methinks
  FChE> overengineered.  It doesn't need to throw exceptions, nor handle
  FChE> accesses of other sizes.  Actually, why not just do a direct
  FChE> sid::bus-level read() on the accessor and do away with the
  FChE> read_disasm_memory* thingie altogether?

Thanks for the feedback.  How's this instead?

Index: include/sidcpuutil.h
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/include/sidcpuutil.h,v
retrieving revision 1.28.2.4
diff -u -p -r1.28.2.4 sidcpuutil.h
--- include/sidcpuutil.h	2002/04/23 21:07:51	1.28.2.4
+++ include/sidcpuutil.h	2002/05/31 13:15:37
@@ -495,6 +495,7 @@ namespace sidutil
   protected:
     sid::bus* data_bus;
     sid::bus* insn_bus;
+    sid::bus* disassembler_bus;
 
   protected:
     template <typename BigOrLittleInt>
@@ -506,6 +507,8 @@ namespace sidutil
     template <typename BigOrLittleInt>
     BigOrLittleInt write_data_memory (sid::host_int_4 pc, sid::host_int_4 address, BigOrLittleInt value) const;
 
+    bool read_disasm_memory (sid::host_int_4 address, sid::big_int_1& value) const;
+
     // ------------------------------------------------------------------------
     
 public:
@@ -529,6 +532,8 @@ public:
 	add_accessor ("data-memory", & this->data_bus);
 	this->insn_bus = 0;
 	add_accessor ("insn-memory", & this->insn_bus);
+	this->disassembler_bus = 0;
+	add_accessor ("disassembler-memory", & this->disassembler_bus);
 	add_bus ("debugger-bus", & this->debugger_bus);
 
 	// pins
@@ -597,6 +602,23 @@ public:
       else
 	dynamic_cast <ofstream&> (s) << t;
       return s;
+    }
+
+    inline bool
+    basic_cpu::read_disasm_memory (sid::host_int_4 address, sid::big_int_1& value) const
+    {
+      sid::bus* bus;
+      bus = (this->disassembler_bus) ? this->disassembler_bus : this->insn_bus;
+      
+      try
+	{
+	  if (LIKELY (bus->read (address, value) == sid::bus::ok))
+	    return true;
+	}
+      catch (cpu_memory_fault& f)
+	{
+	  return false;
+	}
     }
   
     template <typename BigOrLittleInt>

Index: component/cgen-cpu/compCGEN.cxx
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/component/cgen-cpu/compCGEN.cxx,v
retrieving revision 1.66.2.5
diff -u -p -r1.66.2.5 compCGEN.cxx
--- component/cgen-cpu/compCGEN.cxx	2002/04/03 18:43:36	1.66.2.5
+++ component/cgen-cpu/compCGEN.cxx	2002/05/31 13:15:35
@@ -184,10 +184,6 @@ cgen_bi_endian_cpu::cgen_read_memory(bfd
 {
   cgen_bi_endian_cpu *thisp = static_cast<cgen_bi_endian_cpu *>(info->application_data);
 
-  // We don't want to penalize the disassembler with memory latency counts, so we
-  // store it away here ...
-  host_int_8 prev_latency = thisp->total_latency;
-
   switch (length) {
 #if 0 // XXX not sure if this has byte order dependancies or not
   case 1:
@@ -204,13 +200,17 @@ cgen_bi_endian_cpu::cgen_read_memory(bfd
     break;
 #endif
   default:
-    for (int i = 0; i < length; i++)
-      *(myaddr + i) = thisp->read_insn_memory_1(0, memaddr + i);
+    {
+      big_int_1 value;
+      for (int i = 0; i < length; i++)
+	{
+	  if (! thisp->read_disasm_memory (memaddr + i, value))
+	    return 1;
+	  else
+	    *(myaddr + i) = value;
+	}
+    }
   }
-
-  // ... and restore it here.
-  thisp->total_latency = prev_latency;
-
   return 0;
 }
 
Index: component/cgen-cpu/common-xml/behavior.xml
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/component/cgen-cpu/common-xml/behavior.xml,v
retrieving revision 1.1.10.1
diff -u -p -r1.1.10.1 behavior.xml
--- component/cgen-cpu/common-xml/behavior.xml	2002/03/14 01:04:39	1.1.10.1
+++ component/cgen-cpu/common-xml/behavior.xml	2002/05/31 13:15:35
@@ -32,9 +32,12 @@
       <p>Each instruction is first fetched from memory via the
       <accessor>insn-memory</accessor> accessor, and its decoding
       traced if the <attribute>trace-extract?</attribute> attribute is
-      set to a true value.  The decoded form may be cached
-      indefinitely afterwards, although this cache is flushed when the
-      <pin>flush-icache</pin> pin is driven.</p>
+      set to a true value.  To prevent unwanted cache side effects,
+      the <accessor>disassembler-memory</accessor> accessor can be
+      used and connected directly to main memory, bypassing any memory
+      caches.  The decoded form may be cached indefinitely afterwards,
+      although this cache is flushed when the <pin>flush-icache</pin>
+      pin is driven.</p>
 
       <p>The <attribute>engine-type</attribute> attribute specifies
       whether the "scache" ("semantic cache") or "pbb" ("pseudo basic
Index: component/cgen-cpu/common-xml/interface.xml
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/component/cgen-cpu/common-xml/interface.xml,v
retrieving revision 1.2.10.1
diff -u -p -r1.2.10.1 interface.xml
--- component/cgen-cpu/common-xml/interface.xml	2002/03/14 01:04:39	1.2.10.1
+++ component/cgen-cpu/common-xml/interface.xml	2002/05/31 13:15:35
@@ -16,6 +16,7 @@
     <!-- accessors -->
     <defaccessor name="data-memory" accesses="any" behaviors="execution" />
     <defaccessor name="insn-memory" accesses="typically 4-byte accesses" behaviors="execution" />
+    <defaccessor name="disassembler-memory" accesses="any" behaviors="execution" />
 
 
     <!-- buses -->

  reply	other threads:[~2002-05-31 20:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-29  7:46 Ben Elliston
2002-05-29  8:53 ` Frank Ch. Eigler
2002-05-31 13:35   ` Ben Elliston [this message]
2002-05-31 13:39     ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15607.56973.58661.290693@tooth.toronto.redhat.com \
    --to=bje@redhat.com \
    --cc=fche@redhat.com \
    --cc=sid@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).