Several changes for timestamp bundle:

Fully defined the structure.
Single copy of it + single timer across all modules, managing it is now the responsibility of KernelState.

add global_critical_region::PrepareToAcquire, which uses Prefetchw on the global crit. We now know we can use Prefetchw on all cpus that have AVX.
add  KeQueryInterruptTime, which is used by some dashboards.

add threading::NanoSleep
This commit is contained in:
chss95cs@gmail.com
2023-04-16 10:08:01 -04:00
parent 12c9135843
commit ab21e1e0f0
15 changed files with 147 additions and 54 deletions

View File

@@ -17,6 +17,7 @@
#include <memory>
#include <vector>
#include "achievement_manager.h"
#include "xenia/base/bit_map.h"
#include "xenia/base/cvar.h"
#include "xenia/base/mutex.h"
@@ -30,7 +31,6 @@
#include "xenia/memory.h"
#include "xenia/vfs/virtual_file_system.h"
#include "xenia/xbox.h"
#include "achievement_manager.h"
namespace xe {
class ByteStream;
@@ -88,6 +88,17 @@ struct TerminateNotification {
uint32_t priority;
};
// structure for KeTimeStampBuindle
// a bit like the timers on KUSER_SHARED on normal win32
// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm
struct X_TIME_STAMP_BUNDLE {
uint64_t interrupt_time;
// i assume system_time is in 100 ns intervals like on win32
uint64_t system_time;
uint32_t tick_count;
uint32_t padding;
};
class KernelState {
public:
explicit KernelState(Emulator* emulator);
@@ -234,6 +245,14 @@ class KernelState {
bool Restore(ByteStream* stream);
uint32_t notification_position_ = 2;
uint32_t GetKeTimestampBundle();
XE_NOINLINE
XE_COLD
uint32_t CreateKeTimestampBundle();
void UpdateKeTimestampBundle();
private:
void LoadKernelModule(object_ref<KernelModule> kernel_module);
@@ -271,7 +290,8 @@ class KernelState {
std::list<std::function<void()>> dispatch_queue_;
BitMap tls_bitmap_;
uint32_t ke_timestamp_bundle_ptr_ = 0;
std::unique_ptr<xe::threading::HighResolutionTimer> timestamp_timer_;
friend class XObject;
};