Commit Graph

79 Commits

Author SHA1 Message Date
AJR
eb1b8e58e2 emumem: Allow an address shift of 1 (to the right) for 8-bit spaces (nw) 2019-03-01 19:05:45 -05:00
AJR
50f045ba74 Eliminate the default address map member of address_space_config (nw)
Since all device address maps are now class methods defined in ordinary C++, default RAM maps can be provided more simply with an explicit has_configured_map check in an internal map definition.

A number of default address maps that probably weren't meant to be overridden have also been changed to ordinary internal maps.
2019-02-17 11:50:17 -05:00
Olivier Galibert
a9e6f19320 emumem: remove m_baseptr, may fix the save state issues [O. Galibert] 2018-12-20 20:25:33 +01:00
mooglyguy
bf0cfcf13d -keyboard/a1200, changela, goldnpkr, m68705prg, mexico86, pipeline, pitnrun, qix, quizpun2, stfight, tigeroad: Removed MACHINE_CONFIG. [Ryan Holtz]
-m68705, m68hc05: Removed MCFG. [Ryan Holtz]

-qix: First-pass cleanup. [Ryan Holtz]

-core: Fixed spelling of "nonexistent". [Ryan Holtz]
2018-12-14 23:45:04 +01:00
AJR
969175269d Invalidate memory access caches when removing watchpoints to prevent crashes on subsequent accesses to the same memory areas 2018-10-23 09:04:25 -04:00
Vas Crabb
250c06a4d7 srcclean (nw) 2018-09-23 12:22:35 +10:00
Olivier Galibert
dd64cdceee emumem: Fix ioports/membanks in internal maps [O. Galibert]
PS: That may break things, we'll see.
2018-08-26 10:36:30 +02:00
AJR
ac355d1559 Apply logical address mask properly in debug disassembly view
Associated core changes (nw)
- Move definition of address_space_config from dimemory.cpp to emumem.cpp (declaration was already in emumem.h)
- Add getters for more members of address_space_config with future privatization in mind (nw)
2018-08-24 22:20:54 -04:00
Olivier Galibert
e78ca34bac memory,devcb: Put capabilities at parity [O. Galibert] 2018-08-10 09:47:03 +02:00
Olivier Galibert
639c9b85fc memory: Allow simplified versions of handlers [O. Galibert]
A standard memory handler has as a prototype (where uX = u8, u16, u32 or u64):
  uX device::read(address_space &space, offs_t offset, uX mem_mask);
  void device::write(address_space &space, offs_t offset, uX data, uX mem_mask);

We now allow simplified versions which are:
  uX device::read(offs_t offset, uX mem_mask);
  void device::write(offs_t offset, uX data, uX mem_mask);

  uX device::read(offs_t offset);
  void device::write(offs_t offset, uX data);

  uX device::read();
  void device::write(uX data);

Use them at will.  Also consider
(DECLARE_)(READ|WRITE)(8|16|32|64)_MEMBER on the way out, use the
explicit prototypes.

Same for lambdas in the memory map, the parameters are now optional
following the same combinations.
2018-08-02 21:08:47 +02:00
Vas Crabb
c0ab1c5aa4 (nw) srcclean and some cleanup:
* Make more #include guards follow standard format - using MAME_ as the prefix makes it easy to see which ones come from our code in a preprocessor dump, and having both src/devices/machine/foo.h and src/mame/machine/foo.h causes issues anyway
* Get #include "emu.h" out of headers - it should only be the first thing in a complilation unit or we get differences in behaviour with PCH on/off
* Add out-of-line destructors to some devices - it forces the compiler to instantiate the vtable in a certain location and avoids some non-deterministic compiler behaviours
2018-07-22 20:41:57 +10:00
AJR
7c18a71442 A better way to make friends (nw) 2018-06-29 18:29:37 -04:00
Olivier Galibert
a704ed7b1b emumem: Backend modernization [O. Galibert] 2018-06-29 20:04:28 +02:00
Olivier Galibert
4c24f25845 emumem: Rename direct_read_handler to memory_access_cache. Parametrize the template on more information (data width, endianness) to make it possible to turn it into an handler cache eventually, and not just a memory block cache. Make it capable of large and unaligned accesses. [O. Galibert] 2018-05-11 18:23:04 +09:00
AJR
daec5f3639 Relax constraints on address mirroring/global mask combinations. Mirror bits are now allowed to fall outside the driver-specified global mask, though memory map validation requires that they cover the entire masked-out portions of the address space if any do.
This change is intended to expedite debugging of software written for the TMPZ84C015 or similar Z80-based controllers which use 8-bit I/O addressing for the on-chip peripherals but may use either 8-bit or 16-bit addressing externally.
2018-04-11 10:04:31 -04:00
smf-
8ebd748b1b Fix fencepost in memory_manager::region_containing, which caused regions to be registered for state saving. [smf] 2018-04-07 08:55:53 +01:00
Olivier Galibert
12b5454a27 Now that was a subtle one... (nw) 2018-04-05 15:58:14 +02:00
Olivier Galibert
c5345b9ea8 Grammar police (nw) 2018-02-24 14:09:46 +01:00
AJR
c12f2ee58d Set up heavily mirrored memory ranges with subunit masks (e.g. orunners) much more efficiently 2018-02-15 22:04:17 -05:00
ajrhacker
5386ad7284 Generalized support for byte-smeared accesses (nw) (#3207)
The new cswidth address map constructor method overrides the masking normally performed on narrow-width accesses. This entailed a lot of reconfiguration to make the shifting and masking of subunits independent operations. There is unlikely to have any significant performance impact on drivers that don't frequently reconfigure their memory handlers.
2018-02-15 06:43:57 +01:00
Olivier Galibert
c521964316 API change: Memory maps are now methods of the owner class [O. Galibert]
Also, a lot more freedom happened, that's going to be more visible
soon.
2018-02-12 10:04:52 +01:00
Olivier Galibert
870695380c Head, meet desk (nw) 2018-02-07 16:53:06 +01:00
Olivier Galibert
2b13112e7a Renju fix, that one was a nightmare (nw) 2018-02-07 11:52:39 +01:00
Olivier Galibert
127cd08d4d API change: Memory maps are now "last entry wins" [O. Galibert]
This allows for the much more natural "import another map and patch
it" structure, or "cover a whole region then punch holes in it".  Our
previous first-entry-wins rule was always a surprise to newcomers, and
oldcomers too.
2018-01-31 22:03:00 +01:00
Vas Crabb
25f84e3bf0 srcclean and manual cleanups (nw)
please people, remember to keep source UTF-8 and if you're committing on behalf of others, clean up indents to meet MAME conventions
anyone can run srcclean over a submission and see what will get hit
2017-12-24 15:03:04 +11:00
smf-
09539116b5 we're all friends (nw) 2017-12-15 11:37:15 +00:00
AJR
39c59a5041 Remove machine member of address_space (nw) 2017-12-14 22:14:46 -05:00
smf-
49b83056b1 another example of m_machine(machine()) (nw) 2017-12-14 23:27:03 +00:00
smf-
ed2502fb4b replacing space.machine() with machine() has some interesting consequences (nw)
m_machine(space.machine())
running_machine &machine() const { return m_machine; }
2017-12-14 22:02:09 +00:00
Olivier Galibert
bd5b00af5f space.machine -> machine (nw) 2017-12-14 18:37:10 +01:00
Firehawke
9ece34eb21 Revert "Revert "Merge branch 'master' of https://github.com/mamedev/mame""
This reverts commit 54155441e9.
2017-12-13 21:31:27 -07:00
Firehawke
54155441e9 Revert "Merge branch 'master' of https://github.com/mamedev/mame"
This reverts commit f537428e5a, reversing
changes made to 0d70d79810.
2017-12-13 21:01:10 -07:00
Olivier Galibert
4f90cbd744 Watchpoint fixes (nw) 2017-12-03 16:38:53 +01:00
Vas Crabb
f88769555b constexpr implies inline, generalise iabs, work around lack of C++14 constexpr in VS2015 (nw) 2017-12-01 23:45:11 +11:00
Olivier Galibert
7c8a1fa409 Pet peeving with extreme prejudice (nw) 2017-11-30 12:29:32 +01:00
Olivier Galibert
0584df8b9c fixes (nw) 2017-11-30 08:12:28 +01:00
smf-
57cdf5a9d8 fix for Visual Studio 2017 (nw) 2017-11-29 12:30:09 +00:00
Olivier Galibert
c46e1007a8 emumem: API change [O. Galibert]
* direct_read_data is now a template which takes the address bus shift
  as a parameter.

* address_space::direct<shift>() is now a template method that takes
  the shift as a parameter and returns a pointer instead of a
  reference

* the address to give to {read|write}_* on address_space or
  direct_read_data is now the address one wants to access

Longer explanation:

Up until now, the {read|write}_* methods required the caller to give
the byte offset instead of the actual address.  That's the same on
byte-addressing CPUs, e.g. the ones everyone knows, but it's different
on the word/long/quad addressing ones (tms, sharc, etc...) or the
bit-addressing one (tms340x0).  Changing that required templatizing
the direct access interface on the bus addressing granularity,
historically called address bus shift.  Also, since everybody was
taking the address of the reference returned by direct(), and
structurally didn't have much choice in the matter, it got changed to
return a pointer directly.

Longest historical explanation:

In a cpu core, the hottest memory access, by far, is the opcode
fetching.  It's also an access with very good locality (doesn't move
much, tends to stay in the same rom/ram zone even when jumping around,
tends not to hit handlers), which makes efficient caching worthwhile
(as in, 30-50% faster core iirc on something like the 6502, but that
was 20 years ago and a number of things changed since then).  In fact,
opcode fetching was, in the distant past, just an array lookup indexed
by pc on an offset pointer, which was updated on branches.  It didn't
stay that way because more elaborate access is often needed (handlers,
banking with instructions crossing a bank...) but it still ends up with
a frontend of "if the address is still in the current range read from
pointer+address otherwise do the slowpath", e.g. two usually correctly
predicted branches plus the read most of the time.

Then the >8 bits cpus arrived.  That was ok, it just required to do
the add to a u8 *, then convert to a u16/u32 * and do the read.  At
the asm level, it was all identical except for the final read, and
read_byte/word/long being separate there was no test (and associated
overhead) added in the path.

Then the word-addressing CPUs arrived with, iirc, the tms cpus used in
atari games.  They require, to read from the pointer, to shift the
address, either explicitely, or implicitely through indexing a u16 *.
There were three possibilities:

1- create a new read_* method for each size and granularity.  That
   amounts to a lot of copy/paste in the end, and functions with
   identical prototypes so the compiler can't detect you're using the
   wrong one.

2- put a variable shift in the read path.  That was too expensive
   especially since the most critical cpus are byte-addressing (68000 at
   the time was the key).  Having bit-adressing cpus which means the
   shift can either be right or left depending on the variable makes
   things even worse.

3- require the caller to do the shift himself when needed.

The last solution was chosen, and starting that day the address was a
byte offset and not the real address.  Which is, actually, quite
surprising when writing a new cpu core or, worse, when using the
read/write methods from the driver code.

But since then, C++ happened.  And, in particular, templates with
non-type parameters.  Suddendly, solution 1 can be done without the
copy/paste and with different types allowing to detect (at runtime,
but systematically and at startup) if you got it wrong, while still
generating optimal code.  So it was time to switch to that solution
and makes the address parameter sane again.  Especially since it makes
mucking in the rest of the memory subsystem code a lot more
understandable.
2017-11-29 10:32:31 +01:00
Vas Crabb
17790b2f5f forgot these (nw) 2017-07-13 15:54:28 +10:00
Vas Crabb
7718fe042c kill a trampoline (nw) 2017-07-13 15:51:33 +10:00
Vas Crabb
66de90675f Make device_memory_interface own its address_spaces 2017-07-13 15:35:18 +10:00
Vas Crabb
536b2153d9 make device_memory_interface slightly less of a special case, use a typedef to avoid nested templates everywhere (nw) 2017-07-10 19:35:07 +10:00
Olivier Galibert
92ef0f292c Initialization ordering fixes (nw) 2017-07-03 22:22:22 +02:00
Olivier Galibert
cbbbd07484 dimemory: Lift the cap on the number of address spaces per device [O. Galibert] 2017-07-03 08:03:57 +02:00
Nathan Woods
c192588f61 Changed 'enum read_or_write' to be 'enum class' 2017-06-19 10:37:03 +10:00
Vas Crabb
96c9112785 general cleanup:
* move rarely-used output and pty interfaces out of emu.h
* consolidate and de-duplicate forward declarations, also remove some obsolete ones
* clean up more #include guard macros
* scope down a few more things

(nw) Everyone, please keep forward declarations for src/emu in src/emu/emufwd.h -
this will make it far easier to keep them in sync with declarations than having
them scattered through all the other files.
2017-05-23 15:01:11 +10:00
AJR
f4fb3436fe This is now totally fatal, so use a proper error message (nw) 2017-05-06 01:15:59 -04:00
AJR
902d2d924b NPOT subunit compromise (nw)
Handlers with a non-power-of-2 number of subunits are allowed once again. However, the offset multiplier will be rounded up to the nearest power of 2.
2017-04-28 12:23:49 -04:00
AJR
78343b2786 Finish removing direct_update from the core (nw) 2017-04-01 18:20:50 -04:00
Olivier Galibert
5769f31c7d This is Sparta ! 2017-04-01 22:39:35 +02:00