mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
libmixer fix
This commit is contained in:
parent
c1786df2a6
commit
152feb898e
@ -2263,14 +2263,6 @@ private:
|
|||||||
{
|
{
|
||||||
case 0x0: SysCall(); break;
|
case 0x0: SysCall(); break;
|
||||||
case 0x1: throw "SC(): HyperCall LV1";
|
case 0x1: throw "SC(): HyperCall LV1";
|
||||||
case 0x2:
|
|
||||||
Emu.GetSFuncManager().StaticExecute(CPU, (u32)CPU.GPR[11]);
|
|
||||||
if (Ini.HLELogging.GetValue())
|
|
||||||
{
|
|
||||||
LOG_NOTICE(PPU, "'%s' done with code[0x%llx]! #pc: 0x%x",
|
|
||||||
Emu.GetSFuncManager()[CPU.GPR[11]]->name, CPU.GPR[3], CPU.PC);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 0x3: CPU.FastStop(); break;
|
case 0x3: CPU.FastStop(); break;
|
||||||
default: throw fmt::Format("SC(): unknown level (0x%x)", lev);
|
default: throw fmt::Format("SC(): unknown level (0x%x)", lev);
|
||||||
}
|
}
|
||||||
|
@ -2007,10 +2007,6 @@ void Compiler::SC(u32 lev) {
|
|||||||
case 0:
|
case 0:
|
||||||
Call<void>("SysCalls.DoSyscall", SysCalls::DoSyscall, m_state.args[CompileTaskState::Args::State], GetGpr(11));
|
Call<void>("SysCalls.DoSyscall", SysCalls::DoSyscall, m_state.args[CompileTaskState::Args::State], GetGpr(11));
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
Call<void>("StaticFuncManager.StaticExecute", &StaticFuncManager::StaticExecute,
|
|
||||||
m_ir_builder->getInt64((u64)&Emu.GetSFuncManager()), m_state.args[CompileTaskState::Args::State], GetGpr(11, 32));
|
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
Call<void>("PPUThread.FastStop", &PPUThread::FastStop, m_state.args[CompileTaskState::Args::State]);
|
Call<void>("PPUThread.FastStop", &PPUThread::FastStop, m_state.args[CompileTaskState::Args::State]);
|
||||||
break;
|
break;
|
||||||
|
@ -209,85 +209,3 @@ void Module::PushNewFuncSub(SFunc* func)
|
|||||||
{
|
{
|
||||||
Emu.GetSFuncManager().push_back(func);
|
Emu.GetSFuncManager().push_back(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fix_import(Module* module, u32 nid, u32 addr)
|
|
||||||
{
|
|
||||||
using namespace PPU_instr;
|
|
||||||
|
|
||||||
vm::ptr<u32> ptr = vm::ptr<u32>::make(addr);
|
|
||||||
|
|
||||||
u32 index;
|
|
||||||
|
|
||||||
if (auto func = get_ps3_func_by_nid(nid, &index))
|
|
||||||
{
|
|
||||||
*ptr++ = HACK(index);
|
|
||||||
*ptr++ = BLR();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
module->Error("Unimplemented function 0x%x (0x%x)", nid, addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
//*ptr++ = ADDIS(11, 0, func >> 16);
|
|
||||||
//*ptr++ = ORI(11, 11, func & 0xffff);
|
|
||||||
//*ptr++ = NOP();
|
|
||||||
//++ptr;
|
|
||||||
//*ptr++ = SC(0);
|
|
||||||
//*ptr++ = BLR();
|
|
||||||
//*ptr++ = NOP();
|
|
||||||
//*ptr++ = NOP();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fix_relocs(Module* module, u32 lib, u32 start, u32 end, u32 seg2)
|
|
||||||
{
|
|
||||||
// start of table:
|
|
||||||
// addr = (u64) addr - seg2, (u32) 1, (u32) 1, (u64) ptr
|
|
||||||
// addr = (u64) addr - seg2, (u32) 0x101, (u32) 1, (u64) ptr - seg2 (???)
|
|
||||||
// addr = (u64) addr, (u32) 0x100, (u32) 1, (u64) ptr - seg2 (???)
|
|
||||||
// addr = (u64) addr, (u32) 0, (u32) 1, (u64) ptr (???)
|
|
||||||
|
|
||||||
for (u32 i = lib + start; i < lib + end; i += 24)
|
|
||||||
{
|
|
||||||
u64 addr = vm::read64(i) + lib;
|
|
||||||
const u64 flag = vm::read64(i + 8);
|
|
||||||
|
|
||||||
if ((u32)addr != addr || (u32)(addr + seg2) != (addr + seg2))
|
|
||||||
{
|
|
||||||
module->Error("fix_relocs(): invalid address (0x%llx)", addr);
|
|
||||||
}
|
|
||||||
else if (flag == 0x10100000001ull)
|
|
||||||
{
|
|
||||||
addr = addr + seg2;
|
|
||||||
u32 value = vm::read32((u32)addr);
|
|
||||||
assert(value == vm::read64(i + 16) + seg2);
|
|
||||||
vm::write32((u32)addr, value + lib);
|
|
||||||
}
|
|
||||||
else if (flag == 0x100000001ull)
|
|
||||||
{
|
|
||||||
addr = addr + seg2;
|
|
||||||
u32 value = vm::read32((u32)addr);
|
|
||||||
assert(value == vm::read64(i + 16));
|
|
||||||
vm::write32((u32)addr, value + lib);
|
|
||||||
}
|
|
||||||
else if (flag == 0x10000000001ull)
|
|
||||||
{
|
|
||||||
u32 value = vm::read32((u32)addr);
|
|
||||||
assert(value == vm::read64(i + 16) + seg2);
|
|
||||||
vm::write32((u32)addr, value + lib);
|
|
||||||
}
|
|
||||||
else if (flag == 1)
|
|
||||||
{
|
|
||||||
u32 value = vm::read32((u32)addr);
|
|
||||||
assert(value == vm::read64(i + 16));
|
|
||||||
vm::write32((u32)addr, value + lib);
|
|
||||||
}
|
|
||||||
else if (flag == 0x10000000004ull || flag == 0x10000000006ull)
|
|
||||||
{
|
|
||||||
// seems to be instruction modifiers for imports (done in other way in FIX_IMPORT)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
module->Notice("fix_relocs(): 0x%x : 0x%llx", i - lib, flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -30,17 +30,11 @@ struct SFuncOp
|
|||||||
|
|
||||||
struct SFunc
|
struct SFunc
|
||||||
{
|
{
|
||||||
func_caller* func;
|
u32 index;
|
||||||
void* ptr;
|
|
||||||
const char* name;
|
const char* name;
|
||||||
std::vector<SFuncOp> ops;
|
std::vector<SFuncOp> ops;
|
||||||
u64 group;
|
u64 group;
|
||||||
u32 found;
|
u32 found;
|
||||||
|
|
||||||
~SFunc()
|
|
||||||
{
|
|
||||||
delete func;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class StaticFuncManager;
|
class StaticFuncManager;
|
||||||
@ -147,8 +141,7 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
|
|||||||
if (!ops[0]) return;
|
if (!ops[0]) return;
|
||||||
|
|
||||||
SFunc* sf = new SFunc;
|
SFunc* sf = new SFunc;
|
||||||
sf->ptr = (void *)func;
|
sf->index = add_ps3_func(ModuleFunc(get_function_id(name), this, bind_func(func)));
|
||||||
sf->func = bind_func(func);
|
|
||||||
sf->name = name;
|
sf->name = name;
|
||||||
sf->group = *(u64*)group;
|
sf->group = *(u64*)group;
|
||||||
sf->found = 0;
|
sf->found = 0;
|
||||||
@ -167,12 +160,6 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
|
|||||||
PushNewFuncSub(sf);
|
PushNewFuncSub(sf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fix_import(Module* module, u32 nid, u32 addr);
|
|
||||||
|
|
||||||
#define FIX_IMPORT(module, func, addr) fix_import(module, get_function_id(#func), addr)
|
|
||||||
|
|
||||||
void fix_relocs(Module* module, u32 lib, u32 start, u32 end, u32 seg2);
|
|
||||||
|
|
||||||
#define REG_SUB(module, group, name, ...) \
|
#define REG_SUB(module, group, name, ...) \
|
||||||
static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \
|
static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \
|
||||||
module.AddFuncSub(group, name ## _table, #name, name)
|
module.AddFuncSub(group, name ## _table, #name, name)
|
||||||
|
@ -312,10 +312,15 @@ int cellSurMixerCreate(vm::ptr<const CellSurMixerConfig> config)
|
|||||||
port.channel = 8;
|
port.channel = 8;
|
||||||
port.block = 16;
|
port.block = 16;
|
||||||
port.attr = 0;
|
port.attr = 0;
|
||||||
port.level = 1.0f;
|
port.addr = g_audio.buffer + AUDIO_PORT_OFFSET * g_surmx.audio_port;
|
||||||
|
port.read_index_addr = g_audio.indexes + sizeof(u64) * g_surmx.audio_port;
|
||||||
|
port.size = port.channel * port.block * AUDIO_SAMPLES * sizeof(float);
|
||||||
port.tag = 0;
|
port.tag = 0;
|
||||||
|
port.level = 1.0f;
|
||||||
|
port.level_set = 1.0f;
|
||||||
|
port.level_inc = 0.0f;
|
||||||
|
|
||||||
libmixer.Warning("*** audio port opened(default)");
|
libmixer.Warning("*** audio port opened (port=%d)", g_surmx.audio_port);
|
||||||
|
|
||||||
mixcount = 0;
|
mixcount = 0;
|
||||||
surMixerCb.set(0);
|
surMixerCb.set(0);
|
||||||
@ -628,6 +633,11 @@ Module libmixer("libmixer", []()
|
|||||||
{
|
{
|
||||||
g_surmx.audio_port = ~0;
|
g_surmx.audio_port = ~0;
|
||||||
|
|
||||||
|
libmixer.on_stop = []()
|
||||||
|
{
|
||||||
|
ssp.clear();
|
||||||
|
};
|
||||||
|
|
||||||
REG_SUB(libmixer, "surmxAAN", cellAANAddData,
|
REG_SUB(libmixer, "surmxAAN", cellAANAddData,
|
||||||
0xffffffff7c691b78,
|
0xffffffff7c691b78,
|
||||||
0xffffffff7c0802a6,
|
0xffffffff7c0802a6,
|
||||||
|
@ -29,7 +29,7 @@ void StaticFuncManager::StaticAnalyse(void* ptr, u32 size, u32 base)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip NOP
|
// skip NOP
|
||||||
if (data[k] == se32(0x60000000))
|
if (data[k] == se32(0x60000000))
|
||||||
{
|
{
|
||||||
x--;
|
x--;
|
||||||
continue;
|
continue;
|
||||||
@ -84,10 +84,9 @@ void StaticFuncManager::StaticAnalyse(void* ptr, u32 size, u32 base)
|
|||||||
{
|
{
|
||||||
LOG_NOTICE(LOADER, "Function '%s' hooked (addr=0x%x)", m_static_funcs_list[j]->name, i * 4 + base);
|
LOG_NOTICE(LOADER, "Function '%s' hooked (addr=0x%x)", m_static_funcs_list[j]->name, i * 4 + base);
|
||||||
m_static_funcs_list[j]->found++;
|
m_static_funcs_list[j]->found++;
|
||||||
data[i+0] = re32(0x39600000 | j); // li r11, j
|
data[i+0] = re32(0x04000000 | m_static_funcs_list[j]->index); // hack
|
||||||
data[i+1] = se32(0x44000042); // sc 2
|
|
||||||
data[i+2] = se32(0x4e800020); // blr
|
data[i+2] = se32(0x4e800020); // blr
|
||||||
i += 2; // skip modified code
|
i += 1; // skip modified code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +117,7 @@ void StaticFuncManager::StaticAnalyse(void* ptr, u32 size, u32 base)
|
|||||||
// check if this function has been found with different pattern
|
// check if this function has been found with different pattern
|
||||||
for (u32 k = 0; k < m_static_funcs_list.size(); k++) if (m_static_funcs_list[k]->group == group)
|
for (u32 k = 0; k < m_static_funcs_list.size(); k++) if (m_static_funcs_list[k]->group == group)
|
||||||
{
|
{
|
||||||
if (k != j && m_static_funcs_list[k]->ptr == m_static_funcs_list[j]->ptr)
|
if (k != j && m_static_funcs_list[k]->index == m_static_funcs_list[j]->index)
|
||||||
{
|
{
|
||||||
count += m_static_funcs_list[k]->found;
|
count += m_static_funcs_list[k]->found;
|
||||||
}
|
}
|
||||||
@ -138,7 +137,7 @@ void StaticFuncManager::StaticAnalyse(void* ptr, u32 size, u32 base)
|
|||||||
// ensure that this function has NOT been found with different pattern
|
// ensure that this function has NOT been found with different pattern
|
||||||
for (u32 k = 0; k < m_static_funcs_list.size(); k++) if (m_static_funcs_list[k]->group == group)
|
for (u32 k = 0; k < m_static_funcs_list.size(); k++) if (m_static_funcs_list[k]->group == group)
|
||||||
{
|
{
|
||||||
if (k != j && m_static_funcs_list[k]->ptr == m_static_funcs_list[j]->ptr)
|
if (k != j && m_static_funcs_list[k]->index == m_static_funcs_list[j]->index)
|
||||||
{
|
{
|
||||||
if (m_static_funcs_list[k]->found)
|
if (m_static_funcs_list[k]->found)
|
||||||
{
|
{
|
||||||
@ -179,18 +178,6 @@ void StaticFuncManager::StaticAnalyse(void* ptr, u32 size, u32 base)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticFuncManager::StaticExecute(PPUThread& CPU, u32 code)
|
|
||||||
{
|
|
||||||
if (code < m_static_funcs_list.size())
|
|
||||||
{
|
|
||||||
(*m_static_funcs_list[code]->func)(CPU);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_ERROR(LOADER, "StaticExecute(%d): unknown function or illegal opcode", code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StaticFuncManager::StaticFinalize()
|
void StaticFuncManager::StaticFinalize()
|
||||||
{
|
{
|
||||||
for (SFunc *s : m_static_funcs_list)
|
for (SFunc *s : m_static_funcs_list)
|
||||||
|
@ -9,7 +9,6 @@ class StaticFuncManager
|
|||||||
std::vector<SFunc *> m_static_funcs_list;
|
std::vector<SFunc *> m_static_funcs_list;
|
||||||
public:
|
public:
|
||||||
void StaticAnalyse(void* ptr, u32 size, u32 base);
|
void StaticAnalyse(void* ptr, u32 size, u32 base);
|
||||||
void StaticExecute(PPUThread& CPU, u32 code);
|
|
||||||
void StaticFinalize();
|
void StaticFinalize();
|
||||||
void push_back(SFunc *ele);
|
void push_back(SFunc *ele);
|
||||||
SFunc *operator[](size_t i);
|
SFunc *operator[](size_t i);
|
||||||
|
Loading…
Reference in New Issue
Block a user