More style.
This commit is contained in:
@@ -19,7 +19,7 @@ namespace apps {
|
||||
|
||||
class XXGIApp : public XApp {
|
||||
public:
|
||||
XXGIApp(KernelState* kernel_state);
|
||||
explicit XXGIApp(KernelState* kernel_state);
|
||||
|
||||
X_RESULT DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
|
||||
uint32_t buffer_length) override;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace apps {
|
||||
|
||||
class XXLiveBaseApp : public XApp {
|
||||
public:
|
||||
XXLiveBaseApp(KernelState* kernel_state);
|
||||
explicit XXLiveBaseApp(KernelState* kernel_state);
|
||||
|
||||
X_RESULT DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
|
||||
uint32_t buffer_length) override;
|
||||
|
||||
@@ -66,7 +66,7 @@ class XXMPApp : public XApp {
|
||||
std::vector<std::unique_ptr<Song>> songs;
|
||||
};
|
||||
|
||||
XXMPApp(KernelState* kernel_state);
|
||||
explicit XXMPApp(KernelState* kernel_state);
|
||||
|
||||
X_RESULT XMPGetStatus(uint32_t status_ptr);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ struct XCONTENT_DATA {
|
||||
std::string file_name;
|
||||
|
||||
XCONTENT_DATA() = default;
|
||||
XCONTENT_DATA(const uint8_t* ptr) {
|
||||
explicit XCONTENT_DATA(const uint8_t* ptr) {
|
||||
device_id = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
content_type = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
display_name = xe::load_and_swap<std::wstring>(ptr + 8);
|
||||
|
||||
@@ -23,7 +23,7 @@ class NativeList;
|
||||
|
||||
class Dispatcher {
|
||||
public:
|
||||
Dispatcher(KernelState* kernel_state);
|
||||
explicit Dispatcher(KernelState* kernel_state);
|
||||
virtual ~Dispatcher();
|
||||
|
||||
KernelState* kernel_state() const { return kernel_state_; }
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/string.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
@@ -337,8 +339,8 @@ object_ref<XUserModule> KernelState::LoadUserModule(const char* raw_name) {
|
||||
void KernelState::TerminateTitle(bool from_guest_thread) {
|
||||
std::lock_guard<xe::recursive_mutex> lock(object_mutex_);
|
||||
|
||||
// First: Call terminate routines
|
||||
// TODO: These might take arguments
|
||||
// First: call terminate routines.
|
||||
// TODO(benvanik): these might take arguments.
|
||||
// FIXME: Calling these will send some threads into kernel code and they'll
|
||||
// hold the lock when terminated! Do we need to wait for all threads to exit?
|
||||
/*
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/mutex.h"
|
||||
#include "xenia/cpu/export_resolver.h"
|
||||
@@ -86,7 +87,7 @@ struct TerminateNotification {
|
||||
|
||||
class KernelState {
|
||||
public:
|
||||
KernelState(Emulator* emulator);
|
||||
explicit KernelState(Emulator* emulator);
|
||||
~KernelState();
|
||||
|
||||
static KernelState* shared();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace kernel {
|
||||
|
||||
class NativeList {
|
||||
public:
|
||||
NativeList(Memory* memory);
|
||||
explicit NativeList(Memory* memory);
|
||||
|
||||
void Insert(uint32_t list_entry_ptr);
|
||||
bool IsQueued(uint32_t list_entry_ptr);
|
||||
|
||||
@@ -61,8 +61,8 @@ X_STATUS ObjectTable::FindFreeSlot(uint32_t* out_slot) {
|
||||
uint32_t new_table_capacity = std::max(16 * 1024u, table_capacity_ * 2);
|
||||
size_t new_table_size = new_table_capacity * sizeof(ObjectTableEntry);
|
||||
size_t old_table_size = table_capacity_ * sizeof(ObjectTableEntry);
|
||||
ObjectTableEntry* new_table =
|
||||
(ObjectTableEntry*)realloc(table_, new_table_size);
|
||||
auto new_table =
|
||||
reinterpret_cast<ObjectTableEntry*>(realloc(table_, new_table_size));
|
||||
if (!new_table) {
|
||||
return X_STATUS_NO_MEMORY;
|
||||
}
|
||||
@@ -235,14 +235,14 @@ XObject* ObjectTable::LookupObject(X_HANDLE handle, bool already_locked) {
|
||||
}
|
||||
|
||||
void ObjectTable::GetObjectsByType(XObject::Type type,
|
||||
std::vector<object_ref<XObject>>& results) {
|
||||
std::vector<object_ref<XObject>>* results) {
|
||||
std::lock_guard<xe::recursive_mutex> lock(table_mutex_);
|
||||
for (uint32_t slot = 0; slot < table_capacity_; ++slot) {
|
||||
auto& entry = table_[slot];
|
||||
if (entry.object) {
|
||||
if (entry.object->type() == type) {
|
||||
entry.object->Retain();
|
||||
results.push_back(object_ref<XObject>(entry.object));
|
||||
results->push_back(object_ref<XObject>(entry.object));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/mutex.h"
|
||||
#include "xenia/kernel/xobject.h"
|
||||
@@ -46,7 +47,7 @@ class ObjectTable {
|
||||
std::vector<object_ref<T>> GetObjectsByType(XObject::Type type) {
|
||||
std::vector<object_ref<T>> results;
|
||||
GetObjectsByType(
|
||||
type, *reinterpret_cast<std::vector<object_ref<XObject>>*>(&results));
|
||||
type, reinterpret_cast<std::vector<object_ref<XObject>>*>(&results));
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ class ObjectTable {
|
||||
ObjectTableEntry* LookupTable(X_HANDLE handle);
|
||||
XObject* LookupObject(X_HANDLE handle, bool already_locked);
|
||||
void GetObjectsByType(XObject::Type type,
|
||||
std::vector<object_ref<XObject>>& results);
|
||||
std::vector<object_ref<XObject>>* results);
|
||||
|
||||
X_HANDLE TranslateHandle(X_HANDLE handle);
|
||||
X_STATUS FindFreeSlot(uint32_t* out_slot);
|
||||
|
||||
@@ -27,11 +27,11 @@ void XEvent::Initialize(bool manual_reset, bool initial_state) {
|
||||
}
|
||||
}
|
||||
|
||||
void XEvent::InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header) {
|
||||
void XEvent::InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header) {
|
||||
assert_false(event_);
|
||||
|
||||
bool manual_reset;
|
||||
switch (header.type) {
|
||||
switch (header->type) {
|
||||
case 0x00: // EventNotificationObject (manual reset)
|
||||
manual_reset = true;
|
||||
break;
|
||||
@@ -43,7 +43,7 @@ void XEvent::InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool initial_state = header.signal_state ? true : false;
|
||||
bool initial_state = header->signal_state ? true : false;
|
||||
Initialize(manual_reset, initial_state);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ struct X_KEVENT {
|
||||
|
||||
class XEvent : public XObject {
|
||||
public:
|
||||
XEvent(KernelState* kernel_state);
|
||||
explicit XEvent(KernelState* kernel_state);
|
||||
~XEvent() override;
|
||||
|
||||
void Initialize(bool manual_reset, bool initial_state);
|
||||
void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header);
|
||||
void InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header);
|
||||
|
||||
int32_t Set(uint32_t priority_increment, bool wait);
|
||||
int32_t Pulse(uint32_t priority_increment, bool wait);
|
||||
|
||||
@@ -60,9 +60,10 @@ X_STATUS XFile::QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info,
|
||||
}
|
||||
}
|
||||
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
auto end = reinterpret_cast<uint8_t*>(out_info) + length;
|
||||
const auto& entry_name = entry->name();
|
||||
if (((uint8_t*)&out_info->file_name[0]) + entry_name.size() > end) {
|
||||
if (reinterpret_cast<uint8_t*>(&out_info->file_name[0]) + entry_name.size() >
|
||||
end) {
|
||||
assert_always("Buffer overflow?");
|
||||
return X_STATUS_NO_SUCH_FILE;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
#ifndef XENIA_KERNEL_OBJECTS_XFILE_H_
|
||||
#define XENIA_KERNEL_OBJECTS_XFILE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "xenia/base/filesystem.h"
|
||||
#include "xenia/kernel/objects/xevent.h"
|
||||
#include "xenia/kernel/xobject.h"
|
||||
#include "xenia/vfs/device.h"
|
||||
#include "xenia/vfs/entry.h"
|
||||
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -53,10 +54,10 @@ class X_FILE_DIRECTORY_INFORMATION {
|
||||
|
||||
void Write(uint8_t* base, uint32_t p) {
|
||||
uint8_t* dst = base + p;
|
||||
uint8_t* src = (uint8_t*)this;
|
||||
uint8_t* src = reinterpret_cast<uint8_t*>(this);
|
||||
X_FILE_DIRECTORY_INFORMATION* info;
|
||||
do {
|
||||
info = (X_FILE_DIRECTORY_INFORMATION*)src;
|
||||
info = reinterpret_cast<X_FILE_DIRECTORY_INFORMATION*>(src);
|
||||
xe::store_and_swap<uint32_t>(dst, info->next_entry_offset);
|
||||
xe::store_and_swap<uint32_t>(dst + 4, info->file_index);
|
||||
xe::store_and_swap<uint64_t>(dst + 8, info->creation_time);
|
||||
|
||||
@@ -23,7 +23,7 @@ void XMutant::Initialize(bool initial_owner) {
|
||||
mutant_ = xe::threading::Mutant::Create(initial_owner);
|
||||
}
|
||||
|
||||
void XMutant::InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header) {
|
||||
void XMutant::InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header) {
|
||||
assert_false(mutant_);
|
||||
|
||||
// Haven't seen this yet, but it's possible.
|
||||
|
||||
@@ -19,11 +19,11 @@ namespace kernel {
|
||||
|
||||
class XMutant : public XObject {
|
||||
public:
|
||||
XMutant(KernelState* kernel_state);
|
||||
explicit XMutant(KernelState* kernel_state);
|
||||
~XMutant() override;
|
||||
|
||||
void Initialize(bool initial_owner);
|
||||
void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header);
|
||||
void InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header);
|
||||
|
||||
X_STATUS ReleaseMutant(uint32_t priority_increment, bool abandon, bool wait);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace kernel {
|
||||
|
||||
class XNotifyListener : public XObject {
|
||||
public:
|
||||
XNotifyListener(KernelState* kernel_state);
|
||||
explicit XNotifyListener(KernelState* kernel_state);
|
||||
~XNotifyListener() override;
|
||||
|
||||
uint64_t mask() const { return mask_; }
|
||||
|
||||
@@ -25,7 +25,7 @@ void XSemaphore::Initialize(int32_t initial_count, int32_t maximum_count) {
|
||||
semaphore_ = xe::threading::Semaphore::Create(initial_count, maximum_count);
|
||||
}
|
||||
|
||||
void XSemaphore::InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header) {
|
||||
void XSemaphore::InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header) {
|
||||
assert_false(semaphore_);
|
||||
|
||||
auto semaphore = reinterpret_cast<X_KSEMAPHORE*>(native_ptr);
|
||||
|
||||
@@ -24,11 +24,11 @@ struct X_KSEMAPHORE {
|
||||
|
||||
class XSemaphore : public XObject {
|
||||
public:
|
||||
XSemaphore(KernelState* kernel_state);
|
||||
explicit XSemaphore(KernelState* kernel_state);
|
||||
~XSemaphore() override;
|
||||
|
||||
void Initialize(int32_t initial_count, int32_t maximum_count);
|
||||
void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header);
|
||||
void InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header);
|
||||
|
||||
int32_t ReleaseSemaphore(int32_t release_count);
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@ DEFINE_bool(ignore_thread_affinities, true,
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
using namespace xe::cpu;
|
||||
|
||||
uint32_t next_xthread_id = 0;
|
||||
thread_local XThread* current_thread_tls = nullptr;
|
||||
xe::mutex critical_region_;
|
||||
@@ -220,9 +218,9 @@ X_STATUS XThread::Create() {
|
||||
|
||||
// Allocate processor thread state.
|
||||
// This is thread safe.
|
||||
thread_state_ = new ThreadState(kernel_state()->processor(), thread_id_,
|
||||
ThreadStackType::kUserStack, 0,
|
||||
creation_params_.stack_size, pcr_address_);
|
||||
thread_state_ = new cpu::ThreadState(
|
||||
kernel_state()->processor(), thread_id_, cpu::ThreadStackType::kUserStack,
|
||||
0, creation_params_.stack_size, pcr_address_);
|
||||
XELOGI("XThread%04X (%X) Stack: %.8X-%.8X", handle(),
|
||||
thread_state_->thread_id(), thread_state_->stack_limit(),
|
||||
thread_state_->stack_base());
|
||||
@@ -352,7 +350,7 @@ X_STATUS XThread::Exit(int exit_code) {
|
||||
// This may only be called on the thread itself.
|
||||
assert_true(XThread::GetCurrentThread() == this);
|
||||
|
||||
// TODO(benvanik); dispatch events? waiters? etc?
|
||||
// TODO(benvanik): dispatch events? waiters? etc?
|
||||
RundownAPCs();
|
||||
|
||||
// Set exit code.
|
||||
@@ -380,7 +378,7 @@ X_STATUS XThread::Exit(int exit_code) {
|
||||
}
|
||||
|
||||
X_STATUS XThread::Terminate(int exit_code) {
|
||||
// TODO: Inform the profiler that this thread is exiting.
|
||||
// TODO(benvanik): inform the profiler that this thread is exiting.
|
||||
|
||||
// Set exit code.
|
||||
X_KTHREAD* thread = guest_object<X_KTHREAD>();
|
||||
@@ -426,8 +424,9 @@ void XThread::Execute() {
|
||||
} else {
|
||||
// Run user code.
|
||||
uint64_t args[] = {creation_params_.start_context};
|
||||
exit_code = (int)kernel_state()->processor()->Execute(
|
||||
thread_state_, creation_params_.start_address, args, xe::countof(args));
|
||||
exit_code = static_cast<int>(kernel_state()->processor()->Execute(
|
||||
thread_state_, creation_params_.start_address, args,
|
||||
xe::countof(args)));
|
||||
// If we got here it means the execute completed without an exit being
|
||||
// called.
|
||||
// Treat the return code as an implicit exit code.
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace kernel {
|
||||
|
||||
class XTimer : public XObject {
|
||||
public:
|
||||
XTimer(KernelState* kernel_state);
|
||||
explicit XTimer(KernelState* kernel_state);
|
||||
~XTimer() override;
|
||||
|
||||
void Initialize(uint32_t timer_type);
|
||||
@@ -41,4 +41,4 @@ class XTimer : public XObject {
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_KERNEL_OBJECTS_TIMER_H_
|
||||
#endif // XENIA_KERNEL_OBJECTS_XTIMER_H_
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "xenia/kernel/objects/xuser_module.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
#include "xenia/cpu/xex_module.h"
|
||||
@@ -19,8 +21,6 @@
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
using namespace xe::cpu;
|
||||
|
||||
XUserModule::XUserModule(KernelState* kernel_state, const char* path)
|
||||
: XModule(kernel_state, ModuleType::kUserModule, path) {}
|
||||
|
||||
@@ -74,11 +74,11 @@ X_STATUS XUserModule::LoadFromFile(std::string path) {
|
||||
}
|
||||
|
||||
X_STATUS XUserModule::LoadFromMemory(const void* addr, const size_t length) {
|
||||
Processor* processor = kernel_state()->processor();
|
||||
auto processor = kernel_state()->processor();
|
||||
|
||||
// Prepare the module for execution.
|
||||
// Runtime takes ownership.
|
||||
auto xex_module = std::make_unique<XexModule>(processor, kernel_state());
|
||||
auto xex_module = std::make_unique<cpu::XexModule>(processor, kernel_state());
|
||||
if (!xex_module->Load(name_, path_, addr, length)) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
@@ -136,8 +136,8 @@ uint32_t XUserModule::GetProcAddressByName(const char* name) {
|
||||
X_STATUS XUserModule::GetSection(const char* name, uint32_t* out_section_data,
|
||||
uint32_t* out_section_size) {
|
||||
xex2_opt_resource_info* resource_header = nullptr;
|
||||
if (!XexModule::GetOptHeader(xex_header(), XEX_HEADER_RESOURCE_INFO,
|
||||
&resource_header)) {
|
||||
if (!cpu::XexModule::GetOptHeader(xex_header(), XEX_HEADER_RESOURCE_INFO,
|
||||
&resource_header)) {
|
||||
// No resources.
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
@@ -198,11 +198,14 @@ X_STATUS XUserModule::GetOptHeader(uint8_t* membase, const xex2_header* header,
|
||||
break;
|
||||
case 0x01:
|
||||
// Return pointer to data stored in header value.
|
||||
field_value = uint32_t((uint8_t*)&opt_header.value - membase);
|
||||
field_value = static_cast<uint32_t>(
|
||||
reinterpret_cast<const uint8_t*>(&opt_header.value) - membase);
|
||||
break;
|
||||
default:
|
||||
// Data stored at offset to header.
|
||||
field_value = uint32_t((uint8_t*)header - membase) + opt_header.offset;
|
||||
field_value = static_cast<uint32_t>(
|
||||
reinterpret_cast<const uint8_t*>(header) - membase) +
|
||||
opt_header.offset;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -275,12 +278,13 @@ void XUserModule::Dump() {
|
||||
auto& opt_header = header->headers[i];
|
||||
|
||||
// Stash a pointer (although this isn't used in every case)
|
||||
void* opt_header_ptr = (uint8_t*)header + opt_header.offset;
|
||||
auto opt_header_ptr =
|
||||
reinterpret_cast<const uint8_t*>(header) + opt_header.offset;
|
||||
switch (opt_header.key) {
|
||||
case XEX_HEADER_RESOURCE_INFO: {
|
||||
printf(" XEX_HEADER_RESOURCE_INFO:\n");
|
||||
auto opt_resource_info =
|
||||
reinterpret_cast<xex2_opt_resource_info*>(opt_header_ptr);
|
||||
reinterpret_cast<const xex2_opt_resource_info*>(opt_header_ptr);
|
||||
|
||||
uint32_t count = (opt_resource_info->size - 4) / 16;
|
||||
for (uint32_t j = 0; j < count; j++) {
|
||||
@@ -304,7 +308,7 @@ void XUserModule::Dump() {
|
||||
} break;
|
||||
case XEX_HEADER_BOUNDING_PATH: {
|
||||
auto opt_bound_path =
|
||||
reinterpret_cast<xex2_opt_bound_path*>(opt_header_ptr);
|
||||
reinterpret_cast<const xex2_opt_bound_path*>(opt_header_ptr);
|
||||
printf(" XEX_HEADER_BOUNDING_PATH: %s\n", opt_bound_path->path);
|
||||
} break;
|
||||
case XEX_HEADER_ORIGINAL_BASE_ADDRESS: {
|
||||
@@ -343,15 +347,14 @@ void XUserModule::Dump() {
|
||||
}
|
||||
}
|
||||
|
||||
auto libraries = (uint8_t*)opt_import_libraries +
|
||||
opt_import_libraries->string_table_size + 12;
|
||||
auto libraries =
|
||||
reinterpret_cast<const uint8_t*>(opt_import_libraries) +
|
||||
opt_import_libraries->string_table_size + 12;
|
||||
uint32_t library_offset = 0;
|
||||
for (uint32_t l = 0; l < opt_import_libraries->library_count; l++) {
|
||||
auto library = reinterpret_cast<xex2_import_library*>(
|
||||
(uint8_t*)libraries + library_offset);
|
||||
auto library = reinterpret_cast<const xex2_import_library*>(
|
||||
libraries + library_offset);
|
||||
auto name = string_table[library->name_index];
|
||||
|
||||
// Okay. Dump it.
|
||||
printf(" %s - %d imports\n", name, (uint16_t)library->count);
|
||||
|
||||
// Manually byteswap these because of the bitfields.
|
||||
@@ -372,7 +375,7 @@ void XUserModule::Dump() {
|
||||
} break;
|
||||
case XEX_HEADER_ORIGINAL_PE_NAME: {
|
||||
auto opt_pe_name =
|
||||
reinterpret_cast<xex2_opt_original_pe_name*>(opt_header_ptr);
|
||||
reinterpret_cast<const xex2_opt_original_pe_name*>(opt_header_ptr);
|
||||
printf(" XEX_HEADER_ORIGINAL_PE_NAME: %s\n", opt_pe_name->name);
|
||||
} break;
|
||||
case XEX_HEADER_STATIC_LIBRARIES: {
|
||||
@@ -383,10 +386,11 @@ void XUserModule::Dump() {
|
||||
uint32_t count = (opt_static_libraries->size - 4) / 0x10;
|
||||
for (uint32_t l = 0; l < count; l++) {
|
||||
auto& library = opt_static_libraries->libraries[l];
|
||||
printf(
|
||||
" %-8s : %d.%d.%d.%d\n", library.name,
|
||||
(uint16_t)library.version_major, (uint16_t)library.version_minor,
|
||||
(uint16_t)library.version_build, (uint16_t)library.version_qfe);
|
||||
printf(" %-8s : %d.%d.%d.%d\n", library.name,
|
||||
static_cast<uint16_t>(library.version_major),
|
||||
static_cast<uint16_t>(library.version_minor),
|
||||
static_cast<uint16_t>(library.version_build),
|
||||
static_cast<uint16_t>(library.version_qfe));
|
||||
}
|
||||
} break;
|
||||
case XEX_HEADER_TLS_INFO: {
|
||||
@@ -395,42 +399,46 @@ void XUserModule::Dump() {
|
||||
reinterpret_cast<const xex2_opt_tls_info*>(opt_header_ptr);
|
||||
|
||||
printf(" Slot Count: %d\n",
|
||||
(uint32_t)opt_tls_info->slot_count);
|
||||
static_cast<uint32_t>(opt_tls_info->slot_count));
|
||||
printf(" Raw Data Address: %.8X\n",
|
||||
(uint32_t)opt_tls_info->raw_data_address);
|
||||
printf(" Data Size: %d\n", (uint32_t)opt_tls_info->data_size);
|
||||
static_cast<uint32_t>(opt_tls_info->raw_data_address));
|
||||
printf(" Data Size: %d\n",
|
||||
static_cast<uint32_t>(opt_tls_info->data_size));
|
||||
printf(" Raw Data Size: %d\n",
|
||||
(uint32_t)opt_tls_info->raw_data_size);
|
||||
static_cast<uint32_t>(opt_tls_info->raw_data_size));
|
||||
} break;
|
||||
case XEX_HEADER_DEFAULT_STACK_SIZE: {
|
||||
printf(" XEX_HEADER_DEFAULT_STACK_SIZE: %d\n",
|
||||
(uint32_t)opt_header.value);
|
||||
static_cast<uint32_t>(opt_header.value));
|
||||
} break;
|
||||
case XEX_HEADER_DEFAULT_FILESYSTEM_CACHE_SIZE: {
|
||||
printf(" XEX_HEADER_DEFAULT_FILESYSTEM_CACHE_SIZE: %d\n",
|
||||
(uint32_t)opt_header.value);
|
||||
static_cast<uint32_t>(opt_header.value));
|
||||
} break;
|
||||
case XEX_HEADER_DEFAULT_HEAP_SIZE: {
|
||||
printf(" XEX_HEADER_DEFAULT_HEAP_SIZE: %d\n",
|
||||
(uint32_t)opt_header.value);
|
||||
static_cast<uint32_t>(opt_header.value));
|
||||
} break;
|
||||
case XEX_HEADER_PAGE_HEAP_SIZE_AND_FLAGS: {
|
||||
printf(" XEX_HEADER_PAGE_HEAP_SIZE_AND_FLAGS (TODO):\n");
|
||||
} break;
|
||||
case XEX_HEADER_SYSTEM_FLAGS: {
|
||||
printf(" XEX_HEADER_SYSTEM_FLAGS: %.8X\n", (uint32_t)opt_header.value);
|
||||
printf(" XEX_HEADER_SYSTEM_FLAGS: %.8X\n",
|
||||
static_cast<uint32_t>(opt_header.value));
|
||||
} break;
|
||||
case XEX_HEADER_EXECUTION_INFO: {
|
||||
printf(" XEX_HEADER_EXECUTION_INFO:\n");
|
||||
auto opt_exec_info =
|
||||
reinterpret_cast<const xex2_opt_execution_info*>(opt_header_ptr);
|
||||
|
||||
printf(" Media ID: %.8X\n", (uint32_t)opt_exec_info->media_id);
|
||||
printf(" Title ID: %.8X\n", (uint32_t)opt_exec_info->title_id);
|
||||
printf(" Savegame ID: %.8X\n", (uint32_t)opt_exec_info->title_id);
|
||||
printf(" Disc Number / Total: %d / %d\n",
|
||||
(uint8_t)opt_exec_info->disc_number,
|
||||
(uint8_t)opt_exec_info->disc_count);
|
||||
printf(" Media ID: %.8X\n",
|
||||
static_cast<uint32_t>(opt_exec_info->media_id));
|
||||
printf(" Title ID: %.8X\n",
|
||||
static_cast<uint32_t>(opt_exec_info->title_id));
|
||||
printf(" Savegame ID: %.8X\n",
|
||||
static_cast<uint32_t>(opt_exec_info->title_id));
|
||||
printf(" Disc Number / Total: %d / %d\n", opt_exec_info->disc_number,
|
||||
opt_exec_info->disc_count);
|
||||
} break;
|
||||
case XEX_HEADER_TITLE_WORKSPACE_SIZE: {
|
||||
printf(" XEX_HEADER_TITLE_WORKSPACE_SIZE: %d\n",
|
||||
@@ -463,23 +471,21 @@ void XUserModule::Dump() {
|
||||
auto exe_address = xex_module()->xex_security_info()->load_address;
|
||||
auto e = memory()->TranslateVirtual<const X_IMAGE_EXPORT_DIRECTORY*>(
|
||||
exe_address + dir->offset);
|
||||
auto e_base = reinterpret_cast<uintptr_t>(e);
|
||||
|
||||
// e->AddressOfX RVAs are relative to the IMAGE_EXPORT_DIRECTORY!
|
||||
uint32_t* function_table =
|
||||
(uint32_t*)((uint64_t)e + e->AddressOfFunctions);
|
||||
|
||||
// Names relative to directory
|
||||
uint32_t* name_table = (uint32_t*)((uint64_t)e + e->AddressOfNames);
|
||||
|
||||
// Table of ordinals (by name)
|
||||
uint16_t* ordinal_table =
|
||||
(uint16_t*)((uint64_t)e + e->AddressOfNameOrdinals);
|
||||
|
||||
auto function_table =
|
||||
reinterpret_cast<const uint32_t*>(e_base + e->AddressOfFunctions);
|
||||
// Names relative to directory.
|
||||
auto name_table =
|
||||
reinterpret_cast<const uint32_t*>(e_base + e->AddressOfNames);
|
||||
// Table of ordinals (by name).
|
||||
auto ordinal_table = reinterpret_cast<const uint16_t*>(
|
||||
e_base + e->AddressOfNameOrdinals);
|
||||
for (uint32_t n = 0; n < e->NumberOfNames; n++) {
|
||||
const char* name = (const char*)((uint8_t*)e + name_table[n]);
|
||||
auto name = reinterpret_cast<const char*>(e_base + name_table[n]);
|
||||
uint16_t ordinal = ordinal_table[n];
|
||||
uint32_t addr = exe_address + function_table[ordinal];
|
||||
|
||||
printf(" %-28s - %.3X - %.8X\n", name, ordinal, addr);
|
||||
}
|
||||
} break;
|
||||
@@ -515,14 +521,14 @@ void XUserModule::Dump() {
|
||||
uint32_t start_address = security_info->load_address + (page * page_size);
|
||||
uint32_t end_address = start_address + (page_descriptor.size * page_size);
|
||||
|
||||
printf(" %3d %s %3d pages %.8X - %.8X (%d bytes)\n", (int)page, type,
|
||||
page_descriptor.size, (int)start_address, (int)end_address,
|
||||
printf(" %3u %s %3u pages %.8X - %.8X (%d bytes)\n", page, type,
|
||||
page_descriptor.size, start_address, end_address,
|
||||
page_descriptor.size * page_size);
|
||||
page += page_descriptor.size;
|
||||
}
|
||||
|
||||
// Print out imports.
|
||||
// TODO: Figure out a way to remove dependency on old xex header.
|
||||
// TODO(benvanik): figure out a way to remove dependency on old xex header.
|
||||
auto old_header = xe_xex2_get_header(xex_module()->xex());
|
||||
|
||||
printf("Imports:\n");
|
||||
@@ -533,7 +539,7 @@ void XUserModule::Dump() {
|
||||
size_t import_info_count;
|
||||
if (!xe_xex2_get_import_infos(xex_module()->xex(), library, &import_infos,
|
||||
&import_info_count)) {
|
||||
printf(" %s - %d imports\n", library->name, (int)import_info_count);
|
||||
printf(" %s - %lld imports\n", library->name, import_info_count);
|
||||
printf(" Version: %d.%d.%d.%d\n", library->version.major,
|
||||
library->version.minor, library->version.build,
|
||||
library->version.qfe);
|
||||
@@ -582,12 +588,13 @@ void XUserModule::Dump() {
|
||||
}
|
||||
}
|
||||
}
|
||||
printf(" Total: %4u\n", uint32_t(import_info_count));
|
||||
float total_count = static_cast<float>(import_info_count) * 100.0f;
|
||||
printf(" Total: %4llu\n", import_info_count);
|
||||
printf(" Known: %3d%% (%d known, %d unknown)\n",
|
||||
(int)(known_count / (float)import_info_count * 100.0f),
|
||||
known_count, unknown_count);
|
||||
static_cast<int>(known_count / total_count), known_count,
|
||||
unknown_count);
|
||||
printf(" Implemented: %3d%% (%d implemented, %d unimplemented)\n",
|
||||
(int)(impl_count / (float)import_info_count * 100.0f), impl_count,
|
||||
static_cast<int>(impl_count / total_count), impl_count,
|
||||
unimpl_count);
|
||||
printf("\n");
|
||||
|
||||
@@ -597,7 +604,7 @@ void XUserModule::Dump() {
|
||||
const char* name = "UNKNOWN";
|
||||
bool implemented = false;
|
||||
|
||||
Export* kernel_export = nullptr;
|
||||
cpu::Export* kernel_export = nullptr;
|
||||
if (kernel_state_->IsKernelModule(library->name)) {
|
||||
kernel_export =
|
||||
export_resolver->GetExportByOrdinal(library->name, info->ordinal);
|
||||
@@ -608,11 +615,12 @@ void XUserModule::Dump() {
|
||||
} else {
|
||||
auto module = kernel_state_->GetModule(library->name);
|
||||
if (module && module->GetProcAddressByOrdinal(info->ordinal)) {
|
||||
// TODO: Name lookup
|
||||
// TODO(benvanik): name lookup.
|
||||
implemented = true;
|
||||
}
|
||||
}
|
||||
if (kernel_export && kernel_export->type == Export::Type::kVariable) {
|
||||
if (kernel_export &&
|
||||
kernel_export->type == cpu::Export::Type::kVariable) {
|
||||
printf(" V %.8X %.3X (%3d) %s %s\n", info->value_address,
|
||||
info->ordinal, info->ordinal, implemented ? " " : "!!", name);
|
||||
} else if (info->thunk_address) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define XENIA_KERNEL_UTIL_SHIM_UTILS_H_
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "xenia/base/byte_order.h"
|
||||
#include "xenia/base/memory.h"
|
||||
@@ -313,51 +314,51 @@ using pointer_result_t = shim::Result<uint32_t>;
|
||||
|
||||
namespace shim {
|
||||
|
||||
inline void AppendParam(StringBuffer& string_buffer, int_t param) {
|
||||
string_buffer.AppendFormat("%d", int32_t(param));
|
||||
inline void AppendParam(StringBuffer* string_buffer, int_t param) {
|
||||
string_buffer->AppendFormat("%d", int32_t(param));
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, dword_t param) {
|
||||
string_buffer.AppendFormat("%.8X", uint32_t(param));
|
||||
inline void AppendParam(StringBuffer* string_buffer, dword_t param) {
|
||||
string_buffer->AppendFormat("%.8X", uint32_t(param));
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, qword_t param) {
|
||||
string_buffer.AppendFormat("%.16llX", uint64_t(param));
|
||||
inline void AppendParam(StringBuffer* string_buffer, qword_t param) {
|
||||
string_buffer->AppendFormat("%.16llX", uint64_t(param));
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, float_t param) {
|
||||
string_buffer.AppendFormat("%G", static_cast<float>(param));
|
||||
inline void AppendParam(StringBuffer* string_buffer, float_t param) {
|
||||
string_buffer->AppendFormat("%G", static_cast<float>(param));
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, double_t param) {
|
||||
string_buffer.AppendFormat("%G", static_cast<double>(param));
|
||||
inline void AppendParam(StringBuffer* string_buffer, double_t param) {
|
||||
string_buffer->AppendFormat("%G", static_cast<double>(param));
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, lpvoid_t param) {
|
||||
string_buffer.AppendFormat("%.8X", uint32_t(param));
|
||||
inline void AppendParam(StringBuffer* string_buffer, lpvoid_t param) {
|
||||
string_buffer->AppendFormat("%.8X", uint32_t(param));
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, lpdword_t param) {
|
||||
string_buffer.AppendFormat("%.8X", param.guest_address());
|
||||
inline void AppendParam(StringBuffer* string_buffer, lpdword_t param) {
|
||||
string_buffer->AppendFormat("%.8X", param.guest_address());
|
||||
if (param) {
|
||||
string_buffer.AppendFormat("(%.8X)", param.value());
|
||||
string_buffer->AppendFormat("(%.8X)", param.value());
|
||||
}
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, lpqword_t param) {
|
||||
string_buffer.AppendFormat("%.8X", param.guest_address());
|
||||
inline void AppendParam(StringBuffer* string_buffer, lpqword_t param) {
|
||||
string_buffer->AppendFormat("%.8X", param.guest_address());
|
||||
if (param) {
|
||||
string_buffer.AppendFormat("(%.16llX)", param.value());
|
||||
string_buffer->AppendFormat("(%.16llX)", param.value());
|
||||
}
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, lpfloat_t param) {
|
||||
string_buffer.AppendFormat("%.8X", param.guest_address());
|
||||
inline void AppendParam(StringBuffer* string_buffer, lpfloat_t param) {
|
||||
string_buffer->AppendFormat("%.8X", param.guest_address());
|
||||
if (param) {
|
||||
string_buffer.AppendFormat("(%G)", param.value());
|
||||
string_buffer->AppendFormat("(%G)", param.value());
|
||||
}
|
||||
}
|
||||
inline void AppendParam(StringBuffer& string_buffer, lpdouble_t param) {
|
||||
string_buffer.AppendFormat("%.8X", param.guest_address());
|
||||
inline void AppendParam(StringBuffer* string_buffer, lpdouble_t param) {
|
||||
string_buffer->AppendFormat("%.8X", param.guest_address());
|
||||
if (param) {
|
||||
string_buffer.AppendFormat("(%G)", param.value());
|
||||
string_buffer->AppendFormat("(%G)", param.value());
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
void AppendParam(StringBuffer& string_buffer, pointer_t<T> param) {
|
||||
string_buffer.AppendFormat("%.8X", param.guest_address());
|
||||
void AppendParam(StringBuffer* string_buffer, pointer_t<T> param) {
|
||||
string_buffer->AppendFormat("%.8X", param.guest_address());
|
||||
}
|
||||
|
||||
enum class KernelModuleId {
|
||||
@@ -379,7 +380,7 @@ template <size_t I = 0, typename... Ps>
|
||||
string_buffer.Append(", ");
|
||||
}
|
||||
auto param = std::get<I>(params);
|
||||
AppendParam(string_buffer, param);
|
||||
AppendParam(&string_buffer, param);
|
||||
AppendKernelCallParams<I + 1>(string_buffer, export_entry, params);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
using namespace xe::hid;
|
||||
using xe::hid::X_INPUT_CAPABILITIES;
|
||||
using xe::hid::X_INPUT_KEYSTROKE;
|
||||
using xe::hid::X_INPUT_STATE;
|
||||
using xe::hid::X_INPUT_VIBRATION;
|
||||
|
||||
constexpr uint32_t XINPUT_FLAG_GAMEPAD = 0x01;
|
||||
constexpr uint32_t XINPUT_FLAG_ANY_USER = 1 << 30;
|
||||
@@ -69,7 +72,7 @@ SHIM_CALL XamInputGetCapabilities_shim(PPCContext* ppc_context,
|
||||
user_index = 0;
|
||||
}
|
||||
|
||||
InputSystem* input_system = kernel_state->emulator()->input_system();
|
||||
auto input_system = kernel_state->emulator()->input_system();
|
||||
|
||||
auto caps = SHIM_STRUCT(X_INPUT_CAPABILITIES, caps_ptr);
|
||||
X_RESULT result = input_system->GetCapabilities(user_index, flags, caps);
|
||||
@@ -100,7 +103,7 @@ SHIM_CALL XamInputGetCapabilitiesEx_shim(PPCContext* ppc_context,
|
||||
user_index = 0;
|
||||
}
|
||||
|
||||
InputSystem* input_system = kernel_state->emulator()->input_system();
|
||||
auto input_system = kernel_state->emulator()->input_system();
|
||||
|
||||
auto caps = SHIM_STRUCT(X_INPUT_CAPABILITIES, caps_ptr);
|
||||
X_RESULT result = input_system->GetCapabilities(user_index, flags, caps);
|
||||
@@ -128,7 +131,7 @@ SHIM_CALL XamInputGetState_shim(PPCContext* ppc_context,
|
||||
user_index = 0;
|
||||
}
|
||||
|
||||
InputSystem* input_system = kernel_state->emulator()->input_system();
|
||||
auto input_system = kernel_state->emulator()->input_system();
|
||||
|
||||
auto input_state = SHIM_STRUCT(X_INPUT_STATE, state_ptr);
|
||||
X_RESULT result = input_system->GetState(user_index, input_state);
|
||||
@@ -153,7 +156,7 @@ SHIM_CALL XamInputSetState_shim(PPCContext* ppc_context,
|
||||
user_index = 0;
|
||||
}
|
||||
|
||||
InputSystem* input_system = kernel_state->emulator()->input_system();
|
||||
auto input_system = kernel_state->emulator()->input_system();
|
||||
|
||||
auto vibration = SHIM_STRUCT(X_INPUT_VIBRATION, vibration_ptr);
|
||||
X_RESULT result = input_system->SetState(user_index, vibration);
|
||||
@@ -188,7 +191,7 @@ SHIM_CALL XamInputGetKeystroke_shim(PPCContext* ppc_context,
|
||||
user_index = 0;
|
||||
}
|
||||
|
||||
InputSystem* input_system = kernel_state->emulator()->input_system();
|
||||
auto input_system = kernel_state->emulator()->input_system();
|
||||
|
||||
auto keystroke = SHIM_STRUCT(X_INPUT_KEYSTROKE, keystroke_ptr);
|
||||
X_RESULT result = input_system->GetKeystroke(user_index, flags, keystroke);
|
||||
@@ -221,7 +224,7 @@ SHIM_CALL XamInputGetKeystrokeEx_shim(PPCContext* ppc_context,
|
||||
user_index = 0;
|
||||
}
|
||||
|
||||
InputSystem* input_system = kernel_state->emulator()->input_system();
|
||||
auto input_system = kernel_state->emulator()->input_system();
|
||||
|
||||
auto keystroke = SHIM_STRUCT(X_INPUT_KEYSTROKE, keystroke_ptr);
|
||||
X_RESULT result = input_system->GetKeystroke(user_index, flags, keystroke);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "xenia/kernel/xam_module.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/kernel/kernel_state.h"
|
||||
#include "xenia/kernel/xam_private.h"
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_XAM_H_
|
||||
#define XENIA_KERNEL_XAM_H_
|
||||
#ifndef XENIA_KERNEL_XAM_MODULE_H_
|
||||
#define XENIA_KERNEL_XAM_MODULE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "xenia/cpu/export_resolver.h"
|
||||
#include "xenia/kernel/objects/xkernel_module.h"
|
||||
@@ -41,4 +43,4 @@ class XamModule : public XKernelModule {
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_KERNEL_XAM_H_
|
||||
#endif // XENIA_KERNEL_XAM_MODULE_H_
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
// NOTE: must be included last as it expects windows.h to already be included.
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS // inet_addr
|
||||
#include <winsock2.h>
|
||||
#include <winsock2.h> // NOLINT(build/include_order)
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
@@ -190,7 +190,7 @@ SHIM_CALL NetDll_WSAStartup_shim(PPCContext* ppc_context,
|
||||
|
||||
XELOGD("NetDll_WSAStartup(%d, %.4X, %.8X)", caller, version, data_ptr);
|
||||
|
||||
// TODO: Abstraction layer needed
|
||||
// TODO(benvanik): abstraction layer needed.
|
||||
WSADATA wsaData;
|
||||
ZeroMemory(&wsaData, sizeof(WSADATA));
|
||||
int ret = WSAStartup(version, &wsaData);
|
||||
|
||||
@@ -27,7 +27,7 @@ SHIM_CALL XamIsUIActive_shim(PPCContext* ppc_context,
|
||||
|
||||
class MessageBoxWindow : public el::ModalForm {
|
||||
public:
|
||||
MessageBoxWindow(xe::threading::Fence* fence)
|
||||
explicit MessageBoxWindow(xe::threading::Fence* fence)
|
||||
: ModalForm([fence]() { fence->Signal(); }) {}
|
||||
~MessageBoxWindow() override = default;
|
||||
|
||||
@@ -51,7 +51,7 @@ class MessageBoxWindow : public el::ModalForm {
|
||||
|
||||
protected:
|
||||
void BuildUI() override {
|
||||
using namespace el::dsl;
|
||||
using namespace el::dsl; // NOLINT(build/namespaces)
|
||||
|
||||
set_text(xe::to_string(title_));
|
||||
|
||||
@@ -170,7 +170,7 @@ SHIM_CALL XamShowMessageBoxUI_shim(PPCContext* ppc_context,
|
||||
|
||||
class KeyboardInputWindow : public el::ModalForm {
|
||||
public:
|
||||
KeyboardInputWindow(xe::threading::Fence* fence)
|
||||
explicit KeyboardInputWindow(xe::threading::Fence* fence)
|
||||
: ModalForm([fence]() { fence->Signal(); }) {}
|
||||
~KeyboardInputWindow() override = default;
|
||||
|
||||
@@ -196,7 +196,7 @@ class KeyboardInputWindow : public el::ModalForm {
|
||||
|
||||
protected:
|
||||
void BuildUI() override {
|
||||
using namespace el::dsl;
|
||||
using namespace el::dsl; // NOLINT(build/namespaces)
|
||||
|
||||
set_text(xe::to_string(title_));
|
||||
|
||||
@@ -343,13 +343,13 @@ DECLARE_XAM_EXPORT(XamShowDeviceSelectorUI, ExportTag::kImplemented);
|
||||
|
||||
class DirtyDiscWindow : public el::ModalForm {
|
||||
public:
|
||||
DirtyDiscWindow(xe::threading::Fence* fence)
|
||||
explicit DirtyDiscWindow(xe::threading::Fence* fence)
|
||||
: ModalForm([fence]() { fence->Signal(); }) {}
|
||||
~DirtyDiscWindow() override = default;
|
||||
|
||||
protected:
|
||||
void BuildUI() override {
|
||||
using namespace el::dsl;
|
||||
using namespace el::dsl; // NOLINT(build/namespaces)
|
||||
|
||||
set_text("Disc Read Error");
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ SHIM_CALL XamUserGetSigninInfo_shim(PPCContext* ppc_context,
|
||||
SHIM_SET_MEM_32(info_ptr + 12, user_profile->signin_state());
|
||||
SHIM_SET_MEM_32(info_ptr + 16, 0); // ?
|
||||
SHIM_SET_MEM_32(info_ptr + 20, 0); // ?
|
||||
char* buffer = (char*)SHIM_MEM_ADDR(info_ptr + 24);
|
||||
strcpy(buffer, user_profile->name().data());
|
||||
char* buffer = reinterpret_cast<char*>(SHIM_MEM_ADDR(info_ptr + 24));
|
||||
std::strcpy(buffer, user_profile->name().data());
|
||||
SHIM_SET_RETURN_32(0);
|
||||
} else {
|
||||
SHIM_SET_RETURN_32(X_ERROR_NO_SUCH_USER);
|
||||
@@ -90,8 +90,8 @@ SHIM_CALL XamUserGetName_shim(PPCContext* ppc_context,
|
||||
|
||||
if (user_index == 0) {
|
||||
const auto& user_profile = kernel_state->user_profile();
|
||||
char* buffer = (char*)SHIM_MEM_ADDR(buffer_ptr);
|
||||
strcpy(buffer, user_profile->name().data());
|
||||
char* buffer = reinterpret_cast<char*>(SHIM_MEM_ADDR(buffer_ptr));
|
||||
std::strcpy(buffer, user_profile->name().data());
|
||||
SHIM_SET_RETURN_32(0);
|
||||
} else {
|
||||
SHIM_SET_RETURN_32(X_ERROR_NO_SUCH_USER);
|
||||
@@ -210,12 +210,13 @@ SHIM_CALL XamUserReadProfileSettings_shim(PPCContext* ppc_context,
|
||||
return;
|
||||
}
|
||||
|
||||
auto out_header = (X_USER_READ_PROFILE_SETTINGS*)SHIM_MEM_ADDR(buffer_ptr);
|
||||
auto out_header = reinterpret_cast<X_USER_READ_PROFILE_SETTINGS*>(
|
||||
SHIM_MEM_ADDR(buffer_ptr));
|
||||
out_header->setting_count = setting_count;
|
||||
out_header->settings_ptr = buffer_ptr + 8;
|
||||
|
||||
auto out_setting =
|
||||
(X_USER_READ_PROFILE_SETTING*)SHIM_MEM_ADDR(out_header->settings_ptr);
|
||||
auto out_setting = reinterpret_cast<X_USER_READ_PROFILE_SETTING*>(
|
||||
SHIM_MEM_ADDR(out_header->settings_ptr));
|
||||
|
||||
size_t buffer_offset = base_size_needed;
|
||||
for (uint32_t n = 0; n < setting_count; ++n) {
|
||||
@@ -231,9 +232,11 @@ SHIM_CALL XamUserReadProfileSettings_shim(PPCContext* ppc_context,
|
||||
buffer_offset =
|
||||
setting->Append(&out_setting->setting_data[0],
|
||||
SHIM_MEM_ADDR(buffer_ptr), buffer_ptr, buffer_offset);
|
||||
} /*else {
|
||||
}
|
||||
// TODO(benvanik): why did I do this?
|
||||
/*else {
|
||||
std::memset(&out_setting->setting_data[0], 0,
|
||||
sizeof(out_setting->setting_data));
|
||||
sizeof(out_setting->setting_data));
|
||||
}*/
|
||||
++out_setting;
|
||||
}
|
||||
@@ -280,7 +283,7 @@ SHIM_CALL XamUserWriteProfileSettings_shim(PPCContext* ppc_context,
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Update and save settings.
|
||||
// TODO(benvanik): update and save settings.
|
||||
// const auto& user_profile = kernel_state->user_profile();
|
||||
|
||||
if (overlapped_ptr) {
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
#include "xenia/kernel/xboxkrnl_private.h"
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
using namespace xe::apu;
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
using xe::apu::XMA_CONTEXT_DATA;
|
||||
|
||||
// See audio_system.cc for implementation details.
|
||||
//
|
||||
// XMA details:
|
||||
@@ -164,7 +164,8 @@ SHIM_CALL XMASetLoopData_shim(PPCContext* ppc_context,
|
||||
XELOGD("XMASetLoopData(%.8X, %.8X)", context_ptr, loop_data_ptr);
|
||||
|
||||
XMA_CONTEXT_DATA context(SHIM_MEM_ADDR(context_ptr));
|
||||
auto loop_data = (XMA_CONTEXT_DATA*)SHIM_MEM_ADDR(loop_data_ptr);
|
||||
auto loop_data =
|
||||
reinterpret_cast<XMA_CONTEXT_DATA*>(SHIM_MEM_ADDR(loop_data_ptr));
|
||||
|
||||
context.loop_start = loop_data->loop_start;
|
||||
context.loop_end = loop_data->loop_end;
|
||||
|
||||
@@ -24,22 +24,22 @@ typedef struct {
|
||||
uint8_t buffer[64]; // 0x18
|
||||
} XECRYPT_SHA_STATE;
|
||||
|
||||
void InitSha1(sha1::SHA1& sha, const XECRYPT_SHA_STATE* state) {
|
||||
void InitSha1(sha1::SHA1* sha, const XECRYPT_SHA_STATE* state) {
|
||||
uint32_t digest[5];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
digest[i] = state->state[i];
|
||||
}
|
||||
|
||||
sha.init(digest, state->buffer, state->count);
|
||||
sha->init(digest, state->buffer, state->count);
|
||||
}
|
||||
|
||||
void StoreSha1(sha1::SHA1& sha, XECRYPT_SHA_STATE* state) {
|
||||
void StoreSha1(sha1::SHA1* sha, XECRYPT_SHA_STATE* state) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
state->state[i] = sha.getDigest()[i];
|
||||
state->state[i] = sha->getDigest()[i];
|
||||
}
|
||||
|
||||
state->count = (uint32_t)sha.getByteCount();
|
||||
std::memcpy(state->buffer, sha.getBlock(), sha.getBlockByteIndex());
|
||||
state->count = static_cast<uint32_t>(sha->getByteCount());
|
||||
std::memcpy(state->buffer, sha->getBlock(), sha->getBlockByteIndex());
|
||||
}
|
||||
|
||||
void XeCryptShaInit(pointer_t<XECRYPT_SHA_STATE> sha_state) {
|
||||
@@ -56,18 +56,18 @@ DECLARE_XBOXKRNL_EXPORT(XeCryptShaInit, ExportTag::kImplemented);
|
||||
void XeCryptShaUpdate(pointer_t<XECRYPT_SHA_STATE> sha_state, lpvoid_t input,
|
||||
dword_t input_size) {
|
||||
sha1::SHA1 sha;
|
||||
InitSha1(sha, sha_state);
|
||||
InitSha1(&sha, sha_state);
|
||||
|
||||
sha.processBytes(input, input_size);
|
||||
|
||||
StoreSha1(sha, sha_state);
|
||||
StoreSha1(&sha, sha_state);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT(XeCryptShaUpdate, ExportTag::kImplemented);
|
||||
|
||||
void XeCryptShaFinal(pointer_t<XECRYPT_SHA_STATE> sha_state,
|
||||
pointer_t<xe::be<uint32_t>> out, dword_t out_size) {
|
||||
sha1::SHA1 sha;
|
||||
InitSha1(sha, sha_state);
|
||||
InitSha1(&sha, sha_state);
|
||||
|
||||
uint32_t digest[5];
|
||||
sha.finalize(digest);
|
||||
|
||||
@@ -40,10 +40,10 @@ typedef struct {
|
||||
xe::be<uint32_t> exception_information[15];
|
||||
} X_EXCEPTION_RECORD;
|
||||
static_assert_size(X_EXCEPTION_RECORD, 0x50);
|
||||
void AppendParam(StringBuffer& string_buffer,
|
||||
void AppendParam(StringBuffer* string_buffer,
|
||||
pointer_t<X_EXCEPTION_RECORD> record) {
|
||||
string_buffer.AppendFormat("%.8X(%.8X)", record.guest_address(),
|
||||
uint32_t(record->exception_code));
|
||||
string_buffer->AppendFormat("%.8X(%.8X)", record.guest_address(),
|
||||
uint32_t(record->exception_code));
|
||||
}
|
||||
|
||||
void RtlRaiseException(pointer_t<X_EXCEPTION_RECORD> record) {
|
||||
@@ -51,7 +51,8 @@ void RtlRaiseException(pointer_t<X_EXCEPTION_RECORD> record) {
|
||||
// SetThreadName. FFS.
|
||||
// https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
|
||||
|
||||
// TODO: check record->number_parameters to make sure it's a correct size
|
||||
// TODO(benvanik): check record->number_parameters to make sure it's a
|
||||
// correct size.
|
||||
auto thread_info =
|
||||
reinterpret_cast<X_THREADNAME_INFO*>(&record->exception_information[0]);
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
using namespace xe::vfs;
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/hardware/ff540287.aspx
|
||||
class X_FILE_FS_VOLUME_INFORMATION {
|
||||
public:
|
||||
@@ -123,7 +121,7 @@ dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access,
|
||||
|
||||
// Attempt open (or create).
|
||||
object_ref<XFile> file;
|
||||
FileAction file_action;
|
||||
xe::vfs::FileAction file_action;
|
||||
X_STATUS result = kernel_state()->file_system()->OpenFile(
|
||||
kernel_state(), target_path,
|
||||
xe::vfs::FileDisposition((uint32_t)creation_disposition), desired_access,
|
||||
@@ -152,7 +150,8 @@ dword_result_t NtOpenFile(lpdword_t handle_out, dword_t desired_access,
|
||||
dword_t open_options) {
|
||||
return NtCreateFile(handle_out, desired_access, object_attributes,
|
||||
io_status_block, nullptr, 0, 0,
|
||||
(uint32_t)FileDisposition::kOpen, open_options);
|
||||
static_cast<uint32_t>(xe::vfs::FileDisposition::kOpen),
|
||||
open_options);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT(NtOpenFile, ExportTag::kImplemented);
|
||||
|
||||
@@ -212,7 +211,7 @@ dword_result_t NtReadFile(dword_t file_handle, dword_t event_handle,
|
||||
// we have written the info out.
|
||||
signal_event = true;
|
||||
} else {
|
||||
// TODO: Async.
|
||||
// TODO(benvanik): async.
|
||||
|
||||
// X_STATUS_PENDING if not returning immediately.
|
||||
// XFile is waitable and signalled after each async req completes.
|
||||
@@ -454,10 +453,9 @@ dword_result_t NtQueryInformationFile(
|
||||
*/
|
||||
result = X_STATUS_UNSUCCESSFUL;
|
||||
info = 0;
|
||||
|
||||
} break;
|
||||
case XFileSectorInformation:
|
||||
// TODO: Return sector this file's on.
|
||||
// TODO(benvanik): return sector this file's on.
|
||||
assert_true(length == 4);
|
||||
|
||||
result = X_STATUS_UNSUCCESSFUL;
|
||||
|
||||
@@ -420,7 +420,8 @@ SHIM_CALL MmQueryStatistics_shim(PPCContext* ppc_context,
|
||||
|
||||
const uint32_t size = sizeof(X_MM_QUERY_STATISTICS_RESULT);
|
||||
|
||||
auto stats = (X_MM_QUERY_STATISTICS_RESULT*)SHIM_MEM_ADDR(stats_ptr);
|
||||
auto stats =
|
||||
reinterpret_cast<X_MM_QUERY_STATISTICS_RESULT*>(SHIM_MEM_ADDR(stats_ptr));
|
||||
if (stats->size != size) {
|
||||
SHIM_SET_RETURN_32(X_STATUS_BUFFER_TOO_SMALL);
|
||||
return;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/clock.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULE_H_
|
||||
#define XENIA_KERNEL_MODULE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_MODULE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_MODULE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -41,4 +41,4 @@ class XboxkrnlModule : public XKernelModule {
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_KERNEL_MODULE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_MODULE_H_
|
||||
|
||||
@@ -319,10 +319,10 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_context,
|
||||
SHIM_SET_RETURN_32(result);
|
||||
}
|
||||
|
||||
void AppendParam(StringBuffer& string_buffer,
|
||||
void AppendParam(StringBuffer* string_buffer,
|
||||
pointer_t<X_EX_TITLE_TERMINATE_REGISTRATION> reg) {
|
||||
string_buffer.AppendFormat("%.8X(%.8X, %.8X)", reg.guest_address(),
|
||||
reg->notification_routine, reg->priority);
|
||||
string_buffer->AppendFormat("%.8X(%.8X, %.8X)", reg.guest_address(),
|
||||
reg->notification_routine, reg->priority);
|
||||
}
|
||||
|
||||
void ExRegisterTitleTerminateNotification(
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_ORDINALS_H_
|
||||
#define XENIA_KERNEL_ORDINALS_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_ORDINALS_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_ORDINALS_H_
|
||||
|
||||
#include "xenia/cpu/export_resolver.h"
|
||||
|
||||
@@ -21,4 +21,4 @@ enum {
|
||||
} // namespace ordinals
|
||||
#include "xenia/kernel/util/ordinal_table_post.inc"
|
||||
|
||||
#endif // XENIA_KERNEL_ORDINALS_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_ORDINALS_H_
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_PRIVATE_H_
|
||||
#define XENIA_KERNEL_PRIVATE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_PRIVATE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_PRIVATE_H_
|
||||
|
||||
#include "xenia/kernel/xboxkrnl_ordinals.h"
|
||||
|
||||
@@ -54,8 +54,7 @@ void RegisterUsbcamExports(xe::cpu::ExportResolver* export_resolver,
|
||||
void RegisterVideoExports(xe::cpu::ExportResolver* export_resolver,
|
||||
KernelState* kernel_state);
|
||||
} // namespace xboxkrnl
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_KERNEL_PRIVATE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_PRIVATE_H_
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "xenia/kernel/xboxkrnl_rtl.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "xenia/base/atomic.h"
|
||||
#include "xenia/base/logging.h"
|
||||
@@ -219,7 +220,8 @@ SHIM_CALL RtlMultiByteToUnicodeN_shim(PPCContext* ppc_context,
|
||||
uint32_t copy_len = destination_len >> 1;
|
||||
copy_len = copy_len < source_len ? copy_len : source_len;
|
||||
|
||||
// TODO: maybe use MultiByteToUnicode on Win32? would require swapping
|
||||
// TODO(benvanik): maybe use MultiByteToUnicode on Win32? would require
|
||||
// swapping.
|
||||
|
||||
for (uint32_t i = 0; i < copy_len; i++) {
|
||||
xe::store_and_swap<uint16_t>(
|
||||
@@ -245,10 +247,10 @@ SHIM_CALL RtlUnicodeToMultiByteN_shim(PPCContext* ppc_context,
|
||||
uint32_t copy_len = source_len >> 1;
|
||||
copy_len = copy_len < destination_len ? copy_len : destination_len;
|
||||
|
||||
// TODO: maybe use UnicodeToMultiByte on Win32?
|
||||
// TODO(benvanik): maybe use UnicodeToMultiByte on Win32?
|
||||
|
||||
auto source = (uint16_t*)SHIM_MEM_ADDR(source_ptr);
|
||||
auto destination = (uint8_t*)SHIM_MEM_ADDR(destination_ptr);
|
||||
auto source = reinterpret_cast<uint16_t*>(SHIM_MEM_ADDR(source_ptr));
|
||||
auto destination = reinterpret_cast<uint8_t*>(SHIM_MEM_ADDR(destination_ptr));
|
||||
for (uint32_t i = 0; i < copy_len; i++) {
|
||||
uint16_t c = xe::byte_swap(*source++);
|
||||
*destination++ = c < 256 ? (uint8_t)c : '?';
|
||||
@@ -360,7 +362,7 @@ SHIM_CALL RtlEnterCriticalSection_shim(PPCContext* ppc_context,
|
||||
|
||||
uint32_t thread_id = XThread::GetCurrentThreadId();
|
||||
|
||||
auto cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr);
|
||||
auto cs = reinterpret_cast<X_RTL_CRITICAL_SECTION*>(SHIM_MEM_ADDR(cs_ptr));
|
||||
uint32_t spin_wait_remaining = cs->spin_count_div_256 * 256;
|
||||
|
||||
spin:
|
||||
@@ -401,7 +403,7 @@ SHIM_CALL RtlTryEnterCriticalSection_shim(PPCContext* ppc_context,
|
||||
|
||||
uint32_t thread_id = XThread::GetCurrentThreadId();
|
||||
|
||||
auto cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr);
|
||||
auto cs = reinterpret_cast<X_RTL_CRITICAL_SECTION*>(SHIM_MEM_ADDR(cs_ptr));
|
||||
|
||||
uint32_t result = 0;
|
||||
if (xe::atomic_cas(-1, 0, &cs->lock_count)) {
|
||||
@@ -428,7 +430,7 @@ SHIM_CALL RtlLeaveCriticalSection_shim(PPCContext* ppc_context,
|
||||
// FYI: No need to check if the owning thread is calling this, as that should
|
||||
// be the only case.
|
||||
|
||||
auto cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr);
|
||||
auto cs = reinterpret_cast<X_RTL_CRITICAL_SECTION*>(SHIM_MEM_ADDR(cs_ptr));
|
||||
|
||||
// Drop recursion count - if we are still not zero'ed return.
|
||||
int32_t recursion_count = --cs->recursion_count;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_RTL_H_
|
||||
#define XENIA_KERNEL_RTL_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_RTL_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_RTL_H_
|
||||
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
@@ -26,4 +26,4 @@ X_STATUS xeRtlInitializeCriticalSectionAndSpinCount(X_RTL_CRITICAL_SECTION* cs,
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_KERNEL_RTL_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_RTL_H_
|
||||
|
||||
@@ -441,9 +441,10 @@ DECLARE_XBOXKRNL_EXPORT(KeInitializeEvent,
|
||||
|
||||
dword_result_t KeSetEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
dword_t wait) {
|
||||
// Update dispatch header
|
||||
xe::atomic_exchange(xe::byte_swap<uint32_t>(1),
|
||||
(uint32_t*)&event_ptr->header.signal_state);
|
||||
// Update dispatch header.
|
||||
xe::atomic_exchange(
|
||||
xe::byte_swap<uint32_t>(1),
|
||||
reinterpret_cast<uint32_t*>(&event_ptr->header.signal_state));
|
||||
|
||||
auto ev = XObject::GetNativeObject<XEvent>(kernel_state(), event_ptr);
|
||||
if (!ev) {
|
||||
@@ -469,8 +470,9 @@ dword_result_t KePulseEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
DECLARE_XBOXKRNL_EXPORT(KePulseEvent, ExportTag::kImplemented);
|
||||
|
||||
dword_result_t KeResetEvent(pointer_t<X_KEVENT> event_ptr) {
|
||||
// Update dispatch header
|
||||
xe::atomic_exchange(0, (uint32_t*)&event_ptr->header.signal_state);
|
||||
// Update dispatch header.
|
||||
xe::atomic_exchange(
|
||||
0, reinterpret_cast<uint32_t*>(&event_ptr->header.signal_state));
|
||||
|
||||
auto ev = XObject::GetNativeObject<XEvent>(kernel_state(), event_ptr);
|
||||
if (!ev) {
|
||||
|
||||
@@ -113,7 +113,7 @@ void VdGetCurrentDisplayInformation(pointer_t<X_DISPLAY_INFO> display_info) {
|
||||
DECLARE_XBOXKRNL_EXPORT(VdGetCurrentDisplayInformation, ExportTag::kVideo);
|
||||
|
||||
void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode) {
|
||||
// TODO: get info from actual display
|
||||
// TODO(benvanik): get info from actual display.
|
||||
video_mode.Zero();
|
||||
video_mode->display_width = 1280;
|
||||
video_mode->display_height = 720;
|
||||
@@ -273,8 +273,8 @@ struct BufferScaling {
|
||||
xe::be<uint16_t> bb_width;
|
||||
xe::be<uint16_t> bb_height;
|
||||
};
|
||||
void AppendParam(StringBuffer& string_buffer, pointer_t<BufferScaling> param) {
|
||||
string_buffer.AppendFormat(
|
||||
void AppendParam(StringBuffer* string_buffer, pointer_t<BufferScaling> param) {
|
||||
string_buffer->AppendFormat(
|
||||
"%.8X(scale %dx%d -> %dx%d))", param.guest_address(),
|
||||
uint16_t(param->bb_width), uint16_t(param->bb_height),
|
||||
uint16_t(param->fb_width), uint16_t(param->fb_height));
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "xenia/kernel/xobject.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/clock.h"
|
||||
#include "xenia/kernel/kernel_state.h"
|
||||
#include "xenia/kernel/objects/xevent.h"
|
||||
@@ -311,19 +313,19 @@ object_ref<XObject> XObject::GetNativeObject(KernelState* kernel_state,
|
||||
case 1: // EventSynchronizationObject
|
||||
{
|
||||
auto ev = new XEvent(kernel_state);
|
||||
ev->InitializeNative(native_ptr, *header);
|
||||
ev->InitializeNative(native_ptr, header);
|
||||
object = ev;
|
||||
} break;
|
||||
case 2: // MutantObject
|
||||
{
|
||||
auto mutant = new XMutant(kernel_state);
|
||||
mutant->InitializeNative(native_ptr, *header);
|
||||
mutant->InitializeNative(native_ptr, header);
|
||||
object = mutant;
|
||||
} break;
|
||||
case 5: // SemaphoreObject
|
||||
{
|
||||
auto sem = new XSemaphore(kernel_state);
|
||||
sem->InitializeNative(native_ptr, *header);
|
||||
sem->InitializeNative(native_ptr, header);
|
||||
object = sem;
|
||||
} break;
|
||||
case 3: // ProcessObject
|
||||
|
||||
@@ -10,14 +10,16 @@
|
||||
#ifndef XENIA_KERNEL_XOBJECT_H_
|
||||
#define XENIA_KERNEL_XOBJECT_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/memory.h"
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
namespace xe {
|
||||
class Emulator;
|
||||
class Memory;
|
||||
} // namespace xe
|
||||
|
||||
namespace xe {
|
||||
@@ -206,7 +208,8 @@ template <typename T>
|
||||
class object_ref {
|
||||
public:
|
||||
object_ref() noexcept : value_(nullptr) {}
|
||||
object_ref(nullptr_t) noexcept : value_(nullptr) {}
|
||||
object_ref(nullptr_t) noexcept : value_(nullptr) {
|
||||
} // NOLINT(runtime/explicit)
|
||||
object_ref& operator=(nullptr_t) noexcept {
|
||||
reset();
|
||||
return (*this);
|
||||
@@ -238,12 +241,12 @@ class object_ref {
|
||||
}
|
||||
|
||||
object_ref& operator=(const object_ref& right) noexcept {
|
||||
object_ref(right).swap(*this);
|
||||
object_ref(right).swap(*this); // NOLINT(runtime/explicit): misrecognized?
|
||||
return (*this);
|
||||
}
|
||||
template <typename V>
|
||||
object_ref& operator=(const object_ref<V>& right) noexcept {
|
||||
object_ref(right).swap(*this);
|
||||
object_ref(right).swap(*this); // NOLINT(runtime/explicit): misrecognized?
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -296,12 +299,12 @@ class object_ref {
|
||||
|
||||
template <class _Ty>
|
||||
bool operator==(const object_ref<_Ty>& _Left, nullptr_t) noexcept {
|
||||
return (_Left.get() == (_Ty*)0);
|
||||
return (_Left.get() == reinterpret_cast<_Ty*>(0));
|
||||
}
|
||||
|
||||
template <class _Ty>
|
||||
bool operator==(nullptr_t, const object_ref<_Ty>& _Right) noexcept {
|
||||
return ((_Ty*)0 == _Right.get());
|
||||
return (reinterpret_cast<_Ty*>(0) == _Right.get());
|
||||
}
|
||||
|
||||
template <class _Ty>
|
||||
|
||||
Reference in New Issue
Block a user