diff options
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r-- | src/core/hle/kernel/domain.cpp | 21 | ||||
-rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 10 | ||||
-rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 12 | ||||
-rw-r--r-- | src/core/hle/kernel/kernel.h | 1 | ||||
-rw-r--r-- | src/core/hle/kernel/memory.cpp | 6 | ||||
-rw-r--r-- | src/core/hle/kernel/mutex.h | 6 | ||||
-rw-r--r-- | src/core/hle/kernel/process.h | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 46 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.h | 14 | ||||
-rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 9 |
10 files changed, 102 insertions, 25 deletions
diff --git a/src/core/hle/kernel/domain.cpp b/src/core/hle/kernel/domain.cpp index 7ebb4b9c7..5035e9c08 100644 --- a/src/core/hle/kernel/domain.cpp +++ b/src/core/hle/kernel/domain.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/logging/log.h" +#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/domain.h" #include "core/hle/kernel/handle_table.h" @@ -36,7 +38,24 @@ ResultCode Domain::SendSyncRequest(SharedPtr<Thread> thread) { if (domain_message_header) { // If there is a DomainMessageHeader, then this is CommandType "Request" const u32 object_id{context.GetDomainMessageHeader()->object_id}; - return request_handlers[object_id - 1]->HandleSyncRequest(context); + switch (domain_message_header->command) { + case IPC::DomainMessageHeader::CommandType::SendMessage: + return request_handlers[object_id - 1]->HandleSyncRequest(context); + + case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: { + LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x%08X", object_id); + + request_handlers[object_id - 1] = nullptr; + + IPC::RequestBuilder rb{context, 2}; + rb.Push(RESULT_SUCCESS); + + return RESULT_SUCCESS; + } + } + + LOG_CRITICAL(IPC, "Unknown domain command=%d", domain_message_header->command.Value()); + UNIMPLEMENTED(); } return request_handlers.front()->HandleSyncRequest(context); } diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index afa09b404..ac62a0d5a 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -102,13 +102,21 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) { data_payload_header = std::make_unique<IPC::DataPayloadHeader>(rp.PopRaw<IPC::DataPayloadHeader>()); + data_payload_offset = rp.GetCurrentOffset(); + + if (domain_message_header && + domain_message_header->command == + IPC::DomainMessageHeader::CommandType::CloseVirtualHandle) { + // CloseVirtualHandle command does not have SFC* or any data + return; + } + if (incoming) { ASSERT(data_payload_header->magic == Common::MakeMagic('S', 'F', 'C', 'I')); } else { ASSERT(data_payload_header->magic == Common::MakeMagic('S', 'F', 'C', 'O')); } - data_payload_offset = rp.GetCurrentOffset(); command = rp.Pop<u32_le>(); rp.Skip(1, false); // The command is actually an u64, but we don't use the high part. } diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 09caa43df..6dceb766d 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -151,13 +151,13 @@ public: return domain != nullptr; } - template<typename T> + template <typename T> SharedPtr<T> GetCopyObject(size_t index) { ASSERT(index < copy_objects.size()); return DynamicObjectCast<T>(copy_objects[index]); } - template<typename T> + template <typename T> SharedPtr<T> GetMoveObject(size_t index) { ASSERT(index < move_objects.size()); return DynamicObjectCast<T>(move_objects[index]); @@ -175,6 +175,14 @@ public: domain_objects.emplace_back(std::move(object)); } + /// Clears the list of objects so that no lingering objects are written accidentally to the + /// response buffer. + void ClearIncomingObjects() { + move_objects.clear(); + copy_objects.clear(); + domain_objects.clear(); + } + private: std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; SharedPtr<Kernel::Domain> domain; diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index df3b4083e..4d9549e45 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -105,7 +105,6 @@ public: UNREACHABLE(); } - public: static unsigned int next_object_id; diff --git a/src/core/hle/kernel/memory.cpp b/src/core/hle/kernel/memory.cpp index d990d0569..d2600cdd7 100644 --- a/src/core/hle/kernel/memory.cpp +++ b/src/core/hle/kernel/memory.cpp @@ -95,10 +95,8 @@ MemoryRegionInfo* GetMemoryRegion(MemoryRegion region) { } } -void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping) { -} +void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping) {} -void MapSharedPages(VMManager& address_space) { -} +void MapSharedPages(VMManager& address_space) {} } // namespace Kernel diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 49b6b454e..38db21005 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -41,9 +41,9 @@ public: return HANDLE_TYPE; } - u32 priority; ///< The priority of the mutex, used for priority inheritance. - std::string name; ///< Name of mutex (optional) - VAddr guest_addr; ///< Address of the guest mutex value + u32 priority; ///< The priority of the mutex, used for priority inheritance. + std::string name; ///< Name of mutex (optional) + VAddr guest_addr; ///< Address of the guest mutex value /** * Elevate the mutex priority to the best priority diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 20b4e401c..add98472f 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -131,6 +131,8 @@ public: /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse /// this value from the process header. u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK; + u32 allowed_thread_priority_mask = 0xFFFFFFFF; + u32 is_virtual_address_memory_enabled = 0; /// Current status of the process ProcessStatus status; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 9c60576c1..6401af35a 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -255,9 +255,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) { - LOG_TRACE(Kernel_SVC, - "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, " - "requesting_current_thread_handle=0x%08X", + 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); SharedPtr<Thread> holding_thread = g_handle_table.Get<Thread>(holding_thread_handle); @@ -305,14 +304,27 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) LOG_TRACE(Kernel_SVC, "called info_id=0x%X, info_sub_id=0x%X, handle=0x%08X", info_id, info_sub_id, handle); - ASSERT(handle == 0 || handle == CurrentProcess); - auto& vm_manager = g_current_process->vm_manager; switch (static_cast<GetInfoType>(info_id)) { case GetInfoType::AllowedCpuIdBitmask: *result = g_current_process->allowed_processor_mask; break; + case GetInfoType::AllowedThreadPrioBitmask: + *result = g_current_process->allowed_thread_priority_mask; + break; + case GetInfoType::MapRegionBaseAddr: + *result = vm_manager.GetAddressSpaceBaseAddr(); + break; + case GetInfoType::MapRegionSize: + *result = vm_manager.GetAddressSpaceSize(); + break; + case GetInfoType::HeapRegionBaseAddr: + *result = vm_manager.GetNewMapRegionBaseAddr() + vm_manager.GetNewMapRegionSize(); + break; + case GetInfoType::HeapRegionSize: + *result = Memory::HEAP_SIZE; + break; case GetInfoType::TotalMemoryUsage: *result = vm_manager.GetTotalMemoryUsage(); break; @@ -334,6 +346,18 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) case GetInfoType::NewMapRegionSize: *result = vm_manager.GetNewMapRegionSize(); break; + case GetInfoType::IsVirtualAddressMemoryEnabled: + *result = g_current_process->is_virtual_address_memory_enabled; + break; + case GetInfoType::TitleId: + LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query titleid, returned 0"); + *result = 0; + break; + case GetInfoType::PrivilegedProcessId: + LOG_WARNING(Kernel_SVC, + "(STUBBED) Attempted to query priviledged process id bounds, returned 0"); + *result = 0; + break; default: UNIMPLEMENTED(); } @@ -522,9 +546,8 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V Core::System::GetInstance().PrepareReschedule(); - LOG_TRACE(Kernel_SVC, - "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " - "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", + LOG_TRACE(Kernel_SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " + "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, name.c_str(), arg, stack_top, priority, processor_id, *out_handle); return RESULT_SUCCESS; @@ -709,6 +732,11 @@ static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 return RESULT_SUCCESS; } +static ResultCode SetThreadCoreMask(u64, u64, u64) { + LOG_WARNING(Kernel_SVC, "(STUBBED) called"); + return RESULT_SUCCESS; +} + namespace { struct FunctionDef { using Func = void(); @@ -735,7 +763,7 @@ static const FunctionDef SVC_Table[] = { {0x0C, SvcWrap<GetThreadPriority>, "GetThreadPriority"}, {0x0D, SvcWrap<SetThreadPriority>, "SetThreadPriority"}, {0x0E, nullptr, "GetThreadCoreMask"}, - {0x0F, nullptr, "SetThreadCoreMask"}, + {0x0F, SvcWrap<SetThreadCoreMask>, "SetThreadCoreMask"}, {0x10, SvcWrap<GetCurrentProcessorNumber>, "GetCurrentProcessorNumber"}, {0x11, nullptr, "SignalEvent"}, {0x12, nullptr, "ClearEvent"}, diff --git a/src/core/hle/kernel/svc.h b/src/core/hle/kernel/svc.h index 610cd1d7d..42cc41da3 100644 --- a/src/core/hle/kernel/svc.h +++ b/src/core/hle/kernel/svc.h @@ -24,14 +24,28 @@ struct PageInfo { enum class GetInfoType : u64 { // 1.0.0+ AllowedCpuIdBitmask = 0, + AllowedThreadPrioBitmask = 1, + MapRegionBaseAddr = 2, + MapRegionSize = 3, + HeapRegionBaseAddr = 4, + HeapRegionSize = 5, TotalMemoryUsage = 6, TotalHeapUsage = 7, + IsCurrentProcessBeingDebugged = 8, + ResourceHandleLimit = 9, + IdleTickCount = 10, RandomEntropy = 11, + PerformanceCounter = 0xF0000002, // 2.0.0+ AddressSpaceBaseAddr = 12, AddressSpaceSize = 13, NewMapRegionBaseAddr = 14, NewMapRegionSize = 15, + // 3.0.0+ + IsVirtualAddressMemoryEnabled = 16, + TitleId = 18, + // 4.0.0+ + PrivilegedProcessId = 19, }; void CallSVC(u32 immediate); diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index dca637dde..bf261699e 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -6,9 +6,9 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/arm/arm_interface.h" +#include "core/core.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/vm_manager.h" -#include "core/core.h" #include "core/memory.h" #include "core/memory_setup.h" #include "core/mmio.h" @@ -86,7 +86,8 @@ ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target, VirtualMemoryArea& final_vma = vma_handle->second; ASSERT(final_vma.size == size); - Core::CPU().MapBackingMemory(target, size, block->data() + offset, VMAPermission::ReadWriteExecute); + Core::CPU().MapBackingMemory(target, size, block->data() + offset, + VMAPermission::ReadWriteExecute); final_vma.type = VMAType::AllocatedMemoryBlock; final_vma.permissions = VMAPermission::ReadWrite; @@ -356,12 +357,12 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { u64 VMManager::GetTotalMemoryUsage() { LOG_WARNING(Kernel, "(STUBBED) called"); - return 0x400000; + return 0xBE000000; } u64 VMManager::GetTotalHeapUsage() { LOG_WARNING(Kernel, "(STUBBED) called"); - return 0x10000; + return 0x0; } VAddr VMManager::GetAddressSpaceBaseAddr() { |