This is the mail archive of the sid@sources.redhat.com mailing list for the SID project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch][rfa] SID mapper component enhancement


Hi,

The attached patch enhances the syntax accepted when defining mappings
in the hw-mapper-basic and hw-mapper-transparent components to allow the
specification of a base address for the mapped memory. Currently, the
default mapped base address for hw-mapper-basic is zero and for
hw-mapper-transparent it is the same as the starting address of the
range. The mapped base address is specified using <base>= within the
range specification as follows:

    [<base>=<start>-<end>]

wordsize and stride/width are also still accepted:

    [<wordsize>*<base>=<start-end>,stride,width]

This patch does not change the behavior of existing specifications.

The SID mapper tests pass with no regressions as does xstormy16-allinsn.exp. Also tested against an internal port which inspired this enhancement.

Ok to commit?

Dave

2002-04-09  Dave Brolley  <brolley@redhat.com>

	* hw-mapper-basic.xml: Describe <mapped_base> usage.
	* compMapper.cxx (struct mapping_record): New field, 'mapped_base'.
	(class generic_mapper_bus): Remove 'transparent_t' parameter,
	'low_multiplier' member  and 'is_transparent' member.
	(generic_mapper_bus::write_strideoffset_any): Compute mapped_address
	relative to mapped_base.
	(generic_mapper_bus::read_strideoffset_any): Ditto.
	(generic_mapper_bus::write_any): Ditto.
	(generic_mapper_bus::read_any): Ditto.
	(make_name_mapping): Remove 'garbage1' -- not used. Detect wordsize and
	mapped_base specifications using their operators.

Index: sid/component/mapper/ChangeLog
===================================================================
RCS file: /cvs/src/src/sid/component/mapper/ChangeLog,v
retrieving revision 1.12
diff -c -p -r1.12 ChangeLog
*** sid/component/mapper/ChangeLog	15 Mar 2002 20:58:40 -0000	1.12
--- sid/component/mapper/ChangeLog	10 Apr 2002 17:55:01 -0000
***************
*** 1,3 ****
--- 1,18 ----
+ 2002-04-09  Dave Brolley  <brolley@redhat.com>
+ 
+ 	* hw-mapper-basic.xml: Describe <mapped_base> usage.
+ 	* hw-mapper-basic.txt: Regenerated.
+ 	* compMapper.cxx (struct mapping_record): New field, 'mapped_base'.
+ 	(class generic_mapper_bus): Remove 'transparent_t' parameter,
+ 	'low_multiplier' member  and 'is_transparent' member.
+ 	(generic_mapper_bus::write_strideoffset_any): Compute mapped_address
+ 	relative to mapped_base.
+ 	(generic_mapper_bus::read_strideoffset_any): Ditto.
+ 	(generic_mapper_bus::write_any): Ditto.
+ 	(generic_mapper_bus::read_any): Ditto.
+ 	(make_name_mapping): Remove 'garbage1' -- not used. Detect wordsize and
+ 	mapped_base specifications using their operators.
+ 
  2002-03-15  Frank Ch. Eigler  <fche@redhat.com>
  
  	* compMapper.cxx (make_name_mapping): Tolerate bank-less suffix form.
Index: sid/component/mapper/compMapper.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/mapper/compMapper.cxx,v
retrieving revision 1.10
diff -c -p -r1.10 compMapper.cxx
*** sid/component/mapper/compMapper.cxx	15 Mar 2002 20:58:40 -0000	1.10
--- sid/component/mapper/compMapper.cxx	10 Apr 2002 17:55:01 -0000
*************** using sidutil::attribute_coder_virtual_p
*** 63,68 ****
--- 63,69 ----
  
  struct mapping_record
  {
+   host_int_4 mapped_base;       // Base of mapped address
    host_int_4 low, high;         // inclusive address range
    host_int_4 hit_count;         // number of accesses via this record
    bus* accessor;                // target bus
*************** class generic_mapper;
*** 165,174 ****
  class generic_mapper_bus: public bus
  {
  public:
!   generic_mapper_bus (generic_mapper* target, bool transparent_p): target (target)
      {
        this->tlb1 = this->tlb2 = 0;
-       this->low_multiplier = (transparent_p ? 0 : 1);
      }
  
  
--- 166,174 ----
  class generic_mapper_bus: public bus
  {
  public:
!   generic_mapper_bus (generic_mapper* target): target (target)
      {
        this->tlb1 = this->tlb2 = 0;
      }
  
  
*************** public:
*** 201,207 ****
        for (unsigned i=0; i<slave_size; i++)
  	ds.write_byte (i, data.read_byte (i + slave_offset - master_offset));
  
!       host_int_4 mapped_address = (address - (this->low_multiplier * r->low)) >> (r->stride_shift - r->width_shift);
        
        bus::status st = r->accessor->write (mapped_address, ds);
        st.latency += target->latency;
--- 201,207 ----
        for (unsigned i=0; i<slave_size; i++)
  	ds.write_byte (i, data.read_byte (i + slave_offset - master_offset));
  
!       host_int_4 mapped_address = (address - (r->low - r->mapped_base)) >> (r->stride_shift - r->width_shift);
        
        bus::status st = r->accessor->write (mapped_address, ds);
        st.latency += target->latency;
*************** public:
*** 230,236 ****
  	return bus::misaligned;
  
        DataSlave ds;
!       host_int_4 mapped_address = (address - (this->low_multiplier * r->low)) >> (r->stride_shift - r->width_shift);
        bus::status s = r->accessor->read (mapped_address, ds);
  
        // Copy data bytes for master
--- 230,236 ----
  	return bus::misaligned;
  
        DataSlave ds;
!       host_int_4 mapped_address = (address - (r->low - r->mapped_base)) >> (r->stride_shift - r->width_shift);
        bus::status s = r->accessor->read (mapped_address, ds);
  
        // Copy data bytes for master
*************** private:
*** 287,293 ****
    generic_mapper* target;
    mutable struct mapping_record* tlb1;
    mutable struct mapping_record* tlb2;
-   unsigned low_multiplier;
  
  public:
    void clear_tlb () { tlb1 = tlb2 = 0; }
--- 287,292 ----
*************** private:
*** 343,356 ****
    component::status set_hits (std::string entry, const std::string& value);
  
    host_int_2 latency;
  };
  
  
  generic_mapper::generic_mapper (bool transparent_p)
!   :my_bus (this, transparent_p),
     bank (0),
     bank_pin (this, & generic_mapper::bank_pin_handler),
!    latency (0)
  {
    add_bus ("access-port", &this->my_bus);
    add_attribute_virtual ("state-snapshot", this,
--- 342,357 ----
    component::status set_hits (std::string entry, const std::string& value);
  
    host_int_2 latency;
+   bool is_transparent;
  };
  
  
  generic_mapper::generic_mapper (bool transparent_p)
!   :my_bus (this),
     bank (0),
     bank_pin (this, & generic_mapper::bank_pin_handler),
!    latency (0),
!    is_transparent (transparent_p)
  {
    add_bus ("access-port", &this->my_bus);
    add_attribute_virtual ("state-snapshot", this,
*************** generic_mapper_bus::write_any (host_int_
*** 502,508 ****
  	// bypass stride/offset calculations?
  	if (LIKELY(! r->use_strideoffset_p))
  	  {
! 	    host_int_4 mapped_address = address - (this->low_multiplier * r->low);
  	    bus::status st = r->accessor->write (mapped_address, data);
  	    st.latency += target->latency;
  	    return st;
--- 503,509 ----
  	// bypass stride/offset calculations?
  	if (LIKELY(! r->use_strideoffset_p))
  	  {
! 	    host_int_4 mapped_address = address - (r->low - r->mapped_base);
  	    bus::status st = r->accessor->write (mapped_address, data);
  	    st.latency += target->latency;
  	    return st;
*************** generic_mapper_bus::read_any (host_int_4
*** 546,552 ****
  	// bypass stride/offset calculations?
  	if (LIKELY(! r->use_strideoffset_p))
  	  {
! 	    host_int_4 mapped_address = address - (this->low_multiplier * r->low);
  	    bus::status st = r->accessor->read (mapped_address, data);
  	    st.latency += target->latency;
  	    return st;
--- 547,553 ----
  	// bypass stride/offset calculations?
  	if (LIKELY(! r->use_strideoffset_p))
  	  {
! 	    host_int_4 mapped_address = address - (r->low - r->mapped_base);
  	    bus::status st = r->accessor->read (mapped_address, data);
  	    st.latency += target->latency;
  	    return st;
*************** generic_mapper_bus::read_any (host_int_4
*** 589,598 ****
  // GARBAGE1[SPEC]GARBAGE2
  //
  // where SPEC ::=
! // LOW-HIGH                              (2 tokens)
! // LOW-HIGH,STRIDE,WIDTH                 (3 tokens)
! // BYTES_PER_WORD*LOW-HIGH               (4 tokens)
! // BYTES_PER_WORD*LOW-HIGH,STRIDE,WIDTH  (5 tokens)
  //
  // and GARBAGE2 ::=
  // {BANKS}GARBAGE3
--- 590,603 ----
  // GARBAGE1[SPEC]GARBAGE2
  //
  // where SPEC ::=
! // LOW-HIGH
! // LOW-HIGH,STRIDE,WIDTH
! // MAPPED_BASE=LOW-HIGH
! // MAPPED_BASE=LOW-HIGH,STRIDE,WIDTH
! // BYTES_PER_WORD*LOW-HIGH
! // BYTES_PER_WORD*LOW-HIGH,STRIDE,WIDTH
! // BYTES_PER_WORD*MAPPED_BASE=LOW-HIGH
! // BYTES_PER_WORD*MAPPED_BASE=LOW-HIGH,STRIDE,WIDTH
  //
  // and GARBAGE2 ::=
  // {BANKS}GARBAGE3
*************** generic_mapper::make_name_mapping (const
*** 617,623 ****
        return 0;
      }
  
-   string garbage1 = fields_outer[0];
    string spec = fields_outer[1];
    string garbage2 = fields_outer[2];
  
--- 622,627 ----
*************** generic_mapper::make_name_mapping (const
*** 663,684 ****
        return 0;
      }
  
!   // XXX: equivocate */-/, separators
!   vector<string> fields = tokenize (spec, "*-,");  
    
!   // Must have between 2 and 5 tokens (including empties
!   // before/after "[" and "]"
!   if (fields.size() < 2 || fields.size() > 5)
      {
!       cerr << "mapper error: parse error (bad number of [SPEC] fields) in "
  	   << str << endl;
        return 0;
      }
  
!   // strip the word width off the front of the descriptor array
!   record.bytes_per_word = 1;
!   if (fields.size() == 3 || fields.size() == 5) 
      {
        component::status stat = parse_attribute(fields [0], record.bytes_per_word);
        if (stat != component::ok) 
  	{
--- 667,686 ----
        return 0;
      }
  
!   // Check for the BYTES_PER_WORD* specification.
!   vector<string> fields = tokenize (spec, "*");  
    
!   // Must have 1 or 2 tokens
!   if (fields.size() > 2)
      {
!       cerr << "mapper error: parse error (more than one word size) in "
  	   << str << endl;
        return 0;
      }
  
!   if (fields.size() == 2) 
      {
+       // strip the word width off the front of the descriptor array
        component::status stat = parse_attribute(fields [0], record.bytes_per_word);
        if (stat != component::ok) 
  	{
*************** generic_mapper::make_name_mapping (const
*** 687,698 ****
  	}
        fields.erase (fields.begin ());
      }
  
!   assert (fields.size() == 2 || fields.size() == 4);
!   
!   record.use_strideoffset_p = (fields.size() == 4);
!   record.spec = str;
!   record.hit_count = 0;
  
    // parse two or four fields
    component::status s1 = parse_attribute(fields[0], record.low);
--- 689,737 ----
  	}
        fields.erase (fields.begin ());
      }
+   else
+     record.bytes_per_word = 1;
  
!   assert (fields.size() == 1);
!   spec = fields[0];
! 
!   // Check for a mapped_base output address specification
!   fields = tokenize (spec, "=");
! 
!   // Must have 1 or 2 tokens
!   if (fields.size() > 2)
!     {
!       cerr << "mapper error: parse error (more than one mapped base address) in "
! 	   << str << endl;
!       return 0;
!     }
! 
!   bool mapped_base_default;
!   if (fields.size() == 2) 
!     {
!       // strip the mapped_base address off the front of the descriptor array
!       component::status stat = parse_attribute(fields [0], record.mapped_base);
!       if (stat != component::ok) 
! 	{
! 	  cerr << "mapper error: parse error (mapped_base) in " << str << endl;
! 	  return 0;
! 	}
!       fields.erase (fields.begin ());
!       mapped_base_default = false;
!     }
!   else
!     mapped_base_default = true;
! 
!   assert (fields.size() == 1);
!   spec = fields[0];
! 
!   // Now parse the address range and the stride/width, if any
!   fields = tokenize (spec, "-,");
!   if (fields.size() != 2 && fields.size() != 4)
!     {
!       cerr << "mapper error: parse error (wrong number of arguments to [SPEC]) in " << str << endl;
!       return 0;
!     }
  
    // parse two or four fields
    component::status s1 = parse_attribute(fields[0], record.low);
*************** generic_mapper::make_name_mapping (const
*** 702,707 ****
--- 741,748 ----
        cerr << "mapper error: parse error (low-high) in " << str << endl;
        return 0;
      }
+ 
+   record.use_strideoffset_p = (fields.size() == 4);
    if (record.use_strideoffset_p)
      {
        component::status s3 = parse_attribute(fields[2], record.stride);
*************** generic_mapper::make_name_mapping (const
*** 720,726 ****
--- 761,778 ----
        return 0;
      }
  
+   // We now enough information to set the default for the mapped_base address
+   // if required.
+   if (mapped_base_default)
+     {
+       if (is_transparent)
+ 	record.mapped_base = record.low;
+       else
+ 	record.mapped_base = 0;
+     }
+ 
    // scale all values by the word width
+   record.mapped_base *= record.bytes_per_word;
    record.low    *= record.bytes_per_word;
    record.high   *= record.bytes_per_word;
    record.stride *= record.bytes_per_word;
*************** generic_mapper::make_name_mapping (const
*** 772,777 ****
--- 824,830 ----
  
        // compute offset; adjust high/low to contain entire stride regions
        record.offset = record.low & record.stride_mask;
+       record.mapped_base &= ~ record.stride_mask;
        record.low &= ~ record.stride_mask;
        record.high |= record.stride_mask;
      }
*************** generic_mapper::make_name_mapping (const
*** 789,794 ****
--- 842,849 ----
  
    // fill in slot
    record.accessor = acc;
+   record.spec = str;
+   record.hit_count = 0;
  
    /*
    cout << "new mapping_record: "
Index: sid/component/mapper/hw-mapper-basic.txt
===================================================================
RCS file: /cvs/src/src/sid/component/mapper/hw-mapper-basic.txt,v
retrieving revision 1.5
diff -c -p -r1.5 hw-mapper-basic.txt
*** sid/component/mapper/hw-mapper-basic.txt	12 Mar 2002 18:03:18 -0000	1.5
--- sid/component/mapper/hw-mapper-basic.txt	10 Apr 2002 17:55:01 -0000
*************** Functionality:
*** 23,28 ****
--- 23,32 ----
       * [<wordsize>*<low>-<high>]
       * [<low>-<high>,<stride>,<width>]
       * [<wordsize>*<low>-<high>,<stride>,<width>]
+      * [<mapped_base>=<low>-<high>]
+      * [<wordsize>*<mapped_base>=<low>-<high>]
+      * [<mapped_base>=<low>-<high>,<stride>,<width>]
+      * [<wordsize>*<mapped_base>=<low>-<high>,<stride>,<width>]
     where:
       * <low> is the starting address for the mapped region.
       * <high> is the ending address for the mapped region.
*************** Functionality:
*** 31,36 ****
--- 35,45 ----
       * <wordsize> is the number of bytes in an address unit: a constant
         multiplier you can use to permit specifying <low>, <high>, <stride>
         and <width> in terms of multi-byte words.
+      * <mapped_base> is the base address of the mapped bytes on the target
+        bus. Addresses in the mapped region will be adjusted to start at
+        <mapped_base>. For hw-mapper-transparent, the default <mapped_base> is
+        the value of <start>. For hw-mapper-basic, the default <mapped_base>
+        is zero.
  
     To the right of the "]" closing bracket, an optional specification block
     may list the numbers of mapping banks for this record. This block is
*************** Functionality:
*** 52,61 ****
     another.
  
     The downstream addresses passed by the hw-mapper-basic variant are
!    relative to the matching region, so are zero-based. The
!    hw-mapper-transparent does not make downstream addresses relative, so it
!    may be more suitable for carving up an address space by multiple layers of
!    mapping.
  
     See the "mapping" behavior below for more details.
  
--- 61,71 ----
     another.
  
     The downstream addresses passed by the hw-mapper-basic variant are
!    relative to the matching region, so are zero-based, by default. The
!    hw-mapper-transparent does not make downstream addresses relative by
!    default, so it may be more suitable for carving up an address space by
!    multiple layers of mapping. Use of <mapped_base> for either component
!    overrides this default behavior.
  
     See the "mapping" behavior below for more details.
  
*************** Functionality:
*** 97,110 ****
     |                | address is transformed         |
     |                | according to the following     |
     |                | rules:                         |
!    |                |   * The accessor's <low>       |
!    |                |     address is subtracted from |
!    |                |     the incoming address, so   |
     |                |     outgoing addresses will be |
!    |                |     relative and zero-based.   |
!    |                |     The hw-mapper-transparent  |
!    |                |     component variant omits    |
!    |                |     this subtraction.          |
     |                |   * If the accessor has        |
     |                |     stride/width values,       |
     |                |     divide the relative        |
--- 107,118 ----
     |                | address is transformed         |
     |                | according to the following     |
     |                | rules:                         |
!    |                |   * The accessor's             |
!    |                |     <mapped_base> address is   |
!    |                |     subtracted from the        |
!    |                |     incoming address, so       |
     |                |     outgoing addresses will be |
!    |                |     relative.                  |
     |                |   * If the accessor has        |
     |                |     stride/width values,       |
     |                |     divide the relative        |
Index: sid/component/mapper/hw-mapper-basic.xml
===================================================================
RCS file: /cvs/src/src/sid/component/mapper/hw-mapper-basic.xml,v
retrieving revision 1.3
diff -c -p -r1.3 hw-mapper-basic.xml
*** sid/component/mapper/hw-mapper-basic.xml	12 Mar 2002 18:03:18 -0000	1.3
--- sid/component/mapper/hw-mapper-basic.xml	10 Apr 2002 17:55:01 -0000
***************
*** 47,52 ****
--- 47,56 ----
  	    <li><tt>[&lt;wordsize&gt;*&lt;low&gt;-&lt;high&gt;]</tt></li>
  	    <li><tt>[&lt;low&gt;-&lt;high&gt;,&lt;stride&gt;,&lt;width&gt;]</tt></li>
  	    <li><tt>[&lt;wordsize&gt;*&lt;low&gt;-&lt;high&gt;,&lt;stride&gt;,&lt;width&gt;]</tt></li>
+ 	    <li><tt>[&lt;mapped_base&gt;=&lt;low&gt;-&lt;high&gt;]</tt></li>
+ 	    <li><tt>[&lt;wordsize&gt;*&lt;mapped_base&gt;=&lt;low&gt;-&lt;high&gt;]</tt></li>
+ 	    <li><tt>[&lt;mapped_base&gt;=&lt;low&gt;-&lt;high&gt;,&lt;stride&gt;,&lt;width&gt;]</tt></li>
+ 	    <li><tt>[&lt;wordsize&gt;*&lt;mapped_base&gt;=&lt;low&gt;-&lt;high&gt;,&lt;stride&gt;,&lt;width&gt;]</tt></li>
  	  </ul>
  
  	  where:
***************
*** 63,68 ****
--- 67,79 ----
  	    &lt;wordsize&gt;</tt> is the number of bytes in an address unit:
  	  a constant multiplier you can use to permit specifying &lt;low&gt;, &lt;high&gt;,
  	  &lt;stride&gt; and &lt;width&gt; in terms of multi-byte words.</li>
+ 	  <li><tt>
+ 	    &lt;mapped_base&gt;</tt> is the base address of the mapped bytes on the
+ 	    target bus.  Addresses in the mapped region will be adjusted to start at
+ 	    &lt;mapped_base&gt;. For <component>hw-mapper-transparent</component>,
+ 	    the default &lt;mapped_base&gt; is the value of &lt;start&gt;. For
+ 	    <component>hw-mapper-basic</component>, the default &lt;mapped_base&gt;
+ 	    is zero.</li>
  	  </ul>
  	</p>
  	
***************
*** 94,103 ****
  	<p>
            The downstream addresses passed by the
            <component>hw-mapper-basic</component> variant are relative
!           to the matching region, so are zero-based.  The
            <component>hw-mapper-transparent</component> does not make
!           downstream addresses relative, so it may be more suitable for 
!           carving up an address space by multiple layers of mapping.</p>
  
  	<p>
  	  See the "mapping" behavior below for more details.</p></p>
--- 105,116 ----
  	<p>
            The downstream addresses passed by the
            <component>hw-mapper-basic</component> variant are relative
!           to the matching region, so are zero-based, by default.  The
            <component>hw-mapper-transparent</component> does not make
!           downstream addresses relative by default, so it may be more suitable for 
!           carving up an address space by multiple layers of mapping.
!           Use of &lt;mapped_base&gt; for either component overrides this
!           default behavior.</p>
  
  	<p>
  	  See the "mapping" behavior below for more details.</p></p>
***************
*** 136,145 ****
  
  	  <ul>
  	    <li>
! 	      The accessor's &lt;low&gt; address is subtracted from the incoming
! 	      address, so outgoing addresses will be relative and zero-based.
!               The <component>hw-mapper-transparent</component> component variant 
!               omits this subtraction.</li>
  	    <li>
  	      If the accessor has stride/width values, divide the relative
  	      address by the quotient (&lt;stride&gt;/&lt;width&gt;).  As a result,
--- 149,156 ----
  
  	  <ul>
  	    <li>
! 	      The accessor's &lt;mapped_base&gt; address is subtracted from the incoming
! 	      address, so outgoing addresses will be relative.</li>
  	    <li>
  	      If the accessor has stride/width values, divide the relative
  	      address by the quotient (&lt;stride&gt;/&lt;width&gt;).  As a result,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]