mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00

and paths consistently for devices, I/O ports, memory regions, memory banks, and memory shares. [Aaron Giles] NOTE: there are likely regressions lurking here, mostly due to devices not being properly found. I have temporarily added more logging to -verbose to help understand what's going on. Please let me know ASAP if anything that is being actively worked on got broken. As before, the driver device is the root device and all other devices are owned by it. Previously all devices were kept in a single master list, and the hierarchy was purely logical. With this change, each device owns its own list of subdevices, and the hierarchy is explicitly manifest. This means when a device is removed, all of its subdevices are automatically removed as well. A side effect of this is that walking the device list is no longer simple. To address this, a new set of iterator classes is provided, which walks the device tree in a depth first manner. There is a general device_iterator class for walking all devices, plus templates for a device_type_iterator and a device_interface_iterator which are used to build iterators for identifying only devices of a given type or with a given interface. Typedefs for commonly-used cases (e.g., screen_device_iterator, memory_interface_iterator) are provided. Iterators can also provide counts, and can perform indexed lookups. All device name lookups are now done relative to another device. The maching_config and running_machine classes now have a root_device() method to get the root of the hierarchy. The existing machine->device("name") is now equivalent to machine->root_device().subdevice("name"). A proper and normalized device path structure is now supported. Device names that start with a colon are treated as absolute paths from the root device. Device names can also use a caret (^) to refer to the owning device. Querying the device's tag() returns the device's full path from the root. A new method basetag() returns just the final tag. The new pathing system is built on top of the device_t::subtag() method, so anyone using that will automatically support the new pathing rules. Each device has its own internal map to cache successful lookups so that subsequent lookups should be very fast. Updated every place I could find that referenced devices, memory regions, I/O ports, memory banks and memory shares to leverage subtag/subdevice (or siblingtag/siblingdevice which are built on top). Removed the device_list class, as it doesn't apply any more. Moved some of its methods into running_machine instead. Simplified the device callback system since the new pathing can describe all of the special-case devices that were previously handled manually. Changed the core output function callbacks to be delegates. Completely rewrote the validity checking mechanism. The validity checker is now a proper C++ class, and temporarily takes over the error and warning outputs. All errors and warnings are collected during a session, and then output in a consistent manner, with an explicit driver and source file listed for each one, as well as additional device and/or I/O port contexts where appropriate. Validity checkers should no longer explicitly output this information, just the error, assuming that the context is provided. Rewrote the software_list_device as a modern device, getting rid of the software_list_config abstraction and simplifying things. Changed the way FLAC compiles so that it works like other external libraries, and also compiles successfully for MSVC builds.
129 lines
3.2 KiB
C++
129 lines
3.2 KiB
C++
/***************************************************************************
|
|
|
|
i2cmem.h
|
|
|
|
I2C Memory
|
|
|
|
***************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
#ifndef __I2CMEM_H__
|
|
#define __I2CMEM_H__
|
|
|
|
|
|
/***************************************************************************
|
|
CONSTANTS
|
|
***************************************************************************/
|
|
|
|
#define I2CMEM_SLAVE_ADDRESS ( 0xa0 )
|
|
#define I2CMEM_SLAVE_ADDRESS_ALT ( 0xb0 )
|
|
|
|
|
|
//**************************************************************************
|
|
// INTERFACE CONFIGURATION MACROS
|
|
//**************************************************************************
|
|
|
|
#define MCFG_I2CMEM_ADD( _tag, _interface ) \
|
|
MCFG_DEVICE_ADD( _tag, I2CMEM, 0 ) \
|
|
i2cmem_device::static_set_interface(*device, _interface);
|
|
|
|
|
|
//**************************************************************************
|
|
// TYPE DEFINITIONS
|
|
//**************************************************************************
|
|
|
|
// ======================> i2cmem_interface
|
|
|
|
struct i2cmem_interface
|
|
{
|
|
int m_slave_address;
|
|
int m_page_size;
|
|
int m_data_size;
|
|
};
|
|
|
|
|
|
// ======================> i2cmem_device
|
|
|
|
class i2cmem_device :
|
|
public device_t,
|
|
public device_memory_interface,
|
|
public device_nvram_interface,
|
|
public i2cmem_interface
|
|
{
|
|
public:
|
|
// construction/destruction
|
|
i2cmem_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock );
|
|
|
|
// inline configuration
|
|
static void static_set_interface(device_t &device, const i2cmem_interface &interface);
|
|
|
|
// I/O operations
|
|
void set_e0_line( int state );
|
|
void set_e1_line( int state );
|
|
void set_e2_line( int state );
|
|
void set_sda_line( int state );
|
|
void set_scl_line( int state );
|
|
void set_wc_line( int state );
|
|
int read_sda_line();
|
|
|
|
protected:
|
|
// device-level overrides
|
|
virtual void device_config_complete();
|
|
virtual void device_validity_check(validity_checker &valid) const;
|
|
virtual void device_start();
|
|
virtual void device_reset();
|
|
|
|
// device_memory_interface overrides
|
|
virtual const address_space_config *memory_space_config( address_spacenum spacenum = AS_0 ) const;
|
|
|
|
// device_nvram_interface overrides
|
|
virtual void nvram_default();
|
|
virtual void nvram_read( emu_file &file );
|
|
virtual void nvram_write( emu_file &file );
|
|
|
|
// internal helpers
|
|
int address_mask();
|
|
int select_device();
|
|
int data_offset();
|
|
|
|
// device-specific configuration
|
|
address_space_config m_space_config;
|
|
int m_address_bits;
|
|
|
|
// internal state
|
|
int m_scl;
|
|
int m_sdaw;
|
|
int m_e0;
|
|
int m_e1;
|
|
int m_e2;
|
|
int m_wc;
|
|
int m_sdar;
|
|
int m_state;
|
|
int m_bits;
|
|
int m_shift;
|
|
int m_devsel;
|
|
int m_byteaddr;
|
|
UINT8 *m_page;
|
|
int m_page_offset;
|
|
};
|
|
|
|
|
|
// device type definition
|
|
extern const device_type I2CMEM;
|
|
|
|
|
|
//**************************************************************************
|
|
// READ/WRITE HANDLERS
|
|
//**************************************************************************
|
|
|
|
WRITE_LINE_DEVICE_HANDLER( i2cmem_e0_write );
|
|
WRITE_LINE_DEVICE_HANDLER( i2cmem_e1_write );
|
|
WRITE_LINE_DEVICE_HANDLER( i2cmem_e2_write );
|
|
WRITE_LINE_DEVICE_HANDLER( i2cmem_sda_write );
|
|
WRITE_LINE_DEVICE_HANDLER( i2cmem_scl_write );
|
|
WRITE_LINE_DEVICE_HANDLER( i2cmem_wc_write );
|
|
READ_LINE_DEVICE_HANDLER( i2cmem_sda_read );
|
|
|
|
#endif /* __I2CMEM_H__ */
|