diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 9c60576c16..d832a07d28 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -314,10 +314,10 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) *result = g_current_process->allowed_processor_mask; break; case GetInfoType::TotalMemoryUsage: - *result = vm_manager.GetTotalMemoryUsage(); + *result = 0xBE000000;//vm_manager.GetTotalMemoryUsage(); break; case GetInfoType::TotalHeapUsage: - *result = vm_manager.GetTotalHeapUsage(); + *result = 0;//vm_manager.GetTotalHeapUsage(); break; case GetInfoType::RandomEntropy: *result = 0; @@ -328,12 +328,22 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) case GetInfoType::AddressSpaceSize: *result = vm_manager.GetAddressSpaceSize(); break; + case GetInfoType::MapRegionBaseAddr: + *result = vm_manager.GetAddressSpaceBaseAddr(); + break; + case GetInfoType::MapRegionSize: + *result = vm_manager.GetAddressSpaceSize(); + break; case GetInfoType::NewMapRegionBaseAddr: *result = vm_manager.GetNewMapRegionBaseAddr(); break; case GetInfoType::NewMapRegionSize: *result = vm_manager.GetNewMapRegionSize(); break; + + case GetInfoType::IsVirtualAddressMemoryEnabled: + *result = 1; + break; default: UNIMPLEMENTED(); } @@ -709,6 +719,16 @@ static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 return RESULT_SUCCESS; } +static ResultCode MapPhysicalMemory(VAddr addr, u64 size) { + LOG_WARNING(Kernel_SVC, "(STUBBED) called addr 0x%llx size 0x%llx", addr, size); + return RESULT_SUCCESS; +} + +static ResultCode SetThreadCoreMask(u32 in0, u64 in1) { + LOG_WARNING(Kernel_SVC, "(STUBBED) called in0 0x%llx in1 0x%llx", in0, in1); + return RESULT_SUCCESS; +} + namespace { struct FunctionDef { using Func = void(); @@ -735,7 +755,7 @@ static const FunctionDef SVC_Table[] = { {0x0C, SvcWrap, "GetThreadPriority"}, {0x0D, SvcWrap, "SetThreadPriority"}, {0x0E, nullptr, "GetThreadCoreMask"}, - {0x0F, nullptr, "SetThreadCoreMask"}, + {0x0F, SvcWrap, "SetThreadCoreMask"}, {0x10, SvcWrap, "GetCurrentProcessorNumber"}, {0x11, nullptr, "SignalEvent"}, {0x12, nullptr, "ClearEvent"}, @@ -764,7 +784,7 @@ static const FunctionDef SVC_Table[] = { {0x29, SvcWrap, "GetInfo"}, {0x2A, nullptr, "FlushEntireDataCache"}, {0x2B, nullptr, "FlushDataCache"}, - {0x2C, nullptr, "MapPhysicalMemory"}, + {0x2C, SvcWrap, "MapPhysicalMemory"}, {0x2D, nullptr, "UnmapPhysicalMemory"}, {0x2E, nullptr, "Unknown"}, {0x2F, nullptr, "GetLastThreadInfo"}, diff --git a/src/core/hle/kernel/svc.h b/src/core/hle/kernel/svc.h index 610cd1d7d7..f43c95fdde 100644 --- a/src/core/hle/kernel/svc.h +++ b/src/core/hle/kernel/svc.h @@ -24,6 +24,8 @@ struct PageInfo { enum class GetInfoType : u64 { // 1.0.0+ AllowedCpuIdBitmask = 0, + MapRegionBaseAddr = 2, + MapRegionSize = 3, TotalMemoryUsage = 6, TotalHeapUsage = 7, RandomEntropy = 11, @@ -32,6 +34,8 @@ enum class GetInfoType : u64 { AddressSpaceSize = 13, NewMapRegionBaseAddr = 14, NewMapRegionSize = 15, + + IsVirtualAddressMemoryEnabled = 16, }; void CallSVC(u32 immediate); diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index fd7054bbda..34e2f91046 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -169,6 +169,16 @@ void SvcWrap() { func(); } +template +void SvcWrap() { + func(PARAM(0), PARAM(1)); +} + +template +void SvcWrap() { + func(PARAM(0), PARAM(1)); +} + template void SvcWrap() { func((s64)PARAM(0)); diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp new file mode 100644 index 0000000000..eb774d6ca8 --- /dev/null +++ b/src/core/hle/service/acc/acc.cpp @@ -0,0 +1,31 @@ +// Copyright 2018 yuzu emulator team +// 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/service/acc/acc.h" + +namespace Service { +namespace Account { + +void InstallInterfaces(SM::ServiceManager& service_manager) { + std::make_shared()->InstallAsService(service_manager); +} + +Acc_U0::Acc_U0() : ServiceFramework("acc:u0") { + static const FunctionInfo functions[] = { + {100, &Acc_U0::InitializeApplicationInfo, "InitializeApplicationInfo" }, + }; + RegisterHandlers(functions); +} + +void Acc_U0::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called"); + IPC::RequestBuilder rb{ ctx, 2 }; + rb.Push(RESULT_SUCCESS); +} + + +} +} diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h new file mode 100644 index 0000000000..8ef48b2bd2 --- /dev/null +++ b/src/core/hle/service/acc/acc.h @@ -0,0 +1,23 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/kernel/hle_ipc.h" +#include "core/hle/service/service.h" + +namespace Service { +namespace Account { + +void InstallInterfaces(SM::ServiceManager& service_manager); + + +class Acc_U0 final : public ServiceFramework { +public: + Acc_U0(); + ~Acc_U0() = default; +private: + void InitializeApplicationInfo(Kernel::HLERequestContext& ctx); +}; + +} +} diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp index f65d6b9f51..704fa53cb0 100644 --- a/src/core/hle/service/am/applet_oe.cpp +++ b/src/core/hle/service/am/applet_oe.cpp @@ -54,7 +54,12 @@ class ISelfController final : public ServiceFramework { public: ISelfController() : ServiceFramework("ISelfController") { static const FunctionInfo functions[] = { + {11, &ISelfController::SetOperationModeChangedNotification, "SetOperationModeChangedNotification"}, + {12, &ISelfController::SetPerformanceModeChangedNotification, "SetPerformanceModeChangedNotification" }, {13, &ISelfController::SetFocusHandlingMode, "SetFocusHandlingMode"}, + {14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"}, + {16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"}, + }; RegisterHandlers(functions); } @@ -69,6 +74,38 @@ private: LOG_WARNING(Service, "(STUBBED) called"); } + + void SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) { + IPC::RequestBuilder rb{ ctx, 2 }; + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service, "(STUBBED) called"); + } + + void SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) { + IPC::RequestBuilder rb{ ctx, 2 }; + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service, "(STUBBED) called"); + } + + void SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) { + IPC::RequestBuilder rb{ ctx, 2 }; + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service, "(STUBBED) called"); + } + + void SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) { + // Takes 3 input u8s with each field located immediately after the previous u8, these are + // bool flags. No output. + + IPC::RequestBuilder rb{ ctx, 2 }; + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service, "(STUBBED) called"); + } + }; class ICommonStateGetter final : public ServiceFramework { diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp index f70b9fc100..2f9c32f058 100644 --- a/src/core/hle/service/apm/apm.cpp +++ b/src/core/hle/service/apm/apm.cpp @@ -4,6 +4,8 @@ #include "common/logging/log.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/client_port.h" +#include "core/hle/kernel/client_session.h" #include "core/hle/service/apm/apm.h" namespace Service { @@ -13,13 +15,47 @@ void InstallInterfaces(SM::ServiceManager& service_manager) { std::make_shared()->InstallAsService(service_manager); } +class ISession final : public ServiceFramework { +public: + ISession() : ServiceFramework("ISession") { + static const FunctionInfo functions[] = { + {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration" }, + }; + RegisterHandlers(functions); + } +private: + void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called"); + IPC::RequestBuilder rb{ ctx, 2 }; + rb.Push(RESULT_SUCCESS); + } +}; + +void APM::OpenSession(Kernel::HLERequestContext& ctx) { + auto client_port = std::make_shared()->CreatePort(); + auto session = client_port->Connect(); + if (session.Succeeded()) { + LOG_DEBUG(Service_SM, "called, initialized ISession -> session=%u", + (*session)->GetObjectId()); + IPC::RequestBuilder rb{ ctx, 2, 0, 1 }; + rb.Push(RESULT_SUCCESS); + rb.PushMoveObjects(std::move(session).Unwrap()); + } + else { + UNIMPLEMENTED(); + } + + LOG_INFO(Service_SM, "called"); +} + APM::APM() : ServiceFramework("apm") { static const FunctionInfo functions[] = { - {0x00000000, nullptr, "OpenSession"}, + {0x00000000, &APM::OpenSession, "OpenSession"}, {0x00000001, nullptr, "GetPerformanceMode"}, }; RegisterHandlers(functions); } + } // namespace APM } // namespace Service diff --git a/src/core/hle/service/apm/apm.h b/src/core/hle/service/apm/apm.h index 377db71a4b..1a500f1ede 100644 --- a/src/core/hle/service/apm/apm.h +++ b/src/core/hle/service/apm/apm.h @@ -13,6 +13,8 @@ class APM final : public ServiceFramework { public: APM(); ~APM() = default; +private: + void OpenSession(Kernel::HLERequestContext& ctx); }; /// Registers all AM services with the specified service manager. diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp new file mode 100644 index 0000000000..90c24d9c33 --- /dev/null +++ b/src/core/hle/service/fatal/fatal.cpp @@ -0,0 +1,31 @@ +// Copyright 2018 yuzu emulator team +// 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/service/fatal/fatal.h" + +namespace Service { +namespace Fatal { + +void InstallInterfaces(SM::ServiceManager& service_manager) { + std::make_shared()->InstallAsService(service_manager); +} + +Fatal_U::Fatal_U() : ServiceFramework("fatal:u") { + static const FunctionInfo functions[] = { + { 2, &Fatal_U::TransitionToFatalError, "TransitionToFatalError" }, + }; + RegisterHandlers(functions); +} + +void Fatal_U::TransitionToFatalError(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called"); + IPC::RequestBuilder rb{ ctx, 2 }; + rb.Push(RESULT_SUCCESS); +} + + +} +} diff --git a/src/core/hle/service/fatal/fatal.h b/src/core/hle/service/fatal/fatal.h new file mode 100644 index 0000000000..3eebcc805d --- /dev/null +++ b/src/core/hle/service/fatal/fatal.h @@ -0,0 +1,23 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/kernel/hle_ipc.h" +#include "core/hle/service/service.h" + +namespace Service { +namespace Fatal { + +void InstallInterfaces(SM::ServiceManager& service_manager); + + +class Fatal_U final : public ServiceFramework { +public: + Fatal_U(); + ~Fatal_U() = default; +private: + void TransitionToFatalError(Kernel::HLERequestContext& ctx); +}; + +} +} diff --git a/src/core/hle/service/nvdrv/nvdrv_a.cpp b/src/core/hle/service/nvdrv/nvdrv_a.cpp index 84d89cb493..0c9a2da33c 100644 --- a/src/core/hle/service/nvdrv/nvdrv_a.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_a.cpp @@ -30,6 +30,7 @@ void NVDRV_A::Open(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(fd); rb.Push(0); + LOG_WARNING(Service, "Opened!!!"); } void NVDRV_A::Ioctl(Kernel::HLERequestContext& ctx) { @@ -66,7 +67,7 @@ void NVDRV_A::Initialize(Kernel::HLERequestContext& ctx) { rb.Push(0); } -NVDRV_A::NVDRV_A() : ServiceFramework("nvdrv:a") { +NVDRV_A::NVDRV_A() : ServiceFramework("nvdrv") { static const FunctionInfo functions[] = { {0, &NVDRV_A::Open, "Open"}, {1, &NVDRV_A::Ioctl, "Ioctl"}, diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 02d4346601..dc5c79911a 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -14,10 +14,12 @@ #include "core/hle/kernel/process.h" #include "core/hle/kernel/server_port.h" #include "core/hle/kernel/thread.h" +#include "core/hle/service/acc/acc.h" #include "core/hle/service/am/am.h" #include "core/hle/service/aoc/aoc_u.h" #include "core/hle/service/apm/apm.h" #include "core/hle/service/audio/audio.h" +#include "core/hle/service/fatal/fatal.h" #include "core/hle/service/hid/hid.h" #include "core/hle/service/lm/lm.h" #include "core/hle/service/nvdrv/nvdrv.h" @@ -164,10 +166,12 @@ void Init() { SM::g_service_manager = std::make_shared(); SM::ServiceManager::InstallInterfaces(SM::g_service_manager); + Account::InstallInterfaces(*SM::g_service_manager); AM::InstallInterfaces(*SM::g_service_manager); AOC::InstallInterfaces(*SM::g_service_manager); APM::InstallInterfaces(*SM::g_service_manager); Audio::InstallInterfaces(*SM::g_service_manager); + Fatal::InstallInterfaces(*SM::g_service_manager); HID::InstallInterfaces(*SM::g_service_manager); LM::InstallInterfaces(*SM::g_service_manager); NVDRV::InstallInterfaces(*SM::g_service_manager); diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp index e8f5d0e4a2..27e4ee62dd 100644 --- a/src/core/hle/service/sm/controller.cpp +++ b/src/core/hle/service/sm/controller.cpp @@ -46,7 +46,7 @@ Controller::Controller() : ServiceFramework("IpcController") { {0x00000001, nullptr, "ConvertDomainToSession"}, {0x00000002, &Controller::DuplicateSession, "DuplicateSession"}, {0x00000003, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"}, - {0x00000004, nullptr, "DuplicateSessionEx"}, + {0x00000004, &Controller::DuplicateSession, "DuplicateSessionEx"}, }; RegisterHandlers(functions); } diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp index 1a5a28b0d8..5875b90e31 100644 --- a/src/core/hle/service/vi/vi_m.cpp +++ b/src/core/hle/service/vi/vi_m.cpp @@ -8,23 +8,23 @@ #include "core/hle/service/vi/vi_m.h" namespace Service { -namespace VI { + namespace VI { -void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service, "(STUBBED) called"); + void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called"); - IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; - rb.PushIpcInterface(nv_flinger); -} + IPC::RequestBuilder rb{ ctx, 2, 0, 0, 1 }; + rb.PushIpcInterface(nv_flinger); + } -VI_M::VI_M() : ServiceFramework("vi:m") { - static const FunctionInfo functions[] = { - {2, &VI_M::GetDisplayService, "GetDisplayService"}, - {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, - }; - RegisterHandlers(functions); - nv_flinger = std::make_shared(); -} + VI_M::VI_M() : ServiceFramework("vi:m") { + static const FunctionInfo functions[] = { + { 2, &VI_M::GetDisplayService, "GetDisplayService" }, + { 3, nullptr, "GetDisplayServiceWithProxyNameExchange" }, + }; + RegisterHandlers(functions); + nv_flinger = std::make_shared(); + } -} // namespace VI + } // namespace VI } // namespace Service diff --git a/src/core/memory.h b/src/core/memory.h index 91bd4d8891..f802481ebc 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -124,19 +124,19 @@ enum : PAddr { /// Virtual user-space memory regions enum : VAddr { - /// Where the application text, data and bss reside. - PROCESS_IMAGE_VADDR = 0x08000000, - PROCESS_IMAGE_MAX_SIZE = 0x08000000, - PROCESS_IMAGE_VADDR_END = PROCESS_IMAGE_VADDR + PROCESS_IMAGE_MAX_SIZE, + /// Where the application text, data and bss reside. + PROCESS_IMAGE_VADDR = 0x08000000, + PROCESS_IMAGE_MAX_SIZE = 0x08000000, + PROCESS_IMAGE_VADDR_END = PROCESS_IMAGE_VADDR + PROCESS_IMAGE_MAX_SIZE, - /// Area where IPC buffers are mapped onto. - IPC_MAPPING_VADDR = 0x04000000, - IPC_MAPPING_SIZE = 0x04000000, - IPC_MAPPING_VADDR_END = IPC_MAPPING_VADDR + IPC_MAPPING_SIZE, + /// Area where IPC buffers are mapped onto. + IPC_MAPPING_VADDR = 0x04000000, + IPC_MAPPING_SIZE = 0x04000000, + IPC_MAPPING_VADDR_END = IPC_MAPPING_VADDR + IPC_MAPPING_SIZE, - /// Application heap (includes stack). - HEAP_VADDR = 0x108000000, - HEAP_SIZE = 0x18000000, + /// Application heap (includes stack). + HEAP_VADDR = 0x108000000, + HEAP_SIZE = 0xF0000000,//0x18000000, HEAP_VADDR_END = HEAP_VADDR + HEAP_SIZE, /// Area where shared memory buffers are mapped onto. @@ -177,7 +177,7 @@ enum : VAddr { SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE, /// Area where TLS (Thread-Local Storage) buffers are allocated. - TLS_AREA_VADDR = 0x1FF82000, + TLS_AREA_VADDR = 0x228000000,//0x1FF82000, TLS_ENTRY_SIZE = 0x200, /// Equivalent to LINEAR_HEAP_VADDR, but expanded to cover the extra memory in the New 3DS.