diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 18 | ||||
-rw-r--r-- | src/core/hle/service/sm/controller.cpp | 8 | ||||
-rw-r--r-- | src/core/hle/service/sm/controller.h | 1 | ||||
-rw-r--r-- | src/core/hle/service/vi/vi.cpp | 46 | ||||
-rw-r--r-- | src/core/loader/nro.cpp | 29 |
5 files changed, 50 insertions, 52 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 6401af35a..45da842ef 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -57,7 +57,7 @@ static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { } /// Connect to an OS service given the port name, returns the handle to the port to out -static ResultCode ConnectToPort(Handle* out_handle, VAddr port_name_address) { +static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address) { if (!Memory::IsValidVirtualAddress(port_name_address)) return ERR_NOT_FOUND; @@ -253,8 +253,8 @@ static ResultCode CancelSynchronization(Handle thread_handle) { } /// Attempts to locks a mutex, creating it if it does not already exist -static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, - Handle requesting_thread_handle) { +static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr, + Handle requesting_thread_handle) { LOG_TRACE(Kernel_SVC, "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, " "requesting_current_thread_handle=0x%08X", holding_thread_handle, mutex_addr, requesting_thread_handle); @@ -277,7 +277,7 @@ static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, } /// Unlock a mutex -static ResultCode UnlockMutex(VAddr mutex_addr) { +static ResultCode ArbitrateUnlock(VAddr mutex_addr) { LOG_TRACE(Kernel_SVC, "called mutex_addr=0x%llx", mutex_addr); SharedPtr<Mutex> mutex = g_object_address_table.Get<Mutex>(mutex_addr); @@ -774,12 +774,12 @@ static const FunctionDef SVC_Table[] = { {0x17, SvcWrap<ResetSignal>, "ResetSignal"}, {0x18, SvcWrap<WaitSynchronization>, "WaitSynchronization"}, {0x19, SvcWrap<CancelSynchronization>, "CancelSynchronization"}, - {0x1A, SvcWrap<LockMutex>, "LockMutex"}, - {0x1B, SvcWrap<UnlockMutex>, "UnlockMutex"}, + {0x1A, SvcWrap<ArbitrateLock>, "ArbitrateLock"}, + {0x1B, SvcWrap<ArbitrateUnlock>, "ArbitrateUnlock"}, {0x1C, SvcWrap<WaitProcessWideKeyAtomic>, "WaitProcessWideKeyAtomic"}, {0x1D, SvcWrap<SignalProcessWideKey>, "SignalProcessWideKey"}, {0x1E, SvcWrap<GetSystemTick>, "GetSystemTick"}, - {0x1F, SvcWrap<ConnectToPort>, "ConnectToPort"}, + {0x1F, SvcWrap<ConnectToNamedPort>, "ConnectToNamedPort"}, {0x20, nullptr, "SendSyncRequestLight"}, {0x21, SvcWrap<SendSyncRequest>, "SendSyncRequest"}, {0x22, nullptr, "SendSyncRequestWithUserBuffer"}, @@ -823,8 +823,8 @@ static const FunctionDef SVC_Table[] = { {0x48, nullptr, "Unknown"}, {0x49, nullptr, "Unknown"}, {0x4A, nullptr, "Unknown"}, - {0x4B, nullptr, "Unknown"}, - {0x4C, nullptr, "Unknown"}, + {0x4B, nullptr, "CreateJitMemory"}, + {0x4C, nullptr, "MapJitMemory"}, {0x4D, nullptr, "SleepSystem"}, {0x4E, nullptr, "ReadWriteRegister"}, {0x4F, nullptr, "SetProcessActivity"}, diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp index e8f5d0e4a..7b1c8ee37 100644 --- a/src/core/hle/service/sm/controller.cpp +++ b/src/core/hle/service/sm/controller.cpp @@ -32,6 +32,12 @@ void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service, "called"); } +void Controller::DuplicateSessionEx(Kernel::HLERequestContext& ctx) { + DuplicateSession(ctx); + + LOG_WARNING(Service, "(STUBBED) called, using DuplicateSession"); +} + void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); @@ -46,7 +52,7 @@ Controller::Controller() : ServiceFramework("IpcController") { {0x00000001, nullptr, "ConvertDomainToSession"}, {0x00000002, &Controller::DuplicateSession, "DuplicateSession"}, {0x00000003, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"}, - {0x00000004, nullptr, "DuplicateSessionEx"}, + {0x00000004, &Controller::DuplicateSessionEx, "DuplicateSessionEx"}, }; RegisterHandlers(functions); } diff --git a/src/core/hle/service/sm/controller.h b/src/core/hle/service/sm/controller.h index 0b873b492..7b4bc4b75 100644 --- a/src/core/hle/service/sm/controller.h +++ b/src/core/hle/service/sm/controller.h @@ -17,6 +17,7 @@ public: private: void ConvertSessionToDomain(Kernel::HLERequestContext& ctx); void DuplicateSession(Kernel::HLERequestContext& ctx); + void DuplicateSessionEx(Kernel::HLERequestContext& ctx); void QueryPointerBufferSize(Kernel::HLERequestContext& ctx); }; diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index cae2c4466..108a635d7 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -26,7 +26,7 @@ public: // This default size was chosen arbitrarily. static constexpr size_t DefaultBufferSize = 0x40; Parcel() : buffer(DefaultBufferSize) {} - Parcel(std::vector<u8> data) : buffer(std::move(data)) {} + explicit Parcel(std::vector<u8> data) : buffer(std::move(data)) {} virtual ~Parcel() = default; template <typename T> @@ -47,8 +47,9 @@ public: } std::vector<u8> ReadBlock(size_t length) { - std::vector<u8> data(length); - std::memcpy(data.data(), buffer.data() + read_index, length); + const u8* const begin = buffer.data() + read_index; + const u8* const end = begin + length; + std::vector<u8> data(begin, end); read_index += length; read_index = Common::AlignUp(read_index, 4); return data; @@ -101,9 +102,9 @@ public: } protected: - virtual void SerializeData(){}; + virtual void SerializeData() {} - virtual void DeserializeData(){}; + virtual void DeserializeData() {} private: struct Header { @@ -121,7 +122,7 @@ private: class NativeWindow : public Parcel { public: - NativeWindow(u32 id) : Parcel() { + explicit NativeWindow(u32 id) : Parcel() { data.id = id; } ~NativeWindow() override = default; @@ -147,12 +148,12 @@ private: class IGBPConnectRequestParcel : public Parcel { public: - IGBPConnectRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { + explicit IGBPConnectRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { Deserialize(); } ~IGBPConnectRequestParcel() override = default; - void DeserializeData() { + void DeserializeData() override { std::u16string token = ReadInterfaceToken(); data = Read<Data>(); } @@ -168,7 +169,7 @@ public: class IGBPConnectResponseParcel : public Parcel { public: - IGBPConnectResponseParcel(u32 width, u32 height) : Parcel() { + explicit IGBPConnectResponseParcel(u32 width, u32 height) : Parcel() { data.width = width; data.height = height; } @@ -194,12 +195,13 @@ private: class IGBPSetPreallocatedBufferRequestParcel : public Parcel { public: - IGBPSetPreallocatedBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { + explicit IGBPSetPreallocatedBufferRequestParcel(const std::vector<u8>& buffer) + : Parcel(buffer) { Deserialize(); } ~IGBPSetPreallocatedBufferRequestParcel() override = default; - void DeserializeData() { + void DeserializeData() override { std::u16string token = ReadInterfaceToken(); data = Read<Data>(); ASSERT(data.graphic_buffer_length == sizeof(IGBPBuffer)); @@ -231,12 +233,12 @@ protected: class IGBPDequeueBufferRequestParcel : public Parcel { public: - IGBPDequeueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { + explicit IGBPDequeueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { Deserialize(); } ~IGBPDequeueBufferRequestParcel() override = default; - void DeserializeData() { + void DeserializeData() override { std::u16string token = ReadInterfaceToken(); data = Read<Data>(); } @@ -254,7 +256,7 @@ public: class IGBPDequeueBufferResponseParcel : public Parcel { public: - IGBPDequeueBufferResponseParcel(u32 slot) : Parcel(), slot(slot) {} + explicit IGBPDequeueBufferResponseParcel(u32 slot) : Parcel(), slot(slot) {} ~IGBPDequeueBufferResponseParcel() override = default; protected: @@ -271,12 +273,12 @@ protected: class IGBPRequestBufferRequestParcel : public Parcel { public: - IGBPRequestBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { + explicit IGBPRequestBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { Deserialize(); } ~IGBPRequestBufferRequestParcel() override = default; - void DeserializeData() { + void DeserializeData() override { std::u16string token = ReadInterfaceToken(); slot = Read<u32_le>(); } @@ -286,7 +288,7 @@ public: class IGBPRequestBufferResponseParcel : public Parcel { public: - IGBPRequestBufferResponseParcel(IGBPBuffer buffer) : Parcel(), buffer(buffer) {} + explicit IGBPRequestBufferResponseParcel(IGBPBuffer buffer) : Parcel(), buffer(buffer) {} ~IGBPRequestBufferResponseParcel() override = default; protected: @@ -307,12 +309,12 @@ protected: class IGBPQueueBufferRequestParcel : public Parcel { public: - IGBPQueueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { + explicit IGBPQueueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { Deserialize(); } ~IGBPQueueBufferRequestParcel() override = default; - void DeserializeData() { + void DeserializeData() override { std::u16string token = ReadInterfaceToken(); data = Read<Data>(); } @@ -330,7 +332,7 @@ public: class IGBPQueueBufferResponseParcel : public Parcel { public: - IGBPQueueBufferResponseParcel(u32 width, u32 height) : Parcel() { + explicit IGBPQueueBufferResponseParcel(u32 width, u32 height) : Parcel() { data.width = width; data.height = height; } @@ -356,7 +358,7 @@ private: class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { public: - IHOSBinderDriver(std::shared_ptr<NVFlinger> nv_flinger) + explicit IHOSBinderDriver(std::shared_ptr<NVFlinger> nv_flinger) : ServiceFramework("IHOSBinderDriver"), nv_flinger(std::move(nv_flinger)) { static const FunctionInfo functions[] = { {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, @@ -506,7 +508,7 @@ private: class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> { public: - IManagerDisplayService(std::shared_ptr<NVFlinger> nv_flinger) + explicit IManagerDisplayService(std::shared_ptr<NVFlinger> nv_flinger) : ServiceFramework("IManagerDisplayService"), nv_flinger(std::move(nv_flinger)) { static const FunctionInfo functions[] = { {1020, &IManagerDisplayService::CloseDisplay, "CloseDisplay"}, diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 66c61b038..6864a1926 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp @@ -62,20 +62,6 @@ static constexpr u32 PageAlignSize(u32 size) { return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; } -static std::vector<u8> ReadSegment(FileUtil::IOFile& file, const NroSegmentHeader& header) { - std::vector<u8> data; - data.resize(header.size); - - file.Seek(header.offset + sizeof(NroHeader), SEEK_SET); - size_t bytes_read{file.ReadBytes(data.data(), header.size)}; - if (header.size != PageAlignSize(static_cast<u32>(bytes_read))) { - LOG_CRITICAL(Loader, "Failed to read NRO segment bytes", header.size); - return {}; - } - - return data; -} - bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) { FileUtil::IOFile file(path, "rb"); if (!file.IsOpen()) { @@ -95,7 +81,7 @@ bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) { // Build program image Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("", 0); std::vector<u8> program_image; - program_image.resize(PageAlignSize(nro_header.file_size + nro_header.bss_size)); + program_image.resize(PageAlignSize(nro_header.file_size)); file.Seek(0, SEEK_SET); file.ReadBytes(program_image.data(), nro_header.file_size); @@ -107,15 +93,16 @@ bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) { // Read MOD header ModHeader mod_header{}; - u32 bss_size{Memory::PAGE_SIZE}; // Default .bss to page size if MOD0 section doesn't exist + // Default .bss to NRO header bss size if MOD0 section doesn't exist + u32 bss_size{PageAlignSize(nro_header.bss_size)}; std::memcpy(&mod_header, program_image.data() + nro_header.module_header_offset, sizeof(ModHeader)); const bool has_mod_header{mod_header.magic == Common::MakeMagic('M', 'O', 'D', '0')}; if (has_mod_header) { // Resize program image to include .bss section and page align each section bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset); - codeset->data.size += bss_size; } + codeset->data.size += bss_size; program_image.resize(PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)); // Load codeset for current process @@ -134,9 +121,11 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) { return ResultStatus::Error; } - // Load and relocate "main" and "sdk" NSO - static constexpr VAddr base_addr{Memory::PROCESS_IMAGE_VADDR}; process = Kernel::Process::Create("main"); + + // Load NRO + static constexpr VAddr base_addr{Memory::PROCESS_IMAGE_VADDR}; + if (!LoadNro(filepath, base_addr)) { return ResultStatus::ErrorInvalidFormat; } @@ -145,7 +134,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) { process->address_mappings = default_address_mappings; process->resource_limit = Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); - process->Run(base_addr, 48, Kernel::DEFAULT_STACK_SIZE); + process->Run(base_addr + sizeof(NroHeader), 48, Kernel::DEFAULT_STACK_SIZE); is_loaded = true; return ResultStatus::Success; |