mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-29 09:50:27 -04:00
75d729ce40
* refactor: from guest threads to EE scheduler * feat: bad wip mpeg fix for code veronica * feat: cheap copy from host feat: small perf o vsync tick * feat: added EE clock Hz fix: fix MPEG out of sync with new EE refactor * fix: fix lotr tests * fix: fix cri dtx loading fix: fix wrong mmi instruction translation fix: fix thread info params feat: added EE timers decoder and consumer feat: split SFI and IOP memory to prevent collision and overrides * feat: revert wrong changes * refactor: change GS architecture * feat: IOP emulator refactor: codegen to catch callbacks on mips code feat: added a lot of entries or IOP emulator * feat: analyzer resolve the complete constant-producing sequence with five-instruction backward scan stopped at LUI and therefore * feat: remove recompiled version of GetRomName refactor: split IOP emulator logic feat: added more HLE IOP modules feat: added ps2_path * eat: enhance ELF parser with improved callable entry detection and control flow analysis * feat: update memory hint handling and enhance entry point discovery logic * feat: add SET_GPR_ZE32 macro for zero-extending loads with unsigned semantics * refactor: Refactor PS2 IOP Host Adapter and Memory Management feat: Added PS2Vfs for virtual file system operations, including file opening, reading, writing, and path resolution. feat: Improve VIF1 data processing to handle GIF image packets more efficiently. * feat: added a lot of tests * fix: fix texture caching feat: wip multi version on dbcman * feat: remove LLE IOPs
136 lines
4.2 KiB
C++
136 lines
4.2 KiB
C++
#pragma once
|
|
|
|
#include "ps2x/iop/iop_types.h"
|
|
|
|
#include <array>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace ps2x::iop
|
|
{
|
|
enum class HostPathKind : uint32_t
|
|
{
|
|
ElfDirectory = 0,
|
|
CdRoot = 1,
|
|
CdImage = 2,
|
|
HostRoot = 3,
|
|
MemoryCardRoot = 4,
|
|
};
|
|
|
|
enum class LogLevel : uint32_t
|
|
{
|
|
Debug = 0,
|
|
Info = 1,
|
|
Warning = 2,
|
|
Error = 3,
|
|
};
|
|
|
|
enum class MemoryCardOperation : uint32_t
|
|
{
|
|
Init,
|
|
GetInfo,
|
|
Open,
|
|
Close,
|
|
Seek,
|
|
Read,
|
|
Write,
|
|
Flush,
|
|
Chdir,
|
|
GetDir,
|
|
SetFileInfo,
|
|
Delete,
|
|
Format,
|
|
Unformat,
|
|
Mkdir,
|
|
};
|
|
|
|
struct MemoryCardRequest
|
|
{
|
|
MemoryCardOperation operation = MemoryCardOperation::Init;
|
|
// The fifth argument is carried in $t0 by the EE n32 ABI
|
|
std::array<uint32_t, 5> arguments{};
|
|
};
|
|
|
|
class IopHost
|
|
{
|
|
public:
|
|
virtual ~IopHost() = default;
|
|
|
|
virtual bool readGuest(uint32_t address, void *destination, size_t size) const = 0;
|
|
virtual bool writeGuest(uint32_t address, const void *source, size_t size) = 0;
|
|
virtual bool zeroGuest(uint32_t address, size_t size) = 0;
|
|
virtual bool normalizeGuestAddress(uint32_t address, uint32_t &normalized) const = 0;
|
|
|
|
// IOP RAM is a distinct address space from the EE guest. TODO remove this later
|
|
virtual bool readIopMemory(uint32_t address, void *destination, size_t size) const
|
|
{
|
|
(void)address;
|
|
(void)destination;
|
|
(void)size;
|
|
return false;
|
|
}
|
|
virtual bool writeIopMemory(uint32_t address, const void *source, size_t size)
|
|
{
|
|
(void)address;
|
|
(void)source;
|
|
(void)size;
|
|
return false;
|
|
}
|
|
virtual bool zeroIopMemory(uint32_t address, size_t size)
|
|
{
|
|
(void)address;
|
|
(void)size;
|
|
return false;
|
|
}
|
|
virtual bool normalizeIopAddress(uint32_t address, uint32_t &normalized) const
|
|
{
|
|
(void)address;
|
|
normalized = 0u;
|
|
return false;
|
|
}
|
|
virtual uint32_t allocateIopHandle(IopHandleKind kind) = 0;
|
|
virtual uint32_t allocateGuest(uint32_t size, uint32_t alignment) = 0;
|
|
virtual void freeGuest(uint32_t address) = 0;
|
|
|
|
virtual void audioCommand(uint32_t sid, uint32_t function, GuestBuffer send, GuestBuffer receive) = 0;
|
|
|
|
virtual std::string hostPath(HostPathKind kind) const = 0;
|
|
virtual std::string translateGuestPath(std::string_view path) const = 0;
|
|
virtual uint64_t openHostFile(std::string_view path) = 0;
|
|
virtual bool hostFileSize(uint64_t handle, uint64_t &size) const = 0;
|
|
virtual bool readHostFile(uint64_t handle,
|
|
uint64_t offset,
|
|
void *destination,
|
|
size_t size,
|
|
size_t &bytesRead) = 0;
|
|
virtual void closeHostFile(uint64_t handle) = 0;
|
|
|
|
virtual int32_t memoryCard(const MemoryCardRequest &request) = 0;
|
|
|
|
virtual bool hasGuestFunction(uint32_t address) const = 0;
|
|
virtual bool invokeGuestFunction(uint64_t callToken,
|
|
uint32_t address,
|
|
uint32_t a0,
|
|
uint32_t a1,
|
|
uint32_t a2,
|
|
uint32_t a3,
|
|
uint32_t *resultAddress) = 0;
|
|
|
|
// Deliver an IOP -> EE SIF command packet. The default keeps hosts
|
|
// which do not emulate the EE command dispatcher source-compatible.
|
|
virtual bool sendSifCommand(uint32_t commandId,
|
|
const void *packet,
|
|
size_t packetSize)
|
|
{
|
|
(void)commandId;
|
|
(void)packet;
|
|
(void)packetSize;
|
|
return false;
|
|
}
|
|
|
|
virtual void log(LogLevel level, std::string_view message) = 0;
|
|
};
|
|
}
|