From e3220f7ae6dba73a08daf63eeb533ce17f9ab171 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sat, 2 May 2015 03:42:51 -0700 Subject: [PATCH] Code cleanup: moving poly/ into xenia/base/ --- src/README.md | 1 - src/poly/assert.h | 76 ------- src/poly/byte_order.h | 65 ------ src/xdb/cursor.h | 12 +- src/xdb/postmortem_cursor.cc | 2 +- src/xdb/postmortem_debug_target.cc | 9 +- src/xdb/protocol.h | 10 +- src/xenia/apu/audio_system.cc | 30 +-- src/xenia/apu/xaudio2/xaudio2_audio_driver.cc | 4 +- src/{poly => xenia/base}/README.md | 8 +- src/{poly => xenia/base}/arena.cc | 8 +- src/{poly => xenia/base}/arena.h | 10 +- src/xenia/base/assert.h | 77 +++++++ src/{poly => xenia/base}/atomic.h | 12 +- src/xenia/base/byte_order.h | 83 ++++++++ src/{poly => xenia/base}/cxx_compat.h | 10 +- src/{poly => xenia/base}/debugging.h | 11 +- src/{poly => xenia/base}/debugging_mac.cc | 6 +- src/{poly => xenia/base}/debugging_win.cc | 14 +- src/{poly => xenia/base}/delegate.h | 10 +- src/{poly => xenia/base}/fs.cc | 8 +- src/{poly => xenia/base}/fs.h | 59 +++--- src/{poly => xenia/base}/fs_win.cc | 8 +- src/xenia/{ => base}/logging.cc | 26 +-- src/xenia/{ => base}/logging.h | 22 +- src/{poly => xenia/base}/main.h | 18 +- src/{poly => xenia/base}/main_posix.cc | 15 +- src/{poly => xenia/base}/main_win.cc | 34 +-- src/{poly => xenia/base}/mapped_memory.h | 10 +- .../base}/mapped_memory_posix.cc | 10 +- src/{poly => xenia/base}/mapped_memory_win.cc | 6 +- src/{poly => xenia/base}/math.cc | 6 +- src/{poly => xenia/base}/math.h | 12 +- src/{poly => xenia/base}/memory.h | 42 ++-- .../base/memory_generic.cc} | 6 +- src/{poly => xenia/base}/platform.h | 10 +- src/{poly => xenia/base}/reset_scope.h | 10 +- src/{poly => xenia/base}/sources.gypi | 4 +- src/{poly => xenia/base}/string.cc | 14 +- src/{poly => xenia/base}/string.h | 18 +- src/{poly => xenia/base}/string_buffer.cc | 6 +- src/{poly => xenia/base}/string_buffer.h | 10 +- src/{poly => xenia/base}/threading.cc | 6 +- src/{poly => xenia/base}/threading.h | 11 +- src/{poly => xenia/base}/threading_mac.cc | 10 +- src/{poly => xenia/base}/threading_posix.cc | 8 +- src/{poly => xenia/base}/threading_win.cc | 8 +- src/{poly => xenia/base}/type_pool.h | 10 +- src/{poly => xenia/base}/vec128.h | 14 +- src/xenia/cpu/backend/x64/x64_assembler.cc | 6 +- src/xenia/cpu/backend/x64/x64_assembler.h | 6 +- .../cpu/backend/x64/x64_code_cache_posix.cc | 6 +- .../cpu/backend/x64/x64_code_cache_win.cc | 12 +- src/xenia/cpu/backend/x64/x64_emitter.cc | 22 +- src/xenia/cpu/backend/x64/x64_emitter.h | 9 +- src/xenia/cpu/backend/x64/x64_sequences.cc | 18 +- src/xenia/cpu/backend/x64/x64_tracers.cc | 63 +++--- src/xenia/cpu/compiler/compiler.h | 6 +- src/xenia/cpu/compiler/compiler_pass.cc | 2 +- src/xenia/cpu/compiler/compiler_pass.h | 4 +- .../passes/constant_propagation_pass.cc | 2 +- .../compiler/passes/context_promotion_pass.h | 2 +- .../passes/data_flow_analysis_pass.cc | 4 +- .../passes/register_allocation_pass.cc | 16 +- .../cpu/compiler/passes/validation_pass.cc | 2 +- .../compiler/passes/value_reduction_pass.cc | 2 +- src/xenia/cpu/debugger.h | 4 +- src/xenia/cpu/entry_table.cc | 4 +- src/xenia/cpu/export_resolver.cc | 4 +- src/xenia/cpu/frontend/ppc_context.h | 4 +- src/xenia/cpu/frontend/ppc_disasm.cc | 144 ++++++------- src/xenia/cpu/frontend/ppc_disasm.h | 4 +- src/xenia/cpu/frontend/ppc_emit_altivec.cc | 6 +- src/xenia/cpu/frontend/ppc_emit_alu.cc | 2 +- src/xenia/cpu/frontend/ppc_emit_control.cc | 2 +- src/xenia/cpu/frontend/ppc_emit_fpu.cc | 2 +- src/xenia/cpu/frontend/ppc_emit_memory.cc | 2 +- src/xenia/cpu/frontend/ppc_frontend.h | 6 +- src/xenia/cpu/frontend/ppc_hir_builder.cc | 10 +- src/xenia/cpu/frontend/ppc_hir_builder.h | 4 +- src/xenia/cpu/frontend/ppc_instr.cc | 12 +- src/xenia/cpu/frontend/ppc_instr.h | 4 +- src/xenia/cpu/frontend/ppc_instr_tables.h | 150 ++++++------- src/xenia/cpu/frontend/ppc_scanner.cc | 8 +- src/xenia/cpu/frontend/ppc_translator.cc | 20 +- src/xenia/cpu/frontend/ppc_translator.h | 6 +- .../cpu/frontend/test/xe-cpu-ppc-test.cc | 22 +- src/xenia/cpu/function.cc | 2 +- src/xenia/cpu/hir/block.cc | 2 +- src/xenia/cpu/hir/block.h | 4 +- src/xenia/cpu/hir/hir_builder.cc | 10 +- src/xenia/cpu/hir/hir_builder.h | 15 +- src/xenia/cpu/hir/value.cc | 24 +-- src/xenia/cpu/hir/value.h | 10 +- src/xenia/cpu/mmio_handler.cc | 22 +- src/xenia/cpu/mmio_handler_mac.cc | 8 +- src/xenia/cpu/module.cc | 8 +- src/xenia/cpu/processor.cc | 18 +- src/xenia/cpu/raw_module.cc | 8 +- src/xenia/cpu/runtime.cc | 2 +- src/xenia/cpu/test/test_byte_swap.cc | 4 +- src/xenia/cpu/test/test_extract.cc | 4 +- src/xenia/cpu/test/test_insert.cc | 4 +- .../cpu/test/test_load_vector_shl_shr.cc | 4 +- src/xenia/cpu/test/test_pack.cc | 4 +- src/xenia/cpu/test/test_permute.cc | 4 +- src/xenia/cpu/test/test_shr.cc | 4 +- src/xenia/cpu/test/test_swizzle.cc | 4 +- src/xenia/cpu/test/test_unpack.cc | 4 +- src/xenia/cpu/test/test_vector_add.cc | 4 +- src/xenia/cpu/test/test_vector_max.cc | 4 +- src/xenia/cpu/test/test_vector_min.cc | 4 +- src/xenia/cpu/test/test_vector_rotate_left.cc | 4 +- src/xenia/cpu/test/test_vector_sha.cc | 4 +- src/xenia/cpu/test/test_vector_shl.cc | 4 +- src/xenia/cpu/test/test_vector_shr.cc | 4 +- src/xenia/cpu/test/util.h | 2 +- src/xenia/cpu/test/xe-cpu-hir-test.cc | 10 +- src/xenia/cpu/test/xe-cpu-sandbox.cc | 2 +- src/xenia/cpu/test_module.cc | 12 +- src/xenia/cpu/thread_state.cc | 6 +- src/xenia/cpu/xex_module.cc | 56 ++--- src/xenia/debug_agent.cc | 10 +- src/xenia/debug_agent.h | 2 +- src/xenia/emulator.cc | 12 +- src/xenia/gpu/gl4/blitter.cc | 4 +- src/xenia/gpu/gl4/circular_buffer.cc | 10 +- src/xenia/gpu/gl4/command_processor.cc | 69 +++--- src/xenia/gpu/gl4/draw_batcher.cc | 8 +- src/xenia/gpu/gl4/gl4_graphics_system.cc | 13 +- src/xenia/gpu/gl4/gl4_profiler_display.cc | 8 +- src/xenia/gpu/gl4/gl4_shader.cc | 10 +- src/xenia/gpu/gl4/gl4_shader_translator.cc | 6 +- src/xenia/gpu/gl4/gl4_shader_translator.h | 4 +- src/xenia/gpu/gl4/gl_context.cc | 10 +- src/xenia/gpu/gl4/texture_cache.cc | 20 +- src/xenia/gpu/gl4/wgl_control.cc | 4 +- src/xenia/gpu/gl4/wgl_control.h | 2 +- src/xenia/gpu/graphics_system.cc | 6 +- src/xenia/gpu/register_file.cc | 2 +- src/xenia/gpu/shader.cc | 12 +- src/xenia/gpu/texture_info.cc | 22 +- src/xenia/gpu/texture_info.h | 2 +- src/xenia/gpu/trace_viewer_main.cc | 160 +++++++------- src/xenia/gpu/ucode.h | 2 +- src/xenia/gpu/ucode_disassembler.cc | 2 +- src/xenia/gpu/xenos.h | 6 +- src/xenia/kernel/apps/xgi_app.cc | 30 +-- src/xenia/kernel/apps/xlivebase_app.cc | 6 +- src/xenia/kernel/apps/xmp_app.cc | 198 +++++++++--------- src/xenia/kernel/content_manager.cc | 36 ++-- src/xenia/kernel/content_manager.h | 18 +- .../kernel/fs/devices/disc_image_device.cc | 9 +- .../kernel/fs/devices/disc_image_device.h | 4 +- .../kernel/fs/devices/disc_image_entry.cc | 2 +- .../kernel/fs/devices/disc_image_entry.h | 12 +- .../kernel/fs/devices/host_path_device.cc | 12 +- .../kernel/fs/devices/host_path_entry.cc | 19 +- .../fs/devices/stfs_container_device.cc | 9 +- .../kernel/fs/devices/stfs_container_device.h | 4 +- .../kernel/fs/devices/stfs_container_entry.cc | 5 +- .../kernel/fs/devices/stfs_container_entry.h | 14 +- src/xenia/kernel/fs/entry.cc | 4 +- src/xenia/kernel/fs/filesystem.cc | 16 +- src/xenia/kernel/fs/gdfx.cc | 26 +-- src/xenia/kernel/fs/gdfx.h | 12 +- src/xenia/kernel/fs/stfs.cc | 94 ++++----- src/xenia/kernel/fs/stfs.h | 12 +- src/xenia/kernel/kernel_state.cc | 8 +- src/xenia/kernel/native_list.cc | 26 ++- src/xenia/kernel/objects/xfile.h | 51 +++-- src/xenia/kernel/objects/xkernel_module.cc | 4 +- src/xenia/kernel/objects/xthread.cc | 77 ++++--- src/xenia/kernel/objects/xtimer.cc | 2 +- src/xenia/kernel/objects/xuser_module.cc | 22 +- src/xenia/kernel/user_profile.h | 34 +-- src/xenia/kernel/util/export_table_pre.inc | 2 +- src/xenia/kernel/util/shim_utils.h | 20 +- src/xenia/kernel/util/xex2.cc | 159 +++++++------- src/xenia/kernel/xam_content.cc | 22 +- src/xenia/kernel/xam_info.cc | 2 +- src/xenia/kernel/xam_input.cc | 2 +- src/xenia/kernel/xam_module.cc | 4 +- src/xenia/kernel/xam_msg.cc | 2 +- src/xenia/kernel/xam_net.cc | 24 +-- src/xenia/kernel/xam_notify.cc | 2 +- src/xenia/kernel/xam_ui.cc | 8 +- src/xenia/kernel/xam_user.cc | 2 +- src/xenia/kernel/xam_voice.cc | 2 +- src/xenia/kernel/xboxkrnl_audio.cc | 2 +- src/xenia/kernel/xboxkrnl_audio_xma.cc | 18 +- src/xenia/kernel/xboxkrnl_debug.cc | 2 +- src/xenia/kernel/xboxkrnl_hal.cc | 2 +- src/xenia/kernel/xboxkrnl_io.cc | 14 +- src/xenia/kernel/xboxkrnl_memory.cc | 10 +- src/xenia/kernel/xboxkrnl_misc.cc | 2 +- src/xenia/kernel/xboxkrnl_module.cc | 44 ++-- src/xenia/kernel/xboxkrnl_modules.cc | 4 +- src/xenia/kernel/xboxkrnl_ob.cc | 2 +- src/xenia/kernel/xboxkrnl_rtl.cc | 38 ++-- src/xenia/kernel/xboxkrnl_strings.cc | 20 +- src/xenia/kernel/xboxkrnl_threading.cc | 14 +- src/xenia/kernel/xboxkrnl_usbcam.cc | 2 +- src/xenia/kernel/xboxkrnl_video.cc | 22 +- src/xenia/kernel/xobject.cc | 26 +-- src/xenia/memory.cc | 18 +- src/xenia/memory.h | 4 +- src/xenia/profiling.cc | 2 +- src/xenia/profiling.h | 2 +- src/xenia/sources.gypi | 3 +- .../tools/api-scanner/api_scanner_loader.h | 6 +- .../tools/api-scanner/api_scanner_main.cc | 6 +- src/xenia/ui/control.cc | 2 +- src/xenia/ui/control.h | 30 +-- src/xenia/ui/main_window.cc | 8 +- src/xenia/ui/menu_item.h | 4 +- src/xenia/ui/win32/win32_loop.cc | 6 +- src/xenia/ui/win32/win32_loop.h | 4 +- src/xenia/ui/win32/win32_window.cc | 2 +- src/xenia/ui/window.h | 10 +- src/xenia/xbox.h | 28 ++- src/xenia/xenia_main.cc | 9 +- xenia.gyp | 84 +------- 223 files changed, 1758 insertions(+), 1881 deletions(-) delete mode 100644 src/poly/assert.h delete mode 100644 src/poly/byte_order.h rename src/{poly => xenia/base}/README.md (76%) rename src/{poly => xenia/base}/arena.cc (96%) rename src/{poly => xenia/base}/arena.h (89%) create mode 100644 src/xenia/base/assert.h rename src/{poly => xenia/base}/atomic.h (97%) create mode 100644 src/xenia/base/byte_order.h rename src/{poly => xenia/base}/cxx_compat.h (90%) rename src/{poly => xenia/base}/debugging.h (87%) rename src/{poly => xenia/base}/debugging_mac.cc (93%) rename src/{poly => xenia/base}/debugging_win.cc (76%) rename src/{poly => xenia/base}/delegate.h (90%) rename src/{poly => xenia/base}/fs.cc (97%) rename src/{poly => xenia/base}/fs.h (59%) rename src/{poly => xenia/base}/fs_win.cc (95%) rename src/xenia/{ => base}/logging.cc (83%) rename src/xenia/{ => base}/logging.h (86%) rename src/{poly => xenia/base}/main.h (73%) rename src/{poly => xenia/base}/main_posix.cc (80%) rename src/{poly => xenia/base}/main_win.cc (73%) rename src/{poly => xenia/base}/mapped_memory.h (88%) rename src/{poly => xenia/base}/mapped_memory_posix.cc (91%) rename src/{poly => xenia/base}/mapped_memory_win.cc (97%) rename src/{poly => xenia/base}/math.cc (97%) rename src/{poly => xenia/base}/math.h (97%) rename src/{poly => xenia/base}/memory.h (90%) rename src/{poly/memory.cc => xenia/base/memory_generic.cc} (97%) rename src/{poly => xenia/base}/platform.h (93%) rename src/{poly => xenia/base}/reset_scope.h (87%) rename src/{poly => xenia/base}/sources.gypi (94%) rename src/{poly => xenia/base}/string.cc (95%) rename src/{poly => xenia/base}/string.h (81%) rename src/{poly => xenia/base}/string_buffer.cc (96%) rename src/{poly => xenia/base}/string_buffer.h (88%) rename src/{poly => xenia/base}/threading.cc (88%) rename src/{poly => xenia/base}/threading.h (93%) rename src/{poly => xenia/base}/threading_mac.cc (88%) rename src/{poly => xenia/base}/threading_posix.cc (90%) rename src/{poly => xenia/base}/threading_win.cc (95%) rename src/{poly => xenia/base}/type_pool.h (90%) rename src/{poly => xenia/base}/vec128.h (97%) diff --git a/src/README.md b/src/README.md index fdcfa4e30..a9087a2e9 100644 --- a/src/README.md +++ b/src/README.md @@ -1,5 +1,4 @@ All code (headers and sources) lives under this path, excluding third_party code. -* poly: a lightweight cross-platform/compiler compatibility library. * xdb: xenia debugger library and UI. * xenia: emulator code. diff --git a/src/poly/assert.h b/src/poly/assert.h deleted file mode 100644 index 5fbc77a9d..000000000 --- a/src/poly/assert.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2014 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef POLY_ASSERT_H_ -#define POLY_ASSERT_H_ - -#include - -#include "poly/platform.h" - -namespace poly { - -#define static_assert_size(type, size) \ - static_assert(sizeof(type) == size, \ - "bad definition for " #type ": must be " #size " bytes") - -// We rely on assert being compiled out in NDEBUG. -#define poly_assert assert - -#define __POLY_EXPAND(x) x -#define __POLY_ARGC(...) \ - __POLY_EXPAND(__POLY_ARGC_IMPL(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, \ - 6, 5, 4, 3, 2, 1, 0)) -#define __POLY_ARGC_IMPL(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \ - x13, x14, x15, N, ...) \ - N -#define __POLY_MACRO_DISPATCH(func, ...) \ - __POLY_MACRO_DISPATCH_(func, __POLY_ARGC(__VA_ARGS__)) -#define __POLY_MACRO_DISPATCH_(func, nargs) __POLY_MACRO_DISPATCH__(func, nargs) -#define __POLY_MACRO_DISPATCH__(func, nargs) func##nargs - -#define assert_always(...) poly_assert(false) - -#define assert_true(...) \ - __POLY_MACRO_DISPATCH(assert_true, __VA_ARGS__)(__VA_ARGS__) -#define assert_true1(expr) poly_assert(expr) -#define assert_true2(expr, message) poly_assert((expr) || !message) - -#define assert_false(...) \ - __POLY_MACRO_DISPATCH(assert_false, __VA_ARGS__)(__VA_ARGS__) -#define assert_false1(expr) poly_assert(!(expr)) -#define assert_false2(expr, message) poly_assert(!(expr) || !message) - -#define assert_zero(...) \ - __POLY_MACRO_DISPATCH(assert_zero, __VA_ARGS__)(__VA_ARGS__) -#define assert_zero1(expr) poly_assert((expr) == 0) -#define assert_zero2(expr, message) poly_assert((expr) == 0 || !message) - -#define assert_not_zero(...) \ - __POLY_MACRO_DISPATCH(assert_not_zero, __VA_ARGS__)(__VA_ARGS__) -#define assert_not_zero1(expr) poly_assert((expr) != 0) -#define assert_not_zero2(expr, message) poly_assert((expr) != 0 || !message) - -#define assert_null(...) \ - __POLY_MACRO_DISPATCH(assert_null, __VA_ARGS__)(__VA_ARGS__) -#define assert_null1(expr) poly_assert((expr) == nullptr) -#define assert_null2(expr, message) poly_assert((expr) == nullptr || !message) - -#define assert_not_null(...) \ - __POLY_MACRO_DISPATCH(assert_not_null, __VA_ARGS__)(__VA_ARGS__) -#define assert_not_null1(expr) poly_assert((expr) != nullptr) -#define assert_not_null2(expr, message) \ - poly_assert((expr) != nullptr || !message) - -#define assert_unhandled_case(variable) \ - assert_always("unhandled switch(" #variable ") case") - -} // namespace poly - -#endif // POLY_ASSERT_H_ diff --git a/src/poly/byte_order.h b/src/poly/byte_order.h deleted file mode 100644 index cd7972e6e..000000000 --- a/src/poly/byte_order.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2014 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef POLY_BYTE_ORDER_H_ -#define POLY_BYTE_ORDER_H_ - -#include - -#include "poly/platform.h" - -#if XE_PLATFORM_MAC -#include -#endif // XE_PLATFORM_MAC - -namespace poly { - -#if XE_COMPILER_MSVC -#define POLY_BYTE_SWAP_16 _byteswap_ushort -#define POLY_BYTE_SWAP_32 _byteswap_ulong -#define POLY_BYTE_SWAP_64 _byteswap_uint64 -#elif XE_PLATFORM_MAC -#define POLY_BYTE_SWAP_16 OSSwapInt16 -#define POLY_BYTE_SWAP_32 OSSwapInt32 -#define POLY_BYTE_SWAP_64 OSSwapInt64 -#else -#define POLY_BYTE_SWAP_16 __bswap_16 -#define POLY_BYTE_SWAP_32 __bswap_32 -#define POLY_BYTE_SWAP_64 __bswap_64 -#endif // XE_COMPILER_MSVC - -inline int8_t byte_swap(int8_t value) { return value; } -inline uint8_t byte_swap(uint8_t value) { return value; } -inline int16_t byte_swap(int16_t value) { - return static_cast(POLY_BYTE_SWAP_16(static_cast(value))); -} -inline uint16_t byte_swap(uint16_t value) { return POLY_BYTE_SWAP_16(value); } -inline uint16_t byte_swap(wchar_t value) { - return static_cast(POLY_BYTE_SWAP_16(value)); -} -inline int32_t byte_swap(int32_t value) { - return static_cast(POLY_BYTE_SWAP_32(static_cast(value))); -} -inline uint32_t byte_swap(uint32_t value) { return POLY_BYTE_SWAP_32(value); } -inline int64_t byte_swap(int64_t value) { - return static_cast(POLY_BYTE_SWAP_64(static_cast(value))); -} -inline uint64_t byte_swap(uint64_t value) { return POLY_BYTE_SWAP_64(value); } -inline float byte_swap(float value) { - uint32_t temp = byte_swap(*reinterpret_cast(&value)); - return *reinterpret_cast(&temp); -} -inline double byte_swap(double value) { - uint64_t temp = byte_swap(*reinterpret_cast(&value)); - return *reinterpret_cast(&temp); -} - -} // namespace poly - -#endif // POLY_BYTE_ORDER_H_ diff --git a/src/xdb/cursor.h b/src/xdb/cursor.h index 13a99afec..7d11abd46 100644 --- a/src/xdb/cursor.h +++ b/src/xdb/cursor.h @@ -12,7 +12,7 @@ #include -#include +#include "xenia/base/delegate.h" #include #include #include @@ -27,15 +27,15 @@ class Cursor { // TODO(benvanik): breakpoints/events - poly::Delegate end_of_stream; + xe::Delegate end_of_stream; std::vector modules(); std::vector threads(); - poly::Delegate module_loaded; - poly::Delegate module_unloaded; - poly::Delegate thread_created; - poly::Delegate thread_exited; + xe::Delegate module_loaded; + xe::Delegate module_unloaded; + xe::Delegate thread_created; + xe::Delegate thread_exited; // TODO(benvanik): memory access diff --git a/src/xdb/postmortem_cursor.cc b/src/xdb/postmortem_cursor.cc index c1e6e3e00..6b1a530c8 100644 --- a/src/xdb/postmortem_cursor.cc +++ b/src/xdb/postmortem_cursor.cc @@ -93,7 +93,7 @@ class PostmortemCursor::Executor { return; } while (!exit_signal) { - auto event_type = poly::load(trace_ptr_); + auto event_type = xe::load(trace_ptr_); switch (event_type) { case EventType::END_OF_STREAM: { eof_= true; diff --git a/src/xdb/postmortem_debug_target.cc b/src/xdb/postmortem_debug_target.cc index ffad63348..dc174b6ef 100644 --- a/src/xdb/postmortem_debug_target.cc +++ b/src/xdb/postmortem_debug_target.cc @@ -9,7 +9,6 @@ #include -#include #include #include @@ -60,8 +59,7 @@ bool PostmortemDebugTarget::LoadTrace(const std::wstring& path, // path lookup. const uint8_t* ptr = trace_base_ + 8; EventType event_type; - while ((event_type = poly::load(ptr)) != - EventType::END_OF_STREAM) { + while ((event_type = xe::load(ptr)) != EventType::END_OF_STREAM) { switch (event_type) { case EventType::PROCESS_START: { process_start_event_ = protocol::ProcessStartEvent::Get(ptr); @@ -80,7 +78,7 @@ bool PostmortemDebugTarget::LoadTrace(const std::wstring& path, } else { // If no path was provided just use what's in the trace. auto trace_content_path = - poly::to_wstring(std::string(process_start_event_->launch_path)); + xe::to_wstring(std::string(process_start_event_->launch_path)); initialized_filesystem = InitializeFileSystem(trace_content_path); } if (!initialized_filesystem) { @@ -101,8 +99,7 @@ bool PostmortemDebugTarget::Prepare(std::atomic& cancelled) { const uint8_t* ptr = trace_base_ + 8; EventType event_type; - while ((event_type = poly::load(ptr)) != - EventType::END_OF_STREAM) { + while ((event_type = xe::load(ptr)) != EventType::END_OF_STREAM) { switch (event_type) { case EventType::PROCESS_START: { assert_true(process_start_event_ == diff --git a/src/xdb/protocol.h b/src/xdb/protocol.h index 585a2b853..3246059d3 100644 --- a/src/xdb/protocol.h +++ b/src/xdb/protocol.h @@ -12,13 +12,13 @@ #include -#include "poly/atomic.h" -#include "poly/vec128.h" +#include "xenia/base/atomic.h" +#include "xenia/base/vec128.h" namespace xdb { namespace protocol { -using vec128_t = poly::vec128_t; +using vec128_t = xe::vec128_t; #pragma pack(push, 4) @@ -57,7 +57,7 @@ struct Event { if (!trace_base) { return nullptr; } - uint64_t ptr = poly::atomic_exchange_add( + uint64_t ptr = xe::atomic_exchange_add( sizeof(T), reinterpret_cast(trace_base)); return reinterpret_cast(ptr); } @@ -96,7 +96,7 @@ struct Registers { uint32_t vscr; uint64_t gpr[32]; double fpr[32]; - poly::vec128_t vr[128]; + xe::vec128_t vr[128]; }; struct ThreadCreateEvent : public Event { diff --git a/src/xenia/apu/audio_system.cc b/src/xenia/apu/audio_system.cc index 1138eb323..9d88f008e 100644 --- a/src/xenia/apu/audio_system.cc +++ b/src/xenia/apu/audio_system.cc @@ -9,12 +9,12 @@ #include "xenia/apu/audio_system.h" -#include "poly/math.h" #include "xenia/apu/audio_driver.h" -#include "xenia/emulator.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/cpu/processor.h" #include "xenia/cpu/thread_state.h" -#include "xenia/logging.h" +#include "xenia/emulator.h" #include "xenia/profiling.h" // As with normal Microsoft, there are like twelve different ways to access @@ -59,13 +59,13 @@ AudioSystem::AudioSystem(Emulator* emulator) for (size_t i = 0; i < maximum_client_count_; ++i) { unused_clients_.push(i); } - for (size_t i = 0; i < poly::countof(client_wait_handles_); ++i) { + for (size_t i = 0; i < xe::countof(client_wait_handles_); ++i) { client_wait_handles_[i] = CreateEvent(NULL, TRUE, FALSE, NULL); } } AudioSystem::~AudioSystem() { - for (size_t i = 0; i < poly::countof(client_wait_handles_); ++i) { + for (size_t i = 0; i < xe::countof(client_wait_handles_); ++i) { CloseHandle(client_wait_handles_[i]); } } @@ -107,7 +107,7 @@ X_STATUS AudioSystem::Setup() { } void AudioSystem::ThreadStart() { - poly::threading::set_name("Audio Worker"); + xe::threading::set_name("Audio Worker"); xe::Profiler::ThreadEnter("Audio Worker"); // Initialize driver and ringbuffer. @@ -118,7 +118,7 @@ void AudioSystem::ThreadStart() { // Main run loop. while (running_) { auto result = - WaitForMultipleObjectsEx(DWORD(poly::countof(client_wait_handles_)), + WaitForMultipleObjectsEx(DWORD(xe::countof(client_wait_handles_)), client_wait_handles_, FALSE, INFINITE, FALSE); if (result == WAIT_FAILED || result == WAIT_OBJECT_0 + maximum_client_count_) { @@ -137,7 +137,7 @@ void AudioSystem::ThreadStart() { if (client_callback) { uint64_t args[] = {client_callback_arg}; processor->Execute(thread_state_, client_callback, args, - poly::countof(args)); + xe::countof(args)); } pumped++; index++; @@ -219,7 +219,7 @@ X_STATUS AudioSystem::RegisterClient(uint32_t callback, uint32_t callback_arg, unused_clients_.pop(); uint32_t ptr = memory()->SystemHeapAlloc(0x4); - poly::store_and_swap(memory()->TranslateVirtual(ptr), callback_arg); + xe::store_and_swap(memory()->TranslateVirtual(ptr), callback_arg); clients_[index] = {driver, callback, callback_arg, ptr}; @@ -276,13 +276,13 @@ uint64_t AudioSystem::ReadRegister(uint64_t addr) { value = registers_.current_context; } - value = poly::byte_swap(value); + value = xe::byte_swap(value); return value; } void AudioSystem::WriteRegister(uint64_t addr, uint64_t value) { uint32_t r = addr & 0xFFFF; - value = poly::byte_swap(uint32_t(value)); + value = xe::byte_swap(uint32_t(value)); XELOGAPU("WriteRegister(%.4X, %.8X)", r, value); // 1804h is written to with 0x02000000 and 0x03000000 around a lock operation @@ -303,15 +303,15 @@ void AudioSystem::WriteRegister(uint64_t addr, uint64_t value) { uint32_t guest_ptr = registers_.xma_context_array_ptr + context_id * kXmaContextSize; auto context_ptr = memory()->TranslateVirtual(guest_ptr); - uint32_t dword0 = poly::load_and_swap(context_ptr + 0); + uint32_t dword0 = xe::load_and_swap(context_ptr + 0); bool has_valid_input = (dword0 & 0x00300000) != 0; if (has_valid_input) { dword0 = dword0 & ~0x00300000; - poly::store_and_swap(context_ptr + 0, dword0); + xe::store_and_swap(context_ptr + 0, dword0); // Set output buffer to invalid. - uint32_t dword1 = poly::load_and_swap(context_ptr + 4); + uint32_t dword1 = xe::load_and_swap(context_ptr + 4); dword1 = dword1 & ~0x80000000; - poly::store_and_swap(context_ptr + 4, dword1); + xe::store_and_swap(context_ptr + 4, dword1); } } value >>= 1; diff --git a/src/xenia/apu/xaudio2/xaudio2_audio_driver.cc b/src/xenia/apu/xaudio2/xaudio2_audio_driver.cc index 0d988788b..c897c295b 100644 --- a/src/xenia/apu/xaudio2/xaudio2_audio_driver.cc +++ b/src/xenia/apu/xaudio2/xaudio2_audio_driver.cc @@ -10,8 +10,8 @@ #include "xenia/apu/xaudio2/xaudio2_audio_driver.h" #include "xenia/apu/apu-private.h" +#include "xenia/base/logging.h" #include "xenia/emulator.h" -#include "xenia/logging.h" namespace xe { namespace apu { @@ -131,7 +131,7 @@ void XAudio2AudioDriver::SubmitFrame(uint32_t frame_ptr) { for (int index = 0, o = 0; index < channel_samples_; ++index) { for (int channel = 0, table = 0; channel < interleave_channels; ++channel, table += channel_samples_) { - output_frame[o++] = poly::byte_swap(input_frame[table + index]); + output_frame[o++] = xe::byte_swap(input_frame[table + index]); } } diff --git a/src/poly/README.md b/src/xenia/base/README.md similarity index 76% rename from src/poly/README.md rename to src/xenia/base/README.md index a221bae4a..b3d202fd3 100644 --- a/src/poly/README.md +++ b/src/xenia/base/README.md @@ -1,4 +1,4 @@ -poly is a lightweight cross-platform/compiler compatibility library. +A lightweight cross-platform/compiler compatibility library. This library presupposes C++11/14 support. As more compilers get C++14 it will assume that. @@ -7,9 +7,9 @@ Other parts of the project use this to avoid creating spaghetti linkage. Code specific to the emulator should be kept out, as not all of the projects that depend on this need it. -Where possible, C++11/14 STL should be used instead of adding any code in here, and -the code should be kept as small as possible (by reusing STL/etc). Third party -dependencies should be kept to a minimum. +Where possible, C++11/14 STL should be used instead of adding any code in here, +and the code should be kept as small as possible (by reusing STL/etc). Third +party dependencies should be kept to a minimum. Target compilers: * MSVC++ 2013+ diff --git a/src/poly/arena.cc b/src/xenia/base/arena.cc similarity index 96% rename from src/poly/arena.cc rename to src/xenia/base/arena.cc index ea655882a..7b19bb1a7 100644 --- a/src/poly/arena.cc +++ b/src/xenia/base/arena.cc @@ -7,13 +7,13 @@ ****************************************************************************** */ -#include "poly/arena.h" +#include "xenia/base/arena.h" #include -#include "poly/assert.h" +#include "xenia/base/assert.h" -namespace poly { +namespace xe { Arena::Arena(size_t chunk_size) : chunk_size_(chunk_size), head_chunk_(nullptr), active_chunk_(nullptr) {} @@ -100,4 +100,4 @@ Arena::Chunk::~Chunk() { } } -} // namespace poly +} // namespace xe diff --git a/src/poly/arena.h b/src/xenia/base/arena.h similarity index 89% rename from src/poly/arena.h rename to src/xenia/base/arena.h index 1cc71df63..77f0bcdeb 100644 --- a/src/poly/arena.h +++ b/src/xenia/base/arena.h @@ -7,13 +7,13 @@ ****************************************************************************** */ -#ifndef POLY_ARENA_H_ -#define POLY_ARENA_H_ +#ifndef XENIA_BASE_ARENA_H_ +#define XENIA_BASE_ARENA_H_ #include #include -namespace poly { +namespace xe { class Arena { public: @@ -50,6 +50,6 @@ class Arena { Chunk* active_chunk_; }; -} // namespace poly +} // namespace xe -#endif // POLY_ARENA_H_ +#endif // XENIA_BASE_ARENA_H_ diff --git a/src/xenia/base/assert.h b/src/xenia/base/assert.h new file mode 100644 index 000000000..83dcf1f73 --- /dev/null +++ b/src/xenia/base/assert.h @@ -0,0 +1,77 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2014 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_BASE_ASSERT_H_ +#define XENIA_BASE_ASSERT_H_ + +#include + +#include "xenia/base/platform.h" + +namespace xe { + +#define static_assert_size(type, size) \ + static_assert(sizeof(type) == size, \ + "bad definition for " #type ": must be " #size " bytes") + +// We rely on assert being compiled out in NDEBUG. +#define xenia_assert assert + +#define __XENIA_EXPAND(x) x +#define __XENIA_ARGC(...) \ + __XENIA_EXPAND(__XENIA_ARGC_IMPL(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, \ + 7, 6, 5, 4, 3, 2, 1, 0)) +#define __XENIA_ARGC_IMPL(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \ + x13, x14, x15, N, ...) \ + N +#define __XENIA_MACRO_DISPATCH(func, ...) \ + __XENIA_MACRO_DISPATCH_(func, __XENIA_ARGC(__VA_ARGS__)) +#define __XENIA_MACRO_DISPATCH_(func, nargs) \ + __XENIA_MACRO_DISPATCH__(func, nargs) +#define __XENIA_MACRO_DISPATCH__(func, nargs) func##nargs + +#define assert_always(...) xenia_assert(false) + +#define assert_true(...) \ + __XENIA_MACRO_DISPATCH(assert_true, __VA_ARGS__)(__VA_ARGS__) +#define assert_true1(expr) xenia_assert(expr) +#define assert_true2(expr, message) xenia_assert((expr) || !message) + +#define assert_false(...) \ + __XENIA_MACRO_DISPATCH(assert_false, __VA_ARGS__)(__VA_ARGS__) +#define assert_false1(expr) xenia_assert(!(expr)) +#define assert_false2(expr, message) xenia_assert(!(expr) || !message) + +#define assert_zero(...) \ + __XENIA_MACRO_DISPATCH(assert_zero, __VA_ARGS__)(__VA_ARGS__) +#define assert_zero1(expr) xenia_assert((expr) == 0) +#define assert_zero2(expr, message) xenia_assert((expr) == 0 || !message) + +#define assert_not_zero(...) \ + __XENIA_MACRO_DISPATCH(assert_not_zero, __VA_ARGS__)(__VA_ARGS__) +#define assert_not_zero1(expr) xenia_assert((expr) != 0) +#define assert_not_zero2(expr, message) xenia_assert((expr) != 0 || !message) + +#define assert_null(...) \ + __XENIA_MACRO_DISPATCH(assert_null, __VA_ARGS__)(__VA_ARGS__) +#define assert_null1(expr) xenia_assert((expr) == nullptr) +#define assert_null2(expr, message) xenia_assert((expr) == nullptr || !message) + +#define assert_not_null(...) \ + __XENIA_MACRO_DISPATCH(assert_not_null, __VA_ARGS__)(__VA_ARGS__) +#define assert_not_null1(expr) xenia_assert((expr) != nullptr) +#define assert_not_null2(expr, message) \ + xenia_assert((expr) != nullptr || !message) + +#define assert_unhandled_case(variable) \ + assert_always("unhandled switch(" #variable ") case") + +} // namespace xe + +#endif // XENIA_BASE_ASSERT_H_ diff --git a/src/poly/atomic.h b/src/xenia/base/atomic.h similarity index 97% rename from src/poly/atomic.h rename to src/xenia/base/atomic.h index 9462a445a..c9878d3c2 100644 --- a/src/poly/atomic.h +++ b/src/xenia/base/atomic.h @@ -7,18 +7,18 @@ ****************************************************************************** */ -#ifndef POLY_ATOMIC_H_ -#define POLY_ATOMIC_H_ +#ifndef XENIA_BASE_ATOMIC_H_ +#define XENIA_BASE_ATOMIC_H_ #include -#include "poly/platform.h" +#include "xenia/base/platform.h" #if XE_PLATFORM_MAC #include #endif // XE_PLATFORM_MAC -namespace poly { +namespace xe { // These functions are modeled off of the Apple OSAtomic routines // http://developer.apple.com/library/mac/#documentation/DriversKernelHardware/Reference/libkern_ref/OSAtomic_h/ @@ -179,6 +179,6 @@ inline bool atomic_cas(uint64_t old_value, uint64_t new_value, reinterpret_cast(value)); } -} // namespace poly +} // namespace xe -#endif // POLY_ATOMIC_H_ +#endif // XENIA_BASE_ATOMIC_H_ diff --git a/src/xenia/base/byte_order.h b/src/xenia/base/byte_order.h new file mode 100644 index 000000000..9aea97d6e --- /dev/null +++ b/src/xenia/base/byte_order.h @@ -0,0 +1,83 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2014 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_BASE_BYTE_ORDER_H_ +#define XENIA_BASE_BYTE_ORDER_H_ + +#include + +#include "xenia/base/platform.h" + +#if XE_PLATFORM_MAC +#include +#endif // XE_PLATFORM_MAC + +namespace xe { + +#if XE_COMPILER_MSVC +#define XENIA_BASE_BYTE_SWAP_16 _byteswap_ushort +#define XENIA_BASE_BYTE_SWAP_32 _byteswap_ulong +#define XENIA_BASE_BYTE_SWAP_64 _byteswap_uint64 +#elif XE_PLATFORM_MAC +#define XENIA_BASE_BYTE_SWAP_16 OSSwapInt16 +#define XENIA_BASE_BYTE_SWAP_32 OSSwapInt32 +#define XENIA_BASE_BYTE_SWAP_64 OSSwapInt64 +#else +#define XENIA_BASE_BYTE_SWAP_16 __bswap_16 +#define XENIA_BASE_BYTE_SWAP_32 __bswap_32 +#define XENIA_BASE_BYTE_SWAP_64 __bswap_64 +#endif // XE_COMPILER_MSVC + +inline int8_t byte_swap(int8_t value) { return value; } +inline uint8_t byte_swap(uint8_t value) { return value; } +inline int16_t byte_swap(int16_t value) { + return static_cast( + XENIA_BASE_BYTE_SWAP_16(static_cast(value))); +} +inline uint16_t byte_swap(uint16_t value) { + return XENIA_BASE_BYTE_SWAP_16(value); +} +inline uint16_t byte_swap(wchar_t value) { + return static_cast(XENIA_BASE_BYTE_SWAP_16(value)); +} +inline int32_t byte_swap(int32_t value) { + return static_cast( + XENIA_BASE_BYTE_SWAP_32(static_cast(value))); +} +inline uint32_t byte_swap(uint32_t value) { + return XENIA_BASE_BYTE_SWAP_32(value); +} +inline int64_t byte_swap(int64_t value) { + return static_cast( + XENIA_BASE_BYTE_SWAP_64(static_cast(value))); +} +inline uint64_t byte_swap(uint64_t value) { + return XENIA_BASE_BYTE_SWAP_64(value); +} +inline float byte_swap(float value) { + uint32_t temp = byte_swap(*reinterpret_cast(&value)); + return *reinterpret_cast(&temp); +} +inline double byte_swap(double value) { + uint64_t temp = byte_swap(*reinterpret_cast(&value)); + return *reinterpret_cast(&temp); +} + +template +struct be { + be() = default; + be(const T &src) : value(xe::byte_swap(src)) {} + be(const be &other) { value = other.value; } + operator T() const { return xe::byte_swap(value); } + T value; +}; + +} // namespace xe + +#endif // XENIA_BASE_BYTE_ORDER_H_ diff --git a/src/poly/cxx_compat.h b/src/xenia/base/cxx_compat.h similarity index 90% rename from src/poly/cxx_compat.h rename to src/xenia/base/cxx_compat.h index e34b6679b..dce16f528 100644 --- a/src/poly/cxx_compat.h +++ b/src/xenia/base/cxx_compat.h @@ -7,12 +7,12 @@ ****************************************************************************** */ -#ifndef POLY_CXX_COMPAT_H_ -#define POLY_CXX_COMPAT_H_ +#ifndef XENIA_BASE_CXX_COMPAT_H_ +#define XENIA_BASE_CXX_COMPAT_H_ #include -#include "poly/platform.h" +#include "xenia/base/platform.h" // C++11 thread local storage. // http://en.cppreference.com/w/cpp/language/storage_duration @@ -46,6 +46,6 @@ unique_ptr make_unique(Args&&... args) { #endif // clang < 3.4 #endif // !XE_COMPILER_MSVC -namespace poly {} // namespace poly +namespace xe {} // namespace xe -#endif // POLY_CXX_COMPAT_H_ +#endif // XENIA_BASE_CXX_COMPAT_H_ diff --git a/src/poly/debugging.h b/src/xenia/base/debugging.h similarity index 87% rename from src/poly/debugging.h rename to src/xenia/base/debugging.h index 0c3c260dd..60980db71 100644 --- a/src/poly/debugging.h +++ b/src/xenia/base/debugging.h @@ -7,13 +7,12 @@ ****************************************************************************** */ -#ifndef POLY_DEBUGGING_H_ -#define POLY_DEBUGGING_H_ +#ifndef XENIA_BASE_DEBUGGING_H_ +#define XENIA_BASE_DEBUGGING_H_ #include - -namespace poly { +namespace xe { namespace debugging { // Returns true if a debugger is attached to this process. @@ -27,6 +26,6 @@ bool IsDebuggerAttached(); void Break(); } // namespace debugging -} // namespace poly +} // namespace xe -#endif // POLY_DEBUGGING_H_ +#endif // XENIA_BASE_DEBUGGING_H_ diff --git a/src/poly/debugging_mac.cc b/src/xenia/base/debugging_mac.cc similarity index 93% rename from src/poly/debugging_mac.cc rename to src/xenia/base/debugging_mac.cc index a99639743..f7fabd305 100644 --- a/src/poly/debugging_mac.cc +++ b/src/xenia/base/debugging_mac.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ -#include +#include "xenia/base/debugging.h" #include #include -namespace poly { +namespace xe { namespace debugging { bool IsDebuggerAttached() { @@ -32,4 +32,4 @@ void Break() { } } // namespace debugging -} // namespace poly +} // namespace xe diff --git a/src/poly/debugging_win.cc b/src/xenia/base/debugging_win.cc similarity index 76% rename from src/poly/debugging_win.cc rename to src/xenia/base/debugging_win.cc index e7218fe91..86998f026 100644 --- a/src/poly/debugging_win.cc +++ b/src/xenia/base/debugging_win.cc @@ -7,20 +7,16 @@ ****************************************************************************** */ -#include "poly/debugging.h" +#include "xenia/base/debugging.h" #include -namespace poly { +namespace xe { namespace debugging { -bool IsDebuggerAttached() { - return IsDebuggerPresent() ? true : false; -} +bool IsDebuggerAttached() { return IsDebuggerPresent() ? true : false; } -void Break() { - __debugbreak(); -} +void Break() { __debugbreak(); } } // namespace debugging -} // namespace poly +} // namespace xe diff --git a/src/poly/delegate.h b/src/xenia/base/delegate.h similarity index 90% rename from src/poly/delegate.h rename to src/xenia/base/delegate.h index 3c351a3d9..aa0590cd8 100644 --- a/src/poly/delegate.h +++ b/src/xenia/base/delegate.h @@ -7,14 +7,14 @@ ****************************************************************************** */ -#ifndef POLY_DELEGATE_H_ -#define POLY_DELEGATE_H_ +#ifndef XENIA_BASE_DELEGATE_H_ +#define XENIA_BASE_DELEGATE_H_ #include #include #include -namespace poly { +namespace xe { // TODO(benvanik): go lockfree, and don't hold the lock while emitting. @@ -45,6 +45,6 @@ class Delegate { std::vector listeners_; }; -} // namespace poly +} // namespace xe -#endif // POLY_DELEGATE_H_ +#endif // XENIA_BASE_DELEGATE_H_ diff --git a/src/poly/fs.cc b/src/xenia/base/fs.cc similarity index 97% rename from src/poly/fs.cc rename to src/xenia/base/fs.cc index 23b917c60..e789eb8d0 100644 --- a/src/poly/fs.cc +++ b/src/xenia/base/fs.cc @@ -7,18 +7,18 @@ ****************************************************************************** */ -#include "poly/fs.h" +#include "xenia/base/fs.h" #include #include #include -namespace poly { +namespace xe { namespace fs { std::string CanonicalizePath(const std::string& original_path) { char path_sep('\\'); - std::string path(poly::fix_path_separators(original_path, path_sep)); + std::string path(xe::fix_path_separators(original_path, path_sep)); std::vector path_breaks; @@ -179,4 +179,4 @@ bool WildcardEngine::Match(const std::string& str) const { } } // namespace fs -} // namespace poly +} // namespace xe diff --git a/src/poly/fs.h b/src/xenia/base/fs.h similarity index 59% rename from src/poly/fs.h rename to src/xenia/base/fs.h index 0d1edea9e..281c21ec9 100644 --- a/src/poly/fs.h +++ b/src/xenia/base/fs.h @@ -7,17 +7,17 @@ ****************************************************************************** */ -#ifndef POLY_FS_H_ -#define POLY_FS_H_ +#ifndef XENIA_BASE_FS_H_ +#define XENIA_BASE_FS_H_ #include -#include "poly/string.h" +#include "xenia/base/string.h" #include #include -namespace poly { +namespace xe { namespace fs { bool PathExists(const std::wstring& path); @@ -39,44 +39,41 @@ std::vector ListFiles(const std::wstring& path); std::string CanonicalizePath(const std::string& original_path); -class WildcardFlags -{ -public: - bool - FromStart: 1, - ToEnd : 1; +class WildcardFlags { + public: + bool FromStart : 1, ToEnd : 1; - WildcardFlags(); - WildcardFlags(bool start, bool end); + WildcardFlags(); + WildcardFlags(bool start, bool end); - static WildcardFlags FIRST; - static WildcardFlags LAST; + static WildcardFlags FIRST; + static WildcardFlags LAST; }; -class WildcardRule -{ -public: - WildcardRule(const std::string& str_match, const WildcardFlags &flags); - bool Check(const std::string& str_lower, std::string::size_type& offset) const; - -private: +class WildcardRule { + public: + WildcardRule(const std::string& str_match, const WildcardFlags& flags); + bool Check(const std::string& str_lower, + std::string::size_type& offset) const; + + private: std::string match; - WildcardFlags rules; + WildcardFlags rules; }; -class WildcardEngine -{ -public: - void SetRule(const std::string &pattern); +class WildcardEngine { + public: + void SetRule(const std::string& pattern); // Always ignoring case - bool Match(const std::string &str) const; -private: + bool Match(const std::string& str) const; + + private: std::vector rules; - void PreparePattern(const std::string &pattern); + void PreparePattern(const std::string& pattern); }; } // namespace fs -} // namespace poly +} // namespace xe -#endif // POLY_FS_H_ +#endif // XENIA_BASE_FS_H_ diff --git a/src/poly/fs_win.cc b/src/xenia/base/fs_win.cc similarity index 95% rename from src/poly/fs_win.cc rename to src/xenia/base/fs_win.cc index 8090d27f4..893775dea 100644 --- a/src/poly/fs_win.cc +++ b/src/xenia/base/fs_win.cc @@ -7,15 +7,15 @@ ****************************************************************************** */ -#include "poly/fs.h" +#include "xenia/base/fs.h" #include #include -#include "poly/platform.h" +#include "xenia/base/platform.h" -namespace poly { +namespace xe { namespace fs { bool PathExists(const std::wstring& path) { @@ -74,4 +74,4 @@ std::vector ListFiles(const std::wstring& path) { } } // namespace fs -} // namespace poly +} // namespace xe diff --git a/src/xenia/logging.cc b/src/xenia/base/logging.cc similarity index 83% rename from src/xenia/logging.cc rename to src/xenia/base/logging.cc index 5c382cbfe..225d35966 100644 --- a/src/xenia/logging.cc +++ b/src/xenia/base/logging.cc @@ -7,16 +7,16 @@ ****************************************************************************** */ -#include "xenia/logging.h" +#include "xenia/base/logging.h" #include #include -#include "poly/cxx_compat.h" -#include "poly/main.h" -#include "poly/math.h" -#include "poly/threading.h" +#include "xenia/base/cxx_compat.h" +#include "xenia/base/main.h" +#include "xenia/base/math.h" +#include "xenia/base/threading.h" DEFINE_bool(fast_stdout, false, "Don't lock around stdout/stderr. May introduce weirdness."); @@ -34,7 +34,7 @@ void format_log_line(char* buffer, size_t buffer_count, const char* file_path, char* buffer_ptr; if (FLAGS_log_filenames) { // Strip out just the filename from the path. - const char* filename = strrchr(file_path, poly::path_separator); + const char* filename = strrchr(file_path, xe::path_separator); if (filename) { // Slash - skip over it. filename++; @@ -46,15 +46,15 @@ void format_log_line(char* buffer, size_t buffer_count, const char* file_path, // Format string - add a trailing newline if required. const char* outfmt = "%c> %.2X %s:%d: "; buffer_ptr = buffer + snprintf(buffer, buffer_count - 1, outfmt, level_char, - poly::threading::current_thread_id(), - filename, line_number); + xe::threading::current_thread_id(), filename, + line_number); } else { buffer_ptr = buffer; *(buffer_ptr++) = level_char; *(buffer_ptr++) = '>'; *(buffer_ptr++) = ' '; buffer_ptr += - sprintf(buffer_ptr, "%.4X", poly::threading::current_thread_id()); + sprintf(buffer_ptr, "%.4X", xe::threading::current_thread_id()); *(buffer_ptr++) = ' '; } @@ -78,7 +78,7 @@ void log_line(const char* file_path, const uint32_t line_number, va_list args; va_start(args, fmt); - format_log_line(log_buffer, poly::countof(log_buffer), file_path, line_number, + format_log_line(log_buffer, xe::countof(log_buffer), file_path, line_number, level_char, fmt, args); va_end(args); @@ -103,8 +103,8 @@ void handle_fatal(const char* file_path, const uint32_t line_number, char buffer[2048]; va_list args; va_start(args, fmt); - format_log_line(buffer, poly::countof(buffer), file_path, line_number, 'X', - fmt, args); + format_log_line(buffer, xe::countof(buffer), file_path, line_number, 'X', fmt, + args); va_end(args); if (!FLAGS_fast_stdout) { @@ -121,7 +121,7 @@ void handle_fatal(const char* file_path, const uint32_t line_number, } #if XE_PLATFORM_WIN32 - if (!poly::has_console_attached()) { + if (!xe::has_console_attached()) { MessageBoxA(NULL, buffer, "Xenia Error", MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); } diff --git a/src/xenia/logging.h b/src/xenia/base/logging.h similarity index 86% rename from src/xenia/logging.h rename to src/xenia/base/logging.h index d5b564678..4bcf518bf 100644 --- a/src/xenia/logging.h +++ b/src/xenia/base/logging.h @@ -12,20 +12,20 @@ #include -#include "poly/string.h" +#include "xenia/base/string.h" namespace xe { -#define XE_OPTION_ENABLE_LOGGING 1 -#define XE_OPTION_LOG_ERROR 1 -#define XE_OPTION_LOG_WARNING 1 -#define XE_OPTION_LOG_INFO 1 -#define XE_OPTION_LOG_DEBUG 1 -#define XE_OPTION_LOG_CPU 1 -#define XE_OPTION_LOG_APU 1 -#define XE_OPTION_LOG_GPU 1 -#define XE_OPTION_LOG_KERNEL 1 -#define XE_OPTION_LOG_FS 1 +#define XE_OPTION_ENABLE_LOGGING 1 +#define XE_OPTION_LOG_ERROR 1 +#define XE_OPTION_LOG_WARNING 1 +#define XE_OPTION_LOG_INFO 1 +#define XE_OPTION_LOG_DEBUG 1 +#define XE_OPTION_LOG_CPU 1 +#define XE_OPTION_LOG_APU 1 +#define XE_OPTION_LOG_GPU 1 +#define XE_OPTION_LOG_KERNEL 1 +#define XE_OPTION_LOG_FS 1 #define XE_EMPTY_MACRO \ do { \ diff --git a/src/poly/main.h b/src/xenia/base/main.h similarity index 73% rename from src/poly/main.h rename to src/xenia/base/main.h index 339f04e3f..3371847cc 100644 --- a/src/poly/main.h +++ b/src/xenia/base/main.h @@ -7,15 +7,15 @@ ****************************************************************************** */ -#ifndef POLY_MAIN_H_ -#define POLY_MAIN_H_ +#ifndef XENIA_BASE_MAIN_H_ +#define XENIA_BASE_MAIN_H_ #include #include -#include "poly/platform.h" +#include "xenia/base/platform.h" -namespace poly { +namespace xe { // Returns true if there is a user-visible console attached to receive stdout. bool has_console_attached(); @@ -29,11 +29,11 @@ struct EntryInfo { }; EntryInfo GetEntryInfo(); -#define DEFINE_ENTRY_POINT(name, usage, entry_point) \ - poly::EntryInfo poly::GetEntryInfo() { \ - return poly::EntryInfo({name, usage, entry_point}); \ +#define DEFINE_ENTRY_POINT(name, usage, entry_point) \ + xe::EntryInfo xe::GetEntryInfo() { \ + return xe::EntryInfo({name, usage, entry_point}); \ } -} // namespace poly +} // namespace xe -#endif // POLY_MAIN_H_ +#endif // XENIA_BASE_MAIN_H_ diff --git a/src/poly/main_posix.cc b/src/xenia/base/main_posix.cc similarity index 80% rename from src/poly/main_posix.cc rename to src/xenia/base/main_posix.cc index 353a0d2be..cc178672a 100644 --- a/src/poly/main_posix.cc +++ b/src/xenia/base/main_posix.cc @@ -7,28 +7,29 @@ ****************************************************************************** */ -#include +#include "xenia/base/main.h" #include -#include -namespace poly { +#include "xenia/base/string.h" + +namespace xe { bool has_console_attached() { return true; } -} // namespace poly +} // namespace xe extern "C" int main(int argc, char** argv) { - auto entry_info = poly::GetEntryInfo(); + auto entry_info = xe::GetEntryInfo(); google::SetUsageMessage(std::string("usage: ") + - poly::to_string(entry_info.usage)); + xe::to_string(entry_info.usage)); google::SetVersionString("1.0"); google::ParseCommandLineFlags(&argc, &argv, true); std::vector args; for (int n = 0; n < argc; n++) { - args.push_back(poly::to_wstring(argv[n])); + args.push_back(xe::to_wstring(argv[n])); } // Call app-provided entry point. diff --git a/src/poly/main_win.cc b/src/xenia/base/main_win.cc similarity index 73% rename from src/poly/main_win.cc rename to src/xenia/base/main_win.cc index 0b95a0350..2e56405a8 100644 --- a/src/poly/main_win.cc +++ b/src/xenia/base/main_win.cc @@ -7,16 +7,16 @@ ****************************************************************************** */ -#include "poly/main.h" +#include "xenia/base/main.h" #include #include #include #include -#include "poly/string.h" +#include "xenia/base/string.h" -namespace poly { +namespace xe { bool has_console_attached_ = true; @@ -46,14 +46,14 @@ void AttachConsole() { setvbuf(stderr, nullptr, _IONBF, 0); } -} // namespace poly +} // namespace xe // Used in console mode apps; automatically picked based on subsystem. int wmain(int argc, wchar_t* argv[]) { - auto entry_info = poly::GetEntryInfo(); + auto entry_info = xe::GetEntryInfo(); google::SetUsageMessage(std::string("usage: ") + - poly::to_string(entry_info.usage)); + xe::to_string(entry_info.usage)); google::SetVersionString("1.0"); // Convert all args to narrow, as gflags doesn't support wchar. @@ -71,7 +71,7 @@ int wmain(int argc, wchar_t* argv[]) { // Widen all remaining flags and convert to usable strings. std::vector args; for (int n = 0; n < argc; n++) { - args.push_back(poly::to_wstring(argva[n])); + args.push_back(xe::to_wstring(argva[n])); } // Setup COM on the main thread. @@ -89,9 +89,9 @@ int wmain(int argc, wchar_t* argv[]) { int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR command_line, int) { // Attach a console so we can write output to stdout. If the user hasn't // redirected output themselves it'll pop up a window. - poly::AttachConsole(); + xe::AttachConsole(); - auto entry_info = poly::GetEntryInfo(); + auto entry_info = xe::GetEntryInfo(); // Convert to an argv-like format so we can share code/use gflags. std::wstring buffer = entry_info.name + L" " + command_line; @@ -109,11 +109,19 @@ int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR command_line, int) { } #if defined _M_IX86 -#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#pragma comment( \ + linker, \ + "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_IA64 -#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#pragma comment( \ + linker, \ + "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_X64 -#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#pragma comment( \ + linker, \ + "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") #else -#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#pragma comment( \ + linker, \ + "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #endif diff --git a/src/poly/mapped_memory.h b/src/xenia/base/mapped_memory.h similarity index 88% rename from src/poly/mapped_memory.h rename to src/xenia/base/mapped_memory.h index 9db211e4f..771824a8f 100644 --- a/src/poly/mapped_memory.h +++ b/src/xenia/base/mapped_memory.h @@ -7,13 +7,13 @@ ****************************************************************************** */ -#ifndef POLY_MAPPED_MEMORY_H_ -#define POLY_MAPPED_MEMORY_H_ +#ifndef XENIA_BASE_MAPPED_MEMORY_H_ +#define XENIA_BASE_MAPPED_MEMORY_H_ #include #include -namespace poly { +namespace xe { class MappedMemory { public: @@ -41,6 +41,6 @@ class MappedMemory { size_t size_; }; -} // namespace poly +} // namespace xe -#endif // POLY_MAPPED_MEMORY_H_ +#endif // XENIA_BASE_MAPPED_MEMORY_H_ diff --git a/src/poly/mapped_memory_posix.cc b/src/xenia/base/mapped_memory_posix.cc similarity index 91% rename from src/poly/mapped_memory_posix.cc rename to src/xenia/base/mapped_memory_posix.cc index c5358d582..40ee08eab 100644 --- a/src/poly/mapped_memory_posix.cc +++ b/src/xenia/base/mapped_memory_posix.cc @@ -7,14 +7,14 @@ ****************************************************************************** */ -#include +#include "xenia/base/mapped_memory.h" #include #include -#include +#include "xenia/base/string.h" -namespace poly { +namespace xe { class PosixMappedMemory : public MappedMemory { public: @@ -51,7 +51,7 @@ std::unique_ptr MappedMemory::Open(const std::wstring& path, auto mm = std::make_unique(path, mode); - mm->file_handle = fopen(poly::to_string(path).c_str(), mode_str); + mm->file_handle = fopen(xe::to_string(path).c_str(), mode_str); if (!mm->file_handle) { return nullptr; } @@ -74,4 +74,4 @@ std::unique_ptr MappedMemory::Open(const std::wstring& path, return std::move(mm); } -} // namespace poly +} // namespace xe diff --git a/src/poly/mapped_memory_win.cc b/src/xenia/base/mapped_memory_win.cc similarity index 97% rename from src/poly/mapped_memory_win.cc rename to src/xenia/base/mapped_memory_win.cc index 83320fd12..70d3b9d49 100644 --- a/src/poly/mapped_memory_win.cc +++ b/src/xenia/base/mapped_memory_win.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ -#include "poly/mapped_memory.h" +#include "xenia/base/mapped_memory.h" #include -namespace poly { +namespace xe { class Win32MappedMemory : public MappedMemory { public: @@ -102,4 +102,4 @@ std::unique_ptr MappedMemory::Open(const std::wstring& path, return std::move(mm); } -} // namespace poly +} // namespace xe diff --git a/src/poly/math.cc b/src/xenia/base/math.cc similarity index 97% rename from src/poly/math.cc rename to src/xenia/base/math.cc index 6ed8c7329..1dff7c143 100644 --- a/src/poly/math.cc +++ b/src/xenia/base/math.cc @@ -7,9 +7,9 @@ ****************************************************************************** */ -#include "poly/math.h" +#include "xenia/base/math.h" -namespace poly { +namespace xe { // TODO(benvanik): replace with alternate implementation. // XMConvertFloatToHalf @@ -66,4 +66,4 @@ float half_to_float(uint16_t value) { return *(float *)&Result; } -} // namespace poly +} // namespace xe diff --git a/src/poly/math.h b/src/xenia/base/math.h similarity index 97% rename from src/poly/math.h rename to src/xenia/base/math.h index 6216985a5..4288a7be4 100644 --- a/src/poly/math.h +++ b/src/xenia/base/math.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef POLY_MATH_H_ -#define POLY_MATH_H_ +#ifndef XENIA_BASE_MATH_H_ +#define XENIA_BASE_MATH_H_ #include @@ -17,9 +17,9 @@ #include #include -#include "poly/platform.h" +#include "xenia/base/platform.h" -namespace poly { +namespace xe { template size_t countof(T (&arr)[N]) { @@ -220,6 +220,6 @@ int64_t m128_i64(const __m128& v) { uint16_t float_to_half(float value); float half_to_float(uint16_t value); -} // namespace poly +} // namespace xe -#endif // POLY_MATH_H_ +#endif // XENIA_BASE_MATH_H_ diff --git a/src/poly/memory.h b/src/xenia/base/memory.h similarity index 90% rename from src/poly/memory.h rename to src/xenia/base/memory.h index be3e643ea..0e6ec9d9d 100644 --- a/src/poly/memory.h +++ b/src/xenia/base/memory.h @@ -7,16 +7,16 @@ ****************************************************************************** */ -#ifndef POLY_MEMORY_H_ -#define POLY_MEMORY_H_ +#ifndef XENIA_BASE_MEMORY_H_ +#define XENIA_BASE_MEMORY_H_ #include #include -#include "poly/assert.h" -#include "poly/byte_order.h" +#include "xenia/base/assert.h" +#include "xenia/base/byte_order.h" -namespace poly { +namespace xe { inline size_t hash_combine(size_t seed) { return seed; } @@ -73,7 +73,7 @@ void copy_and_swap(T* dest, const T* src, size_t count) { copy_and_swap_64_unaligned(pd, ps, count); } } else { - assert_always("Invalid poly::copy_and_swap size"); + assert_always("Invalid xe::copy_and_swap size"); } } @@ -130,7 +130,7 @@ inline T load(const void* mem) { } else if (sizeof(T) == 8) { return static_cast(load(mem)); } else { - assert_always("Invalid poly::load size"); + assert_always("Invalid xe::load size"); } } @@ -181,7 +181,7 @@ inline std::string load_and_swap(const void* mem) { std::string value; for (int i = 0;; ++i) { auto c = - poly::load_and_swap(reinterpret_cast(mem) + i); + xe::load_and_swap(reinterpret_cast(mem) + i); if (!c) { break; } @@ -193,8 +193,8 @@ template <> inline std::wstring load_and_swap(const void* mem) { std::wstring value; for (int i = 0;; ++i) { - auto c = poly::load_and_swap( - reinterpret_cast(mem) + i); + auto c = + xe::load_and_swap(reinterpret_cast(mem) + i); if (!c) { break; } @@ -256,7 +256,7 @@ inline void store(const void* mem, T value) { } else if (sizeof(T) == 8) { store(mem, static_cast(value)); } else { - assert_always("Invalid poly::store size"); + assert_always("Invalid xe::store size"); } } @@ -305,27 +305,17 @@ inline void store_and_swap(void* mem, double value) { template <> inline void store_and_swap(void* mem, std::string value) { for (auto i = 0; i < value.size(); ++i) { - poly::store_and_swap(reinterpret_cast(mem) + i, - value[i]); + xe::store_and_swap(reinterpret_cast(mem) + i, value[i]); } } template <> inline void store_and_swap(void* mem, std::wstring value) { for (auto i = 0; i < value.size(); ++i) { - poly::store_and_swap(reinterpret_cast(mem) + i, - value[i]); + xe::store_and_swap(reinterpret_cast(mem) + i, + value[i]); } } -template -struct be { - be() = default; - be(const T& src) : value(poly::byte_swap(src)) {} - be(const be& other) { value = other.value; } - operator T() const { return poly::byte_swap(value); } - T value; -}; +} // namespace xe -} // namespace poly - -#endif // POLY_MEMORY_H_ +#endif // XENIA_BASE_MEMORY_H_ diff --git a/src/poly/memory.cc b/src/xenia/base/memory_generic.cc similarity index 97% rename from src/poly/memory.cc rename to src/xenia/base/memory_generic.cc index 08e3f8901..3682fcc5d 100644 --- a/src/poly/memory.cc +++ b/src/xenia/base/memory_generic.cc @@ -7,7 +7,7 @@ ****************************************************************************** */ -#include "poly/memory.h" +#include "xenia/base/memory.h" #include @@ -15,7 +15,7 @@ #include #endif // !XE_PLATFORM_WIN32 -namespace poly { +namespace xe { size_t page_size() { static size_t value = 0; @@ -72,4 +72,4 @@ void copy_and_swap_64_unaligned(uint64_t* dest, const uint64_t* src, } } -} // namespace poly +} // namespace xe diff --git a/src/poly/platform.h b/src/xenia/base/platform.h similarity index 93% rename from src/poly/platform.h rename to src/xenia/base/platform.h index f039962a2..184cd8388 100644 --- a/src/poly/platform.h +++ b/src/xenia/base/platform.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef POLY_PLATFORM_H_ -#define POLY_PLATFORM_H_ +#ifndef XENIA_BASE_PLATFORM_H_ +#define XENIA_BASE_PLATFORM_H_ // NOTE: ordering matters here as sometimes multiple flags are defined on // certain platforms. @@ -61,7 +61,7 @@ #include #endif // XE_COMPILER_MSVC -namespace poly { +namespace xe { #if XE_PLATFORM_WIN32 const char path_separator = '\\'; @@ -71,6 +71,6 @@ const char path_separator = '/'; const size_t max_path = 1024; // PATH_MAX #endif // XE_PLATFORM_WIN32 -} // namespace poly +} // namespace xe -#endif // POLY_PLATFORM_H_ +#endif // XENIA_BASE_PLATFORM_H_ diff --git a/src/poly/reset_scope.h b/src/xenia/base/reset_scope.h similarity index 87% rename from src/poly/reset_scope.h rename to src/xenia/base/reset_scope.h index caff320b8..ec0ad90c8 100644 --- a/src/poly/reset_scope.h +++ b/src/xenia/base/reset_scope.h @@ -7,12 +7,12 @@ ****************************************************************************** */ -#ifndef POLY_RESET_SCOPE_H_ -#define POLY_RESET_SCOPE_H_ +#ifndef XENIA_BASE_RESET_SCOPE_H_ +#define XENIA_BASE_RESET_SCOPE_H_ #include -namespace poly { +namespace xe { template class ResetScope { @@ -38,6 +38,6 @@ inline ResetScope make_reset_scope(const std::unique_ptr& value) { return ResetScope(value.get()); } -} // namespace poly +} // namespace xe -#endif // POLY_RESET_SCOPE_H_ +#endif // XENIA_BASE_RESET_SCOPE_H_ diff --git a/src/poly/sources.gypi b/src/xenia/base/sources.gypi similarity index 94% rename from src/poly/sources.gypi rename to src/xenia/base/sources.gypi index ee55cf04f..4f53ac17f 100644 --- a/src/poly/sources.gypi +++ b/src/xenia/base/sources.gypi @@ -11,11 +11,13 @@ 'cxx_compat.h', 'fs.h', 'fs.cc', + 'logging.cc', + 'logging.h', 'main.h', 'mapped_memory.h', 'math.cc', 'math.h', - 'memory.cc', + 'memory_generic.cc', 'memory.h', 'platform.h', 'reset_scope.h', diff --git a/src/poly/string.cc b/src/xenia/base/string.cc similarity index 95% rename from src/poly/string.cc rename to src/xenia/base/string.cc index 615e41973..068c1b6ac 100644 --- a/src/poly/string.cc +++ b/src/xenia/base/string.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ -#include "poly/string.h" +#include "xenia/base/string.h" #include #include -namespace poly { +namespace xe { std::string to_string(const std::wstring& source) { static std::wstring_convert> converter; @@ -42,13 +42,13 @@ std::string::size_type find_first_of_case(const std::string& target, std::wstring to_absolute_path(const std::wstring& path) { #if XE_PLATFORM_WIN32 - wchar_t buffer[poly::max_path]; + wchar_t buffer[xe::max_path]; _wfullpath(buffer, path.c_str(), sizeof(buffer) / sizeof(wchar_t)); return buffer; #else - char buffer[poly::max_path]; - realpath(poly::to_string(path).c_str(), buffer); - return poly::to_wstring(buffer); + char buffer[xe::max_path]; + realpath(xe::to_string(path).c_str(), buffer); + return xe::to_wstring(buffer); #endif // XE_PLATFORM_WIN32 } @@ -166,4 +166,4 @@ std::wstring find_name_from_path(const std::wstring& path) { return name; } -} // namespace poly +} // namespace xe diff --git a/src/poly/string.h b/src/xenia/base/string.h similarity index 81% rename from src/poly/string.h rename to src/xenia/base/string.h index fa36155b2..9ed7a1603 100644 --- a/src/poly/string.h +++ b/src/xenia/base/string.h @@ -7,16 +7,16 @@ ****************************************************************************** */ -#ifndef POLY_STRING_H_ -#define POLY_STRING_H_ +#ifndef XENIA_BASE_STRING_H_ +#define XENIA_BASE_STRING_H_ #include #include #include -#include "poly/platform.h" +#include "xenia/base/platform.h" -namespace poly { +namespace xe { std::string to_string(const std::wstring& source); std::wstring to_wstring(const std::string& source); @@ -33,19 +33,19 @@ std::vector split_path(const std::string& path); // Joins two path segments with the given separator. std::wstring join_paths(const std::wstring& left, const std::wstring& right, - wchar_t sep = poly::path_separator); + wchar_t sep = xe::path_separator); // Replaces all path separators with the given value and removes redundant // separators. std::wstring fix_path_separators(const std::wstring& source, - wchar_t new_sep = poly::path_separator); + wchar_t new_sep = xe::path_separator); std::string fix_path_separators(const std::string& source, - char new_sep = poly::path_separator); + char new_sep = xe::path_separator); // Find the top directory name or filename from a path std::string find_name_from_path(const std::string& path); std::wstring find_name_from_path(const std::wstring& path); -} // namespace poly +} // namespace xe -#endif // POLY_STRING_H_ +#endif // XENIA_BASE_STRING_H_ diff --git a/src/poly/string_buffer.cc b/src/xenia/base/string_buffer.cc similarity index 96% rename from src/poly/string_buffer.cc rename to src/xenia/base/string_buffer.cc index 44613ea71..7b1b6e4f9 100644 --- a/src/poly/string_buffer.cc +++ b/src/xenia/base/string_buffer.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ -#include "poly/string_buffer.h" +#include "xenia/base/string_buffer.h" #include #include -namespace poly { +namespace xe { StringBuffer::StringBuffer(size_t initial_capacity) { buffer_.reserve(std::max(initial_capacity, static_cast(1024))); @@ -68,4 +68,4 @@ std::string StringBuffer::to_string() { char* StringBuffer::ToString() { return strdup(buffer_.data()); } -} // namespace poly +} // namespace xe diff --git a/src/poly/string_buffer.h b/src/xenia/base/string_buffer.h similarity index 88% rename from src/poly/string_buffer.h rename to src/xenia/base/string_buffer.h index bdc1f7a3e..3a9938b7f 100644 --- a/src/poly/string_buffer.h +++ b/src/xenia/base/string_buffer.h @@ -7,14 +7,14 @@ ****************************************************************************** */ -#ifndef POLY_STRING_BUFFER_H_ -#define POLY_STRING_BUFFER_H_ +#ifndef XENIA_BASE_STRING_BUFFER_H_ +#define XENIA_BASE_STRING_BUFFER_H_ #include #include #include -namespace poly { +namespace xe { class StringBuffer { public: @@ -41,6 +41,6 @@ class StringBuffer { std::vector buffer_; }; -} // namespace poly +} // namespace xe -#endif // POLY_STRING_BUFFER_H_ +#endif // XENIA_BASE_STRING_BUFFER_H_ diff --git a/src/poly/threading.cc b/src/xenia/base/threading.cc similarity index 88% rename from src/poly/threading.cc rename to src/xenia/base/threading.cc index 5550647d2..bf9bdb755 100644 --- a/src/poly/threading.cc +++ b/src/xenia/base/threading.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ -#include "poly/threading.h" +#include "xenia/base/threading.h" -namespace poly { +namespace xe { namespace threading { // } // namespace threading -} // namespace poly +} // namespace xe diff --git a/src/poly/threading.h b/src/xenia/base/threading.h similarity index 93% rename from src/poly/threading.h rename to src/xenia/base/threading.h index d78010c88..8edfa72a6 100644 --- a/src/poly/threading.h +++ b/src/xenia/base/threading.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef POLY_THREADING_H_ -#define POLY_THREADING_H_ +#ifndef XENIA_BASE_THREADING_H_ +#define XENIA_BASE_THREADING_H_ #include #include @@ -18,8 +18,7 @@ #include #include - -namespace poly { +namespace xe { namespace threading { class Fence { @@ -69,6 +68,6 @@ void Sleep(std::chrono::duration duration) { } } // namespace threading -} // namespace poly +} // namespace xe -#endif // POLY_THREADING_H_ +#endif // XENIA_BASE_THREADING_H_ diff --git a/src/poly/threading_mac.cc b/src/xenia/base/threading_mac.cc similarity index 88% rename from src/poly/threading_mac.cc rename to src/xenia/base/threading_mac.cc index ae25099de..2ea681817 100644 --- a/src/poly/threading_mac.cc +++ b/src/xenia/base/threading_mac.cc @@ -7,14 +7,14 @@ ****************************************************************************** */ -#include +#include "xenia/base/threading.h" #include #include #include #include -namespace poly { +namespace xe { namespace threading { uint64_t ticks() { return mach_absolute_time(); } @@ -24,9 +24,7 @@ uint32_t current_thread_id() { return static_cast(tid); } -void set_name(const std::string& name) { - pthread_setname_np(name.c_str()); -} +void set_name(const std::string& name) { pthread_setname_np(name.c_str()); } void set_name(std::thread::native_handle_type handle, const std::string& name) { // ? @@ -41,4 +39,4 @@ void Sleep(std::chrono::microseconds duration) { } } // namespace threading -} // namespace poly +} // namespace xe diff --git a/src/poly/threading_posix.cc b/src/xenia/base/threading_posix.cc similarity index 90% rename from src/poly/threading_posix.cc rename to src/xenia/base/threading_posix.cc index 815414f52..21cb3f252 100644 --- a/src/poly/threading_posix.cc +++ b/src/xenia/base/threading_posix.cc @@ -7,15 +7,15 @@ ****************************************************************************** */ -#include +#include "xenia/base/threading.h" #include #include -namespace poly { +namespace xe { namespace threading { -//uint64_t ticks() { return mach_absolute_time(); } +// uint64_t ticks() { return mach_absolute_time(); } // uint32_t current_thread_id() { // mach_port_t tid = pthread_mach_thread_np(pthread_self()); @@ -39,4 +39,4 @@ void Sleep(std::chrono::microseconds duration) { } } // namespace threading -} // namespace poly +} // namespace xe diff --git a/src/poly/threading_win.cc b/src/xenia/base/threading_win.cc similarity index 95% rename from src/poly/threading_win.cc rename to src/xenia/base/threading_win.cc index c27a757bf..342fbb7de 100644 --- a/src/poly/threading_win.cc +++ b/src/xenia/base/threading_win.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ -#include "poly/threading.h" +#include "xenia/base/threading.h" -#include "poly/platform.h" +#include "xenia/base/platform.h" -namespace poly { +namespace xe { namespace threading { uint64_t ticks() { @@ -80,4 +80,4 @@ void Sleep(std::chrono::microseconds duration) { } } // namespace threading -} // namespace poly +} // namespace xe diff --git a/src/poly/type_pool.h b/src/xenia/base/type_pool.h similarity index 90% rename from src/poly/type_pool.h rename to src/xenia/base/type_pool.h index 1f29a5c39..81f0ba77f 100644 --- a/src/poly/type_pool.h +++ b/src/xenia/base/type_pool.h @@ -7,13 +7,13 @@ ****************************************************************************** */ -#ifndef POLY_TYPE_POOL_H_ -#define POLY_TYPE_POOL_H_ +#ifndef XENIA_BASE_TYPE_POOL_H_ +#define XENIA_BASE_TYPE_POOL_H_ #include #include -namespace poly { +namespace xe { template class TypePool { @@ -54,6 +54,6 @@ class TypePool { std::vector list_; }; -} // namespace poly +} // namespace xe -#endif // POLY_TYPE_POOL_H_ +#endif // XENIA_BASE_TYPE_POOL_H_ diff --git a/src/poly/vec128.h b/src/xenia/base/vec128.h similarity index 97% rename from src/poly/vec128.h rename to src/xenia/base/vec128.h index 7372a9e85..5a691253f 100644 --- a/src/poly/vec128.h +++ b/src/xenia/base/vec128.h @@ -7,15 +7,15 @@ ****************************************************************************** */ -#ifndef POLY_VEC128_H_ -#define POLY_VEC128_H_ +#ifndef XENIA_BASE_VEC128_H_ +#define XENIA_BASE_VEC128_H_ #include -#include "poly/math.h" -#include "poly/platform.h" +#include "xenia/base/math.h" +#include "xenia/base/platform.h" -namespace poly { +namespace xe { // The first rule of vector programming is to only rely on exact positions // when absolutely required - prefer dumb loops to exact offsets. @@ -194,6 +194,6 @@ static inline vec128_t vec128b(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, return v; } -} // namespace poly +} // namespace xe -#endif // POLY_VEC128_H_ +#endif // XENIA_BASE_VEC128_H_ diff --git a/src/xenia/cpu/backend/x64/x64_assembler.cc b/src/xenia/cpu/backend/x64/x64_assembler.cc index 60cafd87d..a9c93a440 100644 --- a/src/xenia/cpu/backend/x64/x64_assembler.cc +++ b/src/xenia/cpu/backend/x64/x64_assembler.cc @@ -9,13 +9,13 @@ #include "xenia/cpu/backend/x64/x64_assembler.h" +#include "xenia/base/reset_scope.h" #include "xenia/cpu/backend/x64/x64_backend.h" #include "xenia/cpu/backend/x64/x64_emitter.h" #include "xenia/cpu/backend/x64/x64_function.h" #include "xenia/cpu/hir/hir_builder.h" #include "xenia/cpu/hir/label.h" #include "xenia/cpu/runtime.h" -#include "poly/reset_scope.h" #include "xenia/profiling.h" namespace BE { @@ -65,7 +65,7 @@ int X64Assembler::Assemble(FunctionInfo* symbol_info, HIRBuilder* builder, SCOPE_profile_cpu_f("cpu"); // Reset when we leave. - poly::make_reset_scope(this); + xe::make_reset_scope(this); // Lower HIR -> x64. void* machine_code = 0; @@ -95,7 +95,7 @@ int X64Assembler::Assemble(FunctionInfo* symbol_info, HIRBuilder* builder, } void X64Assembler::DumpMachineCode(DebugInfo* debug_info, void* machine_code, - size_t code_size, poly::StringBuffer* str) { + size_t code_size, StringBuffer* str) { BE::DISASM disasm = {0}; disasm.Archi = 64; disasm.Options = BE::Tabulation + BE::MasmSyntax + BE::PrefixedNumeral; diff --git a/src/xenia/cpu/backend/x64/x64_assembler.h b/src/xenia/cpu/backend/x64/x64_assembler.h index f805ad248..2b9c5f305 100644 --- a/src/xenia/cpu/backend/x64/x64_assembler.h +++ b/src/xenia/cpu/backend/x64/x64_assembler.h @@ -12,8 +12,8 @@ #include +#include "xenia/base/string_buffer.h" #include "xenia/cpu/backend/assembler.h" -#include "poly/string_buffer.h" namespace xe { namespace cpu { @@ -39,14 +39,14 @@ class X64Assembler : public Assembler { private: void DumpMachineCode(DebugInfo* debug_info, void* machine_code, - size_t code_size, poly::StringBuffer* str); + size_t code_size, StringBuffer* str); private: X64Backend* x64_backend_; std::unique_ptr emitter_; std::unique_ptr allocator_; - poly::StringBuffer string_buffer_; + StringBuffer string_buffer_; }; } // namespace x64 diff --git a/src/xenia/cpu/backend/x64/x64_code_cache_posix.cc b/src/xenia/cpu/backend/x64/x64_code_cache_posix.cc index 8c2c92587..44ecb6ecd 100644 --- a/src/xenia/cpu/backend/x64/x64_code_cache_posix.cc +++ b/src/xenia/cpu/backend/x64/x64_code_cache_posix.cc @@ -11,8 +11,8 @@ #include -#include "poly/assert.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/math.h" namespace xe { namespace cpu { @@ -51,7 +51,7 @@ void* X64CodeCache::PlaceCode(void* machine_code, size_t code_size, size_t stack_size) { // Always move the code to land on 16b alignment. We do this by rounding up // to 16b so that all offsets are aligned. - code_size = poly::round_up(code_size, 16); + code_size = xe::round_up(code_size, 16); lock_.lock(); diff --git a/src/xenia/cpu/backend/x64/x64_code_cache_win.cc b/src/xenia/cpu/backend/x64/x64_code_cache_win.cc index 7ac255d23..c526db928 100644 --- a/src/xenia/cpu/backend/x64/x64_code_cache_win.cc +++ b/src/xenia/cpu/backend/x64/x64_code_cache_win.cc @@ -9,9 +9,9 @@ #include "xenia/cpu/backend/x64/x64_code_cache.h" -#include "poly/assert.h" -#include "poly/math.h" -#include "xenia/logging.h" +#include "xenia/base/assert.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" namespace xe { namespace cpu { @@ -64,11 +64,11 @@ void* X64CodeCache::PlaceCode(void* machine_code, size_t code_size, size_t alloc_size = code_size; // Add unwind info into the allocation size. Keep things 16b aligned. - alloc_size += poly::round_up(X64CodeChunk::UNWIND_INFO_SIZE, 16); + alloc_size += xe::round_up(X64CodeChunk::UNWIND_INFO_SIZE, 16); // Always move the code to land on 16b alignment. We do this by rounding up // to 16b so that all offsets are aligned. - alloc_size = poly::round_up(alloc_size, 16); + alloc_size = xe::round_up(alloc_size, 16); lock_.lock(); @@ -108,7 +108,7 @@ X64CodeChunk::X64CodeChunk(size_t chunk_size) PAGE_EXECUTE_READWRITE); fn_table_capacity = - static_cast(poly::round_up(capacity / ESTIMATED_FN_SIZE, 16)); + static_cast(xe::round_up(capacity / ESTIMATED_FN_SIZE, 16)); size_t table_size = fn_table_capacity * sizeof(RUNTIME_FUNCTION); fn_table = (RUNTIME_FUNCTION*)malloc(table_size); fn_table_count = 0; diff --git a/src/xenia/cpu/backend/x64/x64_emitter.cc b/src/xenia/cpu/backend/x64/x64_emitter.cc index 26ebd9bf1..a51996529 100644 --- a/src/xenia/cpu/backend/x64/x64_emitter.cc +++ b/src/xenia/cpu/backend/x64/x64_emitter.cc @@ -9,21 +9,21 @@ #include "xenia/cpu/backend/x64/x64_emitter.h" -#include "poly/assert.h" -#include "poly/math.h" -#include "poly/vec128.h" +#include "xenia/base/assert.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" +#include "xenia/base/vec128.h" #include "xenia/cpu/backend/x64/x64_backend.h" #include "xenia/cpu/backend/x64/x64_code_cache.h" #include "xenia/cpu/backend/x64/x64_function.h" #include "xenia/cpu/backend/x64/x64_sequences.h" #include "xenia/cpu/backend/x64/x64_thunk_emitter.h" #include "xenia/cpu/cpu-private.h" -#include "xenia/cpu/hir/hir_builder.h" #include "xenia/cpu/debug_info.h" +#include "xenia/cpu/hir/hir_builder.h" #include "xenia/cpu/runtime.h" #include "xenia/cpu/symbol_info.h" #include "xenia/cpu/thread_state.h" -#include "xenia/logging.h" #include "xenia/profiling.h" #include "xdb/protocol.h" @@ -36,10 +36,6 @@ namespace x64 { using namespace xe::cpu::hir; using namespace xe::cpu; -using poly::vec128b; -using poly::vec128f; -using poly::vec128i; - using namespace Xbyak; using xe::cpu::hir::HIRBuilder; using xe::cpu::hir::Instr; @@ -132,13 +128,13 @@ int X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) { auto slot = *it; size_t type_size = GetTypeSize(slot->type); // Align to natural size. - stack_offset = poly::align(stack_offset, type_size); + stack_offset = xe::align(stack_offset, type_size); slot->set_constant((uint32_t)stack_offset); stack_offset += type_size; } // Ensure 16b alignment. stack_offset -= StackLayout::GUEST_STACK_SIZE; - stack_offset = poly::align(stack_offset, static_cast(16)); + stack_offset = xe::align(stack_offset, static_cast(16)); // Function prolog. // Must be 16b aligned. @@ -536,8 +532,8 @@ uint64_t ResolveFunctionAddress(void* raw_context, uint32_t target_address) { Asm* table_slot = reinterpret_cast(table_start); bool wrote_ic = false; for (int i = 0; i < kICSlotCount; ++i) { - if (poly::atomic_cas(kICSlotInvalidTargetAddress, addr, - &table_slot->target_constant)) { + if (xe::atomic_cas(kICSlotInvalidTargetAddress, addr, + &table_slot->target_constant)) { // Got slot! Just write the compare and we're done. table_slot->address_constant = static_cast(target_address); wrote_ic = true; diff --git a/src/xenia/cpu/backend/x64/x64_emitter.h b/src/xenia/cpu/backend/x64/x64_emitter.h index ac47f934a..a3ea927e4 100644 --- a/src/xenia/cpu/backend/x64/x64_emitter.h +++ b/src/xenia/cpu/backend/x64/x64_emitter.h @@ -10,10 +10,11 @@ #ifndef XENIA_BACKEND_X64_X64_EMITTER_H_ #define XENIA_BACKEND_X64_X64_EMITTER_H_ -#include "xenia/cpu/hir/value.h" -#include "poly/arena.h" #include "third_party/xbyak/xbyak/xbyak.h" +#include "xenia/base/arena.h" +#include "xenia/cpu/hir/value.h" + namespace xe { namespace cpu { class DebugInfo; @@ -32,8 +33,6 @@ namespace cpu { namespace backend { namespace x64 { -using vec128_t = poly::vec128_t; - class X64Backend; class X64CodeCache; @@ -196,7 +195,7 @@ class X64Emitter : public Xbyak::CodeGenerator { hir::Instr* current_instr_; size_t source_map_count_; - poly::Arena source_map_arena_; + Arena source_map_arena_; size_t stack_size_; diff --git a/src/xenia/cpu/backend/x64/x64_sequences.cc b/src/xenia/cpu/backend/x64/x64_sequences.cc index c32efa336..7acc20e5c 100644 --- a/src/xenia/cpu/backend/x64/x64_sequences.cc +++ b/src/xenia/cpu/backend/x64/x64_sequences.cc @@ -24,13 +24,13 @@ #include "xenia/cpu/backend/x64/x64_sequences.h" -#include "poly/assert.h" -#include "poly/threading.h" +#include "xenia/base/assert.h" +#include "xenia/base/logging.h" +#include "xenia/base/threading.h" #include "xenia/cpu/backend/x64/x64_emitter.h" #include "xenia/cpu/backend/x64/x64_tracers.h" #include "xenia/cpu/hir/hir_builder.h" #include "xenia/cpu/runtime.h" -#include "xenia/logging.h" namespace xe { namespace cpu { @@ -43,8 +43,6 @@ using namespace Xbyak; using namespace xe::cpu::hir; using namespace xe::cpu; -using poly::vec128b; - typedef bool (*SequenceSelectFn)(X64Emitter&, const Instr*, const Instr**); std::unordered_multimap sequence_table; @@ -1022,7 +1020,7 @@ EMITTER(LOAD_VECTOR_SHL_I8, MATCH(I, I8<>>)) { static void Emit(X64Emitter& e, const EmitArgType& i) { if (i.src1.is_constant) { auto sh = i.src1.constant(); - assert_true(sh < poly::countof(lvsl_table)); + assert_true(sh < xe::countof(lvsl_table)); e.mov(e.rax, (uintptr_t)&lvsl_table[sh]); e.vmovaps(i.dest, e.ptr[e.rax]); } else { @@ -1066,7 +1064,7 @@ EMITTER(LOAD_VECTOR_SHR_I8, MATCH(I, I8<>>)) { static void Emit(X64Emitter& e, const EmitArgType& i) { if (i.src1.is_constant) { auto sh = i.src1.constant(); - assert_true(sh < poly::countof(lvsr_table)); + assert_true(sh < xe::countof(lvsr_table)); e.mov(e.rax, (uintptr_t)&lvsr_table[sh]); e.vmovaps(i.dest, e.ptr[e.rax]); } else { @@ -1095,7 +1093,7 @@ EMITTER(LOAD_CLOCK, MATCH(I>)) { e.mov(i.dest, e.rax); } static uint64_t LoadClock(void* raw_context) { - return poly::threading::ticks(); + return xe::threading::ticks(); } }; EMITTER_OPCODE_TABLE( @@ -4697,7 +4695,7 @@ EMITTER(VECTOR_ROTATE_LEFT_V128, MATCH(I, V128 _mm_store_si128(reinterpret_cast<__m128i*>(value), src1); _mm_store_si128(reinterpret_cast<__m128i*>(shamt), src2); for (size_t i = 0; i < 16; ++i) { - value[i] = poly::rotate_left(value[i], shamt[i] & 0x7); + value[i] = xe::rotate_left(value[i], shamt[i] & 0x7); } return _mm_load_si128(reinterpret_cast<__m128i*>(value)); } @@ -4707,7 +4705,7 @@ EMITTER(VECTOR_ROTATE_LEFT_V128, MATCH(I, V128 _mm_store_si128(reinterpret_cast<__m128i*>(value), src1); _mm_store_si128(reinterpret_cast<__m128i*>(shamt), src2); for (size_t i = 0; i < 8; ++i) { - value[i] = poly::rotate_left(value[i], shamt[i] & 0xF); + value[i] = xe::rotate_left(value[i], shamt[i] & 0xF); } return _mm_load_si128(reinterpret_cast<__m128i*>(value)); } diff --git a/src/xenia/cpu/backend/x64/x64_tracers.cc b/src/xenia/cpu/backend/x64/x64_tracers.cc index 10f934b0e..60701a058 100644 --- a/src/xenia/cpu/backend/x64/x64_tracers.cc +++ b/src/xenia/cpu/backend/x64/x64_tracers.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/backend/x64/x64_tracers.h" -#include "poly/vec128.h" +#include "xenia/base/vec128.h" #include "xenia/cpu/backend/x64/x64_emitter.h" #include "xenia/cpu/runtime.h" #include "xenia/cpu/thread_state.h" @@ -71,23 +71,22 @@ void TraceContextLoadI64(void* raw_context, uint64_t offset, uint64_t value) { } void TraceContextLoadF32(void* raw_context, uint64_t offset, __m128 value) { auto thread_state = *((ThreadState**)raw_context); - DPRINT("%e (%X) = ctx f32 +%llu\n", poly::m128_f32<0>(value), - poly::m128_i32<0>(value), offset); + DPRINT("%e (%X) = ctx f32 +%llu\n", xe::m128_f32<0>(value), + xe::m128_i32<0>(value), offset); } void TraceContextLoadF64(void* raw_context, uint64_t offset, const double* value) { auto thread_state = *((ThreadState**)raw_context); auto v = _mm_loadu_pd(value); - DPRINT("%le (%llX) = ctx f64 +%llu\n", poly::m128_f64<0>(v), - poly::m128_i64<0>(v), offset); + DPRINT("%le (%llX) = ctx f64 +%llu\n", xe::m128_f64<0>(v), xe::m128_i64<0>(v), + offset); } void TraceContextLoadV128(void* raw_context, uint64_t offset, __m128 value) { auto thread_state = *((ThreadState**)raw_context); DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = ctx v128 +%llu\n", - poly::m128_f32<0>(value), poly::m128_f32<1>(value), - poly::m128_f32<2>(value), poly::m128_f32<3>(value), - poly::m128_i32<0>(value), poly::m128_i32<1>(value), - poly::m128_i32<2>(value), poly::m128_i32<3>(value), offset); + xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value), + xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value), + xe::m128_i32<2>(value), xe::m128_i32<3>(value), offset); } void TraceContextStoreI8(void* raw_context, uint64_t offset, uint8_t value) { @@ -108,23 +107,22 @@ void TraceContextStoreI64(void* raw_context, uint64_t offset, uint64_t value) { } void TraceContextStoreF32(void* raw_context, uint64_t offset, __m128 value) { auto thread_state = *((ThreadState**)raw_context); - DPRINT("ctx f32 +%llu = %e (%X)\n", offset, poly::m128_f32<0>(value), - poly::m128_i32<0>(value)); + DPRINT("ctx f32 +%llu = %e (%X)\n", offset, xe::m128_f32<0>(value), + xe::m128_i32<0>(value)); } void TraceContextStoreF64(void* raw_context, uint64_t offset, const double* value) { auto thread_state = *((ThreadState**)raw_context); auto v = _mm_loadu_pd(value); - DPRINT("ctx f64 +%llu = %le (%llX)\n", offset, poly::m128_f64<0>(v), - poly::m128_i64<0>(v)); + DPRINT("ctx f64 +%llu = %le (%llX)\n", offset, xe::m128_f64<0>(v), + xe::m128_i64<0>(v)); } void TraceContextStoreV128(void* raw_context, uint64_t offset, __m128 value) { auto thread_state = *((ThreadState**)raw_context); DPRINT("ctx v128 +%llu = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n", offset, - poly::m128_f32<0>(value), poly::m128_f32<1>(value), - poly::m128_f32<2>(value), poly::m128_f32<3>(value), - poly::m128_i32<0>(value), poly::m128_i32<1>(value), - poly::m128_i32<2>(value), poly::m128_i32<3>(value)); + xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value), + xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value), + xe::m128_i32<2>(value), xe::m128_i32<3>(value)); } void TraceMemoryLoadI8(void* raw_context, uint32_t address, uint8_t value) { @@ -145,21 +143,20 @@ void TraceMemoryLoadI64(void* raw_context, uint32_t address, uint64_t value) { } void TraceMemoryLoadF32(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *((ThreadState**)raw_context); - DPRINT("%e (%X) = load.f32 %.8X\n", poly::m128_f32<0>(value), - poly::m128_i32<0>(value), address); + DPRINT("%e (%X) = load.f32 %.8X\n", xe::m128_f32<0>(value), + xe::m128_i32<0>(value), address); } void TraceMemoryLoadF64(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *((ThreadState**)raw_context); - DPRINT("%le (%llX) = load.f64 %.8X\n", poly::m128_f64<0>(value), - poly::m128_i64<0>(value), address); + DPRINT("%le (%llX) = load.f64 %.8X\n", xe::m128_f64<0>(value), + xe::m128_i64<0>(value), address); } void TraceMemoryLoadV128(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *((ThreadState**)raw_context); DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = load.v128 %.8X\n", - poly::m128_f32<0>(value), poly::m128_f32<1>(value), - poly::m128_f32<2>(value), poly::m128_f32<3>(value), - poly::m128_i32<0>(value), poly::m128_i32<1>(value), - poly::m128_i32<2>(value), poly::m128_i32<3>(value), address); + xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value), + xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value), + xe::m128_i32<2>(value), xe::m128_i32<3>(value), address); } void TraceMemoryStoreI8(void* raw_context, uint32_t address, uint8_t value) { @@ -180,21 +177,21 @@ void TraceMemoryStoreI64(void* raw_context, uint32_t address, uint64_t value) { } void TraceMemoryStoreF32(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *((ThreadState**)raw_context); - DPRINT("store.f32 %.8X = %e (%X)\n", address, poly::m128_f32<0>(value), - poly::m128_i32<0>(value)); + DPRINT("store.f32 %.8X = %e (%X)\n", address, xe::m128_f32<0>(value), + xe::m128_i32<0>(value)); } void TraceMemoryStoreF64(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *((ThreadState**)raw_context); - DPRINT("store.f64 %.8X = %le (%llX)\n", address, poly::m128_f64<0>(value), - poly::m128_i64<0>(value)); + DPRINT("store.f64 %.8X = %le (%llX)\n", address, xe::m128_f64<0>(value), + xe::m128_i64<0>(value)); } void TraceMemoryStoreV128(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *((ThreadState**)raw_context); DPRINT("store.v128 %.8X = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n", - address, poly::m128_f32<0>(value), poly::m128_f32<1>(value), - poly::m128_f32<2>(value), poly::m128_f32<3>(value), - poly::m128_i32<0>(value), poly::m128_i32<1>(value), - poly::m128_i32<2>(value), poly::m128_i32<3>(value)); + address, xe::m128_f32<0>(value), xe::m128_f32<1>(value), + xe::m128_f32<2>(value), xe::m128_f32<3>(value), xe::m128_i32<0>(value), + xe::m128_i32<1>(value), xe::m128_i32<2>(value), + xe::m128_i32<3>(value)); } } // namespace x64 diff --git a/src/xenia/cpu/compiler/compiler.h b/src/xenia/cpu/compiler/compiler.h index 1c84d999f..17b4b6c98 100644 --- a/src/xenia/cpu/compiler/compiler.h +++ b/src/xenia/cpu/compiler/compiler.h @@ -13,8 +13,8 @@ #include #include +#include "xenia/base/arena.h" #include "xenia/cpu/hir/hir_builder.h" -#include "poly/arena.h" namespace xe { namespace cpu { @@ -34,7 +34,7 @@ class Compiler { ~Compiler(); Runtime* runtime() const { return runtime_; } - poly::Arena* scratch_arena() { return &scratch_arena_; } + Arena* scratch_arena() { return &scratch_arena_; } void AddPass(std::unique_ptr pass); @@ -44,7 +44,7 @@ class Compiler { private: Runtime* runtime_; - poly::Arena scratch_arena_; + Arena scratch_arena_; std::vector> passes_; }; diff --git a/src/xenia/cpu/compiler/compiler_pass.cc b/src/xenia/cpu/compiler/compiler_pass.cc index ec80973d4..b9b768099 100644 --- a/src/xenia/cpu/compiler/compiler_pass.cc +++ b/src/xenia/cpu/compiler/compiler_pass.cc @@ -25,7 +25,7 @@ int CompilerPass::Initialize(Compiler* compiler) { return 0; } -poly::Arena* CompilerPass::scratch_arena() const { +Arena* CompilerPass::scratch_arena() const { return compiler_->scratch_arena(); } diff --git a/src/xenia/cpu/compiler/compiler_pass.h b/src/xenia/cpu/compiler/compiler_pass.h index 884001433..0857cfdc9 100644 --- a/src/xenia/cpu/compiler/compiler_pass.h +++ b/src/xenia/cpu/compiler/compiler_pass.h @@ -10,8 +10,8 @@ #ifndef XENIA_COMPILER_COMPILER_PASS_H_ #define XENIA_COMPILER_COMPILER_PASS_H_ +#include "xenia/base/arena.h" #include "xenia/cpu/hir/hir_builder.h" -#include "poly/arena.h" namespace xe { namespace cpu { @@ -35,7 +35,7 @@ class CompilerPass { virtual int Run(hir::HIRBuilder* builder) = 0; protected: - poly::Arena* scratch_arena() const; + Arena* scratch_arena() const; protected: Runtime* runtime_; diff --git a/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc b/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc index 043f34055..4fb4e0c79 100644 --- a/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc +++ b/src/xenia/cpu/compiler/passes/constant_propagation_pass.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/compiler/passes/constant_propagation_pass.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/function.h" #include "xenia/cpu/runtime.h" #include "xenia/profiling.h" diff --git a/src/xenia/cpu/compiler/passes/context_promotion_pass.h b/src/xenia/cpu/compiler/passes/context_promotion_pass.h index ae384853a..94f308c67 100644 --- a/src/xenia/cpu/compiler/passes/context_promotion_pass.h +++ b/src/xenia/cpu/compiler/passes/context_promotion_pass.h @@ -10,7 +10,7 @@ #ifndef XENIA_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_ #define XENIA_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_ -#include "poly/platform.h" +#include "xenia/base/platform.h" #include "xenia/cpu/compiler/compiler_pass.h" #if XE_COMPILER_MSVC diff --git a/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc b/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc index d8a901fd7..84a6886d2 100644 --- a/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc +++ b/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc @@ -9,8 +9,8 @@ #include "xenia/cpu/compiler/passes/data_flow_analysis_pass.h" -#include "poly/assert.h" -#include "poly/platform.h" +#include "xenia/base/assert.h" +#include "xenia/base/platform.h" #include "xenia/cpu/backend/backend.h" #include "xenia/cpu/compiler/compiler.h" #include "xenia/cpu/runtime.h" diff --git a/src/xenia/cpu/compiler/passes/register_allocation_pass.cc b/src/xenia/cpu/compiler/passes/register_allocation_pass.cc index 15b93c51c..92dde1007 100644 --- a/src/xenia/cpu/compiler/passes/register_allocation_pass.cc +++ b/src/xenia/cpu/compiler/passes/register_allocation_pass.cc @@ -11,9 +11,9 @@ #include -#include "poly/assert.h" -#include "poly/math.h" -#include "xenia/logging.h" +#include "xenia/base/assert.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/profiling.h" namespace xe { @@ -61,7 +61,7 @@ RegisterAllocationPass::RegisterAllocationPass(const MachineInfo* machine_info) } RegisterAllocationPass::~RegisterAllocationPass() { - for (size_t n = 0; n < poly::countof(usage_sets_.all_sets); n++) { + for (size_t n = 0; n < xe::countof(usage_sets_.all_sets); n++) { if (!usage_sets_.all_sets[n]) { break; } @@ -175,7 +175,7 @@ int RegisterAllocationPass::Run(HIRBuilder* builder) { void RegisterAllocationPass::DumpUsage(const char* name) { #if 0 fprintf(stdout, "\n%s:\n", name); - for (size_t i = 0; i < poly::countof(usage_sets_.all_sets); ++i) { + for (size_t i = 0; i < xe::countof(usage_sets_.all_sets); ++i) { auto usage_set = usage_sets_.all_sets[i]; if (usage_set) { fprintf(stdout, "set %s:\n", usage_set->set->name); @@ -194,7 +194,7 @@ void RegisterAllocationPass::DumpUsage(const char* name) { } void RegisterAllocationPass::PrepareBlockState() { - for (size_t i = 0; i < poly::countof(usage_sets_.all_sets); ++i) { + for (size_t i = 0; i < xe::countof(usage_sets_.all_sets); ++i) { auto usage_set = usage_sets_.all_sets[i]; if (usage_set) { usage_set->availability.set(); @@ -205,7 +205,7 @@ void RegisterAllocationPass::PrepareBlockState() { } void RegisterAllocationPass::AdvanceUses(Instr* instr) { - for (size_t i = 0; i < poly::countof(usage_sets_.all_sets); ++i) { + for (size_t i = 0; i < xe::countof(usage_sets_.all_sets); ++i) { auto usage_set = usage_sets_.all_sets[i]; if (!usage_set) { break; @@ -310,7 +310,7 @@ bool RegisterAllocationPass::TryAllocateRegister(Value* value) { // Find the first free register, if any. // We have to ensure it's a valid one (in our count). uint32_t first_unused = 0; - bool none_used = poly::bit_scan_forward( + bool none_used = xe::bit_scan_forward( static_cast(usage_set->availability.to_ulong()), &first_unused); if (none_used && first_unused < usage_set->count) { // Available! Use it! diff --git a/src/xenia/cpu/compiler/passes/validation_pass.cc b/src/xenia/cpu/compiler/passes/validation_pass.cc index 5654ec998..36d5b38d9 100644 --- a/src/xenia/cpu/compiler/passes/validation_pass.cc +++ b/src/xenia/cpu/compiler/passes/validation_pass.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/compiler/passes/validation_pass.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/backend/backend.h" #include "xenia/cpu/compiler/compiler.h" #include "xenia/cpu/runtime.h" diff --git a/src/xenia/cpu/compiler/passes/value_reduction_pass.cc b/src/xenia/cpu/compiler/passes/value_reduction_pass.cc index 3cdfa1ffc..807ee347f 100644 --- a/src/xenia/cpu/compiler/passes/value_reduction_pass.cc +++ b/src/xenia/cpu/compiler/passes/value_reduction_pass.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/compiler/passes/value_reduction_pass.h" -#include "poly/platform.h" +#include "xenia/base/platform.h" #include "xenia/cpu/backend/backend.h" #include "xenia/cpu/compiler/compiler.h" #include "xenia/cpu/runtime.h" diff --git a/src/xenia/cpu/debugger.h b/src/xenia/cpu/debugger.h index 20b282fe2..ab94e3f80 100644 --- a/src/xenia/cpu/debugger.h +++ b/src/xenia/cpu/debugger.h @@ -15,7 +15,7 @@ #include #include -#include "poly/delegate.h" +#include "xenia/base/delegate.h" #include "xenia/cpu/thread_state.h" namespace xe { @@ -104,7 +104,7 @@ class Debugger { void OnBreakpointHit(ThreadState* thread_state, Breakpoint* breakpoint); public: - poly::Delegate breakpoint_hit; + Delegate breakpoint_hit; private: Runtime* runtime_; diff --git a/src/xenia/cpu/entry_table.cc b/src/xenia/cpu/entry_table.cc index b02334cd6..618c48d64 100644 --- a/src/xenia/cpu/entry_table.cc +++ b/src/xenia/cpu/entry_table.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/entry_table.h" -#include "poly/threading.h" +#include "xenia/base/threading.h" #include "xenia/profiling.h" namespace xe { @@ -53,7 +53,7 @@ Entry::Status EntryTable::GetOrCreate(uint32_t address, Entry** out_entry) { do { lock_.unlock(); // TODO(benvanik): sleep for less time? - poly::threading::Sleep(std::chrono::microseconds(10)); + xe::threading::Sleep(std::chrono::microseconds(10)); lock_.lock(); } while (entry->status == Entry::STATUS_COMPILING); } diff --git a/src/xenia/cpu/export_resolver.cc b/src/xenia/cpu/export_resolver.cc index 4974c25cb..95bb9ce8f 100644 --- a/src/xenia/cpu/export_resolver.cc +++ b/src/xenia/cpu/export_resolver.cc @@ -9,8 +9,8 @@ #include "xenia/cpu/export_resolver.h" -#include "poly/assert.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/math.h" namespace xe { namespace cpu { diff --git a/src/xenia/cpu/frontend/ppc_context.h b/src/xenia/cpu/frontend/ppc_context.h index 336496e60..81a30e302 100644 --- a/src/xenia/cpu/frontend/ppc_context.h +++ b/src/xenia/cpu/frontend/ppc_context.h @@ -12,7 +12,7 @@ #include -#include "poly/vec128.h" +#include "xenia/base/vec128.h" namespace xe { namespace cpu { @@ -25,8 +25,6 @@ namespace xe { namespace cpu { namespace frontend { -using vec128_t = poly::vec128_t; - // Map: // 0-31: GPR // 32-63: FPR diff --git a/src/xenia/cpu/frontend/ppc_disasm.cc b/src/xenia/cpu/frontend/ppc_disasm.cc index cdb6bb3f1..cd1773105 100644 --- a/src/xenia/cpu/frontend/ppc_disasm.cc +++ b/src/xenia/cpu/frontend/ppc_disasm.cc @@ -9,63 +9,63 @@ #include "xenia/cpu/frontend/ppc_disasm.h" -#include "poly/assert.h" -#include "poly/math.h" -#include "poly/string_buffer.h" +#include "xenia/base/assert.h" +#include "xenia/base/math.h" +#include "xenia/base/string_buffer.h" namespace xe { namespace cpu { namespace frontend { -void Disasm_0(InstrData& i, poly::StringBuffer* str) { +void Disasm_0(InstrData& i, StringBuffer* str) { str->Append("%-8s ???", i.type->name); } -void Disasm__(InstrData& i, poly::StringBuffer* str) { +void Disasm__(InstrData& i, StringBuffer* str) { str->Append("%-8s", i.type->name); } -void Disasm_X_FRT_FRB(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_FRT_FRB(InstrData& i, StringBuffer* str) { str->Append("%*s%s f%d, f%d", i.X.Rc ? -7 : -8, i.type->name, i.X.Rc ? "." : "", i.X.RT, i.X.RB); } -void Disasm_A_FRT_FRB(InstrData& i, poly::StringBuffer* str) { +void Disasm_A_FRT_FRB(InstrData& i, StringBuffer* str) { str->Append("%*s%s f%d, f%d", i.A.Rc ? -7 : -8, i.type->name, i.A.Rc ? "." : "", i.A.FRT, i.A.FRB); } -void Disasm_A_FRT_FRA_FRB(InstrData& i, poly::StringBuffer* str) { +void Disasm_A_FRT_FRA_FRB(InstrData& i, StringBuffer* str) { str->Append("%*s%s f%d, f%d, f%d", i.A.Rc ? -7 : -8, i.type->name, i.A.Rc ? "." : "", i.A.FRT, i.A.FRA, i.A.FRB); } -void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, poly::StringBuffer* str) { +void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, StringBuffer* str) { str->Append("%*s%s f%d, f%d, f%d, f%d", i.A.Rc ? -7 : -8, i.type->name, i.A.Rc ? "." : "", i.A.FRT, i.A.FRA, i.A.FRB, i.A.FRC); } -void Disasm_X_RT_RA_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_RT_RA_RB(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB); } -void Disasm_X_RT_RA0_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_RT_RA0_RB(InstrData& i, StringBuffer* str) { if (i.X.RA) { str->Append("%-8s r%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB); } else { str->Append("%-8s r%d, 0, r%d", i.type->name, i.X.RT, i.X.RB); } } -void Disasm_X_FRT_RA_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_FRT_RA_RB(InstrData& i, StringBuffer* str) { str->Append("%-8s f%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB); } -void Disasm_X_FRT_RA0_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_FRT_RA0_RB(InstrData& i, StringBuffer* str) { if (i.X.RA) { str->Append("%-8s f%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB); } else { str->Append("%-8s f%d, 0, r%d", i.type->name, i.X.RT, i.X.RB); } } -void Disasm_D_RT_RA_I(InstrData& i, poly::StringBuffer* str) { +void Disasm_D_RT_RA_I(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d, r%d, %d", i.type->name, i.D.RT, i.D.RA, (int32_t)(int16_t) XEEXTS16(i.D.DS)); } -void Disasm_D_RT_RA0_I(InstrData& i, poly::StringBuffer* str) { +void Disasm_D_RT_RA0_I(InstrData& i, StringBuffer* str) { if (i.D.RA) { str->Append("%-8s r%d, r%d, %d", i.type->name, i.D.RT, i.D.RA, (int32_t)(int16_t) XEEXTS16(i.D.DS)); @@ -74,11 +74,11 @@ void Disasm_D_RT_RA0_I(InstrData& i, poly::StringBuffer* str) { (int32_t)(int16_t) XEEXTS16(i.D.DS)); } } -void Disasm_D_FRT_RA_I(InstrData& i, poly::StringBuffer* str) { +void Disasm_D_FRT_RA_I(InstrData& i, StringBuffer* str) { str->Append("%-8s f%d, r%d, %d", i.type->name, i.D.RT, i.D.RA, (int32_t)(int16_t) XEEXTS16(i.D.DS)); } -void Disasm_D_FRT_RA0_I(InstrData& i, poly::StringBuffer* str) { +void Disasm_D_FRT_RA0_I(InstrData& i, StringBuffer* str) { if (i.D.RA) { str->Append("%-8s f%d, r%d, %d", i.type->name, i.D.RT, i.D.RA, (int32_t)(int16_t) XEEXTS16(i.D.DS)); @@ -87,11 +87,11 @@ void Disasm_D_FRT_RA0_I(InstrData& i, poly::StringBuffer* str) { (int32_t)(int16_t) XEEXTS16(i.D.DS)); } } -void Disasm_DS_RT_RA_I(InstrData& i, poly::StringBuffer* str) { +void Disasm_DS_RT_RA_I(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d, r%d, %d", i.type->name, i.DS.RT, i.DS.RA, (int32_t)(int16_t) XEEXTS16(i.DS.DS << 2)); } -void Disasm_DS_RT_RA0_I(InstrData& i, poly::StringBuffer* str) { +void Disasm_DS_RT_RA0_I(InstrData& i, StringBuffer* str) { if (i.DS.RA) { str->Append("%-8s r%d, r%d, %d", i.type->name, i.DS.RT, i.DS.RA, (int32_t)(int16_t) XEEXTS16(i.DS.DS << 2)); @@ -100,29 +100,29 @@ void Disasm_DS_RT_RA0_I(InstrData& i, poly::StringBuffer* str) { (int32_t)(int16_t) XEEXTS16(i.DS.DS << 2)); } } -void Disasm_D_RA(InstrData& i, poly::StringBuffer* str) { +void Disasm_D_RA(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d", i.type->name, i.D.RA); } -void Disasm_X_RA_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_RA_RB(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d, r%d", i.type->name, i.X.RA, i.X.RB); } -void Disasm_XO_RT_RA_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_XO_RT_RA_RB(InstrData& i, StringBuffer* str) { str->Append("%*s%s%s r%d, r%d, r%d", i.XO.Rc ? -7 : -8, i.type->name, i.XO.OE ? "o" : "", i.XO.Rc ? "." : "", i.XO.RT, i.XO.RA, i.XO.RB); } -void Disasm_XO_RT_RA(InstrData& i, poly::StringBuffer* str) { +void Disasm_XO_RT_RA(InstrData& i, StringBuffer* str) { str->Append("%*s%s%s r%d, r%d", i.XO.Rc ? -7 : -8, i.type->name, i.XO.OE ? "o" : "", i.XO.Rc ? "." : "", i.XO.RT, i.XO.RA); } -void Disasm_X_RA_RT_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_RA_RT_RB(InstrData& i, StringBuffer* str) { str->Append("%*s%s r%d, r%d, r%d", i.X.Rc ? -7 : -8, i.type->name, i.X.Rc ? "." : "", i.X.RA, i.X.RT, i.X.RB); } -void Disasm_D_RA_RT_I(InstrData& i, poly::StringBuffer* str) { +void Disasm_D_RA_RT_I(InstrData& i, StringBuffer* str) { str->Append("%-7s. r%d, r%d, %.4Xh", i.type->name, i.D.RA, i.D.RT, i.D.DS); } -void Disasm_X_RA_RT(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_RA_RT(InstrData& i, StringBuffer* str) { str->Append("%*s%s r%d, r%d", i.X.Rc ? -7 : -8, i.type->name, i.X.Rc ? "." : "", i.X.RA, i.X.RT); } @@ -161,14 +161,14 @@ void Disasm_X_RA_RT(InstrData& i, poly::StringBuffer* str) { (i.VX128_R.VA128l | (i.VX128_R.VA128h << 5) | (i.VX128_R.VA128H << 6)) #define VX128_R_VB128 (i.VX128_R.VB128l | (i.VX128_R.VB128h << 5)) -void Disasm_X_VX_RA0_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_X_VX_RA0_RB(InstrData& i, StringBuffer* str) { if (i.X.RA) { str->Append("%-8s v%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB); } else { str->Append("%-8s v%d, 0, r%d", i.type->name, i.X.RT, i.X.RB); } } -void Disasm_VX1281_VD_RA0_RB(InstrData& i, poly::StringBuffer* str) { +void Disasm_VX1281_VD_RA0_RB(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_1_VD128; if (i.VX128_1.RA) { str->Append("%-8s v%d, r%d, r%d", i.type->name, vd, i.VX128_1.RA, @@ -177,45 +177,45 @@ void Disasm_VX1281_VD_RA0_RB(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s v%d, 0, r%d", i.type->name, vd, i.VX128_1.RB); } } -void Disasm_VX1283_VD_VB(InstrData& i, poly::StringBuffer* str) { +void Disasm_VX1283_VD_VB(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_3_VD128; const uint32_t vb = VX128_3_VB128; str->Append("%-8s v%d, v%d", i.type->name, vd, vb); } -void Disasm_VX1283_VD_VB_I(InstrData& i, poly::StringBuffer* str) { +void Disasm_VX1283_VD_VB_I(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_VD128; const uint32_t va = VX128_VA128; const uint32_t uimm = i.VX128_3.IMM; str->Append("%-8s v%d, v%d, %.2Xh", i.type->name, vd, va, uimm); } -void Disasm_VX_VD_VA_VB(InstrData& i, poly::StringBuffer* str) { +void Disasm_VX_VD_VA_VB(InstrData& i, StringBuffer* str) { str->Append("%-8s v%d, v%d, v%d", i.type->name, i.VX.VD, i.VX.VA, i.VX.VB); } -void Disasm_VX128_VD_VA_VB(InstrData& i, poly::StringBuffer* str) { +void Disasm_VX128_VD_VA_VB(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_VD128; const uint32_t va = VX128_VA128; const uint32_t vb = VX128_VB128; str->Append("%-8s v%d, v%d, v%d", i.type->name, vd, va, vb); } -void Disasm_VX128_VD_VA_VD_VB(InstrData& i, poly::StringBuffer* str) { +void Disasm_VX128_VD_VA_VD_VB(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_VD128; const uint32_t va = VX128_VA128; const uint32_t vb = VX128_VB128; str->Append("%-8s v%d, v%d, v%d, v%d", i.type->name, vd, va, vd, vb); } -void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, poly::StringBuffer* str) { +void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_2_VD128; const uint32_t va = VX128_2_VA128; const uint32_t vb = VX128_2_VB128; const uint32_t vc = i.VX128_2.VC; str->Append("%-8s v%d, v%d, v%d, v%d", i.type->name, vd, va, vb, vc); } -void Disasm_VXA_VD_VA_VB_VC(InstrData& i, poly::StringBuffer* str) { +void Disasm_VXA_VD_VA_VB_VC(InstrData& i, StringBuffer* str) { str->Append("%-8s v%d, v%d, v%d, v%d", i.type->name, i.VXA.VD, i.VXA.VA, i.VXA.VB, i.VXA.VC); } -void Disasm_sync(InstrData& i, poly::StringBuffer* str) { +void Disasm_sync(InstrData& i, StringBuffer* str) { const char* name; int L = i.X.RT & 3; switch (L) { @@ -234,7 +234,7 @@ void Disasm_sync(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s %.2X", name, L); } -void Disasm_dcbf(InstrData& i, poly::StringBuffer* str) { +void Disasm_dcbf(InstrData& i, StringBuffer* str) { const char* name; switch (i.X.RT & 3) { case 0: @@ -256,7 +256,7 @@ void Disasm_dcbf(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s r%d, r%d", name, i.X.RA, i.X.RB); } -void Disasm_dcbz(InstrData& i, poly::StringBuffer* str) { +void Disasm_dcbz(InstrData& i, StringBuffer* str) { // or dcbz128 0x7C2007EC if (i.X.RA) { str->Append("%-8s r%d, r%d", i.type->name, i.X.RA, i.X.RB); @@ -265,16 +265,16 @@ void Disasm_dcbz(InstrData& i, poly::StringBuffer* str) { } } -void Disasm_fcmp(InstrData& i, poly::StringBuffer* str) { +void Disasm_fcmp(InstrData& i, StringBuffer* str) { str->Append("%-8s cr%d, f%d, f%d", i.type->name, i.X.RT >> 2, i.X.RA, i.X.RB); } -void Disasm_mffsx(InstrData& i, poly::StringBuffer* str) { +void Disasm_mffsx(InstrData& i, StringBuffer* str) { str->Append("%*s%s f%d, FPSCR", i.X.Rc ? -7 : -8, i.type->name, i.X.Rc ? "." : "", i.X.RT); } -void Disasm_bx(InstrData& i, poly::StringBuffer* str) { +void Disasm_bx(InstrData& i, StringBuffer* str) { const char* name = i.I.LK ? "bl" : "b"; uint32_t nia; if (i.I.AA) { @@ -285,7 +285,7 @@ void Disasm_bx(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s %.8X", name, nia); // TODO(benvanik): resolve target name? } -void Disasm_bcx(InstrData& i, poly::StringBuffer* str) { +void Disasm_bcx(InstrData& i, StringBuffer* str) { const char* s0 = i.B.LK ? "lr, " : ""; const char* s1; if (!select_bits(i.B.BO, 2, 2)) { @@ -295,7 +295,7 @@ void Disasm_bcx(InstrData& i, poly::StringBuffer* str) { } char s2[8] = {0}; if (!select_bits(i.B.BO, 4, 4)) { - snprintf(s2, poly::countof(s2), "cr%d, ", i.B.BI >> 2); + snprintf(s2, xe::countof(s2), "cr%d, ", i.B.BI >> 2); } uint32_t nia; if (i.B.AA) { @@ -306,17 +306,17 @@ void Disasm_bcx(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s %s%s%s%.8X", i.type->name, s0, s1, s2, nia); // TODO(benvanik): resolve target name? } -void Disasm_bcctrx(InstrData& i, poly::StringBuffer* str) { +void Disasm_bcctrx(InstrData& i, StringBuffer* str) { // TODO(benvanik): mnemonics const char* s0 = i.XL.LK ? "lr, " : ""; char s2[8] = {0}; if (!select_bits(i.XL.BO, 4, 4)) { - snprintf(s2, poly::countof(s2), "cr%d, ", i.XL.BI >> 2); + snprintf(s2, xe::countof(s2), "cr%d, ", i.XL.BI >> 2); } str->Append("%-8s %s%sctr", i.type->name, s0, s2); // TODO(benvanik): resolve target name? } -void Disasm_bclrx(InstrData& i, poly::StringBuffer* str) { +void Disasm_bclrx(InstrData& i, StringBuffer* str) { const char* name = "bclr"; if (i.code == 0x4E800020) { name = "blr"; @@ -329,12 +329,12 @@ void Disasm_bclrx(InstrData& i, poly::StringBuffer* str) { } char s2[8] = {0}; if (!select_bits(i.XL.BO, 4, 4)) { - snprintf(s2, poly::countof(s2), "cr%d, ", i.XL.BI >> 2); + snprintf(s2, xe::countof(s2), "cr%d, ", i.XL.BI >> 2); } str->Append("%-8s %s%s", name, s1, s2); } -void Disasm_mfcr(InstrData& i, poly::StringBuffer* str) { +void Disasm_mfcr(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d, cr", i.type->name, i.X.RT); } const char* Disasm_spr_name(uint32_t n) { @@ -352,40 +352,40 @@ const char* Disasm_spr_name(uint32_t n) { } return reg; } -void Disasm_mfspr(InstrData& i, poly::StringBuffer* str) { +void Disasm_mfspr(InstrData& i, StringBuffer* str) { const uint32_t n = ((i.XFX.spr & 0x1F) << 5) | ((i.XFX.spr >> 5) & 0x1F); const char* reg = Disasm_spr_name(n); str->Append("%-8s r%d, %s", i.type->name, i.XFX.RT, reg); } -void Disasm_mtspr(InstrData& i, poly::StringBuffer* str) { +void Disasm_mtspr(InstrData& i, StringBuffer* str) { const uint32_t n = ((i.XFX.spr & 0x1F) << 5) | ((i.XFX.spr >> 5) & 0x1F); const char* reg = Disasm_spr_name(n); str->Append("%-8s %s, r%d", i.type->name, reg, i.XFX.RT); } -void Disasm_mftb(InstrData& i, poly::StringBuffer* str) { +void Disasm_mftb(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d, tb", i.type->name, i.XFX.RT); } -void Disasm_mfmsr(InstrData& i, poly::StringBuffer* str) { +void Disasm_mfmsr(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d", i.type->name, i.X.RT); } -void Disasm_mtmsr(InstrData& i, poly::StringBuffer* str) { +void Disasm_mtmsr(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d, %d", i.type->name, i.X.RT, (i.X.RA & 16) ? 1 : 0); } -void Disasm_cmp(InstrData& i, poly::StringBuffer* str) { +void Disasm_cmp(InstrData& i, StringBuffer* str) { str->Append("%-8s cr%d, %.2X, r%d, r%d", i.type->name, i.X.RT >> 2, i.X.RT & 1, i.X.RA, i.X.RB); } -void Disasm_cmpi(InstrData& i, poly::StringBuffer* str) { +void Disasm_cmpi(InstrData& i, StringBuffer* str) { str->Append("%-8s cr%d, %.2X, r%d, %d", i.type->name, i.D.RT >> 2, i.D.RT & 1, i.D.RA, XEEXTS16(i.D.DS)); } -void Disasm_cmpli(InstrData& i, poly::StringBuffer* str) { +void Disasm_cmpli(InstrData& i, StringBuffer* str) { str->Append("%-8s cr%d, %.2X, r%d, %.2X", i.type->name, i.D.RT >> 2, i.D.RT & 1, i.D.RA, XEEXTS16(i.D.DS)); } -void Disasm_rld(InstrData& i, poly::StringBuffer* str) { +void Disasm_rld(InstrData& i, StringBuffer* str) { if (i.MD.idx == 0) { // XEDISASMR(rldiclx, 0x78000000, MD ) str->Append("%*s%s r%d, r%d, %d, %d", i.MD.Rc ? -7 : -8, "rldicl", @@ -422,75 +422,75 @@ void Disasm_rld(InstrData& i, poly::StringBuffer* str) { assert_always(); } } -void Disasm_rlwim(InstrData& i, poly::StringBuffer* str) { +void Disasm_rlwim(InstrData& i, StringBuffer* str) { str->Append("%*s%s r%d, r%d, %d, %d, %d", i.M.Rc ? -7 : -8, i.type->name, i.M.Rc ? "." : "", i.M.RA, i.M.RT, i.M.SH, i.M.MB, i.M.ME); } -void Disasm_rlwnmx(InstrData& i, poly::StringBuffer* str) { +void Disasm_rlwnmx(InstrData& i, StringBuffer* str) { str->Append("%*s%s r%d, r%d, r%d, %d, %d", i.M.Rc ? -7 : -8, i.type->name, i.M.Rc ? "." : "", i.M.RA, i.M.RT, i.M.SH, i.M.MB, i.M.ME); } -void Disasm_srawix(InstrData& i, poly::StringBuffer* str) { +void Disasm_srawix(InstrData& i, StringBuffer* str) { str->Append("%*s%s r%d, r%d, %d", i.X.Rc ? -7 : -8, i.type->name, i.X.Rc ? "." : "", i.X.RA, i.X.RT, i.X.RB); } -void Disasm_sradix(InstrData& i, poly::StringBuffer* str) { +void Disasm_sradix(InstrData& i, StringBuffer* str) { str->Append("%*s%s r%d, r%d, %d", i.XS.Rc ? -7 : -8, i.type->name, i.XS.Rc ? "." : "", i.XS.RA, i.XS.RT, (i.XS.SH5 << 5) | i.XS.SH); } -void Disasm_vpermwi128(InstrData& i, poly::StringBuffer* str) { +void Disasm_vpermwi128(InstrData& i, StringBuffer* str) { const uint32_t vd = i.VX128_P.VD128l | (i.VX128_P.VD128h << 5); const uint32_t vb = i.VX128_P.VB128l | (i.VX128_P.VB128h << 5); str->Append("%-8s v%d, v%d, %.2X", i.type->name, vd, vb, i.VX128_P.PERMl | (i.VX128_P.PERMh << 5)); } -void Disasm_vrfin128(InstrData& i, poly::StringBuffer* str) { +void Disasm_vrfin128(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_3_VD128; const uint32_t vb = VX128_3_VB128; str->Append("%-8s v%d, v%d", i.type->name, vd, vb); } -void Disasm_vrlimi128(InstrData& i, poly::StringBuffer* str) { +void Disasm_vrlimi128(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_4_VD128; const uint32_t vb = VX128_4_VB128; str->Append("%-8s v%d, v%d, %.2X, %.2X", i.type->name, vd, vb, i.VX128_4.IMM, i.VX128_4.z); } -void Disasm_vsldoi128(InstrData& i, poly::StringBuffer* str) { +void Disasm_vsldoi128(InstrData& i, StringBuffer* str) { const uint32_t vd = VX128_5_VD128; const uint32_t va = VX128_5_VA128; const uint32_t vb = VX128_5_VB128; const uint32_t sh = i.VX128_5.SH; str->Append("%-8s v%d, v%d, v%d, %.2X", i.type->name, vd, va, vb, sh); } -void Disasm_vspltb(InstrData& i, poly::StringBuffer* str) { +void Disasm_vspltb(InstrData& i, StringBuffer* str) { str->Append("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB, i.VX.VA & 0xF); } -void Disasm_vsplth(InstrData& i, poly::StringBuffer* str) { +void Disasm_vsplth(InstrData& i, StringBuffer* str) { str->Append("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB, i.VX.VA & 0x7); } -void Disasm_vspltw(InstrData& i, poly::StringBuffer* str) { +void Disasm_vspltw(InstrData& i, StringBuffer* str) { str->Append("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB, i.VX.VA); } -void Disasm_vspltisb(InstrData& i, poly::StringBuffer* str) { +void Disasm_vspltisb(InstrData& i, StringBuffer* str) { // 5bit -> 8bit sign extend int8_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xF0) : i.VX.VA; str->Append("%-8s v%d, %.2X", i.type->name, i.VX.VD, simm); } -void Disasm_vspltish(InstrData& i, poly::StringBuffer* str) { +void Disasm_vspltish(InstrData& i, StringBuffer* str) { // 5bit -> 16bit sign extend int16_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xFFF0) : i.VX.VA; str->Append("%-8s v%d, %.4X", i.type->name, i.VX.VD, simm); } -void Disasm_vspltisw(InstrData& i, poly::StringBuffer* str) { +void Disasm_vspltisw(InstrData& i, StringBuffer* str) { // 5bit -> 32bit sign extend int32_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xFFFFFFF0) : i.VX.VA; str->Append("%-8s v%d, %.8X", i.type->name, i.VX.VD, simm); } -int DisasmPPC(InstrData& i, poly::StringBuffer* str) { +int DisasmPPC(InstrData& i, StringBuffer* str) { if (!i.type) { str->Append("???"); } else { diff --git a/src/xenia/cpu/frontend/ppc_disasm.h b/src/xenia/cpu/frontend/ppc_disasm.h index dfa610d6e..8414068e0 100644 --- a/src/xenia/cpu/frontend/ppc_disasm.h +++ b/src/xenia/cpu/frontend/ppc_disasm.h @@ -10,14 +10,14 @@ #ifndef XENIA_FRONTEND_PPC_DISASM_H_ #define XENIA_FRONTEND_PPC_DISASM_H_ +#include "xenia/base/string_buffer.h" #include "xenia/cpu/frontend/ppc_instr.h" -#include "poly/string_buffer.h" namespace xe { namespace cpu { namespace frontend { -int DisasmPPC(InstrData& i, poly::StringBuffer* str); +int DisasmPPC(InstrData& i, StringBuffer* str); } // namespace frontend } // namespace cpu diff --git a/src/xenia/cpu/frontend/ppc_emit_altivec.cc b/src/xenia/cpu/frontend/ppc_emit_altivec.cc index 9909bc8c2..c309975df 100644 --- a/src/xenia/cpu/frontend/ppc_emit_altivec.cc +++ b/src/xenia/cpu/frontend/ppc_emit_altivec.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/frontend/ppc_emit-private.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/frontend/ppc_context.h" #include "xenia/cpu/frontend/ppc_hir_builder.h" @@ -19,10 +19,6 @@ namespace frontend { // TODO(benvanik): remove when enums redefined. using namespace xe::cpu::hir; -using poly::vec128b; -using poly::vec128f; -using poly::vec128i; -using poly::vec128s; using xe::cpu::hir::Value; diff --git a/src/xenia/cpu/frontend/ppc_emit_alu.cc b/src/xenia/cpu/frontend/ppc_emit_alu.cc index 39e0e6fe1..37506f014 100644 --- a/src/xenia/cpu/frontend/ppc_emit_alu.cc +++ b/src/xenia/cpu/frontend/ppc_emit_alu.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/frontend/ppc_emit-private.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/frontend/ppc_context.h" #include "xenia/cpu/frontend/ppc_hir_builder.h" diff --git a/src/xenia/cpu/frontend/ppc_emit_control.cc b/src/xenia/cpu/frontend/ppc_emit_control.cc index ea508f11c..597acabd5 100644 --- a/src/xenia/cpu/frontend/ppc_emit_control.cc +++ b/src/xenia/cpu/frontend/ppc_emit_control.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/frontend/ppc_emit-private.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/frontend/ppc_context.h" #include "xenia/cpu/frontend/ppc_hir_builder.h" diff --git a/src/xenia/cpu/frontend/ppc_emit_fpu.cc b/src/xenia/cpu/frontend/ppc_emit_fpu.cc index acc2ff41f..dd3342c88 100644 --- a/src/xenia/cpu/frontend/ppc_emit_fpu.cc +++ b/src/xenia/cpu/frontend/ppc_emit_fpu.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/frontend/ppc_emit-private.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/frontend/ppc_context.h" #include "xenia/cpu/frontend/ppc_hir_builder.h" diff --git a/src/xenia/cpu/frontend/ppc_emit_memory.cc b/src/xenia/cpu/frontend/ppc_emit_memory.cc index 660ad795d..cf83bd736 100644 --- a/src/xenia/cpu/frontend/ppc_emit_memory.cc +++ b/src/xenia/cpu/frontend/ppc_emit_memory.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/frontend/ppc_emit-private.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/frontend/ppc_context.h" #include "xenia/cpu/frontend/ppc_hir_builder.h" diff --git a/src/xenia/cpu/frontend/ppc_frontend.h b/src/xenia/cpu/frontend/ppc_frontend.h index c0af243fd..5b2f55b56 100644 --- a/src/xenia/cpu/frontend/ppc_frontend.h +++ b/src/xenia/cpu/frontend/ppc_frontend.h @@ -13,11 +13,11 @@ #include #include -#include "poly/type_pool.h" +#include "xenia/base/type_pool.h" #include "xenia/cpu/frontend/context_info.h" -#include "xenia/memory.h" #include "xenia/cpu/function.h" #include "xenia/cpu/symbol_info.h" +#include "xenia/memory.h" namespace xe { namespace cpu { @@ -58,7 +58,7 @@ class PPCFrontend { Runtime* runtime_; std::unique_ptr context_info_; PPCBuiltins builtins_; - poly::TypePool translator_pool_; + TypePool translator_pool_; }; } // namespace frontend diff --git a/src/xenia/cpu/frontend/ppc_hir_builder.cc b/src/xenia/cpu/frontend/ppc_hir_builder.cc index 2ff761b26..a5ad3339a 100644 --- a/src/xenia/cpu/frontend/ppc_hir_builder.cc +++ b/src/xenia/cpu/frontend/ppc_hir_builder.cc @@ -9,8 +9,9 @@ #include "xenia/cpu/frontend/ppc_hir_builder.h" -#include "poly/byte_order.h" -#include "poly/memory.h" +#include "xenia/base/byte_order.h" +#include "xenia/base/logging.h" +#include "xenia/base/memory.h" #include "xenia/cpu/cpu-private.h" #include "xenia/cpu/frontend/ppc_context.h" #include "xenia/cpu/frontend/ppc_disasm.h" @@ -18,7 +19,6 @@ #include "xenia/cpu/frontend/ppc_instr.h" #include "xenia/cpu/hir/label.h" #include "xenia/cpu/runtime.h" -#include "xenia/logging.h" #include "xenia/profiling.h" namespace xe { @@ -82,7 +82,7 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) { for (uint32_t address = start_address, offset = 0; address <= end_address; address += 4, offset++) { i.address = address; - i.code = poly::load_and_swap(memory->TranslateVirtual(address)); + i.code = xe::load_and_swap(memory->TranslateVirtual(address)); // TODO(benvanik): find a way to avoid using the opcode tables. i.type = GetInstrType(i.code); trace_info_.dest_count = 0; @@ -170,7 +170,7 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) { void PPCHIRBuilder::AnnotateLabel(uint32_t address, Label* label) { char name_buffer[13]; - snprintf(name_buffer, poly::countof(name_buffer), "loc_%.8X", address); + snprintf(name_buffer, xe::countof(name_buffer), "loc_%.8X", address); label->name = (char*)arena_->Alloc(sizeof(name_buffer)); memcpy(label->name, name_buffer, sizeof(name_buffer)); } diff --git a/src/xenia/cpu/frontend/ppc_hir_builder.h b/src/xenia/cpu/frontend/ppc_hir_builder.h index 1b35f5170..b017ee75f 100644 --- a/src/xenia/cpu/frontend/ppc_hir_builder.h +++ b/src/xenia/cpu/frontend/ppc_hir_builder.h @@ -10,10 +10,10 @@ #ifndef XENIA_FRONTEND_PPC_HIR_BUILDER_H_ #define XENIA_FRONTEND_PPC_HIR_BUILDER_H_ +#include "xenia/base/string_buffer.h" #include "xenia/cpu/hir/hir_builder.h" #include "xenia/cpu/function.h" #include "xenia/cpu/symbol_info.h" -#include "poly/string_buffer.h" namespace xe { namespace cpu { @@ -91,7 +91,7 @@ class PPCHIRBuilder : public hir::HIRBuilder { PPCFrontend* frontend_; // Reset whenever needed: - poly::StringBuffer comment_buffer_; + StringBuffer comment_buffer_; // Reset each Emit: bool with_debug_info_; diff --git a/src/xenia/cpu/frontend/ppc_instr.cc b/src/xenia/cpu/frontend/ppc_instr.cc index 6802c91f3..4216784b8 100644 --- a/src/xenia/cpu/frontend/ppc_instr.cc +++ b/src/xenia/cpu/frontend/ppc_instr.cc @@ -12,9 +12,9 @@ #include #include -#include "poly/assert.h" -#include "poly/math.h" -#include "poly/string_buffer.h" +#include "xenia/base/assert.h" +#include "xenia/base/math.h" +#include "xenia/base/string_buffer.h" #include "xenia/cpu/frontend/ppc_instr_tables.h" namespace xe { @@ -24,7 +24,7 @@ namespace frontend { std::vector all_instrs_; void DumpAllInstrCounts() { - poly::StringBuffer sb; + StringBuffer sb; sb.Append("Instruction translation counts:\n"); for (auto instr_type : all_instrs_) { if (instr_type->translation_count) { @@ -42,7 +42,7 @@ void InstrOperand::Dump(std::string& out_str) { } char buffer[32]; - const size_t max_count = poly::countof(buffer); + const size_t max_count = xe::countof(buffer); switch (type) { case InstrOperand::kRegister: switch (reg.set) { @@ -380,7 +380,7 @@ InstrType* GetInstrType(uint32_t code) { // Slow lookup via linear scan. // This is primarily due to laziness. It could be made fast like the others. - for (size_t n = 0; n < poly::countof(tables::instr_table_scan); n++) { + for (size_t n = 0; n < xe::countof(tables::instr_table_scan); n++) { slot = &(tables::instr_table_scan[n]); if (slot->opcode == (code & slot->opcode_mask)) { return slot; diff --git a/src/xenia/cpu/frontend/ppc_instr.h b/src/xenia/cpu/frontend/ppc_instr.h index 865738c5c..0e2d3558c 100644 --- a/src/xenia/cpu/frontend/ppc_instr.h +++ b/src/xenia/cpu/frontend/ppc_instr.h @@ -14,7 +14,7 @@ #include #include -#include "poly/string_buffer.h" +#include "xenia/base/string_buffer.h" namespace xe { namespace cpu { @@ -547,7 +547,7 @@ class InstrDisasm { void Dump(std::string& out_str, size_t pad = 13); }; -typedef void (*InstrDisasmFn)(InstrData& i, poly::StringBuffer* str); +typedef void (*InstrDisasmFn)(InstrData& i, StringBuffer* str); typedef void* InstrEmitFn; class InstrType { diff --git a/src/xenia/cpu/frontend/ppc_instr_tables.h b/src/xenia/cpu/frontend/ppc_instr_tables.h index b054ea072..6ddae920d 100644 --- a/src/xenia/cpu/frontend/ppc_instr_tables.h +++ b/src/xenia/cpu/frontend/ppc_instr_tables.h @@ -12,84 +12,84 @@ #include -#include "poly/math.h" -#include "poly/string_buffer.h" +#include "xenia/base/math.h" +#include "xenia/base/string_buffer.h" #include "xenia/cpu/frontend/ppc_instr.h" namespace xe { namespace cpu { namespace frontend { -void Disasm_0(InstrData& i, poly::StringBuffer* str); -void Disasm__(InstrData& i, poly::StringBuffer* str); -void Disasm_X_FRT_FRB(InstrData& i, poly::StringBuffer* str); -void Disasm_A_FRT_FRB(InstrData& i, poly::StringBuffer* str); -void Disasm_A_FRT_FRA_FRB(InstrData& i, poly::StringBuffer* str); -void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, poly::StringBuffer* str); -void Disasm_X_RT_RA_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_X_RT_RA0_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_X_FRT_RA_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_X_FRT_RA0_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_D_RT_RA_I(InstrData& i, poly::StringBuffer* str); -void Disasm_D_RT_RA0_I(InstrData& i, poly::StringBuffer* str); -void Disasm_D_FRT_RA_I(InstrData& i, poly::StringBuffer* str); -void Disasm_D_FRT_RA0_I(InstrData& i, poly::StringBuffer* str); -void Disasm_DS_RT_RA_I(InstrData& i, poly::StringBuffer* str); -void Disasm_DS_RT_RA0_I(InstrData& i, poly::StringBuffer* str); -void Disasm_D_RA(InstrData& i, poly::StringBuffer* str); -void Disasm_X_RA_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_XO_RT_RA_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_XO_RT_RA(InstrData& i, poly::StringBuffer* str); -void Disasm_X_RA_RT_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_D_RA_RT_I(InstrData& i, poly::StringBuffer* str); -void Disasm_X_RA_RT(InstrData& i, poly::StringBuffer* str); -void Disasm_X_VX_RA0_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_VX1281_VD_RA0_RB(InstrData& i, poly::StringBuffer* str); -void Disasm_VX1283_VD_VB(InstrData& i, poly::StringBuffer* str); -void Disasm_VX1283_VD_VB_I(InstrData& i, poly::StringBuffer* str); -void Disasm_VX_VD_VA_VB(InstrData& i, poly::StringBuffer* str); -void Disasm_VX128_VD_VA_VB(InstrData& i, poly::StringBuffer* str); -void Disasm_VX128_VD_VA_VD_VB(InstrData& i, poly::StringBuffer* str); -void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, poly::StringBuffer* str); -void Disasm_VXA_VD_VA_VB_VC(InstrData& i, poly::StringBuffer* str); +void Disasm_0(InstrData& i, StringBuffer* str); +void Disasm__(InstrData& i, StringBuffer* str); +void Disasm_X_FRT_FRB(InstrData& i, StringBuffer* str); +void Disasm_A_FRT_FRB(InstrData& i, StringBuffer* str); +void Disasm_A_FRT_FRA_FRB(InstrData& i, StringBuffer* str); +void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, StringBuffer* str); +void Disasm_X_RT_RA_RB(InstrData& i, StringBuffer* str); +void Disasm_X_RT_RA0_RB(InstrData& i, StringBuffer* str); +void Disasm_X_FRT_RA_RB(InstrData& i, StringBuffer* str); +void Disasm_X_FRT_RA0_RB(InstrData& i, StringBuffer* str); +void Disasm_D_RT_RA_I(InstrData& i, StringBuffer* str); +void Disasm_D_RT_RA0_I(InstrData& i, StringBuffer* str); +void Disasm_D_FRT_RA_I(InstrData& i, StringBuffer* str); +void Disasm_D_FRT_RA0_I(InstrData& i, StringBuffer* str); +void Disasm_DS_RT_RA_I(InstrData& i, StringBuffer* str); +void Disasm_DS_RT_RA0_I(InstrData& i, StringBuffer* str); +void Disasm_D_RA(InstrData& i, StringBuffer* str); +void Disasm_X_RA_RB(InstrData& i, StringBuffer* str); +void Disasm_XO_RT_RA_RB(InstrData& i, StringBuffer* str); +void Disasm_XO_RT_RA(InstrData& i, StringBuffer* str); +void Disasm_X_RA_RT_RB(InstrData& i, StringBuffer* str); +void Disasm_D_RA_RT_I(InstrData& i, StringBuffer* str); +void Disasm_X_RA_RT(InstrData& i, StringBuffer* str); +void Disasm_X_VX_RA0_RB(InstrData& i, StringBuffer* str); +void Disasm_VX1281_VD_RA0_RB(InstrData& i, StringBuffer* str); +void Disasm_VX1283_VD_VB(InstrData& i, StringBuffer* str); +void Disasm_VX1283_VD_VB_I(InstrData& i, StringBuffer* str); +void Disasm_VX_VD_VA_VB(InstrData& i, StringBuffer* str); +void Disasm_VX128_VD_VA_VB(InstrData& i, StringBuffer* str); +void Disasm_VX128_VD_VA_VD_VB(InstrData& i, StringBuffer* str); +void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, StringBuffer* str); +void Disasm_VXA_VD_VA_VB_VC(InstrData& i, StringBuffer* str); -void Disasm_sync(InstrData& i, poly::StringBuffer* str); -void Disasm_dcbf(InstrData& i, poly::StringBuffer* str); -void Disasm_dcbz(InstrData& i, poly::StringBuffer* str); -void Disasm_fcmp(InstrData& i, poly::StringBuffer* str); +void Disasm_sync(InstrData& i, StringBuffer* str); +void Disasm_dcbf(InstrData& i, StringBuffer* str); +void Disasm_dcbz(InstrData& i, StringBuffer* str); +void Disasm_fcmp(InstrData& i, StringBuffer* str); -void Disasm_bx(InstrData& i, poly::StringBuffer* str); -void Disasm_bcx(InstrData& i, poly::StringBuffer* str); -void Disasm_bcctrx(InstrData& i, poly::StringBuffer* str); -void Disasm_bclrx(InstrData& i, poly::StringBuffer* str); +void Disasm_bx(InstrData& i, StringBuffer* str); +void Disasm_bcx(InstrData& i, StringBuffer* str); +void Disasm_bcctrx(InstrData& i, StringBuffer* str); +void Disasm_bclrx(InstrData& i, StringBuffer* str); -void Disasm_mfcr(InstrData& i, poly::StringBuffer* str); -void Disasm_mfspr(InstrData& i, poly::StringBuffer* str); -void Disasm_mtspr(InstrData& i, poly::StringBuffer* str); -void Disasm_mftb(InstrData& i, poly::StringBuffer* str); -void Disasm_mfmsr(InstrData& i, poly::StringBuffer* str); -void Disasm_mtmsr(InstrData& i, poly::StringBuffer* str); +void Disasm_mfcr(InstrData& i, StringBuffer* str); +void Disasm_mfspr(InstrData& i, StringBuffer* str); +void Disasm_mtspr(InstrData& i, StringBuffer* str); +void Disasm_mftb(InstrData& i, StringBuffer* str); +void Disasm_mfmsr(InstrData& i, StringBuffer* str); +void Disasm_mtmsr(InstrData& i, StringBuffer* str); -void Disasm_cmp(InstrData& i, poly::StringBuffer* str); -void Disasm_cmpi(InstrData& i, poly::StringBuffer* str); -void Disasm_cmpli(InstrData& i, poly::StringBuffer* str); +void Disasm_cmp(InstrData& i, StringBuffer* str); +void Disasm_cmpi(InstrData& i, StringBuffer* str); +void Disasm_cmpli(InstrData& i, StringBuffer* str); -void Disasm_rld(InstrData& i, poly::StringBuffer* str); -void Disasm_rlwim(InstrData& i, poly::StringBuffer* str); -void Disasm_rlwnmx(InstrData& i, poly::StringBuffer* str); -void Disasm_srawix(InstrData& i, poly::StringBuffer* str); -void Disasm_sradix(InstrData& i, poly::StringBuffer* str); +void Disasm_rld(InstrData& i, StringBuffer* str); +void Disasm_rlwim(InstrData& i, StringBuffer* str); +void Disasm_rlwnmx(InstrData& i, StringBuffer* str); +void Disasm_srawix(InstrData& i, StringBuffer* str); +void Disasm_sradix(InstrData& i, StringBuffer* str); -void Disasm_vpermwi128(InstrData& i, poly::StringBuffer* str); -void Disasm_vrfin128(InstrData& i, poly::StringBuffer* str); -void Disasm_vrlimi128(InstrData& i, poly::StringBuffer* str); -void Disasm_vsldoi128(InstrData& i, poly::StringBuffer* str); -void Disasm_vspltb(InstrData& i, poly::StringBuffer* str); -void Disasm_vsplth(InstrData& i, poly::StringBuffer* str); -void Disasm_vspltw(InstrData& i, poly::StringBuffer* str); -void Disasm_vspltisb(InstrData& i, poly::StringBuffer* str); -void Disasm_vspltish(InstrData& i, poly::StringBuffer* str); -void Disasm_vspltisw(InstrData& i, poly::StringBuffer* str); +void Disasm_vpermwi128(InstrData& i, StringBuffer* str); +void Disasm_vrfin128(InstrData& i, StringBuffer* str); +void Disasm_vrlimi128(InstrData& i, StringBuffer* str); +void Disasm_vsldoi128(InstrData& i, StringBuffer* str); +void Disasm_vspltb(InstrData& i, StringBuffer* str); +void Disasm_vsplth(InstrData& i, StringBuffer* str); +void Disasm_vspltw(InstrData& i, StringBuffer* str); +void Disasm_vspltisb(InstrData& i, StringBuffer* str); +void Disasm_vspltish(InstrData& i, StringBuffer* str); +void Disasm_vspltisw(InstrData& i, StringBuffer* str); namespace tables { @@ -364,7 +364,7 @@ static InstrType instr_table_4_unprep[] = { "Vector Logical XOR"), }; static InstrType** instr_table_4 = instr_table_prep( - instr_table_4_unprep, poly::countof(instr_table_4_unprep), 0, 11); + instr_table_4_unprep, xe::countof(instr_table_4_unprep), 0, 11); // Opcode = 19, index = bits 10-1 (10) static InstrType instr_table_19_unprep[] = { @@ -384,7 +384,7 @@ static InstrType instr_table_19_unprep[] = { "Branch Conditional to Count Register"), }; static InstrType** instr_table_19 = instr_table_prep( - instr_table_19_unprep, poly::countof(instr_table_19_unprep), 1, 10); + instr_table_19_unprep, xe::countof(instr_table_19_unprep), 1, 10); // Opcode = 30, index = bits 4-1 (4) static InstrType instr_table_30_unprep[] = { @@ -400,7 +400,7 @@ static InstrType instr_table_30_unprep[] = { // INSTRUCTION(rldcrx, 0x78000012, MDS, General , 0), }; static InstrType** instr_table_30 = instr_table_prep( - instr_table_30_unprep, poly::countof(instr_table_30_unprep), 0, 0); + instr_table_30_unprep, xe::countof(instr_table_30_unprep), 0, 0); // Opcode = 31, index = bits 10-1 (10) static InstrType instr_table_31_unprep[] = { @@ -651,7 +651,7 @@ static InstrType instr_table_31_unprep[] = { "Store Vector Right Indexed LRU"), }; static InstrType** instr_table_31 = instr_table_prep( - instr_table_31_unprep, poly::countof(instr_table_31_unprep), 1, 10); + instr_table_31_unprep, xe::countof(instr_table_31_unprep), 1, 10); // Opcode = 58, index = bits 1-0 (2) static InstrType instr_table_58_unprep[] = { @@ -662,7 +662,7 @@ static InstrType instr_table_58_unprep[] = { "Load Word Algebraic"), }; static InstrType** instr_table_58 = instr_table_prep( - instr_table_58_unprep, poly::countof(instr_table_58_unprep), 0, 1); + instr_table_58_unprep, xe::countof(instr_table_58_unprep), 0, 1); // Opcode = 59, index = bits 5-1 (5) static InstrType instr_table_59_unprep[] = { @@ -688,7 +688,7 @@ static InstrType instr_table_59_unprep[] = { "Floating Negative Multiply-Add [Single]"), }; static InstrType** instr_table_59 = instr_table_prep( - instr_table_59_unprep, poly::countof(instr_table_59_unprep), 1, 5); + instr_table_59_unprep, xe::countof(instr_table_59_unprep), 1, 5); // Opcode = 62, index = bits 1-0 (2) static InstrType instr_table_62_unprep[] = { @@ -697,7 +697,7 @@ static InstrType instr_table_62_unprep[] = { "Store Doubleword with Update"), }; static InstrType** instr_table_62 = instr_table_prep( - instr_table_62_unprep, poly::countof(instr_table_62_unprep), 0, 1); + instr_table_62_unprep, xe::countof(instr_table_62_unprep), 0, 1); // Opcode = 63, index = bits 10-1 (10) // NOTE: the A format instructions need some special handling because @@ -757,7 +757,7 @@ static InstrType instr_table_63_unprep[] = { "Floating Convert From Integer Doubleword"), }; static InstrType** instr_table_63 = instr_table_prep_63( - instr_table_63_unprep, poly::countof(instr_table_63_unprep), 1, 10); + instr_table_63_unprep, xe::countof(instr_table_63_unprep), 1, 10); // Main table, index = bits 31-26 (6) : (code >> 26) static InstrType instr_table_unprep[64] = { @@ -837,7 +837,7 @@ static InstrType instr_table_unprep[64] = { "Store Floating-Point Double with Update"), }; static InstrType** instr_table = instr_table_prep( - instr_table_unprep, poly::countof(instr_table_unprep), 26, 31); + instr_table_unprep, xe::countof(instr_table_unprep), 26, 31); // Altivec instructions. // TODO(benvanik): build a table like the other instructions. diff --git a/src/xenia/cpu/frontend/ppc_scanner.cc b/src/xenia/cpu/frontend/ppc_scanner.cc index ba5d1a02c..38943def8 100644 --- a/src/xenia/cpu/frontend/ppc_scanner.cc +++ b/src/xenia/cpu/frontend/ppc_scanner.cc @@ -12,11 +12,11 @@ #include #include -#include "poly/memory.h" +#include "xenia/base/logging.h" +#include "xenia/base/memory.h" #include "xenia/cpu/frontend/ppc_frontend.h" #include "xenia/cpu/frontend/ppc_instr.h" #include "xenia/cpu/runtime.h" -#include "xenia/logging.h" #include "xenia/profiling.h" #if 0 @@ -63,7 +63,7 @@ int PPCScanner::FindExtents(FunctionInfo* symbol_info) { InstrData i; while (true) { i.address = address; - i.code = poly::load_and_swap(memory->TranslateVirtual(address)); + i.code = xe::load_and_swap(memory->TranslateVirtual(address)); // If we fetched 0 assume that we somehow hit one of the awesome // 'no really we meant to end after that bl' functions. @@ -290,7 +290,7 @@ std::vector PPCScanner::FindBlocks(FunctionInfo* symbol_info) { InstrData i; for (uint32_t address = start_address; address <= end_address; address += 4) { i.address = address; - i.code = poly::load_and_swap(memory->TranslateVirtual(address)); + i.code = xe::load_and_swap(memory->TranslateVirtual(address)); if (!i.code) { continue; } diff --git a/src/xenia/cpu/frontend/ppc_translator.cc b/src/xenia/cpu/frontend/ppc_translator.cc index 588b4629f..b5e4512f8 100644 --- a/src/xenia/cpu/frontend/ppc_translator.cc +++ b/src/xenia/cpu/frontend/ppc_translator.cc @@ -9,10 +9,10 @@ #include "xenia/cpu/frontend/ppc_translator.h" -#include "poly/assert.h" -#include "poly/byte_order.h" -#include "poly/memory.h" -#include "poly/reset_scope.h" +#include "xenia/base/assert.h" +#include "xenia/base/byte_order.h" +#include "xenia/base/memory.h" +#include "xenia/base/reset_scope.h" #include "xenia/cpu/compiler/compiler_passes.h" #include "xenia/cpu/cpu-private.h" #include "xenia/cpu/frontend/ppc_disasm.h" @@ -92,10 +92,10 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info, SCOPE_profile_cpu_f("cpu"); // Reset() all caching when we leave. - poly::make_reset_scope(builder_); - poly::make_reset_scope(compiler_); - poly::make_reset_scope(assembler_); - poly::make_reset_scope(&string_buffer_); + xe::make_reset_scope(builder_); + xe::make_reset_scope(compiler_); + xe::make_reset_scope(assembler_); + xe::make_reset_scope(&string_buffer_); // Scan the function to find its extents. We only need to do this if we // haven't already been provided with them from some other source. @@ -176,7 +176,7 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info, }; void PPCTranslator::DumpSource(FunctionInfo* symbol_info, - poly::StringBuffer* string_buffer) { + StringBuffer* string_buffer) { Memory* memory = frontend_->memory(); string_buffer->Append("%s fn %.8X-%.8X %s\n", @@ -193,7 +193,7 @@ void PPCTranslator::DumpSource(FunctionInfo* symbol_info, for (uint32_t address = start_address, offset = 0; address <= end_address; address += 4, offset++) { i.address = address; - i.code = poly::load_and_swap(memory->TranslateVirtual(address)); + i.code = xe::load_and_swap(memory->TranslateVirtual(address)); // TODO(benvanik): find a way to avoid using the opcode tables. i.type = GetInstrType(i.code); diff --git a/src/xenia/cpu/frontend/ppc_translator.h b/src/xenia/cpu/frontend/ppc_translator.h index db6ae5f75..87aa85c7b 100644 --- a/src/xenia/cpu/frontend/ppc_translator.h +++ b/src/xenia/cpu/frontend/ppc_translator.h @@ -12,10 +12,10 @@ #include +#include "xenia/base/string_buffer.h" #include "xenia/cpu/backend/assembler.h" #include "xenia/cpu/compiler/compiler.h" #include "xenia/cpu/symbol_info.h" -#include "poly/string_buffer.h" namespace xe { namespace cpu { @@ -34,7 +34,7 @@ class PPCTranslator { uint32_t trace_flags, Function** out_function); private: - void DumpSource(FunctionInfo* symbol_info, poly::StringBuffer* string_buffer); + void DumpSource(FunctionInfo* symbol_info, StringBuffer* string_buffer); private: PPCFrontend* frontend_; @@ -43,7 +43,7 @@ class PPCTranslator { std::unique_ptr compiler_; std::unique_ptr assembler_; - poly::StringBuffer string_buffer_; + StringBuffer string_buffer_; }; } // namespace frontend diff --git a/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc b/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc index 22fbde9e7..c9f0d19e6 100644 --- a/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc +++ b/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc @@ -7,14 +7,14 @@ ****************************************************************************** */ -#include "poly/main.h" -#include "poly/math.h" +#include "xenia/base/logging.h" +#include "xenia/base/main.h" +#include "xenia/base/math.h" #include "xenia/cpu/cpu.h" #include "xenia/cpu/backend/x64/x64_backend.h" #include "xenia/cpu/frontend/ppc_context.h" #include "xenia/cpu/frontend/ppc_frontend.h" #include "xenia/cpu/raw_module.h" -#include "xenia/logging.h" #if !XE_PLATFORM_WIN32 #include @@ -48,11 +48,11 @@ struct TestCase { class TestSuite { public: TestSuite(const std::wstring& src_file_path) : src_file_path(src_file_path) { - name = src_file_path.substr( - src_file_path.find_last_of(poly::path_separator) + 1); + name = src_file_path.substr(src_file_path.find_last_of(xe::path_separator) + + 1); name = ReplaceExtension(name, L""); - map_file_path = poly::to_wstring(FLAGS_test_bin_path) + name + L".map"; - bin_file_path = poly::to_wstring(FLAGS_test_bin_path) + name + L".bin"; + map_file_path = xe::to_wstring(FLAGS_test_bin_path) + name + L".map"; + bin_file_path = xe::to_wstring(FLAGS_test_bin_path) + name + L".bin"; } bool Load() { @@ -92,7 +92,7 @@ class TestSuite { } bool ReadMap(const std::wstring& map_file_path) { - FILE* f = fopen(poly::to_string(map_file_path).c_str(), "r"); + FILE* f = fopen(xe::to_string(map_file_path).c_str(), "r"); if (!f) { return false; } @@ -120,7 +120,7 @@ class TestSuite { bool ReadAnnotations(const std::wstring& src_file_path) { TestCase* current_test_case = nullptr; - FILE* f = fopen(poly::to_string(src_file_path).c_str(), "r"); + FILE* f = fopen(xe::to_string(src_file_path).c_str(), "r"); if (!f) { return false; } @@ -273,7 +273,7 @@ class TestRunner { auto reg_value = it.second.substr(space_pos + 1); if (!ppc_state->CompareRegWithString(reg_name.c_str(), reg_value.c_str(), actual_value, - poly::countof(actual_value))) { + xe::countof(actual_value))) { any_failed = true; printf("Register %s assert failed:\n", reg_name.c_str()); printf(" Expected: %s == %s\n", reg_name.c_str(), reg_value.c_str()); @@ -373,7 +373,7 @@ bool RunTests(const std::wstring& test_name) { int passed_count = 0; auto test_path_root = - poly::fix_path_separators(poly::to_wstring(FLAGS_test_path)); + xe::fix_path_separators(xe::to_wstring(FLAGS_test_path)); std::vector test_files; if (!DiscoverTests(test_path_root, test_files)) { return false; diff --git a/src/xenia/cpu/function.cc b/src/xenia/cpu/function.cc index 23513d13c..ed49b96df 100644 --- a/src/xenia/cpu/function.cc +++ b/src/xenia/cpu/function.cc @@ -10,10 +10,10 @@ #include "xenia/cpu/function.h" #include "xdb/protocol.h" +#include "xenia/base/logging.h" #include "xenia/cpu/debugger.h" #include "xenia/cpu/symbol_info.h" #include "xenia/cpu/thread_state.h" -#include "xenia/logging.h" namespace xe { namespace cpu { diff --git a/src/xenia/cpu/hir/block.cc b/src/xenia/cpu/hir/block.cc index 14f612cb0..9a0222b76 100644 --- a/src/xenia/cpu/hir/block.cc +++ b/src/xenia/cpu/hir/block.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/hir/block.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/hir/instr.h" namespace xe { diff --git a/src/xenia/cpu/hir/block.h b/src/xenia/cpu/hir/block.h index dcd745600..83feb7f2a 100644 --- a/src/xenia/cpu/hir/block.h +++ b/src/xenia/cpu/hir/block.h @@ -10,7 +10,7 @@ #ifndef XENIA_HIR_BLOCK_H_ #define XENIA_HIR_BLOCK_H_ -#include "poly/arena.h" +#include "xenia/base/arena.h" namespace llvm { class BitVector; @@ -46,7 +46,7 @@ class Edge { class Block { public: - poly::Arena* arena; + Arena* arena; Block* next; Block* prev; diff --git a/src/xenia/cpu/hir/hir_builder.cc b/src/xenia/cpu/hir/hir_builder.cc index dc063fa8c..121d1476b 100644 --- a/src/xenia/cpu/hir/hir_builder.cc +++ b/src/xenia/cpu/hir/hir_builder.cc @@ -9,7 +9,7 @@ #include "xenia/cpu/hir/hir_builder.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/cpu/hir/block.h" #include "xenia/cpu/hir/instr.h" #include "xenia/cpu/hir/label.h" @@ -29,7 +29,7 @@ namespace hir { assert_true((value1->type) == (value2->type)) HIRBuilder::HIRBuilder() { - arena_ = new poly::Arena(); + arena_ = new Arena(); Reset(); } @@ -87,7 +87,7 @@ int HIRBuilder::Finalize() { return 0; } -void HIRBuilder::DumpValue(poly::StringBuffer* str, Value* value) { +void HIRBuilder::DumpValue(StringBuffer* str, Value* value) { if (value->IsConstant()) { switch (value->type) { case INT8_TYPE: @@ -128,7 +128,7 @@ void HIRBuilder::DumpValue(poly::StringBuffer* str, Value* value) { } } -void HIRBuilder::DumpOp(poly::StringBuffer* str, OpcodeSignatureType sig_type, +void HIRBuilder::DumpOp(StringBuffer* str, OpcodeSignatureType sig_type, Instr::Op* op) { switch (sig_type) { case OPCODE_SIG_TYPE_X: @@ -155,7 +155,7 @@ void HIRBuilder::DumpOp(poly::StringBuffer* str, OpcodeSignatureType sig_type, } } -void HIRBuilder::Dump(poly::StringBuffer* str) { +void HIRBuilder::Dump(StringBuffer* str) { if (attributes_) { str->Append("; attributes = %.8X\n", attributes_); } diff --git a/src/xenia/cpu/hir/hir_builder.h b/src/xenia/cpu/hir/hir_builder.h index e9e0ed3ae..085860160 100644 --- a/src/xenia/cpu/hir/hir_builder.h +++ b/src/xenia/cpu/hir/hir_builder.h @@ -12,13 +12,13 @@ #include +#include "xenia/base/arena.h" +#include "xenia/base/string_buffer.h" #include "xenia/cpu/hir/block.h" #include "xenia/cpu/hir/instr.h" #include "xenia/cpu/hir/label.h" #include "xenia/cpu/hir/opcodes.h" #include "xenia/cpu/hir/value.h" -#include "poly/arena.h" -#include "poly/string_buffer.h" namespace xe { namespace cpu { @@ -36,10 +36,10 @@ class HIRBuilder { virtual void Reset(); virtual int Finalize(); - void Dump(poly::StringBuffer* str); + void Dump(StringBuffer* str); void AssertNoCycles(); - poly::Arena* arena() const { return arena_; } + Arena* arena() const { return arena_; } uint32_t attributes() const { return attributes_; } void set_attributes(uint32_t value) { attributes_ = value; } @@ -229,9 +229,8 @@ class HIRBuilder { Value* AtomicSub(Value* address, Value* value); protected: - void DumpValue(poly::StringBuffer* str, Value* value); - void DumpOp(poly::StringBuffer* str, OpcodeSignatureType sig_type, - Instr::Op* op); + void DumpValue(StringBuffer* str, Value* value); + void DumpOp(StringBuffer* str, OpcodeSignatureType sig_type, Instr::Op* op); Value* AllocValue(TypeName type = INT64_TYPE); Value* CloneValue(Value* source); @@ -246,7 +245,7 @@ class HIRBuilder { TypeName part_type); protected: - poly::Arena* arena_; + Arena* arena_; uint32_t attributes_; diff --git a/src/xenia/cpu/hir/value.cc b/src/xenia/cpu/hir/value.cc index cf2db6f6d..7a70f1201 100644 --- a/src/xenia/cpu/hir/value.cc +++ b/src/xenia/cpu/hir/value.cc @@ -11,15 +11,15 @@ #include -#include "poly/assert.h" -#include "poly/byte_order.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/byte_order.h" +#include "xenia/base/math.h" namespace xe { namespace cpu { namespace hir { -Value::Use* Value::AddUse(poly::Arena* arena, Instr* instr) { +Value::Use* Value::AddUse(Arena* arena, Instr* instr) { Use* use = arena->Alloc(); use->instr = instr; use->prev = NULL; @@ -587,17 +587,17 @@ void Value::ByteSwap() { constant.i8 = constant.i8; break; case INT16_TYPE: - constant.i16 = poly::byte_swap(constant.i16); + constant.i16 = xe::byte_swap(constant.i16); break; case INT32_TYPE: - constant.i32 = poly::byte_swap(constant.i32); + constant.i32 = xe::byte_swap(constant.i32); break; case INT64_TYPE: - constant.i64 = poly::byte_swap(constant.i64); + constant.i64 = xe::byte_swap(constant.i64); break; case VEC128_TYPE: for (int n = 0; n < 4; n++) { - constant.v128.u32[n] = poly::byte_swap(constant.v128.u32[n]); + constant.v128.u32[n] = xe::byte_swap(constant.v128.u32[n]); } break; default: @@ -609,16 +609,16 @@ void Value::ByteSwap() { void Value::CountLeadingZeros(const Value* other) { switch (other->type) { case INT8_TYPE: - constant.i8 = poly::lzcnt(constant.i8); + constant.i8 = xe::lzcnt(constant.i8); break; case INT16_TYPE: - constant.i8 = poly::lzcnt(constant.i16); + constant.i8 = xe::lzcnt(constant.i16); break; case INT32_TYPE: - constant.i8 = poly::lzcnt(constant.i32); + constant.i8 = xe::lzcnt(constant.i32); break; case INT64_TYPE: - constant.i8 = poly::lzcnt(constant.i64); + constant.i8 = xe::lzcnt(constant.i64); break; default: assert_unhandled_case(type); diff --git a/src/xenia/cpu/hir/value.h b/src/xenia/cpu/hir/value.h index 9a2b93300..c9be576fc 100644 --- a/src/xenia/cpu/hir/value.h +++ b/src/xenia/cpu/hir/value.h @@ -10,9 +10,9 @@ #ifndef XENIA_HIR_VALUE_H_ #define XENIA_HIR_VALUE_H_ -#include "poly/arena.h" -#include "poly/assert.h" -#include "poly/vec128.h" +#include "xenia/base/arena.h" +#include "xenia/base/assert.h" +#include "xenia/base/vec128.h" #include "xenia/cpu/backend/machine_info.h" #include "xenia/cpu/hir/opcodes.h" @@ -22,7 +22,7 @@ namespace hir { class Instr; -using vec128_t = poly::vec128_t; +using vec128_t = xe::vec128_t; enum TypeName { // Many tables rely on this ordering. @@ -102,7 +102,7 @@ class Value { // TODO(benvanik): remove to shrink size. void* tag; - Use* AddUse(poly::Arena* arena, Instr* instr); + Use* AddUse(Arena* arena, Instr* instr); void RemoveUse(Use* use); int8_t get_constant(int8_t) const { return constant.i8; } diff --git a/src/xenia/cpu/mmio_handler.cc b/src/xenia/cpu/mmio_handler.cc index dde7b0586..c9f17eaca 100644 --- a/src/xenia/cpu/mmio_handler.cc +++ b/src/xenia/cpu/mmio_handler.cc @@ -9,9 +9,9 @@ #include "xenia/cpu/mmio_handler.h" -#include "poly/assert.h" -#include "poly/byte_order.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/byte_order.h" +#include "xenia/base/math.h" namespace BE { #include @@ -230,7 +230,7 @@ bool MMIOHandler::HandleAccessFault(void* thread_state, // register. uint64_t value = range->read(range->context, fault_address & 0xFFFFFFFF); uint32_t be_reg_index; - if (!poly::bit_scan_forward(arg1_type & 0xFFFF, &be_reg_index)) { + if (!xe::bit_scan_forward(arg1_type & 0xFFFF, &be_reg_index)) { be_reg_index = 0; } uint64_t* reg_ptr = GetThreadStateRegPtr(thread_state, be_reg_index); @@ -239,13 +239,13 @@ bool MMIOHandler::HandleAccessFault(void* thread_state, *reg_ptr = static_cast(value); break; case 16: - *reg_ptr = poly::byte_swap(static_cast(value)); + *reg_ptr = xe::byte_swap(static_cast(value)); break; case 32: - *reg_ptr = poly::byte_swap(static_cast(value)); + *reg_ptr = xe::byte_swap(static_cast(value)); break; case 64: - *reg_ptr = poly::byte_swap(static_cast(value)); + *reg_ptr = xe::byte_swap(static_cast(value)); break; } } else if (is_store) { @@ -253,7 +253,7 @@ bool MMIOHandler::HandleAccessFault(void* thread_state, uint64_t value; if ((arg2_type & BE::REGISTER_TYPE) == BE::REGISTER_TYPE) { uint32_t be_reg_index; - if (!poly::bit_scan_forward(arg2_type & 0xFFFF, &be_reg_index)) { + if (!xe::bit_scan_forward(arg2_type & 0xFFFF, &be_reg_index)) { be_reg_index = 0; } uint64_t* reg_ptr = GetThreadStateRegPtr(thread_state, be_reg_index); @@ -269,13 +269,13 @@ bool MMIOHandler::HandleAccessFault(void* thread_state, value = static_cast(value); break; case 16: - value = poly::byte_swap(static_cast(value)); + value = xe::byte_swap(static_cast(value)); break; case 32: - value = poly::byte_swap(static_cast(value)); + value = xe::byte_swap(static_cast(value)); break; case 64: - value = poly::byte_swap(static_cast(value)); + value = xe::byte_swap(static_cast(value)); break; } range->write(range->context, fault_address & 0xFFFFFFFF, value); diff --git a/src/xenia/cpu/mmio_handler_mac.cc b/src/xenia/cpu/mmio_handler_mac.cc index e892add3f..5f701eded 100644 --- a/src/xenia/cpu/mmio_handler_mac.cc +++ b/src/xenia/cpu/mmio_handler_mac.cc @@ -14,7 +14,7 @@ #include -#include "xenia/logging.h" +#include "xenia/base/logging.h" // Mach internal function, not defined in any header. // http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/exc_server.html @@ -117,7 +117,7 @@ void MachMMIOHandler::ThreadEntry() { listen_port_, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (ret != MACH_MSG_SUCCESS) { XELOGE("mach_msg receive failed with %d %s", ret, mach_error_string(ret)); - poly::debugging::Break(); + xe::debugging::Break(); break; } @@ -129,7 +129,7 @@ void MachMMIOHandler::ThreadEntry() { MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL) != MACH_MSG_SUCCESS) { XELOGE("mach_msg reply send failed"); - poly::debugging::Break(); + xe::debugging::Break(); break; } } @@ -168,7 +168,7 @@ kern_return_t CatchExceptionRaise(mach_port_t thread) { XELOGE("MMIO unhandled bad access for %llx, bubbling", fault_address); // TODO(benvanik): manipulate stack so that we can rip = break_handler or // something and have the stack trace be valid. - poly::debugging::Break(); + xe::debugging::Break(); // When the thread resumes, kill it. thread_state.__rip = reinterpret_cast(FailBadAccess); diff --git a/src/xenia/cpu/module.cc b/src/xenia/cpu/module.cc index 9faf69a31..a7b483f86 100644 --- a/src/xenia/cpu/module.cc +++ b/src/xenia/cpu/module.cc @@ -12,7 +12,7 @@ #include #include -#include "poly/threading.h" +#include "xenia/base/threading.h" #include "xenia/cpu/runtime.h" #include "xenia/profiling.h" @@ -37,7 +37,7 @@ SymbolInfo* Module::LookupSymbol(uint32_t address, bool wait) { do { lock_.unlock(); // TODO(benvanik): sleep for less time? - poly::threading::Sleep(std::chrono::microseconds(100)); + xe::threading::Sleep(std::chrono::microseconds(100)); lock_.lock(); } while (symbol_info->status() == SymbolInfo::STATUS_DECLARING); } else { @@ -70,7 +70,7 @@ SymbolInfo::Status Module::DeclareSymbol(SymbolInfo::Type type, do { lock_.unlock(); // TODO(benvanik): sleep for less time? - poly::threading::Sleep(std::chrono::microseconds(100)); + xe::threading::Sleep(std::chrono::microseconds(100)); lock_.lock(); } while (symbol_info->status() == SymbolInfo::STATUS_DECLARING); } @@ -130,7 +130,7 @@ SymbolInfo::Status Module::DefineSymbol(SymbolInfo* symbol_info) { do { lock_.unlock(); // TODO(benvanik): sleep for less time? - poly::threading::Sleep(std::chrono::microseconds(100)); + xe::threading::Sleep(std::chrono::microseconds(100)); lock_.lock(); } while (symbol_info->status() == SymbolInfo::STATUS_DEFINING); status = symbol_info->status(); diff --git a/src/xenia/cpu/processor.cc b/src/xenia/cpu/processor.cc index e77e63c3b..79444dcc1 100644 --- a/src/xenia/cpu/processor.cc +++ b/src/xenia/cpu/processor.cc @@ -9,14 +9,14 @@ #include "xenia/cpu/processor.h" -#include "poly/atomic.h" -#include "poly/byte_order.h" -#include "poly/memory.h" +#include "xenia/base/atomic.h" +#include "xenia/base/byte_order.h" +#include "xenia/base/logging.h" +#include "xenia/base/memory.h" #include "xenia/cpu/cpu-private.h" #include "xenia/cpu/export_resolver.h" #include "xenia/cpu/runtime.h" #include "xenia/cpu/xex_module.h" -#include "xenia/logging.h" #include "xenia/profiling.h" namespace xe { @@ -151,13 +151,13 @@ uint64_t Processor::Execute(ThreadState* thread_state, uint32_t address, Irql Processor::RaiseIrql(Irql new_value) { return static_cast( - poly::atomic_exchange(static_cast(new_value), - reinterpret_cast(&irql_))); + xe::atomic_exchange(static_cast(new_value), + reinterpret_cast(&irql_))); } void Processor::LowerIrql(Irql old_value) { - poly::atomic_exchange(static_cast(old_value), - reinterpret_cast(&irql_)); + xe::atomic_exchange(static_cast(old_value), + reinterpret_cast(&irql_)); } uint64_t Processor::ExecuteInterrupt(uint32_t cpu, uint32_t address, @@ -168,7 +168,7 @@ uint64_t Processor::ExecuteInterrupt(uint32_t cpu, uint32_t address, std::lock_guard lock(interrupt_thread_lock_); // Set 0x10C(r13) to the current CPU ID. - poly::store_and_swap( + xe::store_and_swap( memory_->TranslateVirtual(interrupt_thread_block_ + 0x10C), cpu); // Execute interrupt. diff --git a/src/xenia/cpu/raw_module.cc b/src/xenia/cpu/raw_module.cc index 0ee9afa4d..22389c3d0 100644 --- a/src/xenia/cpu/raw_module.cc +++ b/src/xenia/cpu/raw_module.cc @@ -9,8 +9,8 @@ #include "xenia/cpu/raw_module.h" -#include "poly/platform.h" -#include "poly/string.h" +#include "xenia/base/platform.h" +#include "xenia/base/string.h" namespace xe { namespace cpu { @@ -21,7 +21,7 @@ RawModule::RawModule(Runtime* runtime) RawModule::~RawModule() {} int RawModule::LoadFile(uint32_t base_address, const std::wstring& path) { - auto fixed_path = poly::to_string(poly::fix_path_separators(path)); + auto fixed_path = xe::to_string(xe::fix_path_separators(path)); FILE* file = fopen(fixed_path.c_str(), "rb"); fseek(file, 0, SEEK_END); uint32_t file_length = static_cast(ftell(file)); @@ -39,7 +39,7 @@ int RawModule::LoadFile(uint32_t base_address, const std::wstring& path) { fclose(file); // Setup debug info. - auto last_slash = fixed_path.find_last_of(poly::path_separator); + auto last_slash = fixed_path.find_last_of(xe::path_separator); if (last_slash != std::string::npos) { name_ = fixed_path.substr(last_slash + 1); } else { diff --git a/src/xenia/cpu/runtime.cc b/src/xenia/cpu/runtime.cc index 2c981e7e3..dc860a822 100644 --- a/src/xenia/cpu/runtime.cc +++ b/src/xenia/cpu/runtime.cc @@ -11,8 +11,8 @@ #include -#include "poly/assert.h" #include "xdb/protocol.h" +#include "xenia/base/assert.h" #include "xenia/cpu/frontend/ppc_frontend.h" #include "xenia/cpu/module.h" #include "xenia/cpu/thread_state.h" diff --git a/src/xenia/cpu/test/test_byte_swap.cc b/src/xenia/cpu/test/test_byte_swap.cc index 9e6d39757..d780a1148 100644 --- a/src/xenia/cpu/test/test_byte_swap.cc +++ b/src/xenia/cpu/test/test_byte_swap.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("BYTE_SWAP_V128", "[instr]") { TestFunction([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_extract.cc b/src/xenia/cpu/test/test_extract.cc index c577d1aa7..7b90c97f7 100644 --- a/src/xenia/cpu/test/test_extract.cc +++ b/src/xenia/cpu/test/test_extract.cc @@ -11,11 +11,11 @@ #include -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("EXTRACT_INT8", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_insert.cc b/src/xenia/cpu/test/test_insert.cc index da42e4f8e..882ed1488 100644 --- a/src/xenia/cpu/test/test_insert.cc +++ b/src/xenia/cpu/test/test_insert.cc @@ -11,11 +11,11 @@ #include -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("INSERT_INT8", "[instr]") { for (int i = 0; i < 16; ++i) { diff --git a/src/xenia/cpu/test/test_load_vector_shl_shr.cc b/src/xenia/cpu/test/test_load_vector_shl_shr.cc index 120c929e9..accc5d6d2 100644 --- a/src/xenia/cpu/test/test_load_vector_shl_shr.cc +++ b/src/xenia/cpu/test/test_load_vector_shl_shr.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("LOAD_VECTOR_SHL", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_pack.cc b/src/xenia/cpu/test/test_pack.cc index e7dea10d0..69f2d815a 100644 --- a/src/xenia/cpu/test/test_pack.cc +++ b/src/xenia/cpu/test/test_pack.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("PACK_D3DCOLOR", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_permute.cc b/src/xenia/cpu/test/test_permute.cc index 0bd884925..4530eb562 100644 --- a/src/xenia/cpu/test/test_permute.cc +++ b/src/xenia/cpu/test/test_permute.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("PERMUTE_V128_BY_INT32_CONSTANT", "[instr]") { { diff --git a/src/xenia/cpu/test/test_shr.cc b/src/xenia/cpu/test/test_shr.cc index 171f4ba9e..d5363df02 100644 --- a/src/xenia/cpu/test/test_shr.cc +++ b/src/xenia/cpu/test/test_shr.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("SHR_I8", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_swizzle.cc b/src/xenia/cpu/test/test_swizzle.cc index b0cb30a2c..c33761c0c 100644 --- a/src/xenia/cpu/test/test_swizzle.cc +++ b/src/xenia/cpu/test/test_swizzle.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("SWIZZLE_V128", "[instr]") { TestFunction([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_unpack.cc b/src/xenia/cpu/test/test_unpack.cc index 0b95e23b3..27c8d5cab 100644 --- a/src/xenia/cpu/test/test_unpack.cc +++ b/src/xenia/cpu/test/test_unpack.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("UNPACK_D3DCOLOR", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_vector_add.cc b/src/xenia/cpu/test/test_vector_add.cc index 98b1f0642..04f67be83 100644 --- a/src/xenia/cpu/test/test_vector_add.cc +++ b/src/xenia/cpu/test/test_vector_add.cc @@ -11,11 +11,11 @@ #include -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("VECTOR_ADD_I8", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_vector_max.cc b/src/xenia/cpu/test/test_vector_max.cc index 2cf17ef1a..ea5b13f33 100644 --- a/src/xenia/cpu/test/test_vector_max.cc +++ b/src/xenia/cpu/test/test_vector_max.cc @@ -11,11 +11,11 @@ #include -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("VECTOR_MAX_I8_SIGNED", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_vector_min.cc b/src/xenia/cpu/test/test_vector_min.cc index a94263c37..5c03965ea 100644 --- a/src/xenia/cpu/test/test_vector_min.cc +++ b/src/xenia/cpu/test/test_vector_min.cc @@ -11,11 +11,11 @@ #include -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("VECTOR_MIN_I8_SIGNED", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_vector_rotate_left.cc b/src/xenia/cpu/test/test_vector_rotate_left.cc index d9820f549..3485ae4e2 100644 --- a/src/xenia/cpu/test/test_vector_rotate_left.cc +++ b/src/xenia/cpu/test/test_vector_rotate_left.cc @@ -10,11 +10,11 @@ #include "third_party/xbyak/xbyak/xbyak_bin2hex.h" #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("VECTOR_ROTATE_LEFT_I8", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_vector_sha.cc b/src/xenia/cpu/test/test_vector_sha.cc index b79bf9db2..c6d33c91b 100644 --- a/src/xenia/cpu/test/test_vector_sha.cc +++ b/src/xenia/cpu/test/test_vector_sha.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("VECTOR_SHA_I8", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_vector_shl.cc b/src/xenia/cpu/test/test_vector_shl.cc index 65c1ab572..506c6b1bd 100644 --- a/src/xenia/cpu/test/test_vector_shl.cc +++ b/src/xenia/cpu/test/test_vector_shl.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("VECTOR_SHL_I8", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/test_vector_shr.cc b/src/xenia/cpu/test/test_vector_shr.cc index 64c1330ae..55bbe989f 100644 --- a/src/xenia/cpu/test/test_vector_shr.cc +++ b/src/xenia/cpu/test/test_vector_shr.cc @@ -9,11 +9,11 @@ #include "xenia/cpu/test/util.h" -using namespace xe::cpu::hir; +using namespace xe; using namespace xe::cpu; +using namespace xe::cpu::hir; using namespace xe::cpu::test; using xe::cpu::frontend::PPCContext; -using namespace poly; TEST_CASE("VECTOR_SHR_I8", "[instr]") { TestFunction test([](HIRBuilder& b) { diff --git a/src/xenia/cpu/test/util.h b/src/xenia/cpu/test/util.h index 209d8af3c..0d8203efb 100644 --- a/src/xenia/cpu/test/util.h +++ b/src/xenia/cpu/test/util.h @@ -10,7 +10,7 @@ #ifndef XENIA_TEST_UTIL_H_ #define XENIA_TEST_UTIL_H_ -#include "poly/main.h" +#include "xenia/base/main.h" #include "xenia/cpu/backend/x64/x64_backend.h" #include "xenia/cpu/cpu.h" #include "xenia/cpu/frontend/ppc_context.h" diff --git a/src/xenia/cpu/test/xe-cpu-hir-test.cc b/src/xenia/cpu/test/xe-cpu-hir-test.cc index af83eb486..6b20a7b44 100644 --- a/src/xenia/cpu/test/xe-cpu-hir-test.cc +++ b/src/xenia/cpu/test/xe-cpu-hir-test.cc @@ -10,8 +10,8 @@ #define CATCH_CONFIG_RUNNER #include "third_party/catch/single_include/catch.hpp" -#include "poly/debugging.h" -#include "poly/string.h" +#include "xenia/base/debugging.h" +#include "xenia/base/string.h" #include "xenia/cpu/test/util.h" namespace xe { @@ -25,7 +25,7 @@ int main(std::vector& args) { std::vector narrow_args; auto narrow_argv = new char* [args.size()]; for (size_t i = 0; i < args.size(); ++i) { - auto narrow_arg = poly::to_string(args[i]); + auto narrow_arg = xe::to_string(args[i]); narrow_argv[i] = const_cast(narrow_arg.data()); narrow_args.push_back(std::move(narrow_arg)); } @@ -33,8 +33,8 @@ int main(std::vector& args) { if (ret) { #if XE_PLATFORM_WIN32 // Visual Studio kills the console on shutdown, so prevent that. - if (poly::debugging::IsDebuggerAttached()) { - poly::debugging::Break(); + if (xe::debugging::IsDebuggerAttached()) { + xe::debugging::Break(); } #endif // XE_PLATFORM_WIN32 } diff --git a/src/xenia/cpu/test/xe-cpu-sandbox.cc b/src/xenia/cpu/test/xe-cpu-sandbox.cc index c34c862c5..5bd8f3375 100644 --- a/src/xenia/cpu/test/xe-cpu-sandbox.cc +++ b/src/xenia/cpu/test/xe-cpu-sandbox.cc @@ -7,7 +7,7 @@ ****************************************************************************** */ -#include "poly/main.h" +#include "xenia/base/main.h" #include "xenia/cpu/cpu.h" #include "xenia/cpu/backend/x64/x64_backend.h" #include "xenia/cpu/frontend/ppc_context.h" diff --git a/src/xenia/cpu/test_module.cc b/src/xenia/cpu/test_module.cc index b69264246..6997869dc 100644 --- a/src/xenia/cpu/test_module.cc +++ b/src/xenia/cpu/test_module.cc @@ -9,10 +9,10 @@ #include "xenia/cpu/test_module.h" -#include "poly/assert.h" -#include "poly/platform.h" -#include "poly/reset_scope.h" -#include "poly/string.h" +#include "xenia/base/assert.h" +#include "xenia/base/platform.h" +#include "xenia/base/reset_scope.h" +#include "xenia/base/string.h" #include "xenia/cpu/compiler/compiler_passes.h" #include "xenia/cpu/runtime.h" @@ -78,8 +78,8 @@ SymbolInfo::Status TestModule::DeclareFunction(uint32_t address, auto symbol_info = *out_symbol_info; // Reset() all caching when we leave. - poly::make_reset_scope(compiler_); - poly::make_reset_scope(assembler_); + xe::make_reset_scope(compiler_); + xe::make_reset_scope(assembler_); if (!generate_(*builder_.get())) { symbol_info->set_status(SymbolInfo::STATUS_FAILED); diff --git a/src/xenia/cpu/thread_state.cc b/src/xenia/cpu/thread_state.cc index d4db0c653..a828439dd 100644 --- a/src/xenia/cpu/thread_state.cc +++ b/src/xenia/cpu/thread_state.cc @@ -9,9 +9,9 @@ #include "xenia/cpu/thread_state.h" -#include "poly/assert.h" -#include "poly/threading.h" #include "xdb/protocol.h" +#include "xenia/base/assert.h" +#include "xenia/base/threading.h" #include "xenia/cpu/runtime.h" namespace xe { @@ -36,7 +36,7 @@ ThreadState::ThreadState(Runtime* runtime, uint32_t thread_id, if (thread_id_ == UINT_MAX) { // System thread. Assign the system thread ID with a high bit // set so people know what's up. - uint32_t system_thread_handle = poly::threading::current_thread_id(); + uint32_t system_thread_handle = xe::threading::current_thread_id(); thread_id_ = 0x80000000 | system_thread_handle; } backend_data_ = runtime->backend()->AllocThreadData(); diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index b6e951088..d5aa22799 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -11,13 +11,13 @@ #include -#include "poly/byte_order.h" -#include "poly/math.h" -#include "poly/memory.h" +#include "xenia/base/byte_order.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" +#include "xenia/base/memory.h" #include "xenia/cpu/cpu-private.h" #include "xenia/cpu/export_resolver.h" #include "xenia/cpu/runtime.h" -#include "xenia/logging.h" namespace xe { namespace cpu { @@ -111,12 +111,12 @@ int XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) { if (kernel_export) { if (info->thunk_address) { - snprintf(name, poly::countof(name), "__imp_%s", kernel_export->name); + snprintf(name, xe::countof(name), "__imp_%s", kernel_export->name); } else { - snprintf(name, poly::countof(name), "%s", kernel_export->name); + snprintf(name, xe::countof(name), "%s", kernel_export->name); } } else { - snprintf(name, poly::countof(name), "__imp_%s_%.3X", library->name, + snprintf(name, xe::countof(name), "__imp_%s_%.3X", library->name, info->ordinal); } @@ -134,20 +134,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 = poly::byte_swap(info->thunk_address); + *slot = xe::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 = poly::byte_swap(0xF00DF00D); + *slot = xe::byte_swap(0xF00DF00D); } } else { if (kernel_export->is_implemented) { // Implemented - replace with pointer. - poly::store_and_swap(slot, kernel_export->variable_ptr); + xe::store_and_swap(slot, kernel_export->variable_ptr); } else { // Not implemented - write with a dummy value. - poly::store_and_swap( + xe::store_and_swap( slot, 0xD000BEEF | (kernel_export->ordinal & 0xFFF) << 16); XELOGCPU("WARNING: imported a variable with no value: %s", kernel_export->name); @@ -157,9 +157,9 @@ int XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) { if (info->thunk_address) { if (kernel_export) { - snprintf(name, poly::countof(name), "%s", kernel_export->name); + snprintf(name, xe::countof(name), "%s", kernel_export->name); } else { - snprintf(name, poly::countof(name), "__kernel_%s_%.3X", library->name, + snprintf(name, xe::countof(name), "__kernel_%s_%.3X", library->name, info->ordinal); } @@ -178,10 +178,10 @@ int XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) { // nop // nop uint8_t* p = memory()->TranslateVirtual(info->thunk_address); - poly::store_and_swap(p + 0x0, 0x44000002); - poly::store_and_swap(p + 0x4, 0x4E800020); - poly::store_and_swap(p + 0x8, 0x60000000); - poly::store_and_swap(p + 0xC, 0x60000000); + xe::store_and_swap(p + 0x0, 0x44000002); + xe::store_and_swap(p + 0x4, 0x4E800020); + xe::store_and_swap(p + 0x8, 0x60000000); + xe::store_and_swap(p + 0xC, 0x60000000); FunctionInfo::ExternHandler handler = 0; void* handler_data = 0; @@ -390,17 +390,17 @@ int XexModule::FindSaveRest() { if (!gplr_start) { gplr_start = memory_->SearchAligned(start_address, end_address, gprlr_code_values, - poly::countof(gprlr_code_values)); + xe::countof(gprlr_code_values)); } if (!fpr_start) { fpr_start = memory_->SearchAligned(start_address, end_address, fpr_code_values, - poly::countof(fpr_code_values)); + xe::countof(fpr_code_values)); } if (!vmx_start) { vmx_start = memory_->SearchAligned(start_address, end_address, vmx_code_values, - poly::countof(vmx_code_values)); + xe::countof(vmx_code_values)); } if (gplr_start && fpr_start && vmx_start) { break; @@ -414,7 +414,7 @@ int XexModule::FindSaveRest() { if (gplr_start) { uint32_t address = gplr_start; for (int n = 14; n <= 31; n++) { - snprintf(name, poly::countof(name), "__savegprlr_%d", n); + snprintf(name, xe::countof(name), "__savegprlr_%d", n); FunctionInfo* symbol_info; DeclareFunction(address, &symbol_info); symbol_info->set_end_address(address + (31 - n) * 4 + 2 * 4); @@ -427,7 +427,7 @@ int XexModule::FindSaveRest() { } address = gplr_start + 20 * 4; for (int n = 14; n <= 31; n++) { - snprintf(name, poly::countof(name), "__restgprlr_%d", n); + snprintf(name, xe::countof(name), "__restgprlr_%d", n); FunctionInfo* symbol_info; DeclareFunction(address, &symbol_info); symbol_info->set_end_address(address + (31 - n) * 4 + 3 * 4); @@ -442,7 +442,7 @@ int XexModule::FindSaveRest() { if (fpr_start) { uint32_t address = fpr_start; for (int n = 14; n <= 31; n++) { - snprintf(name, poly::countof(name), "__savefpr_%d", n); + snprintf(name, xe::countof(name), "__savefpr_%d", n); FunctionInfo* symbol_info; DeclareFunction(address, &symbol_info); symbol_info->set_end_address(address + (31 - n) * 4 + 1 * 4); @@ -455,7 +455,7 @@ int XexModule::FindSaveRest() { } address = fpr_start + (18 * 4) + (1 * 4); for (int n = 14; n <= 31; n++) { - snprintf(name, poly::countof(name), "__restfpr_%d", n); + snprintf(name, xe::countof(name), "__restfpr_%d", n); FunctionInfo* symbol_info; DeclareFunction(address, &symbol_info); symbol_info->set_end_address(address + (31 - n) * 4 + 1 * 4); @@ -475,7 +475,7 @@ int XexModule::FindSaveRest() { // 64-127 rest uint32_t address = vmx_start; for (int n = 14; n <= 31; n++) { - snprintf(name, poly::countof(name), "__savevmx_%d", n); + snprintf(name, xe::countof(name), "__savevmx_%d", n); FunctionInfo* symbol_info; DeclareFunction(address, &symbol_info); symbol_info->set_name(name); @@ -487,7 +487,7 @@ int XexModule::FindSaveRest() { } address += 4; for (int n = 64; n <= 127; n++) { - snprintf(name, poly::countof(name), "__savevmx_%d", n); + snprintf(name, xe::countof(name), "__savevmx_%d", n); FunctionInfo* symbol_info; DeclareFunction(address, &symbol_info); symbol_info->set_name(name); @@ -499,7 +499,7 @@ int XexModule::FindSaveRest() { } address = vmx_start + (18 * 2 * 4) + (1 * 4) + (64 * 2 * 4) + (1 * 4); for (int n = 14; n <= 31; n++) { - snprintf(name, poly::countof(name), "__restvmx_%d", n); + snprintf(name, xe::countof(name), "__restvmx_%d", n); FunctionInfo* symbol_info; DeclareFunction(address, &symbol_info); symbol_info->set_name(name); @@ -511,7 +511,7 @@ int XexModule::FindSaveRest() { } address += 4; for (int n = 64; n <= 127; n++) { - snprintf(name, poly::countof(name), "__restvmx_%d", n); + snprintf(name, xe::countof(name), "__restvmx_%d", n); FunctionInfo* symbol_info; DeclareFunction(address, &symbol_info); symbol_info->set_name(name); diff --git a/src/xenia/debug_agent.cc b/src/xenia/debug_agent.cc index 8a1403a74..74fbcabee 100644 --- a/src/xenia/debug_agent.cc +++ b/src/xenia/debug_agent.cc @@ -11,9 +11,9 @@ #include -#include "poly/memory.h" -#include "poly/string.h" -#include "xenia/logging.h" +#include "xenia/base/logging.h" +#include "xenia/base/memory.h" +#include "xenia/base/string.h" DEFINE_string(trace_file, "", "Trace to the given file."); DEFINE_uint64(trace_capacity, 0x40000000, "Trace file capacity to allocate."); @@ -47,7 +47,7 @@ int DebugAgent::Initialize() { } int DebugAgent::SetupTracing(const std::string& trace_file, uint64_t capacity) { - auto file_path = poly::to_wstring(trace_file); + auto file_path = xe::to_wstring(trace_file); file_ = CreateFile(file_path.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY, @@ -72,7 +72,7 @@ int DebugAgent::SetupTracing(const std::string& trace_file, uint64_t capacity) { } // Store initial trace base. - poly::store(trace_base_, trace_base() + 8); + xe::store(trace_base_, trace_base() + 8); return 0; } diff --git a/src/xenia/debug_agent.h b/src/xenia/debug_agent.h index bfc1c9bb1..7836fa753 100644 --- a/src/xenia/debug_agent.h +++ b/src/xenia/debug_agent.h @@ -12,7 +12,7 @@ #include -#include "poly/platform.h" +#include "xenia/base/platform.h" namespace xe { diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index 1418cded4..bf71a70a2 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -9,10 +9,10 @@ #include "xenia/emulator.h" -#include "poly/assert.h" -#include "poly/string.h" #include "xdb/protocol.h" #include "xenia/apu/apu.h" +#include "xenia/base/assert.h" +#include "xenia/base/string.h" #include "xenia/cpu/cpu.h" #include "xenia/gpu/gpu.h" #include "xenia/hid/hid.h" @@ -162,7 +162,7 @@ X_STATUS Emulator::LaunchXexFile(const std::wstring& path) { // Get just the filename (foo.xex). std::wstring file_name; - auto last_slash = path.find_last_of(poly::path_separator); + auto last_slash = path.find_last_of(xe::path_separator); if (last_slash == std::string::npos) { // No slash found, whole thing is a file. file_name = path; @@ -172,7 +172,7 @@ X_STATUS Emulator::LaunchXexFile(const std::wstring& path) { } // Launch the game. - std::string fs_path = "game:\\" + poly::to_string(file_name); + std::string fs_path = "game:\\" + xe::to_string(file_name); return CompleteLaunch(path, fs_path); } @@ -204,8 +204,8 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path, if (ev) { ev->type = xdb::protocol::EventType::PROCESS_START; ev->membase = reinterpret_cast(memory()->virtual_membase()); - auto path_length = poly::to_string(path) - .copy(ev->launch_path, sizeof(ev->launch_path) - 1); + auto path_length = + xe::to_string(path).copy(ev->launch_path, sizeof(ev->launch_path) - 1); ev->launch_path[path_length] = 0; } diff --git a/src/xenia/gpu/gl4/blitter.cc b/src/xenia/gpu/gl4/blitter.cc index c9aa92dde..b924c831e 100644 --- a/src/xenia/gpu/gl4/blitter.cc +++ b/src/xenia/gpu/gl4/blitter.cc @@ -11,8 +11,8 @@ #include -#include "poly/assert.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/math.h" namespace xe { namespace gpu { diff --git a/src/xenia/gpu/gl4/circular_buffer.cc b/src/xenia/gpu/gl4/circular_buffer.cc index 538b71e82..3a44eaad9 100644 --- a/src/xenia/gpu/gl4/circular_buffer.cc +++ b/src/xenia/gpu/gl4/circular_buffer.cc @@ -9,8 +9,8 @@ #include "xenia/gpu/gl4/circular_buffer.h" -#include "poly/assert.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/math.h" #include "xenia/gpu/gl4/gl4_gpu-private.h" #include "xenia/gpu/gpu-private.h" @@ -67,13 +67,13 @@ void CircularBuffer::Shutdown() { } bool CircularBuffer::CanAcquire(size_t length) { - size_t aligned_length = poly::round_up(length, alignment_); + size_t aligned_length = xe::round_up(length, alignment_); return write_head_ + aligned_length <= capacity_; } CircularBuffer::Allocation CircularBuffer::Acquire(size_t length) { // Addresses must always be % 256. - size_t aligned_length = poly::round_up(length, alignment_); + size_t aligned_length = xe::round_up(length, alignment_); assert_true(aligned_length <= capacity_, "Request too large"); if (write_head_ + aligned_length > capacity_) { // Flush and wait. @@ -97,7 +97,7 @@ bool CircularBuffer::AcquireCached(uint32_t key, size_t length, auto& it = allocation_cache_.find(full_key); if (it != allocation_cache_.end()) { uintptr_t write_head = it->second; - size_t aligned_length = poly::round_up(length, alignment_); + size_t aligned_length = xe::round_up(length, alignment_); out_allocation->host_ptr = host_base_ + write_head; out_allocation->gpu_ptr = gpu_base_ + write_head; out_allocation->offset = write_head; diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc index 6b96875c6..b95c97fae 100644 --- a/src/xenia/gpu/gl4/command_processor.cc +++ b/src/xenia/gpu/gl4/command_processor.cc @@ -11,14 +11,14 @@ #include -#include "poly/math.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/gpu/gl4/gl4_gpu-private.h" #include "xenia/gpu/gl4/gl4_graphics_system.h" #include "xenia/gpu/gpu-private.h" #include "xenia/gpu/sampler_info.h" #include "xenia/gpu/texture_info.h" #include "xenia/gpu/xenos.h" -#include "xenia/logging.h" #include "xenia/profiling.h" #include "third_party/xxhash/xxhash.h" @@ -100,7 +100,7 @@ bool CommandProcessor::Initialize(std::unique_ptr context) { worker_running_ = true; worker_thread_ = std::thread([this]() { - poly::threading::set_name("GL4 Worker"); + xe::threading::set_name("GL4 Worker"); xe::Profiler::ThreadEnter("GL4 Worker"); WorkerMain(); xe::Profiler::ThreadExit(); @@ -212,7 +212,7 @@ void CommandProcessor::WorkerMain() { // TODO(benvanik): use reader->Read_update_freq_ and only issue after moving // that many indices. if (read_ptr_writeback_ptr_) { - poly::store_and_swap( + xe::store_and_swap( memory_->TranslatePhysical(read_ptr_writeback_ptr_), read_ptr_index_); } } @@ -488,8 +488,7 @@ void CommandProcessor::WriteRegister(uint32_t index, uint32_t value) { // Enabled - write to address. uint32_t scratch_addr = regs->values[XE_GPU_REG_SCRATCH_ADDR].u32; uint32_t mem_addr = scratch_addr + (scratch_reg * 4); - poly::store_and_swap(memory_->TranslatePhysical(mem_addr), - value); + xe::store_and_swap(memory_->TranslatePhysical(mem_addr), value); } } } @@ -602,14 +601,14 @@ class CommandProcessor::RingbufferReader { uint32_t offset() const { return offset_; } bool can_read() const { return ptr_ != end_ptr_; } - uint32_t Peek() { return poly::load_and_swap(membase_ + ptr_); } + uint32_t Peek() { return xe::load_and_swap(membase_ + ptr_); } void CheckRead(uint32_t words) { assert_true(ptr_ + words * sizeof(uint32_t) <= end_ptr_); } uint32_t Read() { - uint32_t value = poly::load_and_swap(membase_ + ptr_); + uint32_t value = xe::load_and_swap(membase_ + ptr_); Advance(1); return value; } @@ -992,7 +991,7 @@ bool CommandProcessor::ExecutePacketType3_WAIT_REG_MEM(RingbufferReader* reader, // Memory. auto endianness = static_cast(poll_reg_addr & 0x3); poll_reg_addr &= ~0x3; - value = poly::load(memory_->TranslatePhysical(poll_reg_addr)); + value = xe::load(memory_->TranslatePhysical(poll_reg_addr)); value = GpuSwap(value, endianness); trace_writer_.WriteMemoryRead(poll_reg_addr, 4); } else { @@ -1095,7 +1094,7 @@ bool CommandProcessor::ExecutePacketType3_COND_WRITE(RingbufferReader* reader, auto endianness = static_cast(poll_reg_addr & 0x3); poll_reg_addr &= ~0x3; trace_writer_.WriteMemoryRead(poll_reg_addr, 4); - value = poly::load(memory_->TranslatePhysical(poll_reg_addr)); + value = xe::load(memory_->TranslatePhysical(poll_reg_addr)); value = GpuSwap(value, endianness); } else { // Register. @@ -1136,7 +1135,7 @@ bool CommandProcessor::ExecutePacketType3_COND_WRITE(RingbufferReader* reader, auto endianness = static_cast(write_reg_addr & 0x3); write_reg_addr &= ~0x3; write_data = GpuSwap(write_data, endianness); - poly::store(memory_->TranslatePhysical(write_reg_addr), write_data); + xe::store(memory_->TranslatePhysical(write_reg_addr), write_data); trace_writer_.WriteMemoryWrite(write_reg_addr, 4); } else { // Register. @@ -1182,7 +1181,7 @@ bool CommandProcessor::ExecutePacketType3_EVENT_WRITE_SHD( auto endianness = static_cast(address & 0x3); address &= ~0x3; data_value = GpuSwap(data_value, endianness); - poly::store(memory_->TranslatePhysical(address), data_value); + xe::store(memory_->TranslatePhysical(address), data_value); trace_writer_.WriteMemoryWrite(address, 4); return true; } @@ -1206,9 +1205,9 @@ bool CommandProcessor::ExecutePacketType3_EVENT_WRITE_EXT( 1, // max z }; assert_true(endianness == xenos::Endian::k8in16); - poly::copy_and_swap_16_aligned( + xe::copy_and_swap_16_aligned( reinterpret_cast(memory_->TranslatePhysical(address)), extents, - poly::countof(extents)); + xe::countof(extents)); trace_writer_.WriteMemoryWrite(address, sizeof(extents)); return true; } @@ -1367,7 +1366,7 @@ bool CommandProcessor::ExecutePacketType3_LOAD_ALU_CONSTANT( } trace_writer_.WriteMemoryRead(address, size_dwords * 4); for (uint32_t n = 0; n < size_dwords; n++, index++) { - uint32_t data = poly::load_and_swap( + uint32_t data = xe::load_and_swap( memory_->TranslatePhysical(address + n * 4)); WriteRegister(index, data); } @@ -1626,7 +1625,7 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateShaders( if (!cached_pipeline->handles.default_pipeline) { // Perhaps it's a bit wasteful to do all of these, but oh well. GLuint pipelines[5]; - glCreateProgramPipelines(GLsizei(poly::countof(pipelines)), pipelines); + glCreateProgramPipelines(GLsizei(xe::countof(pipelines)), pipelines); glUseProgramStages(pipelines[0], GL_VERTEX_SHADER_BIT, vertex_program); glUseProgramStages(pipelines[0], GL_FRAGMENT_SHADER_BIT, fragment_program); @@ -1748,7 +1747,7 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRenderTargets() { regs.rb_color3_info, }; // A2XX_RB_COLOR_MASK_WRITE_* == D3DRS_COLORWRITEENABLE - for (int n = 0; n < poly::countof(color_info); n++) { + for (int n = 0; n < xe::countof(color_info); n++) { uint32_t write_mask = (regs.rb_color_mask >> (n * 4)) & 0xF; if (!write_mask || !shader_targets[n]) { // Unused, so keep disabled and set to wildcard so we'll take any @@ -2133,7 +2132,7 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateBlendState() { /* 3 */ GL_MAX, /* 4 */ GL_FUNC_REVERSE_SUBTRACT, }; - for (int i = 0; i < poly::countof(regs.rb_blendcontrol); ++i) { + for (int i = 0; i < xe::countof(regs.rb_blendcontrol); ++i) { uint32_t blend_control = regs.rb_blendcontrol[i]; // A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND auto src_blend = blend_map[(blend_control & 0x0000001F) >> 0]; @@ -2299,11 +2298,11 @@ CommandProcessor::UpdateStatus CommandProcessor::PopulateIndexBuffer() { if (info.format == IndexFormat::kInt32) { auto dest = reinterpret_cast(allocation.host_ptr); auto src = memory_->TranslatePhysical(info.guest_base); - poly::copy_and_swap_32_aligned(dest, src, info.count); + xe::copy_and_swap_32_aligned(dest, src, info.count); } else { auto dest = reinterpret_cast(allocation.host_ptr); auto src = memory_->TranslatePhysical(info.guest_base); - poly::copy_and_swap_16_aligned(dest, src, info.count); + xe::copy_and_swap_16_aligned(dest, src, info.count); } draw_batcher_.set_index_buffer(allocation); scratch_buffer_.Commit(std::move(allocation)); @@ -2354,7 +2353,7 @@ CommandProcessor::UpdateStatus CommandProcessor::PopulateVertexBuffers() { // We could be smart about this to save GPU bandwidth by building a CRC // as we copy and only if it differs from the previous value committing // it (and if it matches just discard and reuse). - poly::copy_and_swap_32_aligned( + xe::copy_and_swap_32_aligned( reinterpret_cast(allocation.host_ptr), memory_->TranslatePhysical(fetch->address << 2), valid_range / 4); @@ -2663,8 +2662,8 @@ bool CommandProcessor::IssueCopy() { // but I can't seem to find something similar. uint32_t dest_logical_width = copy_dest_pitch; uint32_t dest_logical_height = copy_dest_height; - uint32_t dest_block_width = poly::round_up(dest_logical_width, 32); - uint32_t dest_block_height = poly::round_up(dest_logical_height, 32); + uint32_t dest_block_width = xe::round_up(dest_logical_width, 32); + uint32_t dest_block_height = xe::round_up(dest_logical_height, 32); uint32_t window_offset = regs[XE_GPU_REG_PA_SC_WINDOW_OFFSET].u32; int16_t window_offset_x = window_offset & 0x7FFF; @@ -2700,24 +2699,24 @@ bool CommandProcessor::IssueCopy() { trace_writer_.WriteMemoryRead(fetch->address << 2, fetch->size * 4); int32_t dest_min_x = int32_t((std::min( std::min( - GpuSwap(poly::load(vertex_addr + 0), Endian(fetch->endian)), - GpuSwap(poly::load(vertex_addr + 8), Endian(fetch->endian))), - GpuSwap(poly::load(vertex_addr + 16), Endian(fetch->endian))))); + GpuSwap(xe::load(vertex_addr + 0), Endian(fetch->endian)), + GpuSwap(xe::load(vertex_addr + 8), Endian(fetch->endian))), + GpuSwap(xe::load(vertex_addr + 16), Endian(fetch->endian))))); int32_t dest_max_x = int32_t((std::max( std::max( - GpuSwap(poly::load(vertex_addr + 0), Endian(fetch->endian)), - GpuSwap(poly::load(vertex_addr + 8), Endian(fetch->endian))), - GpuSwap(poly::load(vertex_addr + 16), Endian(fetch->endian))))); + GpuSwap(xe::load(vertex_addr + 0), Endian(fetch->endian)), + GpuSwap(xe::load(vertex_addr + 8), Endian(fetch->endian))), + GpuSwap(xe::load(vertex_addr + 16), Endian(fetch->endian))))); int32_t dest_min_y = int32_t((std::min( std::min( - GpuSwap(poly::load(vertex_addr + 4), Endian(fetch->endian)), - GpuSwap(poly::load(vertex_addr + 12), Endian(fetch->endian))), - GpuSwap(poly::load(vertex_addr + 20), Endian(fetch->endian))))); + GpuSwap(xe::load(vertex_addr + 4), Endian(fetch->endian)), + GpuSwap(xe::load(vertex_addr + 12), Endian(fetch->endian))), + GpuSwap(xe::load(vertex_addr + 20), Endian(fetch->endian))))); int32_t dest_max_y = int32_t((std::max( std::max( - GpuSwap(poly::load(vertex_addr + 4), Endian(fetch->endian)), - GpuSwap(poly::load(vertex_addr + 12), Endian(fetch->endian))), - GpuSwap(poly::load(vertex_addr + 20), Endian(fetch->endian))))); + GpuSwap(xe::load(vertex_addr + 4), Endian(fetch->endian)), + GpuSwap(xe::load(vertex_addr + 12), Endian(fetch->endian))), + GpuSwap(xe::load(vertex_addr + 20), Endian(fetch->endian))))); Rect2D dest_rect(dest_min_x, dest_min_y, dest_max_x - dest_min_x, dest_max_y - dest_min_y); Rect2D src_rect(0, 0, dest_rect.width, dest_rect.height); diff --git a/src/xenia/gpu/gl4/draw_batcher.cc b/src/xenia/gpu/gl4/draw_batcher.cc index 374291fe4..d5227d3c6 100644 --- a/src/xenia/gpu/gl4/draw_batcher.cc +++ b/src/xenia/gpu/gl4/draw_batcher.cc @@ -9,11 +9,11 @@ #include "xenia/gpu/gl4/draw_batcher.h" -#include "poly/cxx_compat.h" -#include "poly/math.h" +#include "xenia/base/cxx_compat.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/gpu/gl4/gl4_gpu-private.h" #include "xenia/gpu/gpu-private.h" -#include "xenia/logging.h" namespace xe { namespace gpu { @@ -168,7 +168,7 @@ bool DrawBatcher::BeginDraw() { } } batch_state_.command_stride = - poly::round_up(command_size, GLsizei(kCommandBufferAlignment)); + xe::round_up(command_size, GLsizei(kCommandBufferAlignment)); GLsizei header_size = sizeof(CommonHeader); diff --git a/src/xenia/gpu/gl4/gl4_graphics_system.cc b/src/xenia/gpu/gl4/gl4_graphics_system.cc index 279af48c5..a533cb091 100644 --- a/src/xenia/gpu/gl4/gl4_graphics_system.cc +++ b/src/xenia/gpu/gl4/gl4_graphics_system.cc @@ -9,13 +9,13 @@ #include "xenia/gpu/gl4/gl4_graphics_system.h" -#include "poly/threading.h" +#include "xenia/base/logging.h" +#include "xenia/base/threading.h" #include "xenia/cpu/processor.h" #include "xenia/gpu/gl4/gl4_gpu-private.h" #include "xenia/gpu/gl4/gl4_profiler_display.h" #include "xenia/gpu/gpu-private.h" #include "xenia/gpu/tracing.h" -#include "xenia/logging.h" namespace xe { namespace gpu { @@ -38,7 +38,7 @@ X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor, // Create rendering control. // This must happen on the UI thread. - poly::threading::Fence control_ready_fence; + xe::threading::Fence control_ready_fence; std::unique_ptr processor_context; target_loop_->Post([&]() { // Setup the GL control that actually does the drawing. @@ -128,12 +128,11 @@ void GL4GraphicsSystem::RequestSwap() { } void GL4GraphicsSystem::RequestFrameTrace() { - command_processor_->RequestFrameTrace( - poly::to_wstring(FLAGS_trace_gpu_prefix)); + command_processor_->RequestFrameTrace(xe::to_wstring(FLAGS_trace_gpu_prefix)); } void GL4GraphicsSystem::BeginTracing() { - command_processor_->BeginTracing(poly::to_wstring(FLAGS_trace_gpu_prefix)); + command_processor_->BeginTracing(xe::to_wstring(FLAGS_trace_gpu_prefix)); } void GL4GraphicsSystem::EndTracing() { command_processor_->EndTracing(); } @@ -149,7 +148,7 @@ void GL4GraphicsSystem::PlayTrace(const uint8_t* trace_data, size_t trace_size, const PacketStartCommand* pending_packet = nullptr; while (trace_ptr < trace_data + trace_size) { auto type = - static_cast(poly::load(trace_ptr)); + static_cast(xe::load(trace_ptr)); switch (type) { case TraceCommandType::kPrimaryBufferStart: { auto cmd = diff --git a/src/xenia/gpu/gl4/gl4_profiler_display.cc b/src/xenia/gpu/gl4/gl4_profiler_display.cc index 686505a1f..99148b3cd 100644 --- a/src/xenia/gpu/gl4/gl4_profiler_display.cc +++ b/src/xenia/gpu/gl4/gl4_profiler_display.cc @@ -11,9 +11,9 @@ #include "third_party/microprofile/microprofileui.h" -#include "poly/assert.h" -#include "poly/cxx_compat.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/cxx_compat.h" +#include "xenia/base/math.h" #include "xenia/gpu/gpu-private.h" namespace xe { @@ -182,7 +182,7 @@ GL4ProfilerDisplay::GL4ProfilerDisplay(WGLControl* control) bool GL4ProfilerDisplay::SetupFont() { // Setup font lookup table. - for (uint32_t i = 0; i < poly::countof(font_description_.char_offsets); ++i) { + for (uint32_t i = 0; i < xe::countof(font_description_.char_offsets); ++i) { font_description_.char_offsets[i] = 206; } for (uint32_t i = 'A'; i <= 'Z'; ++i) { diff --git a/src/xenia/gpu/gl4/gl4_shader.cc b/src/xenia/gpu/gl4/gl4_shader.cc index 174725251..23a10de4f 100644 --- a/src/xenia/gpu/gl4/gl4_shader.cc +++ b/src/xenia/gpu/gl4/gl4_shader.cc @@ -9,12 +9,12 @@ #include "xenia/gpu/gl4/gl4_shader.h" -#include "poly/cxx_compat.h" -#include "poly/math.h" +#include "xenia/base/cxx_compat.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/gpu/gl4/gl4_gpu-private.h" #include "xenia/gpu/gl4/gl4_shader_translator.h" #include "xenia/gpu/gpu-private.h" -#include "xenia/logging.h" namespace xe { namespace gpu { @@ -355,8 +355,8 @@ bool GL4Shader::CompileProgram(std::string source) { // Save to disk, if we asked for it. auto base_path = FLAGS_dump_shaders.c_str(); - char file_name[poly::max_path]; - snprintf(file_name, poly::countof(file_name), "%s/gl4_gen_%.16llX.%s", + char file_name[xe::max_path]; + snprintf(file_name, xe::countof(file_name), "%s/gl4_gen_%.16llX.%s", base_path, data_hash_, shader_type_ == ShaderType::kVertex ? "vert" : "frag"); if (FLAGS_dump_shaders.size()) { diff --git a/src/xenia/gpu/gl4/gl4_shader_translator.cc b/src/xenia/gpu/gl4/gl4_shader_translator.cc index ebf030e40..cbf3803d2 100644 --- a/src/xenia/gpu/gl4/gl4_shader_translator.cc +++ b/src/xenia/gpu/gl4/gl4_shader_translator.cc @@ -9,10 +9,10 @@ #include "xenia/gpu/gl4/gl4_shader_translator.h" -#include "poly/assert.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/gpu/gpu-private.h" -#include "xenia/logging.h" namespace xe { namespace gpu { diff --git a/src/xenia/gpu/gl4/gl4_shader_translator.h b/src/xenia/gpu/gl4/gl4_shader_translator.h index 211ec52b8..17afb68ca 100644 --- a/src/xenia/gpu/gl4/gl4_shader_translator.h +++ b/src/xenia/gpu/gl4/gl4_shader_translator.h @@ -12,7 +12,7 @@ #include -#include "poly/string_buffer.h" +#include "xenia/base/string_buffer.h" #include "xenia/gpu/gl4/gl_context.h" #include "xenia/gpu/gl4/gl4_shader.h" #include "xenia/gpu/ucode.h" @@ -41,7 +41,7 @@ class GL4ShaderTranslator { const uint32_t* dwords_; static const int kOutputCapacity = 64 * 1024; - poly::StringBuffer output_; + StringBuffer output_; bool is_vertex_shader() const { return shader_type_ == ShaderType::kVertex; } bool is_pixel_shader() const { return shader_type_ == ShaderType::kPixel; } diff --git a/src/xenia/gpu/gl4/gl_context.cc b/src/xenia/gpu/gl4/gl_context.cc index 9adb5d0ad..5e9a9b26b 100644 --- a/src/xenia/gpu/gl4/gl_context.cc +++ b/src/xenia/gpu/gl4/gl_context.cc @@ -11,11 +11,11 @@ #include -#include "poly/assert.h" -#include "poly/cxx_compat.h" -#include "poly/math.h" +#include "xenia/base/assert.h" +#include "xenia/base/cxx_compat.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/gpu/gl4/gl4_gpu-private.h" -#include "xenia/logging.h" #include "xenia/profiling.h" namespace xe { @@ -306,7 +306,7 @@ void GLContext::SetupDebugging() { // intended to be used as an offset into a buffer object? }; glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_OTHER, GL_DONT_CARE, - GLsizei(poly::countof(disable_message_ids)), + GLsizei(xe::countof(disable_message_ids)), disable_message_ids, GL_FALSE); // Callback will be made from driver threads. diff --git a/src/xenia/gpu/gl4/texture_cache.cc b/src/xenia/gpu/gl4/texture_cache.cc index d0c3805da..eaea6056b 100644 --- a/src/xenia/gpu/gl4/texture_cache.cc +++ b/src/xenia/gpu/gl4/texture_cache.cc @@ -9,11 +9,11 @@ #include "xenia/gpu/gl4/texture_cache.h" -#include "poly/assert.h" -#include "poly/math.h" -#include "poly/memory.h" +#include "xenia/base/assert.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" +#include "xenia/base/memory.h" #include "xenia/gpu/gpu-private.h" -#include "xenia/logging.h" namespace xe { namespace gpu { @@ -652,14 +652,14 @@ void TextureSwap(Endian endianness, void* dest, const void* src, size_t length) { switch (endianness) { case Endian::k8in16: - poly::copy_and_swap_16_aligned(reinterpret_cast(dest), - reinterpret_cast(src), - length / 2); + xe::copy_and_swap_16_aligned(reinterpret_cast(dest), + reinterpret_cast(src), + length / 2); break; case Endian::k8in32: - poly::copy_and_swap_32_aligned(reinterpret_cast(dest), - reinterpret_cast(src), - length / 4); + xe::copy_and_swap_32_aligned(reinterpret_cast(dest), + reinterpret_cast(src), + length / 4); break; case Endian::k16in32: // TODO(benvanik): make more efficient. diff --git a/src/xenia/gpu/gl4/wgl_control.cc b/src/xenia/gpu/gl4/wgl_control.cc index 10a63f69c..bd708597f 100644 --- a/src/xenia/gpu/gl4/wgl_control.cc +++ b/src/xenia/gpu/gl4/wgl_control.cc @@ -9,9 +9,9 @@ #include "xenia/gpu/gl4/wgl_control.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" +#include "xenia/base/logging.h" #include "xenia/gpu/gl4/gl4_gpu-private.h" -#include "xenia/logging.h" #include "xenia/profiling.h" namespace xe { diff --git a/src/xenia/gpu/gl4/wgl_control.h b/src/xenia/gpu/gl4/wgl_control.h index a3c1e5b9e..a377866d3 100644 --- a/src/xenia/gpu/gl4/wgl_control.h +++ b/src/xenia/gpu/gl4/wgl_control.h @@ -12,7 +12,7 @@ #include -#include "poly/threading.h" +#include "xenia/base/threading.h" #include "xenia/gpu/gl4/gl_context.h" #include "xenia/ui/loop.h" #include "xenia/ui/win32/win32_control.h" diff --git a/src/xenia/gpu/graphics_system.cc b/src/xenia/gpu/graphics_system.cc index 65e352d7c..22600cc5d 100644 --- a/src/xenia/gpu/graphics_system.cc +++ b/src/xenia/gpu/graphics_system.cc @@ -9,10 +9,10 @@ #include "xenia/gpu/graphics_system.h" -#include "poly/math.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/cpu/processor.h" #include "xenia/gpu/gpu-private.h" -#include "xenia/logging.h" namespace xe { namespace gpu { @@ -63,7 +63,7 @@ void GraphicsSystem::DispatchInterruptCallback(uint32_t source, uint32_t cpu) { // NOTE: we may be executing in some random thread. uint64_t args[] = {source, interrupt_callback_data_}; processor_->ExecuteInterrupt(cpu, interrupt_callback_, args, - poly::countof(args)); + xe::countof(args)); } } // namespace gpu diff --git a/src/xenia/gpu/register_file.cc b/src/xenia/gpu/register_file.cc index e66812277..e5280ee67 100644 --- a/src/xenia/gpu/register_file.cc +++ b/src/xenia/gpu/register_file.cc @@ -9,7 +9,7 @@ #include "xenia/gpu/register_file.h" -#include "poly/math.h" +#include "xenia/base/math.h" namespace xe { namespace gpu { diff --git a/src/xenia/gpu/shader.cc b/src/xenia/gpu/shader.cc index 3a262e873..a62f33e02 100644 --- a/src/xenia/gpu/shader.cc +++ b/src/xenia/gpu/shader.cc @@ -9,8 +9,8 @@ #include "xenia/gpu/shader.h" -#include "poly/math.h" -#include "poly/memory.h" +#include "xenia/base/math.h" +#include "xenia/base/memory.h" #include "xenia/gpu/ucode_disassembler.h" namespace xe { @@ -26,7 +26,7 @@ Shader::Shader(ShaderType shader_type, uint64_t data_hash, has_prepared_(false), is_valid_(false) { data_.resize(dword_count); - poly::copy_and_swap(data_.data(), dword_ptr, dword_count); + xe::copy_and_swap(data_.data(), dword_ptr, dword_count); std::memset(&alloc_counts_, 0, sizeof(alloc_counts_)); std::memset(&buffer_inputs_, 0, sizeof(buffer_inputs_)); std::memset(&sampler_inputs_, 0, sizeof(sampler_inputs_)); @@ -198,7 +198,7 @@ void Shader::GatherVertexFetch(const instr_fetch_vtx_t* vtx) { for (size_t n = 0; n < inputs.count; n++) { auto& desc = inputs.descs[n]; if (desc.fetch_slot == fetch_slot) { - assert_true(desc.element_count <= poly::countof(desc.elements)); + assert_true(desc.element_count <= xe::countof(desc.elements)); // It may not hold that all strides are equal, but I hope it does. assert_true(!vtx->stride || desc.stride_words == vtx->stride); el = &desc.elements[desc.element_count++]; @@ -207,7 +207,7 @@ void Shader::GatherVertexFetch(const instr_fetch_vtx_t* vtx) { } if (!el) { assert_not_zero(vtx->stride); - assert_true(inputs.count + 1 < poly::countof(inputs.descs)); + assert_true(inputs.count + 1 < xe::countof(inputs.descs)); auto& desc = inputs.descs[inputs.count++]; desc.input_index = inputs.count - 1; desc.fetch_slot = fetch_slot; @@ -263,7 +263,7 @@ void Shader::GatherTextureFetch(const instr_fetch_tex_t* tex) { assert_true(tex->const_idx < 0x1F); - assert_true(sampler_inputs_.count + 1 <= poly::countof(sampler_inputs_.descs)); + assert_true(sampler_inputs_.count + 1 <= xe::countof(sampler_inputs_.descs)); auto& input = sampler_inputs_.descs[sampler_inputs_.count++]; input.input_index = sampler_inputs_.count - 1; input.fetch_slot = tex->const_idx & 0xF; // ?????????????????????????????? diff --git a/src/xenia/gpu/texture_info.cc b/src/xenia/gpu/texture_info.cc index ac431c4d4..89d30f924 100644 --- a/src/xenia/gpu/texture_info.cc +++ b/src/xenia/gpu/texture_info.cc @@ -11,7 +11,7 @@ #include "third_party/xxhash/xxhash.h" -#include "poly/math.h" +#include "xenia/base/math.h" namespace xe { namespace gpu { @@ -178,10 +178,10 @@ void TextureInfo::CalculateTextureSizes2D(const xe_gpu_texture_fetch_t& fetch) { // w/h in blocks must be a multiple of block size. uint32_t block_width = - poly::round_up(size_2d.logical_width, format_info->block_width) / + xe::round_up(size_2d.logical_width, format_info->block_width) / format_info->block_width; uint32_t block_height = - poly::round_up(size_2d.logical_height, format_info->block_height) / + xe::round_up(size_2d.logical_height, format_info->block_height) / format_info->block_height; // Tiles are 32x32 blocks. All textures must be multiples of tile dimensions. @@ -196,7 +196,7 @@ void TextureInfo::CalculateTextureSizes2D(const xe_gpu_texture_fetch_t& fetch) { uint32_t byte_pitch = tile_width * 32 * bytes_per_block; if (!is_tiled) { // Each row must be a multiple of 256 in linear textures. - byte_pitch = poly::round_up(byte_pitch, 256); + byte_pitch = xe::round_up(byte_pitch, 256); } size_2d.input_width = tile_width * 32 * format_info->block_width; @@ -219,11 +219,11 @@ void TextureInfo::CalculateTextureSizesCube(const xe_gpu_texture_fetch_t& fetch) // w/h in blocks must be a multiple of block size. uint32_t block_width = - poly::round_up(size_cube.logical_width, format_info->block_width) / - format_info->block_width; + xe::round_up(size_cube.logical_width, format_info->block_width) / + format_info->block_width; uint32_t block_height = - poly::round_up(size_cube.logical_height, format_info->block_height) / - format_info->block_height; + xe::round_up(size_cube.logical_height, format_info->block_height) / + format_info->block_height; // Tiles are 32x32 blocks. All textures must be multiples of tile dimensions. uint32_t tile_width = uint32_t(std::ceilf(block_width / 32.0f)); @@ -237,7 +237,7 @@ void TextureInfo::CalculateTextureSizesCube(const xe_gpu_texture_fetch_t& fetch) uint32_t byte_pitch = tile_width * 32 * bytes_per_block; if (!is_tiled) { // Each row must be a multiple of 256 in linear textures. - byte_pitch = poly::round_up(byte_pitch, 256); + byte_pitch = xe::round_up(byte_pitch, 256); } size_cube.input_width = tile_width * 32 * format_info->block_width; @@ -297,8 +297,8 @@ void TextureInfo::GetPackedTileOffset(const TextureInfo& texture_info, return; } - if (poly::log2_ceil(texture_info.size_2d.logical_width) > - poly::log2_ceil(texture_info.size_2d.logical_height)) { + if (xe::log2_ceil(texture_info.size_2d.logical_width) > + xe::log2_ceil(texture_info.size_2d.logical_height)) { // Wider than tall. Laid out vertically. *out_offset_x = 0; *out_offset_y = 16; diff --git a/src/xenia/gpu/texture_info.h b/src/xenia/gpu/texture_info.h index 6ef340cb5..3dc5467bf 100644 --- a/src/xenia/gpu/texture_info.h +++ b/src/xenia/gpu/texture_info.h @@ -12,7 +12,7 @@ #include -#include "poly/assert.h" +#include "xenia/base/assert.h" #include "xenia/gpu/ucode.h" #include "xenia/gpu/xenos.h" diff --git a/src/xenia/gpu/trace_viewer_main.cc b/src/xenia/gpu/trace_viewer_main.cc index f52b76595..4b9af88fc 100644 --- a/src/xenia/gpu/trace_viewer_main.cc +++ b/src/xenia/gpu/trace_viewer_main.cc @@ -9,17 +9,18 @@ #include -#include "poly/main.h" -#include "poly/mapped_memory.h" -#include "poly/math.h" #include "third_party/imgui/imgui.h" + +#include "xenia/base/logging.h" +#include "xenia/base/main.h" +#include "xenia/base/mapped_memory.h" +#include "xenia/base/math.h" +#include "xenia/emulator.h" #include "xenia/gpu/gl4/gl_context.h" #include "xenia/gpu/graphics_system.h" #include "xenia/gpu/register_file.h" #include "xenia/gpu/tracing.h" #include "xenia/gpu/xenos.h" -#include "xenia/emulator.h" -#include "xenia/logging.h" #include "xenia/profiling.h" #include "xenia/ui/main_window.h" @@ -100,7 +101,7 @@ bool DisasmPacketType0(const uint8_t* base_ptr, uint32_t packet, uint32_t base_index = (packet & 0x7FFF); uint32_t write_one_reg = (packet >> 15) & 0x1; for (uint32_t m = 0; m < count; m++) { - uint32_t reg_data = poly::load_and_swap(ptr); + uint32_t reg_data = xe::load_and_swap(ptr); uint32_t target_index = write_one_reg ? base_index : base_index + m; out_info->actions.emplace_back( PacketAction::RegisterWrite(target_index, reg_data)); @@ -120,8 +121,8 @@ bool DisasmPacketType1(const uint8_t* base_ptr, uint32_t packet, uint32_t reg_index_1 = packet & 0x7FF; uint32_t reg_index_2 = (packet >> 11) & 0x7FF; - uint32_t reg_data_1 = poly::load_and_swap(ptr); - uint32_t reg_data_2 = poly::load_and_swap(ptr + 4); + uint32_t reg_data_1 = xe::load_and_swap(ptr); + uint32_t reg_data_2 = xe::load_and_swap(ptr + 4); out_info->actions.emplace_back( PacketAction::RegisterWrite(reg_index_1, reg_data_1)); out_info->actions.emplace_back( @@ -177,7 +178,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_INTERRUPT"}; out_info->type_info = &op_info; - uint32_t cpu_mask = poly::load_and_swap(ptr + 0); + uint32_t cpu_mask = xe::load_and_swap(ptr + 0); for (int n = 0; n < 6; n++) { if (cpu_mask & (1 << n)) { // graphics_system_->DispatchInterruptCallback(1, n); @@ -193,7 +194,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kSwap, "PM4_XE_SWAP"}; out_info->type_info = &op_info; - uint32_t frontbuffer_ptr = poly::load_and_swap(ptr + 0); + uint32_t frontbuffer_ptr = xe::load_and_swap(ptr + 0); break; } case PM4_INDIRECT_BUFFER: { @@ -201,8 +202,8 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_INDIRECT_BUFFER"}; out_info->type_info = &op_info; - uint32_t list_ptr = poly::load_and_swap(ptr + 0); - uint32_t list_length = poly::load_and_swap(ptr + 4); + uint32_t list_ptr = xe::load_and_swap(ptr + 0); + uint32_t list_length = xe::load_and_swap(ptr + 4); break; } case PM4_WAIT_REG_MEM: { @@ -210,11 +211,11 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_WAIT_REG_MEM"}; out_info->type_info = &op_info; - uint32_t wait_info = poly::load_and_swap(ptr + 0); - uint32_t poll_reg_addr = poly::load_and_swap(ptr + 4); - uint32_t ref = poly::load_and_swap(ptr + 8); - uint32_t mask = poly::load_and_swap(ptr + 12); - uint32_t wait = poly::load_and_swap(ptr + 16); + uint32_t wait_info = xe::load_and_swap(ptr + 0); + uint32_t poll_reg_addr = xe::load_and_swap(ptr + 4); + uint32_t ref = xe::load_and_swap(ptr + 8); + uint32_t mask = xe::load_and_swap(ptr + 12); + uint32_t wait = xe::load_and_swap(ptr + 16); break; } case PM4_REG_RMW: { @@ -223,9 +224,9 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_REG_RMW"}; out_info->type_info = &op_info; - uint32_t rmw_info = poly::load_and_swap(ptr + 0); - uint32_t and_mask = poly::load_and_swap(ptr + 4); - uint32_t or_mask = poly::load_and_swap(ptr + 8); + uint32_t rmw_info = xe::load_and_swap(ptr + 0); + uint32_t and_mask = xe::load_and_swap(ptr + 4); + uint32_t or_mask = xe::load_and_swap(ptr + 8); break; } case PM4_COND_WRITE: { @@ -233,12 +234,12 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_COND_WRITE"}; out_info->type_info = &op_info; - uint32_t wait_info = poly::load_and_swap(ptr + 0); - uint32_t poll_reg_addr = poly::load_and_swap(ptr + 4); - uint32_t ref = poly::load_and_swap(ptr + 8); - uint32_t mask = poly::load_and_swap(ptr + 12); - uint32_t write_reg_addr = poly::load_and_swap(ptr + 16); - uint32_t write_data = poly::load_and_swap(ptr + 20); + uint32_t wait_info = xe::load_and_swap(ptr + 0); + uint32_t poll_reg_addr = xe::load_and_swap(ptr + 4); + uint32_t ref = xe::load_and_swap(ptr + 8); + uint32_t mask = xe::load_and_swap(ptr + 12); + uint32_t write_reg_addr = xe::load_and_swap(ptr + 16); + uint32_t write_data = xe::load_and_swap(ptr + 20); break; } case PM4_EVENT_WRITE: { @@ -246,7 +247,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_EVENT_WRITE"}; out_info->type_info = &op_info; - uint32_t initiator = poly::load_and_swap(ptr + 0); + uint32_t initiator = xe::load_and_swap(ptr + 0); break; } case PM4_EVENT_WRITE_SHD: { @@ -254,9 +255,9 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_EVENT_WRITE_SHD"}; out_info->type_info = &op_info; - uint32_t initiator = poly::load_and_swap(ptr + 0); - uint32_t address = poly::load_and_swap(ptr + 4); - uint32_t value = poly::load_and_swap(ptr + 8); + uint32_t initiator = xe::load_and_swap(ptr + 0); + uint32_t address = xe::load_and_swap(ptr + 4); + uint32_t value = xe::load_and_swap(ptr + 8); break; } case PM4_EVENT_WRITE_EXT: { @@ -264,8 +265,8 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_EVENT_WRITE_EXT"}; out_info->type_info = &op_info; - uint32_t unk0 = poly::load_and_swap(ptr + 0); - uint32_t unk1 = poly::load_and_swap(ptr + 4); + uint32_t unk0 = xe::load_and_swap(ptr + 0); + uint32_t unk1 = xe::load_and_swap(ptr + 4); break; } case PM4_DRAW_INDX: { @@ -274,15 +275,15 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kDraw, "PM4_DRAW_INDX"}; out_info->type_info = &op_info; - uint32_t dword0 = poly::load_and_swap(ptr + 0); - uint32_t dword1 = poly::load_and_swap(ptr + 4); + uint32_t dword0 = xe::load_and_swap(ptr + 0); + uint32_t dword1 = xe::load_and_swap(ptr + 4); uint32_t index_count = dword1 >> 16; auto prim_type = static_cast(dword1 & 0x3F); uint32_t src_sel = (dword1 >> 6) & 0x3; if (src_sel == 0x0) { // Indexed draw. - uint32_t guest_base = poly::load_and_swap(ptr + 8); - uint32_t index_size = poly::load_and_swap(ptr + 12); + uint32_t guest_base = xe::load_and_swap(ptr + 8); + uint32_t index_size = xe::load_and_swap(ptr + 12); auto endianness = static_cast(index_size >> 30); index_size &= 0x00FFFFFF; bool index_32bit = (dword1 >> 11) & 0x1; @@ -300,7 +301,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kDraw, "PM4_DRAW_INDX_2"}; out_info->type_info = &op_info; - uint32_t dword0 = poly::load_and_swap(ptr + 0); + uint32_t dword0 = xe::load_and_swap(ptr + 0); uint32_t index_count = dword0 >> 16; auto prim_type = static_cast(dword0 & 0x3F); uint32_t src_sel = (dword0 >> 6) & 0x3; @@ -317,7 +318,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_SET_CONSTANT"}; out_info->type_info = &op_info; - uint32_t offset_type = poly::load_and_swap(ptr + 0); + uint32_t offset_type = xe::load_and_swap(ptr + 0); uint32_t index = offset_type & 0x7FF; uint32_t type = (offset_type >> 16) & 0xFF; switch (type) { @@ -342,7 +343,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, break; } for (uint32_t n = 0; n < count - 1; n++, index++) { - uint32_t data = poly::load_and_swap(ptr + 4 + n * 4); + uint32_t data = xe::load_and_swap(ptr + 4 + n * 4); out_info->actions.emplace_back( PacketAction::RegisterWrite(index, data)); } @@ -352,10 +353,10 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_SET_CONSTANT2"}; out_info->type_info = &op_info; - uint32_t offset_type = poly::load_and_swap(ptr + 0); + uint32_t offset_type = xe::load_and_swap(ptr + 0); uint32_t index = offset_type & 0xFFFF; for (uint32_t n = 0; n < count - 1; n++, index++) { - uint32_t data = poly::load_and_swap(ptr + 4 + n * 4); + uint32_t data = xe::load_and_swap(ptr + 4 + n * 4); out_info->actions.emplace_back( PacketAction::RegisterWrite(index, data)); } @@ -367,11 +368,11 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_LOAD_ALU_CONSTANT"}; out_info->type_info = &op_info; - uint32_t address = poly::load_and_swap(ptr + 0); + uint32_t address = xe::load_and_swap(ptr + 0); address &= 0x3FFFFFFF; - uint32_t offset_type = poly::load_and_swap(ptr + 4); + uint32_t offset_type = xe::load_and_swap(ptr + 4); uint32_t index = offset_type & 0x7FF; - uint32_t size_dwords = poly::load_and_swap(ptr + 8); + uint32_t size_dwords = xe::load_and_swap(ptr + 8); size_dwords &= 0xFFF; uint32_t type = (offset_type >> 16) & 0xFF; switch (type) { @@ -396,7 +397,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, } for (uint32_t n = 0; n < size_dwords; n++, index++) { // Hrm, ? - // poly::load_and_swap(membase_ + GpuToCpu(address + n * 4)); + // xe::load_and_swap(membase_ + GpuToCpu(address + n * 4)); uint32_t data = 0xDEADBEEF; out_info->actions.emplace_back( PacketAction::RegisterWrite(index, data)); @@ -407,10 +408,10 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_SET_SHADER_CONSTANTS"}; out_info->type_info = &op_info; - uint32_t offset_type = poly::load_and_swap(ptr + 0); + uint32_t offset_type = xe::load_and_swap(ptr + 0); uint32_t index = offset_type & 0xFFFF; for (uint32_t n = 0; n < count - 1; n++, index++) { - uint32_t data = poly::load_and_swap(ptr + 4 + n * 4); + uint32_t data = xe::load_and_swap(ptr + 4 + n * 4); out_info->actions.emplace_back( PacketAction::RegisterWrite(index, data)); } @@ -421,10 +422,10 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_IM_LOAD"}; out_info->type_info = &op_info; - uint32_t addr_type = poly::load_and_swap(ptr + 0); + uint32_t addr_type = xe::load_and_swap(ptr + 0); auto shader_type = static_cast(addr_type & 0x3); uint32_t addr = addr_type & ~0x3; - uint32_t start_size = poly::load_and_swap(ptr + 4); + uint32_t start_size = xe::load_and_swap(ptr + 4); uint32_t start = start_size >> 16; uint32_t size_dwords = start_size & 0xFFFF; // dwords assert_true(start == 0); @@ -435,8 +436,8 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_IM_LOAD_IMMEDIATE"}; out_info->type_info = &op_info; - uint32_t dword0 = poly::load_and_swap(ptr + 0); - uint32_t dword1 = poly::load_and_swap(ptr + 4); + uint32_t dword0 = xe::load_and_swap(ptr + 0); + uint32_t dword1 = xe::load_and_swap(ptr + 4); auto shader_type = static_cast(dword0); uint32_t start_size = dword1; uint32_t start = start_size >> 16; @@ -449,14 +450,14 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_INVALIDATE_STATE"}; out_info->type_info = &op_info; - uint32_t mask = poly::load_and_swap(ptr + 0); + uint32_t mask = xe::load_and_swap(ptr + 0); break; } case PM4_SET_BIN_MASK_LO: { static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_SET_BIN_MASK_LO"}; out_info->type_info = &op_info; - uint32_t value = poly::load_and_swap(ptr); + uint32_t value = xe::load_and_swap(ptr); // bin_mask_ = (bin_mask_ & 0xFFFFFFFF00000000ull) | value; out_info->actions.emplace_back(PacketAction::SetBinMask(value)); break; @@ -465,7 +466,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_SET_BIN_MASK_HI"}; out_info->type_info = &op_info; - uint32_t value = poly::load_and_swap(ptr); + uint32_t value = xe::load_and_swap(ptr); // bin_mask_ = // (bin_mask_ & 0xFFFFFFFFull) | (static_cast(value) << 32); break; @@ -474,7 +475,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_SET_BIN_SELECT_LO"}; out_info->type_info = &op_info; - uint32_t value = poly::load_and_swap(ptr); + uint32_t value = xe::load_and_swap(ptr); // bin_select_ = (bin_select_ & 0xFFFFFFFF00000000ull) | value; out_info->actions.emplace_back(PacketAction::SetBinSelect(value)); break; @@ -483,7 +484,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, static const PacketTypeInfo op_info = {PacketCategory::kGeneric, "PM4_SET_BIN_SELECT_HI"}; out_info->type_info = &op_info; - uint32_t value = poly::load_and_swap(ptr); + uint32_t value = xe::load_and_swap(ptr); // bin_select_ = // (bin_select_ & 0xFFFFFFFFull) | (static_cast(value) << 32); break; @@ -513,7 +514,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet, bool DisasmPacket(const uint8_t* base_ptr, PacketInfo* out_info) { std::memset(out_info, 0, sizeof(PacketInfo)); - const uint32_t packet = poly::load_and_swap(base_ptr); + const uint32_t packet = xe::load_and_swap(base_ptr); const uint32_t packet_type = packet >> 30; switch (packet_type) { case 0x00: @@ -531,7 +532,7 @@ bool DisasmPacket(const uint8_t* base_ptr, PacketInfo* out_info) { } PacketCategory GetPacketCategory(const uint8_t* base_ptr) { - const uint32_t packet = poly::load_and_swap(base_ptr); + const uint32_t packet = xe::load_and_swap(base_ptr); const uint32_t packet_type = packet >> 30; switch (packet_type) { case 0x00: @@ -597,7 +598,7 @@ class TraceReader { bool Open(const std::wstring& path) { Close(); - mmap_ = poly::MappedMemory::Open(path, poly::MappedMemory::Mode::kRead); + mmap_ = MappedMemory::Open(path, MappedMemory::Mode::kRead); if (!mmap_) { return false; } @@ -658,8 +659,7 @@ class TraceReader { bool pending_break = false; while (trace_ptr < trace_data_ + trace_size_) { ++current_frame.command_count; - auto type = - static_cast(poly::load(trace_ptr)); + auto type = static_cast(xe::load(trace_ptr)); switch (type) { case TraceCommandType::kPrimaryBufferStart: { auto cmd = @@ -759,7 +759,7 @@ class TraceReader { } } - std::unique_ptr mmap_; + std::unique_ptr mmap_; const uint8_t* trace_data_; size_t trace_size_; std::vector frames_; @@ -1266,8 +1266,8 @@ void DrawVertexFetcher(const Memory* memory, gl4::GL4Shader* shader, const uint8_t* vstart = addr + i * desc.stride_words * 4; for (uint32_t el_index = 0; el_index < desc.element_count; ++el_index) { const auto& el = desc.elements[el_index]; -#define LOADEL(type, wo) \ - GpuSwap(poly::load(vstart + (el.offset_words + wo) * 4), \ +#define LOADEL(type, wo) \ + GpuSwap(xe::load(vstart + (el.offset_words + wo) * 4), \ Endian(fetch->endian)) switch (el.format) { case VertexFormat::k_32: @@ -1402,7 +1402,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, auto frame = player.current_frame(); const auto& command = frame->commands[player.current_command_index()]; auto packet_head = command.head_ptr + sizeof(PacketStartCommand); - uint32_t packet = poly::load_and_swap(packet_head); + uint32_t packet = xe::load_and_swap(packet_head); uint32_t packet_type = packet >> 30; assert_true(packet_type == 0x03); uint32_t opcode = (packet >> 8) & 0x7F; @@ -1418,8 +1418,8 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, std::memset(&draw_info, 0, sizeof(draw_info)); switch (opcode) { case PM4_DRAW_INDX: { - uint32_t dword0 = poly::load_and_swap(packet_head + 4); - uint32_t dword1 = poly::load_and_swap(packet_head + 8); + uint32_t dword0 = xe::load_and_swap(packet_head + 4); + uint32_t dword1 = xe::load_and_swap(packet_head + 8); draw_info.index_count = dword1 >> 16; draw_info.prim_type = static_cast(dword1 & 0x3F); uint32_t src_sel = (dword1 >> 6) & 0x3; @@ -1427,8 +1427,8 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, // Indexed draw. draw_info.is_auto_index = false; draw_info.index_buffer_ptr = - poly::load_and_swap(packet_head + 12); - uint32_t index_size = poly::load_and_swap(packet_head + 16); + xe::load_and_swap(packet_head + 12); + uint32_t index_size = xe::load_and_swap(packet_head + 16); draw_info.index_endianness = static_cast(index_size >> 30); index_size &= 0x00FFFFFF; bool index_32bit = (dword1 >> 11) & 0x1; @@ -1445,7 +1445,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, break; } case PM4_DRAW_INDX_2: { - uint32_t dword0 = poly::load_and_swap(packet_head + 4); + uint32_t dword0 = xe::load_and_swap(packet_head + 4); uint32_t src_sel = (dword0 >> 6) & 0x3; assert_true(src_sel == 0x2); // 'SrcSel=AutoIndex' draw_info.prim_type = static_cast(dword0 & 0x3F); @@ -1654,7 +1654,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, regs[XE_GPU_REG_RB_BLENDCONTROL_3].u32, }; ImGui::Columns(2); - for (int i = 0; i < poly::countof(color_info); ++i) { + for (int i = 0; i < xe::countof(color_info); ++i) { uint32_t blend_control = rb_blendcontrol[i]; // A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND auto src_blend = (blend_control & 0x0000001F) >> 0; @@ -1711,7 +1711,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, ImGui::Columns(1); ImGui::Columns(4); - for (int i = 0; i < poly::countof(color_info); ++i) { + for (int i = 0; i < xe::countof(color_info); ++i) { uint32_t write_mask = (rb_color_mask >> (i * 4)) & 0xF; uint32_t color_base = color_info[i] & 0xFFF; auto color_format = @@ -1883,9 +1883,9 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, } ImGui::NextColumn(); uint32_t value = element_size == 4 - ? GpuSwap(poly::load(data_ptr), + ? GpuSwap(xe::load(data_ptr), draw_info.index_endianness) - : GpuSwap(poly::load(data_ptr), + : GpuSwap(xe::load(data_ptr), draw_info.index_endianness); ImGui::Text(" %d", value); ImGui::NextColumn(); @@ -2047,7 +2047,7 @@ void DrawPacketDisassemblerUI(xe::ui::MainWindow* window, TracePlayer& player, const PacketStartCommand* pending_packet = nullptr; auto trace_ptr = start_ptr; while (trace_ptr < end_ptr) { - auto type = static_cast(poly::load(trace_ptr)); + auto type = static_cast(xe::load(trace_ptr)); switch (type) { case TraceCommandType::kPrimaryBufferStart: { auto cmd = @@ -2190,17 +2190,17 @@ int trace_viewer_main(std::vector& args) { // Passed as a named argument. // TODO(benvanik): find something better than gflags that supports // unicode. - path = poly::to_wstring(FLAGS_target_trace_file); + path = xe::to_wstring(FLAGS_target_trace_file); } else { // Passed as an unnamed argument. path = args[1]; } // Normalize the path and make absolute. - auto abs_path = poly::to_absolute_path(path); + auto abs_path = xe::to_absolute_path(path); auto window = emulator->main_window(); auto loop = window->loop(); - auto file_name = poly::find_name_from_path(path); + auto file_name = xe::find_name_from_path(path); window->set_title(std::wstring(L"Xenia GPU Trace Viewer: ") + file_name); auto graphics_system = emulator->graphics_system(); @@ -2265,10 +2265,10 @@ int trace_viewer_main(std::vector& args) { imgui_setup = true; } auto& io = ImGui::GetIO(); - auto current_ticks = poly::threading::ticks(); + auto current_ticks = xe::threading::ticks(); static uint64_t last_ticks = 0; io.DeltaTime = (current_ticks - last_ticks) / - float(poly::threading::ticks_per_second()); + float(xe::threading::ticks_per_second()); last_ticks = current_ticks; io.DisplaySize = diff --git a/src/xenia/gpu/ucode.h b/src/xenia/gpu/ucode.h index 8d05cac49..15bbac763 100644 --- a/src/xenia/gpu/ucode.h +++ b/src/xenia/gpu/ucode.h @@ -12,7 +12,7 @@ #include -#include "poly/platform.h" +#include "xenia/base/platform.h" namespace xe { namespace gpu { diff --git a/src/xenia/gpu/ucode_disassembler.cc b/src/xenia/gpu/ucode_disassembler.cc index 80471ea34..d414e430d 100644 --- a/src/xenia/gpu/ucode_disassembler.cc +++ b/src/xenia/gpu/ucode_disassembler.cc @@ -37,7 +37,7 @@ #include #include -#include "poly/assert.h" +#include "xenia/base/assert.h" namespace xe { namespace gpu { diff --git a/src/xenia/gpu/xenos.h b/src/xenia/gpu/xenos.h index f81f4510e..a661de6c2 100644 --- a/src/xenia/gpu/xenos.h +++ b/src/xenia/gpu/xenos.h @@ -10,8 +10,8 @@ #ifndef XENIA_GPU_XENOS_H_ #define XENIA_GPU_XENOS_H_ -#include "poly/assert.h" -#include "poly/byte_order.h" +#include "xenia/base/assert.h" +#include "xenia/base/byte_order.h" #include "xenia/gpu/ucode.h" namespace xe { @@ -239,7 +239,7 @@ inline uint32_t GpuSwap(uint32_t value, Endian endianness) { case Endian::k8in32: // Swap bytes. // NOTE: we are likely doing two swaps here. Wasteful. Oh well. - return poly::byte_swap(value); + return xe::byte_swap(value); case Endian::k16in32: // Swap half words. return ((value >> 16) & 0xFFFF) | (value << 16); diff --git a/src/xenia/kernel/apps/xgi_app.cc b/src/xenia/kernel/apps/xgi_app.cc index eb55331ed..d6cc259c5 100644 --- a/src/xenia/kernel/apps/xgi_app.cc +++ b/src/xenia/kernel/apps/xgi_app.cc @@ -9,8 +9,8 @@ #include "xenia/kernel/apps/xgi_app.h" -#include "poly/threading.h" -#include "xenia/logging.h" +#include "xenia/base/logging.h" +#include "xenia/base/threading.h" namespace xe { namespace kernel { @@ -32,26 +32,26 @@ X_RESULT XXGIApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, // qword 0 // dword r4 context enum // dword r5 value - uint32_t user_index = poly::load_and_swap(buffer + 0); - uint32_t context_id = poly::load_and_swap(buffer + 16); - uint32_t context_value = poly::load_and_swap(buffer + 20); + uint32_t user_index = xe::load_and_swap(buffer + 0); + uint32_t context_id = xe::load_and_swap(buffer + 16); + uint32_t context_value = xe::load_and_swap(buffer + 20); XELOGD("XUserSetContextEx(%.8X, %.8X, %.8X)", user_index, context_id, context_value); return X_ERROR_SUCCESS; } case 0x000B0007: { - uint32_t user_index = poly::load_and_swap(buffer + 0); - uint32_t property_id = poly::load_and_swap(buffer + 16); - uint32_t value_size = poly::load_and_swap(buffer + 20); - uint32_t value_ptr = poly::load_and_swap(buffer + 24); + uint32_t user_index = xe::load_and_swap(buffer + 0); + uint32_t property_id = xe::load_and_swap(buffer + 16); + uint32_t value_size = xe::load_and_swap(buffer + 20); + uint32_t value_ptr = xe::load_and_swap(buffer + 24); XELOGD("XUserSetPropertyEx(%.8X, %.8X, %d, %.8X)", user_index, property_id, value_size, value_ptr); return X_ERROR_SUCCESS; } case 0x000B0008: { assert_true(!buffer_length || buffer_length == 8); - uint32_t achievement_count = poly::load_and_swap(buffer + 0); - uint32_t achievements_ptr = poly::load_and_swap(buffer + 4); + uint32_t achievement_count = xe::load_and_swap(buffer + 0); + uint32_t achievements_ptr = xe::load_and_swap(buffer + 4); XELOGD("XUserWriteAchievements(%.8X, %.8X)", achievement_count, achievements_ptr); return X_ERROR_SUCCESS; @@ -69,14 +69,14 @@ X_RESULT XXGIApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, case 0x000B0041: { assert_true(!buffer_length || buffer_length == 32); // 00000000 2789fecc 00000000 00000000 200491e0 00000000 200491f0 20049340 - uint32_t user_index = poly::load_and_swap(buffer + 0); - uint32_t context_ptr = poly::load_and_swap(buffer + 16); + uint32_t user_index = xe::load_and_swap(buffer + 0); + uint32_t context_ptr = xe::load_and_swap(buffer + 16); auto context = memory_->TranslateVirtual(context_ptr); - uint32_t context_id = poly::load_and_swap(context + 0); + uint32_t context_id = xe::load_and_swap(context + 0); XELOGD("XUserGetContext(%.8X, %.8X(%.8X))", user_index, context_ptr, context_id); uint32_t value = 0; - poly::store_and_swap(context + 4, value); + xe::store_and_swap(context + 4, value); return X_ERROR_SUCCESS; } case 0x000B0071: { diff --git a/src/xenia/kernel/apps/xlivebase_app.cc b/src/xenia/kernel/apps/xlivebase_app.cc index 909d503b0..02c32be60 100644 --- a/src/xenia/kernel/apps/xlivebase_app.cc +++ b/src/xenia/kernel/apps/xlivebase_app.cc @@ -9,8 +9,8 @@ #include "xenia/kernel/apps/xlivebase_app.h" -#include "poly/threading.h" -#include "xenia/logging.h" +#include "xenia/base/logging.h" +#include "xenia/base/threading.h" namespace xe { namespace kernel { @@ -31,7 +31,7 @@ X_RESULT XXLiveBaseApp::DispatchMessageSync(uint32_t message, // Called on startup, seems to just return a bool in the buffer. assert_true(!buffer_length || buffer_length == 4); XELOGD("XLiveBaseGetLogonId(%.8X)", buffer_ptr); - poly::store_and_swap(buffer + 0, 1); // ? + xe::store_and_swap(buffer + 0, 1); // ? return X_ERROR_SUCCESS; } case 0x00058020: { diff --git a/src/xenia/kernel/apps/xmp_app.cc b/src/xenia/kernel/apps/xmp_app.cc index 8344969d2..87dbfb9e1 100644 --- a/src/xenia/kernel/apps/xmp_app.cc +++ b/src/xenia/kernel/apps/xmp_app.cc @@ -9,8 +9,8 @@ #include "xenia/kernel/apps/xmp_app.h" -#include "poly/threading.h" -#include "xenia/logging.h" +#include "xenia/base/logging.h" +#include "xenia/base/threading.h" namespace xe { namespace kernel { @@ -35,8 +35,8 @@ X_RESULT XXMPApp::XMPGetStatus(uint32_t state_ptr) { Sleep(1); XELOGD("XMPGetStatus(%.8X)", state_ptr); - poly::store_and_swap(memory_->TranslateVirtual(state_ptr), - static_cast(state_)); + xe::store_and_swap(memory_->TranslateVirtual(state_ptr), + static_cast(state_)); return X_ERROR_SUCCESS; } @@ -46,7 +46,7 @@ X_RESULT XXMPApp::XMPCreateTitlePlaylist( uint32_t out_playlist_handle) { XELOGD("XMPCreateTitlePlaylist(%.8X, %.8X, %.8X(%s), %.8X, %.8X, %.8X)", songs_ptr, song_count, playlist_name_ptr, - poly::to_string(playlist_name).c_str(), flags, out_song_handles, + xe::to_string(playlist_name).c_str(), flags, out_song_handles, out_playlist_handle); auto playlist = std::make_unique(); playlist->handle = ++next_playlist_handle_; @@ -56,32 +56,30 @@ X_RESULT XXMPApp::XMPCreateTitlePlaylist( auto song = std::make_unique(); song->handle = ++next_song_handle_; uint8_t* song_base = memory_->TranslateVirtual(songs_ptr + (i * 36)); - song->file_path = - poly::load_and_swap(memory_->TranslateVirtual( - poly::load_and_swap(song_base + 0))); - song->name = poly::load_and_swap(memory_->TranslateVirtual( - poly::load_and_swap(song_base + 4))); - song->artist = poly::load_and_swap(memory_->TranslateVirtual( - poly::load_and_swap(song_base + 8))); - song->album = poly::load_and_swap(memory_->TranslateVirtual( - poly::load_and_swap(song_base + 12))); - song->album_artist = - poly::load_and_swap(memory_->TranslateVirtual( - poly::load_and_swap(song_base + 16))); - song->genre = poly::load_and_swap(memory_->TranslateVirtual( - poly::load_and_swap(song_base + 20))); - song->track_number = poly::load_and_swap(song_base + 24); - song->duration_ms = poly::load_and_swap(song_base + 28); - song->format = static_cast( - poly::load_and_swap(song_base + 32)); + song->file_path = xe::load_and_swap( + memory_->TranslateVirtual(xe::load_and_swap(song_base + 0))); + song->name = xe::load_and_swap( + memory_->TranslateVirtual(xe::load_and_swap(song_base + 4))); + song->artist = xe::load_and_swap( + memory_->TranslateVirtual(xe::load_and_swap(song_base + 8))); + song->album = xe::load_and_swap( + memory_->TranslateVirtual(xe::load_and_swap(song_base + 12))); + song->album_artist = xe::load_and_swap( + memory_->TranslateVirtual(xe::load_and_swap(song_base + 16))); + song->genre = xe::load_and_swap( + memory_->TranslateVirtual(xe::load_and_swap(song_base + 20))); + song->track_number = xe::load_and_swap(song_base + 24); + song->duration_ms = xe::load_and_swap(song_base + 28); + song->format = + static_cast(xe::load_and_swap(song_base + 32)); if (out_song_handles) { - poly::store_and_swap( + xe::store_and_swap( memory_->TranslateVirtual(out_song_handles + (i * 4)), song->handle); } playlist->songs.emplace_back(std::move(song)); } - poly::store_and_swap(memory_->TranslateVirtual(out_playlist_handle), - playlist->handle); + xe::store_and_swap(memory_->TranslateVirtual(out_playlist_handle), + playlist->handle); std::lock_guard lock(mutex_); playlists_.insert({playlist->handle, playlist.get()}); @@ -202,49 +200,49 @@ X_RESULT XXMPApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, switch (message) { case 0x00070002: { assert_true(!buffer_length || buffer_length == 12); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t playlist_handle = poly::load_and_swap(buffer + 4); - uint32_t song_handle = poly::load_and_swap(buffer + 8); // 0? + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t playlist_handle = xe::load_and_swap(buffer + 4); + uint32_t song_handle = xe::load_and_swap(buffer + 8); // 0? assert_true(xmp_client == 0x00000002); return XMPPlayTitlePlaylist(playlist_handle, song_handle); } case 0x00070003: { assert_true(!buffer_length || buffer_length == 4); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); assert_true(xmp_client == 0x00000002); return XMPContinue(); } case 0x00070004: { assert_true(!buffer_length || buffer_length == 8); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t unk = poly::load_and_swap(buffer + 4); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t unk = xe::load_and_swap(buffer + 4); assert_true(xmp_client == 0x00000002); return XMPStop(unk); } case 0x00070005: { assert_true(!buffer_length || buffer_length == 4); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); assert_true(xmp_client == 0x00000002); return XMPPause(); } case 0x00070006: { assert_true(!buffer_length || buffer_length == 4); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); assert_true(xmp_client == 0x00000002); return XMPNext(); } case 0x00070007: { assert_true(!buffer_length || buffer_length == 4); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); assert_true(xmp_client == 0x00000002); return XMPPrevious(); } case 0x00070008: { assert_true(!buffer_length || buffer_length == 16); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t playback_mode = poly::load_and_swap(buffer + 4); - uint32_t repeat_mode = poly::load_and_swap(buffer + 8); - uint32_t flags = poly::load_and_swap(buffer + 12); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t playback_mode = xe::load_and_swap(buffer + 4); + uint32_t repeat_mode = xe::load_and_swap(buffer + 8); + uint32_t flags = xe::load_and_swap(buffer + 12); assert_true(xmp_client == 0x00000002); XELOGD("XMPSetPlaybackBehavior(%.8X, %.8X, %.8X)", playback_mode, repeat_mode, flags); @@ -256,27 +254,26 @@ X_RESULT XXMPApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, } case 0x00070009: { assert_true(!buffer_length || buffer_length == 8); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t state_ptr = poly::load_and_swap( - buffer + 4); // out ptr to 4b - expect 0 + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t state_ptr = + xe::load_and_swap(buffer + 4); // out ptr to 4b - expect 0 assert_true(xmp_client == 0x00000002); return XMPGetStatus(state_ptr); } case 0x0007000B: { assert_true(!buffer_length || buffer_length == 8); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t float_ptr = poly::load_and_swap( + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t float_ptr = xe::load_and_swap( buffer + 4); // out ptr to 4b - floating point assert_true(xmp_client == 0x00000002); XELOGD("XMPGetVolume(%.8X)", float_ptr); - poly::store_and_swap(memory_->TranslateVirtual(float_ptr), - volume_); + xe::store_and_swap(memory_->TranslateVirtual(float_ptr), volume_); return X_ERROR_SUCCESS; } case 0x0007000C: { assert_true(!buffer_length || buffer_length == 8); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - float float_value = poly::load_and_swap(buffer + 4); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + float float_value = xe::load_and_swap(buffer + 4); assert_true(xmp_client == 0x00000002); XELOGD("XMPSetVolume(%g)", float_value); volume_ = float_value; @@ -284,18 +281,18 @@ X_RESULT XXMPApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, } case 0x0007000D: { assert_true(!buffer_length || buffer_length == 36); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t dummy_alloc_ptr = poly::load_and_swap(buffer + 4); - uint32_t dummy_alloc_size = poly::load_and_swap(buffer + 8); - uint32_t songs_ptr = poly::load_and_swap(buffer + 12); - uint32_t song_count = poly::load_and_swap(buffer + 16); - uint32_t playlist_name_ptr = poly::load_and_swap(buffer + 20); - uint32_t flags = poly::load_and_swap(buffer + 24); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t dummy_alloc_ptr = xe::load_and_swap(buffer + 4); + uint32_t dummy_alloc_size = xe::load_and_swap(buffer + 8); + uint32_t songs_ptr = xe::load_and_swap(buffer + 12); + uint32_t song_count = xe::load_and_swap(buffer + 16); + uint32_t playlist_name_ptr = xe::load_and_swap(buffer + 20); + uint32_t flags = xe::load_and_swap(buffer + 24); uint32_t song_handles_ptr = - poly::load_and_swap(buffer + 28); // 0? - uint32_t playlist_handle_ptr = poly::load_and_swap(buffer + 32); + xe::load_and_swap(buffer + 28); // 0? + uint32_t playlist_handle_ptr = xe::load_and_swap(buffer + 32); assert_true(xmp_client == 0x00000002); - auto playlist_name = poly::load_and_swap( + auto playlist_name = xe::load_and_swap( memory_->TranslateVirtual(playlist_name_ptr)); // dummy_alloc_ptr is the result of a XamAlloc of dummy_alloc_size. assert_true(dummy_alloc_size == song_count * 128); @@ -305,9 +302,9 @@ X_RESULT XXMPApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, } case 0x0007000E: { assert_true(!buffer_length || buffer_length == 12); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t unk_ptr = poly::load_and_swap(buffer + 4); // 0 - uint32_t info_ptr = poly::load_and_swap(buffer + 8); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t unk_ptr = xe::load_and_swap(buffer + 4); // 0 + uint32_t info_ptr = xe::load_and_swap(buffer + 8); auto info = memory_->TranslateVirtual(info_ptr); assert_true(xmp_client == 0x00000002); assert_zero(unk_ptr); @@ -316,31 +313,31 @@ X_RESULT XXMPApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, return X_ERROR_NOT_FOUND; } auto& song = active_playlist_->songs[active_song_index_]; - poly::store_and_swap(info + 0, song->handle); - poly::store_and_swap(info + 4 + 572 + 0, song->name); - poly::store_and_swap(info + 4 + 572 + 40, song->artist); - poly::store_and_swap(info + 4 + 572 + 80, song->album); - poly::store_and_swap(info + 4 + 572 + 120, - song->album_artist); - poly::store_and_swap(info + 4 + 572 + 160, song->genre); - poly::store_and_swap(info + 4 + 572 + 200, song->track_number); - poly::store_and_swap(info + 4 + 572 + 204, song->duration_ms); - poly::store_and_swap(info + 4 + 572 + 208, - static_cast(song->format)); + xe::store_and_swap(info + 0, song->handle); + xe::store_and_swap(info + 4 + 572 + 0, song->name); + xe::store_and_swap(info + 4 + 572 + 40, song->artist); + xe::store_and_swap(info + 4 + 572 + 80, song->album); + xe::store_and_swap(info + 4 + 572 + 120, + song->album_artist); + xe::store_and_swap(info + 4 + 572 + 160, song->genre); + xe::store_and_swap(info + 4 + 572 + 200, song->track_number); + xe::store_and_swap(info + 4 + 572 + 204, song->duration_ms); + xe::store_and_swap(info + 4 + 572 + 208, + static_cast(song->format)); return X_ERROR_SUCCESS; } case 0x00070013: { assert_true(!buffer_length || buffer_length == 8); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t playlist_handle = poly::load_and_swap(buffer + 4); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t playlist_handle = xe::load_and_swap(buffer + 4); assert_true(xmp_client == 0x00000002); return XMPDeleteTitlePlaylist(playlist_handle); } case 0x0007001A: { assert_true(!buffer_length || buffer_length == 12); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t unk1 = poly::load_and_swap(buffer + 4); - uint32_t enabled = poly::load_and_swap(buffer + 8); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t unk1 = xe::load_and_swap(buffer + 4); + uint32_t enabled = xe::load_and_swap(buffer + 8); assert_true(xmp_client == 0x00000002); assert_zero(unk1); XELOGD("XMPSetEnabled(%.8X, %.8X)", unk1, enabled); @@ -353,49 +350,48 @@ X_RESULT XXMPApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, } case 0x0007001B: { assert_true(!buffer_length || buffer_length == 12); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t unk_ptr = poly::load_and_swap( - buffer + 4); // out ptr to 4b - expect 0 - uint32_t disabled_ptr = poly::load_and_swap( + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t unk_ptr = + xe::load_and_swap(buffer + 4); // out ptr to 4b - expect 0 + uint32_t disabled_ptr = xe::load_and_swap( buffer + 8); // out ptr to 4b - expect 1 (to skip) assert_true(xmp_client == 0x00000002); XELOGD("XMPGetEnabled(%.8X, %.8X)", unk_ptr, disabled_ptr); - poly::store_and_swap(memory_->TranslateVirtual(unk_ptr), 0); - poly::store_and_swap(memory_->TranslateVirtual(disabled_ptr), - disabled_); + xe::store_and_swap(memory_->TranslateVirtual(unk_ptr), 0); + xe::store_and_swap(memory_->TranslateVirtual(disabled_ptr), + disabled_); // Atrain spawns a thread 82437FD0 to call this in a tight loop forever. - poly::threading::Sleep(std::chrono::milliseconds(10)); + xe::threading::Sleep(std::chrono::milliseconds(10)); return X_ERROR_SUCCESS; } case 0x00070029: { assert_true(!buffer_length || buffer_length == 16); - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t playback_mode_ptr = poly::load_and_swap(buffer + 4); - uint32_t repeat_mode_ptr = poly::load_and_swap(buffer + 8); - uint32_t unk3_ptr = poly::load_and_swap(buffer + 12); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t playback_mode_ptr = xe::load_and_swap(buffer + 4); + uint32_t repeat_mode_ptr = xe::load_and_swap(buffer + 8); + uint32_t unk3_ptr = xe::load_and_swap(buffer + 12); assert_true(xmp_client == 0x00000002); XELOGD("XMPGetPlaybackBehavior(%.8X, %.8X, %.8X)", playback_mode_ptr, repeat_mode_ptr, unk3_ptr); - poly::store_and_swap( - memory_->TranslateVirtual(playback_mode_ptr), - static_cast(playback_mode_)); - poly::store_and_swap(memory_->TranslateVirtual(repeat_mode_ptr), - static_cast(repeat_mode_)); - poly::store_and_swap(memory_->TranslateVirtual(unk3_ptr), - unknown_flags_); + xe::store_and_swap(memory_->TranslateVirtual(playback_mode_ptr), + static_cast(playback_mode_)); + xe::store_and_swap(memory_->TranslateVirtual(repeat_mode_ptr), + static_cast(repeat_mode_)); + xe::store_and_swap(memory_->TranslateVirtual(unk3_ptr), + unknown_flags_); return X_ERROR_SUCCESS; } case 0x0007002E: { assert_true(!buffer_length || buffer_length == 12); // Query of size for XamAlloc - the result of the alloc is passed to // 0x0007000D. - uint32_t xmp_client = poly::load_and_swap(buffer + 0); - uint32_t song_count = poly::load_and_swap(buffer + 4); - uint32_t size_ptr = poly::load_and_swap(buffer + 8); + uint32_t xmp_client = xe::load_and_swap(buffer + 0); + uint32_t song_count = xe::load_and_swap(buffer + 4); + uint32_t size_ptr = xe::load_and_swap(buffer + 8); assert_true(xmp_client == 0x00000002); // We don't use the storage, so just fudge the number. - poly::store_and_swap(memory_->TranslateVirtual(size_ptr), - song_count * 128); + xe::store_and_swap(memory_->TranslateVirtual(size_ptr), + song_count * 128); return X_ERROR_SUCCESS; } case 0x0007003D: { diff --git a/src/xenia/kernel/content_manager.cc b/src/xenia/kernel/content_manager.cc index 05f77ec7c..1e9cc8e82 100644 --- a/src/xenia/kernel/content_manager.cc +++ b/src/xenia/kernel/content_manager.cc @@ -11,7 +11,7 @@ #include -#include "poly/fs.h" +#include "xenia/base/fs.h" #include "xenia/kernel/xobject.h" namespace xe { @@ -70,7 +70,7 @@ std::wstring ContentManager::ResolvePackageRoot(uint32_t content_type) { // Package root path: // content_root/title_id/type_name/ auto package_root = - poly::join_paths(root_path_, poly::join_paths(title_id, type_name)); + xe::join_paths(root_path_, xe::join_paths(title_id, type_name)); return package_root + L"\\"; } @@ -79,8 +79,8 @@ std::wstring ContentManager::ResolvePackagePath(const XCONTENT_DATA& data) { // content_root/title_id/type_name/data_file_name/ auto package_root = ResolvePackageRoot(data.content_type); auto package_path = - poly::join_paths(package_root, poly::to_wstring(data.file_name)); - package_path += poly::path_separator; + xe::join_paths(package_root, xe::to_wstring(data.file_name)); + package_path += xe::path_separator; return package_path; } @@ -91,9 +91,9 @@ std::vector ContentManager::ListContent(uint32_t device_id, // Search path: // content_root/title_id/type_name/* auto package_root = ResolvePackageRoot(content_type); - auto file_infos = poly::fs::ListFiles(package_root); + auto file_infos = xe::fs::ListFiles(package_root); for (const auto& file_info : file_infos) { - if (file_info.type != poly::fs::FileInfo::Type::kDirectory) { + if (file_info.type != xe::fs::FileInfo::Type::kDirectory) { // Directories only. continue; } @@ -101,7 +101,7 @@ std::vector ContentManager::ListContent(uint32_t device_id, content_data.device_id = device_id; content_data.content_type = content_type; content_data.display_name = file_info.name; - content_data.file_name = poly::to_string(file_info.name); + content_data.file_name = xe::to_string(file_info.name); result.emplace_back(std::move(content_data)); } @@ -111,7 +111,7 @@ std::vector ContentManager::ListContent(uint32_t device_id, std::unique_ptr ContentManager::ResolvePackage( std::string root_name, const XCONTENT_DATA& data) { auto package_path = ResolvePackagePath(data); - if (!poly::fs::PathExists(package_path)) { + if (!xe::fs::PathExists(package_path)) { return nullptr; } @@ -124,7 +124,7 @@ std::unique_ptr ContentManager::ResolvePackage( bool ContentManager::ContentExists(const XCONTENT_DATA& data) { auto path = ResolvePackagePath(data); - return poly::fs::PathExists(path); + return xe::fs::PathExists(path); } X_RESULT ContentManager::CreateContent(std::string root_name, @@ -137,12 +137,12 @@ X_RESULT ContentManager::CreateContent(std::string root_name, } auto package_path = ResolvePackagePath(data); - if (poly::fs::PathExists(package_path)) { + if (xe::fs::PathExists(package_path)) { // Exists, must not! return X_ERROR_ALREADY_EXISTS; } - if (!poly::fs::CreateFolder(package_path)) { + if (!xe::fs::CreateFolder(package_path)) { return X_ERROR_ACCESS_DENIED; } @@ -164,7 +164,7 @@ X_RESULT ContentManager::OpenContent(std::string root_name, } auto package_path = ResolvePackagePath(data); - if (!poly::fs::PathExists(package_path)) { + if (!xe::fs::PathExists(package_path)) { // Does not exist, must be created. return X_ERROR_FILE_NOT_FOUND; } @@ -197,8 +197,8 @@ X_RESULT ContentManager::GetContentThumbnail(const XCONTENT_DATA& data, std::vector* buffer) { std::lock_guard lock(content_mutex_); auto package_path = ResolvePackagePath(data); - auto thumb_path = poly::join_paths(package_path, kThumbnailFileName); - if (poly::fs::PathExists(thumb_path)) { + auto thumb_path = xe::join_paths(package_path, kThumbnailFileName); + if (xe::fs::PathExists(thumb_path)) { auto file = _wfopen(thumb_path.c_str(), L"rb"); fseek(file, 0, SEEK_END); size_t file_len = ftell(file); @@ -216,8 +216,8 @@ X_RESULT ContentManager::SetContentThumbnail(const XCONTENT_DATA& data, std::vector buffer) { std::lock_guard lock(content_mutex_); auto package_path = ResolvePackagePath(data); - if (poly::fs::PathExists(package_path)) { - auto thumb_path = poly::join_paths(package_path, kThumbnailFileName); + if (xe::fs::PathExists(package_path)) { + auto thumb_path = xe::join_paths(package_path, kThumbnailFileName); auto file = _wfopen(thumb_path.c_str(), L"wb"); fwrite(buffer.data(), 1, buffer.size(), file); fclose(file); @@ -231,8 +231,8 @@ X_RESULT ContentManager::DeleteContent(const XCONTENT_DATA& data) { std::lock_guard lock(content_mutex_); auto package_path = ResolvePackagePath(data); - if (poly::fs::PathExists(package_path)) { - poly::fs::DeleteFolder(package_path); + if (xe::fs::PathExists(package_path)) { + xe::fs::DeleteFolder(package_path); return X_ERROR_SUCCESS; } else { return X_ERROR_FILE_NOT_FOUND; diff --git a/src/xenia/kernel/content_manager.h b/src/xenia/kernel/content_manager.h index c7d6436f4..e305843a1 100644 --- a/src/xenia/kernel/content_manager.h +++ b/src/xenia/kernel/content_manager.h @@ -16,7 +16,7 @@ #include #include -#include "poly/memory.h" +#include "xenia/base/memory.h" #include "xenia/xbox.h" namespace xe { @@ -33,17 +33,17 @@ struct XCONTENT_DATA { XCONTENT_DATA() = default; XCONTENT_DATA(const uint8_t* ptr) { - device_id = poly::load_and_swap(ptr + 0); - content_type = poly::load_and_swap(ptr + 4); - display_name = poly::load_and_swap(ptr + 8); - file_name = poly::load_and_swap(ptr + 8 + 128 * 2); + device_id = xe::load_and_swap(ptr + 0); + content_type = xe::load_and_swap(ptr + 4); + display_name = xe::load_and_swap(ptr + 8); + file_name = xe::load_and_swap(ptr + 8 + 128 * 2); } void Write(uint8_t* ptr) { - poly::store_and_swap(ptr + 0, device_id); - poly::store_and_swap(ptr + 4, content_type); - poly::store_and_swap(ptr + 8, display_name); - poly::store_and_swap(ptr + 8 + 128 * 2, file_name); + xe::store_and_swap(ptr + 0, device_id); + xe::store_and_swap(ptr + 4, content_type); + xe::store_and_swap(ptr + 8, display_name); + xe::store_and_swap(ptr + 8 + 128 * 2, file_name); } }; diff --git a/src/xenia/kernel/fs/devices/disc_image_device.cc b/src/xenia/kernel/fs/devices/disc_image_device.cc index 91d9856ce..d81d258b6 100644 --- a/src/xenia/kernel/fs/devices/disc_image_device.cc +++ b/src/xenia/kernel/fs/devices/disc_image_device.cc @@ -9,10 +9,10 @@ #include "xenia/kernel/fs/devices/disc_image_device.h" -#include "poly/math.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/kernel/fs/gdfx.h" #include "xenia/kernel/fs/devices/disc_image_entry.h" -#include "xenia/logging.h" namespace xe { namespace kernel { @@ -25,8 +25,7 @@ DiscImageDevice::DiscImageDevice(const std::string& path, DiscImageDevice::~DiscImageDevice() { delete gdfx_; } int DiscImageDevice::Init() { - mmap_ = - poly::MappedMemory::Open(local_path_, poly::MappedMemory::Mode::kRead); + mmap_ = MappedMemory::Open(local_path_, MappedMemory::Mode::kRead); if (!mmap_) { XELOGE("Disc image could not be mapped"); return 1; @@ -54,7 +53,7 @@ std::unique_ptr DiscImageDevice::ResolvePath(const char* path) { GDFXEntry* gdfx_entry = gdfx_->root_entry(); // Walk the path, one separator at a time. - auto path_parts = poly::split_path(path); + auto path_parts = xe::split_path(path); for (auto& part : path_parts) { gdfx_entry = gdfx_entry->GetChild(part.c_str()); if (!gdfx_entry) { diff --git a/src/xenia/kernel/fs/devices/disc_image_device.h b/src/xenia/kernel/fs/devices/disc_image_device.h index 346cf7683..8163dc448 100644 --- a/src/xenia/kernel/fs/devices/disc_image_device.h +++ b/src/xenia/kernel/fs/devices/disc_image_device.h @@ -13,7 +13,7 @@ #include #include -#include "poly/mapped_memory.h" +#include "xenia/base/mapped_memory.h" #include "xenia/kernel/fs/device.h" namespace xe { @@ -33,7 +33,7 @@ class DiscImageDevice : public Device { private: std::wstring local_path_; - std::unique_ptr mmap_; + std::unique_ptr mmap_; GDFX* gdfx_; }; diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.cc b/src/xenia/kernel/fs/devices/disc_image_entry.cc index ea9eef8bf..0f513a0dd 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.cc +++ b/src/xenia/kernel/fs/devices/disc_image_entry.cc @@ -26,7 +26,7 @@ class DiscImageMemoryMapping : public MemoryMapping { }; DiscImageEntry::DiscImageEntry(Device* device, const char* path, - poly::MappedMemory* mmap, GDFXEntry* gdfx_entry) + MappedMemory* mmap, GDFXEntry* gdfx_entry) : Entry(device, path), mmap_(mmap), gdfx_entry_(gdfx_entry), diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.h b/src/xenia/kernel/fs/devices/disc_image_entry.h index 4f4062d9a..79544ebc1 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.h +++ b/src/xenia/kernel/fs/devices/disc_image_entry.h @@ -12,9 +12,9 @@ #include -#include "poly/mapped_memory.h" +#include "xenia/base/fs.h" +#include "xenia/base/mapped_memory.h" #include "xenia/kernel/fs/entry.h" -#include "poly/fs.h" #include "xenia/kernel/fs/gdfx.h" namespace xe { @@ -23,11 +23,11 @@ namespace fs { class DiscImageEntry : public Entry { public: - DiscImageEntry(Device* device, const char* path, poly::MappedMemory* mmap, + DiscImageEntry(Device* device, const char* path, MappedMemory* mmap, GDFXEntry* gdfx_entry); ~DiscImageEntry() override; - poly::MappedMemory* mmap() const { return mmap_; } + MappedMemory* mmap() const { return mmap_; } GDFXEntry* gdfx_entry() const { return gdfx_entry_; } X_STATUS QueryInfo(XFileInfo* out_info) override; @@ -42,10 +42,10 @@ class DiscImageEntry : public Entry { XFile** out_file) override; private: - poly::MappedMemory* mmap_; + MappedMemory* mmap_; GDFXEntry* gdfx_entry_; - poly::fs::WildcardEngine find_engine_; + xe::fs::WildcardEngine find_engine_; GDFXEntry::child_it_t it_; }; diff --git a/src/xenia/kernel/fs/devices/host_path_device.cc b/src/xenia/kernel/fs/devices/host_path_device.cc index d48ed91e9..437c66b04 100644 --- a/src/xenia/kernel/fs/devices/host_path_device.cc +++ b/src/xenia/kernel/fs/devices/host_path_device.cc @@ -9,10 +9,10 @@ #include "xenia/kernel/fs/devices/host_path_device.h" -#include "poly/fs.h" +#include "xenia/base/logging.h" +#include "xenia/base/fs.h" #include "xenia/kernel/fs/devices/host_path_entry.h" #include "xenia/kernel/objects/xfile.h" -#include "xenia/logging.h" namespace xe { namespace kernel { @@ -31,13 +31,13 @@ std::unique_ptr HostPathDevice::ResolvePath(const char* path) { XELOGFS("HostPathDevice::ResolvePath(%s)", path); - auto rel_path = poly::to_wstring(path); - auto full_path = poly::join_paths(local_path_, rel_path); - full_path = poly::fix_path_separators(full_path); + auto rel_path = xe::to_wstring(path); + auto full_path = xe::join_paths(local_path_, rel_path); + full_path = xe::fix_path_separators(full_path); // Only check the file exists when the device is read-only if (read_only_) { - if (!poly::fs::PathExists(full_path)) { + if (!xe::fs::PathExists(full_path)) { return nullptr; } } diff --git a/src/xenia/kernel/fs/devices/host_path_entry.cc b/src/xenia/kernel/fs/devices/host_path_entry.cc index 5c1060d55..7acd0fb5b 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.cc +++ b/src/xenia/kernel/fs/devices/host_path_entry.cc @@ -9,8 +9,8 @@ #include "xenia/kernel/fs/devices/host_path_entry.h" -#include "poly/mapped_memory.h" -#include "poly/string.h" +#include "xenia/base/mapped_memory.h" +#include "xenia/base/string.h" #include "xenia/kernel/fs/devices/host_path_file.h" namespace xe { @@ -19,11 +19,11 @@ namespace fs { class HostPathMemoryMapping : public MemoryMapping { public: - HostPathMemoryMapping(std::unique_ptr mmap) + HostPathMemoryMapping(std::unique_ptr mmap) : MemoryMapping(mmap->data(), mmap->size()), mmap_(std::move(mmap)) {} private: - std::unique_ptr mmap_; + std::unique_ptr mmap_; }; HostPathEntry::HostPathEntry(Device* device, const char* path, @@ -75,9 +75,9 @@ X_STATUS HostPathEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length, if (handle == INVALID_HANDLE_VALUE) { std::wstring target_path = local_path_; if (!file_name) { - target_path = poly::join_paths(target_path, L"*"); + target_path = xe::join_paths(target_path, L"*"); } else { - target_path = poly::join_paths(target_path, poly::to_wstring(file_name)); + target_path = xe::join_paths(target_path, xe::to_wstring(file_name)); } handle = find_file_ = FindFirstFile(target_path.c_str(), &ffd); if (handle == INVALID_HANDLE_VALUE) { @@ -124,10 +124,9 @@ X_STATUS HostPathEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length, std::unique_ptr HostPathEntry::CreateMemoryMapping( Mode map_mode, const size_t offset, const size_t length) { - auto mmap = poly::MappedMemory::Open( - local_path_, - map_mode == Mode::READ ? poly::MappedMemory::Mode::kRead - : poly::MappedMemory::Mode::kReadWrite, + auto mmap = MappedMemory::Open( + local_path_, map_mode == Mode::READ ? MappedMemory::Mode::kRead + : MappedMemory::Mode::kReadWrite, offset, length); if (!mmap) { return nullptr; diff --git a/src/xenia/kernel/fs/devices/stfs_container_device.cc b/src/xenia/kernel/fs/devices/stfs_container_device.cc index 4a8b350cd..c4aa0561f 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_device.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_device.cc @@ -9,11 +9,11 @@ #include "xenia/kernel/fs/devices/stfs_container_device.h" -#include "poly/math.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/kernel/fs/stfs.h" #include "xenia/kernel/fs/devices/stfs_container_entry.h" #include "xenia/kernel/objects/xfile.h" -#include "xenia/logging.h" namespace xe { namespace kernel { @@ -26,8 +26,7 @@ STFSContainerDevice::STFSContainerDevice(const std::string& path, STFSContainerDevice::~STFSContainerDevice() { delete stfs_; } int STFSContainerDevice::Init() { - mmap_ = - poly::MappedMemory::Open(local_path_, poly::MappedMemory::Mode::kRead); + mmap_ = MappedMemory::Open(local_path_, MappedMemory::Mode::kRead); if (!mmap_) { XELOGE("STFS container could not be mapped"); return 1; @@ -55,7 +54,7 @@ std::unique_ptr STFSContainerDevice::ResolvePath(const char* path) { STFSEntry* stfs_entry = stfs_->root_entry(); // Walk the path, one separator at a time. - auto path_parts = poly::split_path(path); + auto path_parts = xe::split_path(path); for (auto& part : path_parts) { stfs_entry = stfs_entry->GetChild(part.c_str()); if (!stfs_entry) { diff --git a/src/xenia/kernel/fs/devices/stfs_container_device.h b/src/xenia/kernel/fs/devices/stfs_container_device.h index ce3c14802..fd6b2eee0 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_device.h +++ b/src/xenia/kernel/fs/devices/stfs_container_device.h @@ -13,7 +13,7 @@ #include #include -#include "poly/mapped_memory.h" +#include "xenia/base/mapped_memory.h" #include "xenia/kernel/fs/device.h" namespace xe { @@ -33,7 +33,7 @@ class STFSContainerDevice : public Device { private: std::wstring local_path_; - std::unique_ptr mmap_; + std::unique_ptr mmap_; STFS* stfs_; }; diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.cc b/src/xenia/kernel/fs/devices/stfs_container_entry.cc index 760d6d93e..c1c308416 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.cc @@ -16,13 +16,12 @@ namespace kernel { namespace fs { STFSContainerEntry::STFSContainerEntry(Device* device, const char* path, - poly::MappedMemory* mmap, + MappedMemory* mmap, STFSEntry* stfs_entry) : Entry(device, path), mmap_(mmap), stfs_entry_(stfs_entry), - it_(stfs_entry_->children.end()) -{ } + it_(stfs_entry_->children.end()) {} STFSContainerEntry::~STFSContainerEntry() = default; diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.h b/src/xenia/kernel/fs/devices/stfs_container_entry.h index 5d5dbbadf..8cc1f132d 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.h +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.h @@ -13,9 +13,9 @@ #include #include -#include "poly/mapped_memory.h" +#include "xenia/base/fs.h" +#include "xenia/base/mapped_memory.h" #include "xenia/kernel/fs/entry.h" -#include "poly/fs.h" #include "xenia/kernel/fs/stfs.h" namespace xe { @@ -24,11 +24,11 @@ namespace fs { class STFSContainerEntry : public Entry { public: - STFSContainerEntry(Device* device, const char* path, poly::MappedMemory* mmap, + STFSContainerEntry(Device* device, const char* path, MappedMemory* mmap, STFSEntry* stfs_entry); ~STFSContainerEntry() override; - poly::MappedMemory* mmap() const { return mmap_; } + MappedMemory* mmap() const { return mmap_; } STFSEntry* stfs_entry() const { return stfs_entry_; } X_STATUS QueryInfo(XFileInfo* out_info) override; @@ -39,10 +39,10 @@ class STFSContainerEntry : public Entry { XFile** out_file) override; private: - poly::MappedMemory* mmap_; + MappedMemory* mmap_; STFSEntry* stfs_entry_; - - poly::fs::WildcardEngine find_engine_; + + xe::fs::WildcardEngine find_engine_; STFSEntry::child_it_t it_; }; diff --git a/src/xenia/kernel/fs/entry.cc b/src/xenia/kernel/fs/entry.cc index af2f11415..52a08cdc7 100644 --- a/src/xenia/kernel/fs/entry.cc +++ b/src/xenia/kernel/fs/entry.cc @@ -9,7 +9,7 @@ #include "xenia/kernel/fs/entry.h" -#include "poly/string.h" +#include "xenia/base/string.h" #include "xenia/kernel/fs/device.h" namespace xe { @@ -25,7 +25,7 @@ Entry::Entry(Device* device, const std::string& path) : device_(device), path_(path) { assert_not_null(device); absolute_path_ = device->path() + path; - name_ = poly::find_name_from_path(path); + name_ = xe::find_name_from_path(path); } Entry::~Entry() = default; diff --git a/src/xenia/kernel/fs/filesystem.cc b/src/xenia/kernel/fs/filesystem.cc index 44b29ad43..7bf86b0ef 100644 --- a/src/xenia/kernel/fs/filesystem.cc +++ b/src/xenia/kernel/fs/filesystem.cc @@ -9,12 +9,12 @@ #include "xenia/kernel/fs/filesystem.h" -#include "poly/fs.h" -#include "poly/string.h" +#include "xenia/base/fs.h" +#include "xenia/base/logging.h" +#include "xenia/base/string.h" #include "xenia/kernel/fs/devices/disc_image_device.h" #include "xenia/kernel/fs/devices/host_path_device.h" #include "xenia/kernel/fs/devices/stfs_container_device.h" -#include "xenia/logging.h" namespace xe { namespace kernel { @@ -34,7 +34,7 @@ FileSystem::~FileSystem() { } fs::FileSystemType FileSystem::InferType(const std::wstring& local_path) { - auto last_slash = local_path.find_last_of(poly::path_separator); + auto last_slash = local_path.find_last_of(xe::path_separator); auto last_dot = local_path.find_last_of('.'); if (last_dot < last_slash) { last_dot = std::wstring::npos; @@ -71,7 +71,7 @@ int FileSystem::InitializeFromPath(fs::FileSystemType type, } case FileSystemType::XEX_FILE: { // Get the parent path of the file. - auto last_slash = local_path.find_last_of(poly::path_separator); + auto last_slash = local_path.find_last_of(xe::path_separator); std::wstring parent_path = local_path.substr(0, last_slash); // Register the local directory in the virtual filesystem. @@ -151,7 +151,7 @@ int FileSystem::DeleteSymbolicLink(const std::string& path) { std::unique_ptr FileSystem::ResolvePath(const std::string& path) { // Resolve relative paths - std::string normalized_path(poly::fs::CanonicalizePath(path)); + std::string normalized_path(xe::fs::CanonicalizePath(path)); // If no path (starts with a slash) do it module-relative. // Which for now, we just make game:. @@ -164,7 +164,7 @@ std::unique_ptr FileSystem::ResolvePath(const std::string& path) { // drive path -> device mappings with nothing nested. std::string full_path = normalized_path; for (const auto& it : symlinks_) { - if (poly::find_first_of_case(normalized_path, it.first) == 0) { + if (xe::find_first_of_case(normalized_path, it.first) == 0) { // Found symlink, fixup by replacing the prefix. full_path = it.second + full_path.substr(it.first.size()); break; @@ -173,7 +173,7 @@ std::unique_ptr FileSystem::ResolvePath(const std::string& path) { // Scan all devices. for (auto& device : devices_) { - if (poly::find_first_of_case(full_path, device->path()) == 0) { + if (xe::find_first_of_case(full_path, device->path()) == 0) { // Found! Trim the device prefix off and pass down. auto device_path = full_path.substr(device->path().size()); return device->ResolvePath(device_path.c_str()); diff --git a/src/xenia/kernel/fs/gdfx.cc b/src/xenia/kernel/fs/gdfx.cc index b9632df27..caed1a656 100644 --- a/src/xenia/kernel/fs/gdfx.cc +++ b/src/xenia/kernel/fs/gdfx.cc @@ -11,7 +11,7 @@ #include "xenia/kernel/fs/gdfx.h" -#include "poly/math.h" +#include "xenia/base/math.h" namespace xe { namespace kernel { @@ -29,8 +29,8 @@ GDFXEntry::~GDFXEntry() { } } -GDFXEntry* GDFXEntry::GetChild(const poly::fs::WildcardEngine& engine, child_it_t& ref_it) -{ +GDFXEntry* GDFXEntry::GetChild(const xe::fs::WildcardEngine& engine, + child_it_t& ref_it) { GDFXEntry* child_entry(nullptr); while (ref_it != children.end()) { if (engine.Match((*ref_it)->name)) { @@ -64,7 +64,7 @@ void GDFXEntry::Dump(int indent) { } } -GDFX::GDFX(poly::MappedMemory* mmap) : mmap_(mmap) { root_entry_ = nullptr; } +GDFX::GDFX(MappedMemory* mmap) : mmap_(mmap) { root_entry_ = nullptr; } GDFX::~GDFX() { delete root_entry_; } @@ -101,7 +101,7 @@ GDFX::Error GDFX::Verify(ParseState& state) { 0x00000000, 0x0000FB20, 0x00020600, 0x0FD90000, }; bool magic_found = false; - for (size_t n = 0; n < poly::countof(likely_offsets); n++) { + for (size_t n = 0; n < xe::countof(likely_offsets); n++) { state.game_offset = likely_offsets[n]; if (VerifyMagic(state, state.game_offset + (32 * kXESectorSize))) { magic_found = true; @@ -118,8 +118,8 @@ GDFX::Error GDFX::Verify(ParseState& state) { return kErrorReadError; } uint8_t* fs_ptr = state.ptr + state.game_offset + (32 * kXESectorSize); - state.root_sector = poly::load(fs_ptr + 20); - state.root_size = poly::load(fs_ptr + 24); + state.root_sector = xe::load(fs_ptr + 20); + state.root_size = xe::load(fs_ptr + 24); state.root_offset = state.game_offset + (state.root_sector * kXESectorSize); if (state.root_size < 13 || state.root_size > 32 * 1024 * 1024) { return kErrorDamagedFile; @@ -152,12 +152,12 @@ bool GDFX::ReadEntry(ParseState& state, const uint8_t* buffer, uint16_t entry_ordinal, GDFXEntry* parent) { const uint8_t* p = buffer + (entry_ordinal * 4); - uint16_t node_l = poly::load(p + 0); - uint16_t node_r = poly::load(p + 2); - size_t sector = poly::load(p + 4); - size_t length = poly::load(p + 8); - uint8_t attributes = poly::load(p + 12); - uint8_t name_length = poly::load(p + 13); + uint16_t node_l = xe::load(p + 0); + uint16_t node_r = xe::load(p + 2); + size_t sector = xe::load(p + 4); + size_t length = xe::load(p + 8); + uint8_t attributes = xe::load(p + 12); + uint8_t name_length = xe::load(p + 13); char* name = (char*)(p + 14); if (node_l && !ReadEntry(state, buffer, node_l, parent)) { diff --git a/src/xenia/kernel/fs/gdfx.h b/src/xenia/kernel/fs/gdfx.h index 450934397..a9890f28a 100644 --- a/src/xenia/kernel/fs/gdfx.h +++ b/src/xenia/kernel/fs/gdfx.h @@ -12,10 +12,10 @@ #include -#include "poly/mapped_memory.h" -#include "xenia/xbox.h" +#include "xenia/base/fs.h" +#include "xenia/base/mapped_memory.h" #include "xenia/kernel/fs/entry.h" -#include "poly/fs.h" +#include "xenia/xbox.h" namespace xe { namespace kernel { @@ -31,7 +31,7 @@ class GDFXEntry { typedef std::vector child_t; typedef child_t::iterator child_it_t; - GDFXEntry* GetChild(const poly::fs::WildcardEngine& engine, child_it_t& ref_it); + GDFXEntry* GetChild(const xe::fs::WildcardEngine& engine, child_it_t& ref_it); GDFXEntry* GetChild(const char* name); void Dump(int indent); @@ -53,7 +53,7 @@ class GDFX { kErrorDamagedFile = -31, }; - GDFX(poly::MappedMemory* mmap); + GDFX(MappedMemory* mmap); virtual ~GDFX(); GDFXEntry* root_entry(); @@ -85,7 +85,7 @@ class GDFX { bool ReadEntry(ParseState& state, const uint8_t* buffer, uint16_t entry_ordinal, GDFXEntry* parent); - poly::MappedMemory* mmap_; + MappedMemory* mmap_; GDFXEntry* root_entry_; }; diff --git a/src/xenia/kernel/fs/stfs.cc b/src/xenia/kernel/fs/stfs.cc index 0ee341ff8..0536022bb 100644 --- a/src/xenia/kernel/fs/stfs.cc +++ b/src/xenia/kernel/fs/stfs.cc @@ -13,64 +13,64 @@ #include -#include "xenia/logging.h" +#include "xenia/base/logging.h" namespace xe { namespace kernel { namespace fs { -#define XEGETUINT24BE(p) \ - (((uint32_t)poly::load_and_swap((p)+0) << 16) | \ - ((uint32_t)poly::load_and_swap((p)+1) << 8) | \ - (uint32_t)poly::load_and_swap((p)+2)) -#define XEGETUINT24LE(p) \ - (((uint32_t)poly::load((p)+2) << 16) | \ - ((uint32_t)poly::load((p)+1) << 8) | \ - (uint32_t)poly::load((p)+0)) +#define XEGETUINT24BE(p) \ + (((uint32_t)xe::load_and_swap((p)+0) << 16) | \ + ((uint32_t)xe::load_and_swap((p)+1) << 8) | \ + (uint32_t)xe::load_and_swap((p)+2)) +#define XEGETUINT24LE(p) \ + (((uint32_t)xe::load((p)+2) << 16) | \ + ((uint32_t)xe::load((p)+1) << 8) | \ + (uint32_t)xe::load((p)+0)) bool STFSVolumeDescriptor::Read(const uint8_t* p) { - descriptor_size = poly::load_and_swap(p + 0x00); + descriptor_size = xe::load_and_swap(p + 0x00); if (descriptor_size != 0x24) { XELOGE("STFS volume descriptor size mismatch, expected 0x24 but got 0x%X", descriptor_size); return false; } - reserved = poly::load_and_swap(p + 0x01); - block_separation = poly::load_and_swap(p + 0x02); - file_table_block_count = poly::load_and_swap(p + 0x03); + reserved = xe::load_and_swap(p + 0x01); + block_separation = xe::load_and_swap(p + 0x02); + file_table_block_count = xe::load_and_swap(p + 0x03); file_table_block_number = XEGETUINT24BE(p + 0x05); memcpy(top_hash_table_hash, p + 0x08, 0x14); - total_allocated_block_count = poly::load_and_swap(p + 0x1C); - total_unallocated_block_count = poly::load_and_swap(p + 0x20); + total_allocated_block_count = xe::load_and_swap(p + 0x1C); + total_unallocated_block_count = xe::load_and_swap(p + 0x20); return true; }; bool STFSHeader::Read(const uint8_t* p) { memcpy(license_entries, p + 0x22C, 0x100); memcpy(header_hash, p + 0x32C, 0x14); - header_size = poly::load_and_swap(p + 0x340); - content_type = (STFSContentType)poly::load_and_swap(p + 0x344); - metadata_version = poly::load_and_swap(p + 0x348); + header_size = xe::load_and_swap(p + 0x340); + content_type = (STFSContentType)xe::load_and_swap(p + 0x344); + metadata_version = xe::load_and_swap(p + 0x348); if (metadata_version > 1) { // This is a variant of thumbnail data/etc. // Can just ignore it for now (until we parse thumbnails). XELOGW("STFSContainer doesn't support version %d yet", metadata_version); } - content_size = poly::load_and_swap(p + 0x34C); - media_id = poly::load_and_swap(p + 0x354); - version = poly::load_and_swap(p + 0x358); - base_version = poly::load_and_swap(p + 0x35C); - title_id = poly::load_and_swap(p + 0x360); - platform = (STFSPlatform)poly::load_and_swap(p + 0x364); - executable_type = poly::load_and_swap(p + 0x365); - disc_number = poly::load_and_swap(p + 0x366); - disc_in_set = poly::load_and_swap(p + 0x367); - save_game_id = poly::load_and_swap(p + 0x368); + content_size = xe::load_and_swap(p + 0x34C); + media_id = xe::load_and_swap(p + 0x354); + version = xe::load_and_swap(p + 0x358); + base_version = xe::load_and_swap(p + 0x35C); + title_id = xe::load_and_swap(p + 0x360); + platform = (STFSPlatform)xe::load_and_swap(p + 0x364); + executable_type = xe::load_and_swap(p + 0x365); + disc_number = xe::load_and_swap(p + 0x366); + disc_in_set = xe::load_and_swap(p + 0x367); + save_game_id = xe::load_and_swap(p + 0x368); memcpy(console_id, p + 0x36C, 0x5); memcpy(profile_id, p + 0x371, 0x8); - data_file_count = poly::load_and_swap(p + 0x39D); - data_file_combined_size = poly::load_and_swap(p + 0x3A1); - descriptor_type = (STFSDescriptorType)poly::load_and_swap(p + 0x3A9); + data_file_count = xe::load_and_swap(p + 0x39D); + data_file_combined_size = xe::load_and_swap(p + 0x3A1); + descriptor_type = (STFSDescriptorType)xe::load_and_swap(p + 0x3A9); if (descriptor_type != STFS_DESCRIPTOR_STFS) { XELOGE("STFS descriptor format not supported: %d", descriptor_type); return false; @@ -80,16 +80,16 @@ bool STFSHeader::Read(const uint8_t* p) { } memcpy(device_id, p + 0x3FD, 0x14); for (size_t n = 0; n < 0x900 / 2; n++) { - display_names[n] = poly::load_and_swap(p + 0x411 + n * 2); - display_descs[n] = poly::load_and_swap(p + 0xD11 + n * 2); + display_names[n] = xe::load_and_swap(p + 0x411 + n * 2); + display_descs[n] = xe::load_and_swap(p + 0xD11 + n * 2); } for (size_t n = 0; n < 0x80 / 2; n++) { - publisher_name[n] = poly::load_and_swap(p + 0x1611 + n * 2); - title_name[n] = poly::load_and_swap(p + 0x1691 + n * 2); + publisher_name[n] = xe::load_and_swap(p + 0x1611 + n * 2); + title_name[n] = xe::load_and_swap(p + 0x1691 + n * 2); } - transfer_flags = poly::load_and_swap(p + 0x1711); - thumbnail_image_size = poly::load_and_swap(p + 0x1712); - title_thumbnail_image_size = poly::load_and_swap(p + 0x1716); + transfer_flags = xe::load_and_swap(p + 0x1711); + thumbnail_image_size = xe::load_and_swap(p + 0x1712); + title_thumbnail_image_size = xe::load_and_swap(p + 0x1716); memcpy(thumbnail_image, p + 0x171A, 0x4000); memcpy(title_thumbnail_image, p + 0x571A, 0x4000); return true; @@ -102,8 +102,8 @@ STFSEntry::STFSEntry() update_timestamp(0), access_timestamp(0) {} -STFSEntry* STFSEntry::GetChild(const poly::fs::WildcardEngine& engine, child_it_t& ref_it) -{ +STFSEntry* STFSEntry::GetChild(const xe::fs::WildcardEngine& engine, + child_it_t& ref_it) { STFSEntry* child_entry(nullptr); while (ref_it != children.end()) { if (engine.Match((*ref_it)->name)) { @@ -133,7 +133,7 @@ void STFSEntry::Dump(int indent) { } } -STFS::STFS(poly::MappedMemory* mmap) : mmap_(mmap) {} +STFS::STFS(MappedMemory* mmap) : mmap_(mmap) {} STFS::~STFS() {} @@ -204,13 +204,13 @@ STFS::Error STFS::ReadAllEntries(const uint8_t* map_ptr) { // Done. break; } - uint8_t filename_length_flags = poly::load_and_swap(p + 0x28); + uint8_t filename_length_flags = xe::load_and_swap(p + 0x28); uint32_t allocated_block_count = XEGETUINT24LE(p + 0x29); uint32_t start_block_index = XEGETUINT24LE(p + 0x2F); - uint16_t path_indicator = poly::load_and_swap(p + 0x32); - uint32_t file_size = poly::load_and_swap(p + 0x34); - uint32_t update_timestamp = poly::load_and_swap(p + 0x38); - uint32_t access_timestamp = poly::load_and_swap(p + 0x3C); + uint16_t path_indicator = xe::load_and_swap(p + 0x32); + uint32_t file_size = xe::load_and_swap(p + 0x34); + uint32_t update_timestamp = xe::load_and_swap(p + 0x38); + uint32_t access_timestamp = xe::load_and_swap(p + 0x3C); p += 0x40; auto entry = std::make_unique(); @@ -335,7 +335,7 @@ STFS::BlockHash_t STFS::GetBlockHash(const uint8_t* map_ptr, // table_index += table_offset - (1 << table_size_shift_); const uint8_t* hash_data = map_ptr + BlockToOffset(table_index); const uint8_t* record_data = hash_data + record * 0x18; - uint32_t info = poly::load_and_swap(record_data + 0x14); + uint32_t info = xe::load_and_swap(record_data + 0x14); uint32_t next_block_index = XEGETUINT24BE(record_data + 0x15); return {next_block_index, info}; } diff --git a/src/xenia/kernel/fs/stfs.h b/src/xenia/kernel/fs/stfs.h index 98994d531..505d7dfd6 100644 --- a/src/xenia/kernel/fs/stfs.h +++ b/src/xenia/kernel/fs/stfs.h @@ -13,10 +13,10 @@ #include #include -#include "poly/mapped_memory.h" -#include "xenia/xbox.h" +#include "xenia/base/fs.h" +#include "xenia/base/mapped_memory.h" #include "xenia/kernel/fs/entry.h" -#include "poly/fs.h" +#include "xenia/xbox.h" namespace xe { namespace kernel { @@ -134,7 +134,7 @@ class STFSEntry { typedef std::vector> child_t; typedef child_t::iterator child_it_t; - STFSEntry* GetChild(const poly::fs::WildcardEngine& engine, child_it_t& ref_it); + STFSEntry* GetChild(const xe::fs::WildcardEngine& engine, child_it_t& ref_it); STFSEntry* GetChild(const char* name); void Dump(int indent); @@ -164,7 +164,7 @@ class STFS { kErrorDamagedFile = -31, }; - STFS(poly::MappedMemory* mmap); + STFS(MappedMemory* mmap); virtual ~STFS(); const STFSHeader* header() const { return &header_; } @@ -186,7 +186,7 @@ class STFS { BlockHash_t GetBlockHash(const uint8_t* map_ptr, uint32_t block_index, uint32_t table_offset); - poly::MappedMemory* mmap_; + MappedMemory* mmap_; STFSPackageType package_type_; STFSHeader header_; diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index 3548bfccc..60933a153 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -11,8 +11,8 @@ #include -#include "poly/assert.h" -#include "poly/string.h" +#include "xenia/base/assert.h" +#include "xenia/base/string.h" #include "xenia/emulator.h" #include "xenia/kernel/dispatcher.h" #include "xenia/kernel/xam_module.h" @@ -52,8 +52,8 @@ KernelState::KernelState(Emulator* emulator) app_manager_ = std::make_unique(); user_profile_ = std::make_unique(); - auto content_root = poly::to_wstring(FLAGS_content_root); - content_root = poly::to_absolute_path(content_root); + auto content_root = xe::to_wstring(FLAGS_content_root); + content_root = xe::to_absolute_path(content_root); content_manager_ = std::make_unique(this, content_root); object_table_ = new ObjectTable(); diff --git a/src/xenia/kernel/native_list.cc b/src/xenia/kernel/native_list.cc index 039869e97..753e1c223 100644 --- a/src/xenia/kernel/native_list.cc +++ b/src/xenia/kernel/native_list.cc @@ -16,44 +16,42 @@ NativeList::NativeList(Memory* memory) : memory_(memory), head_(kInvalidPointer) {} void NativeList::Insert(uint32_t ptr) { - poly::store_and_swap(memory_->TranslateVirtual(ptr + 0), head_); - poly::store_and_swap(memory_->TranslateVirtual(ptr + 4), 0); + xe::store_and_swap(memory_->TranslateVirtual(ptr + 0), head_); + xe::store_and_swap(memory_->TranslateVirtual(ptr + 4), 0); if (head_) { - poly::store_and_swap(memory_->TranslateVirtual(head_ + 4), ptr); + xe::store_and_swap(memory_->TranslateVirtual(head_ + 4), ptr); } head_ = ptr; } bool NativeList::IsQueued(uint32_t ptr) { uint32_t flink = - poly::load_and_swap(memory_->TranslateVirtual(ptr + 0)); + xe::load_and_swap(memory_->TranslateVirtual(ptr + 0)); uint32_t blink = - poly::load_and_swap(memory_->TranslateVirtual(ptr + 4)); + xe::load_and_swap(memory_->TranslateVirtual(ptr + 4)); return head_ == ptr || flink || blink; } void NativeList::Remove(uint32_t ptr) { uint32_t flink = - poly::load_and_swap(memory_->TranslateVirtual(ptr + 0)); + xe::load_and_swap(memory_->TranslateVirtual(ptr + 0)); uint32_t blink = - poly::load_and_swap(memory_->TranslateVirtual(ptr + 4)); + xe::load_and_swap(memory_->TranslateVirtual(ptr + 4)); if (ptr == head_) { head_ = flink; if (flink) { - poly::store_and_swap(memory_->TranslateVirtual(flink + 4), 0); + xe::store_and_swap(memory_->TranslateVirtual(flink + 4), 0); } } else { if (blink) { - poly::store_and_swap(memory_->TranslateVirtual(blink + 0), - flink); + xe::store_and_swap(memory_->TranslateVirtual(blink + 0), flink); } if (flink) { - poly::store_and_swap(memory_->TranslateVirtual(flink + 4), - blink); + xe::store_and_swap(memory_->TranslateVirtual(flink + 4), blink); } } - poly::store_and_swap(memory_->TranslateVirtual(ptr + 0), 0); - poly::store_and_swap(memory_->TranslateVirtual(ptr + 4), 0); + xe::store_and_swap(memory_->TranslateVirtual(ptr + 0), 0); + xe::store_and_swap(memory_->TranslateVirtual(ptr + 4), 0); } uint32_t NativeList::Shift() { diff --git a/src/xenia/kernel/objects/xfile.h b/src/xenia/kernel/objects/xfile.h index 37e86f6a3..f613e5d91 100644 --- a/src/xenia/kernel/objects/xfile.h +++ b/src/xenia/kernel/objects/xfile.h @@ -32,14 +32,14 @@ class XFileInfo { X_FILE_ATTRIBUTES attributes; void Write(uint8_t* base, uint32_t p) { - poly::store_and_swap(base + p, creation_time); - poly::store_and_swap(base + p + 8, last_access_time); - poly::store_and_swap(base + p + 16, last_write_time); - poly::store_and_swap(base + p + 24, change_time); - poly::store_and_swap(base + p + 32, allocation_size); - poly::store_and_swap(base + p + 40, file_length); - poly::store_and_swap(base + p + 48, attributes); - poly::store_and_swap(base + p + 52, 0); // pad + xe::store_and_swap(base + p, creation_time); + xe::store_and_swap(base + p + 8, last_access_time); + xe::store_and_swap(base + p + 16, last_write_time); + xe::store_and_swap(base + p + 24, change_time); + xe::store_and_swap(base + p + 32, allocation_size); + xe::store_and_swap(base + p + 40, file_length); + xe::store_and_swap(base + p + 48, attributes); + xe::store_and_swap(base + p + 52, 0); // pad } }; @@ -64,16 +64,16 @@ class XDirectoryInfo { XDirectoryInfo* info; do { info = (XDirectoryInfo*)src; - poly::store_and_swap(dst, info->next_entry_offset); - poly::store_and_swap(dst + 4, info->file_index); - poly::store_and_swap(dst + 8, info->creation_time); - poly::store_and_swap(dst + 16, info->last_access_time); - poly::store_and_swap(dst + 24, info->last_write_time); - poly::store_and_swap(dst + 32, info->change_time); - poly::store_and_swap(dst + 40, info->end_of_file); - poly::store_and_swap(dst + 48, info->allocation_size); - poly::store_and_swap(dst + 56, info->attributes); - poly::store_and_swap(dst + 60, info->file_name_length); + xe::store_and_swap(dst, info->next_entry_offset); + xe::store_and_swap(dst + 4, info->file_index); + xe::store_and_swap(dst + 8, info->creation_time); + xe::store_and_swap(dst + 16, info->last_access_time); + xe::store_and_swap(dst + 24, info->last_write_time); + xe::store_and_swap(dst + 32, info->change_time); + xe::store_and_swap(dst + 40, info->end_of_file); + xe::store_and_swap(dst + 48, info->allocation_size); + xe::store_and_swap(dst + 56, info->attributes); + xe::store_and_swap(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(dst + 0, this->creation_time); - poly::store_and_swap(dst + 8, this->serial_number); - poly::store_and_swap(dst + 12, this->label_length); - poly::store_and_swap(dst + 16, this->supports_objects); + xe::store_and_swap(dst + 0, this->creation_time); + xe::store_and_swap(dst + 8, this->serial_number); + xe::store_and_swap(dst + 12, this->label_length); + xe::store_and_swap(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(dst + 0, this->attributes); - poly::store_and_swap(dst + 4, - this->maximum_component_name_length); - poly::store_and_swap(dst + 8, this->fs_name_length); + xe::store_and_swap(dst + 0, this->attributes); + xe::store_and_swap(dst + 4, this->maximum_component_name_length); + xe::store_and_swap(dst + 8, this->fs_name_length); memcpy(dst + 12, this->fs_name, this->fs_name_length); } }; diff --git a/src/xenia/kernel/objects/xkernel_module.cc b/src/xenia/kernel/objects/xkernel_module.cc index 73cb86ffc..91d8470fb 100644 --- a/src/xenia/kernel/objects/xkernel_module.cc +++ b/src/xenia/kernel/objects/xkernel_module.cc @@ -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 { diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index fb7bfcf04..7db1cbf03 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -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(thread_state_block + 0x14C); + return xe::load_and_swap(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(p + 0x160); + return xe::load_and_swap(p + 0x160); } void XThread::set_last_error(uint32_t error_code) { uint8_t* p = memory()->TranslateVirtual(thread_state_address_); - poly::store_and_swap(p + 0x160, error_code); + xe::store_and_swap(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(p + 0x000, tls_address_); - poly::store_and_swap(p + 0x100, thread_state_address_); - poly::store_and_swap(p + 0x14C, thread_id_); - poly::store_and_swap(p + 0x150, 0); // ? - poly::store_and_swap(p + 0x160, 0); // last error + xe::store_and_swap(p + 0x000, tls_address_); + xe::store_and_swap(p + 0x100, thread_state_address_); + xe::store_and_swap(p + 0x14C, thread_id_); + xe::store_and_swap(p + 0x150, 0); // ? + xe::store_and_swap(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(apc_ptr + 16); - uint32_t normal_routine = poly::load_and_swap(apc_ptr + 24); - uint32_t normal_context = poly::load_and_swap(apc_ptr + 28); - uint32_t system_arg1 = poly::load_and_swap(apc_ptr + 32); - uint32_t system_arg2 = poly::load_and_swap(apc_ptr + 36); + uint32_t kernel_routine = xe::load_and_swap(apc_ptr + 16); + uint32_t normal_routine = xe::load_and_swap(apc_ptr + 24); + uint32_t normal_context = xe::load_and_swap(apc_ptr + 28); + uint32_t system_arg1 = xe::load_and_swap(apc_ptr + 32); + uint32_t system_arg2 = xe::load_and_swap(apc_ptr + 36); // Mark as uninserted so that it can be reinserted again by the routine. - uint32_t old_flags = poly::load_and_swap(apc_ptr + 40); - poly::store_and_swap(apc_ptr + 40, old_flags & ~0xFF00); + uint32_t old_flags = xe::load_and_swap(apc_ptr + 40); + xe::store_and_swap(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(scratch_ptr + 0, normal_routine); - poly::store_and_swap(scratch_ptr + 4, normal_context); - poly::store_and_swap(scratch_ptr + 8, system_arg1); - poly::store_and_swap(scratch_ptr + 12, system_arg2); + xe::store_and_swap(scratch_ptr + 0, normal_routine); + xe::store_and_swap(scratch_ptr + 4, normal_context); + xe::store_and_swap(scratch_ptr + 8, system_arg1); + xe::store_and_swap(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(scratch_ptr + 0); - normal_context = poly::load_and_swap(scratch_ptr + 4); - system_arg1 = poly::load_and_swap(scratch_ptr + 8); - system_arg2 = poly::load_and_swap(scratch_ptr + 12); + xe::countof(kernel_args)); + normal_routine = xe::load_and_swap(scratch_ptr + 0); + normal_context = xe::load_and_swap(scratch_ptr + 4); + system_arg1 = xe::load_and_swap(scratch_ptr + 8); + system_arg2 = xe::load_and_swap(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(apc_ptr + 20); + uint32_t rundown_routine = xe::load_and_swap(apc_ptr + 20); // Mark as uninserted so that it can be reinserted again by the routine. - uint32_t old_flags = poly::load_and_swap(apc_ptr + 40); - poly::store_and_swap(apc_ptr + 40, old_flags & ~0xFF00); + uint32_t old_flags = xe::load_and_swap(apc_ptr + 40); + xe::store_and_swap(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(); diff --git a/src/xenia/kernel/objects/xtimer.cc b/src/xenia/kernel/objects/xtimer.cc index 99efb7cd5..f96680fc1 100644 --- a/src/xenia/kernel/objects/xtimer.cc +++ b/src/xenia/kernel/objects/xtimer.cc @@ -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 { diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index ae568a271..350365ac8 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -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(eip + 0x00, ex.media_id); - poly::store_and_swap(eip + 0x04, ex.version.value); - poly::store_and_swap(eip + 0x08, ex.base_version.value); - poly::store_and_swap(eip + 0x0C, ex.title_id); - poly::store_and_swap(eip + 0x10, ex.platform); - poly::store_and_swap(eip + 0x11, ex.executable_table); - poly::store_and_swap(eip + 0x12, ex.disc_number); - poly::store_and_swap(eip + 0x13, ex.disc_count); - poly::store_and_swap(eip + 0x14, ex.savegame_id); + xe::store_and_swap(eip + 0x00, ex.media_id); + xe::store_and_swap(eip + 0x04, ex.version.value); + xe::store_and_swap(eip + 0x08, ex.base_version.value); + xe::store_and_swap(eip + 0x0C, ex.title_id); + xe::store_and_swap(eip + 0x10, ex.platform); + xe::store_and_swap(eip + 0x11, ex.executable_table); + xe::store_and_swap(eip + 0x12, ex.disc_number); + xe::store_and_swap(eip + 0x13, ex.disc_count); + xe::store_and_swap(eip + 0x14, ex.savegame_id); // Prepare the module for execution. // Runtime takes ownership. diff --git a/src/xenia/kernel/user_profile.h b/src/xenia/kernel/user_profile.h index c831e9b85..b7fdfe7d3 100644 --- a/src/xenia/kernel/user_profile.h +++ b/src/xenia/kernel/user_profile.h @@ -51,8 +51,8 @@ class UserProfile { virtual size_t extra_size() const { return 0; } virtual size_t Append(uint8_t* user_data, uint8_t* buffer, size_t buffer_offset) { - poly::store_and_swap(user_data + kTypeOffset, - static_cast(type)); + xe::store_and_swap(user_data + kTypeOffset, + static_cast(type)); return buffer_offset; } bool is_title_specific() const { return (setting_id & 0x3F00) == 0x3F00; } @@ -69,7 +69,7 @@ class UserProfile { size_t Append(uint8_t* user_data, uint8_t* buffer, size_t buffer_offset) override { buffer_offset = Setting::Append(user_data, buffer, buffer_offset); - poly::store_and_swap(user_data + kValueOffset, value); + xe::store_and_swap(user_data + kValueOffset, value); return buffer_offset; } }; @@ -80,7 +80,7 @@ class UserProfile { size_t Append(uint8_t* user_data, uint8_t* buffer, size_t buffer_offset) override { buffer_offset = Setting::Append(user_data, buffer, buffer_offset); - poly::store_and_swap(user_data + kValueOffset, value); + xe::store_and_swap(user_data + kValueOffset, value); return buffer_offset; } }; @@ -91,7 +91,7 @@ class UserProfile { size_t Append(uint8_t* user_data, uint8_t* buffer, size_t buffer_offset) override { buffer_offset = Setting::Append(user_data, buffer, buffer_offset); - poly::store_and_swap(user_data + kValueOffset, value); + xe::store_and_swap(user_data + kValueOffset, value); return buffer_offset; } }; @@ -108,13 +108,13 @@ class UserProfile { int32_t length; if (value.empty()) { length = 0; - poly::store_and_swap(user_data + kValueOffset, 0); - poly::store_and_swap(user_data + kPointerOffset, 0); + xe::store_and_swap(user_data + kValueOffset, 0); + xe::store_and_swap(user_data + kPointerOffset, 0); } else { length = 2 * (static_cast(value.size()) + 1); - poly::store_and_swap(user_data + kValueOffset, length); - poly::store_and_swap(user_data + kPointerOffset, - static_cast(buffer_offset)); + xe::store_and_swap(user_data + kValueOffset, length); + xe::store_and_swap(user_data + kPointerOffset, + static_cast(buffer_offset)); memcpy(buffer + buffer_offset, value.data(), length); } return buffer_offset + length; @@ -127,7 +127,7 @@ class UserProfile { size_t Append(uint8_t* user_data, uint8_t* buffer, size_t buffer_offset) override { buffer_offset = Setting::Append(user_data, buffer, buffer_offset); - poly::store_and_swap(user_data + kValueOffset, value); + xe::store_and_swap(user_data + kValueOffset, value); return buffer_offset; } }; @@ -144,13 +144,13 @@ class UserProfile { int32_t length; if (value.empty()) { length = 0; - poly::store_and_swap(user_data + kValueOffset, 0); - poly::store_and_swap(user_data + kPointerOffset, 0); + xe::store_and_swap(user_data + kValueOffset, 0); + xe::store_and_swap(user_data + kPointerOffset, 0); } else { length = static_cast(value.size()); - poly::store_and_swap(user_data + kValueOffset, length); - poly::store_and_swap(user_data + kPointerOffset, - static_cast(buffer_offset)); + xe::store_and_swap(user_data + kValueOffset, length); + xe::store_and_swap(user_data + kPointerOffset, + static_cast(buffer_offset)); memcpy(buffer + buffer_offset, value.data(), length); } return buffer_offset + length; @@ -163,7 +163,7 @@ class UserProfile { size_t Append(uint8_t* user_data, uint8_t* buffer, size_t buffer_offset) override { buffer_offset = Setting::Append(user_data, buffer, buffer_offset); - poly::store_and_swap(user_data + kValueOffset, value); + xe::store_and_swap(user_data + kValueOffset, value); return buffer_offset; } }; diff --git a/src/xenia/kernel/util/export_table_pre.inc b/src/xenia/kernel/util/export_table_pre.inc index 2321e6a7c..e82aca06a 100644 --- a/src/xenia/kernel/util/export_table_pre.inc +++ b/src/xenia/kernel/util/export_table_pre.inc @@ -19,7 +19,7 @@ * #include "xenia/kernel/util/export_table_post.inc" * export_resolver_->RegisterTable( * "my_module.xex", - * my_module_export_table, poly::countof(my_module_export_table)); + * my_module_export_table, xe::countof(my_module_export_table)); */ diff --git a/src/xenia/kernel/util/shim_utils.h b/src/xenia/kernel/util/shim_utils.h index beb9b3bb5..2bf8ea205 100644 --- a/src/xenia/kernel/util/shim_utils.h +++ b/src/xenia/kernel/util/shim_utils.h @@ -27,16 +27,16 @@ using PPCContext = xe::cpu::frontend::PPCContext; #define SHIM_MEM_BASE ppc_state->virtual_membase #define SHIM_MEM_ADDR(a) (a ? (ppc_state->virtual_membase + a) : nullptr) -#define SHIM_MEM_8(a) poly::load_and_swap(SHIM_MEM_ADDR(a)) -#define SHIM_MEM_16(a) poly::load_and_swap(SHIM_MEM_ADDR(a)) -#define SHIM_MEM_32(a) poly::load_and_swap(SHIM_MEM_ADDR(a)) -#define SHIM_MEM_64(a) poly::load_and_swap(SHIM_MEM_ADDR(a)) -#define SHIM_SET_MEM_8(a, v) poly::store_and_swap(SHIM_MEM_ADDR(a), v) -#define SHIM_SET_MEM_16(a, v) poly::store_and_swap(SHIM_MEM_ADDR(a), v) -#define SHIM_SET_MEM_32(a, v) poly::store_and_swap(SHIM_MEM_ADDR(a), v) -#define SHIM_SET_MEM_64(a, v) poly::store_and_swap(SHIM_MEM_ADDR(a), v) -#define SHIM_SET_MEM_F32(a, v) poly::store_and_swap(SHIM_MEM_ADDR(a), v) -#define SHIM_SET_MEM_F64(a, v) poly::store_and_swap(SHIM_MEM_ADDR(a), v) +#define SHIM_MEM_8(a) xe::load_and_swap(SHIM_MEM_ADDR(a)) +#define SHIM_MEM_16(a) xe::load_and_swap(SHIM_MEM_ADDR(a)) +#define SHIM_MEM_32(a) xe::load_and_swap(SHIM_MEM_ADDR(a)) +#define SHIM_MEM_64(a) xe::load_and_swap(SHIM_MEM_ADDR(a)) +#define SHIM_SET_MEM_8(a, v) xe::store_and_swap(SHIM_MEM_ADDR(a), v) +#define SHIM_SET_MEM_16(a, v) xe::store_and_swap(SHIM_MEM_ADDR(a), v) +#define SHIM_SET_MEM_32(a, v) xe::store_and_swap(SHIM_MEM_ADDR(a), v) +#define SHIM_SET_MEM_64(a, v) xe::store_and_swap(SHIM_MEM_ADDR(a), v) +#define SHIM_SET_MEM_F32(a, v) xe::store_and_swap(SHIM_MEM_ADDR(a), v) +#define SHIM_SET_MEM_F64(a, v) xe::store_and_swap(SHIM_MEM_ADDR(a), v) #define SHIM_GPR_8(n) (uint8_t)(ppc_state->r[n]) #define SHIM_GPR_16(n) (uint16_t)(ppc_state->r[n]) diff --git a/src/xenia/kernel/util/xex2.cc b/src/xenia/kernel/util/xex2.cc index bd03dd6bb..c2dfcb40b 100644 --- a/src/xenia/kernel/util/xex2.cc +++ b/src/xenia/kernel/util/xex2.cc @@ -21,10 +21,10 @@ #include "third_party/mspack/mspack.h" #include "third_party/pe/pe_image.h" -#include "poly/math.h" -#include "poly/memory.h" -#include "poly/platform.h" -#include "xenia/logging.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" +#include "xenia/base/memory.h" +#include "xenia/base/platform.h" // TODO(benvanik): remove. #define XEEXPECTZERO(expr) \ @@ -124,22 +124,22 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, const uint8_t *ps; xe_xex2_loader_info_t *ldr; - header->xex2 = poly::load_and_swap(p + 0x00); + header->xex2 = xe::load_and_swap(p + 0x00); if (header->xex2 != 0x58455832) { return 1; } header->module_flags = - (xe_xex2_module_flags)poly::load_and_swap(p + 0x04); - header->exe_offset = poly::load_and_swap(p + 0x08); - header->unknown0 = poly::load_and_swap(p + 0x0C); - header->certificate_offset = poly::load_and_swap(p + 0x10); - header->header_count = poly::load_and_swap(p + 0x14); + (xe_xex2_module_flags)xe::load_and_swap(p + 0x04); + header->exe_offset = xe::load_and_swap(p + 0x08); + header->unknown0 = xe::load_and_swap(p + 0x0C); + header->certificate_offset = xe::load_and_swap(p + 0x10); + header->header_count = xe::load_and_swap(p + 0x14); for (size_t n = 0; n < header->header_count; n++) { const uint8_t *ph = p + 0x18 + (n * 8); - const uint32_t key = poly::load_and_swap(ph + 0x00); - const uint32_t data_offset = poly::load_and_swap(ph + 0x04); + const uint32_t key = xe::load_and_swap(ph + 0x00); + const uint32_t data_offset = xe::load_and_swap(ph + 0x04); xe_xex2_opt_header_t *opt_header = &header->headers[n]; opt_header->key = key; @@ -151,7 +151,7 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, break; case 0xFF: // dataOffset = offset (first dword in data is size) - opt_header->length = poly::load_and_swap(p + data_offset); + opt_header->length = xe::load_and_swap(p + data_offset); opt_header->offset = data_offset; break; default: @@ -174,61 +174,56 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, for (size_t m = 0; m < header->resource_info_count; m++) { auto &res = header->resource_infos[m]; memcpy(res.name, phi + 0x00, 8); - res.address = poly::load_and_swap(phi + 0x08); - res.size = poly::load_and_swap(phi + 0x0C); + res.address = xe::load_and_swap(phi + 0x08); + res.size = xe::load_and_swap(phi + 0x0C); phi += 16; } } break; case XEX_HEADER_EXECUTION_INFO: { xe_xex2_execution_info_t *ex = &header->execution_info; - ex->media_id = poly::load_and_swap(pp + 0x00); - ex->version.value = poly::load_and_swap(pp + 0x04); - ex->base_version.value = poly::load_and_swap(pp + 0x08); - ex->title_id = poly::load_and_swap(pp + 0x0C); - ex->platform = poly::load_and_swap(pp + 0x10); - ex->executable_table = poly::load_and_swap(pp + 0x11); - ex->disc_number = poly::load_and_swap(pp + 0x12); - ex->disc_count = poly::load_and_swap(pp + 0x13); - ex->savegame_id = poly::load_and_swap(pp + 0x14); + ex->media_id = xe::load_and_swap(pp + 0x00); + ex->version.value = xe::load_and_swap(pp + 0x04); + ex->base_version.value = xe::load_and_swap(pp + 0x08); + ex->title_id = xe::load_and_swap(pp + 0x0C); + ex->platform = xe::load_and_swap(pp + 0x10); + ex->executable_table = xe::load_and_swap(pp + 0x11); + ex->disc_number = xe::load_and_swap(pp + 0x12); + ex->disc_count = xe::load_and_swap(pp + 0x13); + ex->savegame_id = xe::load_and_swap(pp + 0x14); } break; case XEX_HEADER_GAME_RATINGS: { xe_xex2_game_ratings_t *ratings = &header->game_ratings; ratings->esrb = - (xe_xex2_rating_esrb_value)poly::load_and_swap(pp + 0x00); + (xe_xex2_rating_esrb_value)xe::load_and_swap(pp + 0x00); ratings->pegi = - (xe_xex2_rating_pegi_value)poly::load_and_swap(pp + 0x01); + (xe_xex2_rating_pegi_value)xe::load_and_swap(pp + 0x01); ratings->pegifi = - (xe_xex2_rating_pegi_fi_value)poly::load_and_swap(pp + - 0x02); + (xe_xex2_rating_pegi_fi_value)xe::load_and_swap(pp + 0x02); ratings->pegipt = - (xe_xex2_rating_pegi_pt_value)poly::load_and_swap(pp + - 0x03); + (xe_xex2_rating_pegi_pt_value)xe::load_and_swap(pp + 0x03); ratings->bbfc = - (xe_xex2_rating_bbfc_value)poly::load_and_swap(pp + 0x04); + (xe_xex2_rating_bbfc_value)xe::load_and_swap(pp + 0x04); ratings->cero = - (xe_xex2_rating_cero_value)poly::load_and_swap(pp + 0x05); + (xe_xex2_rating_cero_value)xe::load_and_swap(pp + 0x05); ratings->usk = - (xe_xex2_rating_usk_value)poly::load_and_swap(pp + 0x06); + (xe_xex2_rating_usk_value)xe::load_and_swap(pp + 0x06); ratings->oflcau = - (xe_xex2_rating_oflc_au_value)poly::load_and_swap(pp + - 0x07); + (xe_xex2_rating_oflc_au_value)xe::load_and_swap(pp + 0x07); ratings->oflcnz = - (xe_xex2_rating_oflc_nz_value)poly::load_and_swap(pp + - 0x08); + (xe_xex2_rating_oflc_nz_value)xe::load_and_swap(pp + 0x08); ratings->kmrb = - (xe_xex2_rating_kmrb_value)poly::load_and_swap(pp + 0x09); + (xe_xex2_rating_kmrb_value)xe::load_and_swap(pp + 0x09); ratings->brazil = - (xe_xex2_rating_brazil_value)poly::load_and_swap(pp + - 0x0A); + (xe_xex2_rating_brazil_value)xe::load_and_swap(pp + 0x0A); ratings->fpb = - (xe_xex2_rating_fpb_value)poly::load_and_swap(pp + 0x0B); + (xe_xex2_rating_fpb_value)xe::load_and_swap(pp + 0x0B); } break; case XEX_HEADER_TLS_INFO: { xe_xex2_tls_info_t *tls = &header->tls_info; - tls->slot_count = poly::load_and_swap(pp + 0x00); - tls->raw_data_address = poly::load_and_swap(pp + 0x04); - tls->data_size = poly::load_and_swap(pp + 0x08); - tls->raw_data_size = poly::load_and_swap(pp + 0x0C); + tls->slot_count = xe::load_and_swap(pp + 0x00); + tls->raw_data_address = xe::load_and_swap(pp + 0x04); + tls->data_size = xe::load_and_swap(pp + 0x08); + tls->raw_data_size = xe::load_and_swap(pp + 0x0C); } break; case XEX_HEADER_IMAGE_BASE_ADDRESS: header->exe_address = opt_header->value; @@ -243,8 +238,8 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, header->exe_heap_size = opt_header->value; break; case XEX_HEADER_IMPORT_LIBRARIES: { - const size_t max_count = poly::countof(header->import_libraries); - size_t count = poly::load_and_swap(pp + 0x08); + const size_t max_count = xe::countof(header->import_libraries); + size_t count = xe::load_and_swap(pp + 0x08); assert_true(count <= max_count); if (count > max_count) { XELOGW("ignoring %zu extra entries in XEX_HEADER_IMPORT_LIBRARIES", @@ -253,24 +248,24 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, } header->import_library_count = count; - uint32_t string_table_size = poly::load_and_swap(pp + 0x04); + uint32_t string_table_size = xe::load_and_swap(pp + 0x04); const char *string_table = (const char *)(pp + 0x0C); pp += 12 + string_table_size; for (size_t m = 0; m < count; m++) { xe_xex2_import_library_t *library = &header->import_libraries[m]; memcpy(library->digest, pp + 0x04, 20); - library->import_id = poly::load_and_swap(pp + 0x18); - library->version.value = poly::load_and_swap(pp + 0x1C); - library->min_version.value = poly::load_and_swap(pp + 0x20); + library->import_id = xe::load_and_swap(pp + 0x18); + library->version.value = xe::load_and_swap(pp + 0x1C); + library->min_version.value = xe::load_and_swap(pp + 0x20); const uint16_t name_index = - poly::load_and_swap(pp + 0x24) & 0xFF; + xe::load_and_swap(pp + 0x24) & 0xFF; for (size_t i = 0, j = 0; i < string_table_size;) { assert_true(j <= 0xFF); if (j == name_index) { std::strncpy(library->name, string_table + i, - poly::countof(library->name)); + xe::countof(library->name)); break; } if (string_table[i] == 0) { @@ -284,19 +279,19 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, } } - library->record_count = poly::load_and_swap(pp + 0x26); + library->record_count = xe::load_and_swap(pp + 0x26); library->records = (uint32_t *)calloc(library->record_count, sizeof(uint32_t)); XEEXPECTNOTNULL(library->records); pp += 0x28; for (size_t i = 0; i < library->record_count; i++) { - library->records[i] = poly::load_and_swap(pp); + library->records[i] = xe::load_and_swap(pp); pp += 4; } } } break; case XEX_HEADER_STATIC_LIBRARIES: { - const size_t max_count = poly::countof(header->static_libraries); + const size_t max_count = xe::countof(header->static_libraries); size_t count = (opt_header->length - 4) / 16; assert_true(count <= max_count); if (count > max_count) { @@ -310,10 +305,10 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, xe_xex2_static_library_t *library = &header->static_libraries[m]; memcpy(library->name, pp + 0x00, 8); library->name[8] = 0; - library->major = poly::load_and_swap(pp + 0x08); - library->minor = poly::load_and_swap(pp + 0x0A); - library->build = poly::load_and_swap(pp + 0x0C); - uint16_t qfeapproval = poly::load_and_swap(pp + 0x0E); + library->major = xe::load_and_swap(pp + 0x08); + library->minor = xe::load_and_swap(pp + 0x0A); + library->build = xe::load_and_swap(pp + 0x0C); + uint16_t qfeapproval = xe::load_and_swap(pp + 0x0E); library->approval = (xe_xex2_approval_type)(qfeapproval & 0x8000); library->qfe = qfeapproval & ~0x8000; pp += 16; @@ -322,9 +317,9 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, case XEX_HEADER_FILE_FORMAT_INFO: { xe_xex2_file_format_info_t *fmt = &header->file_format_info; fmt->encryption_type = - (xe_xex2_encryption_type)poly::load_and_swap(pp + 0x04); + (xe_xex2_encryption_type)xe::load_and_swap(pp + 0x04); fmt->compression_type = - (xe_xex2_compression_type)poly::load_and_swap(pp + 0x06); + (xe_xex2_compression_type)xe::load_and_swap(pp + 0x06); switch (fmt->compression_type) { case XEX_COMPRESSION_NONE: // TODO: XEX_COMPRESSION_NONE @@ -333,7 +328,7 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, case XEX_COMPRESSION_BASIC: { xe_xex2_file_basic_compression_info_t *comp_info = &fmt->compression_info.basic; - uint32_t info_size = poly::load_and_swap(pp + 0x00); + uint32_t info_size = xe::load_and_swap(pp + 0x00); comp_info->block_count = (info_size - 8) / 8; comp_info->blocks = (xe_xex2_file_basic_compression_block_t *)calloc( @@ -344,15 +339,15 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, xe_xex2_file_basic_compression_block_t *block = &comp_info->blocks[m]; block->data_size = - poly::load_and_swap(pp + 0x08 + (m * 8)); + xe::load_and_swap(pp + 0x08 + (m * 8)); block->zero_size = - poly::load_and_swap(pp + 0x0C + (m * 8)); + xe::load_and_swap(pp + 0x0C + (m * 8)); } } break; case XEX_COMPRESSION_NORMAL: { xe_xex2_file_normal_compression_info_t *comp_info = &fmt->compression_info.normal; - uint32_t window_size = poly::load_and_swap(pp + 0x08); + uint32_t window_size = xe::load_and_swap(pp + 0x08); uint32_t window_bits = 0; for (size_t m = 0; m < 32; m++, window_bits++) { window_size <<= 1; @@ -360,9 +355,9 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, break; } } - comp_info->window_size = poly::load_and_swap(pp + 0x08); + comp_info->window_size = xe::load_and_swap(pp + 0x08); comp_info->window_bits = window_bits; - comp_info->block_size = poly::load_and_swap(pp + 0x0C); + comp_info->block_size = xe::load_and_swap(pp + 0x0C); memcpy(comp_info->block_hash, pp + 0x10, 20); } break; case XEX_COMPRESSION_DELTA: @@ -377,28 +372,28 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, // Loader info. pc = p + header->certificate_offset; ldr = &header->loader_info; - ldr->header_size = poly::load_and_swap(pc + 0x000); - ldr->image_size = poly::load_and_swap(pc + 0x004); + ldr->header_size = xe::load_and_swap(pc + 0x000); + ldr->image_size = xe::load_and_swap(pc + 0x004); memcpy(ldr->rsa_signature, pc + 0x008, 256); - ldr->unklength = poly::load_and_swap(pc + 0x108); + ldr->unklength = xe::load_and_swap(pc + 0x108); ldr->image_flags = - (xe_xex2_image_flags)poly::load_and_swap(pc + 0x10C); - ldr->load_address = poly::load_and_swap(pc + 0x110); + (xe_xex2_image_flags)xe::load_and_swap(pc + 0x10C); + ldr->load_address = xe::load_and_swap(pc + 0x110); memcpy(ldr->section_digest, pc + 0x114, 20); - ldr->import_table_count = poly::load_and_swap(pc + 0x128); + ldr->import_table_count = xe::load_and_swap(pc + 0x128); memcpy(ldr->import_table_digest, pc + 0x12C, 20); memcpy(ldr->media_id, pc + 0x140, 16); memcpy(ldr->file_key, pc + 0x150, 16); - ldr->export_table = poly::load_and_swap(pc + 0x160); + ldr->export_table = xe::load_and_swap(pc + 0x160); memcpy(ldr->header_digest, pc + 0x164, 20); ldr->game_regions = - (xe_xex2_region_flags)poly::load_and_swap(pc + 0x178); + (xe_xex2_region_flags)xe::load_and_swap(pc + 0x178); ldr->media_flags = - (xe_xex2_media_flags)poly::load_and_swap(pc + 0x17C); + (xe_xex2_media_flags)xe::load_and_swap(pc + 0x17C); // Section info follows loader info. ps = p + header->certificate_offset + 0x180; - header->section_count = poly::load_and_swap(ps + 0x000); + header->section_count = xe::load_and_swap(ps + 0x000); ps += 4; header->sections = (xe_xex2_section_t *)calloc(header->section_count, sizeof(xe_xex2_section_t)); @@ -407,7 +402,7 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, xe_xex2_section_t *section = &header->sections[n]; section->page_size = header->exe_address <= 0x90000000 ? 64 * 1024 : 4 * 1024; - section->info.value = poly::load_and_swap(ps); + section->info.value = xe::load_and_swap(ps); ps += 4; memcpy(section->digest, ps, sizeof(section->digest)); ps += sizeof(section->digest); @@ -701,7 +696,7 @@ int xe_xex2_read_image_compressed(const xe_xex2_header_t *header, block_size = header->file_format_info.compression_info.normal.block_size; while (block_size) { const uint8_t *pnext = p + block_size; - const size_t next_size = poly::load_and_swap(p); + const size_t next_size = xe::load_and_swap(p); p += 4; p += 20; // skip 20b hash @@ -915,7 +910,7 @@ int xe_xex2_find_import_infos(xe_xex2_ref xex, for (size_t n = 0; n < library->record_count; n++) { const uint32_t record = library->records[n]; const uint32_t value = - poly::load_and_swap(xex->memory->TranslateVirtual(record)); + xe::load_and_swap(xex->memory->TranslateVirtual(record)); if (value & 0xFF000000) { // Thunk for previous record - ignore. } else { @@ -935,7 +930,7 @@ int xe_xex2_find_import_infos(xe_xex2_ref xex, for (size_t n = 0, i = 0; n < library->record_count; n++) { const uint32_t record = library->records[n]; const uint32_t value = - poly::load_and_swap(xex->memory->TranslateVirtual(record)); + xe::load_and_swap(xex->memory->TranslateVirtual(record)); const uint32_t type = (value & 0xFF000000) >> 24; // Verify library index matches given library. diff --git a/src/xenia/kernel/xam_content.cc b/src/xenia/kernel/xam_content.cc index fcc73c950..aac8178fc 100644 --- a/src/xenia/kernel/xam_content.cc +++ b/src/xenia/kernel/xam_content.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xenumerator.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -101,8 +101,8 @@ SHIM_CALL XamContentGetDeviceName_shim(PPCContext* ppc_state, return; } - poly::store_and_swap(SHIM_MEM_ADDR(name_ptr), - dummy_device_info_.name); + xe::store_and_swap(SHIM_MEM_ADDR(name_ptr), + dummy_device_info_.name); SHIM_SET_RETURN_32(X_ERROR_SUCCESS); } @@ -153,8 +153,8 @@ SHIM_CALL XamContentGetDeviceData_shim(PPCContext* ppc_state, SHIM_SET_MEM_32(device_data_ptr + 4, device_info.device_type); SHIM_SET_MEM_64(device_data_ptr + 8, device_info.total_bytes); SHIM_SET_MEM_64(device_data_ptr + 16, device_info.free_bytes); - poly::store_and_swap(SHIM_MEM_ADDR(device_data_ptr + 24), - device_info.name); + xe::store_and_swap(SHIM_MEM_ADDR(device_data_ptr + 24), + device_info.name); SHIM_SET_RETURN_32(X_ERROR_SUCCESS); } @@ -324,8 +324,7 @@ SHIM_CALL XamContentCreate_shim(PPCContext* ppc_state, KernelState* state) { uint32_t license_mask_ptr = SHIM_GET_ARG_32(5); uint32_t overlapped_ptr = SHIM_GET_ARG_32(6); - auto root_name = - poly::load_and_swap(SHIM_MEM_ADDR(root_name_ptr)); + auto root_name = xe::load_and_swap(SHIM_MEM_ADDR(root_name_ptr)); auto content_data = XCONTENT_DATA(SHIM_MEM_ADDR(content_data_ptr)); XELOGD("XamContentCreate(%d, %.8X(%s), %.8X, %.8X, %.8X, %.8X, %.8X)", @@ -349,8 +348,7 @@ SHIM_CALL XamContentCreateEx_shim(PPCContext* ppc_state, KernelState* state) { uint32_t sp = (uint32_t)ppc_state->r[1]; uint32_t overlapped_ptr = SHIM_MEM_32(sp + 0x54); - auto root_name = - poly::load_and_swap(SHIM_MEM_ADDR(root_name_ptr)); + auto root_name = xe::load_and_swap(SHIM_MEM_ADDR(root_name_ptr)); auto content_data = XCONTENT_DATA(SHIM_MEM_ADDR(content_data_ptr)); XELOGD( @@ -369,8 +367,7 @@ SHIM_CALL XamContentFlush_shim(PPCContext* ppc_state, KernelState* state) { uint32_t root_name_ptr = SHIM_GET_ARG_32(0); uint32_t overlapped_ptr = SHIM_GET_ARG_32(1); - auto root_name = - poly::load_and_swap(SHIM_MEM_ADDR(root_name_ptr)); + auto root_name = xe::load_and_swap(SHIM_MEM_ADDR(root_name_ptr)); XELOGD("XamContentFlush(%.8X(%s), %.8X)", root_name_ptr, root_name.c_str(), overlapped_ptr); @@ -388,8 +385,7 @@ SHIM_CALL XamContentClose_shim(PPCContext* ppc_state, KernelState* state) { uint32_t root_name_ptr = SHIM_GET_ARG_32(0); uint32_t overlapped_ptr = SHIM_GET_ARG_32(1); - auto root_name = - poly::load_and_swap(SHIM_MEM_ADDR(root_name_ptr)); + auto root_name = xe::load_and_swap(SHIM_MEM_ADDR(root_name_ptr)); XELOGD("XamContentClose(%.8X(%s), %.8X)", root_name_ptr, root_name.c_str(), overlapped_ptr); diff --git a/src/xenia/kernel/xam_info.cc b/src/xenia/kernel/xam_info.cc index f6cbe23b1..d42361bff 100644 --- a/src/xenia/kernel/xam_info.cc +++ b/src/xenia/kernel/xam_info.cc @@ -7,13 +7,13 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xenumerator.h" #include "xenia/kernel/objects/xuser_module.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/util/xex2.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xam_input.cc b/src/xenia/kernel/xam_input.cc index ebb17ec1c..526565923 100644 --- a/src/xenia/kernel/xam_input.cc +++ b/src/xenia/kernel/xam_input.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/emulator.h" #include "xenia/hid/hid.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xam_module.cc b/src/xenia/kernel/xam_module.cc index f5b2f4607..4237b2e6c 100644 --- a/src/xenia/kernel/xam_module.cc +++ b/src/xenia/kernel/xam_module.cc @@ -9,7 +9,7 @@ #include "xenia/kernel/xam_module.h" -#include "poly/math.h" +#include "xenia/base/math.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/xam_private.h" @@ -47,7 +47,7 @@ void XamModule::RegisterExportTable(xe::cpu::ExportResolver* export_resolver) { }; #include "xenia/kernel/util/export_table_post.inc" export_resolver->RegisterTable("xam.xex", xam_export_table, - poly::countof(xam_export_table)); + xe::countof(xam_export_table)); } XamModule::~XamModule() {} diff --git a/src/xenia/kernel/xam_msg.cc b/src/xenia/kernel/xam_msg.cc index 15f8dc39b..deb355f25 100644 --- a/src/xenia/kernel/xam_msg.cc +++ b/src/xenia/kernel/xam_msg.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xam_net.cc b/src/xenia/kernel/xam_net.cc index d88308eea..c8e9b7815 100644 --- a/src/xenia/kernel/xam_net.cc +++ b/src/xenia/kernel/xam_net.cc @@ -10,23 +10,23 @@ #define _WINSOCK_DEPRECATED_NO_WARNINGS // inet_addr #include +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { namespace kernel { void LoadSockaddr(const uint8_t* ptr, sockaddr* out_addr) { - out_addr->sa_family = poly::load_and_swap(ptr + 0); + out_addr->sa_family = xe::load_and_swap(ptr + 0); switch (out_addr->sa_family) { case AF_INET: { auto in_addr = reinterpret_cast(out_addr); - in_addr->sin_port = poly::load_and_swap(ptr + 2); + in_addr->sin_port = xe::load_and_swap(ptr + 2); // Maybe? Depends on type. - in_addr->sin_addr.S_un.S_addr = poly::load_and_swap(ptr + 4); + in_addr->sin_addr.S_un.S_addr = xe::load_and_swap(ptr + 4); break; } default: @@ -42,10 +42,10 @@ void StoreSockaddr(const sockaddr& addr, uint8_t* ptr) { break; case AF_INET: { auto& in_addr = reinterpret_cast(addr); - poly::store_and_swap(ptr + 0, in_addr.sin_family); - poly::store_and_swap(ptr + 2, in_addr.sin_port); + xe::store_and_swap(ptr + 0, in_addr.sin_family); + xe::store_and_swap(ptr + 2, in_addr.sin_port); // Maybe? Depends on type. - poly::store_and_swap(ptr + 4, in_addr.sin_addr.S_un.S_addr); + xe::store_and_swap(ptr + 4, in_addr.sin_addr.S_un.S_addr); break; } default: @@ -256,21 +256,21 @@ SHIM_CALL NetDll_accept_shim(PPCContext* ppc_state, KernelState* state) { } void LoadFdset(const uint8_t* src, fd_set* dest) { - dest->fd_count = poly::load_and_swap(src); + dest->fd_count = xe::load_and_swap(src); for (int i = 0; i < 64; ++i) { auto socket_handle = - static_cast(poly::load_and_swap(src + 4 + i * 4)); + static_cast(xe::load_and_swap(src + 4 + i * 4)); dest->fd_array[i] = socket_handle; } } void StoreFdset(const fd_set& src, uint8_t* dest) { - poly::store_and_swap(dest, src.fd_count); + xe::store_and_swap(dest, src.fd_count); for (int i = 0; i < 64; ++i) { SOCKET socket_handle = src.fd_array[i]; assert_true(socket_handle >> 32 == 0); - poly::store_and_swap(dest + 4 + i * 4, - static_cast(socket_handle)); + xe::store_and_swap(dest + 4 + i * 4, + static_cast(socket_handle)); } } diff --git a/src/xenia/kernel/xam_notify.cc b/src/xenia/kernel/xam_notify.cc index 84c65e69d..6cf67085e 100644 --- a/src/xenia/kernel/xam_notify.cc +++ b/src/xenia/kernel/xam_notify.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xnotify_listener.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xam_ui.cc b/src/xenia/kernel/xam_ui.cc index 5ab16d614..ebd24b513 100644 --- a/src/xenia/kernel/xam_ui.cc +++ b/src/xenia/kernel/xam_ui.cc @@ -7,10 +7,10 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -30,13 +30,13 @@ SHIM_CALL XamShowMessageBoxUI_shim(PPCContext* ppc_state, KernelState* state) { uint32_t sp = (uint32_t)ppc_state->r[1]; uint32_t overlapped_ptr = SHIM_MEM_32(sp + 0x54); - auto title = poly::load_and_swap(SHIM_MEM_ADDR(title_ptr)); - auto text = poly::load_and_swap(SHIM_MEM_ADDR(text_ptr)); + auto title = xe::load_and_swap(SHIM_MEM_ADDR(title_ptr)); + auto text = xe::load_and_swap(SHIM_MEM_ADDR(text_ptr)); std::vector buttons; std::wstring all_buttons; for (uint32_t j = 0; j < button_count; ++j) { uint32_t button_ptr = SHIM_MEM_32(button_ptrs + j * 4); - auto button = poly::load_and_swap(SHIM_MEM_ADDR(button_ptr)); + auto button = xe::load_and_swap(SHIM_MEM_ADDR(button_ptr)); all_buttons.append(button); if (j + 1 < button_count) { all_buttons.append(L" | "); diff --git a/src/xenia/kernel/xam_user.cc b/src/xenia/kernel/xam_user.cc index ec421a109..25f1c46cf 100644 --- a/src/xenia/kernel/xam_user.cc +++ b/src/xenia/kernel/xam_user.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xenumerator.h" #include "xenia/kernel/objects/xthread.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xam_voice.cc b/src/xenia/kernel/xam_voice.cc index f72dad1a8..45f914bfd 100644 --- a/src/xenia/kernel/xam_voice.cc +++ b/src/xenia/kernel/xam_voice.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/emulator.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_audio.cc b/src/xenia/kernel/xboxkrnl_audio.cc index 1ab702bd0..e489c048c 100644 --- a/src/xenia/kernel/xboxkrnl_audio.cc +++ b/src/xenia/kernel/xboxkrnl_audio.cc @@ -8,11 +8,11 @@ */ #include "xenia/apu/apu.h" +#include "xenia/base/logging.h" #include "xenia/emulator.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_audio_xma.cc b/src/xenia/kernel/xboxkrnl_audio_xma.cc index 86b10a6f6..708af52d6 100644 --- a/src/xenia/kernel/xboxkrnl_audio_xma.cc +++ b/src/xenia/kernel/xboxkrnl_audio_xma.cc @@ -8,11 +8,11 @@ */ #include "xenia/apu/apu.h" +#include "xenia/base/logging.h" #include "xenia/emulator.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -138,15 +138,15 @@ struct XMAContextData { uint32_t unk_dword_9 : 27; XMAContextData(const void* ptr) { - poly::copy_and_swap_32_aligned(reinterpret_cast(this), - reinterpret_cast(ptr), - sizeof(XMAContextData) / 4); + xe::copy_and_swap_32_aligned(reinterpret_cast(this), + reinterpret_cast(ptr), + sizeof(XMAContextData) / 4); } void Store(void* ptr) { - poly::copy_and_swap_32_aligned(reinterpret_cast(ptr), - reinterpret_cast(this), - sizeof(XMAContextData) / 4); + xe::copy_and_swap_32_aligned(reinterpret_cast(ptr), + reinterpret_cast(this), + sizeof(XMAContextData) / 4); } }; static_assert(sizeof(XMAContextData) == 4 * 10, "Must be packed"); @@ -158,8 +158,8 @@ void StoreXmaContextIndexedRegister(KernelState* state, uint32_t base_reg, XMAContextData::kSize; uint32_t reg_num = base_reg + (hw_index >> 5) * 4; uint32_t reg_value = 1 << (hw_index & 0x1F); - poly::store(state->memory()->TranslateVirtual(0x7FEA0000 + reg_num), - reg_value); + xe::store(state->memory()->TranslateVirtual(0x7FEA0000 + reg_num), + reg_value); } SHIM_CALL XMAInitializeContext_shim(PPCContext* ppc_state, KernelState* state) { diff --git a/src/xenia/kernel/xboxkrnl_debug.cc b/src/xenia/kernel/xboxkrnl_debug.cc index 318bc1610..3abc3c5c7 100644 --- a/src/xenia/kernel/xboxkrnl_debug.cc +++ b/src/xenia/kernel/xboxkrnl_debug.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xthread.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_hal.cc b/src/xenia/kernel/xboxkrnl_hal.cc index 4d022fdfd..9b13f98f0 100644 --- a/src/xenia/kernel/xboxkrnl_hal.cc +++ b/src/xenia/kernel/xboxkrnl_hal.cc @@ -7,10 +7,10 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl_io.cc index 486890b13..f9a747577 100644 --- a/src/xenia/kernel/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl_io.cc @@ -7,14 +7,14 @@ ****************************************************************************** */ -#include "poly/memory.h" +#include "xenia/base/logging.h" +#include "xenia/base/memory.h" #include "xenia/kernel/async_request.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/objects/xfile.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -32,14 +32,14 @@ class X_OBJECT_ATTRIBUTES { X_OBJECT_ATTRIBUTES() { Zero(); } X_OBJECT_ATTRIBUTES(const uint8_t* base, uint32_t p) { Read(base, p); } void Read(const uint8_t* base, uint32_t p) { - root_directory = poly::load_and_swap(base + p); - object_name_ptr = poly::load_and_swap(base + p + 4); + root_directory = xe::load_and_swap(base + p); + object_name_ptr = xe::load_and_swap(base + p + 4); if (object_name_ptr) { object_name.Read(base, object_name_ptr); } else { object_name.Zero(); } - attributes = poly::load_and_swap(base + p + 8); + attributes = xe::load_and_swap(base + p + 8); } void Zero() { root_directory = 0; @@ -472,7 +472,7 @@ SHIM_CALL NtQueryInformationFile_shim(PPCContext* ppc_state, info = 8; // TODO(benvanik): use pointer to fs:: entry? SHIM_SET_MEM_64(file_info_ptr, - poly::hash_combine(0, file->absolute_path())); + xe::hash_combine(0, file->absolute_path())); break; case XFilePositionInformation: // struct FILE_POSITION_INFORMATION { @@ -511,7 +511,7 @@ SHIM_CALL NtQueryInformationFile_shim(PPCContext* ppc_state, if (bytes_read == sizeof(magic)) { info = 4; SHIM_SET_MEM_32(file_info_ptr, - magic == poly::byte_swap(0x0FF512ED)); + magic == xe::byte_swap(0x0FF512ED)); } else { result = X_STATUS_UNSUCCESSFUL; } diff --git a/src/xenia/kernel/xboxkrnl_memory.cc b/src/xenia/kernel/xboxkrnl_memory.cc index f3050d690..c9e64a4b6 100644 --- a/src/xenia/kernel/xboxkrnl_memory.cc +++ b/src/xenia/kernel/xboxkrnl_memory.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ -#include "poly/math.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -232,8 +232,8 @@ SHIM_CALL MmAllocatePhysicalMemoryEx_shim(PPCContext* ppc_state, } // Round up the region size and alignment to the next page. - uint32_t adjusted_size = poly::round_up(region_size, page_size); - uint32_t adjusted_alignment = poly::round_up(alignment, page_size); + uint32_t adjusted_size = xe::round_up(region_size, page_size); + uint32_t adjusted_alignment = xe::round_up(alignment, page_size); // Callers can pick an address to allocate with min_addr_range/max_addr_range // and the memory must be allocated there. I haven't seen a game do this, @@ -416,7 +416,7 @@ SHIM_CALL ExAllocatePoolTypeWithTag_shim(PPCContext* ppc_state, uint32_t alignment = 8; uint32_t adjusted_size = size; if (adjusted_size < 4 * 1024) { - adjusted_size = poly::round_up(adjusted_size, 4 * 1024); + adjusted_size = xe::round_up(adjusted_size, 4 * 1024); } else { alignment = 4 * 1024; } diff --git a/src/xenia/kernel/xboxkrnl_misc.cc b/src/xenia/kernel/xboxkrnl_misc.cc index 44e6f5608..17ee8f2b7 100644 --- a/src/xenia/kernel/xboxkrnl_misc.cc +++ b/src/xenia/kernel/xboxkrnl_misc.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xthread.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_module.cc b/src/xenia/kernel/xboxkrnl_module.cc index 5fb661c82..6ed43924e 100644 --- a/src/xenia/kernel/xboxkrnl_module.cc +++ b/src/xenia/kernel/xboxkrnl_module.cc @@ -10,12 +10,13 @@ #include "xenia/kernel/xboxkrnl_module.h" #include -#include "poly/math.h" + +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/emulator.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/xboxkrnl_private.h" #include "xenia/kernel/objects/xuser_module.h" -#include "xenia/logging.h" DEFINE_bool(abort_before_entry, false, "Abort execution right before launching the module."); @@ -52,7 +53,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) auto lpKeDebugMonitorData = memory_->TranslateVirtual(pKeDebugMonitorData); export_resolver_->SetVariableMapping( "xboxkrnl.exe", ordinals::KeDebugMonitorData, pKeDebugMonitorData); - poly::store_and_swap(lpKeDebugMonitorData, 0); + xe::store_and_swap(lpKeDebugMonitorData, 0); // KeCertMonitorData (?*) // Always set to zero, ignored. @@ -60,7 +61,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) auto lpKeCertMonitorData = memory_->TranslateVirtual(pKeCertMonitorData); export_resolver_->SetVariableMapping( "xboxkrnl.exe", ordinals::KeCertMonitorData, pKeCertMonitorData); - poly::store_and_swap(lpKeCertMonitorData, 0); + xe::store_and_swap(lpKeCertMonitorData, 0); // XboxHardwareInfo (XboxHardwareInfo_t, 16b) // flags cpu# ? ? ? ? ? ? @@ -74,8 +75,8 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) auto lpXboxHardwareInfo = memory_->TranslateVirtual(pXboxHardwareInfo); export_resolver_->SetVariableMapping( "xboxkrnl.exe", ordinals::XboxHardwareInfo, pXboxHardwareInfo); - poly::store_and_swap(lpXboxHardwareInfo + 0, 0); // flags - poly::store_and_swap(lpXboxHardwareInfo + 4, 0x06); // cpu count + xe::store_and_swap(lpXboxHardwareInfo + 0, 0); // flags + xe::store_and_swap(lpXboxHardwareInfo + 4, 0x06); // cpu count // Remaining 11b are zeroes? // XexExecutableModuleHandle (?**) @@ -96,10 +97,9 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) uint32_t pXexExecutableModuleHandle = memory_->SystemHeapAlloc(256); auto lpXexExecutableModuleHandle = memory_->TranslateVirtual(pXexExecutableModuleHandle); - poly::store_and_swap(lppXexExecutableModuleHandle, - pXexExecutableModuleHandle); - poly::store_and_swap(lpXexExecutableModuleHandle + 0x58, - 0x80101100); + xe::store_and_swap(lppXexExecutableModuleHandle, + pXexExecutableModuleHandle); + xe::store_and_swap(lpXexExecutableModuleHandle + 0x58, 0x80101100); // ExLoadedCommandLine (char*) // The name of the xex. Not sure this is ever really used on real devices. @@ -111,7 +111,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) "xboxkrnl.exe", ordinals::ExLoadedCommandLine, pExLoadedCommandLine); char command_line[] = "\"default.xex\""; std::memcpy(lpExLoadedCommandLine, command_line, - poly::countof(command_line) + 1); + xe::countof(command_line) + 1); // XboxKrnlVersion (8b) // Kernel version, looks like 2b.2b.2b.2b. @@ -120,11 +120,11 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) auto lpXboxKrnlVersion = memory_->TranslateVirtual(pXboxKrnlVersion); export_resolver_->SetVariableMapping( "xboxkrnl.exe", ordinals::XboxKrnlVersion, pXboxKrnlVersion); - poly::store_and_swap(lpXboxKrnlVersion + 0, 2); - poly::store_and_swap(lpXboxKrnlVersion + 2, 0xFFFF); - poly::store_and_swap(lpXboxKrnlVersion + 4, 0xFFFF); - poly::store_and_swap(lpXboxKrnlVersion + 6, 0x80); - poly::store_and_swap(lpXboxKrnlVersion + 7, 0x00); + xe::store_and_swap(lpXboxKrnlVersion + 0, 2); + xe::store_and_swap(lpXboxKrnlVersion + 2, 0xFFFF); + xe::store_and_swap(lpXboxKrnlVersion + 4, 0xFFFF); + xe::store_and_swap(lpXboxKrnlVersion + 6, 0x80); + xe::store_and_swap(lpXboxKrnlVersion + 7, 0x00); // KeTimeStampBundle (ad) // This must be updated during execution, at 1ms intevals. @@ -133,15 +133,15 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) auto lpKeTimeStampBundle = memory_->TranslateVirtual(pKeTimeStampBundle); export_resolver_->SetVariableMapping( "xboxkrnl.exe", ordinals::KeTimeStampBundle, pKeTimeStampBundle); - poly::store_and_swap(lpKeTimeStampBundle + 0, 0); - poly::store_and_swap(lpKeTimeStampBundle + 8, 0); - poly::store_and_swap(lpKeTimeStampBundle + 16, GetTickCount()); - poly::store_and_swap(lpKeTimeStampBundle + 20, 0); + xe::store_and_swap(lpKeTimeStampBundle + 0, 0); + xe::store_and_swap(lpKeTimeStampBundle + 8, 0); + xe::store_and_swap(lpKeTimeStampBundle + 16, GetTickCount()); + xe::store_and_swap(lpKeTimeStampBundle + 20, 0); CreateTimerQueueTimer( ×tamp_timer_, nullptr, [](PVOID param, BOOLEAN timer_or_wait_fired) { auto timestamp_bundle = reinterpret_cast(param); - poly::store_and_swap(timestamp_bundle + 16, GetTickCount()); + xe::store_and_swap(timestamp_bundle + 16, GetTickCount()); }, lpKeTimeStampBundle, 0, 1, // 1ms @@ -163,7 +163,7 @@ void XboxkrnlModule::RegisterExportTable( }; #include "xenia/kernel/util/export_table_post.inc" export_resolver->RegisterTable("xboxkrnl.exe", xboxkrnl_export_table, - poly::countof(xboxkrnl_export_table)); + xe::countof(xboxkrnl_export_table)); } XboxkrnlModule::~XboxkrnlModule() { diff --git a/src/xenia/kernel/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl_modules.cc index 5de1454e2..ff9b9a530 100644 --- a/src/xenia/kernel/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl_modules.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xuser_module.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/util/xex2.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -90,7 +90,7 @@ X_STATUS xeExGetXConfigSetting(uint16_t category, uint16_t setting, } if (buffer) { - poly::store_and_swap(buffer, value); + xe::store_and_swap(buffer, value); } if (required_size) { *required_size = setting_size; diff --git a/src/xenia/kernel/xboxkrnl_ob.cc b/src/xenia/kernel/xboxkrnl_ob.cc index e3e10275b..538652ff0 100644 --- a/src/xenia/kernel/xboxkrnl_ob.cc +++ b/src/xenia/kernel/xboxkrnl_ob.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xthread.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" #include "xenia/kernel/xobject.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_rtl.cc b/src/xenia/kernel/xboxkrnl_rtl.cc index ffa50b3f6..9f11db91e 100644 --- a/src/xenia/kernel/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/xboxkrnl_rtl.cc @@ -11,15 +11,15 @@ #include -#include "poly/atomic.h" -#include "poly/string.h" +#include "xenia/base/atomic.h" +#include "xenia/base/logging.h" +#include "xenia/base/string.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/xboxkrnl_private.h" #include "xenia/kernel/objects/xthread.h" #include "xenia/kernel/objects/xuser_module.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/util/xex2.h" -#include "xenia/logging.h" namespace xe { namespace kernel { @@ -79,7 +79,7 @@ SHIM_CALL RtlCompareMemoryUlong_shim(PPCContext* ppc_state, // TODO(benvanik): ensure byte order of pattern is correct. // Since we are doing byte-by-byte comparison we may not want to swap. // GET_ARG swaps, so this is a swap back. Ugly. - const uint32_t pb32 = poly::byte_swap(pattern); + const uint32_t pb32 = xe::byte_swap(pattern); const uint8_t* pb = (uint8_t*)&pb32; uint32_t c = 0; @@ -113,7 +113,7 @@ SHIM_CALL RtlFillMemoryUlong_shim(PPCContext* ppc_state, KernelState* state) { // swapped arg value. uint32_t count = length >> 2; - uint32_t native_pattern = poly::byte_swap(pattern); + uint32_t native_pattern = xe::byte_swap(pattern); // TODO: unroll loop? @@ -227,9 +227,9 @@ SHIM_CALL RtlInitUnicodeString_shim(PPCContext* ppc_state, KernelState* state) { uint32_t destination_ptr = SHIM_GET_ARG_32(0); uint32_t source_ptr = SHIM_GET_ARG_32(1); - auto source = - source_ptr ? poly::load_and_swap(SHIM_MEM_ADDR(source_ptr)) - : L""; + auto source = source_ptr + ? xe::load_and_swap(SHIM_MEM_ADDR(source_ptr)) + : L""; XELOGD("RtlInitUnicodeString(%.8X, %.8X = %ls)", destination_ptr, source_ptr, source.empty() ? L"" : source.c_str()); @@ -286,9 +286,9 @@ SHIM_CALL RtlUnicodeStringToAnsiString_shim(PPCContext* ppc_state, // _In_ PCUNICODE_STRING SourceString, // _In_ BOOLEAN AllocateDestinationString - std::wstring unicode_str = poly::load_and_swap( + std::wstring unicode_str = xe::load_and_swap( SHIM_MEM_ADDR(SHIM_MEM_32(source_ptr + 4))); - std::string ansi_str = poly::to_string(unicode_str); + std::string ansi_str = xe::to_string(unicode_str); if (ansi_str.size() > 0xFFFF - 1) { SHIM_SET_RETURN_32(X_STATUS_INVALID_PARAMETER_2); return; @@ -333,9 +333,9 @@ SHIM_CALL RtlMultiByteToUnicodeN_shim(PPCContext* ppc_state, // TODO: maybe use MultiByteToUnicode on Win32? would require swapping for (uint32_t i = 0; i < copy_len; i++) { - poly::store_and_swap( + xe::store_and_swap( SHIM_MEM_ADDR(destination_ptr + i * 2), - poly::load(SHIM_MEM_ADDR(source_ptr + i))); + xe::load(SHIM_MEM_ADDR(source_ptr + i))); } if (written_ptr != 0) { @@ -361,7 +361,7 @@ SHIM_CALL RtlUnicodeToMultiByteN_shim(PPCContext* ppc_state, auto source = (uint16_t*)SHIM_MEM_ADDR(source_ptr); auto destination = (uint8_t*)SHIM_MEM_ADDR(destination_ptr); for (uint32_t i = 0; i < copy_len; i++) { - uint16_t c = poly::byte_swap(*source++); + uint16_t c = xe::byte_swap(*source++); *destination++ = c < 256 ? (uint8_t)c : '?'; } @@ -552,13 +552,13 @@ SHIM_CALL RtlEnterCriticalSection_shim(PPCContext* ppc_state, uint32_t spin_wait_remaining = cs->spin_count_div_256 * 256; spin: - if (poly::atomic_inc(&cs->lock_count) != 0) { + if (xe::atomic_inc(&cs->lock_count) != 0) { // If this thread already owns the CS increment the recursion count. if (cs->owning_thread_id == thread_id) { cs->recursion_count++; return; } - poly::atomic_dec(&cs->lock_count); + xe::atomic_dec(&cs->lock_count); // Thread was locked - spin wait. if (spin_wait_remaining) { @@ -593,13 +593,13 @@ SHIM_CALL RtlTryEnterCriticalSection_shim(PPCContext* ppc_state, auto cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr); uint32_t result = 0; - if (poly::atomic_cas(-1, 0, &cs->lock_count)) { + if (xe::atomic_cas(-1, 0, &cs->lock_count)) { // Able to steal the lock right away. cs->owning_thread_id = thread_id; cs->recursion_count = 1; result = 1; } else if (cs->owning_thread_id == thread_id) { - poly::atomic_inc(&cs->lock_count); + xe::atomic_inc(&cs->lock_count); ++cs->recursion_count; result = 1; } @@ -619,13 +619,13 @@ SHIM_CALL RtlLeaveCriticalSection_shim(PPCContext* ppc_state, // Drop recursion count - if we are still not zero'ed return. uint32_t recursion_count = --cs->recursion_count; if (recursion_count) { - poly::atomic_dec(&cs->lock_count); + xe::atomic_dec(&cs->lock_count); return; } // Unlock! cs->owning_thread_id = 0; - if (poly::atomic_dec(&cs->lock_count) != -1) { + if (xe::atomic_dec(&cs->lock_count) != -1) { // There were waiters - wake one of them. // TODO(benvanik): wake a waiter. XELOGE("RtlLeaveCriticalSection would have woken a waiter"); diff --git a/src/xenia/kernel/xboxkrnl_strings.cc b/src/xenia/kernel/xboxkrnl_strings.cc index 3341a3fec..c5da0bea3 100644 --- a/src/xenia/kernel/xboxkrnl_strings.cc +++ b/src/xenia/kernel/xboxkrnl_strings.cc @@ -7,13 +7,13 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xthread.h" #include "xenia/kernel/objects/xuser_module.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/util/xex2.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -580,7 +580,7 @@ uint32_t vswprintf_core(wchar_t* buffer, const wchar_t* format, wchar_t* swapped_format = (wchar_t*)malloc((format_length + 1) * sizeof(wchar_t)); for (size_t i = 0; i < format_length; ++i) { - swapped_format[i] = poly::byte_swap(format[i]); + swapped_format[i] = xe::byte_swap(format[i]); } swapped_format[format_length] = '\0'; @@ -700,7 +700,7 @@ uint32_t vswprintf_core(wchar_t* buffer, const wchar_t* format, assert_true(arg_size == 8 || arg_size == 4); if (arg_size == 8) { if (arg_extras == 0) { - uint64_t value = poly::load_and_swap( + uint64_t value = xe::load_and_swap( arg_ptr + (arg_index * 8)); // TODO: check if this is correct... int result = wsprintf(b, local, value); b += result; @@ -710,7 +710,7 @@ uint32_t vswprintf_core(wchar_t* buffer, const wchar_t* format, } } else if (arg_size == 4) { if (arg_extras == 0) { - uint32_t value = (uint32_t)poly::load_and_swap( + uint32_t value = (uint32_t)xe::load_and_swap( arg_ptr + (arg_index * 8)); // TODO: check if this is correct... int result = wsprintf(b, local, value); b += result; @@ -722,9 +722,9 @@ uint32_t vswprintf_core(wchar_t* buffer, const wchar_t* format, } else if (*end == 'n') { assert_true(arg_size == 4); if (arg_extras == 0) { - uint32_t value = (uint32_t)poly::load_and_swap( + uint32_t value = (uint32_t)xe::load_and_swap( arg_ptr + (arg_index * 8)); // TODO: check if this is correct... - poly::store_and_swap(membase + value, (uint32_t)(b - buffer)); + xe::store_and_swap(membase + value, (uint32_t)(b - buffer)); arg_index++; } else { assert_true(false); @@ -736,7 +736,7 @@ uint32_t vswprintf_core(wchar_t* buffer, const wchar_t* format, assert_true(arg_size == 4); if (arg_extras == 0) { - uint32_t value = (uint32_t)poly::load_and_swap( + uint32_t value = (uint32_t)xe::load_and_swap( arg_ptr + (arg_index * 8)); // TODO: check if this is correct... const void* pointer = (void*)(membase + value); int result = wsprintf(b, local, pointer); @@ -752,14 +752,14 @@ uint32_t vswprintf_core(wchar_t* buffer, const wchar_t* format, assert_true(arg_size == 4); if (arg_extras == 0) { - uint32_t value = (uint32_t)poly::load_and_swap( + uint32_t value = (uint32_t)xe::load_and_swap( arg_ptr + (arg_index * 8)); // TODO: check if this is correct... const wchar_t* data = (const wchar_t*)(membase + value); size_t data_length = wcslen(data); wchar_t* swapped_data = (wchar_t*)malloc((data_length + 1) * sizeof(wchar_t)); for (size_t i = 0; i < data_length; ++i) { - swapped_data[i] = poly::byte_swap(data[i]); + swapped_data[i] = xe::byte_swap(data[i]); } swapped_data[data_length] = '\0'; int result = wsprintf(b, local, swapped_data); @@ -781,7 +781,7 @@ uint32_t vswprintf_core(wchar_t* buffer, const wchar_t* format, // swap the result buffer for (wchar_t* swap = buffer; swap != b; ++swap) { - *swap = poly::byte_swap(*swap); + *swap = xe::byte_swap(*swap); } return uint32_t(b - buffer); diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index 3a1a04167..ac72a03ba 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -7,7 +7,8 @@ ****************************************************************************** */ -#include "poly/atomic.h" +#include "xenia/base/atomic.h" +#include "xenia/base/logging.h" #include "xenia/cpu/processor.h" #include "xenia/kernel/dispatcher.h" #include "xenia/kernel/kernel_state.h" @@ -19,7 +20,6 @@ #include "xenia/kernel/objects/xtimer.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -63,7 +63,7 @@ void AssertNoNameCollision(KernelState* state, uint32_t obj_attributes_ptr) { // with a success of NAME_EXISTS. // If the name exists and its type doesn't match, we do NAME_COLLISION. // Otherwise, we add like normal. - uint32_t name_str_ptr = poly::load_and_swap( + uint32_t name_str_ptr = xe::load_and_swap( state->memory()->TranslateVirtual(obj_attributes_ptr + 4)); if (name_str_ptr) { X_ANSI_STRING name_str(state->memory()->virtual_membase(), name_str_ptr); @@ -975,7 +975,7 @@ SHIM_CALL KfAcquireSpinLock_shim(PPCContext* ppc_state, KernelState* state) { // Lock. auto lock = reinterpret_cast(SHIM_MEM_ADDR(lock_ptr)); - while (!poly::atomic_cas(0, 1, lock)) { + while (!xe::atomic_cas(0, 1, lock)) { // Spin! // TODO(benvanik): error on deadlock? } @@ -1002,7 +1002,7 @@ SHIM_CALL KfReleaseSpinLock_shim(PPCContext* ppc_state, KernelState* state) { // Unlock. auto lock = reinterpret_cast(SHIM_MEM_ADDR(lock_ptr)); - poly::atomic_dec(lock); + xe::atomic_dec(lock); } SHIM_CALL KeAcquireSpinLockAtRaisedIrql_shim(PPCContext* ppc_state, @@ -1015,7 +1015,7 @@ SHIM_CALL KeAcquireSpinLockAtRaisedIrql_shim(PPCContext* ppc_state, // Lock. auto lock = reinterpret_cast(SHIM_MEM_ADDR(lock_ptr)); - while (!poly::atomic_cas(0, 1, lock)) { + while (!xe::atomic_cas(0, 1, lock)) { // Spin! // TODO(benvanik): error on deadlock? } @@ -1031,7 +1031,7 @@ SHIM_CALL KeReleaseSpinLockFromRaisedIrql_shim(PPCContext* ppc_state, // Unlock. auto lock = reinterpret_cast(SHIM_MEM_ADDR(lock_ptr)); - poly::atomic_dec(lock); + xe::atomic_dec(lock); } SHIM_CALL KeEnterCriticalRegion_shim(PPCContext* ppc_state, diff --git a/src/xenia/kernel/xboxkrnl_usbcam.cc b/src/xenia/kernel/xboxkrnl_usbcam.cc index 27127b27b..eadc6faf6 100644 --- a/src/xenia/kernel/xboxkrnl_usbcam.cc +++ b/src/xenia/kernel/xboxkrnl_usbcam.cc @@ -7,10 +7,10 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_video.cc b/src/xenia/kernel/xboxkrnl_video.cc index 8bdc776d4..8bdfcc0e3 100644 --- a/src/xenia/kernel/xboxkrnl_video.cc +++ b/src/xenia/kernel/xboxkrnl_video.cc @@ -7,6 +7,7 @@ ****************************************************************************** */ +#include "xenia/base/logging.h" #include "xenia/cpu/cpu.h" #include "xenia/emulator.h" #include "xenia/gpu/graphics_system.h" @@ -15,7 +16,6 @@ #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xboxkrnl_private.h" #include "xenia/kernel/xboxkrnl_rtl.h" -#include "xenia/logging.h" #include "xenia/xbox.h" namespace xe { @@ -309,7 +309,7 @@ SHIM_CALL VdInitializeScalerCommandBuffer_shim(PPCContext* ppc_state, size_t total_words = 0x1CC / 4; uint8_t* p = SHIM_MEM_ADDR(dest_ptr); for (size_t i = 0; i < total_words; ++i, p += 4) { - poly::store_and_swap(p, 0x80000000); + xe::store_and_swap(p, 0x80000000); } // returns memcpy size >> 2 for memcpy(...,...,ret << 2) @@ -419,13 +419,13 @@ SHIM_CALL VdSwap_shim(PPCContext* ppc_state, KernelState* state) { // use this method. memset(SHIM_MEM_ADDR(unk0), 0, 64 * 4); auto dwords = reinterpret_cast(SHIM_MEM_ADDR(unk0)); - dwords[0] = poly::byte_swap((0x3 << 30) | ((63 - 1) << 16) | - (xe::gpu::xenos::PM4_XE_SWAP << 8)); - dwords[1] = poly::byte_swap(frontbuffer); + dwords[0] = xe::byte_swap((0x3 << 30) | ((63 - 1) << 16) | + (xe::gpu::xenos::PM4_XE_SWAP << 8)); + dwords[1] = xe::byte_swap(frontbuffer); // Set by VdCallGraphicsNotificationRoutines. - dwords[2] = poly::byte_swap(last_frontbuffer_width_); - dwords[3] = poly::byte_swap(last_frontbuffer_height_); + dwords[2] = xe::byte_swap(last_frontbuffer_width_); + dwords[3] = xe::byte_swap(last_frontbuffer_height_); SHIM_SET_RETURN_64(0); } @@ -468,7 +468,7 @@ void xe::kernel::xboxkrnl::RegisterVideoExports( memory->SystemHeapAlloc(4, 32, kSystemHeapPhysical); export_resolver->SetVariableMapping("xboxkrnl.exe", ordinals::VdGlobalDevice, pVdGlobalDevice); - poly::store_and_swap(memory->TranslateVirtual(pVdGlobalDevice), 0); + xe::store_and_swap(memory->TranslateVirtual(pVdGlobalDevice), 0); // VdGlobalXamDevice (4b) // Pointer to the XAM D3D device, which we don't have. @@ -476,8 +476,7 @@ void xe::kernel::xboxkrnl::RegisterVideoExports( memory->SystemHeapAlloc(4, 32, kSystemHeapPhysical); export_resolver->SetVariableMapping( "xboxkrnl.exe", ordinals::VdGlobalXamDevice, pVdGlobalXamDevice); - poly::store_and_swap(memory->TranslateVirtual(pVdGlobalXamDevice), - 0); + xe::store_and_swap(memory->TranslateVirtual(pVdGlobalXamDevice), 0); // VdGpuClockInMHz (4b) // GPU clock. Xenos is 500MHz. Hope nothing is relying on this timing... @@ -485,8 +484,7 @@ void xe::kernel::xboxkrnl::RegisterVideoExports( memory->SystemHeapAlloc(4, 32, kSystemHeapPhysical); export_resolver->SetVariableMapping("xboxkrnl.exe", ordinals::VdGpuClockInMHz, pVdGpuClockInMHz); - poly::store_and_swap(memory->TranslateVirtual(pVdGpuClockInMHz), - 500); + xe::store_and_swap(memory->TranslateVirtual(pVdGpuClockInMHz), 500); // VdHSIOCalibrationLock (28b) // CriticalSection. diff --git a/src/xenia/kernel/xobject.cc b/src/xenia/kernel/xobject.cc index 48f61783a..af2c85cb6 100644 --- a/src/xenia/kernel/xobject.cc +++ b/src/xenia/kernel/xobject.cc @@ -73,7 +73,7 @@ void XObject::SetAttributes(const uint8_t* obj_attrs_ptr) { return; } - uint32_t name_str_ptr = poly::load_and_swap(obj_attrs_ptr + 4); + uint32_t name_str_ptr = xe::load_and_swap(obj_attrs_ptr + 4); if (name_str_ptr) { X_ANSI_STRING name_str(memory()->virtual_membase(), name_str_ptr); name_ = name_str.to_string(); @@ -157,19 +157,19 @@ void XObject::SetNativePointer(uint32_t native_ptr) { auto header_be = kernel_state_->memory()->TranslateVirtual(native_ptr); DISPATCH_HEADER header; - header.type_flags = poly::byte_swap(header_be->type_flags); - header.signal_state = poly::byte_swap(header_be->signal_state); - header.wait_list_flink = poly::byte_swap(header_be->wait_list_flink); - header.wait_list_blink = poly::byte_swap(header_be->wait_list_blink); + header.type_flags = xe::byte_swap(header_be->type_flags); + header.signal_state = xe::byte_swap(header_be->signal_state); + header.wait_list_flink = xe::byte_swap(header_be->wait_list_flink); + header.wait_list_blink = xe::byte_swap(header_be->wait_list_blink); assert_true(!(header.wait_list_blink & 0x1)); // Stash pointer in struct. uint64_t object_ptr = reinterpret_cast(this); object_ptr |= 0x1; - header_be->wait_list_flink = poly::byte_swap((uint32_t)(object_ptr >> 32)); + header_be->wait_list_flink = xe::byte_swap((uint32_t)(object_ptr >> 32)); header_be->wait_list_blink = - poly::byte_swap((uint32_t)(object_ptr & 0xFFFFFFFF)); + xe::byte_swap((uint32_t)(object_ptr & 0xFFFFFFFF)); } XObject* XObject::GetObject(KernelState* kernel_state, void* native_ptr, @@ -187,10 +187,10 @@ XObject* XObject::GetObject(KernelState* kernel_state, void* native_ptr, DISPATCH_HEADER* header_be = (DISPATCH_HEADER*)native_ptr; DISPATCH_HEADER header; - header.type_flags = poly::byte_swap(header_be->type_flags); - header.signal_state = poly::byte_swap(header_be->signal_state); - header.wait_list_flink = poly::byte_swap(header_be->wait_list_flink); - header.wait_list_blink = poly::byte_swap(header_be->wait_list_blink); + header.type_flags = xe::byte_swap(header_be->type_flags); + header.signal_state = xe::byte_swap(header_be->signal_state); + header.wait_list_flink = xe::byte_swap(header_be->wait_list_flink); + header.wait_list_blink = xe::byte_swap(header_be->wait_list_blink); if (as_type == -1) { as_type = header.type_flags & 0xFF; @@ -248,9 +248,9 @@ XObject* XObject::GetObject(KernelState* kernel_state, void* native_ptr, // Stash pointer in struct. uint64_t object_ptr = reinterpret_cast(object); object_ptr |= 0x1; - header_be->wait_list_flink = poly::byte_swap((uint32_t)(object_ptr >> 32)); + header_be->wait_list_flink = xe::byte_swap((uint32_t)(object_ptr >> 32)); header_be->wait_list_blink = - poly::byte_swap((uint32_t)(object_ptr & 0xFFFFFFFF)); + xe::byte_swap((uint32_t)(object_ptr & 0xFFFFFFFF)); return object; } diff --git a/src/xenia/memory.cc b/src/xenia/memory.cc index e3cf3642e..78cfdf230 100644 --- a/src/xenia/memory.cc +++ b/src/xenia/memory.cc @@ -14,9 +14,9 @@ #include #include -#include "poly/math.h" +#include "xenia/base/logging.h" +#include "xenia/base/math.h" #include "xenia/cpu/mmio_handler.h" -#include "xenia/logging.h" using namespace xe; @@ -124,7 +124,7 @@ Memory::Memory() trace_base_(0), mapping_(0), mapping_base_(nullptr) { - system_page_size_ = uint32_t(poly::page_size()); + system_page_size_ = uint32_t(xe::page_size()); virtual_heap_ = new MemoryHeap(this, false); physical_heap_ = new MemoryHeap(this, true); } @@ -213,8 +213,8 @@ int Memory::Initialize() { // I have no idea what this is, but games try to read/write there. VirtualAlloc(TranslateVirtual(0x40000000), 0x00010000, MEM_COMMIT, PAGE_READWRITE); - poly::store_and_swap(TranslateVirtual(0x40000000), 0x00C40000); - poly::store_and_swap(TranslateVirtual(0x40000004), 0x00010000); + xe::store_and_swap(TranslateVirtual(0x40000000), 0x00C40000); + xe::store_and_swap(TranslateVirtual(0x40000004), 0x00010000); return 0; } @@ -235,8 +235,8 @@ const static struct { 0xE0000000, 0xFFFFFFFF, 0x00000000, // - physical 4k pages }; int Memory::MapViews(uint8_t* mapping_base) { - assert_true(poly::countof(map_info) == poly::countof(views_.all_views)); - for (size_t n = 0; n < poly::countof(map_info); n++) { + assert_true(xe::countof(map_info) == xe::countof(views_.all_views)); + for (size_t n = 0; n < xe::countof(map_info); n++) { #if XE_PLATFORM_WIN32 views_.all_views[n] = reinterpret_cast(MapViewOfFileEx( mapping_, FILE_MAP_ALL_ACCESS, 0x00000000, @@ -260,7 +260,7 @@ int Memory::MapViews(uint8_t* mapping_base) { } void Memory::UnmapViews() { - for (size_t n = 0; n < poly::countof(views_.all_views); n++) { + for (size_t n = 0; n < xe::countof(views_.all_views); n++) { if (views_.all_views[n]) { #if XE_PLATFORM_WIN32 UnmapViewOfFile(views_.all_views[n]); @@ -521,7 +521,7 @@ uint32_t MemoryHeap::Alloc(uint32_t base_address, uint32_t size, uint32_t flags, if (heap_guard_size) { alignment = std::max(alignment, static_cast(heap_guard_size)); alloc_size = - static_cast(poly::round_up(alloc_size, heap_guard_size)); + static_cast(xe::round_up(alloc_size, heap_guard_size)); } lock_.lock(); diff --git a/src/xenia/memory.h b/src/xenia/memory.h index fd7070405..6f0ab1792 100644 --- a/src/xenia/memory.h +++ b/src/xenia/memory.h @@ -14,9 +14,9 @@ #include #include -#include "poly/platform.h" -#include "xenia/memory.h" +#include "xenia/base/platform.h" #include "xenia/cpu/mmio_handler.h" +#include "xenia/memory.h" namespace xe { diff --git a/src/xenia/profiling.cc b/src/xenia/profiling.cc index d4f0f9ff4..3f2aaacbb 100644 --- a/src/xenia/profiling.cc +++ b/src/xenia/profiling.cc @@ -7,7 +7,7 @@ ****************************************************************************** */ -#include "xenia/logging.h" +#include "xenia/base/logging.h" #define MICROPROFILE_ENABLED 1 #define MICROPROFILEUI_ENABLED 1 diff --git a/src/xenia/profiling.h b/src/xenia/profiling.h index 07be0bb0d..6c2253b35 100644 --- a/src/xenia/profiling.h +++ b/src/xenia/profiling.h @@ -12,7 +12,7 @@ #include -#include "poly/string.h" +#include "xenia/base/string.h" #define XE_OPTION_PROFILING 1 #if XE_PLATFORM_WIN32 diff --git a/src/xenia/sources.gypi b/src/xenia/sources.gypi index 920a3f286..f85c33ff2 100644 --- a/src/xenia/sources.gypi +++ b/src/xenia/sources.gypi @@ -5,8 +5,6 @@ 'debug_agent.h', 'emulator.cc', 'emulator.h', - 'logging.cc', - 'logging.h', 'memory.cc', 'memory.h', 'profiling.cc', @@ -17,6 +15,7 @@ 'includes': [ 'apu/sources.gypi', + 'base/sources.gypi', 'cpu/sources.gypi', 'gpu/sources.gypi', 'hid/sources.gypi', diff --git a/src/xenia/tools/api-scanner/api_scanner_loader.h b/src/xenia/tools/api-scanner/api_scanner_loader.h index 991cef72f..c84e405d9 100644 --- a/src/xenia/tools/api-scanner/api_scanner_loader.h +++ b/src/xenia/tools/api-scanner/api_scanner_loader.h @@ -9,9 +9,9 @@ #include -#include "poly/main.h" -#include "poly/math.h" -#include "poly/string.h" +#include "xenia/base/main.h" +#include "xenia/base/math.h" +#include "xenia/base/string.h" #include "xenia/cpu/export_resolver.h" #include "xenia/kernel/fs/filesystem.h" #include "xenia/kernel/objects/xfile.h" diff --git a/src/xenia/tools/api-scanner/api_scanner_main.cc b/src/xenia/tools/api-scanner/api_scanner_main.cc index 0e26ff964..caf67d665 100644 --- a/src/xenia/tools/api-scanner/api_scanner_main.cc +++ b/src/xenia/tools/api-scanner/api_scanner_main.cc @@ -21,10 +21,10 @@ int api_scanner_main(std::vector& args) { if (args.size() == 2 || !FLAGS_target.empty()) { apiscanner_loader loader_; - std::wstring target(FLAGS_target.empty() ? args[1] : - poly::to_wstring(FLAGS_target)); + std::wstring target(FLAGS_target.empty() ? args[1] + : xe::to_wstring(FLAGS_target)); - std::wstring target_abs = poly::to_absolute_path(target); + std::wstring target_abs = xe::to_absolute_path(target); // XXX For each target? if (loader_.LoadTitleImports(target)) { diff --git a/src/xenia/ui/control.cc b/src/xenia/ui/control.cc index 4a8bffafd..eb9601b68 100644 --- a/src/xenia/ui/control.cc +++ b/src/xenia/ui/control.cc @@ -9,7 +9,7 @@ #include "xenia/ui/control.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" namespace xe { namespace ui { diff --git a/src/xenia/ui/control.h b/src/xenia/ui/control.h index c83582e96..8c13866a8 100644 --- a/src/xenia/ui/control.h +++ b/src/xenia/ui/control.h @@ -13,7 +13,7 @@ #include #include -#include "poly/delegate.h" +#include "xenia/base/delegate.h" #include "xenia/ui/ui_event.h" namespace xe { @@ -65,24 +65,24 @@ class Control { virtual void set_focus(bool value) { has_focus_ = value; } public: - poly::Delegate on_resize; - poly::Delegate on_layout; - poly::Delegate on_paint; + Delegate on_resize; + Delegate on_layout; + Delegate on_paint; - poly::Delegate on_visible; - poly::Delegate on_hidden; + Delegate on_visible; + Delegate on_hidden; - poly::Delegate on_got_focus; - poly::Delegate on_lost_focus; + Delegate on_got_focus; + Delegate on_lost_focus; - poly::Delegate on_key_down; - poly::Delegate on_key_up; - poly::Delegate on_key_char; + Delegate on_key_down; + Delegate on_key_up; + Delegate on_key_char; - poly::Delegate on_mouse_down; - poly::Delegate on_mouse_move; - poly::Delegate on_mouse_up; - poly::Delegate on_mouse_wheel; + Delegate on_mouse_down; + Delegate on_mouse_move; + Delegate on_mouse_up; + Delegate on_mouse_wheel; protected: explicit Control(uint32_t flags); diff --git a/src/xenia/ui/main_window.cc b/src/xenia/ui/main_window.cc index 4227f9000..82e743a81 100644 --- a/src/xenia/ui/main_window.cc +++ b/src/xenia/ui/main_window.cc @@ -9,10 +9,10 @@ #include "xenia/ui/main_window.h" -#include "poly/threading.h" +#include "xenia/base/logging.h" +#include "xenia/base/threading.h" #include "xenia/gpu/graphics_system.h" #include "xenia/emulator.h" -#include "xenia/logging.h" #include "xenia/profiling.h" namespace xe { @@ -24,10 +24,10 @@ MainWindow::MainWindow(Emulator* emulator) MainWindow::~MainWindow() = default; void MainWindow::Start() { - poly::threading::Fence fence; + xe::threading::Fence fence; loop_.Post([&]() { - poly::threading::set_name("Win32 Loop"); + xe::threading::set_name("Win32 Loop"); xe::Profiler::ThreadEnter("Win32 Loop"); if (!Initialize()) { diff --git a/src/xenia/ui/menu_item.h b/src/xenia/ui/menu_item.h index 44b9abdbb..72993540b 100644 --- a/src/xenia/ui/menu_item.h +++ b/src/xenia/ui/menu_item.h @@ -13,7 +13,7 @@ #include #include -#include "poly/delegate.h" +#include "xenia/base/delegate.h" #include "xenia/ui/ui_event.h" namespace xe { @@ -39,7 +39,7 @@ class MenuItem { void AddChild(MenuItemPtr child_item); void RemoveChild(MenuItem* child_item); - poly::Delegate on_selected; + Delegate on_selected; protected: MenuItem(Type type); diff --git a/src/xenia/ui/win32/win32_loop.cc b/src/xenia/ui/win32/win32_loop.cc index 7e20d138a..f85221db8 100644 --- a/src/xenia/ui/win32/win32_loop.cc +++ b/src/xenia/ui/win32/win32_loop.cc @@ -9,7 +9,7 @@ #include "xenia/ui/win32/win32_loop.h" -#include "poly/assert.h" +#include "xenia/base/assert.h" namespace xe { namespace ui { @@ -28,9 +28,9 @@ class PostedFn { }; Win32Loop::Win32Loop() : thread_id_(0) { - poly::threading::Fence init_fence; + xe::threading::Fence init_fence; thread_ = std::thread([&]() { - poly::threading::set_name("Win32 Loop"); + xe::threading::set_name("Win32 Loop"); thread_id_ = GetCurrentThreadId(); // Make a Win32 call to enable the thread queue. diff --git a/src/xenia/ui/win32/win32_loop.h b/src/xenia/ui/win32/win32_loop.h index 6eddfc971..fc0fc3121 100644 --- a/src/xenia/ui/win32/win32_loop.h +++ b/src/xenia/ui/win32/win32_loop.h @@ -18,7 +18,7 @@ #include #include -#include "poly/threading.h" +#include "xenia/base/threading.h" #include "xenia/ui/loop.h" namespace xe { @@ -40,7 +40,7 @@ class Win32Loop : public Loop { std::thread thread_; DWORD thread_id_; - poly::threading::Fence quit_fence_; + xe::threading::Fence quit_fence_; }; } // namespace win32 diff --git a/src/xenia/ui/win32/win32_window.cc b/src/xenia/ui/win32/win32_window.cc index 2c5414ced..e3576de98 100644 --- a/src/xenia/ui/win32/win32_window.cc +++ b/src/xenia/ui/win32/win32_window.cc @@ -13,7 +13,7 @@ #include #include -#include "xenia/logging.h" +#include "xenia/base/logging.h" namespace xe { namespace ui { diff --git a/src/xenia/ui/window.h b/src/xenia/ui/window.h index 6371a4af5..311c60319 100644 --- a/src/xenia/ui/window.h +++ b/src/xenia/ui/window.h @@ -12,7 +12,7 @@ #include -#include "poly/delegate.h" +#include "xenia/base/delegate.h" #include "xenia/ui/control.h" #include "xenia/ui/ui_event.h" @@ -46,10 +46,10 @@ class Window : public T { } public: - poly::Delegate on_shown; - poly::Delegate on_hidden; - poly::Delegate on_closing; - poly::Delegate on_closed; + Delegate on_shown; + Delegate on_hidden; + Delegate on_closing; + Delegate on_closed; protected: Window(const std::wstring& title) : T(0), title_(title) {} diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index 1ed83ea00..ab6e1b099 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -12,14 +12,10 @@ #include -#include "poly/memory.h" +#include "xenia/base/memory.h" namespace xe { -template -using be = poly::be; - - #pragma pack(push, 4) @@ -218,35 +214,35 @@ enum X_FILE_INFORMATION_CLASS { inline void XOverlappedSetResult(void* ptr, uint32_t value) { auto p = reinterpret_cast(ptr); - poly::store_and_swap(&p[0], value); + xe::store_and_swap(&p[0], value); } inline void XOverlappedSetLength(void* ptr, uint32_t value) { auto p = reinterpret_cast(ptr); - poly::store_and_swap(&p[1], value); + xe::store_and_swap(&p[1], value); } inline uint32_t XOverlappedGetContext(void* ptr) { auto p = reinterpret_cast(ptr); - return poly::load_and_swap(&p[2]); + return xe::load_and_swap(&p[2]); } inline void XOverlappedSetContext(void* ptr, uint32_t value) { auto p = reinterpret_cast(ptr); - poly::store_and_swap(&p[2], value); + xe::store_and_swap(&p[2], value); } inline X_HANDLE XOverlappedGetEvent(void* ptr) { auto p = reinterpret_cast(ptr); - return poly::load_and_swap(&p[3]); + return xe::load_and_swap(&p[3]); } inline uint32_t XOverlappedGetCompletionRoutine(void* ptr) { auto p = reinterpret_cast(ptr); - return poly::load_and_swap(&p[4]); + return xe::load_and_swap(&p[4]); } inline uint32_t XOverlappedGetCompletionContext(void* ptr) { auto p = reinterpret_cast(ptr); - return poly::load_and_swap(&p[5]); + return xe::load_and_swap(&p[5]); } inline void XOverlappedSetExtendedError(void* ptr, uint32_t value) { auto p = reinterpret_cast(ptr); - poly::store_and_swap(&p[6], value); + xe::store_and_swap(&p[6], value); } class X_ANSI_STRING { @@ -263,10 +259,10 @@ public: Read(base, p); } void Read(const uint8_t* base, uint32_t p) { - length = poly::load_and_swap(base + p); - maximum_length = poly::load_and_swap(base + p + 2); + length = xe::load_and_swap(base + p); + maximum_length = xe::load_and_swap(base + p + 2); if (maximum_length) { - buffer = (const char*)(base + poly::load_and_swap(base + p + 4)); + buffer = (const char*)(base + xe::load_and_swap(base + p + 4)); } else { buffer = 0; } diff --git a/src/xenia/xenia_main.cc b/src/xenia/xenia_main.cc index 895c66138..a3f09392a 100644 --- a/src/xenia/xenia_main.cc +++ b/src/xenia/xenia_main.cc @@ -8,10 +8,11 @@ */ #include -#include "poly/main.h" + +#include "xenia/base/logging.h" +#include "xenia/base/main.h" #include "xenia/emulator.h" #include "xenia/kernel/kernel.h" -#include "xenia/logging.h" #include "xenia/profiling.h" #include "xenia/ui/main_window.h" @@ -38,13 +39,13 @@ int xenia_main(std::vector& args) { // Passed as a named argument. // TODO(benvanik): find something better than gflags that supports // unicode. - path = poly::to_wstring(FLAGS_target); + path = xe::to_wstring(FLAGS_target); } else { // Passed as an unnamed argument. path = args[1]; } // Normalize the path and make absolute. - std::wstring abs_path = poly::to_absolute_path(path); + std::wstring abs_path = xe::to_absolute_path(path); result = emulator->main_window()->LaunchPath(abs_path); if (XFAILED(result)) { diff --git a/xenia.gyp b/xenia.gyp index c5e1ba241..9d32a9c32 100644 --- a/xenia.gyp +++ b/xenia.gyp @@ -202,87 +202,6 @@ }, 'targets': [ - { - 'target_name': 'libpoly', - 'product_name': 'libpoly', - 'type': 'static_library', - - 'dependencies': [ - 'gflags', - ], - - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_CFLAGS': [ - '-fno-operator-names', - ], - }, - }], - ['OS == "linux"', { - 'cflags': [ - '-fno-operator-names', - ], - }], - ], - - 'export_dependent_settings': [ - 'gflags', - ], - - 'direct_dependent_settings': { - 'include_dirs': [ - 'src/', - ], - - 'target_conditions': [ - ['_type=="shared_library"', { - 'cflags': [ - ], - }], - ['_type=="executable"', { - 'conditions': [ - ['OS == "win"', { - 'libraries': [ - 'kernel32', - 'user32', - 'ole32', - 'ntdll', - 'advapi32', - 'Shell32', - ], - }], - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_LDFLAGS': [ - ], - }, - }], - ['OS == "linux"', { - 'libraries': [ - '-lpthread', - '-ldl', - ], - }], - ], - }], - ], - }, - - 'cflags': [ - ], - - 'include_dirs': [ - '.', - 'src/', - '<(INTERMEDIATE_DIR)', - ], - - 'includes': [ - 'src/poly/sources.gypi', - ], - }, - { 'target_name': 'libxenia', 'product_name': 'libxenia', @@ -293,7 +212,6 @@ 'gflags', 'glew', 'llvm', - 'libpoly', 'xxhash', ], 'export_dependent_settings': [ @@ -301,7 +219,6 @@ 'gflags', 'glew', 'llvm', - 'libpoly', 'xxhash', ], @@ -331,6 +248,7 @@ 'glu32', 'opengl32', 'gdi32', + 'ntdll', ], }], ['OS == "mac"', {