Skip to content
Snippets Groups Projects
Commit d4c1c8ba authored by Geo Ster's avatar Geo Ster
Browse files

Add basic SIF implmentation

parent c24d6d32
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@ add_executable(${PROJECT_NAME}
"src/cpu/vu/vif.cc"
"src/media/ipu.cc"
"src/cpu/ee/cop1.cc"
"src/common/sif.cc"
)
# Link to all the required conan libs
......
#include <common/emulator.h>
#include <common/sif.h>
#include <cpu/ee/ee.h>
#include <cpu/ee/dmac.h>
#include <cpu/iop/iop.h>
......@@ -32,6 +33,7 @@ namespace common
vu0 = std::make_unique<vu::VU0>(ee.get());
vif = std::make_unique<vu::VIF>(this);
ipu = std::make_unique<media::IPU>(this);
sif = std::make_unique<common::SIF>(this);
/* Initialize console */
console.open("console.txt", std::ios::out);
......
......@@ -56,6 +56,7 @@ namespace common
};
/* This class act as the "motherboard" of sorts */
class SIF;
class Emulator
{
public:
......@@ -94,6 +95,7 @@ namespace common
std::unique_ptr<vu::VU0> vu0;
std::unique_ptr<vu::VIF> vif;
std::unique_ptr<media::IPU> ipu;
std::unique_ptr<common::SIF> sif;
/* Memory - Registers */
uint8_t* bios;
......
#include <common/sif.h>
#include <common/emulator.h>
constexpr const char* REGS[] =
{
"SIF_MSCOM", "SIF_SMCOM", "SIF_MSFLG",
"SIF_SMFLG", "SIF_CTRL", "", "SIF_BD6"
};
constexpr const char* COMP[] =
{
"IOP", "EE"
};
namespace common
{
SIF::SIF(Emulator* parent) :
emulator(parent)
{
emulator->add_handler(0x1000F200, this, &SIF::read, &SIF::write);
emulator->add_handler(0x1D000000, this, &SIF::read, &SIF::write);
}
uint32_t SIF::read(uint32_t addr)
{
auto comp = (addr >> 9) & 0x1;
uint16_t offset = (addr >> 4) & 0xf;
auto ptr = (uint32_t*)&regs + offset;
fmt::print("[SIF][{}] Read {:#x} from {}\n", COMP[comp], *ptr, REGS[offset]);
return *ptr;
}
void SIF::write(uint32_t addr, uint32_t data)
{
auto comp = (addr >> 9) & 0x1;
uint16_t offset = (addr >> 4) & 0xf;
auto ptr = (uint32_t*)&regs + offset;
fmt::print("[SIF][{}] Writing {:#x} to {}\n", COMP[comp], data, REGS[offset]);
*ptr = data;
}
}
\ No newline at end of file
#pragma once
#include <common/component.h>
namespace common
{
struct SIFRegs
{
uint32_t mscom;
uint32_t smcom;
uint32_t msflg;
uint32_t smflg;
uint32_t ctrl;
uint32_t padding;
uint32_t bd6;
};
class Emulator;
struct SIF : public common::Component
{
SIF(Emulator* parent);
uint32_t read(uint32_t addr);
void write(uint32_t addr, uint32_t data);
private:
Emulator* emulator;
SIFRegs regs = {};
};
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment