Fix compiler errors i introduced under clang-cl

remove xe_kernel_export_shim_fn field of Export function_data, trampoline is now the only way exports get invoked
Remove kernelstate argument from string functions in order to conform to the trampoline signature (the argument was unused anyway)
Constant-evaluated initialization of ppc_opcode_disasm_table, removal of unused std::vector fields
Constant-evaluated initialization of export tables
name field on export is just a const char* now, only immutable static strings are ever passed to it
Remove unused callcount field of export.
PM4 compare op function extracted
Globally apply /Oy, /GS-, /Gw on msvc windows
Remove imgui testwindow code call, it took up like 300 kb
This commit is contained in:
chss95cs@gmail.com
2022-09-29 07:04:17 -07:00
parent 203267b106
commit 7e58a3b320
20 changed files with 140 additions and 204 deletions

View File

@@ -94,7 +94,7 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
// Export (or its parent library) not found.
return 0;
}
if (export_entry->type == cpu::Export::Type::kVariable) {
if (export_entry->get_type() == cpu::Export::Type::kVariable) {
if (export_entry->variable_ptr) {
return export_entry->variable_ptr;
} else {
@@ -105,8 +105,7 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
return 0;
}
} else {
if (export_entry->function_data.trampoline ||
export_entry->function_data.shim) {
if (export_entry->function_data.trampoline) {
auto global_lock = global_critical_region_.Acquire();
// See if the function has been generated already.
@@ -119,9 +118,6 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
if (export_entry->function_data.trampoline) {
handler = (cpu::GuestFunction::ExternHandler)
export_entry->function_data.trampoline;
} else {
handler =
(cpu::GuestFunction::ExternHandler)export_entry->function_data.shim;
}
uint32_t guest_addr =

View File

@@ -783,7 +783,7 @@ void UserModule::Dump() {
}
}
if (kernel_export &&
kernel_export->type == cpu::Export::Type::kVariable) {
kernel_export->get_type() == cpu::Export::Type::kVariable) {
sb.AppendFormat(" V {:08X} {:03X} ({:4}) {} {}\n",
info->value_address, info->ordinal, info->ordinal,
implemented ? " " : "!!", name);

View File

@@ -554,7 +554,6 @@ struct ExportRegistrerHelper {
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name, TAGS);
struct X {
static void Trampoline(PPCContext* ppc_context) {
++export_entry->function_data.call_count;
Param::Init init = {
ppc_context,
0,

View File

@@ -91,7 +91,7 @@ DECLARE_XAM_EXPORT1(XamInputGetCapabilitiesEx, kInput, kSketchy);
dword_result_t XamInputGetState_entry(dword_t user_index, dword_t flags,
pointer_t<X_INPUT_STATE> input_state) {
if (input_state) {
memset((void*)input_state.host_address(), 0, sizeof X_INPUT_STATE);
memset((void*)input_state.host_address(), 0, sizeof(X_INPUT_STATE));
}
if (user_index >= 4) {
return X_ERROR_DEVICE_NOT_CONNECTED;

View File

@@ -41,21 +41,21 @@ xe::cpu::Export* RegisterExport_xam(xe::cpu::Export* export_entry) {
xam_exports[export_entry->ordinal] = export_entry;
return export_entry;
}
// Build the export table used for resolution.
#include "xenia/kernel/util/export_table_pre.inc"
static constexpr xe::cpu::Export xam_export_table[] = {
#include "xenia/kernel/xam/xam_table.inc"
};
#include "xenia/kernel/util/export_table_post.inc"
void XamModule::RegisterExportTable(xe::cpu::ExportResolver* export_resolver) {
assert_not_null(export_resolver);
// Build the export table used for resolution.
#include "xenia/kernel/util/export_table_pre.inc"
static xe::cpu::Export xam_export_table[] = {
#include "xenia/kernel/xam/xam_table.inc"
};
#include "xenia/kernel/util/export_table_post.inc"
for (size_t i = 0; i < xe::countof(xam_export_table); ++i) {
auto& export_entry = xam_export_table[i];
assert_true(export_entry.ordinal < xam_exports.size());
if (!xam_exports[export_entry.ordinal]) {
xam_exports[export_entry.ordinal] = &export_entry;
xam_exports[export_entry.ordinal] =
const_cast<xe::cpu::Export*>(&export_entry);
}
}
export_resolver->RegisterTable("xam.xex", &xam_exports);

View File

@@ -824,7 +824,7 @@ class WideCountFormatData : public FormatData {
int32_t count_;
};
SHIM_CALL DbgPrint_entry(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL DbgPrint_entry(PPCContext* ppc_context) {
uint32_t format_ptr = SHIM_GET_ARG_32(0);
if (!format_ptr) {
SHIM_SET_RETURN_32(X_STATUS_INVALID_PARAMETER);
@@ -854,7 +854,7 @@ SHIM_CALL DbgPrint_entry(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/2ts7cx93.aspx
SHIM_CALL _snprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL _snprintf_entry(PPCContext* ppc_context) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
@@ -894,7 +894,7 @@ SHIM_CALL _snprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/ybk95axf.aspx
SHIM_CALL sprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL sprintf_entry(PPCContext* ppc_context) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
@@ -925,7 +925,7 @@ SHIM_CALL sprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/2ts7cx93.aspx
SHIM_CALL _snwprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL _snwprintf_entry(PPCContext* ppc_context) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
@@ -966,7 +966,7 @@ SHIM_CALL _snwprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/ybk95axf.aspx
SHIM_CALL swprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL swprintf_entry(PPCContext* ppc_context) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
@@ -998,7 +998,7 @@ SHIM_CALL swprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/1kt27hek.aspx
SHIM_CALL _vsnprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL _vsnprintf_entry(PPCContext* ppc_context) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
@@ -1087,7 +1087,7 @@ SHIM_CALL _vsnwprintf_entry(PPCContext* ppc_context,
}
// https://msdn.microsoft.com/en-us/library/28d5ce15.aspx
SHIM_CALL vsprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL vsprintf_entry(PPCContext* ppc_context) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
uint32_t arg_ptr = SHIM_GET_ARG_32(2);
@@ -1147,7 +1147,7 @@ SHIM_CALL _vscwprintf_entry(PPCContext* ppc_context,
}
// https://msdn.microsoft.com/en-us/library/28d5ce15.aspx
SHIM_CALL vswprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL vswprintf_entry(PPCContext* ppc_context) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
uint32_t arg_ptr = SHIM_GET_ARG_32(2);
@@ -1179,7 +1179,7 @@ SHIM_CALL vswprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
}
SHIM_SET_RETURN_32(count);
}
#if 1
void RegisterStringExports(xe::cpu::ExportResolver* export_resolver,
KernelState* state) {
SHIM_SET_MAPPING("xboxkrnl.exe", DbgPrint, state);
@@ -1193,7 +1193,7 @@ void RegisterStringExports(xe::cpu::ExportResolver* export_resolver,
SHIM_SET_MAPPING("xboxkrnl.exe", vswprintf, state);
SHIM_SET_MAPPING("xboxkrnl.exe", _vsnwprintf, state);
}
#endif
} // namespace xboxkrnl
} // namespace kernel
} // namespace xe