1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

libmixer fix

This commit is contained in:
Nekotekina 2015-02-19 22:17:30 +03:00
parent c1786df2a6
commit 152feb898e
7 changed files with 19 additions and 130 deletions

View File

@ -2263,14 +2263,6 @@ private:
{
case 0x0: SysCall(); break;
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;
default: throw fmt::Format("SC(): unknown level (0x%x)", lev);
}

View File

@ -2007,10 +2007,6 @@ void Compiler::SC(u32 lev) {
case 0:
Call<void>("SysCalls.DoSyscall", SysCalls::DoSyscall, m_state.args[CompileTaskState::Args::State], GetGpr(11));
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:
Call<void>("PPUThread.FastStop", &PPUThread::FastStop, m_state.args[CompileTaskState::Args::State]);
break;

View File

@ -209,85 +209,3 @@ void Module::PushNewFuncSub(SFunc* 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);
}
}
}

View File

@ -30,17 +30,11 @@ struct SFuncOp
struct SFunc
{
func_caller* func;
void* ptr;
u32 index;
const char* name;
std::vector<SFuncOp> ops;
u64 group;
u32 found;
~SFunc()
{
delete func;
}
};
class StaticFuncManager;
@ -147,8 +141,7 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
if (!ops[0]) return;
SFunc* sf = new SFunc;
sf->ptr = (void *)func;
sf->func = bind_func(func);
sf->index = add_ps3_func(ModuleFunc(get_function_id(name), this, bind_func(func)));
sf->name = name;
sf->group = *(u64*)group;
sf->found = 0;
@ -167,12 +160,6 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
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, ...) \
static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \
module.AddFuncSub(group, name ## _table, #name, name)

View File

@ -312,10 +312,15 @@ int cellSurMixerCreate(vm::ptr<const CellSurMixerConfig> config)
port.channel = 8;
port.block = 16;
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.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;
surMixerCb.set(0);
@ -628,6 +633,11 @@ Module libmixer("libmixer", []()
{
g_surmx.audio_port = ~0;
libmixer.on_stop = []()
{
ssp.clear();
};
REG_SUB(libmixer, "surmxAAN", cellAANAddData,
0xffffffff7c691b78,
0xffffffff7c0802a6,

View File

@ -29,7 +29,7 @@ void StaticFuncManager::StaticAnalyse(void* ptr, u32 size, u32 base)
}
// skip NOP
if (data[k] == se32(0x60000000))
if (data[k] == se32(0x60000000))
{
x--;
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);
m_static_funcs_list[j]->found++;
data[i+0] = re32(0x39600000 | j); // li r11, j
data[i+1] = se32(0x44000042); // sc 2
data[i+0] = re32(0x04000000 | m_static_funcs_list[j]->index); // hack
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
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;
}
@ -138,7 +137,7 @@ void StaticFuncManager::StaticAnalyse(void* ptr, u32 size, u32 base)
// 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)
{
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)
{
@ -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()
{
for (SFunc *s : m_static_funcs_list)

View File

@ -9,7 +9,6 @@ class StaticFuncManager
std::vector<SFunc *> m_static_funcs_list;
public:
void StaticAnalyse(void* ptr, u32 size, u32 base);
void StaticExecute(PPUThread& CPU, u32 code);
void StaticFinalize();
void push_back(SFunc *ele);
SFunc *operator[](size_t i);