diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/file_util.h | 12 | ||||
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/romfs.cpp | 102 | ||||
| -rw-r--r-- | src/core/hle/romfs.h | 22 | ||||
| -rw-r--r-- | src/core/hle/service/acc/acc.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/acc/acc.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/acc/acc_su.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/acc/acc_u0.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/acc/acc_u1.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 2 |
10 files changed, 20 insertions, 134 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h index 28697d527..430dac41c 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <cstdio> | 8 | #include <cstdio> |
| 9 | #include <fstream> | 9 | #include <fstream> |
| 10 | #include <functional> | 10 | #include <functional> |
| 11 | #include <limits> | ||
| 11 | #include <string> | 12 | #include <string> |
| 12 | #include <string_view> | 13 | #include <string_view> |
| 13 | #include <type_traits> | 14 | #include <type_traits> |
| @@ -210,8 +211,9 @@ public: | |||
| 210 | static_assert(std::is_trivially_copyable<T>(), | 211 | static_assert(std::is_trivially_copyable<T>(), |
| 211 | "Given array does not consist of trivially copyable objects"); | 212 | "Given array does not consist of trivially copyable objects"); |
| 212 | 213 | ||
| 213 | if (!IsOpen()) | 214 | if (!IsOpen()) { |
| 214 | return -1; | 215 | return std::numeric_limits<size_t>::max(); |
| 216 | } | ||
| 215 | 217 | ||
| 216 | return std::fread(data, sizeof(T), length, m_file); | 218 | return std::fread(data, sizeof(T), length, m_file); |
| 217 | } | 219 | } |
| @@ -220,8 +222,10 @@ public: | |||
| 220 | size_t WriteArray(const T* data, size_t length) { | 222 | size_t WriteArray(const T* data, size_t length) { |
| 221 | static_assert(std::is_trivially_copyable<T>(), | 223 | static_assert(std::is_trivially_copyable<T>(), |
| 222 | "Given array does not consist of trivially copyable objects"); | 224 | "Given array does not consist of trivially copyable objects"); |
| 223 | if (!IsOpen()) | 225 | if (!IsOpen()) { |
| 224 | return -1; | 226 | return std::numeric_limits<size_t>::max(); |
| 227 | } | ||
| 228 | |||
| 225 | return std::fwrite(data, sizeof(T), length, m_file); | 229 | return std::fwrite(data, sizeof(T), length, m_file); |
| 226 | } | 230 | } |
| 227 | 231 | ||
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0abf7edc1..cceb1564b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -104,8 +104,6 @@ add_library(core STATIC | |||
| 104 | hle/lock.cpp | 104 | hle/lock.cpp |
| 105 | hle/lock.h | 105 | hle/lock.h |
| 106 | hle/result.h | 106 | hle/result.h |
| 107 | hle/romfs.cpp | ||
| 108 | hle/romfs.h | ||
| 109 | hle/service/acc/acc.cpp | 107 | hle/service/acc/acc.cpp |
| 110 | hle/service/acc/acc.h | 108 | hle/service/acc/acc.h |
| 111 | hle/service/acc/acc_aa.cpp | 109 | hle/service/acc/acc_aa.cpp |
diff --git a/src/core/hle/romfs.cpp b/src/core/hle/romfs.cpp deleted file mode 100644 index 3157df71d..000000000 --- a/src/core/hle/romfs.cpp +++ /dev/null | |||
| @@ -1,102 +0,0 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstring> | ||
| 6 | #include "common/swap.h" | ||
| 7 | #include "core/hle/romfs.h" | ||
| 8 | |||
| 9 | namespace RomFS { | ||
| 10 | |||
| 11 | struct Header { | ||
| 12 | u32_le header_length; | ||
| 13 | u32_le dir_hash_table_offset; | ||
| 14 | u32_le dir_hash_table_length; | ||
| 15 | u32_le dir_table_offset; | ||
| 16 | u32_le dir_table_length; | ||
| 17 | u32_le file_hash_table_offset; | ||
| 18 | u32_le file_hash_table_length; | ||
| 19 | u32_le file_table_offset; | ||
| 20 | u32_le file_table_length; | ||
| 21 | u32_le data_offset; | ||
| 22 | }; | ||
| 23 | |||
| 24 | static_assert(sizeof(Header) == 0x28, "Header has incorrect size"); | ||
| 25 | |||
| 26 | struct DirectoryMetadata { | ||
| 27 | u32_le parent_dir_offset; | ||
| 28 | u32_le next_dir_offset; | ||
| 29 | u32_le first_child_dir_offset; | ||
| 30 | u32_le first_file_offset; | ||
| 31 | u32_le same_hash_next_dir_offset; | ||
| 32 | u32_le name_length; // in bytes | ||
| 33 | // followed by directory name | ||
| 34 | }; | ||
| 35 | |||
| 36 | static_assert(sizeof(DirectoryMetadata) == 0x18, "DirectoryMetadata has incorrect size"); | ||
| 37 | |||
| 38 | struct FileMetadata { | ||
| 39 | u32_le parent_dir_offset; | ||
| 40 | u32_le next_file_offset; | ||
| 41 | u64_le data_offset; | ||
| 42 | u64_le data_length; | ||
| 43 | u32_le same_hash_next_file_offset; | ||
| 44 | u32_le name_length; // in bytes | ||
| 45 | // followed by file name | ||
| 46 | }; | ||
| 47 | |||
| 48 | static_assert(sizeof(FileMetadata) == 0x20, "FileMetadata has incorrect size"); | ||
| 49 | |||
| 50 | static bool MatchName(const u8* buffer, u32 name_length, const std::u16string& name) { | ||
| 51 | std::vector<char16_t> name_buffer(name_length / sizeof(char16_t)); | ||
| 52 | std::memcpy(name_buffer.data(), buffer, name_length); | ||
| 53 | return name == std::u16string(name_buffer.begin(), name_buffer.end()); | ||
| 54 | } | ||
| 55 | |||
| 56 | const u8* GetFilePointer(const u8* romfs, const std::vector<std::u16string>& path) { | ||
| 57 | constexpr u32 INVALID_FIELD = 0xFFFFFFFF; | ||
| 58 | |||
| 59 | // Split path into directory names and file name | ||
| 60 | std::vector<std::u16string> dir_names = path; | ||
| 61 | dir_names.pop_back(); | ||
| 62 | const std::u16string& file_name = path.back(); | ||
| 63 | |||
| 64 | Header header; | ||
| 65 | std::memcpy(&header, romfs, sizeof(header)); | ||
| 66 | |||
| 67 | // Find directories of each level | ||
| 68 | DirectoryMetadata dir; | ||
| 69 | const u8* current_dir = romfs + header.dir_table_offset; | ||
| 70 | std::memcpy(&dir, current_dir, sizeof(dir)); | ||
| 71 | for (const std::u16string& dir_name : dir_names) { | ||
| 72 | u32 child_dir_offset; | ||
| 73 | child_dir_offset = dir.first_child_dir_offset; | ||
| 74 | while (true) { | ||
| 75 | if (child_dir_offset == INVALID_FIELD) { | ||
| 76 | return nullptr; | ||
| 77 | } | ||
| 78 | const u8* current_child_dir = romfs + header.dir_table_offset + child_dir_offset; | ||
| 79 | std::memcpy(&dir, current_child_dir, sizeof(dir)); | ||
| 80 | if (MatchName(current_child_dir + sizeof(dir), dir.name_length, dir_name)) { | ||
| 81 | current_dir = current_child_dir; | ||
| 82 | break; | ||
| 83 | } | ||
| 84 | child_dir_offset = dir.next_dir_offset; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | // Find the file | ||
| 89 | FileMetadata file; | ||
| 90 | u32 file_offset = dir.first_file_offset; | ||
| 91 | while (file_offset != INVALID_FIELD) { | ||
| 92 | const u8* current_file = romfs + header.file_table_offset + file_offset; | ||
| 93 | std::memcpy(&file, current_file, sizeof(file)); | ||
| 94 | if (MatchName(current_file + sizeof(file), file.name_length, file_name)) { | ||
| 95 | return romfs + header.data_offset + file.data_offset; | ||
| 96 | } | ||
| 97 | file_offset = file.next_file_offset; | ||
| 98 | } | ||
| 99 | return nullptr; | ||
| 100 | } | ||
| 101 | |||
| 102 | } // namespace RomFS | ||
diff --git a/src/core/hle/romfs.h b/src/core/hle/romfs.h deleted file mode 100644 index ee9f29760..000000000 --- a/src/core/hle/romfs.h +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | #include <vector> | ||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | namespace RomFS { | ||
| 12 | |||
| 13 | /** | ||
| 14 | * Gets the pointer to a file in a RomFS image. | ||
| 15 | * @param romfs The pointer to the RomFS image | ||
| 16 | * @param path A vector containing the directory names and file name of the path to the file | ||
| 17 | * @return the pointer to the file | ||
| 18 | * @todo reimplement this with a full RomFS manager | ||
| 19 | */ | ||
| 20 | const u8* GetFilePointer(const u8* romfs, const std::vector<std::u16string>& path); | ||
| 21 | |||
| 22 | } // namespace RomFS | ||
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 6d15b46ed..e952b0518 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -119,6 +119,13 @@ private: | |||
| 119 | } | 119 | } |
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) { | ||
| 123 | LOG_WARNING(Service_ACC, "(STUBBED) called"); | ||
| 124 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 125 | rb.Push(RESULT_SUCCESS); | ||
| 126 | rb.Push<u32>(1); | ||
| 127 | } | ||
| 128 | |||
| 122 | void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) { | 129 | void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) { |
| 123 | LOG_WARNING(Service_ACC, "(STUBBED) called"); | 130 | LOG_WARNING(Service_ACC, "(STUBBED) called"); |
| 124 | IPC::ResponseBuilder rb{ctx, 3}; | 131 | IPC::ResponseBuilder rb{ctx, 3}; |
diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h index 0a01d954c..88cabaa01 100644 --- a/src/core/hle/service/acc/acc.h +++ b/src/core/hle/service/acc/acc.h | |||
| @@ -14,6 +14,7 @@ public: | |||
| 14 | public: | 14 | public: |
| 15 | explicit Interface(std::shared_ptr<Module> module, const char* name); | 15 | explicit Interface(std::shared_ptr<Module> module, const char* name); |
| 16 | 16 | ||
| 17 | void GetUserCount(Kernel::HLERequestContext& ctx); | ||
| 17 | void GetUserExistence(Kernel::HLERequestContext& ctx); | 18 | void GetUserExistence(Kernel::HLERequestContext& ctx); |
| 18 | void ListAllUsers(Kernel::HLERequestContext& ctx); | 19 | void ListAllUsers(Kernel::HLERequestContext& ctx); |
| 19 | void ListOpenUsers(Kernel::HLERequestContext& ctx); | 20 | void ListOpenUsers(Kernel::HLERequestContext& ctx); |
diff --git a/src/core/hle/service/acc/acc_su.cpp b/src/core/hle/service/acc/acc_su.cpp index 9ffb40b22..8b2a71f37 100644 --- a/src/core/hle/service/acc/acc_su.cpp +++ b/src/core/hle/service/acc/acc_su.cpp | |||
| @@ -8,7 +8,7 @@ namespace Service::Account { | |||
| 8 | 8 | ||
| 9 | ACC_SU::ACC_SU(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:su") { | 9 | ACC_SU::ACC_SU(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:su") { |
| 10 | static const FunctionInfo functions[] = { | 10 | static const FunctionInfo functions[] = { |
| 11 | {0, nullptr, "GetUserCount"}, | 11 | {0, &ACC_SU::GetUserCount, "GetUserCount"}, |
| 12 | {1, &ACC_SU::GetUserExistence, "GetUserExistence"}, | 12 | {1, &ACC_SU::GetUserExistence, "GetUserExistence"}, |
| 13 | {2, &ACC_SU::ListAllUsers, "ListAllUsers"}, | 13 | {2, &ACC_SU::ListAllUsers, "ListAllUsers"}, |
| 14 | {3, &ACC_SU::ListOpenUsers, "ListOpenUsers"}, | 14 | {3, &ACC_SU::ListOpenUsers, "ListOpenUsers"}, |
diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp index 44e21ac09..d84c8b2e1 100644 --- a/src/core/hle/service/acc/acc_u0.cpp +++ b/src/core/hle/service/acc/acc_u0.cpp | |||
| @@ -8,7 +8,7 @@ namespace Service::Account { | |||
| 8 | 8 | ||
| 9 | ACC_U0::ACC_U0(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:u0") { | 9 | ACC_U0::ACC_U0(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:u0") { |
| 10 | static const FunctionInfo functions[] = { | 10 | static const FunctionInfo functions[] = { |
| 11 | {0, nullptr, "GetUserCount"}, | 11 | {0, &ACC_U0::GetUserCount, "GetUserCount"}, |
| 12 | {1, &ACC_U0::GetUserExistence, "GetUserExistence"}, | 12 | {1, &ACC_U0::GetUserExistence, "GetUserExistence"}, |
| 13 | {2, &ACC_U0::ListAllUsers, "ListAllUsers"}, | 13 | {2, &ACC_U0::ListAllUsers, "ListAllUsers"}, |
| 14 | {3, &ACC_U0::ListOpenUsers, "ListOpenUsers"}, | 14 | {3, &ACC_U0::ListOpenUsers, "ListOpenUsers"}, |
diff --git a/src/core/hle/service/acc/acc_u1.cpp b/src/core/hle/service/acc/acc_u1.cpp index d101d4e0d..0ceaf06b5 100644 --- a/src/core/hle/service/acc/acc_u1.cpp +++ b/src/core/hle/service/acc/acc_u1.cpp | |||
| @@ -8,7 +8,7 @@ namespace Service::Account { | |||
| 8 | 8 | ||
| 9 | ACC_U1::ACC_U1(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:u1") { | 9 | ACC_U1::ACC_U1(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:u1") { |
| 10 | static const FunctionInfo functions[] = { | 10 | static const FunctionInfo functions[] = { |
| 11 | {0, nullptr, "GetUserCount"}, | 11 | {0, &ACC_U1::GetUserCount, "GetUserCount"}, |
| 12 | {1, &ACC_U1::GetUserExistence, "GetUserExistence"}, | 12 | {1, &ACC_U1::GetUserExistence, "GetUserExistence"}, |
| 13 | {2, &ACC_U1::ListAllUsers, "ListAllUsers"}, | 13 | {2, &ACC_U1::ListAllUsers, "ListAllUsers"}, |
| 14 | {3, &ACC_U1::ListOpenUsers, "ListOpenUsers"}, | 14 | {3, &ACC_U1::ListOpenUsers, "ListOpenUsers"}, |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 8f0262e34..dcdfa0e19 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -457,7 +457,7 @@ private: | |||
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { | 459 | void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { |
| 460 | IPC::ResponseBuilder rb{ctx, 2}; | 460 | IPC::ResponseBuilder rb{ctx, 3}; |
| 461 | rb.Push(RESULT_SUCCESS); | 461 | rb.Push(RESULT_SUCCESS); |
| 462 | // TODO (Hexagon12): Properly implement reading gyroscope values from controllers. | 462 | // TODO (Hexagon12): Properly implement reading gyroscope values from controllers. |
| 463 | rb.Push(true); | 463 | rb.Push(true); |