Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement sys_isolated_spu #8056

Merged
merged 3 commits into from
Apr 17, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/Modules/sceNp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,12 @@ error_code npDrmIsAvailable(vm::cptr<u8> k_licensee_addr, vm::cptr<char> drm_pat
sceNp.notice("npDrmIsAvailable(): KLicense key %s", *reinterpret_cast<be_t<v128, 1>*>(k_licensee.data()));
}

if (Emu.GetCat() == "PE")
{
std::copy_n(NP_PSP_KEY_2, std::size(NP_PSP_KEY_2), k_licensee.begin());
sceNp.success("npDrmIsAvailable(): PSP remaster KLicense key apllied.");
}

const std::string enc_drm_path(drm_path.get_ptr(), std::find(drm_path.get_ptr(), drm_path.get_ptr() + 0x100, '\0'));

sceNp.warning(u8"npDrmIsAvailable(): drm_path=“%s”", enc_drm_path);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/RawSPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inline void try_start(spu_thread& spu)
return false;
}

value.status = SPU_STATUS_RUNNING;
value.status = SPU_STATUS_RUNNING | (value.status & SPU_STATUS_IS_ISOLATED);
return true;
}).second)
{
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,9 @@ void spu_recompiler::RDCH(spu_opcode_t op)
{
const XmmLink& vr = XmmAlloc();
c->movzx(*addr, SPU_OFF_8(interrupts_enabled));
c->movzx(arg1->r32(), SPU_OFF_8(is_isolated));
c->shl(arg1->r32(), 1);
c->or_(addr->r32(), arg1->r32());
c->movd(vr, *addr);
c->pslldq(vr, 12);
c->movdqa(SPU_OFF_128(gpr, op.rt), vr);
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/SPURecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5500,6 +5500,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
case SPU_RdMachStat:
{
res.value = m_ir->CreateZExt(m_ir->CreateLoad(spu_ptr<u8>(&spu_thread::interrupts_enabled)), get_type<u32>());
res.value = m_ir->CreateOr(res.value, m_ir->CreateShl(m_ir->CreateZExt(m_ir->CreateLoad(spu_ptr<u8>(&spu_thread::is_isolated)), get_type<u32>()), m_ir->getInt32(1)));
break;
}

Expand Down
10 changes: 5 additions & 5 deletions rpcs3/Emu/Cell/SPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,8 @@ void spu_thread::cpu_init()
mfc_prxy_write_state = {};
}

status_npc.raw() = {is_isolated ? SPU_STATUS_IS_ISOLATED : 0, 0};
run_ctrl.raw() = 0;
status_npc.raw() = {};

int_ctrl[0].clear();
int_ctrl[1].clear();
Expand Down Expand Up @@ -1218,7 +1218,7 @@ void spu_thread::cpu_task()
name_cache = cpu->spu_tname.load();
}

return fmt::format("%sSPU[0x%07x] Thread (%s) [0x%05x]", cpu->offset >= RAW_SPU_BASE_ADDR ? "Raw" : "", cpu->lv2_id, *name_cache.get(), cpu->pc);
return fmt::format("%sSPU[0x%07x] Thread (%s) [0x%05x]", cpu->offset >= RAW_SPU_BASE_ADDR ? cpu->is_isolated ? "Iso" : "Raw" : "", cpu->lv2_id, *name_cache.get(), cpu->pc);
};

if (jit)
Expand Down Expand Up @@ -1286,8 +1286,9 @@ spu_thread::~spu_thread()
}
}

spu_thread::spu_thread(vm::addr_t ls, lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id)
spu_thread::spu_thread(vm::addr_t ls, lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated)
: cpu_thread(idm::last_id())
, is_isolated(is_isolated)
, index(index)
, offset(ls)
, group(group)
Expand Down Expand Up @@ -2591,9 +2592,8 @@ s64 spu_thread::get_ch_value(u32 ch)

case SPU_RdMachStat:
{
// HACK: "Not isolated" status
// Return SPU Interrupt status in LSB
return interrupts_enabled == true;
return u32{interrupts_enabled} | (u32{is_isolated} << 1);
}
}

Expand Down
9 changes: 5 additions & 4 deletions rpcs3/Emu/Cell/SPUThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,22 @@ enum : u64
SPU_INT2_STAT_SPU_MAILBOX_THRESHOLD_INT = (1ull << 4),
};

enum
enum : u32
{
SPU_RUNCNTL_STOP_REQUEST = 0,
SPU_RUNCNTL_RUN_REQUEST = 1,
};

// SPU Status Register bits (not accurate)
enum
enum : u32
{
SPU_STATUS_STOPPED = 0x0,
SPU_STATUS_RUNNING = 0x1,
SPU_STATUS_STOPPED_BY_STOP = 0x2,
SPU_STATUS_STOPPED_BY_HALT = 0x4,
SPU_STATUS_WAITING_FOR_CHANNEL = 0x8,
SPU_STATUS_SINGLE_STEP = 0x10,
SPU_STATUS_IS_ISOLATED = 0x80,
};

enum : u32
Expand Down Expand Up @@ -514,7 +515,7 @@ class spu_thread : public cpu_thread
static const u32 id_step = 1;
static const u32 id_count = 2048;

spu_thread(vm::addr_t ls, lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id);
spu_thread(vm::addr_t ls, lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated = false);

u32 pc = 0;

Expand Down Expand Up @@ -592,8 +593,8 @@ class spu_thread : public cpu_thread
u32 npc; // SPU Next Program Counter register
};

const bool is_isolated;
atomic_t<status_npc_sync_var> status_npc;

std::array<spu_int_ctrl_t, 3> int_ctrl; // SPU Class 0, 1, 2 Interrupt Management

std::array<std::pair<u32, std::weak_ptr<lv2_event_queue>>, 32> spuq; // Event Queue Keys for SPU Thread
Expand Down
30 changes: 16 additions & 14 deletions rpcs3/Emu/Cell/lv2/lv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ void fmt_class_string<ppu_syscall_code>::format(std::string& out, u64 arg)

static bool null_func(ppu_thread& ppu)
{
ppu_log.todo("Unimplemented syscall %s -> CELL_OK", ppu_syscall_code(ppu.gpr[11]));
ppu_log.todo("Unimplemented syscall %s -> CELL_OK (r3=0x%llx, r4=0x%x, r5=0x%llx, r6=0x%llx, r7=0x%llx, r8=0x%llx, r9=0x%llx, r10=0x%llx)", ppu_syscall_code(ppu.gpr[11]),
ppu.gpr[3], ppu.gpr[4], ppu.gpr[5], ppu.gpr[6], ppu.gpr[7], ppu.gpr[8], ppu.gpr[9], ppu.gpr[10]);

ppu.gpr[3] = 0;
ppu.cia += 4;
return false;
Expand Down Expand Up @@ -287,17 +289,17 @@ const std::array<ppu_function_t, 1024> s_ppu_syscall_table
null_func, null_func, null_func, null_func, null_func, //224 UNS
null_func, null_func, null_func, null_func, null_func, //229 UNS?

null_func,//BIND_FUNC(sys_isolated_spu_create) //230 (0x0E6) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_destroy) //231 (0x0E7) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_start) //232 (0x0E8) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_create_interrupt_tag) //233 (0x0E9) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_set_int_mask) //234 (0x0EA) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_get_int_mask) //235 (0x0EB) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_set_int_stat) //236 (0x0EC) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_get_int_stat) //237 (0x0ED) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_set_spu_cfg) //238 (0x0EE) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_get_spu_cfg) //239 (0x0EF) ROOT
null_func,//BIND_FUNC(sys_isolated_spu_read_puint_mb) //240 (0x0F0) ROOT
BIND_FUNC(sys_isolated_spu_create), //230 (0x0E6) ROOT
BIND_FUNC(sys_isolated_spu_destroy), //231 (0x0E7) ROOT
BIND_FUNC(sys_isolated_spu_start), //232 (0x0E8) ROOT
BIND_FUNC(sys_isolated_spu_create_interrupt_tag), //233 (0x0E9) ROOT
BIND_FUNC(sys_isolated_spu_set_int_mask), //234 (0x0EA) ROOT
BIND_FUNC(sys_isolated_spu_get_int_mask), //235 (0x0EB) ROOT
BIND_FUNC(sys_isolated_spu_set_int_stat), //236 (0x0EC) ROOT
BIND_FUNC(sys_isolated_spu_get_int_stat), //237 (0x0ED) ROOT
BIND_FUNC(sys_isolated_spu_set_spu_cfg), //238 (0x0EE) ROOT
BIND_FUNC(sys_isolated_spu_get_spu_cfg), //239 (0x0EF) ROOT
BIND_FUNC(sys_isolated_spu_read_puint_mb), //240 (0x0F0) ROOT
uns_func, uns_func, uns_func, //241-243 ROOT UNS
null_func,//BIND_FUNC(sys_spu_thread_group_system_set_next_group) //244 (0x0F4) ROOT
null_func,//BIND_FUNC(sys_spu_thread_group_system_unset_next_group) //245 (0x0F5) ROOT
Expand Down Expand Up @@ -776,9 +778,9 @@ const std::array<ppu_function_t, 1024> s_ppu_syscall_table
null_func,//BIND_FUNC(sys_ss_update_manager) //863 ROOT
null_func,//BIND_FUNC(sys_ss_sec_hw_framework) //864 DBG
BIND_FUNC(sys_ss_random_number_generator), //865 (0x361)
null_func,//BIND_FUNC(sys_ss_secure_rtc) //866 ROOT
BIND_FUNC(sys_ss_secure_rtc), //866 ROOT
null_func,//BIND_FUNC(sys_ss_appliance_info_manager) //867 ROOT
null_func,//BIND_FUNC(sys_ss_individual_info_manager) //868 ROOT / DBG AUTHID
BIND_FUNC(sys_ss_individual_info_manager), //868 ROOT / DBG AUTHID
null_func,//BIND_FUNC(sys_ss_factory_data_manager) //869 ROOT
BIND_FUNC(sys_ss_get_console_id), //870 (0x366)
BIND_FUNC(sys_ss_access_control_engine), //871 (0x367) DBG
Expand Down