diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/core/hle/config_mem.cpp | 31 | ||||
| -rw-r--r-- | src/core/hle/config_mem.h | 56 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/memory.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/wait_object.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 33 | ||||
| -rw-r--r-- | src/core/hle/shared_page.cpp | 86 | ||||
| -rw-r--r-- | src/core/hle/shared_page.h | 69 | ||||
| -rw-r--r-- | src/core/loader/nro.cpp | 37 | ||||
| -rw-r--r-- | src/core/loader/nro.h | 10 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 10 |
12 files changed, 60 insertions, 293 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index fd75854b0..6b6efbc00 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -40,8 +40,6 @@ add_library(core STATIC | |||
| 40 | frontend/input.h | 40 | frontend/input.h |
| 41 | gdbstub/gdbstub.cpp | 41 | gdbstub/gdbstub.cpp |
| 42 | gdbstub/gdbstub.h | 42 | gdbstub/gdbstub.h |
| 43 | hle/config_mem.cpp | ||
| 44 | hle/config_mem.h | ||
| 45 | hle/ipc.h | 43 | hle/ipc.h |
| 46 | hle/ipc_helpers.h | 44 | hle/ipc_helpers.h |
| 47 | hle/kernel/address_arbiter.cpp | 45 | hle/kernel/address_arbiter.cpp |
| @@ -251,8 +249,6 @@ add_library(core STATIC | |||
| 251 | hle/service/vi/vi_s.h | 249 | hle/service/vi/vi_s.h |
| 252 | hle/service/vi/vi_u.cpp | 250 | hle/service/vi/vi_u.cpp |
| 253 | hle/service/vi/vi_u.h | 251 | hle/service/vi/vi_u.h |
| 254 | hle/shared_page.cpp | ||
| 255 | hle/shared_page.h | ||
| 256 | hw/hw.cpp | 252 | hw/hw.cpp |
| 257 | hw/hw.h | 253 | hw/hw.h |
| 258 | hw/lcd.cpp | 254 | hw/lcd.cpp |
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp deleted file mode 100644 index 038af7909..000000000 --- a/src/core/hle/config_mem.cpp +++ /dev/null | |||
| @@ -1,31 +0,0 @@ | |||
| 1 | // Copyright 2014 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 "core/hle/config_mem.h" | ||
| 7 | |||
| 8 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 9 | |||
| 10 | namespace ConfigMem { | ||
| 11 | |||
| 12 | ConfigMemDef config_mem; | ||
| 13 | |||
| 14 | void Init() { | ||
| 15 | std::memset(&config_mem, 0, sizeof(config_mem)); | ||
| 16 | |||
| 17 | // Values extracted from firmware 11.2.0-35E | ||
| 18 | config_mem.kernel_version_min = 0x34; | ||
| 19 | config_mem.kernel_version_maj = 0x2; | ||
| 20 | config_mem.ns_tid = 0x0004013000008002; | ||
| 21 | config_mem.sys_core_ver = 0x2; | ||
| 22 | config_mem.unit_info = 0x1; // Bit 0 set for Retail | ||
| 23 | config_mem.prev_firm = 0x1; | ||
| 24 | config_mem.ctr_sdk_ver = 0x0000F297; | ||
| 25 | config_mem.firm_version_min = 0x34; | ||
| 26 | config_mem.firm_version_maj = 0x2; | ||
| 27 | config_mem.firm_sys_core_ver = 0x2; | ||
| 28 | config_mem.firm_ctr_sdk_ver = 0x0000F297; | ||
| 29 | } | ||
| 30 | |||
| 31 | } // namespace ConfigMem | ||
diff --git a/src/core/hle/config_mem.h b/src/core/hle/config_mem.h deleted file mode 100644 index 1840d1760..000000000 --- a/src/core/hle/config_mem.h +++ /dev/null | |||
| @@ -1,56 +0,0 @@ | |||
| 1 | // Copyright 2014 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 | // Configuration memory stores various hardware/kernel configuration settings. This memory page is | ||
| 8 | // read-only for ARM11 processes. I'm guessing this would normally be written to by the firmware/ | ||
| 9 | // bootrom. Because we're not emulating this, and essentially just "stubbing" the functionality, I'm | ||
| 10 | // putting this as a subset of HLE for now. | ||
| 11 | |||
| 12 | #include "common/common_funcs.h" | ||
| 13 | #include "common/common_types.h" | ||
| 14 | #include "common/swap.h" | ||
| 15 | #include "core/memory.h" | ||
| 16 | |||
| 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 18 | |||
| 19 | namespace ConfigMem { | ||
| 20 | |||
| 21 | struct ConfigMemDef { | ||
| 22 | u8 kernel_unk; // 0 | ||
| 23 | u8 kernel_version_rev; // 1 | ||
| 24 | u8 kernel_version_min; // 2 | ||
| 25 | u8 kernel_version_maj; // 3 | ||
| 26 | u32_le update_flag; // 4 | ||
| 27 | u64_le ns_tid; // 8 | ||
| 28 | u32_le sys_core_ver; // 10 | ||
| 29 | u8 unit_info; // 14 | ||
| 30 | u8 boot_firm; // 15 | ||
| 31 | u8 prev_firm; // 16 | ||
| 32 | INSERT_PADDING_BYTES(0x1); // 17 | ||
| 33 | u32_le ctr_sdk_ver; // 18 | ||
| 34 | INSERT_PADDING_BYTES(0x30 - 0x1C); // 1C | ||
| 35 | u32_le app_mem_type; // 30 | ||
| 36 | INSERT_PADDING_BYTES(0x40 - 0x34); // 34 | ||
| 37 | u32_le app_mem_alloc; // 40 | ||
| 38 | u32_le sys_mem_alloc; // 44 | ||
| 39 | u32_le base_mem_alloc; // 48 | ||
| 40 | INSERT_PADDING_BYTES(0x60 - 0x4C); // 4C | ||
| 41 | u8 firm_unk; // 60 | ||
| 42 | u8 firm_version_rev; // 61 | ||
| 43 | u8 firm_version_min; // 62 | ||
| 44 | u8 firm_version_maj; // 63 | ||
| 45 | u32_le firm_sys_core_ver; // 64 | ||
| 46 | u32_le firm_ctr_sdk_ver; // 68 | ||
| 47 | INSERT_PADDING_BYTES(0x1000 - 0x6C); // 6C | ||
| 48 | }; | ||
| 49 | static_assert(sizeof(ConfigMemDef) == Memory::CONFIG_MEMORY_SIZE, | ||
| 50 | "Config Memory structure size is wrong"); | ||
| 51 | |||
| 52 | extern ConfigMemDef config_mem; | ||
| 53 | |||
| 54 | void Init(); | ||
| 55 | |||
| 56 | } // namespace ConfigMem | ||
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index b325b879b..1beb98566 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.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 "core/hle/config_mem.h" | ||
| 6 | #include "core/hle/kernel/handle_table.h" | 5 | #include "core/hle/kernel/handle_table.h" |
| 7 | #include "core/hle/kernel/kernel.h" | 6 | #include "core/hle/kernel/kernel.h" |
| 8 | #include "core/hle/kernel/memory.h" | 7 | #include "core/hle/kernel/memory.h" |
| @@ -11,7 +10,6 @@ | |||
| 11 | #include "core/hle/kernel/resource_limit.h" | 10 | #include "core/hle/kernel/resource_limit.h" |
| 12 | #include "core/hle/kernel/thread.h" | 11 | #include "core/hle/kernel/thread.h" |
| 13 | #include "core/hle/kernel/timer.h" | 12 | #include "core/hle/kernel/timer.h" |
| 14 | #include "core/hle/shared_page.h" | ||
| 15 | 13 | ||
| 16 | namespace Kernel { | 14 | namespace Kernel { |
| 17 | 15 | ||
| @@ -19,9 +17,6 @@ unsigned int Object::next_object_id; | |||
| 19 | 17 | ||
| 20 | /// Initialize the kernel | 18 | /// Initialize the kernel |
| 21 | void Init(u32 system_mode) { | 19 | void Init(u32 system_mode) { |
| 22 | ConfigMem::Init(); | ||
| 23 | SharedPage::Init(); | ||
| 24 | |||
| 25 | Kernel::MemoryInit(system_mode); | 20 | Kernel::MemoryInit(system_mode); |
| 26 | 21 | ||
| 27 | Kernel::ResourceLimitsInit(); | 22 | Kernel::ResourceLimitsInit(); |
diff --git a/src/core/hle/kernel/memory.cpp b/src/core/hle/kernel/memory.cpp index d2600cdd7..94eac677c 100644 --- a/src/core/hle/kernel/memory.cpp +++ b/src/core/hle/kernel/memory.cpp | |||
| @@ -11,11 +11,9 @@ | |||
| 11 | #include "common/assert.h" | 11 | #include "common/assert.h" |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 14 | #include "core/hle/config_mem.h" | ||
| 15 | #include "core/hle/kernel/memory.h" | 14 | #include "core/hle/kernel/memory.h" |
| 16 | #include "core/hle/kernel/vm_manager.h" | 15 | #include "core/hle/kernel/vm_manager.h" |
| 17 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
| 18 | #include "core/hle/shared_page.h" | ||
| 19 | #include "core/memory.h" | 17 | #include "core/memory.h" |
| 20 | #include "core/memory_setup.h" | 18 | #include "core/memory_setup.h" |
| 21 | 19 | ||
| @@ -63,14 +61,6 @@ void MemoryInit(u32 mem_type) { | |||
| 63 | 61 | ||
| 64 | // We must've allocated the entire FCRAM by the end | 62 | // We must've allocated the entire FCRAM by the end |
| 65 | ASSERT(base == Memory::FCRAM_SIZE); | 63 | ASSERT(base == Memory::FCRAM_SIZE); |
| 66 | |||
| 67 | using ConfigMem::config_mem; | ||
| 68 | config_mem.app_mem_type = mem_type; | ||
| 69 | // app_mem_malloc does not always match the configured size for memory_region[0]: in case the | ||
| 70 | // n3DS type override is in effect it reports the size the game expects, not the real one. | ||
| 71 | config_mem.app_mem_alloc = memory_region_sizes[mem_type][0]; | ||
| 72 | config_mem.sys_mem_alloc = static_cast<u32_le>(memory_regions[1].size); | ||
| 73 | config_mem.base_mem_alloc = static_cast<u32_le>(memory_regions[2].size); | ||
| 74 | } | 64 | } |
| 75 | 65 | ||
| 76 | void MemoryShutdown() { | 66 | void MemoryShutdown() { |
diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index eb3c92e66..23af346d0 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/config_mem.h" | ||
| 9 | #include "core/hle/kernel/errors.h" | 8 | #include "core/hle/kernel/errors.h" |
| 10 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/kernel/memory.h" | 10 | #include "core/hle/kernel/memory.h" |
| @@ -13,7 +12,6 @@ | |||
| 13 | #include "core/hle/kernel/resource_limit.h" | 12 | #include "core/hle/kernel/resource_limit.h" |
| 14 | #include "core/hle/kernel/thread.h" | 13 | #include "core/hle/kernel/thread.h" |
| 15 | #include "core/hle/kernel/timer.h" | 14 | #include "core/hle/kernel/timer.h" |
| 16 | #include "core/hle/shared_page.h" | ||
| 17 | 15 | ||
| 18 | namespace Kernel { | 16 | namespace Kernel { |
| 19 | 17 | ||
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 3a69b85f9..993f1e65a 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <type_traits> | ||
| 9 | #include <utility> | ||
| 8 | #include <boost/optional.hpp> | 10 | #include <boost/optional.hpp> |
| 9 | #include "common/alignment.h" | 11 | #include "common/alignment.h" |
| 10 | #include "common/math_util.h" | 12 | #include "common/math_util.h" |
| @@ -43,7 +45,9 @@ public: | |||
| 43 | 45 | ||
| 44 | template <typename T> | 46 | template <typename T> |
| 45 | T Read() { | 47 | T Read() { |
| 48 | static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable."); | ||
| 46 | ASSERT(read_index + sizeof(T) <= buffer.size()); | 49 | ASSERT(read_index + sizeof(T) <= buffer.size()); |
| 50 | |||
| 47 | T val; | 51 | T val; |
| 48 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); | 52 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); |
| 49 | read_index += sizeof(T); | 53 | read_index += sizeof(T); |
| @@ -53,7 +57,9 @@ public: | |||
| 53 | 57 | ||
| 54 | template <typename T> | 58 | template <typename T> |
| 55 | T ReadUnaligned() { | 59 | T ReadUnaligned() { |
| 60 | static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable."); | ||
| 56 | ASSERT(read_index + sizeof(T) <= buffer.size()); | 61 | ASSERT(read_index + sizeof(T) <= buffer.size()); |
| 62 | |||
| 57 | T val; | 63 | T val; |
| 58 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); | 64 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); |
| 59 | read_index += sizeof(T); | 65 | read_index += sizeof(T); |
| @@ -87,8 +93,12 @@ public: | |||
| 87 | 93 | ||
| 88 | template <typename T> | 94 | template <typename T> |
| 89 | void Write(const T& val) { | 95 | void Write(const T& val) { |
| 90 | if (buffer.size() < write_index + sizeof(T)) | 96 | static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable."); |
| 97 | |||
| 98 | if (buffer.size() < write_index + sizeof(T)) { | ||
| 91 | buffer.resize(buffer.size() + sizeof(T) + DefaultBufferSize); | 99 | buffer.resize(buffer.size() + sizeof(T) + DefaultBufferSize); |
| 100 | } | ||
| 101 | |||
| 92 | std::memcpy(buffer.data() + write_index, &val, sizeof(T)); | 102 | std::memcpy(buffer.data() + write_index, &val, sizeof(T)); |
| 93 | write_index += sizeof(T); | 103 | write_index += sizeof(T); |
| 94 | write_index = Common::AlignUp(write_index, 4); | 104 | write_index = Common::AlignUp(write_index, 4); |
| @@ -96,7 +106,9 @@ public: | |||
| 96 | 106 | ||
| 97 | template <typename T> | 107 | template <typename T> |
| 98 | void WriteObject(const T& val) { | 108 | void WriteObject(const T& val) { |
| 99 | u32_le size = static_cast<u32>(sizeof(val)); | 109 | static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable."); |
| 110 | |||
| 111 | const u32_le size = static_cast<u32>(sizeof(val)); | ||
| 100 | Write(size); | 112 | Write(size); |
| 101 | // TODO(Subv): Support file descriptors. | 113 | // TODO(Subv): Support file descriptors. |
| 102 | Write<u32_le>(0); // Fd count. | 114 | Write<u32_le>(0); // Fd count. |
| @@ -176,7 +188,7 @@ private: | |||
| 176 | 188 | ||
| 177 | class IGBPConnectRequestParcel : public Parcel { | 189 | class IGBPConnectRequestParcel : public Parcel { |
| 178 | public: | 190 | public: |
| 179 | explicit IGBPConnectRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { | 191 | explicit IGBPConnectRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { |
| 180 | Deserialize(); | 192 | Deserialize(); |
| 181 | } | 193 | } |
| 182 | ~IGBPConnectRequestParcel() override = default; | 194 | ~IGBPConnectRequestParcel() override = default; |
| @@ -223,8 +235,8 @@ private: | |||
| 223 | 235 | ||
| 224 | class IGBPSetPreallocatedBufferRequestParcel : public Parcel { | 236 | class IGBPSetPreallocatedBufferRequestParcel : public Parcel { |
| 225 | public: | 237 | public: |
| 226 | explicit IGBPSetPreallocatedBufferRequestParcel(const std::vector<u8>& buffer) | 238 | explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer) |
| 227 | : Parcel(buffer) { | 239 | : Parcel(std::move(buffer)) { |
| 228 | Deserialize(); | 240 | Deserialize(); |
| 229 | } | 241 | } |
| 230 | ~IGBPSetPreallocatedBufferRequestParcel() override = default; | 242 | ~IGBPSetPreallocatedBufferRequestParcel() override = default; |
| @@ -256,7 +268,7 @@ protected: | |||
| 256 | 268 | ||
| 257 | class IGBPDequeueBufferRequestParcel : public Parcel { | 269 | class IGBPDequeueBufferRequestParcel : public Parcel { |
| 258 | public: | 270 | public: |
| 259 | explicit IGBPDequeueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { | 271 | explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { |
| 260 | Deserialize(); | 272 | Deserialize(); |
| 261 | } | 273 | } |
| 262 | ~IGBPDequeueBufferRequestParcel() override = default; | 274 | ~IGBPDequeueBufferRequestParcel() override = default; |
| @@ -307,7 +319,7 @@ protected: | |||
| 307 | 319 | ||
| 308 | class IGBPRequestBufferRequestParcel : public Parcel { | 320 | class IGBPRequestBufferRequestParcel : public Parcel { |
| 309 | public: | 321 | public: |
| 310 | explicit IGBPRequestBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { | 322 | explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { |
| 311 | Deserialize(); | 323 | Deserialize(); |
| 312 | } | 324 | } |
| 313 | ~IGBPRequestBufferRequestParcel() override = default; | 325 | ~IGBPRequestBufferRequestParcel() override = default; |
| @@ -322,8 +334,7 @@ public: | |||
| 322 | 334 | ||
| 323 | class IGBPRequestBufferResponseParcel : public Parcel { | 335 | class IGBPRequestBufferResponseParcel : public Parcel { |
| 324 | public: | 336 | public: |
| 325 | explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer) | 337 | explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer) : buffer(buffer) {} |
| 326 | : Parcel(), buffer(buffer) {} | ||
| 327 | ~IGBPRequestBufferResponseParcel() override = default; | 338 | ~IGBPRequestBufferResponseParcel() override = default; |
| 328 | 339 | ||
| 329 | protected: | 340 | protected: |
| @@ -340,7 +351,7 @@ protected: | |||
| 340 | 351 | ||
| 341 | class IGBPQueueBufferRequestParcel : public Parcel { | 352 | class IGBPQueueBufferRequestParcel : public Parcel { |
| 342 | public: | 353 | public: |
| 343 | explicit IGBPQueueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { | 354 | explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { |
| 344 | Deserialize(); | 355 | Deserialize(); |
| 345 | } | 356 | } |
| 346 | ~IGBPQueueBufferRequestParcel() override = default; | 357 | ~IGBPQueueBufferRequestParcel() override = default; |
| @@ -409,7 +420,7 @@ private: | |||
| 409 | 420 | ||
| 410 | class IGBPQueryRequestParcel : public Parcel { | 421 | class IGBPQueryRequestParcel : public Parcel { |
| 411 | public: | 422 | public: |
| 412 | explicit IGBPQueryRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { | 423 | explicit IGBPQueryRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { |
| 413 | Deserialize(); | 424 | Deserialize(); |
| 414 | } | 425 | } |
| 415 | ~IGBPQueryRequestParcel() override = default; | 426 | ~IGBPQueryRequestParcel() override = default; |
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp deleted file mode 100644 index 9ed8ab249..000000000 --- a/src/core/hle/shared_page.cpp +++ /dev/null | |||
| @@ -1,86 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <chrono> | ||
| 6 | #include <cstring> | ||
| 7 | #include <ctime> | ||
| 8 | #include "core/core_timing.h" | ||
| 9 | #include "core/hle/shared_page.h" | ||
| 10 | |||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 12 | |||
| 13 | namespace SharedPage { | ||
| 14 | |||
| 15 | SharedPageDef shared_page; | ||
| 16 | |||
| 17 | static CoreTiming::EventType* update_time_event; | ||
| 18 | |||
| 19 | /// Gets system time in 3DS format. The epoch is Jan 1900, and the unit is millisecond. | ||
| 20 | static u64 GetSystemTime() { | ||
| 21 | auto now = std::chrono::system_clock::now(); | ||
| 22 | |||
| 23 | // 3DS system does't allow user to set a time before Jan 1 2000, | ||
| 24 | // so we use it as an auxiliary epoch to calculate the console time. | ||
| 25 | std::tm epoch_tm; | ||
| 26 | epoch_tm.tm_sec = 0; | ||
| 27 | epoch_tm.tm_min = 0; | ||
| 28 | epoch_tm.tm_hour = 0; | ||
| 29 | epoch_tm.tm_mday = 1; | ||
| 30 | epoch_tm.tm_mon = 0; | ||
| 31 | epoch_tm.tm_year = 100; | ||
| 32 | epoch_tm.tm_isdst = 0; | ||
| 33 | auto epoch = std::chrono::system_clock::from_time_t(std::mktime(&epoch_tm)); | ||
| 34 | |||
| 35 | // 3DS console time uses Jan 1 1900 as internal epoch, | ||
| 36 | // so we use the milliseconds between 1900 and 2000 as base console time | ||
| 37 | u64 console_time = 3155673600000ULL; | ||
| 38 | |||
| 39 | // Only when system time is after 2000, we set it as 3DS system time | ||
| 40 | if (now > epoch) { | ||
| 41 | console_time += std::chrono::duration_cast<std::chrono::milliseconds>(now - epoch).count(); | ||
| 42 | } | ||
| 43 | |||
| 44 | // If the system time is in daylight saving, we give an additional hour to console time | ||
| 45 | std::time_t now_time_t = std::chrono::system_clock::to_time_t(now); | ||
| 46 | std::tm* now_tm = std::localtime(&now_time_t); | ||
| 47 | if (now_tm && now_tm->tm_isdst > 0) | ||
| 48 | console_time += 60 * 60 * 1000; | ||
| 49 | |||
| 50 | return console_time; | ||
| 51 | } | ||
| 52 | |||
| 53 | static void UpdateTimeCallback(u64 userdata, int cycles_late) { | ||
| 54 | DateTime& date_time = | ||
| 55 | shared_page.date_time_counter % 2 ? shared_page.date_time_0 : shared_page.date_time_1; | ||
| 56 | |||
| 57 | date_time.date_time = GetSystemTime(); | ||
| 58 | date_time.update_tick = CoreTiming::GetTicks(); | ||
| 59 | date_time.tick_to_second_coefficient = CoreTiming::BASE_CLOCK_RATE; | ||
| 60 | date_time.tick_offset = 0; | ||
| 61 | |||
| 62 | ++shared_page.date_time_counter; | ||
| 63 | |||
| 64 | // system time is updated hourly | ||
| 65 | CoreTiming::ScheduleEvent(CoreTiming::msToCycles(60 * 60 * 1000) - cycles_late, | ||
| 66 | update_time_event); | ||
| 67 | } | ||
| 68 | |||
| 69 | void Init() { | ||
| 70 | std::memset(&shared_page, 0, sizeof(shared_page)); | ||
| 71 | |||
| 72 | shared_page.running_hw = 0x1; // product | ||
| 73 | |||
| 74 | // Some games wait until this value becomes 0x1, before asking running_hw | ||
| 75 | shared_page.unknown_value = 0x1; | ||
| 76 | |||
| 77 | // Set to a completely full battery | ||
| 78 | shared_page.battery_state.is_adapter_connected.Assign(1); | ||
| 79 | shared_page.battery_state.is_charging.Assign(1); | ||
| 80 | |||
| 81 | update_time_event = | ||
| 82 | CoreTiming::RegisterEvent("SharedPage::UpdateTimeCallback", UpdateTimeCallback); | ||
| 83 | CoreTiming::ScheduleEvent(0, update_time_event); | ||
| 84 | } | ||
| 85 | |||
| 86 | } // namespace SharedPage | ||
diff --git a/src/core/hle/shared_page.h b/src/core/hle/shared_page.h deleted file mode 100644 index a58259888..000000000 --- a/src/core/hle/shared_page.h +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 1 | // Copyright 2015 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 | /** | ||
| 8 | * The shared page stores various runtime configuration settings. This memory page is | ||
| 9 | * read-only for user processes (there is a bit in the header that grants the process | ||
| 10 | * write access, according to 3dbrew; this is not emulated) | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "common/bit_field.h" | ||
| 14 | #include "common/common_funcs.h" | ||
| 15 | #include "common/common_types.h" | ||
| 16 | #include "common/swap.h" | ||
| 17 | #include "core/memory.h" | ||
| 18 | |||
| 19 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 20 | |||
| 21 | namespace SharedPage { | ||
| 22 | |||
| 23 | // See http://3dbrew.org/wiki/Configuration_Memory#Shared_Memory_Page_For_ARM11_Processes | ||
| 24 | |||
| 25 | struct DateTime { | ||
| 26 | u64_le date_time; // 0 | ||
| 27 | u64_le update_tick; // 8 | ||
| 28 | u64_le tick_to_second_coefficient; // 10 | ||
| 29 | u64_le tick_offset; // 18 | ||
| 30 | }; | ||
| 31 | static_assert(sizeof(DateTime) == 0x20, "Datetime size is wrong"); | ||
| 32 | |||
| 33 | union BatteryState { | ||
| 34 | u8 raw; | ||
| 35 | BitField<0, 1, u8> is_adapter_connected; | ||
| 36 | BitField<1, 1, u8> is_charging; | ||
| 37 | BitField<2, 3, u8> charge_level; | ||
| 38 | }; | ||
| 39 | |||
| 40 | struct SharedPageDef { | ||
| 41 | // Most of these names are taken from the 3dbrew page linked above. | ||
| 42 | u32_le date_time_counter; // 0 | ||
| 43 | u8 running_hw; // 4 | ||
| 44 | /// "Microcontroller hardware info" | ||
| 45 | u8 mcu_hw_info; // 5 | ||
| 46 | INSERT_PADDING_BYTES(0x20 - 0x6); // 6 | ||
| 47 | DateTime date_time_0; // 20 | ||
| 48 | DateTime date_time_1; // 40 | ||
| 49 | u8 wifi_macaddr[6]; // 60 | ||
| 50 | u8 wifi_link_level; // 66 | ||
| 51 | u8 wifi_unknown2; // 67 | ||
| 52 | INSERT_PADDING_BYTES(0x80 - 0x68); // 68 | ||
| 53 | float_le sliderstate_3d; // 80 | ||
| 54 | u8 ledstate_3d; // 84 | ||
| 55 | BatteryState battery_state; // 85 | ||
| 56 | u8 unknown_value; // 86 | ||
| 57 | INSERT_PADDING_BYTES(0xA0 - 0x87); // 87 | ||
| 58 | u64_le menu_title_id; // A0 | ||
| 59 | u64_le active_menu_title_id; // A8 | ||
| 60 | INSERT_PADDING_BYTES(0x1000 - 0xB0); // B0 | ||
| 61 | }; | ||
| 62 | static_assert(sizeof(SharedPageDef) == Memory::SHARED_PAGE_SIZE, | ||
| 63 | "Shared page structure size is wrong"); | ||
| 64 | |||
| 65 | extern SharedPageDef shared_page; | ||
| 66 | |||
| 67 | void Init(); | ||
| 68 | |||
| 69 | } // namespace SharedPage | ||
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 44158655c..7d3ec2a76 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | 7 | ||
| 8 | #include "common/common_funcs.h" | 8 | #include "common/common_funcs.h" |
| 9 | #include "common/common_types.h" | ||
| 9 | #include "common/file_util.h" | 10 | #include "common/file_util.h" |
| 10 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 11 | #include "common/swap.h" | 12 | #include "common/swap.h" |
| @@ -68,22 +69,27 @@ static_assert(sizeof(AssetHeader) == 0x38, "AssetHeader has incorrect size."); | |||
| 68 | 69 | ||
| 69 | AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) { | 70 | AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) { |
| 70 | NroHeader nro_header{}; | 71 | NroHeader nro_header{}; |
| 71 | if (file->ReadObject(&nro_header) != sizeof(NroHeader)) | 72 | if (file->ReadObject(&nro_header) != sizeof(NroHeader)) { |
| 72 | return; | 73 | return; |
| 74 | } | ||
| 73 | 75 | ||
| 74 | if (file->GetSize() >= nro_header.file_size + sizeof(AssetHeader)) { | 76 | if (file->GetSize() >= nro_header.file_size + sizeof(AssetHeader)) { |
| 75 | u64 offset = nro_header.file_size; | 77 | const u64 offset = nro_header.file_size; |
| 76 | AssetHeader asset_header{}; | 78 | AssetHeader asset_header{}; |
| 77 | if (file->ReadObject(&asset_header, offset) != sizeof(AssetHeader)) | 79 | if (file->ReadObject(&asset_header, offset) != sizeof(AssetHeader)) { |
| 78 | return; | 80 | return; |
| 81 | } | ||
| 79 | 82 | ||
| 80 | if (asset_header.format_version != 0) | 83 | if (asset_header.format_version != 0) { |
| 81 | LOG_WARNING(Loader, | 84 | LOG_WARNING(Loader, |
| 82 | "NRO Asset Header has format {}, currently supported format is 0. If " | 85 | "NRO Asset Header has format {}, currently supported format is 0. If " |
| 83 | "strange glitches occur with metadata, check NRO assets.", | 86 | "strange glitches occur with metadata, check NRO assets.", |
| 84 | asset_header.format_version); | 87 | asset_header.format_version); |
| 85 | if (asset_header.magic != Common::MakeMagic('A', 'S', 'E', 'T')) | 88 | } |
| 89 | |||
| 90 | if (asset_header.magic != Common::MakeMagic('A', 'S', 'E', 'T')) { | ||
| 86 | return; | 91 | return; |
| 92 | } | ||
| 87 | 93 | ||
| 88 | if (asset_header.nacp.size > 0) { | 94 | if (asset_header.nacp.size > 0) { |
| 89 | nacp = std::make_unique<FileSys::NACP>(std::make_shared<FileSys::OffsetVfsFile>( | 95 | nacp = std::make_unique<FileSys::NACP>(std::make_shared<FileSys::OffsetVfsFile>( |
| @@ -101,6 +107,8 @@ AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) { | |||
| 101 | } | 107 | } |
| 102 | } | 108 | } |
| 103 | 109 | ||
| 110 | AppLoader_NRO::~AppLoader_NRO() = default; | ||
| 111 | |||
| 104 | FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& file) { | 112 | FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& file) { |
| 105 | // Read NSO header | 113 | // Read NSO header |
| 106 | NroHeader nro_header{}; | 114 | NroHeader nro_header{}; |
| @@ -130,8 +138,9 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) { | |||
| 130 | // Build program image | 138 | // Build program image |
| 131 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create(""); | 139 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create(""); |
| 132 | std::vector<u8> program_image = file->ReadBytes(PageAlignSize(nro_header.file_size)); | 140 | std::vector<u8> program_image = file->ReadBytes(PageAlignSize(nro_header.file_size)); |
| 133 | if (program_image.size() != PageAlignSize(nro_header.file_size)) | 141 | if (program_image.size() != PageAlignSize(nro_header.file_size)) { |
| 134 | return {}; | 142 | return {}; |
| 143 | } | ||
| 135 | 144 | ||
| 136 | for (std::size_t i = 0; i < nro_header.segments.size(); ++i) { | 145 | for (std::size_t i = 0; i < nro_header.segments.size(); ++i) { |
| 137 | codeset->segments[i].addr = nro_header.segments[i].offset; | 146 | codeset->segments[i].addr = nro_header.segments[i].offset; |
| @@ -187,29 +196,37 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) { | |||
| 187 | } | 196 | } |
| 188 | 197 | ||
| 189 | ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) { | 198 | ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) { |
| 190 | if (icon_data.empty()) | 199 | if (icon_data.empty()) { |
| 191 | return ResultStatus::ErrorNotUsed; | 200 | return ResultStatus::ErrorNotUsed; |
| 201 | } | ||
| 202 | |||
| 192 | buffer = icon_data; | 203 | buffer = icon_data; |
| 193 | return ResultStatus::Success; | 204 | return ResultStatus::Success; |
| 194 | } | 205 | } |
| 195 | 206 | ||
| 196 | ResultStatus AppLoader_NRO::ReadProgramId(u64& out_program_id) { | 207 | ResultStatus AppLoader_NRO::ReadProgramId(u64& out_program_id) { |
| 197 | if (nacp == nullptr) | 208 | if (nacp == nullptr) { |
| 198 | return ResultStatus::ErrorNotUsed; | 209 | return ResultStatus::ErrorNotUsed; |
| 210 | } | ||
| 211 | |||
| 199 | out_program_id = nacp->GetTitleId(); | 212 | out_program_id = nacp->GetTitleId(); |
| 200 | return ResultStatus::Success; | 213 | return ResultStatus::Success; |
| 201 | } | 214 | } |
| 202 | 215 | ||
| 203 | ResultStatus AppLoader_NRO::ReadRomFS(FileSys::VirtualFile& dir) { | 216 | ResultStatus AppLoader_NRO::ReadRomFS(FileSys::VirtualFile& dir) { |
| 204 | if (romfs == nullptr) | 217 | if (romfs == nullptr) { |
| 205 | return ResultStatus::ErrorNotUsed; | 218 | return ResultStatus::ErrorNotUsed; |
| 219 | } | ||
| 220 | |||
| 206 | dir = romfs; | 221 | dir = romfs; |
| 207 | return ResultStatus::Success; | 222 | return ResultStatus::Success; |
| 208 | } | 223 | } |
| 209 | 224 | ||
| 210 | ResultStatus AppLoader_NRO::ReadTitle(std::string& title) { | 225 | ResultStatus AppLoader_NRO::ReadTitle(std::string& title) { |
| 211 | if (nacp == nullptr) | 226 | if (nacp == nullptr) { |
| 212 | return ResultStatus::ErrorNotUsed; | 227 | return ResultStatus::ErrorNotUsed; |
| 228 | } | ||
| 229 | |||
| 213 | title = nacp->GetApplicationName(); | 230 | title = nacp->GetApplicationName(); |
| 214 | return ResultStatus::Success; | 231 | return ResultStatus::Success; |
| 215 | } | 232 | } |
diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h index 5f3fc40d2..04a0f497e 100644 --- a/src/core/loader/nro.h +++ b/src/core/loader/nro.h | |||
| @@ -6,19 +6,21 @@ | |||
| 6 | 6 | ||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/file_sys/control_metadata.h" | ||
| 10 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/loader/linker.h" | 10 | #include "core/loader/linker.h" |
| 12 | #include "core/loader/loader.h" | 11 | #include "core/loader/loader.h" |
| 13 | 12 | ||
| 14 | namespace Loader { | 13 | namespace FileSys { |
| 14 | class NACP; | ||
| 15 | } | ||
| 15 | 16 | ||
| 16 | struct AssetHeader; | 17 | namespace Loader { |
| 17 | 18 | ||
| 18 | /// Loads an NRO file | 19 | /// Loads an NRO file |
| 19 | class AppLoader_NRO final : public AppLoader, Linker { | 20 | class AppLoader_NRO final : public AppLoader, Linker { |
| 20 | public: | 21 | public: |
| 21 | AppLoader_NRO(FileSys::VirtualFile file); | 22 | explicit AppLoader_NRO(FileSys::VirtualFile file); |
| 23 | ~AppLoader_NRO() override; | ||
| 22 | 24 | ||
| 23 | /** | 25 | /** |
| 24 | * Returns the type of the file | 26 | * Returns the type of the file |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index ba827181b..e771411ef 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -6,6 +6,9 @@ | |||
| 6 | #include <set> | 6 | #include <set> |
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include <string_view> | 8 | #include <string_view> |
| 9 | |||
| 10 | #include <fmt/format.h> | ||
| 11 | |||
| 9 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 10 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 11 | #include "video_core/engines/shader_bytecode.h" | 14 | #include "video_core/engines/shader_bytecode.h" |
| @@ -1774,11 +1777,8 @@ private: | |||
| 1774 | }; // namespace Decompiler | 1777 | }; // namespace Decompiler |
| 1775 | 1778 | ||
| 1776 | std::string GetCommonDeclarations() { | 1779 | std::string GetCommonDeclarations() { |
| 1777 | std::string declarations; | 1780 | return fmt::format("#define MAX_CONSTBUFFER_ELEMENTS {}\n", |
| 1778 | declarations += "#define MAX_CONSTBUFFER_ELEMENTS " + | 1781 | RasterizerOpenGL::MaxConstbufferSize / sizeof(GLvec4)); |
| 1779 | std::to_string(RasterizerOpenGL::MaxConstbufferSize / (sizeof(GLvec4))); | ||
| 1780 | declarations += '\n'; | ||
| 1781 | return declarations; | ||
| 1782 | } | 1782 | } |
| 1783 | 1783 | ||
| 1784 | boost::optional<ProgramResult> DecompileProgram(const ProgramCode& program_code, u32 main_offset, | 1784 | boost::optional<ProgramResult> DecompileProgram(const ProgramCode& program_code, u32 main_offset, |