CoreTiming: Reworked CoreTiming (#3119)
* CoreTiming: New CoreTiming; Add Test for CoreTiming
This commit is contained in:
@@ -38,8 +38,8 @@ namespace HLE {
|
||||
namespace Applets {
|
||||
|
||||
static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets;
|
||||
static u32 applet_update_event =
|
||||
-1; ///< The CoreTiming event identifier for the Applet update callback.
|
||||
/// The CoreTiming event identifier for the Applet update callback.
|
||||
static CoreTiming::EventType* applet_update_event = nullptr;
|
||||
/// The interval at which the Applet update callback will be called, 16.6ms
|
||||
static const u64 applet_update_interval_us = 16666;
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
namespace Kernel {
|
||||
|
||||
/// Event type for the thread wake up event
|
||||
static int ThreadWakeupEventType;
|
||||
static CoreTiming::EventType* ThreadWakeupEventType = nullptr;
|
||||
|
||||
bool Thread::ShouldWait(Thread* thread) const {
|
||||
return status != THREADSTATUS_DEAD;
|
||||
@@ -216,8 +216,7 @@ void Thread::WakeAfterDelay(s64 nanoseconds) {
|
||||
if (nanoseconds == -1)
|
||||
return;
|
||||
|
||||
u64 microseconds = nanoseconds / 1000;
|
||||
CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, callback_handle);
|
||||
CoreTiming::ScheduleEvent(nsToCycles(nanoseconds), ThreadWakeupEventType, callback_handle);
|
||||
}
|
||||
|
||||
void Thread::ResumeFromWait() {
|
||||
|
@@ -14,7 +14,7 @@
|
||||
namespace Kernel {
|
||||
|
||||
/// The event type of the generic timer callback event
|
||||
static int timer_callback_event_type;
|
||||
static CoreTiming::EventType* timer_callback_event_type = nullptr;
|
||||
// TODO(yuriks): This can be removed if Timer objects are explicitly pooled in the future, allowing
|
||||
// us to simply use a pool index or similar.
|
||||
static Kernel::HandleTable timer_callback_handle_table;
|
||||
@@ -57,9 +57,7 @@ void Timer::Set(s64 initial, s64 interval) {
|
||||
// Immediately invoke the callback
|
||||
Signal(0);
|
||||
} else {
|
||||
u64 initial_microseconds = initial / 1000;
|
||||
CoreTiming::ScheduleEvent(usToCycles(initial_microseconds), timer_callback_event_type,
|
||||
callback_handle);
|
||||
CoreTiming::ScheduleEvent(nsToCycles(initial), timer_callback_event_type, callback_handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +86,7 @@ void Timer::Signal(int cycles_late) {
|
||||
|
||||
if (interval_delay != 0) {
|
||||
// Reschedule the timer with the interval delay
|
||||
u64 interval_microseconds = interval_delay / 1000;
|
||||
CoreTiming::ScheduleEvent(usToCycles(interval_microseconds) - cycles_late,
|
||||
CoreTiming::ScheduleEvent(nsToCycles(interval_delay) - cycles_late,
|
||||
timer_callback_event_type, callback_handle);
|
||||
}
|
||||
}
|
||||
|
@@ -117,7 +117,7 @@ constexpr std::array<int, 13> LATENCY_BY_FRAME_RATE{{
|
||||
|
||||
std::array<CameraConfig, NumCameras> cameras;
|
||||
std::array<PortConfig, 2> ports;
|
||||
int completion_event_callback;
|
||||
CoreTiming::EventType* completion_event_callback;
|
||||
|
||||
const ResultCode ERROR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
|
||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
||||
|
@@ -41,9 +41,9 @@ static u32 next_gyroscope_index;
|
||||
static int enable_accelerometer_count; // positive means enabled
|
||||
static int enable_gyroscope_count; // positive means enabled
|
||||
|
||||
static int pad_update_event;
|
||||
static int accelerometer_update_event;
|
||||
static int gyroscope_update_event;
|
||||
static CoreTiming::EventType* pad_update_event;
|
||||
static CoreTiming::EventType* accelerometer_update_event;
|
||||
static CoreTiming::EventType* gyroscope_update_event;
|
||||
|
||||
// Updating period for each HID device. These empirical values are measured from a 11.2 3DS.
|
||||
constexpr u64 pad_update_ticks = BASE_CLOCK_RATE_ARM11 / 234;
|
||||
|
@@ -9,6 +9,10 @@
|
||||
#include "core/frontend/input.h"
|
||||
#include "core/hle/service/ir/ir_user.h"
|
||||
|
||||
namespace CoreTiming {
|
||||
struct EventType;
|
||||
} // namespace CoreTiming
|
||||
|
||||
namespace Service {
|
||||
namespace IR {
|
||||
|
||||
@@ -36,7 +40,7 @@ private:
|
||||
void LoadInputDevices();
|
||||
|
||||
u8 hid_period;
|
||||
int hid_polling_callback_id;
|
||||
CoreTiming::EventType* hid_polling_callback_id;
|
||||
std::array<u8, 0x40> calibration_data;
|
||||
std::unique_ptr<Input::ButtonDevice> zl;
|
||||
std::unique_ptr<Input::ButtonDevice> zr;
|
||||
|
@@ -51,7 +51,7 @@ static_assert(sizeof(SharedMem) == 0x98, "SharedMem has wrong size!");
|
||||
static Kernel::SharedPtr<Kernel::Event> update_event;
|
||||
static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory;
|
||||
static u32 next_pad_index;
|
||||
static int update_callback_id;
|
||||
static CoreTiming::EventType* update_callback_id;
|
||||
static std::unique_ptr<Input::ButtonDevice> zl_button;
|
||||
static std::unique_ptr<Input::ButtonDevice> zr_button;
|
||||
static std::unique_ptr<Input::AnalogDevice> c_stick;
|
||||
|
@@ -76,7 +76,7 @@ static u8 network_channel = DefaultNetworkChannel;
|
||||
static NetworkInfo network_info;
|
||||
|
||||
// Event that will generate and send the 802.11 beacon frames.
|
||||
static int beacon_broadcast_event;
|
||||
static CoreTiming::EventType* beacon_broadcast_event;
|
||||
|
||||
// Mutex to synchronize access to the connection status between the emulation thread and the
|
||||
// network thread.
|
||||
|
@@ -15,7 +15,7 @@ namespace SharedPage {
|
||||
|
||||
SharedPageDef shared_page;
|
||||
|
||||
static int update_time_event;
|
||||
static CoreTiming::EventType* update_time_event;
|
||||
|
||||
/// Gets system time in 3DS format. The epoch is Jan 1900, and the unit is millisecond.
|
||||
static u64 GetSystemTime() {
|
||||
@@ -57,7 +57,7 @@ static void UpdateTimeCallback(u64 userdata, int cycles_late) {
|
||||
|
||||
date_time.date_time = GetSystemTime();
|
||||
date_time.update_tick = CoreTiming::GetTicks();
|
||||
date_time.tick_to_second_coefficient = g_clock_rate_arm11;
|
||||
date_time.tick_to_second_coefficient = BASE_CLOCK_RATE_ARM11;
|
||||
date_time.tick_offset = 0;
|
||||
|
||||
++shared_page.date_time_counter;
|
||||
|
Reference in New Issue
Block a user