diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index 310ec7b72..91a9d9101 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -783,8 +783,16 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path, } // Grab the current title ID. xex2_opt_execution_info* info = nullptr; + uint32_t workspace_address = 0; module->GetOptHeader(XEX_HEADER_EXECUTION_INFO, &info); + kernel_state_->memory() + ->LookupHeapByType(false, 0x1000) + ->Alloc(module->workspace_size(), 0x1000, + kMemoryAllocationReserve | kMemoryAllocationCommit, + kMemoryProtectRead | kMemoryProtectWrite, false, + &workspace_address); + if (!info) { title_id_ = 0; } else { diff --git a/src/xenia/kernel/user_module.cc b/src/xenia/kernel/user_module.cc index 738fbeb40..7f5b8fd6d 100644 --- a/src/xenia/kernel/user_module.cc +++ b/src/xenia/kernel/user_module.cc @@ -208,6 +208,13 @@ X_STATUS UserModule::LoadContinue() { // Cache some commonly used headers... this->xex_module()->GetOptHeader(XEX_HEADER_ENTRY_POINT, &entry_point_); this->xex_module()->GetOptHeader(XEX_HEADER_DEFAULT_STACK_SIZE, &stack_size_); + + xe::be* ws_size = 0; + this->xex_module()->GetOptHeader(XEX_HEADER_TITLE_WORKSPACE_SIZE, &ws_size); + // ToDo: Find better way to handle default and mimimal values! + if (ws_size && *ws_size) { + workspace_size_ = std::max(ws_size->get(), uint32_t(256 * 1024)); + } is_dll_module_ = !!(header->module_flags & XEX_MODULE_DLL_MODULE); // Setup the loader data entry diff --git a/src/xenia/kernel/user_module.h b/src/xenia/kernel/user_module.h index 40d9117fc..13def09ba 100644 --- a/src/xenia/kernel/user_module.h +++ b/src/xenia/kernel/user_module.h @@ -67,6 +67,7 @@ class UserModule : public XModule { uint32_t entry_point() const { return entry_point_; } uint32_t stack_size() const { return stack_size_; } + uint32_t workspace_size() const { return workspace_size_; } X_STATUS LoadFromFile(const std::string_view path); X_STATUS LoadFromMemory(const void* addr, const size_t length); @@ -113,6 +114,7 @@ class UserModule : public XModule { bool is_dll_module_ = false; uint32_t entry_point_ = 0; uint32_t stack_size_ = 0; + uint32_t workspace_size_ = 384*1024; }; } // namespace kernel