public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
* [patch][rfa] generic memory enhancements
@ 2003-10-21 19:58 Dave Brolley
  2003-10-21 22:14 ` Dave Brolley
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Brolley @ 2003-10-21 19:58 UTC (permalink / raw)
  To: sid

[-- Attachment #1: Type: text/plain, Size: 350 bytes --]

Hi,

This patch enhances generic memory in several ways:

1) It allows writes to readonly memory if the attribute 
"allow-write-to-rom" is set
2) It warns about write to rom if "warn-write-to-rom" is set
3) It allows the base address of the memory to be specified via the 
"base-address" attribute for use in generated warnings.

ok to commit?

Dave

[-- Attachment #2: memory.ChangeLog --]
[-- Type: text/plain, Size: 1273 bytes --]

2003-10-07  Dave Brolley  <brolley@redhat.com>

	For Stan Cox  <scox@redhat.com>
	* generic.h (SID_GB_WRITE): allow_rom_write implies warn_rom_write.

2003-10-07  Dave Brolley  <brolley@redhat.com>

	For Stan Cox  <scox@redhat.com>
	* generic.h (generic_memory): New member allow_rom_write.
	(SID_GB_WRITE): Use it.
	* generic.cxx (generic_memory): Initialize it.

2003-10-07  Dave Brolley  <brolley@redhat.com>

	* generic.h (generic_read_write_bus::write_any): Move to
	generic_read_only_bus.
	(generic_read_only_bus::SID_GB_WRITE): Allow write to read-only-port
	with a warning if ignore_rom_write is set.

2003-10-07  Dave Brolley  <brolley@redhat.com>

	* generic.h (generic_memory): New member: base_address.
	(SID_GB_WRITE): Add target->base_address to the address printed.
	* generic.cxx (generic_memory): Initialize base_address. Add
	base-address attribute.

2003-10-07  Dave Brolley  <brolley@redhat.com>

	For Stan Cox  <scox@redhat.com>
	* generic.cxx (generic_memory): New member ignore_rom_write.
	* generic.h (generic_read_only_bus::SID_GB_WRITE): Use it.

2003-10-07  Dave Brolley  <brolley@redhat.com>

	For Frank Ch. Eigler  <fche@redhat.com>
	* generic.cxx (generic_memory ctor): Add evil backdoor hack to
	read memory buffer base/size via attributes.


[-- Attachment #3: memory.patch.txt --]
[-- Type: text/plain, Size: 4919 bytes --]

Index: sid/component/memory/generic.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/memory/generic.cxx,v
retrieving revision 1.8
diff -c -p -r1.8 generic.cxx
*** sid/component/memory/generic.cxx	10 Jun 2003 18:27:10 -0000	1.8
--- sid/component/memory/generic.cxx	21 Oct 2003 19:16:36 -0000
***************
*** 1,6 ****
  // generic.cxx - a class of generic memories.  -*- C++ -*-
  
! // Copyright (C) 1999-2001,2003 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
--- 1,6 ----
  // generic.cxx - a class of generic memories.  -*- C++ -*-
  
! // Copyright (C) 1999-2003 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
*************** generic_memory::generic_memory() throw (
*** 55,61 ****
    imagemmap_pin (this, & generic_memory::imagemmap_handler),
    imagemsync_pin (this, & generic_memory::imagemsync_handler),
    read_latency (0),
!   write_latency (0)
  {
    this->max_buffer_length = 32UL * 1024UL * 1024UL;
    this->buffer = 0;
--- 55,64 ----
    imagemmap_pin (this, & generic_memory::imagemmap_handler),
    imagemsync_pin (this, & generic_memory::imagemsync_handler),
    read_latency (0),
!   write_latency (0),
!   base_address (0),
!   warn_rom_write (false),
!   allow_rom_write (false)
  {
    this->max_buffer_length = 32UL * 1024UL * 1024UL;
    this->buffer = 0;
*************** generic_memory::generic_memory() throw (
*** 82,87 ****
--- 85,98 ----
  
    add_attribute ("read-latency", & this->read_latency, "setting");
    add_attribute ("write-latency", & this->write_latency, "setting");
+   add_attribute ("base-address", & this->base_address, "setting");
+ 
+   add_attribute ("warn-rom-write-option?", & this->warn_rom_write, "setting");
+   add_attribute ("allow-rom-write-option?", & this->allow_rom_write, "setting");
+ 
+   // Undocumented, dangerous, do not use ...
+   add_attribute_ro ("buffer-base-UNSAFE", (host_int_4*) & this->buffer);
+   add_attribute_ro ("buffer-length-UNSAFE", & this->buffer_length);
  
    add_attribute_virtual ("state-snapshot", this,
  			 & generic_memory::save_state,
Index: sid/component/memory/generic.h
===================================================================
RCS file: /cvs/src/src/sid/component/memory/generic.h,v
retrieving revision 1.5
diff -c -p -r1.5 generic.h
*** sid/component/memory/generic.h	3 Aug 2001 06:02:46 -0000	1.5
--- sid/component/memory/generic.h	21 Oct 2003 19:16:36 -0000
*************** private:
*** 100,105 ****
--- 100,108 ----
  
    host_int_2 read_latency;
    host_int_2 write_latency;
+   host_int_4 base_address;
+   bool warn_rom_write;
+   bool allow_rom_write;
  
    string image_file_name;
    callback_pin<generic_memory> imageload_pin;
*************** public:
*** 125,131 ****
    // some macros to make manufacturing of the cartesian-product calls simpler
  #define SID_GB_WRITE(type2) \
        bus::status write(host_int_4 address, type2 data) throw () \
! 	  { return bus::unpermitted; } 
   
  #define SID_GB_READ(type2) \
        bus::status read(host_int_4 address, type2& data) throw () \
--- 128,141 ----
    // some macros to make manufacturing of the cartesian-product calls simpler
  #define SID_GB_WRITE(type2) \
        bus::status write(host_int_4 address, type2 data) throw () \
! 	  { if (! target->warn_rom_write && ! target->allow_rom_write) \
! 	       return bus::unpermitted;			\
! 	    cerr << "Warning: invalid write to ROM address 0x" << std::hex << target->base_address + address << endl; \
! 	    if (target->allow_rom_write)		\
! 	        return this->write_any(address,data);	\
! 	    else					\
! 		return bus::ok; }
! 
   
  #define SID_GB_READ(type2) \
        bus::status read(host_int_4 address, type2& data) throw () \
*************** protected:
*** 160,165 ****
--- 170,179 ----
    template <typename DataType>
    inline bus::status
    read_any(host_int_4 address, DataType& data);
+ 
+   template <typename DataType>
+   inline bus::status
+   write_any(host_int_4 address, DataType data);
  };
  
  
*************** public:
*** 190,200 ****
      SID_GB_WRITE(big_int_8);
        
  #undef SID_GB_WRITE
- 
- protected:
-   template <typename DataType>
-   inline bus::status
-   write_any(host_int_4 address, DataType data);
  };
  
  
--- 204,209 ----
*************** protected:
*** 203,209 ****
  
  template <typename DataType>
  inline bus::status
! generic_read_write_bus::write_any(host_int_4 address, DataType data)
  {
    const unsigned width = sizeof(typename DataType::value_type); 
  
--- 212,218 ----
  
  template <typename DataType>
  inline bus::status
! generic_read_only_bus::write_any(host_int_4 address, DataType data)
  {
    const unsigned width = sizeof(typename DataType::value_type); 
  

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch][rfa] generic memory enhancements
  2003-10-21 19:58 [patch][rfa] generic memory enhancements Dave Brolley
@ 2003-10-21 22:14 ` Dave Brolley
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Brolley @ 2003-10-21 22:14 UTC (permalink / raw)
  To: Dave Brolley; +Cc: sid

This patch is postponed pending a better implementation.

Dave Brolley wrote:

> Hi,
>
> This patch enhances generic memory in several ways:
>
> 1) It allows writes to readonly memory if the attribute 
> "allow-write-to-rom" is set
> 2) It warns about write to rom if "warn-write-to-rom" is set
> 3) It allows the base address of the memory to be specified via the 
> "base-address" attribute for use in generated warnings.
>
> ok to commit?
>
> Dave
>
>------------------------------------------------------------------------
>
>2003-10-07  Dave Brolley  <brolley@redhat.com>
>
>	For Stan Cox  <scox@redhat.com>
>	* generic.h (SID_GB_WRITE): allow_rom_write implies warn_rom_write.
>
>2003-10-07  Dave Brolley  <brolley@redhat.com>
>
>	For Stan Cox  <scox@redhat.com>
>	* generic.h (generic_memory): New member allow_rom_write.
>	(SID_GB_WRITE): Use it.
>	* generic.cxx (generic_memory): Initialize it.
>
>2003-10-07  Dave Brolley  <brolley@redhat.com>
>
>	* generic.h (generic_read_write_bus::write_any): Move to
>	generic_read_only_bus.
>	(generic_read_only_bus::SID_GB_WRITE): Allow write to read-only-port
>	with a warning if ignore_rom_write is set.
>
>2003-10-07  Dave Brolley  <brolley@redhat.com>
>
>	* generic.h (generic_memory): New member: base_address.
>	(SID_GB_WRITE): Add target->base_address to the address printed.
>	* generic.cxx (generic_memory): Initialize base_address. Add
>	base-address attribute.
>
>2003-10-07  Dave Brolley  <brolley@redhat.com>
>
>	For Stan Cox  <scox@redhat.com>
>	* generic.cxx (generic_memory): New member ignore_rom_write.
>	* generic.h (generic_read_only_bus::SID_GB_WRITE): Use it.
>
>2003-10-07  Dave Brolley  <brolley@redhat.com>
>
>	For Frank Ch. Eigler  <fche@redhat.com>
>	* generic.cxx (generic_memory ctor): Add evil backdoor hack to
>	read memory buffer base/size via attributes.
>
>  
>
>------------------------------------------------------------------------
>
>Index: sid/component/memory/generic.cxx
>===================================================================
>RCS file: /cvs/src/src/sid/component/memory/generic.cxx,v
>retrieving revision 1.8
>diff -c -p -r1.8 generic.cxx
>*** sid/component/memory/generic.cxx	10 Jun 2003 18:27:10 -0000	1.8
>--- sid/component/memory/generic.cxx	21 Oct 2003 19:16:36 -0000
>***************
>*** 1,6 ****
>  // generic.cxx - a class of generic memories.  -*- C++ -*-
>  
>! // Copyright (C) 1999-2001,2003 Red Hat.
>  // This file is part of SID and is licensed under the GPL.
>  // See the file COPYING.SID for conditions for redistribution.
>  
>--- 1,6 ----
>  // generic.cxx - a class of generic memories.  -*- C++ -*-
>  
>! // Copyright (C) 1999-2003 Red Hat.
>  // This file is part of SID and is licensed under the GPL.
>  // See the file COPYING.SID for conditions for redistribution.
>  
>*************** generic_memory::generic_memory() throw (
>*** 55,61 ****
>    imagemmap_pin (this, & generic_memory::imagemmap_handler),
>    imagemsync_pin (this, & generic_memory::imagemsync_handler),
>    read_latency (0),
>!   write_latency (0)
>  {
>    this->max_buffer_length = 32UL * 1024UL * 1024UL;
>    this->buffer = 0;
>--- 55,64 ----
>    imagemmap_pin (this, & generic_memory::imagemmap_handler),
>    imagemsync_pin (this, & generic_memory::imagemsync_handler),
>    read_latency (0),
>!   write_latency (0),
>!   base_address (0),
>!   warn_rom_write (false),
>!   allow_rom_write (false)
>  {
>    this->max_buffer_length = 32UL * 1024UL * 1024UL;
>    this->buffer = 0;
>*************** generic_memory::generic_memory() throw (
>*** 82,87 ****
>--- 85,98 ----
>  
>    add_attribute ("read-latency", & this->read_latency, "setting");
>    add_attribute ("write-latency", & this->write_latency, "setting");
>+   add_attribute ("base-address", & this->base_address, "setting");
>+ 
>+   add_attribute ("warn-rom-write-option?", & this->warn_rom_write, "setting");
>+   add_attribute ("allow-rom-write-option?", & this->allow_rom_write, "setting");
>+ 
>+   // Undocumented, dangerous, do not use ...
>+   add_attribute_ro ("buffer-base-UNSAFE", (host_int_4*) & this->buffer);
>+   add_attribute_ro ("buffer-length-UNSAFE", & this->buffer_length);
>  
>    add_attribute_virtual ("state-snapshot", this,
>  			 & generic_memory::save_state,
>Index: sid/component/memory/generic.h
>===================================================================
>RCS file: /cvs/src/src/sid/component/memory/generic.h,v
>retrieving revision 1.5
>diff -c -p -r1.5 generic.h
>*** sid/component/memory/generic.h	3 Aug 2001 06:02:46 -0000	1.5
>--- sid/component/memory/generic.h	21 Oct 2003 19:16:36 -0000
>*************** private:
>*** 100,105 ****
>--- 100,108 ----
>  
>    host_int_2 read_latency;
>    host_int_2 write_latency;
>+   host_int_4 base_address;
>+   bool warn_rom_write;
>+   bool allow_rom_write;
>  
>    string image_file_name;
>    callback_pin<generic_memory> imageload_pin;
>*************** public:
>*** 125,131 ****
>    // some macros to make manufacturing of the cartesian-product calls simpler
>  #define SID_GB_WRITE(type2) \
>        bus::status write(host_int_4 address, type2 data) throw () \
>! 	  { return bus::unpermitted; } 
>   
>  #define SID_GB_READ(type2) \
>        bus::status read(host_int_4 address, type2& data) throw () \
>--- 128,141 ----
>    // some macros to make manufacturing of the cartesian-product calls simpler
>  #define SID_GB_WRITE(type2) \
>        bus::status write(host_int_4 address, type2 data) throw () \
>! 	  { if (! target->warn_rom_write && ! target->allow_rom_write) \
>! 	       return bus::unpermitted;			\
>! 	    cerr << "Warning: invalid write to ROM address 0x" << std::hex << target->base_address + address << endl; \
>! 	    if (target->allow_rom_write)		\
>! 	        return this->write_any(address,data);	\
>! 	    else					\
>! 		return bus::ok; }
>! 
>   
>  #define SID_GB_READ(type2) \
>        bus::status read(host_int_4 address, type2& data) throw () \
>*************** protected:
>*** 160,165 ****
>--- 170,179 ----
>    template <typename DataType>
>    inline bus::status
>    read_any(host_int_4 address, DataType& data);
>+ 
>+   template <typename DataType>
>+   inline bus::status
>+   write_any(host_int_4 address, DataType data);
>  };
>  
>  
>*************** public:
>*** 190,200 ****
>      SID_GB_WRITE(big_int_8);
>        
>  #undef SID_GB_WRITE
>- 
>- protected:
>-   template <typename DataType>
>-   inline bus::status
>-   write_any(host_int_4 address, DataType data);
>  };
>  
>  
>--- 204,209 ----
>*************** protected:
>*** 203,209 ****
>  
>  template <typename DataType>
>  inline bus::status
>! generic_read_write_bus::write_any(host_int_4 address, DataType data)
>  {
>    const unsigned width = sizeof(typename DataType::value_type); 
>  
>--- 212,218 ----
>  
>  template <typename DataType>
>  inline bus::status
>! generic_read_only_bus::write_any(host_int_4 address, DataType data)
>  {
>    const unsigned width = sizeof(typename DataType::value_type); 
>  
>  
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-21 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-21 19:58 [patch][rfa] generic memory enhancements Dave Brolley
2003-10-21 22:14 ` Dave Brolley

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).