summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/host_memory.cpp4
-rw-r--r--src/common/input.h18
-rw-r--r--src/common/logging/filter.cpp1
-rw-r--r--src/common/logging/types.h1
-rw-r--r--src/common/x64/cpu_detect.cpp12
-rw-r--r--src/common/x64/native_clock.cpp36
6 files changed, 30 insertions, 42 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp
index b44a44949..28949fe5e 100644
--- a/src/common/host_memory.cpp
+++ b/src/common/host_memory.cpp
@@ -1,3 +1,7 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
#ifdef _WIN32
#include <iterator>
diff --git a/src/common/input.h b/src/common/input.h
index eaee0bdea..f775a4c01 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -227,7 +227,7 @@ struct CallbackStatus {
// Triggered once every input change
struct InputCallback {
- std::function<void(CallbackStatus)> on_change;
+ std::function<void(const CallbackStatus&)> on_change;
};
/// An abstract class template for an input device (a button, an analog input, etc.).
@@ -236,14 +236,10 @@ public:
virtual ~InputDevice() = default;
// Request input device to update if necessary
- virtual void SoftUpdate() {
- return;
- }
+ virtual void SoftUpdate() {}
// Force input device to update data regardless of the current state
- virtual void ForceUpdate() {
- return;
- }
+ virtual void ForceUpdate() {}
// Sets the function to be triggered when input changes
void SetCallback(InputCallback callback_) {
@@ -251,7 +247,7 @@ public:
}
// Triggers the function set in the callback
- void TriggerOnChange(CallbackStatus status) {
+ void TriggerOnChange(const CallbackStatus& status) {
if (callback.on_change) {
callback.on_change(status);
}
@@ -266,11 +262,9 @@ class OutputDevice {
public:
virtual ~OutputDevice() = default;
- virtual void SetLED([[maybe_unused]] LedStatus led_status) {
- return;
- }
+ virtual void SetLED([[maybe_unused]] const LedStatus& led_status) {}
- virtual VibrationError SetVibration([[maybe_unused]] VibrationStatus vibration_status) {
+ virtual VibrationError SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) {
return VibrationError::NotSupported;
}
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index 42744c994..b898a652c 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -114,6 +114,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
SUB(Service, NGCT) \
SUB(Service, NIFM) \
SUB(Service, NIM) \
+ SUB(Service, NOTIF) \
SUB(Service, NPNS) \
SUB(Service, NS) \
SUB(Service, NVDRV) \
diff --git a/src/common/logging/types.h b/src/common/logging/types.h
index 2d21fc483..9ed0c7ad6 100644
--- a/src/common/logging/types.h
+++ b/src/common/logging/types.h
@@ -82,6 +82,7 @@ enum class Class : u8 {
Service_NGCT, ///< The NGCT (No Good Content for Terra) service
Service_NIFM, ///< The NIFM (Network interface) service
Service_NIM, ///< The NIM service
+ Service_NOTIF, ///< The NOTIF (Notification) service
Service_NPNS, ///< The NPNS service
Service_NS, ///< The NS services
Service_NVDRV, ///< The NVDRV (Nvidia driver) service
diff --git a/src/common/x64/cpu_detect.cpp b/src/common/x64/cpu_detect.cpp
index fccd2eee5..fbeacc7e2 100644
--- a/src/common/x64/cpu_detect.cpp
+++ b/src/common/x64/cpu_detect.cpp
@@ -71,9 +71,6 @@ static CPUCaps Detect() {
else
caps.manufacturer = Manufacturer::Unknown;
- u32 family = {};
- u32 model = {};
-
__cpuid(cpu_id, 0x80000000);
u32 max_ex_fn = cpu_id[0];
@@ -84,15 +81,6 @@ static CPUCaps Detect() {
// Detect family and other miscellaneous features
if (max_std_fn >= 1) {
__cpuid(cpu_id, 0x00000001);
- family = (cpu_id[0] >> 8) & 0xf;
- model = (cpu_id[0] >> 4) & 0xf;
- if (family == 0xf) {
- family += (cpu_id[0] >> 20) & 0xff;
- }
- if (family >= 6) {
- model += ((cpu_id[0] >> 16) & 0xf) << 4;
- }
-
if ((cpu_id[3] >> 25) & 1)
caps.sse = true;
if ((cpu_id[3] >> 26) & 1)
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp
index 87de40624..82ee2c8a1 100644
--- a/src/common/x64/native_clock.cpp
+++ b/src/common/x64/native_clock.cpp
@@ -15,26 +15,26 @@
namespace Common {
u64 EstimateRDTSCFrequency() {
- const auto milli_10 = std::chrono::milliseconds{10};
- // get current time
+ // Discard the first result measuring the rdtsc.
_mm_mfence();
- const u64 tscStart = __rdtsc();
- const auto startTime = std::chrono::high_resolution_clock::now();
- // wait roughly 3 seconds
- while (true) {
- auto milli = std::chrono::duration_cast<std::chrono::milliseconds>(
- std::chrono::high_resolution_clock::now() - startTime);
- if (milli.count() >= 3000)
- break;
- std::this_thread::sleep_for(milli_10);
- }
- const auto endTime = std::chrono::high_resolution_clock::now();
+ __rdtsc();
+ std::this_thread::sleep_for(std::chrono::milliseconds{1});
+ _mm_mfence();
+ __rdtsc();
+
+ // Get the current time.
+ const auto start_time = std::chrono::steady_clock::now();
+ _mm_mfence();
+ const u64 tsc_start = __rdtsc();
+ // Wait for 200 milliseconds.
+ std::this_thread::sleep_for(std::chrono::milliseconds{200});
+ const auto end_time = std::chrono::steady_clock::now();
_mm_mfence();
- const u64 tscEnd = __rdtsc();
- // calculate difference
- const u64 timer_diff =
- std::chrono::duration_cast<std::chrono::nanoseconds>(endTime - startTime).count();
- const u64 tsc_diff = tscEnd - tscStart;
+ const u64 tsc_end = __rdtsc();
+ // Calculate differences.
+ const u64 timer_diff = static_cast<u64>(
+ std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count());
+ const u64 tsc_diff = tsc_end - tsc_start;
const u64 tsc_freq = MultiplyAndDivide64(tsc_diff, 1000000000ULL, timer_diff);
return tsc_freq;
}