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/shared_page.cpp | 86 | ||||
| -rw-r--r-- | src/core/hle/shared_page.h | 69 |
8 files changed, 0 insertions, 263 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/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 | ||