2022-09-10 21:40:24 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-09-10 21:40:24 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Powered by XM6 TypeG Technology.
|
|
|
|
// Copyright (C) 2016-2020 GIMONS
|
|
|
|
// Copyright (C) 2022 akuker
|
|
|
|
//
|
|
|
|
// [ High resolution timer ]
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-03 04:20:27 +00:00
|
|
|
#include <memory>
|
2022-09-10 21:40:24 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-11-10 06:44:06 +00:00
|
|
|
#include "shared/scsi.h"
|
2022-09-10 21:40:24 +00:00
|
|
|
|
2022-12-03 04:20:27 +00:00
|
|
|
class PlatformSpecificTimer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Default constructor
|
|
|
|
PlatformSpecificTimer() = default;
|
|
|
|
// Default destructor
|
|
|
|
virtual ~PlatformSpecificTimer() = default;
|
|
|
|
// Initialization
|
|
|
|
virtual void Init() = 0;
|
|
|
|
// Get system timer low byte
|
|
|
|
virtual uint32_t GetTimerLow() = 0;
|
|
|
|
// Get system timer high byte
|
|
|
|
virtual uint32_t GetTimerHigh() = 0;
|
|
|
|
// Sleep for N nanoseconds
|
|
|
|
virtual void SleepNsec(uint32_t nsec) = 0;
|
|
|
|
// Sleep for N microseconds
|
|
|
|
virtual void SleepUsec(uint32_t usec) = 0;
|
|
|
|
};
|
|
|
|
|
2022-09-10 21:40:24 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// System timer
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
class SysTimer
|
|
|
|
{
|
2022-12-03 04:20:27 +00:00
|
|
|
public:
|
|
|
|
static void Init();
|
|
|
|
// Get system timer low byte
|
|
|
|
static uint32_t GetTimerLow();
|
|
|
|
// Get system timer high byte
|
|
|
|
static uint32_t GetTimerHigh();
|
|
|
|
// Sleep for N nanoseconds
|
|
|
|
static void SleepNsec(uint32_t nsec);
|
|
|
|
// Sleep for N microseconds
|
|
|
|
static void SleepUsec(uint32_t usec);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool initialized;
|
|
|
|
static bool is_allwinnner;
|
|
|
|
static bool is_raspberry;
|
2022-09-10 21:40:24 +00:00
|
|
|
|
2022-12-03 04:20:27 +00:00
|
|
|
static std::unique_ptr<PlatformSpecificTimer> systimer_ptr;
|
2022-09-10 21:40:24 +00:00
|
|
|
};
|