Moving byte order/memory access to poly.
This commit is contained in:
@@ -144,7 +144,7 @@ uint64_t Processor::ExecuteInterrupt(
|
||||
|
||||
// Set 0x10C(r13) to the current CPU ID.
|
||||
uint8_t* p = memory_->membase();
|
||||
XESETUINT8BE(p + interrupt_thread_block_ + 0x10C, cpu);
|
||||
poly::store_and_swap<uint8_t>(p + interrupt_thread_block_ + 0x10C, cpu);
|
||||
|
||||
// Execute interrupt.
|
||||
uint64_t result = Execute(interrupt_thread_state_, address, args, arg_count);
|
||||
|
||||
@@ -180,13 +180,13 @@ LONG CALLBACK CheckMMIOHandler(PEXCEPTION_POINTERS ex_info) {
|
||||
*reg_ptr = static_cast<uint8_t>(value);
|
||||
break;
|
||||
case 16:
|
||||
*reg_ptr = XESWAP16(static_cast<uint16_t>(value));
|
||||
*reg_ptr = poly::byte_swap(static_cast<uint16_t>(value));
|
||||
break;
|
||||
case 32:
|
||||
*reg_ptr = XESWAP32(static_cast<uint32_t>(value));
|
||||
*reg_ptr = poly::byte_swap(static_cast<uint32_t>(value));
|
||||
break;
|
||||
case 64:
|
||||
*reg_ptr = XESWAP64(static_cast<uint64_t>(value));
|
||||
*reg_ptr = poly::byte_swap(static_cast<uint64_t>(value));
|
||||
break;
|
||||
}
|
||||
ex_info->ContextRecord->Rip += len;
|
||||
@@ -207,13 +207,13 @@ LONG CALLBACK CheckMMIOHandler(PEXCEPTION_POINTERS ex_info) {
|
||||
value = static_cast<uint8_t>(value);
|
||||
break;
|
||||
case 16:
|
||||
value = XESWAP16(static_cast<uint16_t>(value));
|
||||
value = poly::byte_swap(static_cast<uint16_t>(value));
|
||||
break;
|
||||
case 32:
|
||||
value = XESWAP32(static_cast<uint32_t>(value));
|
||||
value = poly::byte_swap(static_cast<uint32_t>(value));
|
||||
break;
|
||||
case 64:
|
||||
value = XESWAP64(static_cast<uint64_t>(value));
|
||||
value = poly::byte_swap(static_cast<uint64_t>(value));
|
||||
break;
|
||||
}
|
||||
range.write(range.context, address & 0xFFFFFFFF, value);
|
||||
|
||||
@@ -132,20 +132,20 @@ int XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) {
|
||||
if (kernel_export->type == KernelExport::Function) {
|
||||
// Not exactly sure what this should be...
|
||||
if (info->thunk_address) {
|
||||
*slot = XESWAP32BE(info->thunk_address);
|
||||
*slot = poly::byte_swap(info->thunk_address);
|
||||
} else {
|
||||
// TODO(benvanik): find out what import variables are.
|
||||
XELOGW("kernel import variable not defined %.8X %s",
|
||||
info->value_address, kernel_export->name);
|
||||
*slot = XESWAP32BE(0xF00DF00D);
|
||||
*slot = poly::byte_swap(0xF00DF00D);
|
||||
}
|
||||
} else {
|
||||
if (kernel_export->is_implemented) {
|
||||
// Implemented - replace with pointer.
|
||||
XESETUINT32BE(slot, kernel_export->variable_ptr);
|
||||
poly::store_and_swap<uint32_t>(slot, kernel_export->variable_ptr);
|
||||
} else {
|
||||
// Not implemented - write with a dummy value.
|
||||
XESETUINT32BE(slot, 0xD000BEEF | (kernel_export->ordinal & 0xFFF) << 16);
|
||||
poly::store_and_swap<uint32_t>(slot, 0xD000BEEF | (kernel_export->ordinal & 0xFFF) << 16);
|
||||
XELOGCPU("WARNING: imported a variable with no value: %s",
|
||||
kernel_export->name);
|
||||
}
|
||||
@@ -175,10 +175,10 @@ int XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) {
|
||||
// nop
|
||||
// nop
|
||||
uint8_t* p = memory()->Translate(info->thunk_address);
|
||||
XESETUINT32BE(p + 0x0, 0x44000002);
|
||||
XESETUINT32BE(p + 0x4, 0x4E800020);
|
||||
XESETUINT32BE(p + 0x8, 0x60000000);
|
||||
XESETUINT32BE(p + 0xC, 0x60000000);
|
||||
poly::store_and_swap<uint32_t>(p + 0x0, 0x44000002);
|
||||
poly::store_and_swap<uint32_t>(p + 0x4, 0x4E800020);
|
||||
poly::store_and_swap<uint32_t>(p + 0x8, 0x60000000);
|
||||
poly::store_and_swap<uint32_t>(p + 0xC, 0x60000000);
|
||||
|
||||
FunctionInfo::ExternHandler handler = 0;
|
||||
void* handler_data = 0;
|
||||
|
||||
Reference in New Issue
Block a user