From 60015afdc46f60a378b21cd9e57ebe5987c02f5a Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 8 Dec 2013 16:00:55 -0800 Subject: [PATCH] Misc fixes. --- src/alloy/backend/ivm/ivm_intcode.cc | 2 +- src/alloy/hir/function_builder.cc | 2 - src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc | 37 +++++++++++++++++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/alloy/backend/ivm/ivm_intcode.cc b/src/alloy/backend/ivm/ivm_intcode.cc index 8c530a14c..53ad877bb 100644 --- a/src/alloy/backend/ivm/ivm_intcode.cc +++ b/src/alloy/backend/ivm/ivm_intcode.cc @@ -592,7 +592,7 @@ int Translate_CALL_TRUE(TranslationContext& ctx, Instr* i) { } uint32_t IntCode_CALL_INDIRECT_XX(IntCodeState& ics, const IntCode* i, uint32_t reg) { - uint64_t target = ics.rf[reg].u64; + uint64_t target = ics.rf[reg].u32; // Check if return address - if so, return. if (target == ics.return_address) { diff --git a/src/alloy/hir/function_builder.cc b/src/alloy/hir/function_builder.cc index c64159aa8..05e9500b3 100644 --- a/src/alloy/hir/function_builder.cc +++ b/src/alloy/hir/function_builder.cc @@ -1455,8 +1455,6 @@ Value* FunctionBuilder::Splat(Value* value, TypeName target_type) { Value* FunctionBuilder::Permute( Value* control, Value* value1, Value* value2, TypeName part_type) { ASSERT_TYPES_EQUAL(value1, value2); - // For now. - XEASSERT(part_type == INT32_TYPE || part_type == FLOAT32_TYPE); // TODO(benvanik): could do some of this as constants. diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc index 6c157dcd6..02838fdae 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc @@ -210,9 +210,38 @@ SHIM_CALL XexGetModuleHandle_shim( // } -// SHIM_CALL XexGetProcedureAddress_shim( -// PPCContext* ppc_state, KernelState* state) { -// } +SHIM_CALL XexGetProcedureAddress_shim( + PPCContext* ppc_state, KernelState* state) { + uint32_t module_handle = SHIM_GET_ARG_32(0); + uint32_t ordinal = SHIM_GET_ARG_32(1); + uint32_t out_function_ptr = SHIM_GET_ARG_32(2); + + XELOGD( + "XexGetProcedureAddress(%.8X, %.8X, %.8X)", + module_handle, ordinal, out_function_ptr); + + X_STATUS result = X_STATUS_INVALID_HANDLE; + + XModule* module = NULL; + + if (!module_handle) { + module = state->GetExecutableModule(); + } else { + result = state->object_table()->GetObject( + module_handle, (XObject**)&module); + } + + if (XSUCCEEDED(result)) { + // TODO(benvanik): implement. May need to create stub functions on the fly. + // module->GetProcAddressByOrdinal(ordinal); + result = X_STATUS_INVALID_HANDLE; + } + if (module) { + module->Release(); + } + + SHIM_SET_RETURN(result); +} } // namespace xboxkrnl @@ -228,5 +257,5 @@ void xe::kernel::xboxkrnl::RegisterModuleExports( SHIM_SET_MAPPING("xboxkrnl.exe", XexGetModuleHandle, state); // SHIM_SET_MAPPING("xboxkrnl.exe", XexGetModuleSection, state); - // SHIM_SET_MAPPING("xboxkrnl.exe", XexGetProcedureAddress, state); + SHIM_SET_MAPPING("xboxkrnl.exe", XexGetProcedureAddress, state); }