From 1b04b7265301684530dd2298b5d148a05dc010c3 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 17 Apr 2019 11:59:07 -0400 Subject: am: Unstub IApplicationFunctions EnsureSaveData (20) Creates a default save data for the application given a user ID. --- src/core/hle/service/am/am.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/core/hle/service/am') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index aa2c83937..eae052ce0 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1143,13 +1143,20 @@ void IApplicationFunctions::CreateApplicationAndRequestToStartForQuest( void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - u128 uid = rp.PopRaw(); // What does this do? - LOG_WARNING(Service, "(STUBBED) called uid = {:016X}{:016X}", uid[1], uid[0]); + u128 user_id = rp.PopRaw(); + + LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]); + + FileSys::SaveDataDescriptor descriptor{}; + descriptor.title_id = Core::CurrentProcess()->GetTitleID(); + descriptor.user_id = user_id; + descriptor.type = FileSys::SaveDataType::SaveData; + const auto res = fsc.CreateSaveData(FileSys::SaveDataSpaceId::NandUser, descriptor); IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(RESULT_SUCCESS); + rb.Push(res.Code()); rb.Push(0); -} // namespace Service::AM +} void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) { // Takes an input u32 Result, no output. @@ -1261,8 +1268,8 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) { "new_journal={:016X}", static_cast(type), user_id[1], user_id[0], new_normal_size, new_journal_size); - const auto title_id = system.CurrentProcess()->GetTitleID(); - FileSystem::WriteSaveDataSize(type, title_id, user_id, {new_normal_size, new_journal_size}); + fsc.WriteSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id, + {new_normal_size, new_journal_size}); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(RESULT_SUCCESS); @@ -1281,8 +1288,7 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast(type), user_id[1], user_id[0]); - const auto title_id = system.CurrentProcess()->GetTitleID(); - const auto size = FileSystem::ReadSaveDataSize(type, title_id, user_id); + const auto size = fsc.ReadSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id); IPC::ResponseBuilder rb{ctx, 6}; rb.Push(RESULT_SUCCESS); -- cgit v1.2.3