Code cleanup: moving poly/ into xenia/base/
This commit is contained in:
@@ -32,14 +32,14 @@ class XFileInfo {
|
||||
X_FILE_ATTRIBUTES attributes;
|
||||
|
||||
void Write(uint8_t* base, uint32_t p) {
|
||||
poly::store_and_swap<uint64_t>(base + p, creation_time);
|
||||
poly::store_and_swap<uint64_t>(base + p + 8, last_access_time);
|
||||
poly::store_and_swap<uint64_t>(base + p + 16, last_write_time);
|
||||
poly::store_and_swap<uint64_t>(base + p + 24, change_time);
|
||||
poly::store_and_swap<uint64_t>(base + p + 32, allocation_size);
|
||||
poly::store_and_swap<uint64_t>(base + p + 40, file_length);
|
||||
poly::store_and_swap<uint32_t>(base + p + 48, attributes);
|
||||
poly::store_and_swap<uint32_t>(base + p + 52, 0); // pad
|
||||
xe::store_and_swap<uint64_t>(base + p, creation_time);
|
||||
xe::store_and_swap<uint64_t>(base + p + 8, last_access_time);
|
||||
xe::store_and_swap<uint64_t>(base + p + 16, last_write_time);
|
||||
xe::store_and_swap<uint64_t>(base + p + 24, change_time);
|
||||
xe::store_and_swap<uint64_t>(base + p + 32, allocation_size);
|
||||
xe::store_and_swap<uint64_t>(base + p + 40, file_length);
|
||||
xe::store_and_swap<uint32_t>(base + p + 48, attributes);
|
||||
xe::store_and_swap<uint32_t>(base + p + 52, 0); // pad
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,16 +64,16 @@ class XDirectoryInfo {
|
||||
XDirectoryInfo* info;
|
||||
do {
|
||||
info = (XDirectoryInfo*)src;
|
||||
poly::store_and_swap<uint32_t>(dst, info->next_entry_offset);
|
||||
poly::store_and_swap<uint32_t>(dst + 4, info->file_index);
|
||||
poly::store_and_swap<uint64_t>(dst + 8, info->creation_time);
|
||||
poly::store_and_swap<uint64_t>(dst + 16, info->last_access_time);
|
||||
poly::store_and_swap<uint64_t>(dst + 24, info->last_write_time);
|
||||
poly::store_and_swap<uint64_t>(dst + 32, info->change_time);
|
||||
poly::store_and_swap<uint64_t>(dst + 40, info->end_of_file);
|
||||
poly::store_and_swap<uint64_t>(dst + 48, info->allocation_size);
|
||||
poly::store_and_swap<uint32_t>(dst + 56, info->attributes);
|
||||
poly::store_and_swap<uint32_t>(dst + 60, info->file_name_length);
|
||||
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);
|
||||
xe::store_and_swap<uint64_t>(dst + 16, info->last_access_time);
|
||||
xe::store_and_swap<uint64_t>(dst + 24, info->last_write_time);
|
||||
xe::store_and_swap<uint64_t>(dst + 32, info->change_time);
|
||||
xe::store_and_swap<uint64_t>(dst + 40, info->end_of_file);
|
||||
xe::store_and_swap<uint64_t>(dst + 48, info->allocation_size);
|
||||
xe::store_and_swap<uint32_t>(dst + 56, info->attributes);
|
||||
xe::store_and_swap<uint32_t>(dst + 60, info->file_name_length);
|
||||
memcpy(dst + 64, info->file_name, info->file_name_length);
|
||||
dst += info->next_entry_offset;
|
||||
src += info->next_entry_offset;
|
||||
@@ -94,10 +94,10 @@ class XVolumeInfo {
|
||||
|
||||
void Write(uint8_t* base, uint32_t p) {
|
||||
uint8_t* dst = base + p;
|
||||
poly::store_and_swap<uint64_t>(dst + 0, this->creation_time);
|
||||
poly::store_and_swap<uint32_t>(dst + 8, this->serial_number);
|
||||
poly::store_and_swap<uint32_t>(dst + 12, this->label_length);
|
||||
poly::store_and_swap<uint32_t>(dst + 16, this->supports_objects);
|
||||
xe::store_and_swap<uint64_t>(dst + 0, this->creation_time);
|
||||
xe::store_and_swap<uint32_t>(dst + 8, this->serial_number);
|
||||
xe::store_and_swap<uint32_t>(dst + 12, this->label_length);
|
||||
xe::store_and_swap<uint32_t>(dst + 16, this->supports_objects);
|
||||
memcpy(dst + 20, this->label, this->label_length);
|
||||
}
|
||||
};
|
||||
@@ -114,10 +114,9 @@ class XFileSystemAttributeInfo {
|
||||
|
||||
void Write(uint8_t* base, uint32_t p) {
|
||||
uint8_t* dst = base + p;
|
||||
poly::store_and_swap<uint32_t>(dst + 0, this->attributes);
|
||||
poly::store_and_swap<uint32_t>(dst + 4,
|
||||
this->maximum_component_name_length);
|
||||
poly::store_and_swap<uint32_t>(dst + 8, this->fs_name_length);
|
||||
xe::store_and_swap<uint32_t>(dst + 0, this->attributes);
|
||||
xe::store_and_swap<uint32_t>(dst + 4, this->maximum_component_name_length);
|
||||
xe::store_and_swap<uint32_t>(dst + 8, this->fs_name_length);
|
||||
memcpy(dst + 12, this->fs_name, this->fs_name_length);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include "xenia/kernel/objects/xkernel_module.h"
|
||||
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/cpu/cpu.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/kernel/objects/xthread.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
|
||||
#include "xenia/kernel/objects/xthread.h"
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "poly/threading.h"
|
||||
#include "xdb/protocol.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/cpu/cpu.h"
|
||||
#include "xenia/kernel/native_list.h"
|
||||
#include "xenia/kernel/objects/xevent.h"
|
||||
#include "xenia/kernel/objects/xuser_module.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -113,7 +113,7 @@ uint32_t XThread::GetCurrentThreadHandle() {
|
||||
}
|
||||
|
||||
uint32_t XThread::GetCurrentThreadId(const uint8_t* thread_state_block) {
|
||||
return poly::load_and_swap<uint32_t>(thread_state_block + 0x14C);
|
||||
return xe::load_and_swap<uint32_t>(thread_state_block + 0x14C);
|
||||
}
|
||||
|
||||
uint32_t XThread::thread_state() { return thread_state_address_; }
|
||||
@@ -122,17 +122,17 @@ uint32_t XThread::thread_id() { return thread_id_; }
|
||||
|
||||
uint32_t XThread::last_error() {
|
||||
uint8_t* p = memory()->TranslateVirtual(thread_state_address_);
|
||||
return poly::load_and_swap<uint32_t>(p + 0x160);
|
||||
return xe::load_and_swap<uint32_t>(p + 0x160);
|
||||
}
|
||||
|
||||
void XThread::set_last_error(uint32_t error_code) {
|
||||
uint8_t* p = memory()->TranslateVirtual(thread_state_address_);
|
||||
poly::store_and_swap<uint32_t>(p + 0x160, error_code);
|
||||
xe::store_and_swap<uint32_t>(p + 0x160, error_code);
|
||||
}
|
||||
|
||||
void XThread::set_name(const std::string& name) {
|
||||
name_ = name;
|
||||
poly::threading::set_name(thread_handle_, name);
|
||||
xe::threading::set_name(thread_handle_, name);
|
||||
}
|
||||
|
||||
X_STATUS XThread::Create() {
|
||||
@@ -180,11 +180,11 @@ X_STATUS XThread::Create() {
|
||||
|
||||
// Setup the thread state block (last error/etc).
|
||||
uint8_t* p = memory()->TranslateVirtual(thread_state_address_);
|
||||
poly::store_and_swap<uint32_t>(p + 0x000, tls_address_);
|
||||
poly::store_and_swap<uint32_t>(p + 0x100, thread_state_address_);
|
||||
poly::store_and_swap<uint32_t>(p + 0x14C, thread_id_);
|
||||
poly::store_and_swap<uint32_t>(p + 0x150, 0); // ?
|
||||
poly::store_and_swap<uint32_t>(p + 0x160, 0); // last error
|
||||
xe::store_and_swap<uint32_t>(p + 0x000, tls_address_);
|
||||
xe::store_and_swap<uint32_t>(p + 0x100, thread_state_address_);
|
||||
xe::store_and_swap<uint32_t>(p + 0x14C, thread_id_);
|
||||
xe::store_and_swap<uint32_t>(p + 0x150, 0); // ?
|
||||
xe::store_and_swap<uint32_t>(p + 0x160, 0); // last error
|
||||
|
||||
// Allocate processor thread state.
|
||||
// This is thread safe.
|
||||
@@ -200,7 +200,7 @@ X_STATUS XThread::Create() {
|
||||
}
|
||||
|
||||
char thread_name[32];
|
||||
snprintf(thread_name, poly::countof(thread_name), "XThread%04X", handle());
|
||||
snprintf(thread_name, xe::countof(thread_name), "XThread%04X", handle());
|
||||
set_name(thread_name);
|
||||
|
||||
uint32_t proc_mask = creation_params_.creation_flags >> 24;
|
||||
@@ -338,12 +338,12 @@ X_STATUS XThread::PlatformExit(int exit_code) {
|
||||
void XThread::Execute() {
|
||||
XELOGKERNEL("XThread::Execute thid %d (handle=%.8X, '%s', native=%.8X)",
|
||||
thread_id_, handle(), name_.c_str(),
|
||||
poly::threading::current_thread_id());
|
||||
xe::threading::current_thread_id());
|
||||
|
||||
// All threads get a mandatory sleep. This is to deal with some buggy
|
||||
// games that are assuming the 360 is so slow to create threads that they
|
||||
// have time to initialize shared structures AFTER CreateThread (RR).
|
||||
poly::threading::Sleep(std::chrono::milliseconds::duration(100));
|
||||
xe::threading::Sleep(std::chrono::milliseconds::duration(100));
|
||||
|
||||
// If a XapiThreadStartup value is present, we use that as a trampoline.
|
||||
// Otherwise, we are a raw thread.
|
||||
@@ -352,13 +352,12 @@ void XThread::Execute() {
|
||||
creation_params_.start_context};
|
||||
kernel_state()->processor()->Execute(thread_state_,
|
||||
creation_params_.xapi_thread_startup,
|
||||
args, poly::countof(args));
|
||||
args, xe::countof(args));
|
||||
} else {
|
||||
// Run user code.
|
||||
uint64_t args[] = {creation_params_.start_context};
|
||||
int exit_code = (int)kernel_state()->processor()->Execute(
|
||||
thread_state_, creation_params_.start_address, args,
|
||||
poly::countof(args));
|
||||
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.
|
||||
@@ -403,25 +402,25 @@ void XThread::DeliverAPCs(void* data) {
|
||||
// Calling the routine may delete the memory/overwrite it.
|
||||
uint32_t apc_address = apc_list->Shift() - 8;
|
||||
uint8_t* apc_ptr = memory->TranslateVirtual(apc_address);
|
||||
uint32_t kernel_routine = poly::load_and_swap<uint32_t>(apc_ptr + 16);
|
||||
uint32_t normal_routine = poly::load_and_swap<uint32_t>(apc_ptr + 24);
|
||||
uint32_t normal_context = poly::load_and_swap<uint32_t>(apc_ptr + 28);
|
||||
uint32_t system_arg1 = poly::load_and_swap<uint32_t>(apc_ptr + 32);
|
||||
uint32_t system_arg2 = poly::load_and_swap<uint32_t>(apc_ptr + 36);
|
||||
uint32_t kernel_routine = xe::load_and_swap<uint32_t>(apc_ptr + 16);
|
||||
uint32_t normal_routine = xe::load_and_swap<uint32_t>(apc_ptr + 24);
|
||||
uint32_t normal_context = xe::load_and_swap<uint32_t>(apc_ptr + 28);
|
||||
uint32_t system_arg1 = xe::load_and_swap<uint32_t>(apc_ptr + 32);
|
||||
uint32_t system_arg2 = xe::load_and_swap<uint32_t>(apc_ptr + 36);
|
||||
|
||||
// Mark as uninserted so that it can be reinserted again by the routine.
|
||||
uint32_t old_flags = poly::load_and_swap<uint32_t>(apc_ptr + 40);
|
||||
poly::store_and_swap<uint32_t>(apc_ptr + 40, old_flags & ~0xFF00);
|
||||
uint32_t old_flags = xe::load_and_swap<uint32_t>(apc_ptr + 40);
|
||||
xe::store_and_swap<uint32_t>(apc_ptr + 40, old_flags & ~0xFF00);
|
||||
|
||||
// Call kernel routine.
|
||||
// The routine can modify all of its arguments before passing it on.
|
||||
// Since we need to give guest accessible pointers over, we copy things
|
||||
// into and out of scratch.
|
||||
uint8_t* scratch_ptr = memory->TranslateVirtual(thread->scratch_address_);
|
||||
poly::store_and_swap<uint32_t>(scratch_ptr + 0, normal_routine);
|
||||
poly::store_and_swap<uint32_t>(scratch_ptr + 4, normal_context);
|
||||
poly::store_and_swap<uint32_t>(scratch_ptr + 8, system_arg1);
|
||||
poly::store_and_swap<uint32_t>(scratch_ptr + 12, system_arg2);
|
||||
xe::store_and_swap<uint32_t>(scratch_ptr + 0, normal_routine);
|
||||
xe::store_and_swap<uint32_t>(scratch_ptr + 4, normal_context);
|
||||
xe::store_and_swap<uint32_t>(scratch_ptr + 8, system_arg1);
|
||||
xe::store_and_swap<uint32_t>(scratch_ptr + 12, system_arg2);
|
||||
// kernel_routine(apc_address, &normal_routine, &normal_context,
|
||||
// &system_arg1, &system_arg2)
|
||||
uint64_t kernel_args[] = {
|
||||
@@ -429,11 +428,11 @@ void XThread::DeliverAPCs(void* data) {
|
||||
thread->scratch_address_ + 8, thread->scratch_address_ + 12,
|
||||
};
|
||||
processor->ExecuteInterrupt(0, kernel_routine, kernel_args,
|
||||
poly::countof(kernel_args));
|
||||
normal_routine = poly::load_and_swap<uint32_t>(scratch_ptr + 0);
|
||||
normal_context = poly::load_and_swap<uint32_t>(scratch_ptr + 4);
|
||||
system_arg1 = poly::load_and_swap<uint32_t>(scratch_ptr + 8);
|
||||
system_arg2 = poly::load_and_swap<uint32_t>(scratch_ptr + 12);
|
||||
xe::countof(kernel_args));
|
||||
normal_routine = xe::load_and_swap<uint32_t>(scratch_ptr + 0);
|
||||
normal_context = xe::load_and_swap<uint32_t>(scratch_ptr + 4);
|
||||
system_arg1 = xe::load_and_swap<uint32_t>(scratch_ptr + 8);
|
||||
system_arg2 = xe::load_and_swap<uint32_t>(scratch_ptr + 12);
|
||||
|
||||
// Call the normal routine. Note that it may have been killed by the kernel
|
||||
// routine.
|
||||
@@ -442,7 +441,7 @@ void XThread::DeliverAPCs(void* data) {
|
||||
// normal_routine(normal_context, system_arg1, system_arg2)
|
||||
uint64_t normal_args[] = {normal_context, system_arg1, system_arg2};
|
||||
processor->ExecuteInterrupt(0, normal_routine, normal_args,
|
||||
poly::countof(normal_args));
|
||||
xe::countof(normal_args));
|
||||
thread->LockApc();
|
||||
}
|
||||
}
|
||||
@@ -456,18 +455,18 @@ void XThread::RundownAPCs() {
|
||||
// Calling the routine may delete the memory/overwrite it.
|
||||
uint32_t apc_address = apc_list_->Shift() - 8;
|
||||
uint8_t* apc_ptr = memory()->TranslateVirtual(apc_address);
|
||||
uint32_t rundown_routine = poly::load_and_swap<uint32_t>(apc_ptr + 20);
|
||||
uint32_t rundown_routine = xe::load_and_swap<uint32_t>(apc_ptr + 20);
|
||||
|
||||
// Mark as uninserted so that it can be reinserted again by the routine.
|
||||
uint32_t old_flags = poly::load_and_swap<uint32_t>(apc_ptr + 40);
|
||||
poly::store_and_swap<uint32_t>(apc_ptr + 40, old_flags & ~0xFF00);
|
||||
uint32_t old_flags = xe::load_and_swap<uint32_t>(apc_ptr + 40);
|
||||
xe::store_and_swap<uint32_t>(apc_ptr + 40, old_flags & ~0xFF00);
|
||||
|
||||
// Call the rundown routine.
|
||||
if (rundown_routine) {
|
||||
// rundown_routine(apc)
|
||||
uint64_t args[] = {apc_address};
|
||||
kernel_state()->processor()->ExecuteInterrupt(0, rundown_routine, args,
|
||||
poly::countof(args));
|
||||
xe::countof(args));
|
||||
}
|
||||
}
|
||||
UnlockApc();
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include "xenia/kernel/objects/xtimer.h"
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "xenia/kernel/objects/xuser_module.h"
|
||||
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/cpu/cpu.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/kernel/objects/xfile.h"
|
||||
#include "xenia/kernel/objects/xthread.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
@@ -118,15 +118,15 @@ X_STATUS XUserModule::LoadFromMemory(const void* addr, const size_t length) {
|
||||
execution_info_ptr_ = memory()->SystemHeapAlloc(24);
|
||||
auto eip = memory()->TranslateVirtual(execution_info_ptr_);
|
||||
const auto& ex = xe_xex2_get_header(xex_)->execution_info;
|
||||
poly::store_and_swap<uint32_t>(eip + 0x00, ex.media_id);
|
||||
poly::store_and_swap<uint32_t>(eip + 0x04, ex.version.value);
|
||||
poly::store_and_swap<uint32_t>(eip + 0x08, ex.base_version.value);
|
||||
poly::store_and_swap<uint32_t>(eip + 0x0C, ex.title_id);
|
||||
poly::store_and_swap<uint8_t>(eip + 0x10, ex.platform);
|
||||
poly::store_and_swap<uint8_t>(eip + 0x11, ex.executable_table);
|
||||
poly::store_and_swap<uint8_t>(eip + 0x12, ex.disc_number);
|
||||
poly::store_and_swap<uint8_t>(eip + 0x13, ex.disc_count);
|
||||
poly::store_and_swap<uint32_t>(eip + 0x14, ex.savegame_id);
|
||||
xe::store_and_swap<uint32_t>(eip + 0x00, ex.media_id);
|
||||
xe::store_and_swap<uint32_t>(eip + 0x04, ex.version.value);
|
||||
xe::store_and_swap<uint32_t>(eip + 0x08, ex.base_version.value);
|
||||
xe::store_and_swap<uint32_t>(eip + 0x0C, ex.title_id);
|
||||
xe::store_and_swap<uint8_t>(eip + 0x10, ex.platform);
|
||||
xe::store_and_swap<uint8_t>(eip + 0x11, ex.executable_table);
|
||||
xe::store_and_swap<uint8_t>(eip + 0x12, ex.disc_number);
|
||||
xe::store_and_swap<uint8_t>(eip + 0x13, ex.disc_count);
|
||||
xe::store_and_swap<uint32_t>(eip + 0x14, ex.savegame_id);
|
||||
|
||||
// Prepare the module for execution.
|
||||
// Runtime takes ownership.
|
||||
|
||||
Reference in New Issue
Block a user