16 #pragma warning( disable: 4251 )
26#include <CArcDeviceDllMain.h>
27#include <CArcStringList.h>
30using namespace std::string_literals;
70 template<
typename T = std::u
int32_t> std::uint64_t readConfigSpaceRegister( std::uint64_t uiAddress );
79 template<
typename T = std::u
int32_t>
void writeConfigSpaceRegister( std::uint32_t uiAddress, std::uint32_t uiValue );
134 template<
typename T = std::u
int32_t>
auto registerToStream( std::ostream& oss,
const std::string& sRegName, std::uint64_t& uiAddress, std::size_t uiDotLength = 58 )
136 auto uiRegValue = readConfigSpaceRegister<T>( uiAddress );
138 oss <<
"0x" << std::setfill(
'0' ) << std::setw( 2 ) << uiAddress << setDots( (
"\t" + sRegName ), uiDotLength,
' ' )
139 <<
"0x" << std::uppercase << std::setw( 8 ) << std::hex << uiRegValue << std::endl;
141 uiAddress +=
sizeof( T );
151 virtual bool readConfigSpace8( std::uint64_t uiAddress, std::uint64_t* pRegValue )
const noexcept = 0;
158 virtual bool readConfigSpace16( std::uint64_t uiAddress, std::uint64_t* pRegValue )
const noexcept = 0;
165 virtual bool readConfigSpace32( std::uint64_t uiAddress, std::uint64_t* pRegValue )
const noexcept = 0;
172 virtual bool readConfigSpace64( std::uint64_t uiAddress, std::uint64_t* pRegValue )
const noexcept = 0;
179 virtual bool writeConfigSpace8(
const std::uint32_t uiAddress,
const std::uint32_t uiValue )
const noexcept = 0;
186 virtual bool writeConfigSpace16(
const std::uint32_t uiAddress,
const std::uint32_t uiValue )
const noexcept = 0;
193 virtual bool writeConfigSpace32(
const std::uint32_t uiAddress,
const std::uint32_t uiValue )
const noexcept = 0;
206 std::uint64_t uiRegValue = 0;
208 if constexpr ( std::is_same_v<T, std::uint8_t> )
210 if ( !readConfigSpace8( uiAddress, &uiRegValue ) )
212 #ifdef __cpp_lib_format
224 else if constexpr ( std::is_same_v<T, std::uint16_t> )
226 if ( !readConfigSpace16( uiAddress, &uiRegValue ) )
228 #ifdef __cpp_lib_format
240 else if constexpr ( std::is_same_v<T, std::uint32_t> )
242 if ( !readConfigSpace32( uiAddress, &uiRegValue ) )
244 #ifdef __cpp_lib_format
256 else if constexpr ( std::is_same_v<T, std::uint64_t> )
258 if ( !readConfigSpace64( uiAddress, &uiRegValue ) )
260 #ifdef __cpp_lib_format
274 throwArcGen4Error(
"Invalid type for reading PCIe configuration space! Can only be one of std::uint8/16/32/64_t"sv );
289 if constexpr ( std::is_same_v<T, std::uint8_t> )
291 if ( !writeConfigSpace8( uiAddress, uiValue ) )
293 #ifdef __cpp_lib_format
305 else if constexpr ( std::is_same_v<T, std::uint16_t> )
307 if ( !writeConfigSpace16( uiAddress, uiValue ) )
309 #ifdef __cpp_lib_format
321 else if constexpr ( std::is_same_v<T, std::uint32_t> )
323 if ( !writeConfigSpace32( uiAddress, uiValue ) )
325 #ifdef __cpp_lib_format
339 throwArcGen4Error(
"Invalid type for writing PCIe configuration space! Can only be one of std::uint8/16/32_t"sv );
static std::string formatString(const char *pszFmt,...)
static std::uint32_t getSystemError(void) noexcept
static const std::string getSystemErrorMessage(void)
CArcPCIeBase & operator=(CArcPCIeBase &&)=delete
auto registerToStream(std::ostream &oss, const std::string &sRegName, std::uint64_t &uiAddress, std::size_t uiDotLength=58)
virtual bool writeConfigSpace16(const std::uint32_t uiAddress, const std::uint32_t uiValue) const noexcept=0
virtual bool writeConfigSpace32(const std::uint32_t uiAddress, const std::uint32_t uiValue) const noexcept=0
virtual bool readConfigSpace16(std::uint64_t uiAddress, std::uint64_t *pRegValue) const noexcept=0
CArcPCIeBase & operator=(const CArcPCIeBase &)=delete
virtual bool readConfigSpace64(std::uint64_t uiAddress, std::uint64_t *pRegValue) const noexcept=0
void readPCIeCapabilitiesToStream(std::ostream &oss, bool bShowExtended=false, std::size_t uiDotLength=58)
virtual bool readConfigSpace8(std::uint64_t uiAddress, std::uint64_t *pRegValue) const noexcept=0
CArcPCIeBase(const CArcPCIeBase &)=delete
CArcPCIeBase(CArcPCIeBase &&)=delete
static const std::string m_printSeperator
CArcPCIeBase(void)=default
void writeConfigSpaceRegister(std::uint32_t uiAddress, std::uint32_t uiValue)
std::uint64_t readConfigSpaceRegister(std::uint64_t uiAddress)
virtual ~CArcPCIeBase(void)=default
** Default constructor
virtual bool writeConfigSpace8(const std::uint32_t uiAddress, const std::uint32_t uiValue) const noexcept=0
const std::string readConfigSpaceExpanded(void)
const std::string readConfigSpace(void)
virtual bool readConfigSpace32(std::uint64_t uiAddress, std::uint64_t *pRegValue) const noexcept=0
void throwArcGen4Error(const throwFormat_t<> tFormat, Args &&... args)