diff options
Diffstat (limited to 'src')
39 files changed, 488 insertions, 307 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b3807c204..f4be926e4 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -181,10 +181,10 @@ add_library(core STATIC | |||
| 181 | hle/service/nvflinger/buffer_queue.h | 181 | hle/service/nvflinger/buffer_queue.h |
| 182 | hle/service/nvflinger/nvflinger.cpp | 182 | hle/service/nvflinger/nvflinger.cpp |
| 183 | hle/service/nvflinger/nvflinger.h | 183 | hle/service/nvflinger/nvflinger.h |
| 184 | hle/service/pctl/module.cpp | ||
| 185 | hle/service/pctl/module.h | ||
| 184 | hle/service/pctl/pctl.cpp | 186 | hle/service/pctl/pctl.cpp |
| 185 | hle/service/pctl/pctl.h | 187 | hle/service/pctl/pctl.h |
| 186 | hle/service/pctl/pctl_a.cpp | ||
| 187 | hle/service/pctl/pctl_a.h | ||
| 188 | hle/service/service.cpp | 188 | hle/service/service.cpp |
| 189 | hle/service/service.h | 189 | hle/service/service.h |
| 190 | hle/service/set/set.cpp | 190 | hle/service/set/set.cpp |
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp index 4d00249fa..8aa0e0aa4 100644 --- a/src/core/file_sys/disk_filesystem.cpp +++ b/src/core/file_sys/disk_filesystem.cpp | |||
| @@ -80,19 +80,19 @@ ResultCode Disk_FileSystem::RenameFile(const std::string& src_path, | |||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const { | 82 | ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const { |
| 83 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 83 | NGLOG_WARNING(Service_FS, "(STUBBED) called"); |
| 84 | // TODO(wwylele): Use correct error code | 84 | // TODO(wwylele): Use correct error code |
| 85 | return ResultCode(-1); | 85 | return ResultCode(-1); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | ResultCode Disk_FileSystem::DeleteDirectoryRecursively(const Path& path) const { | 88 | ResultCode Disk_FileSystem::DeleteDirectoryRecursively(const Path& path) const { |
| 89 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 89 | NGLOG_WARNING(Service_FS, "(STUBBED) called"); |
| 90 | // TODO(wwylele): Use correct error code | 90 | // TODO(wwylele): Use correct error code |
| 91 | return ResultCode(-1); | 91 | return ResultCode(-1); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const { | 94 | ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const { |
| 95 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 95 | NGLOG_WARNING(Service_FS, "(STUBBED) called"); |
| 96 | 96 | ||
| 97 | std::string full_path = base_directory + path; | 97 | std::string full_path = base_directory + path; |
| 98 | if (size == 0) { | 98 | if (size == 0) { |
| @@ -107,7 +107,7 @@ ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const | |||
| 107 | return RESULT_SUCCESS; | 107 | return RESULT_SUCCESS; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | LOG_ERROR(Service_FS, "Too large file"); | 110 | NGLOG_ERROR(Service_FS, "Too large file"); |
| 111 | // TODO(Subv): Find out the correct error code | 111 | // TODO(Subv): Find out the correct error code |
| 112 | return ResultCode(-1); | 112 | return ResultCode(-1); |
| 113 | } | 113 | } |
| @@ -120,13 +120,13 @@ ResultCode Disk_FileSystem::CreateDirectory(const std::string& path) const { | |||
| 120 | return RESULT_SUCCESS; | 120 | return RESULT_SUCCESS; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating %s", full_path.c_str()); | 123 | NGLOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", full_path); |
| 124 | // TODO(wwylele): Use correct error code | 124 | // TODO(wwylele): Use correct error code |
| 125 | return ResultCode(-1); | 125 | return ResultCode(-1); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | ResultCode Disk_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const { | 128 | ResultCode Disk_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const { |
| 129 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 129 | NGLOG_WARNING(Service_FS, "(STUBBED) called"); |
| 130 | // TODO(wwylele): Use correct error code | 130 | // TODO(wwylele): Use correct error code |
| 131 | return ResultCode(-1); | 131 | return ResultCode(-1); |
| 132 | } | 132 | } |
| @@ -146,7 +146,7 @@ ResultVal<std::unique_ptr<DirectoryBackend>> Disk_FileSystem::OpenDirectory( | |||
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | u64 Disk_FileSystem::GetFreeSpaceSize() const { | 148 | u64 Disk_FileSystem::GetFreeSpaceSize() const { |
| 149 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 149 | NGLOG_WARNING(Service_FS, "(STUBBED) called"); |
| 150 | return 0; | 150 | return 0; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| @@ -163,14 +163,14 @@ ResultVal<FileSys::EntryType> Disk_FileSystem::GetEntryType(const std::string& p | |||
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | ResultVal<size_t> Disk_Storage::Read(const u64 offset, const size_t length, u8* buffer) const { | 165 | ResultVal<size_t> Disk_Storage::Read(const u64 offset, const size_t length, u8* buffer) const { |
| 166 | LOG_TRACE(Service_FS, "called offset=%llu, length=%zu", offset, length); | 166 | NGLOG_TRACE(Service_FS, "called offset={}, length={}", offset, length); |
| 167 | file->Seek(offset, SEEK_SET); | 167 | file->Seek(offset, SEEK_SET); |
| 168 | return MakeResult<size_t>(file->ReadBytes(buffer, length)); | 168 | return MakeResult<size_t>(file->ReadBytes(buffer, length)); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | ResultVal<size_t> Disk_Storage::Write(const u64 offset, const size_t length, const bool flush, | 171 | ResultVal<size_t> Disk_Storage::Write(const u64 offset, const size_t length, const bool flush, |
| 172 | const u8* buffer) const { | 172 | const u8* buffer) const { |
| 173 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 173 | NGLOG_WARNING(Service_FS, "(STUBBED) called"); |
| 174 | file->Seek(offset, SEEK_SET); | 174 | file->Seek(offset, SEEK_SET); |
| 175 | size_t written = file->WriteBytes(buffer, length); | 175 | size_t written = file->WriteBytes(buffer, length); |
| 176 | if (flush) { | 176 | if (flush) { |
| @@ -204,8 +204,7 @@ u64 Disk_Directory::Read(const u64 count, Entry* entries) { | |||
| 204 | const std::string& filename = file.virtualName; | 204 | const std::string& filename = file.virtualName; |
| 205 | Entry& entry = entries[entries_read]; | 205 | Entry& entry = entries[entries_read]; |
| 206 | 206 | ||
| 207 | LOG_TRACE(Service_FS, "File %s: size=%llu dir=%d", filename.c_str(), file.size, | 207 | NGLOG_TRACE(Service_FS, "File {}: size={} dir={}", filename, file.size, file.isDirectory); |
| 208 | file.isDirectory); | ||
| 209 | 208 | ||
| 210 | // TODO(Link Mauve): use a proper conversion to UTF-16. | 209 | // TODO(Link Mauve): use a proper conversion to UTF-16. |
| 211 | for (size_t j = 0; j < FILENAME_LENGTH; ++j) { | 210 | for (size_t j = 0; j < FILENAME_LENGTH; ++j) { |
diff --git a/src/core/file_sys/filesystem.cpp b/src/core/file_sys/filesystem.cpp index 82fdb3c46..87083878b 100644 --- a/src/core/file_sys/filesystem.cpp +++ b/src/core/file_sys/filesystem.cpp | |||
| @@ -71,7 +71,7 @@ std::string Path::AsString() const { | |||
| 71 | case Binary: | 71 | case Binary: |
| 72 | default: | 72 | default: |
| 73 | // TODO(yuriks): Add assert | 73 | // TODO(yuriks): Add assert |
| 74 | LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!"); | 74 | NGLOG_ERROR(Service_FS, "LowPathType cannot be converted to string!"); |
| 75 | return {}; | 75 | return {}; |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| @@ -87,7 +87,7 @@ std::u16string Path::AsU16Str() const { | |||
| 87 | case Invalid: | 87 | case Invalid: |
| 88 | case Binary: | 88 | case Binary: |
| 89 | // TODO(yuriks): Add assert | 89 | // TODO(yuriks): Add assert |
| 90 | LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!"); | 90 | NGLOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!"); |
| 91 | return {}; | 91 | return {}; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| @@ -115,7 +115,7 @@ std::vector<u8> Path::AsBinary() const { | |||
| 115 | case Invalid: | 115 | case Invalid: |
| 116 | default: | 116 | default: |
| 117 | // TODO(yuriks): Add assert | 117 | // TODO(yuriks): Add assert |
| 118 | LOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!"); | 118 | NGLOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!"); |
| 119 | return {}; | 119 | return {}; |
| 120 | } | 120 | } |
| 121 | } | 121 | } |
diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp index 4a58a9291..808254ecc 100644 --- a/src/core/file_sys/partition_filesystem.cpp +++ b/src/core/file_sys/partition_filesystem.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cinttypes> | ||
| 6 | #include <utility> | 5 | #include <utility> |
| 7 | #include "common/file_util.h" | 6 | #include "common/file_util.h" |
| 8 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| @@ -40,7 +39,7 @@ Loader::ResultStatus PartitionFilesystem::Load(const std::string& file_path, siz | |||
| 40 | 39 | ||
| 41 | Loader::ResultStatus result = Load(file_data); | 40 | Loader::ResultStatus result = Load(file_data); |
| 42 | if (result != Loader::ResultStatus::Success) | 41 | if (result != Loader::ResultStatus::Success) |
| 43 | LOG_ERROR(Service_FS, "Failed to load PFS from file %s!", file_path.c_str()); | 42 | NGLOG_ERROR(Service_FS, "Failed to load PFS from file {}!", file_path); |
| 44 | 43 | ||
| 45 | return result; | 44 | return result; |
| 46 | } | 45 | } |
diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp index a6dcebcc3..1f5ded514 100644 --- a/src/core/file_sys/program_metadata.cpp +++ b/src/core/file_sys/program_metadata.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cinttypes> | ||
| 6 | #include "common/file_util.h" | 5 | #include "common/file_util.h" |
| 7 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 8 | #include "core/file_sys/program_metadata.h" | 7 | #include "core/file_sys/program_metadata.h" |
| @@ -22,7 +21,7 @@ Loader::ResultStatus ProgramMetadata::Load(const std::string& file_path) { | |||
| 22 | 21 | ||
| 23 | Loader::ResultStatus result = Load(file_data); | 22 | Loader::ResultStatus result = Load(file_data); |
| 24 | if (result != Loader::ResultStatus::Success) | 23 | if (result != Loader::ResultStatus::Success) |
| 25 | LOG_ERROR(Service_FS, "Failed to load NPDM from file %s!", file_path.c_str()); | 24 | NGLOG_ERROR(Service_FS, "Failed to load NPDM from file {}!", file_path); |
| 26 | 25 | ||
| 27 | return result; | 26 | return result; |
| 28 | } | 27 | } |
| @@ -77,14 +76,14 @@ u64 ProgramMetadata::GetFilesystemPermissions() const { | |||
| 77 | } | 76 | } |
| 78 | 77 | ||
| 79 | void ProgramMetadata::Print() const { | 78 | void ProgramMetadata::Print() const { |
| 80 | LOG_DEBUG(Service_FS, "Magic: %.4s", npdm_header.magic.data()); | 79 | NGLOG_DEBUG(Service_FS, "Magic: {:.4}", npdm_header.magic.data()); |
| 81 | LOG_DEBUG(Service_FS, "Main thread priority: 0x%02x", npdm_header.main_thread_priority); | 80 | NGLOG_DEBUG(Service_FS, "Main thread priority: {:#04X}", npdm_header.main_thread_priority); |
| 82 | LOG_DEBUG(Service_FS, "Main thread core: %u", npdm_header.main_thread_cpu); | 81 | NGLOG_DEBUG(Service_FS, "Main thread core: {}", npdm_header.main_thread_cpu); |
| 83 | LOG_DEBUG(Service_FS, "Main thread stack size: 0x%x bytes", npdm_header.main_stack_size); | 82 | NGLOG_DEBUG(Service_FS, "Main thread stack size: {:#X} bytes", npdm_header.main_stack_size); |
| 84 | LOG_DEBUG(Service_FS, "Process category: %u", npdm_header.process_category); | 83 | NGLOG_DEBUG(Service_FS, "Process category: {}", npdm_header.process_category); |
| 85 | LOG_DEBUG(Service_FS, "Flags: %02x", npdm_header.flags); | 84 | NGLOG_DEBUG(Service_FS, "Flags: {:02X}", npdm_header.flags); |
| 86 | LOG_DEBUG(Service_FS, " > 64-bit instructions: %s", | 85 | NGLOG_DEBUG(Service_FS, " > 64-bit instructions: {}", |
| 87 | npdm_header.has_64_bit_instructions ? "YES" : "NO"); | 86 | npdm_header.has_64_bit_instructions ? "YES" : "NO"); |
| 88 | 87 | ||
| 89 | auto address_space = "Unknown"; | 88 | auto address_space = "Unknown"; |
| 90 | switch (npdm_header.address_space_type) { | 89 | switch (npdm_header.address_space_type) { |
| @@ -96,19 +95,19 @@ void ProgramMetadata::Print() const { | |||
| 96 | break; | 95 | break; |
| 97 | } | 96 | } |
| 98 | 97 | ||
| 99 | LOG_DEBUG(Service_FS, " > Address space: %s\n", address_space); | 98 | NGLOG_DEBUG(Service_FS, " > Address space: {}\n", address_space); |
| 100 | 99 | ||
| 101 | // Begin ACID printing (potential perms, signed) | 100 | // Begin ACID printing (potential perms, signed) |
| 102 | LOG_DEBUG(Service_FS, "Magic: %.4s", acid_header.magic.data()); | 101 | NGLOG_DEBUG(Service_FS, "Magic: {:.4}", acid_header.magic.data()); |
| 103 | LOG_DEBUG(Service_FS, "Flags: %02x", acid_header.flags); | 102 | NGLOG_DEBUG(Service_FS, "Flags: {:02X}", acid_header.flags); |
| 104 | LOG_DEBUG(Service_FS, " > Is Retail: %s", acid_header.is_retail ? "YES" : "NO"); | 103 | NGLOG_DEBUG(Service_FS, " > Is Retail: {}", acid_header.is_retail ? "YES" : "NO"); |
| 105 | LOG_DEBUG(Service_FS, "Title ID Min: %016" PRIX64, acid_header.title_id_min); | 104 | NGLOG_DEBUG(Service_FS, "Title ID Min: {:016X}", acid_header.title_id_min); |
| 106 | LOG_DEBUG(Service_FS, "Title ID Max: %016" PRIX64, acid_header.title_id_max); | 105 | NGLOG_DEBUG(Service_FS, "Title ID Max: {:016X}", acid_header.title_id_max); |
| 107 | LOG_DEBUG(Service_FS, "Filesystem Access: %016" PRIX64 "\n", acid_file_access.permissions); | 106 | NGLOG_DEBUG(Service_FS, "Filesystem Access: {:016X}\n", acid_file_access.permissions); |
| 108 | 107 | ||
| 109 | // Begin ACI0 printing (actual perms, unsigned) | 108 | // Begin ACI0 printing (actual perms, unsigned) |
| 110 | LOG_DEBUG(Service_FS, "Magic: %.4s", aci_header.magic.data()); | 109 | NGLOG_DEBUG(Service_FS, "Magic: {:.4}", aci_header.magic.data()); |
| 111 | LOG_DEBUG(Service_FS, "Title ID: %016" PRIX64, aci_header.title_id); | 110 | NGLOG_DEBUG(Service_FS, "Title ID: {:016X}", aci_header.title_id); |
| 112 | LOG_DEBUG(Service_FS, "Filesystem Access: %016" PRIX64 "\n", aci_file_access.permissions); | 111 | NGLOG_DEBUG(Service_FS, "Filesystem Access: {:016X}\n", aci_file_access.permissions); |
| 113 | } | 112 | } |
| 114 | } // namespace FileSys | 113 | } // namespace FileSys |
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index b21427948..dc7591aca 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp | |||
| @@ -14,7 +14,7 @@ namespace FileSys { | |||
| 14 | RomFS_Factory::RomFS_Factory(Loader::AppLoader& app_loader) { | 14 | RomFS_Factory::RomFS_Factory(Loader::AppLoader& app_loader) { |
| 15 | // Load the RomFS from the app | 15 | // Load the RomFS from the app |
| 16 | if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) { | 16 | if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) { |
| 17 | LOG_ERROR(Service_FS, "Unable to read RomFS!"); | 17 | NGLOG_ERROR(Service_FS, "Unable to read RomFS!"); |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| 20 | 20 | ||
| @@ -24,13 +24,13 @@ ResultVal<std::unique_ptr<FileSystemBackend>> RomFS_Factory::Open(const Path& pa | |||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | ResultCode RomFS_Factory::Format(const Path& path) { | 26 | ResultCode RomFS_Factory::Format(const Path& path) { |
| 27 | LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); | 27 | NGLOG_ERROR(Service_FS, "Unimplemented Format archive {}", GetName()); |
| 28 | // TODO(bunnei): Find the right error code for this | 28 | // TODO(bunnei): Find the right error code for this |
| 29 | return ResultCode(-1); | 29 | return ResultCode(-1); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | ResultVal<ArchiveFormatInfo> RomFS_Factory::GetFormatInfo(const Path& path) const { | 32 | ResultVal<ArchiveFormatInfo> RomFS_Factory::GetFormatInfo(const Path& path) const { |
| 33 | LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); | 33 | NGLOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName()); |
| 34 | // TODO(bunnei): Find the right error code for this | 34 | // TODO(bunnei): Find the right error code for this |
| 35 | return ResultCode(-1); | 35 | return ResultCode(-1); |
| 36 | } | 36 | } |
diff --git a/src/core/file_sys/romfs_filesystem.cpp b/src/core/file_sys/romfs_filesystem.cpp index b9982e6fa..8e2bce687 100644 --- a/src/core/file_sys/romfs_filesystem.cpp +++ b/src/core/file_sys/romfs_filesystem.cpp | |||
| @@ -21,74 +21,72 @@ ResultVal<std::unique_ptr<StorageBackend>> RomFS_FileSystem::OpenFile(const std: | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const { | 23 | ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const { |
| 24 | LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).", | 24 | NGLOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive ({}).", GetName()); |
| 25 | GetName().c_str()); | ||
| 26 | // TODO(bunnei): Use correct error code | 25 | // TODO(bunnei): Use correct error code |
| 27 | return ResultCode(-1); | 26 | return ResultCode(-1); |
| 28 | } | 27 | } |
| 29 | 28 | ||
| 30 | ResultCode RomFS_FileSystem::RenameFile(const std::string& src_path, | 29 | ResultCode RomFS_FileSystem::RenameFile(const std::string& src_path, |
| 31 | const std::string& dest_path) const { | 30 | const std::string& dest_path) const { |
| 32 | LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).", | 31 | NGLOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive ({}).", |
| 33 | GetName().c_str()); | 32 | GetName()); |
| 34 | // TODO(wwylele): Use correct error code | 33 | // TODO(wwylele): Use correct error code |
| 35 | return ResultCode(-1); | 34 | return ResultCode(-1); |
| 36 | } | 35 | } |
| 37 | 36 | ||
| 38 | ResultCode RomFS_FileSystem::DeleteDirectory(const Path& path) const { | 37 | ResultCode RomFS_FileSystem::DeleteDirectory(const Path& path) const { |
| 39 | LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive (%s).", | 38 | NGLOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive ({}).", |
| 40 | GetName().c_str()); | 39 | GetName()); |
| 41 | // TODO(wwylele): Use correct error code | 40 | // TODO(wwylele): Use correct error code |
| 42 | return ResultCode(-1); | 41 | return ResultCode(-1); |
| 43 | } | 42 | } |
| 44 | 43 | ||
| 45 | ResultCode RomFS_FileSystem::DeleteDirectoryRecursively(const Path& path) const { | 44 | ResultCode RomFS_FileSystem::DeleteDirectoryRecursively(const Path& path) const { |
| 46 | LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive (%s).", | 45 | NGLOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive ({}).", |
| 47 | GetName().c_str()); | 46 | GetName()); |
| 48 | // TODO(wwylele): Use correct error code | 47 | // TODO(wwylele): Use correct error code |
| 49 | return ResultCode(-1); | 48 | return ResultCode(-1); |
| 50 | } | 49 | } |
| 51 | 50 | ||
| 52 | ResultCode RomFS_FileSystem::CreateFile(const std::string& path, u64 size) const { | 51 | ResultCode RomFS_FileSystem::CreateFile(const std::string& path, u64 size) const { |
| 53 | LOG_CRITICAL(Service_FS, "Attempted to create a file in an ROMFS archive (%s).", | 52 | NGLOG_CRITICAL(Service_FS, "Attempted to create a file in an ROMFS archive ({}).", GetName()); |
| 54 | GetName().c_str()); | ||
| 55 | // TODO(bunnei): Use correct error code | 53 | // TODO(bunnei): Use correct error code |
| 56 | return ResultCode(-1); | 54 | return ResultCode(-1); |
| 57 | } | 55 | } |
| 58 | 56 | ||
| 59 | ResultCode RomFS_FileSystem::CreateDirectory(const std::string& path) const { | 57 | ResultCode RomFS_FileSystem::CreateDirectory(const std::string& path) const { |
| 60 | LOG_CRITICAL(Service_FS, "Attempted to create a directory in an ROMFS archive (%s).", | 58 | NGLOG_CRITICAL(Service_FS, "Attempted to create a directory in an ROMFS archive ({}).", |
| 61 | GetName().c_str()); | 59 | GetName()); |
| 62 | // TODO(wwylele): Use correct error code | 60 | // TODO(wwylele): Use correct error code |
| 63 | return ResultCode(-1); | 61 | return ResultCode(-1); |
| 64 | } | 62 | } |
| 65 | 63 | ||
| 66 | ResultCode RomFS_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const { | 64 | ResultCode RomFS_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const { |
| 67 | LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).", | 65 | NGLOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive ({}).", |
| 68 | GetName().c_str()); | 66 | GetName()); |
| 69 | // TODO(wwylele): Use correct error code | 67 | // TODO(wwylele): Use correct error code |
| 70 | return ResultCode(-1); | 68 | return ResultCode(-1); |
| 71 | } | 69 | } |
| 72 | 70 | ||
| 73 | ResultVal<std::unique_ptr<DirectoryBackend>> RomFS_FileSystem::OpenDirectory( | 71 | ResultVal<std::unique_ptr<DirectoryBackend>> RomFS_FileSystem::OpenDirectory( |
| 74 | const std::string& path) const { | 72 | const std::string& path) const { |
| 75 | LOG_WARNING(Service_FS, "Opening Directory in a ROMFS archive"); | 73 | NGLOG_WARNING(Service_FS, "Opening Directory in a ROMFS archive"); |
| 76 | return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<ROMFSDirectory>()); | 74 | return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<ROMFSDirectory>()); |
| 77 | } | 75 | } |
| 78 | 76 | ||
| 79 | u64 RomFS_FileSystem::GetFreeSpaceSize() const { | 77 | u64 RomFS_FileSystem::GetFreeSpaceSize() const { |
| 80 | LOG_WARNING(Service_FS, "Attempted to get the free space in an ROMFS archive"); | 78 | NGLOG_WARNING(Service_FS, "Attempted to get the free space in an ROMFS archive"); |
| 81 | return 0; | 79 | return 0; |
| 82 | } | 80 | } |
| 83 | 81 | ||
| 84 | ResultVal<FileSys::EntryType> RomFS_FileSystem::GetEntryType(const std::string& path) const { | 82 | ResultVal<FileSys::EntryType> RomFS_FileSystem::GetEntryType(const std::string& path) const { |
| 85 | LOG_CRITICAL(Service_FS, "Called within an ROMFS archive (path %s).", path.c_str()); | 83 | NGLOG_CRITICAL(Service_FS, "Called within an ROMFS archive (path {}).", path); |
| 86 | // TODO(wwylele): Use correct error code | 84 | // TODO(wwylele): Use correct error code |
| 87 | return ResultCode(-1); | 85 | return ResultCode(-1); |
| 88 | } | 86 | } |
| 89 | 87 | ||
| 90 | ResultVal<size_t> RomFS_Storage::Read(const u64 offset, const size_t length, u8* buffer) const { | 88 | ResultVal<size_t> RomFS_Storage::Read(const u64 offset, const size_t length, u8* buffer) const { |
| 91 | LOG_TRACE(Service_FS, "called offset=%llu, length=%zu", offset, length); | 89 | NGLOG_TRACE(Service_FS, "called offset={}, length={}", offset, length); |
| 92 | romfs_file->Seek(data_offset + offset, SEEK_SET); | 90 | romfs_file->Seek(data_offset + offset, SEEK_SET); |
| 93 | size_t read_length = (size_t)std::min((u64)length, data_size - offset); | 91 | size_t read_length = (size_t)std::min((u64)length, data_size - offset); |
| 94 | 92 | ||
| @@ -97,7 +95,7 @@ ResultVal<size_t> RomFS_Storage::Read(const u64 offset, const size_t length, u8* | |||
| 97 | 95 | ||
| 98 | ResultVal<size_t> RomFS_Storage::Write(const u64 offset, const size_t length, const bool flush, | 96 | ResultVal<size_t> RomFS_Storage::Write(const u64 offset, const size_t length, const bool flush, |
| 99 | const u8* buffer) const { | 97 | const u8* buffer) const { |
| 100 | LOG_ERROR(Service_FS, "Attempted to write to ROMFS file"); | 98 | NGLOG_ERROR(Service_FS, "Attempted to write to ROMFS file"); |
| 101 | // TODO(Subv): Find error code | 99 | // TODO(Subv): Find error code |
| 102 | return MakeResult<size_t>(0); | 100 | return MakeResult<size_t>(0); |
| 103 | } | 101 | } |
| @@ -107,7 +105,7 @@ u64 RomFS_Storage::GetSize() const { | |||
| 107 | } | 105 | } |
| 108 | 106 | ||
| 109 | bool RomFS_Storage::SetSize(const u64 size) const { | 107 | bool RomFS_Storage::SetSize(const u64 size) const { |
| 110 | LOG_ERROR(Service_FS, "Attempted to set the size of an ROMFS file"); | 108 | NGLOG_ERROR(Service_FS, "Attempted to set the size of an ROMFS file"); |
| 111 | return false; | 109 | return false; |
| 112 | } | 110 | } |
| 113 | 111 | ||
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index 14868fed2..c1be8fee4 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -2,11 +2,9 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cinttypes> | ||
| 6 | #include <memory> | 5 | #include <memory> |
| 7 | #include "common/common_types.h" | 6 | #include "common/common_types.h" |
| 8 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 9 | #include "common/string_util.h" | ||
| 10 | #include "core/core.h" | 8 | #include "core/core.h" |
| 11 | #include "core/file_sys/disk_filesystem.h" | 9 | #include "core/file_sys/disk_filesystem.h" |
| 12 | #include "core/file_sys/savedata_factory.h" | 10 | #include "core/file_sys/savedata_factory.h" |
| @@ -30,7 +28,7 @@ ResultVal<std::unique_ptr<FileSystemBackend>> SaveData_Factory::Open(const Path& | |||
| 30 | } | 28 | } |
| 31 | 29 | ||
| 32 | ResultCode SaveData_Factory::Format(const Path& path) { | 30 | ResultCode SaveData_Factory::Format(const Path& path) { |
| 33 | LOG_WARNING(Service_FS, "Format archive %s", GetName().c_str()); | 31 | NGLOG_WARNING(Service_FS, "Format archive {}", GetName()); |
| 34 | // Create the save data directory. | 32 | // Create the save data directory. |
| 35 | if (!FileUtil::CreateFullPath(GetFullPath())) { | 33 | if (!FileUtil::CreateFullPath(GetFullPath())) { |
| 36 | // TODO(Subv): Find the correct error code. | 34 | // TODO(Subv): Find the correct error code. |
| @@ -41,7 +39,7 @@ ResultCode SaveData_Factory::Format(const Path& path) { | |||
| 41 | } | 39 | } |
| 42 | 40 | ||
| 43 | ResultVal<ArchiveFormatInfo> SaveData_Factory::GetFormatInfo(const Path& path) const { | 41 | ResultVal<ArchiveFormatInfo> SaveData_Factory::GetFormatInfo(const Path& path) const { |
| 44 | LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); | 42 | NGLOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName()); |
| 45 | // TODO(bunnei): Find the right error code for this | 43 | // TODO(bunnei): Find the right error code for this |
| 46 | return ResultCode(-1); | 44 | return ResultCode(-1); |
| 47 | } | 45 | } |
| @@ -50,8 +48,7 @@ std::string SaveData_Factory::GetFullPath() const { | |||
| 50 | u64 title_id = Core::CurrentProcess()->program_id; | 48 | u64 title_id = Core::CurrentProcess()->program_id; |
| 51 | // TODO(Subv): Somehow obtain this value. | 49 | // TODO(Subv): Somehow obtain this value. |
| 52 | u32 user = 0; | 50 | u32 user = 0; |
| 53 | return Common::StringFromFormat("%ssave/%016" PRIX64 "/%08X/", nand_directory.c_str(), title_id, | 51 | return fmt::format("{}save/{:016X}/{:08X}/", nand_directory, title_id, user); |
| 54 | user); | ||
| 55 | } | 52 | } |
| 56 | 53 | ||
| 57 | } // namespace FileSys | 54 | } // namespace FileSys |
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp index 00e80d2a7..59ac3e0be 100644 --- a/src/core/file_sys/sdmc_factory.cpp +++ b/src/core/file_sys/sdmc_factory.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cinttypes> | ||
| 6 | #include <memory> | 5 | #include <memory> |
| 7 | #include "common/common_types.h" | 6 | #include "common/common_types.h" |
| 8 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| @@ -26,13 +25,13 @@ ResultVal<std::unique_ptr<FileSystemBackend>> SDMC_Factory::Open(const Path& pat | |||
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | ResultCode SDMC_Factory::Format(const Path& path) { | 27 | ResultCode SDMC_Factory::Format(const Path& path) { |
| 29 | LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); | 28 | NGLOG_ERROR(Service_FS, "Unimplemented Format archive {}", GetName()); |
| 30 | // TODO(Subv): Find the right error code for this | 29 | // TODO(Subv): Find the right error code for this |
| 31 | return ResultCode(-1); | 30 | return ResultCode(-1); |
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | ResultVal<ArchiveFormatInfo> SDMC_Factory::GetFormatInfo(const Path& path) const { | 33 | ResultVal<ArchiveFormatInfo> SDMC_Factory::GetFormatInfo(const Path& path) const { |
| 35 | LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); | 34 | NGLOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName()); |
| 36 | // TODO(bunnei): Find the right error code for this | 35 | // TODO(bunnei): Find the right error code for this |
| 37 | return ResultCode(-1); | 36 | return ResultCode(-1); |
| 38 | } | 37 | } |
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 822449cd5..f7a9920d8 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp | |||
| @@ -26,7 +26,7 @@ ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) { | |||
| 26 | 26 | ||
| 27 | u16 slot = next_free_slot; | 27 | u16 slot = next_free_slot; |
| 28 | if (slot >= generations.size()) { | 28 | if (slot >= generations.size()) { |
| 29 | LOG_ERROR(Kernel, "Unable to allocate Handle, too many slots in use."); | 29 | NGLOG_ERROR(Kernel, "Unable to allocate Handle, too many slots in use."); |
| 30 | return ERR_OUT_OF_HANDLES; | 30 | return ERR_OUT_OF_HANDLES; |
| 31 | } | 31 | } |
| 32 | next_free_slot = generations[slot]; | 32 | next_free_slot = generations[slot]; |
| @@ -48,7 +48,7 @@ ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) { | |||
| 48 | ResultVal<Handle> HandleTable::Duplicate(Handle handle) { | 48 | ResultVal<Handle> HandleTable::Duplicate(Handle handle) { |
| 49 | SharedPtr<Object> object = GetGeneric(handle); | 49 | SharedPtr<Object> object = GetGeneric(handle); |
| 50 | if (object == nullptr) { | 50 | if (object == nullptr) { |
| 51 | LOG_ERROR(Kernel, "Tried to duplicate invalid handle: %08X", handle); | 51 | NGLOG_ERROR(Kernel, "Tried to duplicate invalid handle: {:08X}", handle); |
| 52 | return ERR_INVALID_HANDLE; | 52 | return ERR_INVALID_HANDLE; |
| 53 | } | 53 | } |
| 54 | return Create(std::move(object)); | 54 | return Create(std::move(object)); |
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index bef4f15f5..aa6ca1026 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -118,7 +118,7 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) { | |||
| 118 | std::make_shared<IPC::DomainMessageHeader>(rp.PopRaw<IPC::DomainMessageHeader>()); | 118 | std::make_shared<IPC::DomainMessageHeader>(rp.PopRaw<IPC::DomainMessageHeader>()); |
| 119 | } else { | 119 | } else { |
| 120 | if (Session()->IsDomain()) | 120 | if (Session()->IsDomain()) |
| 121 | LOG_WARNING(IPC, "Domain request has no DomainMessageHeader!"); | 121 | NGLOG_WARNING(IPC, "Domain request has no DomainMessageHeader!"); |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
| @@ -270,7 +270,8 @@ size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size) const { | |||
| 270 | const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()}; | 270 | const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()}; |
| 271 | const size_t buffer_size{GetWriteBufferSize()}; | 271 | const size_t buffer_size{GetWriteBufferSize()}; |
| 272 | if (size > buffer_size) { | 272 | if (size > buffer_size) { |
| 273 | LOG_CRITICAL(Core, "size (%016zx) is greater than buffer_size (%016zx)", size, buffer_size); | 273 | NGLOG_CRITICAL(Core, "size ({:016X}) is greater than buffer_size ({:016X})", size, |
| 274 | buffer_size); | ||
| 274 | size = buffer_size; // TODO(bunnei): This needs to be HW tested | 275 | size = buffer_size; // TODO(bunnei): This needs to be HW tested |
| 275 | } | 276 | } |
| 276 | 277 | ||
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 2cffec198..751a0524d 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -54,7 +54,7 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) { | |||
| 54 | continue; | 54 | continue; |
| 55 | } else if ((type & 0xF00) == 0xE00) { // 0x0FFF | 55 | } else if ((type & 0xF00) == 0xE00) { // 0x0FFF |
| 56 | // Allowed interrupts list | 56 | // Allowed interrupts list |
| 57 | LOG_WARNING(Loader, "ExHeader allowed interrupts list ignored"); | 57 | NGLOG_WARNING(Loader, "ExHeader allowed interrupts list ignored"); |
| 58 | } else if ((type & 0xF80) == 0xF00) { // 0x07FF | 58 | } else if ((type & 0xF80) == 0xF00) { // 0x07FF |
| 59 | // Allowed syscalls mask | 59 | // Allowed syscalls mask |
| 60 | unsigned int index = ((descriptor >> 24) & 7) * 24; | 60 | unsigned int index = ((descriptor >> 24) & 7) * 24; |
| @@ -74,7 +74,7 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) { | |||
| 74 | } else if ((type & 0xFFE) == 0xFF8) { // 0x001F | 74 | } else if ((type & 0xFFE) == 0xFF8) { // 0x001F |
| 75 | // Mapped memory range | 75 | // Mapped memory range |
| 76 | if (i + 1 >= len || ((kernel_caps[i + 1] >> 20) & 0xFFE) != 0xFF8) { | 76 | if (i + 1 >= len || ((kernel_caps[i + 1] >> 20) & 0xFFE) != 0xFF8) { |
| 77 | LOG_WARNING(Loader, "Incomplete exheader memory range descriptor ignored."); | 77 | NGLOG_WARNING(Loader, "Incomplete exheader memory range descriptor ignored."); |
| 78 | continue; | 78 | continue; |
| 79 | } | 79 | } |
| 80 | u32 end_desc = kernel_caps[i + 1]; | 80 | u32 end_desc = kernel_caps[i + 1]; |
| @@ -109,9 +109,9 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) { | |||
| 109 | 109 | ||
| 110 | int minor = kernel_version & 0xFF; | 110 | int minor = kernel_version & 0xFF; |
| 111 | int major = (kernel_version >> 8) & 0xFF; | 111 | int major = (kernel_version >> 8) & 0xFF; |
| 112 | LOG_INFO(Loader, "ExHeader kernel version: %d.%d", major, minor); | 112 | NGLOG_INFO(Loader, "ExHeader kernel version: {}.{}", major, minor); |
| 113 | } else { | 113 | } else { |
| 114 | LOG_ERROR(Loader, "Unhandled kernel caps descriptor: 0x%08X", descriptor); | 114 | NGLOG_ERROR(Loader, "Unhandled kernel caps descriptor: {:#010X}", descriptor); |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | } | 117 | } |
diff --git a/src/core/hle/kernel/resource_limit.cpp b/src/core/hle/kernel/resource_limit.cpp index 88ca8ad7e..0ef5fc57d 100644 --- a/src/core/hle/kernel/resource_limit.cpp +++ b/src/core/hle/kernel/resource_limit.cpp | |||
| @@ -29,7 +29,7 @@ SharedPtr<ResourceLimit> ResourceLimit::GetForCategory(ResourceLimitCategory cat | |||
| 29 | case ResourceLimitCategory::OTHER: | 29 | case ResourceLimitCategory::OTHER: |
| 30 | return resource_limits[static_cast<u8>(category)]; | 30 | return resource_limits[static_cast<u8>(category)]; |
| 31 | default: | 31 | default: |
| 32 | LOG_CRITICAL(Kernel, "Unknown resource limit category"); | 32 | NGLOG_CRITICAL(Kernel, "Unknown resource limit category"); |
| 33 | UNREACHABLE(); | 33 | UNREACHABLE(); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| @@ -55,7 +55,7 @@ s32 ResourceLimit::GetCurrentResourceValue(ResourceType resource) const { | |||
| 55 | case ResourceType::CPUTime: | 55 | case ResourceType::CPUTime: |
| 56 | return current_cpu_time; | 56 | return current_cpu_time; |
| 57 | default: | 57 | default: |
| 58 | LOG_ERROR(Kernel, "Unknown resource type=%08X", static_cast<u32>(resource)); | 58 | NGLOG_ERROR(Kernel, "Unknown resource type={:08X}", static_cast<u32>(resource)); |
| 59 | UNIMPLEMENTED(); | 59 | UNIMPLEMENTED(); |
| 60 | return 0; | 60 | return 0; |
| 61 | } | 61 | } |
| @@ -84,7 +84,7 @@ u32 ResourceLimit::GetMaxResourceValue(ResourceType resource) const { | |||
| 84 | case ResourceType::CPUTime: | 84 | case ResourceType::CPUTime: |
| 85 | return max_cpu_time; | 85 | return max_cpu_time; |
| 86 | default: | 86 | default: |
| 87 | LOG_ERROR(Kernel, "Unknown resource type=%08X", static_cast<u32>(resource)); | 87 | NGLOG_ERROR(Kernel, "Unknown resource type={:08X}", static_cast<u32>(resource)); |
| 88 | UNIMPLEMENTED(); | 88 | UNIMPLEMENTED(); |
| 89 | return 0; | 89 | return 0; |
| 90 | } | 90 | } |
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 921f27efb..ff6a0941a 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp | |||
| @@ -94,11 +94,11 @@ void Scheduler::Reschedule() { | |||
| 94 | Thread* next = PopNextReadyThread(); | 94 | Thread* next = PopNextReadyThread(); |
| 95 | 95 | ||
| 96 | if (cur && next) { | 96 | if (cur && next) { |
| 97 | LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId()); | 97 | NGLOG_TRACE(Kernel, "context switch {} -> {}", cur->GetObjectId(), next->GetObjectId()); |
| 98 | } else if (cur) { | 98 | } else if (cur) { |
| 99 | LOG_TRACE(Kernel, "context switch %u -> idle", cur->GetObjectId()); | 99 | NGLOG_TRACE(Kernel, "context switch {} -> idle", cur->GetObjectId()); |
| 100 | } else if (next) { | 100 | } else if (next) { |
| 101 | LOG_TRACE(Kernel, "context switch idle -> %u", next->GetObjectId()); | 101 | NGLOG_TRACE(Kernel, "context switch idle -> {}", next->GetObjectId()); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | SwitchContext(next); | 104 | SwitchContext(next); |
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 33397d84f..b1f8e771c 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp | |||
| @@ -68,7 +68,7 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con | |||
| 68 | return domain_request_handlers[object_id - 1]->HandleSyncRequest(context); | 68 | return domain_request_handlers[object_id - 1]->HandleSyncRequest(context); |
| 69 | 69 | ||
| 70 | case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: { | 70 | case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: { |
| 71 | LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x%08X", object_id); | 71 | NGLOG_DEBUG(IPC, "CloseVirtualHandle, object_id={:#010X}", object_id); |
| 72 | 72 | ||
| 73 | domain_request_handlers[object_id - 1] = nullptr; | 73 | domain_request_handlers[object_id - 1] = nullptr; |
| 74 | 74 | ||
| @@ -78,8 +78,8 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con | |||
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | LOG_CRITICAL(IPC, "Unknown domain command=%d", | 81 | NGLOG_CRITICAL(IPC, "Unknown domain command={}", |
| 82 | static_cast<int>(domain_message_header->command.Value())); | 82 | static_cast<int>(domain_message_header->command.Value())); |
| 83 | ASSERT(false); | 83 | ASSERT(false); |
| 84 | } | 84 | } |
| 85 | 85 | ||
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index bc99993c8..f0b65c73d 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp | |||
| @@ -107,16 +107,16 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi | |||
| 107 | 107 | ||
| 108 | // Error out if the requested permissions don't match what the creator process allows. | 108 | // Error out if the requested permissions don't match what the creator process allows. |
| 109 | if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) { | 109 | if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) { |
| 110 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%lx name=%s, permissions don't match", | 110 | NGLOG_ERROR(Kernel, "cannot map id={}, address={:#X} name={}, permissions don't match", |
| 111 | GetObjectId(), address, name.c_str()); | 111 | GetObjectId(), address, name); |
| 112 | return ERR_INVALID_COMBINATION; | 112 | return ERR_INVALID_COMBINATION; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | // Error out if the provided permissions are not compatible with what the creator process needs. | 115 | // Error out if the provided permissions are not compatible with what the creator process needs. |
| 116 | if (other_permissions != MemoryPermission::DontCare && | 116 | if (other_permissions != MemoryPermission::DontCare && |
| 117 | static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) { | 117 | static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) { |
| 118 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%lx name=%s, permissions don't match", | 118 | NGLOG_ERROR(Kernel, "cannot map id={}, address={:#X} name={}, permissions don't match", |
| 119 | GetObjectId(), address, name.c_str()); | 119 | GetObjectId(), address, name); |
| 120 | return ERR_WRONG_PERMISSION; | 120 | return ERR_WRONG_PERMISSION; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| @@ -131,9 +131,10 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi | |||
| 131 | auto result = target_process->vm_manager.MapMemoryBlock( | 131 | auto result = target_process->vm_manager.MapMemoryBlock( |
| 132 | target_address, backing_block, backing_block_offset, size, MemoryState::Shared); | 132 | target_address, backing_block, backing_block_offset, size, MemoryState::Shared); |
| 133 | if (result.Failed()) { | 133 | if (result.Failed()) { |
| 134 | LOG_ERROR(Kernel, | 134 | NGLOG_ERROR( |
| 135 | "cannot map id=%u, target_address=0x%lx name=%s, error mapping to virtual memory", | 135 | Kernel, |
| 136 | GetObjectId(), target_address, name.c_str()); | 136 | "cannot map id={}, target_address={:#X} name={}, error mapping to virtual memory", |
| 137 | GetObjectId(), target_address, name); | ||
| 137 | return result.Code(); | 138 | return result.Code(); |
| 138 | } | 139 | } |
| 139 | 140 | ||
| @@ -151,7 +152,7 @@ VMAPermission SharedMemory::ConvertPermissions(MemoryPermission permission) { | |||
| 151 | u32 masked_permissions = | 152 | u32 masked_permissions = |
| 152 | static_cast<u32>(permission) & static_cast<u32>(MemoryPermission::ReadWriteExecute); | 153 | static_cast<u32>(permission) & static_cast<u32>(MemoryPermission::ReadWriteExecute); |
| 153 | return static_cast<VMAPermission>(masked_permissions); | 154 | return static_cast<VMAPermission>(masked_permissions); |
| 154 | }; | 155 | } |
| 155 | 156 | ||
| 156 | u8* SharedMemory::GetPointer(u32 offset) { | 157 | u8* SharedMemory::GetPointer(u32 offset) { |
| 157 | return backing_block->data() + backing_block_offset + offset; | 158 | return backing_block->data() + backing_block_offset + offset; |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index c22da6e47..cb19b1a69 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -31,7 +31,7 @@ namespace Kernel { | |||
| 31 | 31 | ||
| 32 | /// Set the process heap to a given Size. It can both extend and shrink the heap. | 32 | /// Set the process heap to a given Size. It can both extend and shrink the heap. |
| 33 | static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { | 33 | static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { |
| 34 | LOG_TRACE(Kernel_SVC, "called, heap_size=0x%llx", heap_size); | 34 | NGLOG_TRACE(Kernel_SVC, "called, heap_size={:#X}", heap_size); |
| 35 | auto& process = *Core::CurrentProcess(); | 35 | auto& process = *Core::CurrentProcess(); |
| 36 | CASCADE_RESULT(*heap_addr, | 36 | CASCADE_RESULT(*heap_addr, |
| 37 | process.HeapAllocate(Memory::HEAP_VADDR, heap_size, VMAPermission::ReadWrite)); | 37 | process.HeapAllocate(Memory::HEAP_VADDR, heap_size, VMAPermission::ReadWrite)); |
| @@ -39,21 +39,21 @@ static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state1) { | 41 | static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state1) { |
| 42 | LOG_WARNING(Kernel_SVC, "(STUBBED) called, addr=0x%lx", addr); | 42 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, addr={:#X}", addr); |
| 43 | return RESULT_SUCCESS; | 43 | return RESULT_SUCCESS; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | /// Maps a memory range into a different range. | 46 | /// Maps a memory range into a different range. |
| 47 | static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { | 47 | static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { |
| 48 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x%llx, src_addr=0x%llx, size=0x%llx", dst_addr, | 48 | NGLOG_TRACE(Kernel_SVC, "called, dst_addr={:#X}, src_addr={:#X}, size={:#X}", dst_addr, |
| 49 | src_addr, size); | 49 | src_addr, size); |
| 50 | return Core::CurrentProcess()->MirrorMemory(dst_addr, src_addr, size); | 50 | return Core::CurrentProcess()->MirrorMemory(dst_addr, src_addr, size); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | /// Unmaps a region that was previously mapped with svcMapMemory | 53 | /// Unmaps a region that was previously mapped with svcMapMemory |
| 54 | static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { | 54 | static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { |
| 55 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x%llx, src_addr=0x%llx, size=0x%llx", dst_addr, | 55 | NGLOG_TRACE(Kernel_SVC, "called, dst_addr={:#X}, src_addr={:#X}, size={:#X}", dst_addr, |
| 56 | src_addr, size); | 56 | src_addr, size); |
| 57 | return Core::CurrentProcess()->UnmapMemory(dst_addr, src_addr, size); | 57 | return Core::CurrentProcess()->UnmapMemory(dst_addr, src_addr, size); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -68,11 +68,11 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address | |||
| 68 | if (port_name.size() > PortNameMaxLength) | 68 | if (port_name.size() > PortNameMaxLength) |
| 69 | return ERR_PORT_NAME_TOO_LONG; | 69 | return ERR_PORT_NAME_TOO_LONG; |
| 70 | 70 | ||
| 71 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name.c_str()); | 71 | NGLOG_TRACE(Kernel_SVC, "called port_name={}", port_name); |
| 72 | 72 | ||
| 73 | auto it = Service::g_kernel_named_ports.find(port_name); | 73 | auto it = Service::g_kernel_named_ports.find(port_name); |
| 74 | if (it == Service::g_kernel_named_ports.end()) { | 74 | if (it == Service::g_kernel_named_ports.end()) { |
| 75 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name.c_str()); | 75 | NGLOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name); |
| 76 | return ERR_NOT_FOUND; | 76 | return ERR_NOT_FOUND; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| @@ -90,11 +90,11 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address | |||
| 90 | static ResultCode SendSyncRequest(Handle handle) { | 90 | static ResultCode SendSyncRequest(Handle handle) { |
| 91 | SharedPtr<ClientSession> session = g_handle_table.Get<ClientSession>(handle); | 91 | SharedPtr<ClientSession> session = g_handle_table.Get<ClientSession>(handle); |
| 92 | if (!session) { | 92 | if (!session) { |
| 93 | LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle); | 93 | NGLOG_ERROR(Kernel_SVC, "called with invalid handle={:#010X}", handle); |
| 94 | return ERR_INVALID_HANDLE; | 94 | return ERR_INVALID_HANDLE; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str()); | 97 | NGLOG_TRACE(Kernel_SVC, "called handle={:#010X}({})", handle, session->GetName()); |
| 98 | 98 | ||
| 99 | Core::System::GetInstance().PrepareReschedule(); | 99 | Core::System::GetInstance().PrepareReschedule(); |
| 100 | 100 | ||
| @@ -105,7 +105,7 @@ static ResultCode SendSyncRequest(Handle handle) { | |||
| 105 | 105 | ||
| 106 | /// Get the ID for the specified thread. | 106 | /// Get the ID for the specified thread. |
| 107 | static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) { | 107 | static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) { |
| 108 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); | 108 | NGLOG_TRACE(Kernel_SVC, "called thread={:#010X}", thread_handle); |
| 109 | 109 | ||
| 110 | const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); | 110 | const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); |
| 111 | if (!thread) { | 111 | if (!thread) { |
| @@ -118,7 +118,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) { | |||
| 118 | 118 | ||
| 119 | /// Get the ID of the specified process | 119 | /// Get the ID of the specified process |
| 120 | static ResultCode GetProcessId(u32* process_id, Handle process_handle) { | 120 | static ResultCode GetProcessId(u32* process_id, Handle process_handle) { |
| 121 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); | 121 | NGLOG_TRACE(Kernel_SVC, "called process={:#010X}", process_handle); |
| 122 | 122 | ||
| 123 | const SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle); | 123 | const SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle); |
| 124 | if (!process) { | 124 | if (!process) { |
| @@ -178,8 +178,8 @@ static ResultCode WaitSynchronization1( | |||
| 178 | /// Wait for the given handles to synchronize, timeout after the specified nanoseconds | 178 | /// Wait for the given handles to synchronize, timeout after the specified nanoseconds |
| 179 | static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 handle_count, | 179 | static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 handle_count, |
| 180 | s64 nano_seconds) { | 180 | s64 nano_seconds) { |
| 181 | LOG_TRACE(Kernel_SVC, "called handles_address=0x%llx, handle_count=%d, nano_seconds=%d", | 181 | NGLOG_TRACE(Kernel_SVC, "called handles_address={:#X}, handle_count={}, nano_seconds={}", |
| 182 | handles_address, handle_count, nano_seconds); | 182 | handles_address, handle_count, nano_seconds); |
| 183 | 183 | ||
| 184 | if (!Memory::IsValidVirtualAddress(handles_address)) | 184 | if (!Memory::IsValidVirtualAddress(handles_address)) |
| 185 | return ERR_INVALID_POINTER; | 185 | return ERR_INVALID_POINTER; |
| @@ -239,7 +239,7 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 | |||
| 239 | 239 | ||
| 240 | /// Resumes a thread waiting on WaitSynchronization | 240 | /// Resumes a thread waiting on WaitSynchronization |
| 241 | static ResultCode CancelSynchronization(Handle thread_handle) { | 241 | static ResultCode CancelSynchronization(Handle thread_handle) { |
| 242 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); | 242 | NGLOG_TRACE(Kernel_SVC, "called thread={:#X}", thread_handle); |
| 243 | 243 | ||
| 244 | const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); | 244 | const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); |
| 245 | if (!thread) { | 245 | if (!thread) { |
| @@ -256,38 +256,38 @@ static ResultCode CancelSynchronization(Handle thread_handle) { | |||
| 256 | /// Attempts to locks a mutex, creating it if it does not already exist | 256 | /// Attempts to locks a mutex, creating it if it does not already exist |
| 257 | static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr, | 257 | static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr, |
| 258 | Handle requesting_thread_handle) { | 258 | Handle requesting_thread_handle) { |
| 259 | LOG_TRACE(Kernel_SVC, | 259 | NGLOG_TRACE(Kernel_SVC, |
| 260 | "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, " | 260 | "called holding_thread_handle={:#010X}, mutex_addr={:#X}, " |
| 261 | "requesting_current_thread_handle=0x%08X", | 261 | "requesting_current_thread_handle={:#010X}", |
| 262 | holding_thread_handle, mutex_addr, requesting_thread_handle); | 262 | holding_thread_handle, mutex_addr, requesting_thread_handle); |
| 263 | 263 | ||
| 264 | return Mutex::TryAcquire(mutex_addr, holding_thread_handle, requesting_thread_handle); | 264 | return Mutex::TryAcquire(mutex_addr, holding_thread_handle, requesting_thread_handle); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | /// Unlock a mutex | 267 | /// Unlock a mutex |
| 268 | static ResultCode ArbitrateUnlock(VAddr mutex_addr) { | 268 | static ResultCode ArbitrateUnlock(VAddr mutex_addr) { |
| 269 | LOG_TRACE(Kernel_SVC, "called mutex_addr=0x%llx", mutex_addr); | 269 | NGLOG_TRACE(Kernel_SVC, "called mutex_addr={:#X}", mutex_addr); |
| 270 | 270 | ||
| 271 | return Mutex::Release(mutex_addr); | 271 | return Mutex::Release(mutex_addr); |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | /// Break program execution | 274 | /// Break program execution |
| 275 | static void Break(u64 unk_0, u64 unk_1, u64 unk_2) { | 275 | static void Break(u64 unk_0, u64 unk_1, u64 unk_2) { |
| 276 | LOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!"); | 276 | NGLOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!"); |
| 277 | ASSERT(false); | 277 | ASSERT(false); |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | /// Used to output a message on a debug hardware unit - does nothing on a retail unit | 280 | /// Used to output a message on a debug hardware unit - does nothing on a retail unit |
| 281 | static void OutputDebugString(VAddr address, s32 len) { | 281 | static void OutputDebugString(VAddr address, s32 len) { |
| 282 | std::vector<char> string(len); | 282 | std::string str(len, '\0'); |
| 283 | Memory::ReadBlock(address, string.data(), len); | 283 | Memory::ReadBlock(address, str.data(), str.size()); |
| 284 | LOG_DEBUG(Debug_Emulated, "%.*s", len, string.data()); | 284 | NGLOG_DEBUG(Debug_Emulated, "{}", str); |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | /// Gets system/memory information for the current process | 287 | /// Gets system/memory information for the current process |
| 288 | static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) { | 288 | static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) { |
| 289 | LOG_TRACE(Kernel_SVC, "called info_id=0x%X, info_sub_id=0x%X, handle=0x%08X", info_id, | 289 | NGLOG_TRACE(Kernel_SVC, "called info_id={:#X}, info_sub_id={:#X}, handle={:#010X}", info_id, |
| 290 | info_sub_id, handle); | 290 | info_sub_id, handle); |
| 291 | 291 | ||
| 292 | auto& vm_manager = Core::CurrentProcess()->vm_manager; | 292 | auto& vm_manager = Core::CurrentProcess()->vm_manager; |
| 293 | 293 | ||
| @@ -338,12 +338,12 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 338 | *result = Core::CurrentProcess()->is_virtual_address_memory_enabled; | 338 | *result = Core::CurrentProcess()->is_virtual_address_memory_enabled; |
| 339 | break; | 339 | break; |
| 340 | case GetInfoType::TitleId: | 340 | case GetInfoType::TitleId: |
| 341 | LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query titleid, returned 0"); | 341 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query titleid, returned 0"); |
| 342 | *result = 0; | 342 | *result = 0; |
| 343 | break; | 343 | break; |
| 344 | case GetInfoType::PrivilegedProcessId: | 344 | case GetInfoType::PrivilegedProcessId: |
| 345 | LOG_WARNING(Kernel_SVC, | 345 | NGLOG_WARNING(Kernel_SVC, |
| 346 | "(STUBBED) Attempted to query priviledged process id bounds, returned 0"); | 346 | "(STUBBED) Attempted to query privileged process id bounds, returned 0"); |
| 347 | *result = 0; | 347 | *result = 0; |
| 348 | break; | 348 | break; |
| 349 | default: | 349 | default: |
| @@ -355,13 +355,14 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 355 | 355 | ||
| 356 | /// Sets the thread activity | 356 | /// Sets the thread activity |
| 357 | static ResultCode SetThreadActivity(Handle handle, u32 unknown) { | 357 | static ResultCode SetThreadActivity(Handle handle, u32 unknown) { |
| 358 | LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x%08X, unknown=0x%08X", handle, unknown); | 358 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, handle={:#010X}, unknown={:#010X}", handle, |
| 359 | unknown); | ||
| 359 | return RESULT_SUCCESS; | 360 | return RESULT_SUCCESS; |
| 360 | } | 361 | } |
| 361 | 362 | ||
| 362 | /// Gets the thread context | 363 | /// Gets the thread context |
| 363 | static ResultCode GetThreadContext(Handle handle, VAddr addr) { | 364 | static ResultCode GetThreadContext(Handle handle, VAddr addr) { |
| 364 | LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x%08X, addr=0x%" PRIx64, handle, addr); | 365 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, handle={:#010X}, addr={:#X}", handle, addr); |
| 365 | return RESULT_SUCCESS; | 366 | return RESULT_SUCCESS; |
| 366 | } | 367 | } |
| 367 | 368 | ||
| @@ -400,15 +401,15 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) { | |||
| 400 | 401 | ||
| 401 | /// Get which CPU core is executing the current thread | 402 | /// Get which CPU core is executing the current thread |
| 402 | static u32 GetCurrentProcessorNumber() { | 403 | static u32 GetCurrentProcessorNumber() { |
| 403 | LOG_WARNING(Kernel_SVC, "(STUBBED) called, defaulting to processor 0"); | 404 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, defaulting to processor 0"); |
| 404 | return 0; | 405 | return 0; |
| 405 | } | 406 | } |
| 406 | 407 | ||
| 407 | static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size, | 408 | static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size, |
| 408 | u32 permissions) { | 409 | u32 permissions) { |
| 409 | LOG_TRACE(Kernel_SVC, | 410 | NGLOG_TRACE(Kernel_SVC, |
| 410 | "called, shared_memory_handle=0x%08X, addr=0x%llx, size=0x%llx, permissions=0x%08X", | 411 | "called, shared_memory_handle={:#X}, addr={:#X}, size={:#X}, permissions={:#010X}", |
| 411 | shared_memory_handle, addr, size, permissions); | 412 | shared_memory_handle, addr, size, permissions); |
| 412 | 413 | ||
| 413 | SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); | 414 | SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); |
| 414 | if (!shared_memory) { | 415 | if (!shared_memory) { |
| @@ -428,16 +429,15 @@ static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 s | |||
| 428 | return shared_memory->Map(Core::CurrentProcess().get(), addr, permissions_type, | 429 | return shared_memory->Map(Core::CurrentProcess().get(), addr, permissions_type, |
| 429 | MemoryPermission::DontCare); | 430 | MemoryPermission::DontCare); |
| 430 | default: | 431 | default: |
| 431 | LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); | 432 | NGLOG_ERROR(Kernel_SVC, "unknown permissions={:#010X}", permissions); |
| 432 | } | 433 | } |
| 433 | 434 | ||
| 434 | return RESULT_SUCCESS; | 435 | return RESULT_SUCCESS; |
| 435 | } | 436 | } |
| 436 | 437 | ||
| 437 | static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size) { | 438 | static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size) { |
| 438 | LOG_WARNING(Kernel_SVC, | 439 | NGLOG_WARNING(Kernel_SVC, "called, shared_memory_handle={:#010X}, addr={:#X}, size={:#X}", |
| 439 | "called, shared_memory_handle=0x%08X, addr=0x%" PRIx64 ", size=0x%" PRIx64 "", | 440 | shared_memory_handle, addr, size); |
| 440 | shared_memory_handle, addr, size); | ||
| 441 | 441 | ||
| 442 | SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); | 442 | SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); |
| 443 | 443 | ||
| @@ -465,19 +465,19 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i | |||
| 465 | memory_info->type = static_cast<u32>(vma->second.meminfo_state); | 465 | memory_info->type = static_cast<u32>(vma->second.meminfo_state); |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | LOG_TRACE(Kernel_SVC, "called process=0x%08X addr=%llx", process_handle, addr); | 468 | NGLOG_TRACE(Kernel_SVC, "called process={:#010X} addr={:X}", process_handle, addr); |
| 469 | return RESULT_SUCCESS; | 469 | return RESULT_SUCCESS; |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | /// Query memory | 472 | /// Query memory |
| 473 | static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, VAddr addr) { | 473 | static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, VAddr addr) { |
| 474 | LOG_TRACE(Kernel_SVC, "called, addr=%llx", addr); | 474 | NGLOG_TRACE(Kernel_SVC, "called, addr={:X}", addr); |
| 475 | return QueryProcessMemory(memory_info, page_info, CurrentProcess, addr); | 475 | return QueryProcessMemory(memory_info, page_info, CurrentProcess, addr); |
| 476 | } | 476 | } |
| 477 | 477 | ||
| 478 | /// Exits the current process | 478 | /// Exits the current process |
| 479 | static void ExitProcess() { | 479 | static void ExitProcess() { |
| 480 | LOG_INFO(Kernel_SVC, "Process %u exiting", Core::CurrentProcess()->process_id); | 480 | NGLOG_INFO(Kernel_SVC, "Process {} exiting", Core::CurrentProcess()->process_id); |
| 481 | 481 | ||
| 482 | ASSERT_MSG(Core::CurrentProcess()->status == ProcessStatus::Running, | 482 | ASSERT_MSG(Core::CurrentProcess()->status == ProcessStatus::Running, |
| 483 | "Process has already exited"); | 483 | "Process has already exited"); |
| @@ -534,9 +534,9 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V | |||
| 534 | case THREADPROCESSORID_2: | 534 | case THREADPROCESSORID_2: |
| 535 | case THREADPROCESSORID_3: | 535 | case THREADPROCESSORID_3: |
| 536 | // TODO(bunnei): Implement support for other processor IDs | 536 | // TODO(bunnei): Implement support for other processor IDs |
| 537 | LOG_ERROR(Kernel_SVC, | 537 | NGLOG_ERROR(Kernel_SVC, |
| 538 | "Newly created thread must run in another thread (%u), unimplemented.", | 538 | "Newly created thread must run in another thread ({}), unimplemented.", |
| 539 | processor_id); | 539 | processor_id); |
| 540 | break; | 540 | break; |
| 541 | default: | 541 | default: |
| 542 | ASSERT_MSG(false, "Unsupported thread processor ID: %d", processor_id); | 542 | ASSERT_MSG(false, "Unsupported thread processor ID: %d", processor_id); |
| @@ -551,17 +551,17 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V | |||
| 551 | 551 | ||
| 552 | Core::System::GetInstance().PrepareReschedule(); | 552 | Core::System::GetInstance().PrepareReschedule(); |
| 553 | 553 | ||
| 554 | LOG_TRACE(Kernel_SVC, | 554 | NGLOG_TRACE(Kernel_SVC, |
| 555 | "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " | 555 | "called entrypoint={:#010X} ({}), arg={:#010X}, stacktop={:#010X}, " |
| 556 | "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", | 556 | "threadpriority={:#010X}, processorid={:#010X} : created handle={:#010X}", |
| 557 | entry_point, name.c_str(), arg, stack_top, priority, processor_id, *out_handle); | 557 | entry_point, name, arg, stack_top, priority, processor_id, *out_handle); |
| 558 | 558 | ||
| 559 | return RESULT_SUCCESS; | 559 | return RESULT_SUCCESS; |
| 560 | } | 560 | } |
| 561 | 561 | ||
| 562 | /// Starts the thread for the provided handle | 562 | /// Starts the thread for the provided handle |
| 563 | static ResultCode StartThread(Handle thread_handle) { | 563 | static ResultCode StartThread(Handle thread_handle) { |
| 564 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); | 564 | NGLOG_TRACE(Kernel_SVC, "called thread={:#010X}", thread_handle); |
| 565 | 565 | ||
| 566 | const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); | 566 | const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); |
| 567 | if (!thread) { | 567 | if (!thread) { |
| @@ -575,7 +575,7 @@ static ResultCode StartThread(Handle thread_handle) { | |||
| 575 | 575 | ||
| 576 | /// Called when a thread exits | 576 | /// Called when a thread exits |
| 577 | static void ExitThread() { | 577 | static void ExitThread() { |
| 578 | LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::CPU().GetPC()); | 578 | NGLOG_TRACE(Kernel_SVC, "called, pc={:#010X}", Core::CPU().GetPC()); |
| 579 | 579 | ||
| 580 | ExitCurrentThread(); | 580 | ExitCurrentThread(); |
| 581 | Core::System::GetInstance().PrepareReschedule(); | 581 | Core::System::GetInstance().PrepareReschedule(); |
| @@ -583,7 +583,7 @@ static void ExitThread() { | |||
| 583 | 583 | ||
| 584 | /// Sleep the current thread | 584 | /// Sleep the current thread |
| 585 | static void SleepThread(s64 nanoseconds) { | 585 | static void SleepThread(s64 nanoseconds) { |
| 586 | LOG_TRACE(Kernel_SVC, "called nanoseconds=%lld", nanoseconds); | 586 | NGLOG_TRACE(Kernel_SVC, "called nanoseconds={}", nanoseconds); |
| 587 | 587 | ||
| 588 | // Don't attempt to yield execution if there are no available threads to run, | 588 | // Don't attempt to yield execution if there are no available threads to run, |
| 589 | // this way we avoid a useless reschedule to the idle thread. | 589 | // this way we avoid a useless reschedule to the idle thread. |
| @@ -602,9 +602,9 @@ static void SleepThread(s64 nanoseconds) { | |||
| 602 | /// Signal process wide key atomic | 602 | /// Signal process wide key atomic |
| 603 | static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_variable_addr, | 603 | static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_variable_addr, |
| 604 | Handle thread_handle, s64 nano_seconds) { | 604 | Handle thread_handle, s64 nano_seconds) { |
| 605 | LOG_TRACE( | 605 | NGLOG_TRACE( |
| 606 | Kernel_SVC, | 606 | Kernel_SVC, |
| 607 | "called mutex_addr=%llx, condition_variable_addr=%llx, thread_handle=0x%08X, timeout=%d", | 607 | "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle={:#010X}, timeout={}", |
| 608 | mutex_addr, condition_variable_addr, thread_handle, nano_seconds); | 608 | mutex_addr, condition_variable_addr, thread_handle, nano_seconds); |
| 609 | 609 | ||
| 610 | SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); | 610 | SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); |
| @@ -629,8 +629,8 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var | |||
| 629 | 629 | ||
| 630 | /// Signal process wide key | 630 | /// Signal process wide key |
| 631 | static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) { | 631 | static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) { |
| 632 | LOG_TRACE(Kernel_SVC, "called, condition_variable_addr=0x%llx, target=0x%08x", | 632 | NGLOG_TRACE(Kernel_SVC, "called, condition_variable_addr={:#X}, target={:#010X}", |
| 633 | condition_variable_addr, target); | 633 | condition_variable_addr, target); |
| 634 | 634 | ||
| 635 | u32 processed = 0; | 635 | u32 processed = 0; |
| 636 | auto& thread_list = Core::System::GetInstance().Scheduler().GetThreadList(); | 636 | auto& thread_list = Core::System::GetInstance().Scheduler().GetThreadList(); |
| @@ -696,13 +696,13 @@ static u64 GetSystemTick() { | |||
| 696 | 696 | ||
| 697 | /// Close a handle | 697 | /// Close a handle |
| 698 | static ResultCode CloseHandle(Handle handle) { | 698 | static ResultCode CloseHandle(Handle handle) { |
| 699 | LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle); | 699 | NGLOG_TRACE(Kernel_SVC, "Closing handle {:#010X}", handle); |
| 700 | return g_handle_table.Close(handle); | 700 | return g_handle_table.Close(handle); |
| 701 | } | 701 | } |
| 702 | 702 | ||
| 703 | /// Reset an event | 703 | /// Reset an event |
| 704 | static ResultCode ResetSignal(Handle handle) { | 704 | static ResultCode ResetSignal(Handle handle) { |
| 705 | LOG_WARNING(Kernel_SVC, "(STUBBED) called handle 0x%08X", handle); | 705 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) called handle {:#010X}", handle); |
| 706 | auto event = g_handle_table.Get<Event>(handle); | 706 | auto event = g_handle_table.Get<Event>(handle); |
| 707 | ASSERT(event != nullptr); | 707 | ASSERT(event != nullptr); |
| 708 | event->Clear(); | 708 | event->Clear(); |
| @@ -711,29 +711,29 @@ static ResultCode ResetSignal(Handle handle) { | |||
| 711 | 711 | ||
| 712 | /// Creates a TransferMemory object | 712 | /// Creates a TransferMemory object |
| 713 | static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 permissions) { | 713 | static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 permissions) { |
| 714 | LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x%lx, size=0x%lx, perms=%08X", addr, size, | 714 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) called addr={:#X}, size={:#X}, perms={:010X}", addr, size, |
| 715 | permissions); | 715 | permissions); |
| 716 | *handle = 0; | 716 | *handle = 0; |
| 717 | return RESULT_SUCCESS; | 717 | return RESULT_SUCCESS; |
| 718 | } | 718 | } |
| 719 | 719 | ||
| 720 | static ResultCode GetThreadCoreMask(Handle handle, u32* mask, u64* unknown) { | 720 | static ResultCode GetThreadCoreMask(Handle handle, u32* mask, u64* unknown) { |
| 721 | LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x%08X", handle); | 721 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, handle={:010X}", handle); |
| 722 | *mask = 0x0; | 722 | *mask = 0x0; |
| 723 | *unknown = 0xf; | 723 | *unknown = 0xf; |
| 724 | return RESULT_SUCCESS; | 724 | return RESULT_SUCCESS; |
| 725 | } | 725 | } |
| 726 | 726 | ||
| 727 | static ResultCode SetThreadCoreMask(Handle handle, u32 mask, u64 unknown) { | 727 | static ResultCode SetThreadCoreMask(Handle handle, u32 mask, u64 unknown) { |
| 728 | LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x%08X, mask=0x%08X, unknown=0x%lx", handle, | 728 | NGLOG_WARNING(Kernel_SVC, "(STUBBED) called, handle={:#010X}, mask={:#010X}, unknown={:#X}", |
| 729 | mask, unknown); | 729 | handle, mask, unknown); |
| 730 | return RESULT_SUCCESS; | 730 | return RESULT_SUCCESS; |
| 731 | } | 731 | } |
| 732 | 732 | ||
| 733 | static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permissions, | 733 | static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permissions, |
| 734 | u32 remote_permissions) { | 734 | u32 remote_permissions) { |
| 735 | LOG_TRACE(Kernel_SVC, "called, size=0x%llx, localPerms=0x%08x, remotePerms=0x%08x", size, | 735 | NGLOG_TRACE(Kernel_SVC, "called, size={:#X}, localPerms={:#010X}, remotePerms={:#010X}", size, |
| 736 | local_permissions, remote_permissions); | 736 | local_permissions, remote_permissions); |
| 737 | auto sharedMemHandle = | 737 | auto sharedMemHandle = |
| 738 | SharedMemory::Create(g_handle_table.Get<Process>(KernelHandle::CurrentProcess), size, | 738 | SharedMemory::Create(g_handle_table.Get<Process>(KernelHandle::CurrentProcess), size, |
| 739 | static_cast<MemoryPermission>(local_permissions), | 739 | static_cast<MemoryPermission>(local_permissions), |
| @@ -744,7 +744,7 @@ static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permiss | |||
| 744 | } | 744 | } |
| 745 | 745 | ||
| 746 | static ResultCode ClearEvent(Handle handle) { | 746 | static ResultCode ClearEvent(Handle handle) { |
| 747 | LOG_TRACE(Kernel_SVC, "called, event=0xX", handle); | 747 | NGLOG_TRACE(Kernel_SVC, "called, event={:010X}", handle); |
| 748 | 748 | ||
| 749 | SharedPtr<Event> evt = g_handle_table.Get<Event>(handle); | 749 | SharedPtr<Event> evt = g_handle_table.Get<Event>(handle); |
| 750 | if (evt == nullptr) | 750 | if (evt == nullptr) |
| @@ -896,7 +896,7 @@ static const FunctionDef SVC_Table[] = { | |||
| 896 | 896 | ||
| 897 | static const FunctionDef* GetSVCInfo(u32 func_num) { | 897 | static const FunctionDef* GetSVCInfo(u32 func_num) { |
| 898 | if (func_num >= std::size(SVC_Table)) { | 898 | if (func_num >= std::size(SVC_Table)) { |
| 899 | LOG_ERROR(Kernel_SVC, "unknown svc=0x%02X", func_num); | 899 | NGLOG_ERROR(Kernel_SVC, "Unknown svc={:#04X}", func_num); |
| 900 | return nullptr; | 900 | return nullptr; |
| 901 | } | 901 | } |
| 902 | return &SVC_Table[func_num]; | 902 | return &SVC_Table[func_num]; |
| @@ -915,10 +915,10 @@ void CallSVC(u32 immediate) { | |||
| 915 | if (info->func) { | 915 | if (info->func) { |
| 916 | info->func(); | 916 | info->func(); |
| 917 | } else { | 917 | } else { |
| 918 | LOG_CRITICAL(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); | 918 | NGLOG_CRITICAL(Kernel_SVC, "Unimplemented SVC function {}(..)", info->name); |
| 919 | } | 919 | } |
| 920 | } else { | 920 | } else { |
| 921 | LOG_CRITICAL(Kernel_SVC, "unknown SVC function 0x%x", immediate); | 921 | NGLOG_CRITICAL(Kernel_SVC, "Unknown SVC function {:#X}", immediate); |
| 922 | } | 922 | } |
| 923 | } | 923 | } |
| 924 | 924 | ||
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 36222d45f..4cd57ab25 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -101,9 +101,10 @@ void ExitCurrentThread() { | |||
| 101 | * @param cycles_late The number of CPU cycles that have passed since the desired wakeup time | 101 | * @param cycles_late The number of CPU cycles that have passed since the desired wakeup time |
| 102 | */ | 102 | */ |
| 103 | static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) { | 103 | static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) { |
| 104 | SharedPtr<Thread> thread = wakeup_callback_handle_table.Get<Thread>((Handle)thread_handle); | 104 | const auto proper_handle = static_cast<Handle>(thread_handle); |
| 105 | SharedPtr<Thread> thread = wakeup_callback_handle_table.Get<Thread>(proper_handle); | ||
| 105 | if (thread == nullptr) { | 106 | if (thread == nullptr) { |
| 106 | LOG_CRITICAL(Kernel, "Callback fired for invalid thread %08X", (Handle)thread_handle); | 107 | NGLOG_CRITICAL(Kernel, "Callback fired for invalid thread {:08X}", proper_handle); |
| 107 | return; | 108 | return; |
| 108 | } | 109 | } |
| 109 | 110 | ||
| @@ -238,19 +239,19 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 238 | SharedPtr<Process> owner_process) { | 239 | SharedPtr<Process> owner_process) { |
| 239 | // Check if priority is in ranged. Lowest priority -> highest priority id. | 240 | // Check if priority is in ranged. Lowest priority -> highest priority id. |
| 240 | if (priority > THREADPRIO_LOWEST) { | 241 | if (priority > THREADPRIO_LOWEST) { |
| 241 | LOG_ERROR(Kernel_SVC, "Invalid thread priority: %u", priority); | 242 | NGLOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority); |
| 242 | return ERR_OUT_OF_RANGE; | 243 | return ERR_OUT_OF_RANGE; |
| 243 | } | 244 | } |
| 244 | 245 | ||
| 245 | if (processor_id > THREADPROCESSORID_MAX) { | 246 | if (processor_id > THREADPROCESSORID_MAX) { |
| 246 | LOG_ERROR(Kernel_SVC, "Invalid processor id: %d", processor_id); | 247 | NGLOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id); |
| 247 | return ERR_OUT_OF_RANGE_KERNEL; | 248 | return ERR_OUT_OF_RANGE_KERNEL; |
| 248 | } | 249 | } |
| 249 | 250 | ||
| 250 | // TODO(yuriks): Other checks, returning 0xD9001BEA | 251 | // TODO(yuriks): Other checks, returning 0xD9001BEA |
| 251 | 252 | ||
| 252 | if (!Memory::IsValidVirtualAddress(*owner_process, entry_point)) { | 253 | if (!Memory::IsValidVirtualAddress(*owner_process, entry_point)) { |
| 253 | LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %016" PRIx64, name.c_str(), entry_point); | 254 | NGLOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:016X}", name, entry_point); |
| 254 | // TODO (bunnei): Find the correct error code to use here | 255 | // TODO (bunnei): Find the correct error code to use here |
| 255 | return ResultCode(-1); | 256 | return ResultCode(-1); |
| 256 | } | 257 | } |
| @@ -289,8 +290,8 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 289 | auto& linheap_memory = memory_region->linear_heap_memory; | 290 | auto& linheap_memory = memory_region->linear_heap_memory; |
| 290 | 291 | ||
| 291 | if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) { | 292 | if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) { |
| 292 | LOG_ERROR(Kernel_SVC, | 293 | NGLOG_ERROR(Kernel_SVC, |
| 293 | "Not enough space in region to allocate a new TLS page for thread"); | 294 | "Not enough space in region to allocate a new TLS page for thread"); |
| 294 | return ERR_OUT_OF_MEMORY; | 295 | return ERR_OUT_OF_MEMORY; |
| 295 | } | 296 | } |
| 296 | 297 | ||
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 8da745634..ad58bf043 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp | |||
| @@ -77,7 +77,7 @@ void Timer::WakeupAllWaitingThreads() { | |||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | void Timer::Signal(int cycles_late) { | 79 | void Timer::Signal(int cycles_late) { |
| 80 | LOG_TRACE(Kernel, "Timer %u fired", GetObjectId()); | 80 | NGLOG_TRACE(Kernel, "Timer {} fired", GetObjectId()); |
| 81 | 81 | ||
| 82 | signaled = true; | 82 | signaled = true; |
| 83 | 83 | ||
| @@ -97,7 +97,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) { | |||
| 97 | timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle)); | 97 | timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle)); |
| 98 | 98 | ||
| 99 | if (timer == nullptr) { | 99 | if (timer == nullptr) { |
| 100 | LOG_CRITICAL(Kernel, "Callback fired for invalid timer %08" PRIx64, timer_handle); | 100 | NGLOG_CRITICAL(Kernel, "Callback fired for invalid timer {:016X}", timer_handle); |
| 101 | return; | 101 | return; |
| 102 | } | 102 | } |
| 103 | 103 | ||
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index acd65ee68..eb2e35eed 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -379,22 +379,22 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { | |||
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | u64 VMManager::GetTotalMemoryUsage() { | 381 | u64 VMManager::GetTotalMemoryUsage() { |
| 382 | LOG_WARNING(Kernel, "(STUBBED) called"); | 382 | NGLOG_WARNING(Kernel, "(STUBBED) called"); |
| 383 | return 0xF8000000; | 383 | return 0xF8000000; |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | u64 VMManager::GetTotalHeapUsage() { | 386 | u64 VMManager::GetTotalHeapUsage() { |
| 387 | LOG_WARNING(Kernel, "(STUBBED) called"); | 387 | NGLOG_WARNING(Kernel, "(STUBBED) called"); |
| 388 | return 0x0; | 388 | return 0x0; |
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | VAddr VMManager::GetAddressSpaceBaseAddr() { | 391 | VAddr VMManager::GetAddressSpaceBaseAddr() { |
| 392 | LOG_WARNING(Kernel, "(STUBBED) called"); | 392 | NGLOG_WARNING(Kernel, "(STUBBED) called"); |
| 393 | return 0x8000000; | 393 | return 0x8000000; |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | u64 VMManager::GetAddressSpaceSize() { | 396 | u64 VMManager::GetAddressSpaceSize() { |
| 397 | LOG_WARNING(Kernel, "(STUBBED) called"); | 397 | NGLOG_WARNING(Kernel, "(STUBBED) called"); |
| 398 | return MAX_ADDRESS; | 398 | return MAX_ADDRESS; |
| 399 | } | 399 | } |
| 400 | 400 | ||
diff --git a/src/core/hle/service/pctl/pctl_a.cpp b/src/core/hle/service/pctl/module.cpp index 24a6cf310..dd20d5ae7 100644 --- a/src/core/hle/service/pctl/pctl_a.cpp +++ b/src/core/hle/service/pctl/module.cpp | |||
| @@ -4,7 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "core/hle/ipc_helpers.h" | 6 | #include "core/hle/ipc_helpers.h" |
| 7 | #include "core/hle/service/pctl/pctl_a.h" | 7 | #include "core/hle/service/pctl/module.h" |
| 8 | #include "core/hle/service/pctl/pctl.h" | ||
| 8 | 9 | ||
| 9 | namespace Service::PCTL { | 10 | namespace Service::PCTL { |
| 10 | 11 | ||
| @@ -12,7 +13,7 @@ class IParentalControlService final : public ServiceFramework<IParentalControlSe | |||
| 12 | public: | 13 | public: |
| 13 | IParentalControlService() : ServiceFramework("IParentalControlService") { | 14 | IParentalControlService() : ServiceFramework("IParentalControlService") { |
| 14 | static const FunctionInfo functions[] = { | 15 | static const FunctionInfo functions[] = { |
| 15 | {1, nullptr, "Initialize"}, | 16 | {1, &IParentalControlService::Initialize, "Initialize"}, |
| 16 | {1001, nullptr, "CheckFreeCommunicationPermission"}, | 17 | {1001, nullptr, "CheckFreeCommunicationPermission"}, |
| 17 | {1002, nullptr, "ConfirmLaunchApplicationPermission"}, | 18 | {1002, nullptr, "ConfirmLaunchApplicationPermission"}, |
| 18 | {1003, nullptr, "ConfirmResumeApplicationPermission"}, | 19 | {1003, nullptr, "ConfirmResumeApplicationPermission"}, |
| @@ -108,20 +109,38 @@ public: | |||
| 108 | }; | 109 | }; |
| 109 | RegisterHandlers(functions); | 110 | RegisterHandlers(functions); |
| 110 | } | 111 | } |
| 112 | |||
| 113 | private: | ||
| 114 | void Initialize(Kernel::HLERequestContext& ctx) { | ||
| 115 | NGLOG_WARNING(Service_PCTL, "(STUBBED) called"); | ||
| 116 | IPC::ResponseBuilder rb{ctx, 2, 0, 0}; | ||
| 117 | rb.Push(RESULT_SUCCESS); | ||
| 118 | } | ||
| 111 | }; | 119 | }; |
| 112 | void PCTL_A::CreateService(Kernel::HLERequestContext& ctx) { | 120 | |
| 121 | void Module::Interface::CreateService(Kernel::HLERequestContext& ctx) { | ||
| 122 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 123 | rb.Push(RESULT_SUCCESS); | ||
| 124 | rb.PushIpcInterface<IParentalControlService>(); | ||
| 125 | NGLOG_DEBUG(Service_PCTL, "called"); | ||
| 126 | } | ||
| 127 | |||
| 128 | void Module::Interface::CreateServiceWithoutInitialize(Kernel::HLERequestContext& ctx) { | ||
| 113 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 129 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 114 | rb.Push(RESULT_SUCCESS); | 130 | rb.Push(RESULT_SUCCESS); |
| 115 | rb.PushIpcInterface<IParentalControlService>(); | 131 | rb.PushIpcInterface<IParentalControlService>(); |
| 116 | NGLOG_DEBUG(Service_PCTL, "called"); | 132 | NGLOG_DEBUG(Service_PCTL, "called"); |
| 117 | } | 133 | } |
| 118 | 134 | ||
| 119 | PCTL_A::PCTL_A() : ServiceFramework("pctl:a") { | 135 | Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) |
| 120 | static const FunctionInfo functions[] = { | 136 | : ServiceFramework(name), module(std::move(module)) {} |
| 121 | {0, &PCTL_A::CreateService, "CreateService"}, | 137 | |
| 122 | {1, nullptr, "CreateServiceWithoutInitialize"}, | 138 | void InstallInterfaces(SM::ServiceManager& service_manager) { |
| 123 | }; | 139 | auto module = std::make_shared<Module>(); |
| 124 | RegisterHandlers(functions); | 140 | std::make_shared<PCTL>(module, "pctl")->InstallAsService(service_manager); |
| 141 | std::make_shared<PCTL>(module, "pctl:a")->InstallAsService(service_manager); | ||
| 142 | std::make_shared<PCTL>(module, "pctl:r")->InstallAsService(service_manager); | ||
| 143 | std::make_shared<PCTL>(module, "pctl:s")->InstallAsService(service_manager); | ||
| 125 | } | 144 | } |
| 126 | 145 | ||
| 127 | } // namespace Service::PCTL | 146 | } // namespace Service::PCTL |
diff --git a/src/core/hle/service/pctl/module.h b/src/core/hle/service/pctl/module.h new file mode 100644 index 000000000..68da628a8 --- /dev/null +++ b/src/core/hle/service/pctl/module.h | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Service::PCTL { | ||
| 10 | |||
| 11 | class Module final { | ||
| 12 | public: | ||
| 13 | class Interface : public ServiceFramework<Interface> { | ||
| 14 | public: | ||
| 15 | Interface(std::shared_ptr<Module> module, const char* name); | ||
| 16 | |||
| 17 | void CreateService(Kernel::HLERequestContext& ctx); | ||
| 18 | void CreateServiceWithoutInitialize(Kernel::HLERequestContext& ctx); | ||
| 19 | |||
| 20 | protected: | ||
| 21 | std::shared_ptr<Module> module; | ||
| 22 | }; | ||
| 23 | }; | ||
| 24 | |||
| 25 | /// Registers all PCTL services with the specified service manager. | ||
| 26 | void InstallInterfaces(SM::ServiceManager& service_manager); | ||
| 27 | |||
| 28 | } // namespace Service::PCTL | ||
diff --git a/src/core/hle/service/pctl/pctl.cpp b/src/core/hle/service/pctl/pctl.cpp index 6ee81866d..de2741d66 100644 --- a/src/core/hle/service/pctl/pctl.cpp +++ b/src/core/hle/service/pctl/pctl.cpp | |||
| @@ -3,12 +3,15 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/hle/service/pctl/pctl.h" | 5 | #include "core/hle/service/pctl/pctl.h" |
| 6 | #include "core/hle/service/pctl/pctl_a.h" | ||
| 7 | 6 | ||
| 8 | namespace Service::PCTL { | 7 | namespace Service::PCTL { |
| 9 | 8 | ||
| 10 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 9 | PCTL::PCTL(std::shared_ptr<Module> module, const char* name) |
| 11 | std::make_shared<PCTL_A>()->InstallAsService(service_manager); | 10 | : Module::Interface(std::move(module), name) { |
| 11 | static const FunctionInfo functions[] = { | ||
| 12 | {0, &PCTL::CreateService, "CreateService"}, | ||
| 13 | {1, &PCTL::CreateServiceWithoutInitialize, "CreateServiceWithoutInitialize"}, | ||
| 14 | }; | ||
| 15 | RegisterHandlers(functions); | ||
| 12 | } | 16 | } |
| 13 | |||
| 14 | } // namespace Service::PCTL | 17 | } // namespace Service::PCTL |
diff --git a/src/core/hle/service/pctl/pctl.h b/src/core/hle/service/pctl/pctl.h index f0a84b115..8ddf69128 100644 --- a/src/core/hle/service/pctl/pctl.h +++ b/src/core/hle/service/pctl/pctl.h | |||
| @@ -4,11 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/pctl/module.h" |
| 8 | 8 | ||
| 9 | namespace Service::PCTL { | 9 | namespace Service::PCTL { |
| 10 | 10 | ||
| 11 | /// Registers all PCTL services with the specified service manager. | 11 | class PCTL final : public Module::Interface { |
| 12 | void InstallInterfaces(SM::ServiceManager& service_manager); | 12 | public: |
| 13 | explicit PCTL(std::shared_ptr<Module> module, const char* name); | ||
| 14 | }; | ||
| 13 | 15 | ||
| 14 | } // namespace Service::PCTL | 16 | } // namespace Service::PCTL |
diff --git a/src/core/hle/service/pctl/pctl_a.h b/src/core/hle/service/pctl/pctl_a.h deleted file mode 100644 index 09ed82e1b..000000000 --- a/src/core/hle/service/pctl/pctl_a.h +++ /dev/null | |||
| @@ -1,20 +0,0 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Service::PCTL { | ||
| 10 | |||
| 11 | class PCTL_A final : public ServiceFramework<PCTL_A> { | ||
| 12 | public: | ||
| 13 | PCTL_A(); | ||
| 14 | ~PCTL_A() = default; | ||
| 15 | |||
| 16 | private: | ||
| 17 | void CreateService(Kernel::HLERequestContext& ctx); | ||
| 18 | }; | ||
| 19 | |||
| 20 | } // namespace Service::PCTL | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 5817819fe..a85c406be 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | #include "core/hle/service/nifm/nifm.h" | 29 | #include "core/hle/service/nifm/nifm.h" |
| 30 | #include "core/hle/service/ns/ns.h" | 30 | #include "core/hle/service/ns/ns.h" |
| 31 | #include "core/hle/service/nvdrv/nvdrv.h" | 31 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 32 | #include "core/hle/service/pctl/pctl.h" | 32 | #include "core/hle/service/pctl/module.h" |
| 33 | #include "core/hle/service/service.h" | 33 | #include "core/hle/service/service.h" |
| 34 | #include "core/hle/service/set/settings.h" | 34 | #include "core/hle/service/set/settings.h" |
| 35 | #include "core/hle/service/sm/controller.h" | 35 | #include "core/hle/service/sm/controller.h" |
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index ff0420c56..2afa0916d 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -39,8 +39,8 @@ PageTable* GetCurrentPageTable() { | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { | 41 | static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { |
| 42 | LOG_DEBUG(HW_Memory, "Mapping %p onto %016" PRIX64 "-%016" PRIX64, memory, base * PAGE_SIZE, | 42 | NGLOG_DEBUG(HW_Memory, "Mapping {} onto {:016X}-{:016X}", fmt::ptr(memory), base * PAGE_SIZE, |
| 43 | (base + size) * PAGE_SIZE); | 43 | (base + size) * PAGE_SIZE); |
| 44 | 44 | ||
| 45 | RasterizerFlushVirtualRegion(base << PAGE_BITS, size * PAGE_SIZE, | 45 | RasterizerFlushVirtualRegion(base << PAGE_BITS, size * PAGE_SIZE, |
| 46 | FlushMode::FlushAndInvalidate); | 46 | FlushMode::FlushAndInvalidate); |
| @@ -169,10 +169,10 @@ T Read(const VAddr vaddr) { | |||
| 169 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 169 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 170 | switch (type) { | 170 | switch (type) { |
| 171 | case PageType::Unmapped: | 171 | case PageType::Unmapped: |
| 172 | LOG_ERROR(HW_Memory, "unmapped Read%lu @ 0x%08X", sizeof(T) * 8, vaddr); | 172 | NGLOG_ERROR(HW_Memory, "Unmapped Read{} @ {:#010X}", sizeof(T) * 8, vaddr); |
| 173 | return 0; | 173 | return 0; |
| 174 | case PageType::Memory: | 174 | case PageType::Memory: |
| 175 | ASSERT_MSG(false, "Mapped memory page without a pointer @ %08X", vaddr); | 175 | ASSERT_MSG(false, "Mapped memory page without a pointer @ %016" PRIX64, vaddr); |
| 176 | break; | 176 | break; |
| 177 | case PageType::RasterizerCachedMemory: { | 177 | case PageType::RasterizerCachedMemory: { |
| 178 | RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Flush); | 178 | RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Flush); |
| @@ -201,11 +201,11 @@ void Write(const VAddr vaddr, const T data) { | |||
| 201 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 201 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 202 | switch (type) { | 202 | switch (type) { |
| 203 | case PageType::Unmapped: | 203 | case PageType::Unmapped: |
| 204 | LOG_ERROR(HW_Memory, "unmapped Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, | 204 | NGLOG_ERROR(HW_Memory, "Unmapped Write{} {:#010X} @ {:#018X}", sizeof(data) * 8, (u32)data, |
| 205 | vaddr); | 205 | vaddr); |
| 206 | return; | 206 | return; |
| 207 | case PageType::Memory: | 207 | case PageType::Memory: |
| 208 | ASSERT_MSG(false, "Mapped memory page without a pointer @ %08X", vaddr); | 208 | ASSERT_MSG(false, "Mapped memory page without a pointer @ %016" PRIX64, vaddr); |
| 209 | break; | 209 | break; |
| 210 | case PageType::RasterizerCachedMemory: { | 210 | case PageType::RasterizerCachedMemory: { |
| 211 | RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Invalidate); | 211 | RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Invalidate); |
| @@ -251,7 +251,7 @@ u8* GetPointer(const VAddr vaddr) { | |||
| 251 | return GetPointerFromVMA(vaddr); | 251 | return GetPointerFromVMA(vaddr); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | LOG_ERROR(HW_Memory, "unknown GetPointer @ 0x%08x", vaddr); | 254 | NGLOG_ERROR(HW_Memory, "Unknown GetPointer @ {:#018X}", vaddr); |
| 255 | return nullptr; | 255 | return nullptr; |
| 256 | } | 256 | } |
| 257 | 257 | ||
| @@ -288,13 +288,12 @@ u8* GetPhysicalPointer(PAddr address) { | |||
| 288 | }); | 288 | }); |
| 289 | 289 | ||
| 290 | if (area == std::end(memory_areas)) { | 290 | if (area == std::end(memory_areas)) { |
| 291 | LOG_ERROR(HW_Memory, "unknown GetPhysicalPointer @ 0x%016" PRIX64, address); | 291 | NGLOG_ERROR(HW_Memory, "Unknown GetPhysicalPointer @ {:#018X}", address); |
| 292 | return nullptr; | 292 | return nullptr; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | if (area->paddr_base == IO_AREA_PADDR) { | 295 | if (area->paddr_base == IO_AREA_PADDR) { |
| 296 | LOG_ERROR(HW_Memory, "MMIO mappings are not supported yet. phys_addr=0x%016" PRIX64, | 296 | NGLOG_ERROR(HW_Memory, "MMIO mappings are not supported yet. phys_addr={:018X}", address); |
| 297 | address); | ||
| 298 | return nullptr; | 297 | return nullptr; |
| 299 | } | 298 | } |
| 300 | 299 | ||
| @@ -341,9 +340,9 @@ void RasterizerMarkRegionCached(Tegra::GPUVAddr gpu_addr, u64 size, bool cached) | |||
| 341 | Core::System::GetInstance().GPU().memory_manager->GpuToCpuAddress(gpu_addr); | 340 | Core::System::GetInstance().GPU().memory_manager->GpuToCpuAddress(gpu_addr); |
| 342 | // The GPU <-> CPU virtual memory mapping is not 1:1 | 341 | // The GPU <-> CPU virtual memory mapping is not 1:1 |
| 343 | if (!maybe_vaddr) { | 342 | if (!maybe_vaddr) { |
| 344 | LOG_ERROR(HW_Memory, | 343 | NGLOG_ERROR(HW_Memory, |
| 345 | "Trying to flush a cached region to an invalid physical address %08X", | 344 | "Trying to flush a cached region to an invalid physical address {:016X}", |
| 346 | gpu_addr); | 345 | gpu_addr); |
| 347 | continue; | 346 | continue; |
| 348 | } | 347 | } |
| 349 | VAddr vaddr = *maybe_vaddr; | 348 | VAddr vaddr = *maybe_vaddr; |
| @@ -477,8 +476,9 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_ | |||
| 477 | 476 | ||
| 478 | switch (page_table.attributes[page_index]) { | 477 | switch (page_table.attributes[page_index]) { |
| 479 | case PageType::Unmapped: { | 478 | case PageType::Unmapped: { |
| 480 | LOG_ERROR(HW_Memory, "unmapped ReadBlock @ 0x%08X (start address = 0x%08X, size = %zu)", | 479 | NGLOG_ERROR(HW_Memory, |
| 481 | current_vaddr, src_addr, size); | 480 | "Unmapped ReadBlock @ {:#018X} (start address = {:#018X}, size = {})", |
| 481 | current_vaddr, src_addr, size); | ||
| 482 | std::memset(dest_buffer, 0, copy_amount); | 482 | std::memset(dest_buffer, 0, copy_amount); |
| 483 | break; | 483 | break; |
| 484 | } | 484 | } |
| @@ -540,9 +540,9 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi | |||
| 540 | 540 | ||
| 541 | switch (page_table.attributes[page_index]) { | 541 | switch (page_table.attributes[page_index]) { |
| 542 | case PageType::Unmapped: { | 542 | case PageType::Unmapped: { |
| 543 | LOG_ERROR(HW_Memory, | 543 | NGLOG_ERROR(HW_Memory, |
| 544 | "unmapped WriteBlock @ 0x%08X (start address = 0x%08X, size = %zu)", | 544 | "Unmapped WriteBlock @ {:#018X} (start address = {:#018X}, size = {})", |
| 545 | current_vaddr, dest_addr, size); | 545 | current_vaddr, dest_addr, size); |
| 546 | break; | 546 | break; |
| 547 | } | 547 | } |
| 548 | case PageType::Memory: { | 548 | case PageType::Memory: { |
| @@ -588,8 +588,9 @@ void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const size | |||
| 588 | 588 | ||
| 589 | switch (page_table.attributes[page_index]) { | 589 | switch (page_table.attributes[page_index]) { |
| 590 | case PageType::Unmapped: { | 590 | case PageType::Unmapped: { |
| 591 | LOG_ERROR(HW_Memory, "unmapped ZeroBlock @ 0x%08X (start address = 0x%08X, size = %zu)", | 591 | NGLOG_ERROR(HW_Memory, |
| 592 | current_vaddr, dest_addr, size); | 592 | "Unmapped ZeroBlock @ {:#018X} (start address = {#:018X}, size = {})", |
| 593 | current_vaddr, dest_addr, size); | ||
| 593 | break; | 594 | break; |
| 594 | } | 595 | } |
| 595 | case PageType::Memory: { | 596 | case PageType::Memory: { |
| @@ -628,8 +629,9 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, | |||
| 628 | 629 | ||
| 629 | switch (page_table.attributes[page_index]) { | 630 | switch (page_table.attributes[page_index]) { |
| 630 | case PageType::Unmapped: { | 631 | case PageType::Unmapped: { |
| 631 | LOG_ERROR(HW_Memory, "unmapped CopyBlock @ 0x%08X (start address = 0x%08X, size = %zu)", | 632 | NGLOG_ERROR(HW_Memory, |
| 632 | current_vaddr, src_addr, size); | 633 | "Unmapped CopyBlock @ {:#018X} (start address = {:#018X}, size = {})", |
| 634 | current_vaddr, src_addr, size); | ||
| 633 | ZeroBlock(process, dest_addr, copy_amount); | 635 | ZeroBlock(process, dest_addr, copy_amount); |
| 634 | break; | 636 | break; |
| 635 | } | 637 | } |
| @@ -657,6 +659,10 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, | |||
| 657 | } | 659 | } |
| 658 | } | 660 | } |
| 659 | 661 | ||
| 662 | void CopyBlock(VAddr dest_addr, VAddr src_addr, size_t size) { | ||
| 663 | CopyBlock(*Core::CurrentProcess(), dest_addr, src_addr, size); | ||
| 664 | } | ||
| 665 | |||
| 660 | boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) { | 666 | boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) { |
| 661 | if (addr == 0) { | 667 | if (addr == 0) { |
| 662 | return 0; | 668 | return 0; |
| @@ -678,7 +684,7 @@ boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) { | |||
| 678 | PAddr VirtualToPhysicalAddress(const VAddr addr) { | 684 | PAddr VirtualToPhysicalAddress(const VAddr addr) { |
| 679 | auto paddr = TryVirtualToPhysicalAddress(addr); | 685 | auto paddr = TryVirtualToPhysicalAddress(addr); |
| 680 | if (!paddr) { | 686 | if (!paddr) { |
| 681 | LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%016" PRIX64, addr); | 687 | NGLOG_ERROR(HW_Memory, "Unknown virtual address @ {:#018X}", addr); |
| 682 | // To help with debugging, set bit on address so that it's obviously invalid. | 688 | // To help with debugging, set bit on address so that it's obviously invalid. |
| 683 | return addr | 0x80000000; | 689 | return addr | 0x80000000; |
| 684 | } | 690 | } |
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 2c04daba3..2eaece298 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -24,41 +24,18 @@ namespace Tegra { | |||
| 24 | 24 | ||
| 25 | enum class BufferMethods { | 25 | enum class BufferMethods { |
| 26 | BindObject = 0, | 26 | BindObject = 0, |
| 27 | SetGraphMacroCode = 0x45, | 27 | CountBufferMethods = 0x40, |
| 28 | SetGraphMacroCodeArg = 0x46, | ||
| 29 | SetGraphMacroEntry = 0x47, | ||
| 30 | CountBufferMethods = 0x100, | ||
| 31 | }; | 28 | }; |
| 32 | 29 | ||
| 33 | void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) { | 30 | void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) { |
| 34 | LOG_WARNING(HW_GPU, "Processing method %08X on subchannel %u value %08X remaining params %u", | 31 | NGLOG_WARNING(HW_GPU, |
| 35 | method, subchannel, value, remaining_params); | 32 | "Processing method {:08X} on subchannel {} value " |
| 36 | 33 | "{:08X} remaining params {}", | |
| 37 | if (method == static_cast<u32>(BufferMethods::SetGraphMacroEntry)) { | 34 | method, subchannel, value, remaining_params); |
| 38 | // Prepare to upload a new macro, reset the upload counter. | ||
| 39 | LOG_DEBUG(HW_GPU, "Uploading GPU macro %08X", value); | ||
| 40 | current_macro_entry = value; | ||
| 41 | current_macro_code.clear(); | ||
| 42 | return; | ||
| 43 | } | ||
| 44 | |||
| 45 | if (method == static_cast<u32>(BufferMethods::SetGraphMacroCodeArg)) { | ||
| 46 | // Append a new code word to the current macro. | ||
| 47 | current_macro_code.push_back(value); | ||
| 48 | |||
| 49 | // There are no more params remaining, submit the code to the 3D engine. | ||
| 50 | if (remaining_params == 0) { | ||
| 51 | maxwell_3d->SubmitMacroCode(current_macro_entry, std::move(current_macro_code)); | ||
| 52 | current_macro_entry = InvalidGraphMacroEntry; | ||
| 53 | current_macro_code.clear(); | ||
| 54 | } | ||
| 55 | |||
| 56 | return; | ||
| 57 | } | ||
| 58 | 35 | ||
| 59 | if (method == static_cast<u32>(BufferMethods::BindObject)) { | 36 | if (method == static_cast<u32>(BufferMethods::BindObject)) { |
| 60 | // Bind the current subchannel to the desired engine id. | 37 | // Bind the current subchannel to the desired engine id. |
| 61 | LOG_DEBUG(HW_GPU, "Binding subchannel %u to engine %u", subchannel, value); | 38 | NGLOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", subchannel, value); |
| 62 | ASSERT(bound_engines.find(subchannel) == bound_engines.end()); | 39 | ASSERT(bound_engines.find(subchannel) == bound_engines.end()); |
| 63 | bound_engines[subchannel] = static_cast<EngineID>(value); | 40 | bound_engines[subchannel] = static_cast<EngineID>(value); |
| 64 | return; | 41 | return; |
| @@ -66,7 +43,7 @@ void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) | |||
| 66 | 43 | ||
| 67 | if (method < static_cast<u32>(BufferMethods::CountBufferMethods)) { | 44 | if (method < static_cast<u32>(BufferMethods::CountBufferMethods)) { |
| 68 | // TODO(Subv): Research and implement these methods. | 45 | // TODO(Subv): Research and implement these methods. |
| 69 | LOG_ERROR(HW_GPU, "Special buffer methods other than Bind are not implemented"); | 46 | NGLOG_ERROR(HW_GPU, "Special buffer methods other than Bind are not implemented"); |
| 70 | return; | 47 | return; |
| 71 | } | 48 | } |
| 72 | 49 | ||
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp index 7aab163dc..9019f2504 100644 --- a/src/video_core/engines/fermi_2d.cpp +++ b/src/video_core/engines/fermi_2d.cpp | |||
| @@ -2,12 +2,71 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/memory.h" | ||
| 5 | #include "video_core/engines/fermi_2d.h" | 6 | #include "video_core/engines/fermi_2d.h" |
| 7 | #include "video_core/textures/decoders.h" | ||
| 6 | 8 | ||
| 7 | namespace Tegra { | 9 | namespace Tegra { |
| 8 | namespace Engines { | 10 | namespace Engines { |
| 9 | 11 | ||
| 10 | void Fermi2D::WriteReg(u32 method, u32 value) {} | 12 | Fermi2D::Fermi2D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} |
| 13 | |||
| 14 | void Fermi2D::WriteReg(u32 method, u32 value) { | ||
| 15 | ASSERT_MSG(method < Regs::NUM_REGS, | ||
| 16 | "Invalid Fermi2D register, increase the size of the Regs structure"); | ||
| 17 | |||
| 18 | regs.reg_array[method] = value; | ||
| 19 | |||
| 20 | switch (method) { | ||
| 21 | case FERMI2D_REG_INDEX(trigger): { | ||
| 22 | HandleSurfaceCopy(); | ||
| 23 | break; | ||
| 24 | } | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | void Fermi2D::HandleSurfaceCopy() { | ||
| 29 | NGLOG_WARNING(HW_GPU, "Requested a surface copy with operation {}", | ||
| 30 | static_cast<u32>(regs.operation)); | ||
| 31 | |||
| 32 | const GPUVAddr source = regs.src.Address(); | ||
| 33 | const GPUVAddr dest = regs.dst.Address(); | ||
| 34 | |||
| 35 | // TODO(Subv): Only same-format and same-size copies are allowed for now. | ||
| 36 | ASSERT(regs.src.format == regs.dst.format); | ||
| 37 | ASSERT(regs.src.width * regs.src.height == regs.dst.width * regs.dst.height); | ||
| 38 | |||
| 39 | // TODO(Subv): Only raw copies are implemented. | ||
| 40 | ASSERT(regs.operation == Regs::Operation::SrcCopy); | ||
| 41 | |||
| 42 | const VAddr source_cpu = *memory_manager.GpuToCpuAddress(source); | ||
| 43 | const VAddr dest_cpu = *memory_manager.GpuToCpuAddress(dest); | ||
| 44 | |||
| 45 | u32 src_bytes_per_pixel = RenderTargetBytesPerPixel(regs.src.format); | ||
| 46 | u32 dst_bytes_per_pixel = RenderTargetBytesPerPixel(regs.dst.format); | ||
| 47 | |||
| 48 | if (regs.src.linear == regs.dst.linear) { | ||
| 49 | // If the input layout and the output layout are the same, just perform a raw copy. | ||
| 50 | Memory::CopyBlock(dest_cpu, source_cpu, | ||
| 51 | src_bytes_per_pixel * regs.dst.width * regs.dst.height); | ||
| 52 | return; | ||
| 53 | } | ||
| 54 | |||
| 55 | u8* src_buffer = Memory::GetPointer(source_cpu); | ||
| 56 | u8* dst_buffer = Memory::GetPointer(dest_cpu); | ||
| 57 | |||
| 58 | if (!regs.src.linear && regs.dst.linear) { | ||
| 59 | // If the input is tiled and the output is linear, deswizzle the input and copy it over. | ||
| 60 | Texture::CopySwizzledData(regs.src.width, regs.src.height, src_bytes_per_pixel, | ||
| 61 | dst_bytes_per_pixel, src_buffer, dst_buffer, true, | ||
| 62 | regs.src.block_height); | ||
| 63 | } else { | ||
| 64 | // If the input is linear and the output is tiled, swizzle the input and copy it over. | ||
| 65 | Texture::CopySwizzledData(regs.src.width, regs.src.height, src_bytes_per_pixel, | ||
| 66 | dst_bytes_per_pixel, dst_buffer, src_buffer, false, | ||
| 67 | regs.dst.block_height); | ||
| 68 | } | ||
| 69 | } | ||
| 11 | 70 | ||
| 12 | } // namespace Engines | 71 | } // namespace Engines |
| 13 | } // namespace Tegra | 72 | } // namespace Tegra |
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h index 8967ddede..0c5b413cc 100644 --- a/src/video_core/engines/fermi_2d.h +++ b/src/video_core/engines/fermi_2d.h | |||
| @@ -4,19 +4,106 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include "common/assert.h" | ||
| 9 | #include "common/bit_field.h" | ||
| 10 | #include "common/common_funcs.h" | ||
| 7 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "video_core/gpu.h" | ||
| 13 | #include "video_core/memory_manager.h" | ||
| 8 | 14 | ||
| 9 | namespace Tegra { | 15 | namespace Tegra { |
| 10 | namespace Engines { | 16 | namespace Engines { |
| 11 | 17 | ||
| 18 | #define FERMI2D_REG_INDEX(field_name) \ | ||
| 19 | (offsetof(Tegra::Engines::Fermi2D::Regs, field_name) / sizeof(u32)) | ||
| 20 | |||
| 12 | class Fermi2D final { | 21 | class Fermi2D final { |
| 13 | public: | 22 | public: |
| 14 | Fermi2D() = default; | 23 | explicit Fermi2D(MemoryManager& memory_manager); |
| 15 | ~Fermi2D() = default; | 24 | ~Fermi2D() = default; |
| 16 | 25 | ||
| 17 | /// Write the value to the register identified by method. | 26 | /// Write the value to the register identified by method. |
| 18 | void WriteReg(u32 method, u32 value); | 27 | void WriteReg(u32 method, u32 value); |
| 28 | |||
| 29 | struct Regs { | ||
| 30 | static constexpr size_t NUM_REGS = 0x258; | ||
| 31 | |||
| 32 | struct Surface { | ||
| 33 | RenderTargetFormat format; | ||
| 34 | BitField<0, 1, u32> linear; | ||
| 35 | union { | ||
| 36 | BitField<0, 4, u32> block_depth; | ||
| 37 | BitField<4, 4, u32> block_height; | ||
| 38 | BitField<8, 4, u32> block_width; | ||
| 39 | }; | ||
| 40 | u32 depth; | ||
| 41 | u32 layer; | ||
| 42 | u32 pitch; | ||
| 43 | u32 width; | ||
| 44 | u32 height; | ||
| 45 | u32 address_high; | ||
| 46 | u32 address_low; | ||
| 47 | |||
| 48 | GPUVAddr Address() const { | ||
| 49 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) | | ||
| 50 | address_low); | ||
| 51 | } | ||
| 52 | }; | ||
| 53 | static_assert(sizeof(Surface) == 0x28, "Surface has incorrect size"); | ||
| 54 | |||
| 55 | enum class Operation : u32 { | ||
| 56 | SrcCopyAnd = 0, | ||
| 57 | ROPAnd = 1, | ||
| 58 | Blend = 2, | ||
| 59 | SrcCopy = 3, | ||
| 60 | ROP = 4, | ||
| 61 | SrcCopyPremult = 5, | ||
| 62 | BlendPremult = 6, | ||
| 63 | }; | ||
| 64 | |||
| 65 | union { | ||
| 66 | struct { | ||
| 67 | INSERT_PADDING_WORDS(0x80); | ||
| 68 | |||
| 69 | Surface dst; | ||
| 70 | |||
| 71 | INSERT_PADDING_WORDS(2); | ||
| 72 | |||
| 73 | Surface src; | ||
| 74 | |||
| 75 | INSERT_PADDING_WORDS(0x15); | ||
| 76 | |||
| 77 | Operation operation; | ||
| 78 | |||
| 79 | INSERT_PADDING_WORDS(0x9); | ||
| 80 | |||
| 81 | // TODO(Subv): This is only a guess. | ||
| 82 | u32 trigger; | ||
| 83 | |||
| 84 | INSERT_PADDING_WORDS(0x1A3); | ||
| 85 | }; | ||
| 86 | std::array<u32, NUM_REGS> reg_array; | ||
| 87 | }; | ||
| 88 | } regs{}; | ||
| 89 | |||
| 90 | MemoryManager& memory_manager; | ||
| 91 | |||
| 92 | private: | ||
| 93 | /// Performs the copy from the source surface to the destination surface as configured in the | ||
| 94 | /// registers. | ||
| 95 | void HandleSurfaceCopy(); | ||
| 19 | }; | 96 | }; |
| 20 | 97 | ||
| 98 | #define ASSERT_REG_POSITION(field_name, position) \ | ||
| 99 | static_assert(offsetof(Fermi2D::Regs, field_name) == position * 4, \ | ||
| 100 | "Field " #field_name " has invalid position") | ||
| 101 | |||
| 102 | ASSERT_REG_POSITION(dst, 0x80); | ||
| 103 | ASSERT_REG_POSITION(src, 0x8C); | ||
| 104 | ASSERT_REG_POSITION(operation, 0xAB); | ||
| 105 | ASSERT_REG_POSITION(trigger, 0xB5); | ||
| 106 | #undef ASSERT_REG_POSITION | ||
| 107 | |||
| 21 | } // namespace Engines | 108 | } // namespace Engines |
| 22 | } // namespace Tegra | 109 | } // namespace Tegra |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 4e9aed380..4306b894f 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -22,10 +22,6 @@ constexpr u32 MacroRegistersStart = 0xE00; | |||
| 22 | Maxwell3D::Maxwell3D(MemoryManager& memory_manager) | 22 | Maxwell3D::Maxwell3D(MemoryManager& memory_manager) |
| 23 | : memory_manager(memory_manager), macro_interpreter(*this) {} | 23 | : memory_manager(memory_manager), macro_interpreter(*this) {} |
| 24 | 24 | ||
| 25 | void Maxwell3D::SubmitMacroCode(u32 entry, std::vector<u32> code) { | ||
| 26 | uploaded_macros[entry * 2 + MacroRegistersStart] = std::move(code); | ||
| 27 | } | ||
| 28 | |||
| 29 | void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) { | 25 | void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) { |
| 30 | auto macro_code = uploaded_macros.find(method); | 26 | auto macro_code = uploaded_macros.find(method); |
| 31 | // The requested macro must have been uploaded already. | 27 | // The requested macro must have been uploaded already. |
| @@ -37,9 +33,6 @@ void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) { | |||
| 37 | } | 33 | } |
| 38 | 34 | ||
| 39 | void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { | 35 | void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { |
| 40 | ASSERT_MSG(method < Regs::NUM_REGS, | ||
| 41 | "Invalid Maxwell3D register, increase the size of the Regs structure"); | ||
| 42 | |||
| 43 | auto debug_context = Core::System::GetInstance().GetGPUDebugContext(); | 36 | auto debug_context = Core::System::GetInstance().GetGPUDebugContext(); |
| 44 | 37 | ||
| 45 | // It is an error to write to a register other than the current macro's ARG register before it | 38 | // It is an error to write to a register other than the current macro's ARG register before it |
| @@ -68,6 +61,9 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { | |||
| 68 | return; | 61 | return; |
| 69 | } | 62 | } |
| 70 | 63 | ||
| 64 | ASSERT_MSG(method < Regs::NUM_REGS, | ||
| 65 | "Invalid Maxwell3D register, increase the size of the Regs structure"); | ||
| 66 | |||
| 71 | if (debug_context) { | 67 | if (debug_context) { |
| 72 | debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); | 68 | debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); |
| 73 | } | 69 | } |
| @@ -75,6 +71,10 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { | |||
| 75 | regs.reg_array[method] = value; | 71 | regs.reg_array[method] = value; |
| 76 | 72 | ||
| 77 | switch (method) { | 73 | switch (method) { |
| 74 | case MAXWELL3D_REG_INDEX(macros.data): { | ||
| 75 | ProcessMacroUpload(value); | ||
| 76 | break; | ||
| 77 | } | ||
| 78 | case MAXWELL3D_REG_INDEX(code_address.code_address_high): | 78 | case MAXWELL3D_REG_INDEX(code_address.code_address_high): |
| 79 | case MAXWELL3D_REG_INDEX(code_address.code_address_low): { | 79 | case MAXWELL3D_REG_INDEX(code_address.code_address_low): { |
| 80 | // Note: For some reason games (like Puyo Puyo Tetris) seem to write 0 to the CODE_ADDRESS | 80 | // Note: For some reason games (like Puyo Puyo Tetris) seem to write 0 to the CODE_ADDRESS |
| @@ -141,6 +141,12 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { | |||
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | void Maxwell3D::ProcessMacroUpload(u32 data) { | ||
| 145 | // Store the uploaded macro code to interpret them when they're called. | ||
| 146 | auto& macro = uploaded_macros[regs.macros.entry * 2 + MacroRegistersStart]; | ||
| 147 | macro.push_back(data); | ||
| 148 | } | ||
| 149 | |||
| 144 | void Maxwell3D::ProcessQueryGet() { | 150 | void Maxwell3D::ProcessQueryGet() { |
| 145 | GPUVAddr sequence_address = regs.query.QueryAddress(); | 151 | GPUVAddr sequence_address = regs.query.QueryAddress(); |
| 146 | // Since the sequence address is given as a GPU VAddr, we have to convert it to an application | 152 | // Since the sequence address is given as a GPU VAddr, we have to convert it to an application |
| @@ -186,8 +192,8 @@ void Maxwell3D::ProcessQueryGet() { | |||
| 186 | } | 192 | } |
| 187 | 193 | ||
| 188 | void Maxwell3D::DrawArrays() { | 194 | void Maxwell3D::DrawArrays() { |
| 189 | LOG_DEBUG(HW_GPU, "called, topology=%d, count=%d", regs.draw.topology.Value(), | 195 | NGLOG_DEBUG(HW_GPU, "called, topology={}, count={}", |
| 190 | regs.vertex_buffer.count); | 196 | static_cast<u32>(regs.draw.topology.Value()), regs.vertex_buffer.count); |
| 191 | ASSERT_MSG(!(regs.index_array.count && regs.vertex_buffer.count), "Both indexed and direct?"); | 197 | ASSERT_MSG(!(regs.index_array.count && regs.vertex_buffer.count), "Both indexed and direct?"); |
| 192 | 198 | ||
| 193 | auto debug_context = Core::System::GetInstance().GetGPUDebugContext(); | 199 | auto debug_context = Core::System::GetInstance().GetGPUDebugContext(); |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index a022665eb..5cf62fb01 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -31,7 +31,7 @@ public: | |||
| 31 | /// Register structure of the Maxwell3D engine. | 31 | /// Register structure of the Maxwell3D engine. |
| 32 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. | 32 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. |
| 33 | struct Regs { | 33 | struct Regs { |
| 34 | static constexpr size_t NUM_REGS = 0xE36; | 34 | static constexpr size_t NUM_REGS = 0xE00; |
| 35 | 35 | ||
| 36 | static constexpr size_t NumRenderTargets = 8; | 36 | static constexpr size_t NumRenderTargets = 8; |
| 37 | static constexpr size_t NumViewports = 16; | 37 | static constexpr size_t NumViewports = 16; |
| @@ -322,7 +322,15 @@ public: | |||
| 322 | 322 | ||
| 323 | union { | 323 | union { |
| 324 | struct { | 324 | struct { |
| 325 | INSERT_PADDING_WORDS(0x200); | 325 | INSERT_PADDING_WORDS(0x45); |
| 326 | |||
| 327 | struct { | ||
| 328 | INSERT_PADDING_WORDS(1); | ||
| 329 | u32 data; | ||
| 330 | u32 entry; | ||
| 331 | } macros; | ||
| 332 | |||
| 333 | INSERT_PADDING_WORDS(0x1B8); | ||
| 326 | 334 | ||
| 327 | struct { | 335 | struct { |
| 328 | u32 address_high; | 336 | u32 address_high; |
| @@ -605,7 +613,7 @@ public: | |||
| 605 | u32 size[MaxShaderStage]; | 613 | u32 size[MaxShaderStage]; |
| 606 | } tex_info_buffers; | 614 | } tex_info_buffers; |
| 607 | 615 | ||
| 608 | INSERT_PADDING_WORDS(0x102); | 616 | INSERT_PADDING_WORDS(0xCC); |
| 609 | }; | 617 | }; |
| 610 | std::array<u32, NUM_REGS> reg_array; | 618 | std::array<u32, NUM_REGS> reg_array; |
| 611 | }; | 619 | }; |
| @@ -637,9 +645,6 @@ public: | |||
| 637 | /// Write the value to the register identified by method. | 645 | /// Write the value to the register identified by method. |
| 638 | void WriteReg(u32 method, u32 value, u32 remaining_params); | 646 | void WriteReg(u32 method, u32 value, u32 remaining_params); |
| 639 | 647 | ||
| 640 | /// Uploads the code for a GPU macro program associated with the specified entry. | ||
| 641 | void SubmitMacroCode(u32 entry, std::vector<u32> code); | ||
| 642 | |||
| 643 | /// Returns a list of enabled textures for the specified shader stage. | 648 | /// Returns a list of enabled textures for the specified shader stage. |
| 644 | std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const; | 649 | std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const; |
| 645 | 650 | ||
| @@ -670,6 +675,9 @@ private: | |||
| 670 | */ | 675 | */ |
| 671 | void CallMacroMethod(u32 method, std::vector<u32> parameters); | 676 | void CallMacroMethod(u32 method, std::vector<u32> parameters); |
| 672 | 677 | ||
| 678 | /// Handles writes to the macro uploading registers. | ||
| 679 | void ProcessMacroUpload(u32 data); | ||
| 680 | |||
| 673 | /// Handles a write to the QUERY_GET register. | 681 | /// Handles a write to the QUERY_GET register. |
| 674 | void ProcessQueryGet(); | 682 | void ProcessQueryGet(); |
| 675 | 683 | ||
| @@ -687,6 +695,7 @@ private: | |||
| 687 | static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \ | 695 | static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \ |
| 688 | "Field " #field_name " has invalid position") | 696 | "Field " #field_name " has invalid position") |
| 689 | 697 | ||
| 698 | ASSERT_REG_POSITION(macros, 0x45); | ||
| 690 | ASSERT_REG_POSITION(rt, 0x200); | 699 | ASSERT_REG_POSITION(rt, 0x200); |
| 691 | ASSERT_REG_POSITION(viewport_transform[0], 0x280); | 700 | ASSERT_REG_POSITION(viewport_transform[0], 0x280); |
| 692 | ASSERT_REG_POSITION(viewport, 0x300); | 701 | ASSERT_REG_POSITION(viewport, 0x300); |
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 9463cd5d6..9eb143918 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -12,7 +12,7 @@ namespace Tegra { | |||
| 12 | GPU::GPU() { | 12 | GPU::GPU() { |
| 13 | memory_manager = std::make_unique<MemoryManager>(); | 13 | memory_manager = std::make_unique<MemoryManager>(); |
| 14 | maxwell_3d = std::make_unique<Engines::Maxwell3D>(*memory_manager); | 14 | maxwell_3d = std::make_unique<Engines::Maxwell3D>(*memory_manager); |
| 15 | fermi_2d = std::make_unique<Engines::Fermi2D>(); | 15 | fermi_2d = std::make_unique<Engines::Fermi2D>(*memory_manager); |
| 16 | maxwell_compute = std::make_unique<Engines::MaxwellCompute>(); | 16 | maxwell_compute = std::make_unique<Engines::MaxwellCompute>(); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| @@ -22,4 +22,16 @@ const Tegra::Engines::Maxwell3D& GPU::Get3DEngine() const { | |||
| 22 | return *maxwell_3d; | 22 | return *maxwell_3d; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { | ||
| 26 | ASSERT(format != RenderTargetFormat::NONE); | ||
| 27 | |||
| 28 | switch (format) { | ||
| 29 | case RenderTargetFormat::RGBA8_UNORM: | ||
| 30 | case RenderTargetFormat::RGB10_A2_UNORM: | ||
| 31 | return 4; | ||
| 32 | default: | ||
| 33 | UNIMPLEMENTED_MSG("Unimplemented render target format %u", static_cast<u32>(format)); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 25 | } // namespace Tegra | 37 | } // namespace Tegra |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 2888daedc..f168a5171 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -21,6 +21,9 @@ enum class RenderTargetFormat : u32 { | |||
| 21 | RGBA8_SRGB = 0xD6, | 21 | RGBA8_SRGB = 0xD6, |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | /// Returns the number of bytes per pixel of each rendertarget format. | ||
| 25 | u32 RenderTargetBytesPerPixel(RenderTargetFormat format); | ||
| 26 | |||
| 24 | class DebugContext; | 27 | class DebugContext; |
| 25 | 28 | ||
| 26 | /** | 29 | /** |
| @@ -86,8 +89,6 @@ public: | |||
| 86 | } | 89 | } |
| 87 | 90 | ||
| 88 | private: | 91 | private: |
| 89 | static constexpr u32 InvalidGraphMacroEntry = 0xFFFFFFFF; | ||
| 90 | |||
| 91 | /// Writes a single register in the engine bound to the specified subchannel | 92 | /// Writes a single register in the engine bound to the specified subchannel |
| 92 | void WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params); | 93 | void WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params); |
| 93 | 94 | ||
| @@ -100,11 +101,6 @@ private: | |||
| 100 | std::unique_ptr<Engines::Fermi2D> fermi_2d; | 101 | std::unique_ptr<Engines::Fermi2D> fermi_2d; |
| 101 | /// Compute engine | 102 | /// Compute engine |
| 102 | std::unique_ptr<Engines::MaxwellCompute> maxwell_compute; | 103 | std::unique_ptr<Engines::MaxwellCompute> maxwell_compute; |
| 103 | |||
| 104 | /// Entry of the macro that is currently being uploaded | ||
| 105 | u32 current_macro_entry = InvalidGraphMacroEntry; | ||
| 106 | /// Code being uploaded for the current macro | ||
| 107 | std::vector<u32> current_macro_code; | ||
| 108 | }; | 104 | }; |
| 109 | 105 | ||
| 110 | } // namespace Tegra | 106 | } // namespace Tegra |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index b457b1fbe..9b3542e10 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -116,7 +116,7 @@ RasterizerOpenGL::RasterizerOpenGL() { | |||
| 116 | 116 | ||
| 117 | glEnable(GL_BLEND); | 117 | glEnable(GL_BLEND); |
| 118 | 118 | ||
| 119 | LOG_CRITICAL(Render_OpenGL, "Sync fixed function OpenGL state here!"); | 119 | NGLOG_CRITICAL(Render_OpenGL, "Sync fixed function OpenGL state here!"); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | RasterizerOpenGL::~RasterizerOpenGL() { | 122 | RasterizerOpenGL::~RasterizerOpenGL() { |
| @@ -252,8 +252,8 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset) { | |||
| 252 | break; | 252 | break; |
| 253 | } | 253 | } |
| 254 | default: | 254 | default: |
| 255 | LOG_CRITICAL(HW_GPU, "Unimplemented shader index=%d, enable=%d, offset=0x%08X", index, | 255 | NGLOG_CRITICAL(HW_GPU, "Unimplemented shader index={}, enable={}, offset={:#010X}", |
| 256 | shader_config.enable.Value(), shader_config.offset); | 256 | index, shader_config.enable.Value(), shader_config.offset); |
| 257 | UNREACHABLE(); | 257 | UNREACHABLE(); |
| 258 | } | 258 | } |
| 259 | 259 | ||
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 5ca9821b7..77d1692f4 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -302,8 +302,8 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x, | |||
| 302 | right = texcoords.left; | 302 | right = texcoords.left; |
| 303 | } else { | 303 | } else { |
| 304 | // Other transformations are unsupported | 304 | // Other transformations are unsupported |
| 305 | LOG_CRITICAL(Render_OpenGL, "Unsupported framebuffer_transform_flags=%d", | 305 | NGLOG_CRITICAL(Render_OpenGL, "Unsupported framebuffer_transform_flags={}", |
| 306 | framebuffer_transform_flags); | 306 | static_cast<u32>(framebuffer_transform_flags)); |
| 307 | UNIMPLEMENTED(); | 307 | UNIMPLEMENTED(); |
| 308 | } | 308 | } |
| 309 | } | 309 | } |
| @@ -428,9 +428,9 @@ bool RendererOpenGL::Init() { | |||
| 428 | const char* gpu_vendor{reinterpret_cast<char const*>(glGetString(GL_VENDOR))}; | 428 | const char* gpu_vendor{reinterpret_cast<char const*>(glGetString(GL_VENDOR))}; |
| 429 | const char* gpu_model{reinterpret_cast<char const*>(glGetString(GL_RENDERER))}; | 429 | const char* gpu_model{reinterpret_cast<char const*>(glGetString(GL_RENDERER))}; |
| 430 | 430 | ||
| 431 | LOG_INFO(Render_OpenGL, "GL_VERSION: %s", gl_version); | 431 | NGLOG_INFO(Render_OpenGL, "GL_VERSION: {}", gl_version); |
| 432 | LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", gpu_vendor); | 432 | NGLOG_INFO(Render_OpenGL, "GL_VENDOR: {}", gpu_vendor); |
| 433 | LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", gpu_model); | 433 | NGLOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model); |
| 434 | 434 | ||
| 435 | Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", gpu_vendor); | 435 | Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", gpu_vendor); |
| 436 | Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Model", gpu_model); | 436 | Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Model", gpu_model); |
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 9c3ae875c..8b39b2bdf 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -27,9 +27,8 @@ static u32 GetSwizzleOffset(u32 x, u32 y, u32 image_width, u32 bytes_per_pixel, | |||
| 27 | return address; | 27 | return address; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, | 30 | void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, |
| 31 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, | 31 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height) { |
| 32 | u32 block_height) { | ||
| 33 | u8* data_ptrs[2]; | 32 | u8* data_ptrs[2]; |
| 34 | for (unsigned y = 0; y < height; ++y) { | 33 | for (unsigned y = 0; y < height; ++y) { |
| 35 | for (unsigned x = 0; x < width; ++x) { | 34 | for (unsigned x = 0; x < width; ++x) { |
diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index a700911cf..2562c4b06 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h | |||
| @@ -17,6 +17,10 @@ namespace Texture { | |||
| 17 | std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, | 17 | std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, |
| 18 | u32 block_height = TICEntry::DefaultBlockHeight); | 18 | u32 block_height = TICEntry::DefaultBlockHeight); |
| 19 | 19 | ||
| 20 | /// Copies texture data from a buffer and performs swizzling/unswizzling as necessary. | ||
| 21 | void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, | ||
| 22 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height); | ||
| 23 | |||
| 20 | /** | 24 | /** |
| 21 | * Decodes an unswizzled texture into a A8R8G8B8 texture. | 25 | * Decodes an unswizzled texture into a A8R8G8B8 texture. |
| 22 | */ | 26 | */ |
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 289140f31..89dc8ed1e 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp | |||
| @@ -24,9 +24,9 @@ bool Init(EmuWindow* emu_window) { | |||
| 24 | g_renderer = std::make_unique<RendererOpenGL>(); | 24 | g_renderer = std::make_unique<RendererOpenGL>(); |
| 25 | g_renderer->SetWindow(g_emu_window); | 25 | g_renderer->SetWindow(g_emu_window); |
| 26 | if (g_renderer->Init()) { | 26 | if (g_renderer->Init()) { |
| 27 | LOG_DEBUG(Render, "initialized OK"); | 27 | NGLOG_DEBUG(Render, "initialized OK"); |
| 28 | } else { | 28 | } else { |
| 29 | LOG_CRITICAL(Render, "initialization failed !"); | 29 | NGLOG_CRITICAL(Render, "initialization failed !"); |
| 30 | return false; | 30 | return false; |
| 31 | } | 31 | } |
| 32 | return true; | 32 | return true; |
| @@ -36,7 +36,7 @@ bool Init(EmuWindow* emu_window) { | |||
| 36 | void Shutdown() { | 36 | void Shutdown() { |
| 37 | g_renderer.reset(); | 37 | g_renderer.reset(); |
| 38 | 38 | ||
| 39 | LOG_DEBUG(Render, "shutdown OK"); | 39 | NGLOG_DEBUG(Render, "shutdown OK"); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | } // namespace VideoCore | 42 | } // namespace VideoCore |