WolPSX
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Bus Class Reference

Class to implement the Bus. More...

#include <bus.hpp>

Public Member Functions

 Bus (std::string bios_path)
 Construct a new Bus:: Bus object.
 
uint32_t read32_cpu (uint32_t addr)
 Reads a 32-bit word from the given address.
 
void write32_cpu (uint32_t addr, uint32_t data)
 Writes a 32-bit word to the given address.
 
uint16_t read16_cpu (uint32_t addr)
 Reads a 16-bit word from the given address.
 
void write16_cpu (uint32_t addr, uint16_t data)
 Writes a 16-bit word to the given address.
 
uint8_t read8_cpu (uint32_t addr)
 Reads a 8-bit word from the given address.
 
void write8_cpu (uint32_t addr, uint8_t data)
 Writes a 8-bit word to the given address.
 
void clock ()
 Clocks the PSX.
 

Private Member Functions

uint32_t region_mask (uint32_t addr)
 Returns the region mask for a given address.
 

Private Attributes

CPUcpu
 Pointer to the CPU object.
 
BIOSbios
 Pointer to the BIOS object.
 
RAMram
 Pointer to the RAM object.
 
Range bios_range = Range(BIOS_RANGE)
 Range of the BIOS.
 
Range mem_ctrl_range = Range(MEM_CTRL_RANGE)
 Range of the Memory Control Registers.
 
Range ram_size_range = Range(RAM_SIZE_RANGE)
 Range of the RAM Size Register.
 
Range cache_ctrl_range = Range(CACHE_CTRL_RANGE)
 Range of the Cache Control Register.
 
Range ram_range = Range(RAM_RANGE)
 Range of the RAM.
 
Range spu_range = Range(SPU_RANGE)
 Range of the SPU (Sound Processing Unit) Registers.
 
Range expansion2_range = Range(EXPANSION2_RANGE)
 Range of the Expansion 2.
 
Range expansion1_range = Range(EXPANSION1_RANGE)
 Range of the Expansion 1.
 
Range interrupt_range = Range(INTERRUPT_RANGE)
 Range of the Interrupt Registers.
 
Range timer_range = Range(TIMER_RANGE)
 Range of the Timer Registers.
 

Detailed Description

Class to implement the Bus.

Implements the Bus of the PSX. This is the central class that glues all the other components together. All communication between components (classes) is done through this class.

Definition at line 77 of file bus.hpp.

Constructor & Destructor Documentation

◆ Bus()

Bus::Bus ( std::string bios_path)

Construct a new Bus:: Bus object.

Parameters
bios_pathPath to the BIOS file

References: CPU::CPU BIOS::BIOS RAM::RAM CPU::connectBus

Definition at line 20 of file bus.cpp.

Member Function Documentation

◆ clock()

void Bus::clock ( )

Clocks the PSX.

Clocks all the components of the PSX and serves as a synchronization point between the components.

CPU::clock

Definition at line 47 of file bus_utils.cpp.

◆ read16_cpu()

uint16_t Bus::read16_cpu ( uint32_t addr)

Reads a 16-bit word from the given address.

TODO: Map all addresses.

Parameters
addrAddress to read from
Returns
uint16_t Data read from the address
Exceptions
std::runtime_errorIf the address is unaligned
std::runtime_errorIf the address is unmapped

References: Range::contains Range::offset region_mask

Definition at line 186 of file bus.cpp.

◆ read32_cpu()

uint32_t Bus::read32_cpu ( uint32_t addr)

Reads a 32-bit word from the given address.

TODO: Map all addresses.

Parameters
addrAddress to read from
Returns
uint32_t Data read from the address
Exceptions
std::runtime_errorIf the address is unaligned
std::runtime_errorIf the address is unmapped

References: BIOS::read32_cpu RAM::read32_cpu Range::contains Range::offset region_mask

Definition at line 47 of file bus.cpp.

◆ read8_cpu()

uint8_t Bus::read8_cpu ( uint32_t addr)

Reads a 8-bit word from the given address.

TODO: Implement Expansion Region 1. TODO: Map all addresses.

Parameters
addrAddress to read from
Returns
uint8_t Data read from the address
Exceptions
std::runtime_errorIf the address is unmapped

References: BIOS::read32_cpu RAM::read8_cpu Range::contains Range::offset region_mask

Definition at line 281 of file bus.cpp.

◆ region_mask()

uint32_t Bus::region_mask ( uint32_t addr)
private

Returns the region mask for a given address.

The regions are:

  • KUSEG: 0x00000000 - 0x7fffffff
  • KSEG0: 0x80000000 - 0x9fffffff
  • KSEG1: 0xa0000000 - 0xbfffffff
  • KSEG2: 0xc0000000 - 0xffffffff
    Parameters
    addrAddress to get the region mask for
    Returns
    uint32_t Region mask

Definition at line 15 of file bus_utils.cpp.

◆ write16_cpu()

void Bus::write16_cpu ( uint32_t addr,
uint16_t data )

Writes a 16-bit word to the given address.

TODO: Map all addresses.

Parameters
addrAddress to write to
dataData to write to the address
Exceptions
std::runtime_errorIf the address is unaligned
std::runtime_errorIf the address is unmapped

References: Range::contains Range::offset region_mask

Definition at line 222 of file bus.cpp.

◆ write32_cpu()

void Bus::write32_cpu ( uint32_t addr,
uint32_t data )

Writes a 32-bit word to the given address.

TODO: Map all addresses.

Parameters
addrAddress to write to
dataData to write to the address
Exceptions
std::runtime_errorIf the address is unaligned
std::runtime_errorIf the address is unmapped
std::runtime_errorIf the data written to any of the MEM_CTRL registers is invalid

References: RAM::write32_cpu Range::contains Range::offset region_mask

Definition at line 100 of file bus.cpp.

◆ write8_cpu()

void Bus::write8_cpu ( uint32_t addr,
uint8_t data )

Writes a 8-bit word to the given address.

TODO: Implement Expansion Region 2. TODO: Map all addresses.

Parameters
addrAddress to write to
dataData to write to the address
Exceptions
std::runtime_errorIf the address is unmapped

References: RAM::write8_cpu Range::contains Range::offset region_mask

Definition at line 323 of file bus.cpp.

Member Data Documentation

◆ bios

BIOS* Bus::bios
private

Pointer to the BIOS object.

Definition at line 107 of file bus.hpp.

◆ bios_range

Range Bus::bios_range = Range(BIOS_RANGE)
private

Range of the BIOS.

Definition at line 119 of file bus.hpp.

◆ cache_ctrl_range

Range Bus::cache_ctrl_range = Range(CACHE_CTRL_RANGE)
private

Range of the Cache Control Register.

Definition at line 137 of file bus.hpp.

◆ cpu

CPU* Bus::cpu
private

Pointer to the CPU object.

Definition at line 101 of file bus.hpp.

◆ expansion1_range

Range Bus::expansion1_range = Range(EXPANSION1_RANGE)
private

Range of the Expansion 1.

Definition at line 161 of file bus.hpp.

◆ expansion2_range

Range Bus::expansion2_range = Range(EXPANSION2_RANGE)
private

Range of the Expansion 2.

Definition at line 155 of file bus.hpp.

◆ interrupt_range

Range Bus::interrupt_range = Range(INTERRUPT_RANGE)
private

Range of the Interrupt Registers.

Definition at line 167 of file bus.hpp.

◆ mem_ctrl_range

Range Bus::mem_ctrl_range = Range(MEM_CTRL_RANGE)
private

Range of the Memory Control Registers.

Definition at line 125 of file bus.hpp.

◆ ram

RAM* Bus::ram
private

Pointer to the RAM object.

Definition at line 113 of file bus.hpp.

◆ ram_range

Range Bus::ram_range = Range(RAM_RANGE)
private

Range of the RAM.

Definition at line 143 of file bus.hpp.

◆ ram_size_range

Range Bus::ram_size_range = Range(RAM_SIZE_RANGE)
private

Range of the RAM Size Register.

Definition at line 131 of file bus.hpp.

◆ spu_range

Range Bus::spu_range = Range(SPU_RANGE)
private

Range of the SPU (Sound Processing Unit) Registers.

Definition at line 149 of file bus.hpp.

◆ timer_range

Range Bus::timer_range = Range(TIMER_RANGE)
private

Range of the Timer Registers.

Definition at line 173 of file bus.hpp.


The documentation for this class was generated from the following files: