More clang fixes.
This commit is contained in:
parent
12a29371e3
commit
bebda48a4f
|
@ -224,12 +224,12 @@ void KernelState::SetExecutableModule(object_ref<XUserModule> module) {
|
|||
}
|
||||
|
||||
// Setup the kernel's XexExecutableModuleHandle field.
|
||||
auto export = processor()->export_resolver()->GetExportByOrdinal(
|
||||
auto export_entry = processor()->export_resolver()->GetExportByOrdinal(
|
||||
"xboxkrnl.exe", ordinals::XexExecutableModuleHandle);
|
||||
if (export) {
|
||||
assert_not_zero(export->variable_ptr);
|
||||
auto variable_ptr =
|
||||
memory()->TranslateVirtual<xe::be<uint32_t>*>(export->variable_ptr);
|
||||
if (export_entry) {
|
||||
assert_not_zero(export_entry->variable_ptr);
|
||||
auto variable_ptr = memory()->TranslateVirtual<xe::be<uint32_t>*>(
|
||||
export_entry->variable_ptr);
|
||||
*variable_ptr = executable_module_->hmodule_ptr();
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,6 @@ void KernelState::CompleteOverlappedDeferredEx(
|
|||
xe::threading::Sleep(
|
||||
std::chrono::milliseconds::duration(kDeferredOverlappedDelayMillis));
|
||||
completion_callback();
|
||||
auto ptr = memory()->TranslateVirtual(overlapped_ptr);
|
||||
CompleteOverlappedEx(overlapped_ptr, result, extended_error, length);
|
||||
});
|
||||
dispatch_cond_.notify_all();
|
||||
|
|
|
@ -28,23 +28,23 @@ XKernelModule::XKernelModule(KernelState* kernel_state, const char* path)
|
|||
XKernelModule::~XKernelModule() {}
|
||||
|
||||
uint32_t XKernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
|
||||
auto export = export_resolver_->GetExportByOrdinal(name(), ordinal);
|
||||
if (!export) {
|
||||
auto export_entry = export_resolver_->GetExportByOrdinal(name(), ordinal);
|
||||
if (!export_entry) {
|
||||
// Export (or its parent library) not found.
|
||||
return 0;
|
||||
}
|
||||
if (export->type == cpu::Export::Type::kVariable) {
|
||||
if (export->variable_ptr) {
|
||||
return export->variable_ptr;
|
||||
if (export_entry->type == cpu::Export::Type::kVariable) {
|
||||
if (export_entry->variable_ptr) {
|
||||
return export_entry->variable_ptr;
|
||||
} else {
|
||||
XELOGW(
|
||||
"ERROR: var export referenced GetProcAddressByOrdinal(%.4X(%s)) is "
|
||||
"not implemented",
|
||||
ordinal, export->name);
|
||||
ordinal, export_entry->name);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (export->function_data.shim) {
|
||||
if (export_entry->function_data.shim) {
|
||||
// Implemented. Dynamically generate trampoline.
|
||||
XELOGE("GetProcAddressByOrdinal not implemented");
|
||||
return 0;
|
||||
|
@ -53,7 +53,7 @@ uint32_t XKernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
|
|||
XELOGW(
|
||||
"ERROR: fn export referenced GetProcAddressByOrdinal(%.4X(%s)) is "
|
||||
"not implemented",
|
||||
ordinal, export->name);
|
||||
ordinal, export_entry->name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,14 +45,7 @@ XThread::XThread(KernelState* kernel_state, uint32_t stack_size,
|
|||
bool guest_thread)
|
||||
: XObject(kernel_state, kTypeThread),
|
||||
thread_id_(++next_xthread_id),
|
||||
pcr_address_(0),
|
||||
thread_state_address_(0),
|
||||
thread_state_(0),
|
||||
priority_(0),
|
||||
affinity_(0),
|
||||
irql_(0),
|
||||
guest_thread_(guest_thread),
|
||||
running_(false) {
|
||||
guest_thread_(guest_thread) {
|
||||
creation_params_.stack_size = stack_size;
|
||||
creation_params_.xapi_thread_startup = xapi_thread_startup;
|
||||
creation_params_.start_address = start_address;
|
||||
|
|
|
@ -141,27 +141,27 @@ class XThread : public XObject {
|
|||
uint32_t start_address;
|
||||
uint32_t start_context;
|
||||
uint32_t creation_flags;
|
||||
} creation_params_;
|
||||
} creation_params_ = {0};
|
||||
|
||||
uint32_t thread_id_;
|
||||
uint32_t thread_id_ = 0;
|
||||
std::unique_ptr<xe::threading::Thread> thread_;
|
||||
uint32_t scratch_address_;
|
||||
uint32_t scratch_size_;
|
||||
uint32_t tls_address_;
|
||||
uint32_t pcr_address_;
|
||||
uint32_t thread_state_address_;
|
||||
cpu::ThreadState* thread_state_;
|
||||
bool guest_thread_; // Launched into guest code?
|
||||
bool running_;
|
||||
uint32_t scratch_address_ = 0;
|
||||
uint32_t scratch_size_ = 0;
|
||||
uint32_t tls_address_ = 0;
|
||||
uint32_t pcr_address_ = 0;
|
||||
uint32_t thread_state_address_ = 0;
|
||||
cpu::ThreadState* thread_state_ = nullptr;
|
||||
bool guest_thread_ = false; // Launched into guest code.
|
||||
bool running_ = false;
|
||||
|
||||
std::string name_;
|
||||
|
||||
int32_t priority_;
|
||||
uint32_t affinity_;
|
||||
int32_t priority_ = 0;
|
||||
uint32_t affinity_ = 0;
|
||||
|
||||
std::atomic<uint32_t> irql_;
|
||||
xe::mutex apc_lock_;
|
||||
NativeList* apc_list_;
|
||||
NativeList* apc_list_ = nullptr;
|
||||
};
|
||||
|
||||
class XHostThread : public XThread {
|
||||
|
|
|
@ -22,8 +22,6 @@ XTimer::~XTimer() = default;
|
|||
|
||||
void XTimer::Initialize(uint32_t timer_type) {
|
||||
assert_false(timer_);
|
||||
|
||||
bool manual_reset = false;
|
||||
switch (timer_type) {
|
||||
case 0: // NotificationTimer
|
||||
timer_ = xe::threading::Timer::CreateManualResetTimer();
|
||||
|
|
|
@ -107,41 +107,40 @@ class Param {
|
|||
Param() : ordinal_(-1) {}
|
||||
explicit Param(Init& init) : ordinal_(--init.ordinal) {}
|
||||
|
||||
template <typename V>
|
||||
void LoadValue(Init& init, V* out_value) {
|
||||
if (ordinal_ <= 7) {
|
||||
*out_value = V(init.ppc_context->r[3 + ordinal_]);
|
||||
} else {
|
||||
uint32_t stack_ptr =
|
||||
uint32_t(init.ppc_context->r[1]) + 0x54 + (ordinal_ - 7) * 8;
|
||||
*out_value =
|
||||
xe::load_and_swap<V>(init.ppc_context->virtual_membase + stack_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
int ordinal_;
|
||||
};
|
||||
template <>
|
||||
inline void Param::LoadValue<float>(Param::Init& init, float* out_value) {
|
||||
*out_value = float(init.ppc_context->f[1 + ++init.float_ordinal]);
|
||||
}
|
||||
template <>
|
||||
inline void Param::LoadValue<double>(Param::Init& init, double* out_value) {
|
||||
*out_value = init.ppc_context->f[1 + ++init.float_ordinal];
|
||||
}
|
||||
template <typename T>
|
||||
class ParamBase : public Param {
|
||||
public:
|
||||
ParamBase() : Param(), value_(0) {}
|
||||
ParamBase(T value) : Param(), value_(value) {}
|
||||
ParamBase(Init& init) : Param(init) { LoadValue<T>(init); }
|
||||
ParamBase(Init& init) : Param(init) { LoadValue<T>(init, &value_); }
|
||||
ParamBase& operator=(const T& other) {
|
||||
value_ = other;
|
||||
return *this;
|
||||
}
|
||||
operator T() const { return value_; }
|
||||
|
||||
private:
|
||||
template <typename V>
|
||||
void LoadValue(Init& init) {
|
||||
if (ordinal_ <= 7) {
|
||||
value_ = V(init.ppc_context->r[3 + ordinal_]);
|
||||
} else {
|
||||
uint32_t stack_ptr =
|
||||
uint32_t(init.ppc_context->r[1]) + 0x54 + (ordinal_ - 7) * 8;
|
||||
value_ =
|
||||
xe::load_and_swap<T>(init.ppc_context->virtual_membase + stack_ptr);
|
||||
}
|
||||
}
|
||||
template <>
|
||||
void LoadValue<float>(Init& init) {
|
||||
value_ = init.ppc_context->f[1 + ++init.float_ordinal];
|
||||
}
|
||||
template <>
|
||||
void LoadValue<double>(Init& init) {
|
||||
value_ = init.ppc_context->f[1 + ++init.float_ordinal];
|
||||
}
|
||||
|
||||
protected:
|
||||
T value_;
|
||||
};
|
||||
|
@ -365,34 +364,34 @@ enum class KernelModuleId {
|
|||
|
||||
template <size_t I = 0, typename... Ps>
|
||||
typename std::enable_if<I == sizeof...(Ps)>::type AppendKernelCallParams(
|
||||
StringBuffer& string_buffer, xe::cpu::Export* export,
|
||||
StringBuffer& string_buffer, xe::cpu::Export* export_entry,
|
||||
const std::tuple<Ps...>&) {}
|
||||
|
||||
template <size_t I = 0, typename... Ps>
|
||||
typename std::enable_if <
|
||||
I<sizeof...(Ps)>::type AppendKernelCallParams(
|
||||
StringBuffer& string_buffer, xe::cpu::Export* export,
|
||||
StringBuffer& string_buffer, xe::cpu::Export* export_entry,
|
||||
const std::tuple<Ps...>& params) {
|
||||
if (I) {
|
||||
string_buffer.Append(", ");
|
||||
}
|
||||
auto param = std::get<I>(params);
|
||||
AppendParam(string_buffer, param);
|
||||
AppendKernelCallParams<I + 1>(string_buffer, export, params);
|
||||
AppendKernelCallParams<I + 1>(string_buffer, export_entry, params);
|
||||
}
|
||||
|
||||
StringBuffer* thread_local_string_buffer();
|
||||
|
||||
template <typename Tuple>
|
||||
void PrintKernelCall(cpu::Export* export, const Tuple& params) {
|
||||
void PrintKernelCall(cpu::Export* export_entry, const Tuple& params) {
|
||||
auto& string_buffer = *thread_local_string_buffer();
|
||||
string_buffer.Reset();
|
||||
string_buffer.Append(export->name);
|
||||
string_buffer.Append(export_entry->name);
|
||||
string_buffer.Append('(');
|
||||
AppendKernelCallParams(string_buffer, export, params);
|
||||
AppendKernelCallParams(string_buffer, export_entry, params);
|
||||
string_buffer.Append(')');
|
||||
auto str = string_buffer.GetString();
|
||||
if (export->tags & ExportTag::kImportant) {
|
||||
if (export_entry->tags & ExportTag::kImportant) {
|
||||
XELOGI(str);
|
||||
} else {
|
||||
XELOGD(str);
|
||||
|
@ -407,56 +406,56 @@ auto KernelTrampoline(F&& f, Tuple&& t, std::index_sequence<I...>) {
|
|||
template <KernelModuleId MODULE, uint16_t ORDINAL, typename R, typename... Ps>
|
||||
xe::cpu::Export* RegisterExport(R (*fn)(Ps&...), const char* name,
|
||||
xe::cpu::ExportTag::type tags) {
|
||||
static const auto export =
|
||||
static const auto export_entry =
|
||||
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
||||
tags | ExportTag::kImplemented | ExportTag::kLog);
|
||||
static R (*FN)(Ps&...) = fn;
|
||||
struct X {
|
||||
static void Trampoline(PPCContext* ppc_context) {
|
||||
++export->function_data.call_count;
|
||||
++export_entry->function_data.call_count;
|
||||
Param::Init init = {
|
||||
ppc_context, sizeof...(Ps), 0,
|
||||
};
|
||||
auto params = std::make_tuple<Ps...>(Ps(init)...);
|
||||
if (export->tags & ExportTag::kLog) {
|
||||
PrintKernelCall(export, params);
|
||||
if (export_entry->tags & ExportTag::kLog) {
|
||||
PrintKernelCall(export_entry, params);
|
||||
}
|
||||
auto result =
|
||||
KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params),
|
||||
std::make_index_sequence<sizeof...(Ps)>());
|
||||
result.Store(ppc_context);
|
||||
if (export->tags & (ExportTag::kLog | ExportTag::kLogResult)) {
|
||||
if (export_entry->tags & (ExportTag::kLog | ExportTag::kLogResult)) {
|
||||
// TODO(benvanik): log result.
|
||||
}
|
||||
}
|
||||
};
|
||||
export->function_data.trampoline = &X::Trampoline;
|
||||
return export;
|
||||
export_entry->function_data.trampoline = &X::Trampoline;
|
||||
return export_entry;
|
||||
}
|
||||
|
||||
template <KernelModuleId MODULE, uint16_t ORDINAL, typename... Ps>
|
||||
xe::cpu::Export* RegisterExport(void (*fn)(Ps&...), const char* name,
|
||||
xe::cpu::ExportTag::type tags) {
|
||||
static const auto export =
|
||||
static const auto export_entry =
|
||||
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
||||
tags | ExportTag::kImplemented | ExportTag::kLog);
|
||||
static void (*FN)(Ps&...) = fn;
|
||||
struct X {
|
||||
static void Trampoline(PPCContext* ppc_context) {
|
||||
++export->function_data.call_count;
|
||||
++export_entry->function_data.call_count;
|
||||
Param::Init init = {
|
||||
ppc_context, sizeof...(Ps),
|
||||
};
|
||||
auto params = std::make_tuple<Ps...>(Ps(init)...);
|
||||
if (export->tags & ExportTag::kLog) {
|
||||
PrintKernelCall(export, params);
|
||||
if (export_entry->tags & ExportTag::kLog) {
|
||||
PrintKernelCall(export_entry, params);
|
||||
}
|
||||
KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params),
|
||||
std::make_index_sequence<sizeof...(Ps)>());
|
||||
}
|
||||
};
|
||||
export->function_data.trampoline = &X::Trampoline;
|
||||
return export;
|
||||
export_entry->function_data.trampoline = &X::Trampoline;
|
||||
return export_entry;
|
||||
}
|
||||
|
||||
} // namespace shim
|
||||
|
|
|
@ -37,10 +37,10 @@ XamModule::XamModule(Emulator* emulator, KernelState* kernel_state)
|
|||
|
||||
std::vector<xe::cpu::Export*> xam_exports(4096);
|
||||
|
||||
xe::cpu::Export* RegisterExport_xam(xe::cpu::Export* export) {
|
||||
assert_true(export->ordinal < xam_exports.size());
|
||||
xam_exports[export->ordinal] = export;
|
||||
return export;
|
||||
xe::cpu::Export* RegisterExport_xam(xe::cpu::Export* export_entry) {
|
||||
assert_true(export_entry->ordinal < xam_exports.size());
|
||||
xam_exports[export_entry->ordinal] = export_entry;
|
||||
return export_entry;
|
||||
}
|
||||
|
||||
void XamModule::RegisterExportTable(xe::cpu::ExportResolver* export_resolver) {
|
||||
|
@ -53,10 +53,10 @@ void XamModule::RegisterExportTable(xe::cpu::ExportResolver* export_resolver) {
|
|||
};
|
||||
#include "xenia/kernel/util/export_table_post.inc"
|
||||
for (size_t i = 0; i < xe::countof(xam_export_table); ++i) {
|
||||
auto& export = xam_export_table[i];
|
||||
assert_true(export.ordinal < xam_exports.size());
|
||||
if (!xam_exports[export.ordinal]) {
|
||||
xam_exports[export.ordinal] = &export;
|
||||
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;
|
||||
}
|
||||
}
|
||||
export_resolver->RegisterTable("xam.xex", &xam_exports);
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace kernel {
|
|||
|
||||
class KernelState;
|
||||
|
||||
xe::cpu::Export* RegisterExport_xam(xe::cpu::Export* export);
|
||||
xe::cpu::Export* RegisterExport_xam(xe::cpu::Export* export_entry);
|
||||
|
||||
namespace xam {
|
||||
// Registration functions, one per file.
|
||||
|
|
|
@ -280,9 +280,8 @@ SHIM_CALL XamUserWriteProfileSettings_shim(PPCContext* ppc_context,
|
|||
return;
|
||||
}
|
||||
|
||||
const auto& user_profile = kernel_state->user_profile();
|
||||
|
||||
// TODO: Update and save settings.
|
||||
// const auto& user_profile = kernel_state->user_profile();
|
||||
|
||||
if (overlapped_ptr) {
|
||||
kernel_state->CompleteOverlappedImmediate(overlapped_ptr, X_ERROR_SUCCESS);
|
||||
|
|
|
@ -139,10 +139,10 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
|
|||
|
||||
std::vector<xe::cpu::Export*> xboxkrnl_exports(4096);
|
||||
|
||||
xe::cpu::Export* RegisterExport_xboxkrnl(xe::cpu::Export* export) {
|
||||
assert_true(export->ordinal < xboxkrnl_exports.size());
|
||||
xboxkrnl_exports[export->ordinal] = export;
|
||||
return export;
|
||||
xe::cpu::Export* RegisterExport_xboxkrnl(xe::cpu::Export* export_entry) {
|
||||
assert_true(export_entry->ordinal < xboxkrnl_exports.size());
|
||||
xboxkrnl_exports[export_entry->ordinal] = export_entry;
|
||||
return export_entry;
|
||||
}
|
||||
|
||||
void XboxkrnlModule::RegisterExportTable(
|
||||
|
@ -156,10 +156,10 @@ void XboxkrnlModule::RegisterExportTable(
|
|||
};
|
||||
#include "xenia/kernel/util/export_table_post.inc"
|
||||
for (size_t i = 0; i < xe::countof(xboxkrnl_export_table); ++i) {
|
||||
auto& export = xboxkrnl_export_table[i];
|
||||
assert_true(export.ordinal < xboxkrnl_exports.size());
|
||||
if (!xboxkrnl_exports[export.ordinal]) {
|
||||
xboxkrnl_exports[export.ordinal] = &export;
|
||||
auto& export_entry = xboxkrnl_export_table[i];
|
||||
assert_true(export_entry.ordinal < xboxkrnl_exports.size());
|
||||
if (!xboxkrnl_exports[export_entry.ordinal]) {
|
||||
xboxkrnl_exports[export_entry.ordinal] = &export_entry;
|
||||
}
|
||||
}
|
||||
export_resolver->RegisterTable("xboxkrnl.exe", &xboxkrnl_exports);
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace kernel {
|
|||
|
||||
class KernelState;
|
||||
|
||||
xe::cpu::Export* RegisterExport_xboxkrnl(xe::cpu::Export* export);
|
||||
xe::cpu::Export* RegisterExport_xboxkrnl(xe::cpu::Export* export_entry);
|
||||
|
||||
namespace xboxkrnl {
|
||||
// Registration functions, one per file.
|
||||
|
|
|
@ -343,8 +343,8 @@ SHIM_CALL KeDelayExecutionThread_shim(PPCContext* ppc_context,
|
|||
SHIM_CALL NtYieldExecution_shim(PPCContext* ppc_context,
|
||||
KernelState* kernel_state) {
|
||||
// XELOGD("NtYieldExecution()");
|
||||
XThread* thread = XThread::GetCurrentThread();
|
||||
X_STATUS result = thread->Delay(0, 0, 0);
|
||||
auto thread = XThread::GetCurrentThread();
|
||||
thread->Delay(0, 0, 0);
|
||||
SHIM_SET_RETURN_32(0);
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,6 @@ SHIM_CALL KeQuerySystemTime_shim(PPCContext* ppc_context,
|
|||
XELOGD("KeQuerySystemTime(%.8X)", time_ptr);
|
||||
|
||||
uint64_t time = Clock::QueryGuestSystemTime();
|
||||
|
||||
if (time_ptr) {
|
||||
SHIM_SET_MEM_64(time_ptr, time);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue