strat: use sf::NativeHandle for ipc templating
This commit is contained in:
@@ -410,12 +410,12 @@ namespace ams::mitm::sysupdater {
|
||||
return ResultSuccess();
|
||||
};
|
||||
|
||||
Result SystemUpdateService::SetupUpdate(sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat) {
|
||||
return this->SetupUpdateImpl(transfer_memory.GetValue(), transfer_memory_size, path, exfat, GetFirmwareVariationId());
|
||||
Result SystemUpdateService::SetupUpdate(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat) {
|
||||
return this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, GetFirmwareVariationId());
|
||||
}
|
||||
|
||||
Result SystemUpdateService::SetupUpdateWithVariation(sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
|
||||
return this->SetupUpdateImpl(transfer_memory.GetValue(), transfer_memory_size, path, exfat, firmware_variation_id);
|
||||
Result SystemUpdateService::SetupUpdateWithVariation(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
|
||||
return this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id);
|
||||
}
|
||||
|
||||
Result SystemUpdateService::RequestPrepareUpdate(sf::OutCopyHandle out_event_handle, sf::Out<sf::SharedPointer<ns::impl::IAsyncResult>> out_async) {
|
||||
@@ -432,7 +432,7 @@ namespace ams::mitm::sysupdater {
|
||||
|
||||
/* We prepared the task! */
|
||||
this->requested_update = true;
|
||||
out_event_handle.SetValue(async_result.GetImpl().GetEvent().GetReadableHandle());
|
||||
out_event_handle.SetValue(async_result.GetImpl().GetEvent().GetReadableHandle(), false);
|
||||
*out_async = std::move(async_result);
|
||||
|
||||
return ResultSuccess();
|
||||
@@ -469,10 +469,7 @@ namespace ams::mitm::sysupdater {
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SystemUpdateService::SetupUpdateImpl(os::NativeHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
|
||||
/* Ensure the transfer memory handle is closed, if we exit before creating the management object. */
|
||||
auto handle_guard = SCOPE_GUARD { os::CloseNativeHandle(transfer_memory); };
|
||||
|
||||
Result SystemUpdateService::SetupUpdateImpl(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
|
||||
/* Ensure we don't already have an update set up. */
|
||||
R_UNLESS(!this->setup_update, ns::ResultCardUpdateAlreadySetup());
|
||||
|
||||
@@ -484,18 +481,18 @@ namespace ams::mitm::sysupdater {
|
||||
}
|
||||
|
||||
/* Initialize the update task. */
|
||||
handle_guard.Cancel();
|
||||
R_TRY(InitializeUpdateTask(transfer_memory, transfer_memory_size, path, exfat, firmware_variation_id));
|
||||
R_TRY(InitializeUpdateTask(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id));
|
||||
|
||||
/* The update is now set up. */
|
||||
this->setup_update = true;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SystemUpdateService::InitializeUpdateTask(os::NativeHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
|
||||
Result SystemUpdateService::InitializeUpdateTask(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
|
||||
/* Map the transfer memory. */
|
||||
const size_t tmem_buffer_size = static_cast<size_t>(transfer_memory_size);
|
||||
this->update_transfer_memory.emplace(tmem_buffer_size, transfer_memory, true);
|
||||
this->update_transfer_memory.emplace(tmem_buffer_size, transfer_memory.GetOsHandle(), transfer_memory.IsManaged());
|
||||
transfer_memory.Detach();
|
||||
|
||||
void *tmem_buffer;
|
||||
R_TRY(this->update_transfer_memory->Map(std::addressof(tmem_buffer), os::MemoryPermission_None));
|
||||
|
||||
@@ -40,14 +40,14 @@ namespace ams::mitm::sysupdater {
|
||||
|
||||
}
|
||||
|
||||
#define AMS_SYSUPDATER_SYSTEM_UPDATE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, GetUpdateInformation, (sf::Out<mitm::sysupdater::UpdateInformation> out, const ncm::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, ValidateUpdate, (sf::Out<Result> out_validate_result, sf::Out<Result> out_validate_exfat_result, sf::Out<mitm::sysupdater::UpdateValidationInfo> out_validate_info, const ncm::Path &path), (out_validate_result, out_validate_exfat_result, out_validate_info, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, SetupUpdate, (sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat), (transfer_memory, transfer_memory_size, path, exfat)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, SetupUpdateWithVariation, (sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id), (transfer_memory, transfer_memory_size, path, exfat, firmware_variation_id)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, RequestPrepareUpdate, (sf::OutCopyHandle out_event_handle, sf::Out<sf::SharedPointer<ns::impl::IAsyncResult>> out_async), (out_event_handle, out_async)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, GetPrepareUpdateProgress, (sf::Out<mitm::sysupdater::SystemUpdateProgress> out), (out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 6, Result, HasPreparedUpdate, (sf::Out<bool> out), (out)) \
|
||||
#define AMS_SYSUPDATER_SYSTEM_UPDATE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, GetUpdateInformation, (sf::Out<mitm::sysupdater::UpdateInformation> out, const ncm::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, ValidateUpdate, (sf::Out<Result> out_validate_result, sf::Out<Result> out_validate_exfat_result, sf::Out<mitm::sysupdater::UpdateValidationInfo> out_validate_info, const ncm::Path &path), (out_validate_result, out_validate_exfat_result, out_validate_info, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, SetupUpdate, (sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat), (std::move(transfer_memory), transfer_memory_size, path, exfat)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, SetupUpdateWithVariation, (sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id), (std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, RequestPrepareUpdate, (sf::OutCopyHandle out_event_handle, sf::Out<sf::SharedPointer<ns::impl::IAsyncResult>> out_async), (out_event_handle, out_async)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, GetPrepareUpdateProgress, (sf::Out<mitm::sysupdater::SystemUpdateProgress> out), (out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 6, Result, HasPreparedUpdate, (sf::Out<bool> out), (out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 7, Result, ApplyPreparedUpdate, (), ())
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::mitm::sysupdater::impl, ISystemUpdateInterface, AMS_SYSUPDATER_SYSTEM_UPDATE_INTERFACE_INFO)
|
||||
@@ -64,13 +64,13 @@ namespace ams::mitm::sysupdater {
|
||||
public:
|
||||
constexpr SystemUpdateService() : apply_manager(), update_task(), update_transfer_memory(), setup_update(false), requested_update(false) { /* ... */ }
|
||||
private:
|
||||
Result SetupUpdateImpl(os::NativeHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id);
|
||||
Result InitializeUpdateTask(os::NativeHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id);
|
||||
Result SetupUpdateImpl(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id);
|
||||
Result InitializeUpdateTask(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id);
|
||||
public:
|
||||
Result GetUpdateInformation(sf::Out<UpdateInformation> out, const ncm::Path &path);
|
||||
Result ValidateUpdate(sf::Out<Result> out_validate_result, sf::Out<Result> out_validate_exfat_result, sf::Out<UpdateValidationInfo> out_validate_info, const ncm::Path &path);
|
||||
Result SetupUpdate(sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat);
|
||||
Result SetupUpdateWithVariation(sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id);
|
||||
Result SetupUpdate(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat);
|
||||
Result SetupUpdateWithVariation(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id);
|
||||
Result RequestPrepareUpdate(sf::OutCopyHandle out_event_handle, sf::Out<sf::SharedPointer<ns::impl::IAsyncResult>> out_async);
|
||||
Result GetPrepareUpdateProgress(sf::Out<SystemUpdateProgress> out);
|
||||
Result HasPreparedUpdate(sf::Out<bool> out);
|
||||
|
||||
Reference in New Issue
Block a user