summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2020-05-25 16:42:42 +0200
committer Olivier Galibert <galibert@pobox.com>2020-05-25 16:42:57 +0200
commit22513fb6fe281f5ccb75aaddb6417a12a66c313d (patch)
tree3cf84032cc6482d685a8dbb57e015bd17c7f7fdc /src/devices/machine
parente42c2d2874cf9c1092c01ab5ce9ef997d465ce25 (diff)
emumem: A little more speedup. cache and specific change syntax, and are not pointers anymore [O. Galibert]
The last(?) two changes are: - Add a template parameter to everything (theoretically the address space width, in practice a level derived from it to keep as much compatibility between widths as possible) so that the shift size becomes a constant. - Change the syntax of declaring and initializing the caches and specifics so that they're embedded in the owner device. Solves lifetime issues and also removes one indirection (looking up the base dispatch pointer through the cache/specific pointer).
Diffstat (limited to 'src/devices/machine')
-rw-r--r--src/devices/machine/68307.cpp19
-rw-r--r--src/devices/machine/mc68328.cpp3
-rw-r--r--src/devices/machine/ripple_counter.cpp2
-rw-r--r--src/devices/machine/ripple_counter.h6
-rw-r--r--src/devices/machine/s3c2400.h3
-rw-r--r--src/devices/machine/s3c2410.h3
-rw-r--r--src/devices/machine/s3c2440.h3
-rw-r--r--src/devices/machine/s3c24xx.hxx30
-rw-r--r--src/devices/machine/s3c44b0.cpp14
-rw-r--r--src/devices/machine/s3c44b0.h2
-rw-r--r--src/devices/machine/s_smp.cpp5
-rw-r--r--src/devices/machine/s_smp.h8
12 files changed, 48 insertions, 50 deletions
diff --git a/src/devices/machine/68307.cpp b/src/devices/machine/68307.cpp
index 70992f45b07..7419b58937c 100644
--- a/src/devices/machine/68307.cpp
+++ b/src/devices/machine/68307.cpp
@@ -130,15 +130,16 @@ inline int m68307_cpu_device::calc_cs(offs_t address) const
void m68307_cpu_device::init16_m68307(address_space &space)
{
m_space = &space;
- auto cache = space.cache<1, 0, ENDIANNESS_BIG>();
-
- m_readimm16 = [cache](offs_t address) -> u16 { /* m_m68307_currentcs = calc_cs(address); */ return cache->read_word(address); };
- m_read8 = [this](offs_t address) -> u8 { /* m_m68307_currentcs = calc_cs(address); */ return m_space->read_byte(address); };
- m_read16 = [this](offs_t address) -> u16 { /* m_m68307_currentcs = calc_cs(address); */ return m_space->read_word(address); };
- m_read32 = [this](offs_t address) -> u32 { /* m_m68307_currentcs = calc_cs(address); */ return m_space->read_dword(address); };
- m_write8 = [this](offs_t address, u8 data) { /* m_m68307_currentcs = calc_cs(address); */ m_space->write_byte(address, data); };
- m_write16 = [this](offs_t address, u16 data) { /* m_m68307_currentcs = calc_cs(address); */ m_space->write_word(address, data); };
- m_write32 = [this](offs_t address, u32 data) { /* m_m68307_currentcs = calc_cs(address); */ m_space->write_dword(address, data); };
+ space.cache(m_oprogram16);
+ space.specific(m_program16);
+
+ m_readimm16 = [this](offs_t address) -> u16 { /* m_m68307_currentcs = calc_cs(address); */ return m_oprogram16.read_word(address); };
+ m_read8 = [this](offs_t address) -> u8 { /* m_m68307_currentcs = calc_cs(address); */ return m_program16.read_byte(address); };
+ m_read16 = [this](offs_t address) -> u16 { /* m_m68307_currentcs = calc_cs(address); */ return m_program16.read_word(address); };
+ m_read32 = [this](offs_t address) -> u32 { /* m_m68307_currentcs = calc_cs(address); */ return m_program16.read_dword(address); };
+ m_write8 = [this](offs_t address, u8 data) { /* m_m68307_currentcs = calc_cs(address); */ m_program16.write_byte(address, data); };
+ m_write16 = [this](offs_t address, u16 data) { /* m_m68307_currentcs = calc_cs(address); */ m_program16.write_word(address, data); };
+ m_write32 = [this](offs_t address, u32 data) { /* m_m68307_currentcs = calc_cs(address); */ m_program16.write_dword(address, data); };
}
diff --git a/src/devices/machine/mc68328.cpp b/src/devices/machine/mc68328.cpp
index 4b9e9a8b97e..3df500d2f0c 100644
--- a/src/devices/machine/mc68328.cpp
+++ b/src/devices/machine/mc68328.cpp
@@ -3043,7 +3043,6 @@ uint16_t mc68328_device::internal_read(offs_t offset, uint16_t mem_mask)
/* THIS IS PRETTY MUCH TOTALLY WRONG AND DOESN'T REFLECT THE MC68328'S INTERNAL FUNCTIONALITY AT ALL! */
uint32_t mc68328_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- auto mcache = space(AS_PROGRAM).cache<1, 0, ENDIANNESS_BIG>();
uint32_t vram_addr = m_regs.lssa & 0x00fffffe;
uint16_t word;
uint16_t *line;
@@ -3057,7 +3056,7 @@ uint32_t mc68328_device::screen_update(screen_device &screen, bitmap_ind16 &bitm
for (x = 0; x < 160; x += 16, vram_addr += 2)
{
- word = mcache->read_word(vram_addr);
+ word = space(AS_PROGRAM).read_word(vram_addr);
for (b = 0; b < 16; b++)
{
line[x + b] = (word >> (15 - b)) & 0x0001;
diff --git a/src/devices/machine/ripple_counter.cpp b/src/devices/machine/ripple_counter.cpp
index ec0808181ff..96ce53aeec6 100644
--- a/src/devices/machine/ripple_counter.cpp
+++ b/src/devices/machine/ripple_counter.cpp
@@ -35,7 +35,7 @@ DEFINE_DEVICE_TYPE(RIPPLE_COUNTER, ripple_counter_device, "ripple_counter", "Gen
ripple_counter_device::ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, RIPPLE_COUNTER, tag, owner, clock),
- device_rom_interface(mconfig, *this, 0, ENDIANNESS_LITTLE, 8),
+ device_rom_interface(mconfig, *this),
m_count_out_cb(*this),
m_rom_out_cb(*this),
m_count_timer(nullptr),
diff --git a/src/devices/machine/ripple_counter.h b/src/devices/machine/ripple_counter.h
index 5a4ad3e1295..450dc2118bb 100644
--- a/src/devices/machine/ripple_counter.h
+++ b/src/devices/machine/ripple_counter.h
@@ -11,20 +11,22 @@
#pragma once
+#include "dirom.h"
+
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> ripple_counter_device
-class ripple_counter_device : public device_t, public device_rom_interface
+class ripple_counter_device : public device_t, public device_rom_interface<14>
{
public:
// construction/destruction
ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
// configuration
- void set_stages(u8 stages) { m_count_mask = (1U << stages) - 1; set_rom_addr_width(stages); }
+ void set_stages(u8 stages) { m_count_mask = (1U << stages) - 1; override_address_width(stages); }
auto count_out_cb() { return m_count_out_cb.bind(); }
auto rom_out_cb() { return m_rom_out_cb.bind(); }
diff --git a/src/devices/machine/s3c2400.h b/src/devices/machine/s3c2400.h
index 8ffff4968ff..6c5bdf4d40f 100644
--- a/src/devices/machine/s3c2400.h
+++ b/src/devices/machine/s3c2400.h
@@ -454,8 +454,7 @@ private:
required_device<arm7_cpu_device> m_cpu;
required_device<palette_device> m_palette;
required_device<screen_device> m_screen;
-
- memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache;
+ memory_access<24, 2, 0, ENDIANNESS_LITTLE>::cache m_cache;
memcon_t m_memcon;
usbhost_t m_usbhost;
diff --git a/src/devices/machine/s3c2410.h b/src/devices/machine/s3c2410.h
index dd87eba239f..9c270d5802f 100644
--- a/src/devices/machine/s3c2410.h
+++ b/src/devices/machine/s3c2410.h
@@ -562,8 +562,7 @@ private:
required_device<arm7_cpu_device> m_cpu;
required_device<palette_device> m_palette;
required_device<screen_device> m_screen;
-
- memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache;
+ memory_access<24, 2, 0, ENDIANNESS_LITTLE>::cache m_cache;
uint8_t m_steppingstone[4*1024];
memcon_t m_memcon;
diff --git a/src/devices/machine/s3c2440.h b/src/devices/machine/s3c2440.h
index 40a92776c3f..9c3cfa9c337 100644
--- a/src/devices/machine/s3c2440.h
+++ b/src/devices/machine/s3c2440.h
@@ -607,8 +607,7 @@ private:
required_device<arm7_cpu_device> m_cpu;
required_device<palette_device> m_palette;
required_device<screen_device> m_screen;
-
- memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache;
+ memory_access<24, 2, 0, ENDIANNESS_LITTLE>::cache m_cache;
uint8_t m_steppingstone[4*1024];
memcon_t m_memcon;
diff --git a/src/devices/machine/s3c24xx.hxx b/src/devices/machine/s3c24xx.hxx
index 603ee085b1b..707daa62318 100644
--- a/src/devices/machine/s3c24xx.hxx
+++ b/src/devices/machine/s3c24xx.hxx
@@ -292,8 +292,8 @@ uint32_t S3C24_CLASS_NAME::s3c24xx_lcd_dma_read()
uint8_t data[4];
for (int i = 0; i < 2; i++)
{
- data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 0);
- data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 1);
+ data[i*2+0] = m_cache.read_byte(m_lcd.vramaddr_cur + 0);
+ data[i*2+1] = m_cache.read_byte(m_lcd.vramaddr_cur + 1);
m_lcd.vramaddr_cur += 2;
m_lcd.pagewidth_cur++;
if (m_lcd.pagewidth_cur >= m_lcd.pagewidth_max)
@@ -338,39 +338,39 @@ uint32_t S3C24_CLASS_NAME::s3c24xx_lcd_dma_read()
{
if ((m_lcd.vramaddr_cur & 2) == 0)
{
- data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 3);
- data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 2);
+ data[i*2+0] = m_cache.read_byte(m_lcd.vramaddr_cur + 3);
+ data[i*2+1] = m_cache.read_byte(m_lcd.vramaddr_cur + 2);
}
else
{
- data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur - 1);
- data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur - 2);
+ data[i*2+0] = m_cache.read_byte(m_lcd.vramaddr_cur - 1);
+ data[i*2+1] = m_cache.read_byte(m_lcd.vramaddr_cur - 2);
}
}
else
{
- data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 0);
- data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 1);
+ data[i*2+0] = m_cache.read_byte(m_lcd.vramaddr_cur + 0);
+ data[i*2+1] = m_cache.read_byte(m_lcd.vramaddr_cur + 1);
}
}
else
{
if (m_lcd.bswp == 0)
{
- data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 1);
- data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 0);
+ data[i*2+0] = m_cache.read_byte(m_lcd.vramaddr_cur + 1);
+ data[i*2+1] = m_cache.read_byte(m_lcd.vramaddr_cur + 0);
}
else
{
if ((m_lcd.vramaddr_cur & 2) == 0)
{
- data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 2);
- data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 3);
+ data[i*2+0] = m_cache.read_byte(m_lcd.vramaddr_cur + 2);
+ data[i*2+1] = m_cache.read_byte(m_lcd.vramaddr_cur + 3);
}
else
{
- data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur - 2);
- data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur - 1);
+ data[i*2+0] = m_cache.read_byte(m_lcd.vramaddr_cur - 2);
+ data[i*2+1] = m_cache.read_byte(m_lcd.vramaddr_cur - 1);
}
}
}
@@ -744,7 +744,7 @@ void S3C24_CLASS_NAME::s3c24xx_video_start()
m_lcd.bitmap[0] = std::make_unique<bitmap_rgb32>(m_screen->width(), m_screen->height());
m_lcd.bitmap[1] = std::make_unique<bitmap_rgb32>(m_screen->width(), m_screen->height());
- m_cache = m_cpu->space(AS_PROGRAM).cache<2, 0, ENDIANNESS_LITTLE>();
+ m_cpu->space(AS_PROGRAM).cache(m_cache);
}
void S3C24_CLASS_NAME::bitmap_blend( bitmap_rgb32 &bitmap_dst, bitmap_rgb32 &bitmap_src_1, bitmap_rgb32 &bitmap_src_2)
diff --git a/src/devices/machine/s3c44b0.cpp b/src/devices/machine/s3c44b0.cpp
index 8478f54bc58..009b400210e 100644
--- a/src/devices/machine/s3c44b0.cpp
+++ b/src/devices/machine/s3c44b0.cpp
@@ -264,7 +264,7 @@ void s3c44b0_device::device_start()
m_data_r_cb.resolve_safe(0);
m_data_w_cb.resolve();
- m_cache = m_cpu->space(AS_PROGRAM).cache<2, 0, ENDIANNESS_LITTLE>();
+ m_cpu->space(AS_PROGRAM).cache(m_cache);
for (int i = 0; i < 6; i++) m_pwm.timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::pwm_timer_exp),this));
for (auto & elem : m_uart) elem.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::uart_timer_exp),this));
@@ -543,19 +543,19 @@ void s3c44b0_device::lcd_dma_read(int count, uint8_t *data)
{
if ((m_lcd.vramaddr_cur & 2) == 0)
{
- data[0] = m_cache->read_byte(m_lcd.vramaddr_cur + 3);
- data[1] = m_cache->read_byte(m_lcd.vramaddr_cur + 2);
+ data[0] = m_cache.read_byte(m_lcd.vramaddr_cur + 3);
+ data[1] = m_cache.read_byte(m_lcd.vramaddr_cur + 2);
}
else
{
- data[0] = m_cache->read_byte(m_lcd.vramaddr_cur - 1);
- data[1] = m_cache->read_byte(m_lcd.vramaddr_cur - 2);
+ data[0] = m_cache.read_byte(m_lcd.vramaddr_cur - 1);
+ data[1] = m_cache.read_byte(m_lcd.vramaddr_cur - 2);
}
}
else
{
- data[0] = m_cache->read_byte(m_lcd.vramaddr_cur + 0);
- data[1] = m_cache->read_byte(m_lcd.vramaddr_cur + 1);
+ data[0] = m_cache.read_byte(m_lcd.vramaddr_cur + 0);
+ data[1] = m_cache.read_byte(m_lcd.vramaddr_cur + 1);
}
m_lcd.vramaddr_cur += 2;
m_lcd.pagewidth_cur++;
diff --git a/src/devices/machine/s3c44b0.h b/src/devices/machine/s3c44b0.h
index bebddc710ac..89dfa020920 100644
--- a/src/devices/machine/s3c44b0.h
+++ b/src/devices/machine/s3c44b0.h
@@ -600,7 +600,7 @@ private:
devcb_read32 m_data_r_cb;
devcb_write16 m_data_w_cb;
- memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache;
+ memory_access<32, 2, 0, ENDIANNESS_LITTLE>::cache m_cache;
};
DECLARE_DEVICE_TYPE(S3C44B0, s3c44b0_device)
diff --git a/src/devices/machine/s_smp.cpp b/src/devices/machine/s_smp.cpp
index d71b0449f65..fb4396b68d5 100644
--- a/src/devices/machine/s_smp.cpp
+++ b/src/devices/machine/s_smp.cpp
@@ -86,9 +86,8 @@ void s_smp_device::device_start()
m_dsp_io_r_cb.resolve_safe(0);
m_dsp_io_w_cb.resolve_safe();
- m_data = &space(AS_DATA);
- // Find our direct access
- m_dcache = m_data->cache<0, 0, ENDIANNESS_LITTLE>();
+ space(AS_DATA).specific(m_data);
+ space(AS_DATA).cache(m_dcache);
m_tick_timer = timer_alloc(TIMER_TICK_ID);
diff --git a/src/devices/machine/s_smp.h b/src/devices/machine/s_smp.h
index 5fe04b1880a..9fd0232329c 100644
--- a/src/devices/machine/s_smp.h
+++ b/src/devices/machine/s_smp.h
@@ -39,17 +39,17 @@ protected:
address_space_config m_data_config;
private:
- address_space *m_data;
- memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_dcache;
+ memory_access<16, 0, 0, ENDIANNESS_LITTLE>::cache m_dcache;
+ memory_access<16, 0, 0, ENDIANNESS_LITTLE>::specific m_data;
inline u8 data_read_byte(offs_t a)
{
/* IPL ROM enabled */
if (a >= 0xffc0 && m_ctrl & 0x80)
return m_ipl_region[a & 0x3f];
- return m_dcache->read_byte(a);
+ return m_dcache.read_byte(a);
}
- inline void data_write_byte(offs_t a, u8 d) { m_data->write_byte(a, d); }
+ inline void data_write_byte(offs_t a, u8 d) { m_data.write_byte(a, d); }
required_region_ptr<u8> m_ipl_region; /* SPC top 64 bytes */