diff options
| author | 2018-10-30 05:03:25 +0100 | |
|---|---|---|
| committer | 2018-10-30 00:03:25 -0400 | |
| commit | 7a5eda59146306dedaf3e6f07f97a8c6898543dd (patch) | |
| tree | 78e07b43fb0113f95e1c8e9426d3b394b9524d4e /src/core | |
| parent | Merge pull request #1621 from lioncash/ipc (diff) | |
| download | yuzu-7a5eda59146306dedaf3e6f07f97a8c6898543dd.tar.gz yuzu-7a5eda59146306dedaf3e6f07f97a8c6898543dd.tar.xz yuzu-7a5eda59146306dedaf3e6f07f97a8c6898543dd.zip | |
global: Use std::optional instead of boost::optional (#1578)
* get rid of boost::optional
* Remove optional references
* Use std::reference_wrapper for optional references
* Fix clang format
* Fix clang format part 2
* Adressed feedback
* Fix clang format and MacOS build
Diffstat (limited to 'src/core')
24 files changed, 141 insertions, 144 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 6c32154db..6d5b5a2d0 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -185,7 +185,7 @@ struct System::Impl { | |||
| 185 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); | 185 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); |
| 186 | return ResultStatus::ErrorGetLoader; | 186 | return ResultStatus::ErrorGetLoader; |
| 187 | } | 187 | } |
| 188 | std::pair<boost::optional<u32>, Loader::ResultStatus> system_mode = | 188 | std::pair<std::optional<u32>, Loader::ResultStatus> system_mode = |
| 189 | app_loader->LoadKernelSystemMode(); | 189 | app_loader->LoadKernelSystemMode(); |
| 190 | 190 | ||
| 191 | if (system_mode.second != Loader::ResultStatus::Success) { | 191 | if (system_mode.second != Loader::ResultStatus::Success) { |
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 89ae79eb3..904afa039 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp | |||
| @@ -141,28 +141,28 @@ Key128 DeriveKeyblobMACKey(const Key128& keyblob_key, const Key128& mac_source) | |||
| 141 | return mac_key; | 141 | return mac_key; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | boost::optional<Key128> DeriveSDSeed() { | 144 | std::optional<Key128> DeriveSDSeed() { |
| 145 | const FileUtil::IOFile save_43(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + | 145 | const FileUtil::IOFile save_43(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + |
| 146 | "/system/save/8000000000000043", | 146 | "/system/save/8000000000000043", |
| 147 | "rb+"); | 147 | "rb+"); |
| 148 | if (!save_43.IsOpen()) | 148 | if (!save_43.IsOpen()) |
| 149 | return boost::none; | 149 | return {}; |
| 150 | 150 | ||
| 151 | const FileUtil::IOFile sd_private( | 151 | const FileUtil::IOFile sd_private( |
| 152 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + "/Nintendo/Contents/private", "rb+"); | 152 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + "/Nintendo/Contents/private", "rb+"); |
| 153 | if (!sd_private.IsOpen()) | 153 | if (!sd_private.IsOpen()) |
| 154 | return boost::none; | 154 | return {}; |
| 155 | 155 | ||
| 156 | std::array<u8, 0x10> private_seed{}; | 156 | std::array<u8, 0x10> private_seed{}; |
| 157 | if (sd_private.ReadBytes(private_seed.data(), private_seed.size()) != private_seed.size()) { | 157 | if (sd_private.ReadBytes(private_seed.data(), private_seed.size()) != private_seed.size()) { |
| 158 | return boost::none; | 158 | return {}; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | std::array<u8, 0x10> buffer{}; | 161 | std::array<u8, 0x10> buffer{}; |
| 162 | std::size_t offset = 0; | 162 | std::size_t offset = 0; |
| 163 | for (; offset + 0x10 < save_43.GetSize(); ++offset) { | 163 | for (; offset + 0x10 < save_43.GetSize(); ++offset) { |
| 164 | if (!save_43.Seek(offset, SEEK_SET)) { | 164 | if (!save_43.Seek(offset, SEEK_SET)) { |
| 165 | return boost::none; | 165 | return {}; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | save_43.ReadBytes(buffer.data(), buffer.size()); | 168 | save_43.ReadBytes(buffer.data(), buffer.size()); |
| @@ -172,12 +172,12 @@ boost::optional<Key128> DeriveSDSeed() { | |||
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | if (!save_43.Seek(offset + 0x10, SEEK_SET)) { | 174 | if (!save_43.Seek(offset + 0x10, SEEK_SET)) { |
| 175 | return boost::none; | 175 | return {}; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | Key128 seed{}; | 178 | Key128 seed{}; |
| 179 | if (save_43.ReadBytes(seed.data(), seed.size()) != seed.size()) { | 179 | if (save_43.ReadBytes(seed.data(), seed.size()) != seed.size()) { |
| 180 | return boost::none; | 180 | return {}; |
| 181 | } | 181 | } |
| 182 | return seed; | 182 | return seed; |
| 183 | } | 183 | } |
| @@ -291,26 +291,26 @@ static std::array<u8, target_size> MGF1(const std::array<u8, in_size>& seed) { | |||
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | template <size_t size> | 293 | template <size_t size> |
| 294 | static boost::optional<u64> FindTicketOffset(const std::array<u8, size>& data) { | 294 | static std::optional<u64> FindTicketOffset(const std::array<u8, size>& data) { |
| 295 | u64 offset = 0; | 295 | u64 offset = 0; |
| 296 | for (size_t i = 0x20; i < data.size() - 0x10; ++i) { | 296 | for (size_t i = 0x20; i < data.size() - 0x10; ++i) { |
| 297 | if (data[i] == 0x1) { | 297 | if (data[i] == 0x1) { |
| 298 | offset = i + 1; | 298 | offset = i + 1; |
| 299 | break; | 299 | break; |
| 300 | } else if (data[i] != 0x0) { | 300 | } else if (data[i] != 0x0) { |
| 301 | return boost::none; | 301 | return {}; |
| 302 | } | 302 | } |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | return offset; | 305 | return offset; |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | boost::optional<std::pair<Key128, Key128>> ParseTicket(const TicketRaw& ticket, | 308 | std::optional<std::pair<Key128, Key128>> ParseTicket(const TicketRaw& ticket, |
| 309 | const RSAKeyPair<2048>& key) { | 309 | const RSAKeyPair<2048>& key) { |
| 310 | u32 cert_authority; | 310 | u32 cert_authority; |
| 311 | std::memcpy(&cert_authority, ticket.data() + 0x140, sizeof(cert_authority)); | 311 | std::memcpy(&cert_authority, ticket.data() + 0x140, sizeof(cert_authority)); |
| 312 | if (cert_authority == 0) | 312 | if (cert_authority == 0) |
| 313 | return boost::none; | 313 | return {}; |
| 314 | if (cert_authority != Common::MakeMagic('R', 'o', 'o', 't')) { | 314 | if (cert_authority != Common::MakeMagic('R', 'o', 'o', 't')) { |
| 315 | LOG_INFO(Crypto, | 315 | LOG_INFO(Crypto, |
| 316 | "Attempting to parse ticket with non-standard certificate authority {:08X}.", | 316 | "Attempting to parse ticket with non-standard certificate authority {:08X}.", |
| @@ -321,7 +321,7 @@ boost::optional<std::pair<Key128, Key128>> ParseTicket(const TicketRaw& ticket, | |||
| 321 | std::memcpy(rights_id.data(), ticket.data() + 0x2A0, sizeof(Key128)); | 321 | std::memcpy(rights_id.data(), ticket.data() + 0x2A0, sizeof(Key128)); |
| 322 | 322 | ||
| 323 | if (rights_id == Key128{}) | 323 | if (rights_id == Key128{}) |
| 324 | return boost::none; | 324 | return {}; |
| 325 | 325 | ||
| 326 | Key128 key_temp{}; | 326 | Key128 key_temp{}; |
| 327 | 327 | ||
| @@ -356,17 +356,17 @@ boost::optional<std::pair<Key128, Key128>> ParseTicket(const TicketRaw& ticket, | |||
| 356 | std::memcpy(m_2.data(), rsa_step.data() + 0x21, m_2.size()); | 356 | std::memcpy(m_2.data(), rsa_step.data() + 0x21, m_2.size()); |
| 357 | 357 | ||
| 358 | if (m_0 != 0) | 358 | if (m_0 != 0) |
| 359 | return boost::none; | 359 | return {}; |
| 360 | 360 | ||
| 361 | m_1 = m_1 ^ MGF1<0x20>(m_2); | 361 | m_1 = m_1 ^ MGF1<0x20>(m_2); |
| 362 | m_2 = m_2 ^ MGF1<0xDF>(m_1); | 362 | m_2 = m_2 ^ MGF1<0xDF>(m_1); |
| 363 | 363 | ||
| 364 | const auto offset = FindTicketOffset(m_2); | 364 | const auto offset = FindTicketOffset(m_2); |
| 365 | if (offset == boost::none) | 365 | if (!offset) |
| 366 | return boost::none; | 366 | return {}; |
| 367 | ASSERT(offset.get() > 0); | 367 | ASSERT(*offset > 0); |
| 368 | 368 | ||
| 369 | std::memcpy(key_temp.data(), m_2.data() + offset.get(), key_temp.size()); | 369 | std::memcpy(key_temp.data(), m_2.data() + *offset, key_temp.size()); |
| 370 | 370 | ||
| 371 | return std::make_pair(rights_id, key_temp); | 371 | return std::make_pair(rights_id, key_temp); |
| 372 | } | 372 | } |
| @@ -661,8 +661,8 @@ void KeyManager::DeriveSDSeedLazy() { | |||
| 661 | return; | 661 | return; |
| 662 | 662 | ||
| 663 | const auto res = DeriveSDSeed(); | 663 | const auto res = DeriveSDSeed(); |
| 664 | if (res != boost::none) | 664 | if (res) |
| 665 | SetKey(S128KeyType::SDSeed, res.get()); | 665 | SetKey(S128KeyType::SDSeed, *res); |
| 666 | } | 666 | } |
| 667 | 667 | ||
| 668 | static Key128 CalculateCMAC(const u8* source, size_t size, const Key128& key) { | 668 | static Key128 CalculateCMAC(const u8* source, size_t size, const Key128& key) { |
| @@ -889,9 +889,9 @@ void KeyManager::DeriveETicket(PartitionDataManager& data) { | |||
| 889 | 889 | ||
| 890 | for (const auto& raw : res) { | 890 | for (const auto& raw : res) { |
| 891 | const auto pair = ParseTicket(raw, rsa_key); | 891 | const auto pair = ParseTicket(raw, rsa_key); |
| 892 | if (pair == boost::none) | 892 | if (!pair) |
| 893 | continue; | 893 | continue; |
| 894 | const auto& [rid, key] = pair.value(); | 894 | const auto& [rid, key] = *pair; |
| 895 | u128 rights_id; | 895 | u128 rights_id; |
| 896 | std::memcpy(rights_id.data(), rid.data(), rid.size()); | 896 | std::memcpy(rights_id.data(), rid.data(), rid.size()); |
| 897 | SetKey(S128KeyType::Titlekey, key, rights_id[1], rights_id[0]); | 897 | SetKey(S128KeyType::Titlekey, key, rights_id[1], rights_id[0]); |
diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index cccb3c0ae..22f268c65 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h | |||
| @@ -6,9 +6,10 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <map> | 8 | #include <map> |
| 9 | #include <optional> | ||
| 9 | #include <string> | 10 | #include <string> |
| 11 | |||
| 10 | #include <boost/container/flat_map.hpp> | 12 | #include <boost/container/flat_map.hpp> |
| 11 | #include <boost/optional.hpp> | ||
| 12 | #include <fmt/format.h> | 13 | #include <fmt/format.h> |
| 13 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 14 | #include "core/crypto/partition_data_manager.h" | 15 | #include "core/crypto/partition_data_manager.h" |
| @@ -191,14 +192,14 @@ Key128 DeriveMasterKey(const std::array<u8, 0x90>& keyblob, const Key128& master | |||
| 191 | std::array<u8, 0x90> DecryptKeyblob(const std::array<u8, 0xB0>& encrypted_keyblob, | 192 | std::array<u8, 0x90> DecryptKeyblob(const std::array<u8, 0xB0>& encrypted_keyblob, |
| 192 | const Key128& key); | 193 | const Key128& key); |
| 193 | 194 | ||
| 194 | boost::optional<Key128> DeriveSDSeed(); | 195 | std::optional<Key128> DeriveSDSeed(); |
| 195 | Loader::ResultStatus DeriveSDKeys(std::array<Key256, 2>& sd_keys, KeyManager& keys); | 196 | Loader::ResultStatus DeriveSDKeys(std::array<Key256, 2>& sd_keys, KeyManager& keys); |
| 196 | 197 | ||
| 197 | std::vector<TicketRaw> GetTicketblob(const FileUtil::IOFile& ticket_save); | 198 | std::vector<TicketRaw> GetTicketblob(const FileUtil::IOFile& ticket_save); |
| 198 | 199 | ||
| 199 | // Returns a pair of {rights_id, titlekey}. Fails if the ticket has no certificate authority (offset | 200 | // Returns a pair of {rights_id, titlekey}. Fails if the ticket has no certificate authority (offset |
| 200 | // 0x140-0x144 is zero) | 201 | // 0x140-0x144 is zero) |
| 201 | boost::optional<std::pair<Key128, Key128>> ParseTicket( | 202 | std::optional<std::pair<Key128, Key128>> ParseTicket(const TicketRaw& ticket, |
| 202 | const TicketRaw& ticket, const RSAKeyPair<2048>& eticket_extended_key); | 203 | const RSAKeyPair<2048>& eticket_extended_key); |
| 203 | 204 | ||
| 204 | } // namespace Core::Crypto | 205 | } // namespace Core::Crypto |
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 77e04704e..b46fe893c 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp | |||
| @@ -4,10 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <cstring> | 6 | #include <cstring> |
| 7 | #include <optional> | ||
| 7 | #include <utility> | 8 | #include <utility> |
| 8 | 9 | ||
| 9 | #include <boost/optional.hpp> | ||
| 10 | |||
| 11 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 12 | #include "core/crypto/aes_util.h" | 11 | #include "core/crypto/aes_util.h" |
| 13 | #include "core/crypto/ctr_encryption_layer.h" | 12 | #include "core/crypto/ctr_encryption_layer.h" |
| @@ -306,18 +305,18 @@ bool NCA::ReadRomFSSection(const NCASectionHeader& section, const NCASectionTabl | |||
| 306 | subsection_buckets.back().entries.push_back({section.bktr.relocation.offset, {0}, ctr_low}); | 305 | subsection_buckets.back().entries.push_back({section.bktr.relocation.offset, {0}, ctr_low}); |
| 307 | subsection_buckets.back().entries.push_back({size, {0}, 0}); | 306 | subsection_buckets.back().entries.push_back({size, {0}, 0}); |
| 308 | 307 | ||
| 309 | boost::optional<Core::Crypto::Key128> key = boost::none; | 308 | std::optional<Core::Crypto::Key128> key = {}; |
| 310 | if (encrypted) { | 309 | if (encrypted) { |
| 311 | if (has_rights_id) { | 310 | if (has_rights_id) { |
| 312 | status = Loader::ResultStatus::Success; | 311 | status = Loader::ResultStatus::Success; |
| 313 | key = GetTitlekey(); | 312 | key = GetTitlekey(); |
| 314 | if (key == boost::none) { | 313 | if (!key) { |
| 315 | status = Loader::ResultStatus::ErrorMissingTitlekey; | 314 | status = Loader::ResultStatus::ErrorMissingTitlekey; |
| 316 | return false; | 315 | return false; |
| 317 | } | 316 | } |
| 318 | } else { | 317 | } else { |
| 319 | key = GetKeyAreaKey(NCASectionCryptoType::BKTR); | 318 | key = GetKeyAreaKey(NCASectionCryptoType::BKTR); |
| 320 | if (key == boost::none) { | 319 | if (!key) { |
| 321 | status = Loader::ResultStatus::ErrorMissingKeyAreaKey; | 320 | status = Loader::ResultStatus::ErrorMissingKeyAreaKey; |
| 322 | return false; | 321 | return false; |
| 323 | } | 322 | } |
| @@ -332,7 +331,7 @@ bool NCA::ReadRomFSSection(const NCASectionHeader& section, const NCASectionTabl | |||
| 332 | auto bktr = std::make_shared<BKTR>( | 331 | auto bktr = std::make_shared<BKTR>( |
| 333 | bktr_base_romfs, std::make_shared<OffsetVfsFile>(file, romfs_size, base_offset), | 332 | bktr_base_romfs, std::make_shared<OffsetVfsFile>(file, romfs_size, base_offset), |
| 334 | relocation_block, relocation_buckets, subsection_block, subsection_buckets, encrypted, | 333 | relocation_block, relocation_buckets, subsection_block, subsection_buckets, encrypted, |
| 335 | encrypted ? key.get() : Core::Crypto::Key128{}, base_offset, bktr_base_ivfc_offset, | 334 | encrypted ? *key : Core::Crypto::Key128{}, base_offset, bktr_base_ivfc_offset, |
| 336 | section.raw.section_ctr); | 335 | section.raw.section_ctr); |
| 337 | 336 | ||
| 338 | // BKTR applies to entire IVFC, so make an offset version to level 6 | 337 | // BKTR applies to entire IVFC, so make an offset version to level 6 |
| @@ -388,11 +387,11 @@ u8 NCA::GetCryptoRevision() const { | |||
| 388 | return master_key_id; | 387 | return master_key_id; |
| 389 | } | 388 | } |
| 390 | 389 | ||
| 391 | boost::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType type) const { | 390 | std::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType type) const { |
| 392 | const auto master_key_id = GetCryptoRevision(); | 391 | const auto master_key_id = GetCryptoRevision(); |
| 393 | 392 | ||
| 394 | if (!keys.HasKey(Core::Crypto::S128KeyType::KeyArea, master_key_id, header.key_index)) | 393 | if (!keys.HasKey(Core::Crypto::S128KeyType::KeyArea, master_key_id, header.key_index)) |
| 395 | return boost::none; | 394 | return {}; |
| 396 | 395 | ||
| 397 | std::vector<u8> key_area(header.key_area.begin(), header.key_area.end()); | 396 | std::vector<u8> key_area(header.key_area.begin(), header.key_area.end()); |
| 398 | Core::Crypto::AESCipher<Core::Crypto::Key128> cipher( | 397 | Core::Crypto::AESCipher<Core::Crypto::Key128> cipher( |
| @@ -416,25 +415,25 @@ boost::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType ty | |||
| 416 | return out; | 415 | return out; |
| 417 | } | 416 | } |
| 418 | 417 | ||
| 419 | boost::optional<Core::Crypto::Key128> NCA::GetTitlekey() { | 418 | std::optional<Core::Crypto::Key128> NCA::GetTitlekey() { |
| 420 | const auto master_key_id = GetCryptoRevision(); | 419 | const auto master_key_id = GetCryptoRevision(); |
| 421 | 420 | ||
| 422 | u128 rights_id{}; | 421 | u128 rights_id{}; |
| 423 | memcpy(rights_id.data(), header.rights_id.data(), 16); | 422 | memcpy(rights_id.data(), header.rights_id.data(), 16); |
| 424 | if (rights_id == u128{}) { | 423 | if (rights_id == u128{}) { |
| 425 | status = Loader::ResultStatus::ErrorInvalidRightsID; | 424 | status = Loader::ResultStatus::ErrorInvalidRightsID; |
| 426 | return boost::none; | 425 | return {}; |
| 427 | } | 426 | } |
| 428 | 427 | ||
| 429 | auto titlekey = keys.GetKey(Core::Crypto::S128KeyType::Titlekey, rights_id[1], rights_id[0]); | 428 | auto titlekey = keys.GetKey(Core::Crypto::S128KeyType::Titlekey, rights_id[1], rights_id[0]); |
| 430 | if (titlekey == Core::Crypto::Key128{}) { | 429 | if (titlekey == Core::Crypto::Key128{}) { |
| 431 | status = Loader::ResultStatus::ErrorMissingTitlekey; | 430 | status = Loader::ResultStatus::ErrorMissingTitlekey; |
| 432 | return boost::none; | 431 | return {}; |
| 433 | } | 432 | } |
| 434 | 433 | ||
| 435 | if (!keys.HasKey(Core::Crypto::S128KeyType::Titlekek, master_key_id)) { | 434 | if (!keys.HasKey(Core::Crypto::S128KeyType::Titlekek, master_key_id)) { |
| 436 | status = Loader::ResultStatus::ErrorMissingTitlekek; | 435 | status = Loader::ResultStatus::ErrorMissingTitlekek; |
| 437 | return boost::none; | 436 | return {}; |
| 438 | } | 437 | } |
| 439 | 438 | ||
| 440 | Core::Crypto::AESCipher<Core::Crypto::Key128> cipher( | 439 | Core::Crypto::AESCipher<Core::Crypto::Key128> cipher( |
| @@ -458,25 +457,25 @@ VirtualFile NCA::Decrypt(const NCASectionHeader& s_header, VirtualFile in, u64 s | |||
| 458 | case NCASectionCryptoType::BKTR: | 457 | case NCASectionCryptoType::BKTR: |
| 459 | LOG_DEBUG(Crypto, "called with mode=CTR, starting_offset={:016X}", starting_offset); | 458 | LOG_DEBUG(Crypto, "called with mode=CTR, starting_offset={:016X}", starting_offset); |
| 460 | { | 459 | { |
| 461 | boost::optional<Core::Crypto::Key128> key = boost::none; | 460 | std::optional<Core::Crypto::Key128> key = {}; |
| 462 | if (has_rights_id) { | 461 | if (has_rights_id) { |
| 463 | status = Loader::ResultStatus::Success; | 462 | status = Loader::ResultStatus::Success; |
| 464 | key = GetTitlekey(); | 463 | key = GetTitlekey(); |
| 465 | if (key == boost::none) { | 464 | if (!key) { |
| 466 | if (status == Loader::ResultStatus::Success) | 465 | if (status == Loader::ResultStatus::Success) |
| 467 | status = Loader::ResultStatus::ErrorMissingTitlekey; | 466 | status = Loader::ResultStatus::ErrorMissingTitlekey; |
| 468 | return nullptr; | 467 | return nullptr; |
| 469 | } | 468 | } |
| 470 | } else { | 469 | } else { |
| 471 | key = GetKeyAreaKey(NCASectionCryptoType::CTR); | 470 | key = GetKeyAreaKey(NCASectionCryptoType::CTR); |
| 472 | if (key == boost::none) { | 471 | if (!key) { |
| 473 | status = Loader::ResultStatus::ErrorMissingKeyAreaKey; | 472 | status = Loader::ResultStatus::ErrorMissingKeyAreaKey; |
| 474 | return nullptr; | 473 | return nullptr; |
| 475 | } | 474 | } |
| 476 | } | 475 | } |
| 477 | 476 | ||
| 478 | auto out = std::make_shared<Core::Crypto::CTREncryptionLayer>( | 477 | auto out = std::make_shared<Core::Crypto::CTREncryptionLayer>(std::move(in), *key, |
| 479 | std::move(in), key.value(), starting_offset); | 478 | starting_offset); |
| 480 | std::vector<u8> iv(16); | 479 | std::vector<u8> iv(16); |
| 481 | for (u8 i = 0; i < 8; ++i) | 480 | for (u8 i = 0; i < 8; ++i) |
| 482 | iv[i] = s_header.raw.section_ctr[0x8 - i - 1]; | 481 | iv[i] = s_header.raw.section_ctr[0x8 - i - 1]; |
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index 211946686..4bba55607 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h | |||
| @@ -6,9 +6,10 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <optional> | ||
| 9 | #include <string> | 10 | #include <string> |
| 10 | #include <vector> | 11 | #include <vector> |
| 11 | #include <boost/optional.hpp> | 12 | |
| 12 | #include "common/common_funcs.h" | 13 | #include "common/common_funcs.h" |
| 13 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 14 | #include "common/swap.h" | 15 | #include "common/swap.h" |
| @@ -111,8 +112,8 @@ private: | |||
| 111 | bool ReadPFS0Section(const NCASectionHeader& section, const NCASectionTableEntry& entry); | 112 | bool ReadPFS0Section(const NCASectionHeader& section, const NCASectionTableEntry& entry); |
| 112 | 113 | ||
| 113 | u8 GetCryptoRevision() const; | 114 | u8 GetCryptoRevision() const; |
| 114 | boost::optional<Core::Crypto::Key128> GetKeyAreaKey(NCASectionCryptoType type) const; | 115 | std::optional<Core::Crypto::Key128> GetKeyAreaKey(NCASectionCryptoType type) const; |
| 115 | boost::optional<Core::Crypto::Key128> GetTitlekey(); | 116 | std::optional<Core::Crypto::Key128> GetTitlekey(); |
| 116 | VirtualFile Decrypt(const NCASectionHeader& header, VirtualFile in, u64 starting_offset); | 117 | VirtualFile Decrypt(const NCASectionHeader& header, VirtualFile in, u64 starting_offset); |
| 117 | 118 | ||
| 118 | std::vector<VirtualDir> dirs; | 119 | std::vector<VirtualDir> dirs; |
diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp index 999939d5a..485c4913a 100644 --- a/src/core/file_sys/ips_layer.cpp +++ b/src/core/file_sys/ips_layer.cpp | |||
| @@ -103,12 +103,12 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) { | |||
| 103 | offset += sizeof(u16); | 103 | offset += sizeof(u16); |
| 104 | 104 | ||
| 105 | const auto data = ips->ReadByte(offset++); | 105 | const auto data = ips->ReadByte(offset++); |
| 106 | if (data == boost::none) | 106 | if (!data) |
| 107 | return nullptr; | 107 | return nullptr; |
| 108 | 108 | ||
| 109 | if (real_offset + rle_size > in_data.size()) | 109 | if (real_offset + rle_size > in_data.size()) |
| 110 | rle_size = static_cast<u16>(in_data.size() - real_offset); | 110 | rle_size = static_cast<u16>(in_data.size() - real_offset); |
| 111 | std::memset(in_data.data() + real_offset, data.get(), rle_size); | 111 | std::memset(in_data.data() + real_offset, *data, rle_size); |
| 112 | } else { // Standard Patch | 112 | } else { // Standard Patch |
| 113 | auto read = data_size; | 113 | auto read = data_size; |
| 114 | if (real_offset + read > in_data.size()) | 114 | if (real_offset + read > in_data.size()) |
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index cb457b987..0c1156989 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -65,7 +65,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 65 | if (update != nullptr && update->GetExeFS() != nullptr && | 65 | if (update != nullptr && update->GetExeFS() != nullptr && |
| 66 | update->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS) { | 66 | update->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS) { |
| 67 | LOG_INFO(Loader, " ExeFS: Update ({}) applied successfully", | 67 | LOG_INFO(Loader, " ExeFS: Update ({}) applied successfully", |
| 68 | FormatTitleVersion(installed->GetEntryVersion(update_tid).get_value_or(0))); | 68 | FormatTitleVersion(installed->GetEntryVersion(update_tid).value_or(0))); |
| 69 | exefs = update->GetExeFS(); | 69 | exefs = update->GetExeFS(); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| @@ -236,7 +236,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content | |||
| 236 | if (new_nca->GetStatus() == Loader::ResultStatus::Success && | 236 | if (new_nca->GetStatus() == Loader::ResultStatus::Success && |
| 237 | new_nca->GetRomFS() != nullptr) { | 237 | new_nca->GetRomFS() != nullptr) { |
| 238 | LOG_INFO(Loader, " RomFS: Update ({}) applied successfully", | 238 | LOG_INFO(Loader, " RomFS: Update ({}) applied successfully", |
| 239 | FormatTitleVersion(installed->GetEntryVersion(update_tid).get_value_or(0))); | 239 | FormatTitleVersion(installed->GetEntryVersion(update_tid).value_or(0))); |
| 240 | romfs = new_nca->GetRomFS(); | 240 | romfs = new_nca->GetRomFS(); |
| 241 | } | 241 | } |
| 242 | } else if (update_raw != nullptr) { | 242 | } else if (update_raw != nullptr) { |
| @@ -280,12 +280,11 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 280 | } else { | 280 | } else { |
| 281 | if (installed->HasEntry(update_tid, ContentRecordType::Program)) { | 281 | if (installed->HasEntry(update_tid, ContentRecordType::Program)) { |
| 282 | const auto meta_ver = installed->GetEntryVersion(update_tid); | 282 | const auto meta_ver = installed->GetEntryVersion(update_tid); |
| 283 | if (meta_ver == boost::none || meta_ver.get() == 0) { | 283 | if (meta_ver.value_or(0) == 0) { |
| 284 | out.insert_or_assign("Update", ""); | 284 | out.insert_or_assign("Update", ""); |
| 285 | } else { | 285 | } else { |
| 286 | out.insert_or_assign( | 286 | out.insert_or_assign( |
| 287 | "Update", | 287 | "Update", FormatTitleVersion(*meta_ver, TitleVersionFormat::ThreeElements)); |
| 288 | FormatTitleVersion(meta_ver.get(), TitleVersionFormat::ThreeElements)); | ||
| 289 | } | 288 | } |
| 290 | } else if (update_raw != nullptr) { | 289 | } else if (update_raw != nullptr) { |
| 291 | out.insert_or_assign("Update", "PACKED"); | 290 | out.insert_or_assign("Update", "PACKED"); |
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 29b100414..96302a241 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -159,28 +159,28 @@ VirtualFile RegisteredCache::GetFileAtID(NcaID id) const { | |||
| 159 | return file; | 159 | return file; |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | static boost::optional<NcaID> CheckMapForContentRecord( | 162 | static std::optional<NcaID> CheckMapForContentRecord( |
| 163 | const boost::container::flat_map<u64, CNMT>& map, u64 title_id, ContentRecordType type) { | 163 | const boost::container::flat_map<u64, CNMT>& map, u64 title_id, ContentRecordType type) { |
| 164 | if (map.find(title_id) == map.end()) | 164 | if (map.find(title_id) == map.end()) |
| 165 | return boost::none; | 165 | return {}; |
| 166 | 166 | ||
| 167 | const auto& cnmt = map.at(title_id); | 167 | const auto& cnmt = map.at(title_id); |
| 168 | 168 | ||
| 169 | const auto iter = std::find_if(cnmt.GetContentRecords().begin(), cnmt.GetContentRecords().end(), | 169 | const auto iter = std::find_if(cnmt.GetContentRecords().begin(), cnmt.GetContentRecords().end(), |
| 170 | [type](const ContentRecord& rec) { return rec.type == type; }); | 170 | [type](const ContentRecord& rec) { return rec.type == type; }); |
| 171 | if (iter == cnmt.GetContentRecords().end()) | 171 | if (iter == cnmt.GetContentRecords().end()) |
| 172 | return boost::none; | 172 | return {}; |
| 173 | 173 | ||
| 174 | return boost::make_optional(iter->nca_id); | 174 | return std::make_optional(iter->nca_id); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | boost::optional<NcaID> RegisteredCache::GetNcaIDFromMetadata(u64 title_id, | 177 | std::optional<NcaID> RegisteredCache::GetNcaIDFromMetadata(u64 title_id, |
| 178 | ContentRecordType type) const { | 178 | ContentRecordType type) const { |
| 179 | if (type == ContentRecordType::Meta && meta_id.find(title_id) != meta_id.end()) | 179 | if (type == ContentRecordType::Meta && meta_id.find(title_id) != meta_id.end()) |
| 180 | return meta_id.at(title_id); | 180 | return meta_id.at(title_id); |
| 181 | 181 | ||
| 182 | const auto res1 = CheckMapForContentRecord(yuzu_meta, title_id, type); | 182 | const auto res1 = CheckMapForContentRecord(yuzu_meta, title_id, type); |
| 183 | if (res1 != boost::none) | 183 | if (res1) |
| 184 | return res1; | 184 | return res1; |
| 185 | return CheckMapForContentRecord(meta, title_id, type); | 185 | return CheckMapForContentRecord(meta, title_id, type); |
| 186 | } | 186 | } |
| @@ -283,17 +283,14 @@ bool RegisteredCache::HasEntry(RegisteredCacheEntry entry) const { | |||
| 283 | 283 | ||
| 284 | VirtualFile RegisteredCache::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { | 284 | VirtualFile RegisteredCache::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { |
| 285 | const auto id = GetNcaIDFromMetadata(title_id, type); | 285 | const auto id = GetNcaIDFromMetadata(title_id, type); |
| 286 | if (id == boost::none) | 286 | return id ? GetFileAtID(*id) : nullptr; |
| 287 | return nullptr; | ||
| 288 | |||
| 289 | return GetFileAtID(id.get()); | ||
| 290 | } | 287 | } |
| 291 | 288 | ||
| 292 | VirtualFile RegisteredCache::GetEntryUnparsed(RegisteredCacheEntry entry) const { | 289 | VirtualFile RegisteredCache::GetEntryUnparsed(RegisteredCacheEntry entry) const { |
| 293 | return GetEntryUnparsed(entry.title_id, entry.type); | 290 | return GetEntryUnparsed(entry.title_id, entry.type); |
| 294 | } | 291 | } |
| 295 | 292 | ||
| 296 | boost::optional<u32> RegisteredCache::GetEntryVersion(u64 title_id) const { | 293 | std::optional<u32> RegisteredCache::GetEntryVersion(u64 title_id) const { |
| 297 | const auto meta_iter = meta.find(title_id); | 294 | const auto meta_iter = meta.find(title_id); |
| 298 | if (meta_iter != meta.end()) | 295 | if (meta_iter != meta.end()) |
| 299 | return meta_iter->second.GetTitleVersion(); | 296 | return meta_iter->second.GetTitleVersion(); |
| @@ -302,15 +299,12 @@ boost::optional<u32> RegisteredCache::GetEntryVersion(u64 title_id) const { | |||
| 302 | if (yuzu_meta_iter != yuzu_meta.end()) | 299 | if (yuzu_meta_iter != yuzu_meta.end()) |
| 303 | return yuzu_meta_iter->second.GetTitleVersion(); | 300 | return yuzu_meta_iter->second.GetTitleVersion(); |
| 304 | 301 | ||
| 305 | return boost::none; | 302 | return {}; |
| 306 | } | 303 | } |
| 307 | 304 | ||
| 308 | VirtualFile RegisteredCache::GetEntryRaw(u64 title_id, ContentRecordType type) const { | 305 | VirtualFile RegisteredCache::GetEntryRaw(u64 title_id, ContentRecordType type) const { |
| 309 | const auto id = GetNcaIDFromMetadata(title_id, type); | 306 | const auto id = GetNcaIDFromMetadata(title_id, type); |
| 310 | if (id == boost::none) | 307 | return id ? parser(GetFileAtID(*id), *id) : nullptr; |
| 311 | return nullptr; | ||
| 312 | |||
| 313 | return parser(GetFileAtID(id.get()), id.get()); | ||
| 314 | } | 308 | } |
| 315 | 309 | ||
| 316 | VirtualFile RegisteredCache::GetEntryRaw(RegisteredCacheEntry entry) const { | 310 | VirtualFile RegisteredCache::GetEntryRaw(RegisteredCacheEntry entry) const { |
| @@ -364,8 +358,8 @@ std::vector<RegisteredCacheEntry> RegisteredCache::ListEntries() const { | |||
| 364 | } | 358 | } |
| 365 | 359 | ||
| 366 | std::vector<RegisteredCacheEntry> RegisteredCache::ListEntriesFilter( | 360 | std::vector<RegisteredCacheEntry> RegisteredCache::ListEntriesFilter( |
| 367 | boost::optional<TitleType> title_type, boost::optional<ContentRecordType> record_type, | 361 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, |
| 368 | boost::optional<u64> title_id) const { | 362 | std::optional<u64> title_id) const { |
| 369 | std::vector<RegisteredCacheEntry> out; | 363 | std::vector<RegisteredCacheEntry> out; |
| 370 | IterateAllMetadata<RegisteredCacheEntry>( | 364 | IterateAllMetadata<RegisteredCacheEntry>( |
| 371 | out, | 365 | out, |
| @@ -373,11 +367,11 @@ std::vector<RegisteredCacheEntry> RegisteredCache::ListEntriesFilter( | |||
| 373 | return RegisteredCacheEntry{c.GetTitleID(), r.type}; | 367 | return RegisteredCacheEntry{c.GetTitleID(), r.type}; |
| 374 | }, | 368 | }, |
| 375 | [&title_type, &record_type, &title_id](const CNMT& c, const ContentRecord& r) { | 369 | [&title_type, &record_type, &title_id](const CNMT& c, const ContentRecord& r) { |
| 376 | if (title_type != boost::none && title_type.get() != c.GetType()) | 370 | if (title_type && *title_type != c.GetType()) |
| 377 | return false; | 371 | return false; |
| 378 | if (record_type != boost::none && record_type.get() != r.type) | 372 | if (record_type && *record_type != r.type) |
| 379 | return false; | 373 | return false; |
| 380 | if (title_id != boost::none && title_id.get() != c.GetTitleID()) | 374 | if (title_id && *title_id != c.GetTitleID()) |
| 381 | return false; | 375 | return false; |
| 382 | return true; | 376 | return true; |
| 383 | }); | 377 | }); |
| @@ -459,7 +453,7 @@ InstallResult RegisteredCache::InstallEntry(std::shared_ptr<NCA> nca, TitleType | |||
| 459 | 453 | ||
| 460 | InstallResult RegisteredCache::RawInstallNCA(std::shared_ptr<NCA> nca, const VfsCopyFunction& copy, | 454 | InstallResult RegisteredCache::RawInstallNCA(std::shared_ptr<NCA> nca, const VfsCopyFunction& copy, |
| 461 | bool overwrite_if_exists, | 455 | bool overwrite_if_exists, |
| 462 | boost::optional<NcaID> override_id) { | 456 | std::optional<NcaID> override_id) { |
| 463 | const auto in = nca->GetBaseFile(); | 457 | const auto in = nca->GetBaseFile(); |
| 464 | Core::Crypto::SHA256Hash hash{}; | 458 | Core::Crypto::SHA256Hash hash{}; |
| 465 | 459 | ||
| @@ -468,12 +462,12 @@ InstallResult RegisteredCache::RawInstallNCA(std::shared_ptr<NCA> nca, const Vfs | |||
| 468 | // game is massive), we're going to cheat and only hash the first MB of the NCA. | 462 | // game is massive), we're going to cheat and only hash the first MB of the NCA. |
| 469 | // Also, for XCIs the NcaID matters, so if the override id isn't none, use that. | 463 | // Also, for XCIs the NcaID matters, so if the override id isn't none, use that. |
| 470 | NcaID id{}; | 464 | NcaID id{}; |
| 471 | if (override_id == boost::none) { | 465 | if (override_id) { |
| 466 | id = *override_id; | ||
| 467 | } else { | ||
| 472 | const auto& data = in->ReadBytes(0x100000); | 468 | const auto& data = in->ReadBytes(0x100000); |
| 473 | mbedtls_sha256(data.data(), data.size(), hash.data(), 0); | 469 | mbedtls_sha256(data.data(), data.size(), hash.data(), 0); |
| 474 | memcpy(id.data(), hash.data(), 16); | 470 | memcpy(id.data(), hash.data(), 16); |
| 475 | } else { | ||
| 476 | id = override_id.get(); | ||
| 477 | } | 471 | } |
| 478 | 472 | ||
| 479 | std::string path = GetRelativePathFromNcaID(id, false, true); | 473 | std::string path = GetRelativePathFromNcaID(id, false, true); |
| @@ -543,14 +537,14 @@ bool RegisteredCacheUnion::HasEntry(RegisteredCacheEntry entry) const { | |||
| 543 | return HasEntry(entry.title_id, entry.type); | 537 | return HasEntry(entry.title_id, entry.type); |
| 544 | } | 538 | } |
| 545 | 539 | ||
| 546 | boost::optional<u32> RegisteredCacheUnion::GetEntryVersion(u64 title_id) const { | 540 | std::optional<u32> RegisteredCacheUnion::GetEntryVersion(u64 title_id) const { |
| 547 | for (const auto& c : caches) { | 541 | for (const auto& c : caches) { |
| 548 | const auto res = c->GetEntryVersion(title_id); | 542 | const auto res = c->GetEntryVersion(title_id); |
| 549 | if (res != boost::none) | 543 | if (res) |
| 550 | return res; | 544 | return res; |
| 551 | } | 545 | } |
| 552 | 546 | ||
| 553 | return boost::none; | 547 | return {}; |
| 554 | } | 548 | } |
| 555 | 549 | ||
| 556 | VirtualFile RegisteredCacheUnion::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { | 550 | VirtualFile RegisteredCacheUnion::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { |
| @@ -609,8 +603,8 @@ std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntries() const { | |||
| 609 | } | 603 | } |
| 610 | 604 | ||
| 611 | std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntriesFilter( | 605 | std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntriesFilter( |
| 612 | boost::optional<TitleType> title_type, boost::optional<ContentRecordType> record_type, | 606 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, |
| 613 | boost::optional<u64> title_id) const { | 607 | std::optional<u64> title_id) const { |
| 614 | std::vector<RegisteredCacheEntry> out; | 608 | std::vector<RegisteredCacheEntry> out; |
| 615 | for (const auto& c : caches) { | 609 | for (const auto& c : caches) { |
| 616 | c->IterateAllMetadata<RegisteredCacheEntry>( | 610 | c->IterateAllMetadata<RegisteredCacheEntry>( |
| @@ -619,11 +613,11 @@ std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntriesFilter( | |||
| 619 | return RegisteredCacheEntry{c.GetTitleID(), r.type}; | 613 | return RegisteredCacheEntry{c.GetTitleID(), r.type}; |
| 620 | }, | 614 | }, |
| 621 | [&title_type, &record_type, &title_id](const CNMT& c, const ContentRecord& r) { | 615 | [&title_type, &record_type, &title_id](const CNMT& c, const ContentRecord& r) { |
| 622 | if (title_type != boost::none && title_type.get() != c.GetType()) | 616 | if (title_type && *title_type != c.GetType()) |
| 623 | return false; | 617 | return false; |
| 624 | if (record_type != boost::none && record_type.get() != r.type) | 618 | if (record_type && *record_type != r.type) |
| 625 | return false; | 619 | return false; |
| 626 | if (title_id != boost::none && title_id.get() != c.GetTitleID()) | 620 | if (title_id && *title_id != c.GetTitleID()) |
| 627 | return false; | 621 | return false; |
| 628 | return true; | 622 | return true; |
| 629 | }); | 623 | }); |
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 5beceffb3..6cfb16017 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h | |||
| @@ -84,7 +84,7 @@ public: | |||
| 84 | bool HasEntry(u64 title_id, ContentRecordType type) const; | 84 | bool HasEntry(u64 title_id, ContentRecordType type) const; |
| 85 | bool HasEntry(RegisteredCacheEntry entry) const; | 85 | bool HasEntry(RegisteredCacheEntry entry) const; |
| 86 | 86 | ||
| 87 | boost::optional<u32> GetEntryVersion(u64 title_id) const; | 87 | std::optional<u32> GetEntryVersion(u64 title_id) const; |
| 88 | 88 | ||
| 89 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const; | 89 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const; |
| 90 | VirtualFile GetEntryUnparsed(RegisteredCacheEntry entry) const; | 90 | VirtualFile GetEntryUnparsed(RegisteredCacheEntry entry) const; |
| @@ -96,11 +96,10 @@ public: | |||
| 96 | std::unique_ptr<NCA> GetEntry(RegisteredCacheEntry entry) const; | 96 | std::unique_ptr<NCA> GetEntry(RegisteredCacheEntry entry) const; |
| 97 | 97 | ||
| 98 | std::vector<RegisteredCacheEntry> ListEntries() const; | 98 | std::vector<RegisteredCacheEntry> ListEntries() const; |
| 99 | // If a parameter is not boost::none, it will be filtered for from all entries. | 99 | // If a parameter is not std::nullopt, it will be filtered for from all entries. |
| 100 | std::vector<RegisteredCacheEntry> ListEntriesFilter( | 100 | std::vector<RegisteredCacheEntry> ListEntriesFilter( |
| 101 | boost::optional<TitleType> title_type = boost::none, | 101 | std::optional<TitleType> title_type = {}, std::optional<ContentRecordType> record_type = {}, |
| 102 | boost::optional<ContentRecordType> record_type = boost::none, | 102 | std::optional<u64> title_id = {}) const; |
| 103 | boost::optional<u64> title_id = boost::none) const; | ||
| 104 | 103 | ||
| 105 | // Raw copies all the ncas from the xci/nsp to the csache. Does some quick checks to make sure | 104 | // Raw copies all the ncas from the xci/nsp to the csache. Does some quick checks to make sure |
| 106 | // there is a meta NCA and all of them are accessible. | 105 | // there is a meta NCA and all of them are accessible. |
| @@ -125,12 +124,11 @@ private: | |||
| 125 | std::vector<NcaID> AccumulateFiles() const; | 124 | std::vector<NcaID> AccumulateFiles() const; |
| 126 | void ProcessFiles(const std::vector<NcaID>& ids); | 125 | void ProcessFiles(const std::vector<NcaID>& ids); |
| 127 | void AccumulateYuzuMeta(); | 126 | void AccumulateYuzuMeta(); |
| 128 | boost::optional<NcaID> GetNcaIDFromMetadata(u64 title_id, ContentRecordType type) const; | 127 | std::optional<NcaID> GetNcaIDFromMetadata(u64 title_id, ContentRecordType type) const; |
| 129 | VirtualFile GetFileAtID(NcaID id) const; | 128 | VirtualFile GetFileAtID(NcaID id) const; |
| 130 | VirtualFile OpenFileOrDirectoryConcat(const VirtualDir& dir, std::string_view path) const; | 129 | VirtualFile OpenFileOrDirectoryConcat(const VirtualDir& dir, std::string_view path) const; |
| 131 | InstallResult RawInstallNCA(std::shared_ptr<NCA> nca, const VfsCopyFunction& copy, | 130 | InstallResult RawInstallNCA(std::shared_ptr<NCA> nca, const VfsCopyFunction& copy, |
| 132 | bool overwrite_if_exists, | 131 | bool overwrite_if_exists, std::optional<NcaID> override_id = {}); |
| 133 | boost::optional<NcaID> override_id = boost::none); | ||
| 134 | bool RawInstallYuzuMeta(const CNMT& cnmt); | 132 | bool RawInstallYuzuMeta(const CNMT& cnmt); |
| 135 | 133 | ||
| 136 | VirtualDir dir; | 134 | VirtualDir dir; |
| @@ -153,7 +151,7 @@ public: | |||
| 153 | bool HasEntry(u64 title_id, ContentRecordType type) const; | 151 | bool HasEntry(u64 title_id, ContentRecordType type) const; |
| 154 | bool HasEntry(RegisteredCacheEntry entry) const; | 152 | bool HasEntry(RegisteredCacheEntry entry) const; |
| 155 | 153 | ||
| 156 | boost::optional<u32> GetEntryVersion(u64 title_id) const; | 154 | std::optional<u32> GetEntryVersion(u64 title_id) const; |
| 157 | 155 | ||
| 158 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const; | 156 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const; |
| 159 | VirtualFile GetEntryUnparsed(RegisteredCacheEntry entry) const; | 157 | VirtualFile GetEntryUnparsed(RegisteredCacheEntry entry) const; |
| @@ -165,11 +163,10 @@ public: | |||
| 165 | std::unique_ptr<NCA> GetEntry(RegisteredCacheEntry entry) const; | 163 | std::unique_ptr<NCA> GetEntry(RegisteredCacheEntry entry) const; |
| 166 | 164 | ||
| 167 | std::vector<RegisteredCacheEntry> ListEntries() const; | 165 | std::vector<RegisteredCacheEntry> ListEntries() const; |
| 168 | // If a parameter is not boost::none, it will be filtered for from all entries. | 166 | // If a parameter is not std::nullopt, it will be filtered for from all entries. |
| 169 | std::vector<RegisteredCacheEntry> ListEntriesFilter( | 167 | std::vector<RegisteredCacheEntry> ListEntriesFilter( |
| 170 | boost::optional<TitleType> title_type = boost::none, | 168 | std::optional<TitleType> title_type = {}, std::optional<ContentRecordType> record_type = {}, |
| 171 | boost::optional<ContentRecordType> record_type = boost::none, | 169 | std::optional<u64> title_id = {}) const; |
| 172 | boost::optional<u64> title_id = boost::none) const; | ||
| 173 | 170 | ||
| 174 | private: | 171 | private: |
| 175 | std::vector<RegisteredCache*> caches; | 172 | std::vector<RegisteredCache*> caches; |
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 3824c74e0..7b584de7f 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp | |||
| @@ -167,13 +167,13 @@ std::string VfsFile::GetExtension() const { | |||
| 167 | 167 | ||
| 168 | VfsDirectory::~VfsDirectory() = default; | 168 | VfsDirectory::~VfsDirectory() = default; |
| 169 | 169 | ||
| 170 | boost::optional<u8> VfsFile::ReadByte(std::size_t offset) const { | 170 | std::optional<u8> VfsFile::ReadByte(std::size_t offset) const { |
| 171 | u8 out{}; | 171 | u8 out{}; |
| 172 | std::size_t size = Read(&out, 1, offset); | 172 | std::size_t size = Read(&out, 1, offset); |
| 173 | if (size == 1) | 173 | if (size == 1) |
| 174 | return out; | 174 | return out; |
| 175 | 175 | ||
| 176 | return boost::none; | 176 | return {}; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | std::vector<u8> VfsFile::ReadBytes(std::size_t size, std::size_t offset) const { | 179 | std::vector<u8> VfsFile::ReadBytes(std::size_t size, std::size_t offset) const { |
diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index 09dc9f288..002f99d4e 100644 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h | |||
| @@ -4,13 +4,15 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <functional> | ||
| 7 | #include <map> | 8 | #include <map> |
| 8 | #include <memory> | 9 | #include <memory> |
| 10 | #include <optional> | ||
| 9 | #include <string> | 11 | #include <string> |
| 10 | #include <string_view> | 12 | #include <string_view> |
| 11 | #include <type_traits> | 13 | #include <type_traits> |
| 12 | #include <vector> | 14 | #include <vector> |
| 13 | #include <boost/optional.hpp> | 15 | |
| 14 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 15 | #include "core/file_sys/vfs_types.h" | 17 | #include "core/file_sys/vfs_types.h" |
| 16 | 18 | ||
| @@ -103,8 +105,8 @@ public: | |||
| 103 | // into file. Returns number of bytes successfully written. | 105 | // into file. Returns number of bytes successfully written. |
| 104 | virtual std::size_t Write(const u8* data, std::size_t length, std::size_t offset = 0) = 0; | 106 | virtual std::size_t Write(const u8* data, std::size_t length, std::size_t offset = 0) = 0; |
| 105 | 107 | ||
| 106 | // Reads exactly one byte at the offset provided, returning boost::none on error. | 108 | // Reads exactly one byte at the offset provided, returning std::nullopt on error. |
| 107 | virtual boost::optional<u8> ReadByte(std::size_t offset = 0) const; | 109 | virtual std::optional<u8> ReadByte(std::size_t offset = 0) const; |
| 108 | // Reads size bytes starting at offset in file into a vector. | 110 | // Reads size bytes starting at offset in file into a vector. |
| 109 | virtual std::vector<u8> ReadBytes(std::size_t size, std::size_t offset = 0) const; | 111 | virtual std::vector<u8> ReadBytes(std::size_t size, std::size_t offset = 0) const; |
| 110 | // Reads all the bytes from the file into a vector. Equivalent to 'file->Read(file->GetSize(), | 112 | // Reads all the bytes from the file into a vector. Equivalent to 'file->Read(file->GetSize(), |
diff --git a/src/core/file_sys/vfs_offset.cpp b/src/core/file_sys/vfs_offset.cpp index a4c6719a0..c96f88488 100644 --- a/src/core/file_sys/vfs_offset.cpp +++ b/src/core/file_sys/vfs_offset.cpp | |||
| @@ -57,11 +57,11 @@ std::size_t OffsetVfsFile::Write(const u8* data, std::size_t length, std::size_t | |||
| 57 | return file->Write(data, TrimToFit(length, r_offset), offset + r_offset); | 57 | return file->Write(data, TrimToFit(length, r_offset), offset + r_offset); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | boost::optional<u8> OffsetVfsFile::ReadByte(std::size_t r_offset) const { | 60 | std::optional<u8> OffsetVfsFile::ReadByte(std::size_t r_offset) const { |
| 61 | if (r_offset < size) | 61 | if (r_offset < size) |
| 62 | return file->ReadByte(offset + r_offset); | 62 | return file->ReadByte(offset + r_offset); |
| 63 | 63 | ||
| 64 | return boost::none; | 64 | return {}; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | std::vector<u8> OffsetVfsFile::ReadBytes(std::size_t r_size, std::size_t r_offset) const { | 67 | std::vector<u8> OffsetVfsFile::ReadBytes(std::size_t r_size, std::size_t r_offset) const { |
diff --git a/src/core/file_sys/vfs_offset.h b/src/core/file_sys/vfs_offset.h index 8062702a7..f7b7a3256 100644 --- a/src/core/file_sys/vfs_offset.h +++ b/src/core/file_sys/vfs_offset.h | |||
| @@ -29,7 +29,7 @@ public: | |||
| 29 | bool IsReadable() const override; | 29 | bool IsReadable() const override; |
| 30 | std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override; | 30 | std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override; |
| 31 | std::size_t Write(const u8* data, std::size_t length, std::size_t offset) override; | 31 | std::size_t Write(const u8* data, std::size_t length, std::size_t offset) override; |
| 32 | boost::optional<u8> ReadByte(std::size_t offset) const override; | 32 | std::optional<u8> ReadByte(std::size_t offset) const override; |
| 33 | std::vector<u8> ReadBytes(std::size_t size, std::size_t offset) const override; | 33 | std::vector<u8> ReadBytes(std::size_t size, std::size_t offset) const override; |
| 34 | std::vector<u8> ReadAllBytes() const override; | 34 | std::vector<u8> ReadAllBytes() const override; |
| 35 | bool WriteByte(u8 data, std::size_t offset) override; | 35 | bool WriteByte(u8 data, std::size_t offset) override; |
diff --git a/src/core/file_sys/vfs_static.h b/src/core/file_sys/vfs_static.h index 44fab51d1..9f5a90b1b 100644 --- a/src/core/file_sys/vfs_static.h +++ b/src/core/file_sys/vfs_static.h | |||
| @@ -53,10 +53,10 @@ public: | |||
| 53 | return 0; | 53 | return 0; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | boost::optional<u8> ReadByte(std::size_t offset) const override { | 56 | std::optional<u8> ReadByte(std::size_t offset) const override { |
| 57 | if (offset < size) | 57 | if (offset < size) |
| 58 | return value; | 58 | return value; |
| 59 | return boost::none; | 59 | return {}; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | std::vector<u8> ReadBytes(std::size_t length, std::size_t offset) const override { | 62 | std::vector<u8> ReadBytes(std::size_t length, std::size_t offset) const override { |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 59bc9e0af..dd5cd9ced 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <cinttypes> | 6 | #include <cinttypes> |
| 7 | #include <optional> | ||
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | 9 | ||
| 9 | #include <boost/optional.hpp> | ||
| 10 | #include <boost/range/algorithm_ext/erase.hpp> | 10 | #include <boost/range/algorithm_ext/erase.hpp> |
| 11 | 11 | ||
| 12 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| @@ -94,7 +94,7 @@ void Thread::CancelWakeupTimer() { | |||
| 94 | CoreTiming::UnscheduleEventThreadsafe(kernel.ThreadWakeupCallbackEventType(), callback_handle); | 94 | CoreTiming::UnscheduleEventThreadsafe(kernel.ThreadWakeupCallbackEventType(), callback_handle); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | static boost::optional<s32> GetNextProcessorId(u64 mask) { | 97 | static std::optional<s32> GetNextProcessorId(u64 mask) { |
| 98 | for (s32 index = 0; index < Core::NUM_CPU_CORES; ++index) { | 98 | for (s32 index = 0; index < Core::NUM_CPU_CORES; ++index) { |
| 99 | if (mask & (1ULL << index)) { | 99 | if (mask & (1ULL << index)) { |
| 100 | if (!Core::System::GetInstance().Scheduler(index).GetCurrentThread()) { | 100 | if (!Core::System::GetInstance().Scheduler(index).GetCurrentThread()) { |
| @@ -142,7 +142,7 @@ void Thread::ResumeFromWait() { | |||
| 142 | 142 | ||
| 143 | status = ThreadStatus::Ready; | 143 | status = ThreadStatus::Ready; |
| 144 | 144 | ||
| 145 | boost::optional<s32> new_processor_id = GetNextProcessorId(affinity_mask); | 145 | std::optional<s32> new_processor_id = GetNextProcessorId(affinity_mask); |
| 146 | if (!new_processor_id) { | 146 | if (!new_processor_id) { |
| 147 | new_processor_id = processor_id; | 147 | new_processor_id = processor_id; |
| 148 | } | 148 | } |
| @@ -369,7 +369,7 @@ void Thread::ChangeCore(u32 core, u64 mask) { | |||
| 369 | return; | 369 | return; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | boost::optional<s32> new_processor_id{GetNextProcessorId(affinity_mask)}; | 372 | std::optional<s32> new_processor_id{GetNextProcessorId(affinity_mask)}; |
| 373 | 373 | ||
| 374 | if (!new_processor_id) { | 374 | if (!new_processor_id) { |
| 375 | new_processor_id = processor_id; | 375 | new_processor_id = processor_id; |
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 3cac1b4ff..c08394e4c 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -195,7 +195,7 @@ std::size_t ProfileManager::GetOpenUserCount() const { | |||
| 195 | 195 | ||
| 196 | /// Checks if a user id exists in our profile manager | 196 | /// Checks if a user id exists in our profile manager |
| 197 | bool ProfileManager::UserExists(UUID uuid) const { | 197 | bool ProfileManager::UserExists(UUID uuid) const { |
| 198 | return GetUserIndex(uuid) != std::nullopt; | 198 | return GetUserIndex(uuid).has_value(); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | bool ProfileManager::UserExistsIndex(std::size_t index) const { | 201 | bool ProfileManager::UserExistsIndex(std::size_t index) const { |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 59aafd616..ac3ff9f20 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -743,7 +743,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { | |||
| 743 | 743 | ||
| 744 | Account::ProfileManager profile_manager{}; | 744 | Account::ProfileManager profile_manager{}; |
| 745 | const auto uuid = profile_manager.GetUser(Settings::values.current_user); | 745 | const auto uuid = profile_manager.GetUser(Settings::values.current_user); |
| 746 | ASSERT(uuid != std::nullopt); | 746 | ASSERT(uuid); |
| 747 | params.current_user = uuid->uuid; | 747 | params.current_user = uuid->uuid; |
| 748 | 748 | ||
| 749 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 749 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index fd98d541d..630ebbfc7 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp | |||
| @@ -31,7 +31,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer) | |||
| 31 | buffer_wait_event->Signal(); | 31 | buffer_wait_event->Signal(); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | boost::optional<u32> BufferQueue::DequeueBuffer(u32 width, u32 height) { | 34 | std::optional<u32> BufferQueue::DequeueBuffer(u32 width, u32 height) { |
| 35 | auto itr = std::find_if(queue.begin(), queue.end(), [&](const Buffer& buffer) { | 35 | auto itr = std::find_if(queue.begin(), queue.end(), [&](const Buffer& buffer) { |
| 36 | // Only consider free buffers. Buffers become free once again after they've been Acquired | 36 | // Only consider free buffers. Buffers become free once again after they've been Acquired |
| 37 | // and Released by the compositor, see the NVFlinger::Compose method. | 37 | // and Released by the compositor, see the NVFlinger::Compose method. |
| @@ -44,7 +44,7 @@ boost::optional<u32> BufferQueue::DequeueBuffer(u32 width, u32 height) { | |||
| 44 | }); | 44 | }); |
| 45 | 45 | ||
| 46 | if (itr == queue.end()) { | 46 | if (itr == queue.end()) { |
| 47 | return boost::none; | 47 | return {}; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | itr->status = Buffer::Status::Dequeued; | 50 | itr->status = Buffer::Status::Dequeued; |
| @@ -70,12 +70,12 @@ void BufferQueue::QueueBuffer(u32 slot, BufferTransformFlags transform, | |||
| 70 | itr->crop_rect = crop_rect; | 70 | itr->crop_rect = crop_rect; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | boost::optional<const BufferQueue::Buffer&> BufferQueue::AcquireBuffer() { | 73 | std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() { |
| 74 | auto itr = std::find_if(queue.begin(), queue.end(), [](const Buffer& buffer) { | 74 | auto itr = std::find_if(queue.begin(), queue.end(), [](const Buffer& buffer) { |
| 75 | return buffer.status == Buffer::Status::Queued; | 75 | return buffer.status == Buffer::Status::Queued; |
| 76 | }); | 76 | }); |
| 77 | if (itr == queue.end()) | 77 | if (itr == queue.end()) |
| 78 | return boost::none; | 78 | return {}; |
| 79 | itr->status = Buffer::Status::Acquired; | 79 | itr->status = Buffer::Status::Acquired; |
| 80 | return *itr; | 80 | return *itr; |
| 81 | } | 81 | } |
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 50b767732..2fe81a560 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h | |||
| @@ -4,8 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <optional> | ||
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | #include <boost/optional.hpp> | 9 | |
| 9 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 10 | #include "common/math_util.h" | 11 | #include "common/math_util.h" |
| 11 | #include "common/swap.h" | 12 | #include "common/swap.h" |
| @@ -73,11 +74,11 @@ public: | |||
| 73 | }; | 74 | }; |
| 74 | 75 | ||
| 75 | void SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer); | 76 | void SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer); |
| 76 | boost::optional<u32> DequeueBuffer(u32 width, u32 height); | 77 | std::optional<u32> DequeueBuffer(u32 width, u32 height); |
| 77 | const IGBPBuffer& RequestBuffer(u32 slot) const; | 78 | const IGBPBuffer& RequestBuffer(u32 slot) const; |
| 78 | void QueueBuffer(u32 slot, BufferTransformFlags transform, | 79 | void QueueBuffer(u32 slot, BufferTransformFlags transform, |
| 79 | const MathUtil::Rectangle<int>& crop_rect); | 80 | const MathUtil::Rectangle<int>& crop_rect); |
| 80 | boost::optional<const Buffer&> AcquireBuffer(); | 81 | std::optional<std::reference_wrapper<const Buffer>> AcquireBuffer(); |
| 81 | void ReleaseBuffer(u32 slot); | 82 | void ReleaseBuffer(u32 slot); |
| 82 | u32 Query(QueryType type); | 83 | u32 Query(QueryType type); |
| 83 | 84 | ||
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index d47b6f659..214e6d1b3 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <boost/optional.hpp> | 6 | #include <optional> |
| 7 | 7 | ||
| 8 | #include "common/alignment.h" | 8 | #include "common/alignment.h" |
| 9 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| @@ -134,7 +134,7 @@ void NVFlinger::Compose() { | |||
| 134 | 134 | ||
| 135 | MicroProfileFlip(); | 135 | MicroProfileFlip(); |
| 136 | 136 | ||
| 137 | if (buffer == boost::none) { | 137 | if (!buffer) { |
| 138 | auto& system_instance = Core::System::GetInstance(); | 138 | auto& system_instance = Core::System::GetInstance(); |
| 139 | 139 | ||
| 140 | // There was no queued buffer to draw, render previous frame | 140 | // There was no queued buffer to draw, render previous frame |
| @@ -143,7 +143,7 @@ void NVFlinger::Compose() { | |||
| 143 | continue; | 143 | continue; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | auto& igbp_buffer = buffer->igbp_buffer; | 146 | auto& igbp_buffer = buffer->get().igbp_buffer; |
| 147 | 147 | ||
| 148 | // Now send the buffer to the GPU for drawing. | 148 | // Now send the buffer to the GPU for drawing. |
| 149 | // TODO(Subv): Support more than just disp0. The display device selection is probably based | 149 | // TODO(Subv): Support more than just disp0. The display device selection is probably based |
| @@ -152,10 +152,10 @@ void NVFlinger::Compose() { | |||
| 152 | ASSERT(nvdisp); | 152 | ASSERT(nvdisp); |
| 153 | 153 | ||
| 154 | nvdisp->flip(igbp_buffer.gpu_buffer_id, igbp_buffer.offset, igbp_buffer.format, | 154 | nvdisp->flip(igbp_buffer.gpu_buffer_id, igbp_buffer.offset, igbp_buffer.format, |
| 155 | igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, buffer->transform, | 155 | igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, |
| 156 | buffer->crop_rect); | 156 | buffer->get().transform, buffer->get().crop_rect); |
| 157 | 157 | ||
| 158 | buffer_queue->ReleaseBuffer(buffer->slot); | 158 | buffer_queue->ReleaseBuffer(buffer->get().slot); |
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | 161 | ||
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 184537daa..d764b2406 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -6,9 +6,10 @@ | |||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <cstring> | 7 | #include <cstring> |
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <optional> | ||
| 9 | #include <type_traits> | 10 | #include <type_traits> |
| 10 | #include <utility> | 11 | #include <utility> |
| 11 | #include <boost/optional.hpp> | 12 | |
| 12 | #include "common/alignment.h" | 13 | #include "common/alignment.h" |
| 13 | #include "common/assert.h" | 14 | #include "common/assert.h" |
| 14 | #include "common/common_funcs.h" | 15 | #include "common/common_funcs.h" |
| @@ -506,9 +507,9 @@ private: | |||
| 506 | IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()}; | 507 | IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()}; |
| 507 | const u32 width{request.data.width}; | 508 | const u32 width{request.data.width}; |
| 508 | const u32 height{request.data.height}; | 509 | const u32 height{request.data.height}; |
| 509 | boost::optional<u32> slot = buffer_queue->DequeueBuffer(width, height); | 510 | std::optional<u32> slot = buffer_queue->DequeueBuffer(width, height); |
| 510 | 511 | ||
| 511 | if (slot != boost::none) { | 512 | if (slot) { |
| 512 | // Buffer is available | 513 | // Buffer is available |
| 513 | IGBPDequeueBufferResponseParcel response{*slot}; | 514 | IGBPDequeueBufferResponseParcel response{*slot}; |
| 514 | ctx.WriteBuffer(response.Serialize()); | 515 | ctx.WriteBuffer(response.Serialize()); |
| @@ -520,7 +521,7 @@ private: | |||
| 520 | Kernel::ThreadWakeupReason reason) { | 521 | Kernel::ThreadWakeupReason reason) { |
| 521 | // Repeat TransactParcel DequeueBuffer when a buffer is available | 522 | // Repeat TransactParcel DequeueBuffer when a buffer is available |
| 522 | auto buffer_queue = nv_flinger->GetBufferQueue(id); | 523 | auto buffer_queue = nv_flinger->GetBufferQueue(id); |
| 523 | boost::optional<u32> slot = buffer_queue->DequeueBuffer(width, height); | 524 | std::optional<u32> slot = buffer_queue->DequeueBuffer(width, height); |
| 524 | IGBPDequeueBufferResponseParcel response{*slot}; | 525 | IGBPDequeueBufferResponseParcel response{*slot}; |
| 525 | ctx.WriteBuffer(response.Serialize()); | 526 | ctx.WriteBuffer(response.Serialize()); |
| 526 | IPC::ResponseBuilder rb{ctx, 2}; | 527 | IPC::ResponseBuilder rb{ctx, 2}; |
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index e562b3a04..7686634bf 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h | |||
| @@ -6,10 +6,11 @@ | |||
| 6 | 6 | ||
| 7 | #include <iosfwd> | 7 | #include <iosfwd> |
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <optional> | ||
| 9 | #include <string> | 10 | #include <string> |
| 10 | #include <utility> | 11 | #include <utility> |
| 11 | #include <vector> | 12 | #include <vector> |
| 12 | #include <boost/optional.hpp> | 13 | |
| 13 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 14 | #include "core/file_sys/vfs.h" | 15 | #include "core/file_sys/vfs.h" |
| 15 | 16 | ||
| @@ -145,7 +146,7 @@ public: | |||
| 145 | * information. | 146 | * information. |
| 146 | * @returns A pair with the optional system mode, and and the status. | 147 | * @returns A pair with the optional system mode, and and the status. |
| 147 | */ | 148 | */ |
| 148 | virtual std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() { | 149 | virtual std::pair<std::optional<u32>, ResultStatus> LoadKernelSystemMode() { |
| 149 | // 96MB allocated to the application. | 150 | // 96MB allocated to the application. |
| 150 | return std::make_pair(2, ResultStatus::Success); | 151 | return std::make_pair(2, ResultStatus::Success); |
| 151 | } | 152 | } |
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 014298ed6..70abd856a 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <cstring> | 6 | #include <cstring> |
| 7 | #include <optional> | ||
| 7 | #include <utility> | 8 | #include <utility> |
| 8 | 9 | ||
| 9 | #include <boost/optional.hpp> | ||
| 10 | #include "common/assert.h" | 10 | #include "common/assert.h" |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
diff --git a/src/core/memory_hook.h b/src/core/memory_hook.h index 0269c7ff1..940777107 100644 --- a/src/core/memory_hook.h +++ b/src/core/memory_hook.h | |||
| @@ -5,7 +5,8 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <boost/optional.hpp> | 8 | #include <optional> |
| 9 | |||
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 10 | 11 | ||
| 11 | namespace Memory { | 12 | namespace Memory { |
| @@ -18,19 +19,19 @@ namespace Memory { | |||
| 18 | * | 19 | * |
| 19 | * A hook may be mapped to multiple regions of memory. | 20 | * A hook may be mapped to multiple regions of memory. |
| 20 | * | 21 | * |
| 21 | * If a boost::none or false is returned from a function, the read/write request is passed through | 22 | * If a std::nullopt or false is returned from a function, the read/write request is passed through |
| 22 | * to the underlying memory region. | 23 | * to the underlying memory region. |
| 23 | */ | 24 | */ |
| 24 | class MemoryHook { | 25 | class MemoryHook { |
| 25 | public: | 26 | public: |
| 26 | virtual ~MemoryHook(); | 27 | virtual ~MemoryHook(); |
| 27 | 28 | ||
| 28 | virtual boost::optional<bool> IsValidAddress(VAddr addr) = 0; | 29 | virtual std::optional<bool> IsValidAddress(VAddr addr) = 0; |
| 29 | 30 | ||
| 30 | virtual boost::optional<u8> Read8(VAddr addr) = 0; | 31 | virtual std::optional<u8> Read8(VAddr addr) = 0; |
| 31 | virtual boost::optional<u16> Read16(VAddr addr) = 0; | 32 | virtual std::optional<u16> Read16(VAddr addr) = 0; |
| 32 | virtual boost::optional<u32> Read32(VAddr addr) = 0; | 33 | virtual std::optional<u32> Read32(VAddr addr) = 0; |
| 33 | virtual boost::optional<u64> Read64(VAddr addr) = 0; | 34 | virtual std::optional<u64> Read64(VAddr addr) = 0; |
| 34 | 35 | ||
| 35 | virtual bool ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size) = 0; | 36 | virtual bool ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size) = 0; |
| 36 | 37 | ||