Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VPM size to detectPlatform output #57

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion Lib/VideoCore/RegisterMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> RegisterMap::m_instance;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions Lib/VideoCore/RegisterMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -25,7 +24,10 @@ class RegisterMap {
~RegisterMap();

static int numSlices();
static int numTMUPerSlice();
static int numQPUPerSlice();
static int VPMSize();
static int L2CacheEnabled();

private:
RegisterMap();
Expand Down
7 changes: 5 additions & 2 deletions Tools/detectPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down