Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ps2xRecomp/src/lib/elf_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#else
#include <unistd.h>
#endif

#include "libdwarf_private.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this include ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const int siblingResult = dwarf_siblingof_b(dbg, current, TRUE, &sibling, &error);
TRUE is not recognizable here. Fails on MacOS, probably on Linux. where does TRUE macro come from?

#include <libdwarf.h>
#include <dwarf.h>
#include <fstream>
Expand Down
9 changes: 6 additions & 3 deletions ps2xRuntime/include/ps2_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string>
#include <functional>
#include <immintrin.h> // For SSE/AVX instructions
#include <smmintrin.h>
#include <atomic>
#include <filesystem>
#include <iostream>
Expand Down Expand Up @@ -225,8 +226,10 @@ struct alignas(16) R5900Context
for (int i = 0; i < 32; ++i)
{
std::cout << "R" << std::setw(2) << std::dec << i << ": 0x" << std::hex
<< std::setw(8) << r[i].m128i_u32[3] << std::setw(8) << r[i].m128i_u32[2] << "_"
<< std::setw(8) << r[i].m128i_u32[1] << std::setw(8) << r[i].m128i_u32[0] << "\n";
<< std::setw(8) << static_cast<uint32_t>(_mm_extract_epi32(r[i], 3))
<< std::setw(8) << static_cast<uint32_t>(_mm_extract_epi32(r[i], 2)) << "_"
<< std::setw(8) << static_cast<uint32_t>(_mm_extract_epi32(r[i], 1))
<< std::setw(8) << static_cast<uint32_t>(_mm_extract_epi32(r[i], 0)) << "\n";
}
std::cout << "Status: 0x" << std::setw(8) << cop0_status
<< " Cause: 0x" << std::setw(8) << cop0_cause
Expand All @@ -243,7 +246,7 @@ inline uint32_t getRegU32(const R5900Context *ctx, int reg)
// Check if reg is valid (0-31)
if (reg < 0 || reg > 31)
return 0;
return ctx->r[reg].m128i_u32[0];
return static_cast<uint32_t>(_mm_extract_epi32(ctx->r[reg], 0));
}

inline void setReturnU32(R5900Context *ctx, uint32_t value)
Expand Down
15 changes: 9 additions & 6 deletions ps2xRuntime/include/ps2_runtime_macros.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#ifndef PS2_RUNTIME_MACROS_H
#define PS2_RUNTIME_MACROS_H
#include <cstdint>
#include <immintrin.h> // For SSE/AVX intrinsics
#include <intrin.h>
#if defined(_MSC_VER)
#include <intrin.h>
#else
#include <immintrin.h> // For SSE/AVX intrinsics
#endif
inline uint32_t ps2_clz32(uint32_t val) {
#if defined(_MSC_VER)
unsigned long idx;
Expand Down Expand Up @@ -207,10 +210,10 @@ inline __m128i _mm_custom_srav_epi32(__m128i a, __m128i count) {
#define PS2_VCALLMS(addr) // VU0 microprogram calls not supported directly
#define PS2_VCALLMSR(reg) // VU0 microprogram calls not supported directly

#define GPR_U32(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0U : ctx_ptr->r[reg_idx].m128i_u32[0])
#define GPR_S32(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0 : ctx_ptr->r[reg_idx].m128i_i32[0])
#define GPR_U64(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0ULL : ctx_ptr->r[reg_idx].m128i_u64[0])
#define GPR_S64(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0LL : ctx_ptr->r[reg_idx].m128i_i64[0])
#define GPR_U32(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0U : static_cast<uint32_t>(_mm_extract_epi32(ctx_ptr->r[reg_idx], 0)))
#define GPR_S32(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0 : _mm_extract_epi32(ctx_ptr->r[reg_idx], 0))
#define GPR_U64(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0ULL : static_cast<uint32_t>(_mm_extract_epi64(ctx_ptr->r[reg_idx], 0)))
#define GPR_S64(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0LL : _mm_extract_epi64(ctx_ptr->r[reg_idx], 0))
#define GPR_VEC(ctx_ptr, reg_idx) ((reg_idx == 0) ? _mm_setzero_si128() : ctx_ptr->r[reg_idx])

#define SET_GPR_U32(ctx_ptr, reg_idx, val) \
Expand Down
10 changes: 5 additions & 5 deletions ps2xRuntime/src/lib/ps2_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void PS2Runtime::executeVU0Microprogram(uint8_t *rdram, R5900Context *ctx, uint3
{
std::cout << "[VU0] microprogram @0x" << std::hex << address
<< " pc=0x" << ctx->pc
<< " ra=0x" << ctx->r[31].m128i_u32[0]
<< " ra=0x" << static_cast<uint32_t>(_mm_extract_epi32(ctx->r[31], 0))
<< std::dec << std::endl;
}
++count;
Expand Down Expand Up @@ -430,7 +430,7 @@ void PS2Runtime::run()
{
entryPoint(m_memory.getRDRAM(), &m_cpuContext, this);
std::cout << "Game thread returned. PC=0x" << std::hex << m_cpuContext.pc
<< " RA=0x" << m_cpuContext.r[31].m128i_u32[0] << std::dec << std::endl;
<< " RA=0x" << static_cast<uint32_t>(_mm_extract_epi32(m_cpuContext.r[31], 0)) << std::dec << std::endl;
}
catch (const std::exception &e)
{
Expand All @@ -445,9 +445,9 @@ void PS2Runtime::run()
{
std::cout << "[run] activeThreads=" << g_activeThreads.load(std::memory_order_relaxed);
std::cout << " pc=0x" << std::hex << m_cpuContext.pc
<< " ra=0x" << m_cpuContext.r[31].m128i_u32[0]
<< " sp=0x" << m_cpuContext.r[29].m128i_u32[0]
<< " gp=0x" << m_cpuContext.r[28].m128i_u32[0] << std::dec << std::endl;
<< " ra=0x" << static_cast<uint32_t>(_mm_extract_epi32(m_cpuContext.r[31], 0))
<< " sp=0x" << static_cast<uint32_t>(_mm_extract_epi32(m_cpuContext.r[29], 0))
<< " gp=0x" << static_cast<uint32_t>(_mm_extract_epi32(m_cpuContext.r[28], 0)) << std::dec << std::endl;
}
if ((tick % 600) == 0)
{
Expand Down
7 changes: 6 additions & 1 deletion ps2xRuntime/src/lib/ps2_syscalls.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "ps2_syscalls.h"
#include "ps2_runtime.h"
#include "ps2_runtime_macros.h"
Expand All @@ -15,6 +14,12 @@
#include <atomic>
#include <filesystem>

#ifndef _WIN32
#include <unistd.h> // for unlink,rmdir,chdir
#include <sys/stat.h> // for mkdir
#endif


std::unordered_map<int, FILE *> g_fileDescriptors;
int g_nextFd = 3; // Start after stdin, stdout, stderr

Expand Down