project64/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h

84 lines
2.3 KiB
C
Raw Normal View History

#pragma once
#include <Project64-core\Settings\GameSettings.h>
#include <Project64-core\Settings\DebugSettings.h>
#include <Project64-core\Logging.h>
#include "MemoryHandler.h"
#include <stdint.h>
class PeripheralInterfaceReg
{
protected:
PeripheralInterfaceReg(uint32_t * PeripheralInterface);
public:
uint32_t & PI_DRAM_ADDR_REG;
uint32_t & PI_CART_ADDR_REG;
uint32_t & PI_RD_LEN_REG;
uint32_t & PI_WR_LEN_REG;
uint32_t & PI_STATUS_REG;
uint32_t & PI_BSD_DOM1_LAT_REG;
uint32_t & PI_DOMAIN1_REG;
uint32_t & PI_BSD_DOM1_PWD_REG;
uint32_t & PI_BSD_DOM1_PGS_REG;
uint32_t & PI_BSD_DOM1_RLS_REG;
uint32_t & PI_BSD_DOM2_LAT_REG;
uint32_t & PI_DOMAIN2_REG;
uint32_t & PI_BSD_DOM2_PWD_REG;
uint32_t & PI_BSD_DOM2_PGS_REG;
uint32_t & PI_BSD_DOM2_RLS_REG;
private:
PeripheralInterfaceReg();
PeripheralInterfaceReg(const PeripheralInterfaceReg&);
PeripheralInterfaceReg& operator=(const PeripheralInterfaceReg&);
};
class CRegisters;
class CMipsMemoryVM;
class CartridgeDomain2Address2Handler;
2022-07-04 07:44:27 +00:00
// Peripheral interface flags
enum
{
PI_STATUS_DMA_BUSY = 0x01,
PI_STATUS_IO_BUSY = 0x02,
PI_STATUS_ERROR = 0x04,
PI_STATUS_INTERRUPT = 0x08,
PI_SET_RESET = 0x01,
PI_CLR_INTR = 0x02,
};
class PeripheralInterfaceHandler :
public MemoryHandler,
private CGameSettings,
private CDebugSettings,
private CLogging,
2022-07-04 07:44:27 +00:00
private PeripheralInterfaceReg,
private MIPSInterfaceReg
{
public:
2022-07-04 07:44:27 +00:00
PeripheralInterfaceHandler(CN64System & System, CMipsMemoryVM & MMU, CRegisters & Reg, CartridgeDomain2Address2Handler & Domain2Address2Handler);
2022-02-21 11:26:25 +00:00
bool Read32(uint32_t Address, uint32_t & Value);
bool Write32(uint32_t Address, uint32_t Value, uint32_t Mask);
private:
PeripheralInterfaceHandler();
PeripheralInterfaceHandler(const PeripheralInterfaceHandler &);
PeripheralInterfaceHandler & operator=(const PeripheralInterfaceHandler &);
2022-07-04 07:44:27 +00:00
static void stSystemReset(PeripheralInterfaceHandler * _this) { _this->SystemReset(); }
void PI_DMA_READ();
void PI_DMA_WRITE();
2022-07-04 07:44:27 +00:00
void SystemReset(void);
void OnFirstDMA();
2022-07-04 07:44:27 +00:00
void ReadBlock(uint32_t Address, uint8_t * Block, uint32_t BlockLen);
CartridgeDomain2Address2Handler & m_Domain2Address2Handler;
CMipsMemoryVM & m_MMU;
CRegisters & m_Reg;
uint32_t & m_PC;
};