sysupdater: minor api fixes (now verified working on hardware)

This commit is contained in:
Michael Scire 2020-06-27 07:33:36 -07:00
parent 76fa4db2ed
commit 838492c84c
5 changed files with 27 additions and 11 deletions

View File

@ -318,12 +318,12 @@ namespace ams::ncm {
return reinterpret_cast<uintptr_t>(this->data);
}
uintptr_t GetFirmwarVariationIdStartAddress() const {
uintptr_t GetFirmwareVariationIdStartAddress() const {
return this->GetHeaderAddress() + sizeof(SystemUpdateMetaExtendedDataHeader);
}
uintptr_t GetFirmwareVariationIdAddress(size_t i) const {
return this->GetFirmwarVariationIdStartAddress() + i * sizeof(FirmwareVariationId);
return this->GetFirmwareVariationIdStartAddress() + i * sizeof(FirmwareVariationId);
}
uintptr_t GetFirmwareVariationInfoStartAddress() const {
@ -331,7 +331,7 @@ namespace ams::ncm {
}
uintptr_t GetFirmwareVariationInfoAddress(size_t i) const {
return this->GetFirmwarVariationIdStartAddress() + i * sizeof(FirmwareVariationInfo);
return this->GetFirmwareVariationInfoStartAddress() + i * sizeof(FirmwareVariationInfo);
}
uintptr_t GetContentMetaInfoStartAddress() const {

View File

@ -62,6 +62,8 @@
"svcReplyAndReceive": "0x43",
"svcReplyAndReceiveWithUserBuffer": "0x44",
"svcCreateEvent": "0x45",
"svcMapTransferMemory": "0x51",
"svcUnmapTransferMemory": "0x52",
"svcCreateInterruptEvent": "0x53",
"svcReadWriteRegister": "0x4E",
"svcQueryIoMapping": "0x55",

View File

@ -55,10 +55,10 @@ namespace ams::mitm::sysupdater {
}
Result ParseMountName(const char **path, std::shared_ptr<ams::fs::fsa::IFileSystem> *out) {
/* The equivalent function here supports all the common mount names; we'll only support the SD card. */
if (const auto sd_mount_len = strnlen(ams::fs::impl::SdCardFileSystemMountName, ams::fs::MountNameLengthMax); std::strncmp(*path, ams::fs::impl::SdCardFileSystemMountName, sd_mount_len) == 0) {
/* Open an sd card fs. */
*path += sd_mount_len;
/* The equivalent function here supports all the common mount names; we'll only support the SD card, system content storage. */
if (const auto mount_len = strnlen(ams::fs::impl::SdCardFileSystemMountName, ams::fs::MountNameLengthMax); std::strncmp(*path, ams::fs::impl::SdCardFileSystemMountName, mount_len) == 0) {
/* Advance the path. */
*path += mount_len;
/* Open the SD card. This uses libnx bindings. */
FsFileSystem fs;
@ -68,6 +68,20 @@ namespace ams::mitm::sysupdater {
auto fsa = std::make_shared<ams::fs::RemoteFileSystem>(fs);
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInSdCardA());
/* Set the output fs. */
*out = std::move(fsa);
} else if (const auto mount_len = strnlen(ams::fs::impl::ContentStorageSystemMountName, ams::fs::MountNameLengthMax); std::strncmp(*path, ams::fs::impl::ContentStorageSystemMountName, mount_len) == 0) {
/* Advance the path. */
*path += mount_len;
/* Open the system content storage. This uses libnx bindings. */
FsFileSystem fs;
R_TRY(fsOpenContentStorageFileSystem(std::addressof(fs), FsContentStorageId_System));
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_shared<ams::fs::RemoteFileSystem>(fs);
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInContentStorageA());
/* Set the output fs. */
*out = std::move(fsa);
} else {

View File

@ -403,11 +403,11 @@ namespace ams::mitm::sysupdater {
return ResultSuccess();
};
Result SystemUpdateService::SetupUpdate(sf::MoveHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat) {
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::SetupUpdateWithVariation(sf::MoveHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId 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(transfer_memory.GetValue(), transfer_memory_size, path, exfat, firmware_variation_id);
}

View File

@ -65,8 +65,8 @@ namespace ams::mitm::sysupdater {
private:
Result GetUpdateInformation(sf::Out<UpdateInformation> out, const ncm::Path &path);
Result ValidateUpdate(sf::Out<Result> out_validate_result, sf::Out<UpdateValidationInfo> out_validate_info, const ncm::Path &path);
Result SetupUpdate(sf::MoveHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat);
Result SetupUpdateWithVariation(sf::MoveHandle 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<std::shared_ptr<IAsyncResult>> out_async);
Result GetPrepareUpdateProgress(sf::Out<SystemUpdateProgress> out);
Result HasPreparedUpdate(sf::Out<bool> out);