diff --git a/Lib/VideoCore/RegisterMap.cpp b/Lib/VideoCore/RegisterMap.cpp index 6050e11..8629482 100644 --- a/Lib/VideoCore/RegisterMap.cpp +++ b/Lib/VideoCore/RegisterMap.cpp @@ -14,7 +14,8 @@ enum { V3D_BASE = (0xc00000 >> 2), V3D_IDENT0 = 0, V3D_IDENT1, - V3D_IDENT2 + V3D_IDENT2, + V3D_L2CACTL = (0x00020 >> 2) }; std::unique_ptr RegisterMap::m_instance; @@ -72,6 +73,30 @@ int RegisterMap::numQPUPerSlice() { } +int RegisterMap::numTMUPerSlice() { + return (readRegister(V3D_IDENT1) >> 12) & 0xf; +} + + +/** + * @brief get the size of the VPM. + * + * @return Size of VPM in KB + */ +int RegisterMap::VPMSize() { + uint32_t reg = readRegister(V3D_IDENT1); + int value = (reg >> 28) & 0xf; + + if (value == 0) return 16; // According to reference doc p.97 + return value; +} + + +int RegisterMap::L2CacheEnabled() { + return (readRegister(V3D_L2CACTL) & 0x1); +} + + RegisterMap *RegisterMap::instance() { if (m_instance.get() == nullptr) { m_instance.reset(new RegisterMap); diff --git a/Lib/VideoCore/RegisterMap.h b/Lib/VideoCore/RegisterMap.h index 5c293f2..caab0a0 100644 --- a/Lib/VideoCore/RegisterMap.h +++ b/Lib/VideoCore/RegisterMap.h @@ -10,9 +10,8 @@ namespace QPULib { /** * @brief interface for the VideoCore registers. * - * This implementation is far from complete. It only reads - * two fields from a single register. Regard it as a proof of - * concept which can be expanded as needed. + * This implementation is far from complete. + * The reading of more registers can be added as needed. * * Implemented as singleton with lazy load, so that it's * not initialized when it's not used. @@ -25,7 +24,10 @@ class RegisterMap { ~RegisterMap(); static int numSlices(); + static int numTMUPerSlice(); static int numQPUPerSlice(); + static int VPMSize(); + static int L2CacheEnabled(); private: RegisterMap(); diff --git a/Tools/detectPlatform.cpp b/Tools/detectPlatform.cpp index 25afbea..0d26981 100644 --- a/Tools/detectPlatform.cpp +++ b/Tools/detectPlatform.cpp @@ -120,8 +120,11 @@ int main(int argc, char *argv[]) { printf("Hardware revision: %04x\n", revision); if (geteuid() == 0) { // Only do this as root (sudo) - printf("Number of slices: %d\n", RegisterMap::numSlices()); - printf("Number of QPU's per slice: %d\n", RegisterMap::numQPUPerSlice()); + printf("Number of slices : %d\n", RegisterMap::numSlices()); + printf("QPU's per slice : %d\n", RegisterMap::numQPUPerSlice()); + printf("TMU's per slice : %d\n", RegisterMap::numTMUPerSlice()); + printf("Size of VPM : %dKB\n", RegisterMap::VPMSize()); + printf("L2 Cache enabled : %s\n", (RegisterMap::L2CacheEnabled())? "yes": "no"); } else { printf("You can see more if you use sudo\n"); }