Skip to content

Instantly share code, notes, and snippets.

@Wolfvak
Created October 13, 2017 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wolfvak/1f743e2e927add415ee4e4b85e5f70b1 to your computer and use it in GitHub Desktop.
Save Wolfvak/1f743e2e927add415ee4e4b85e5f70b1 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <unistd.h>
const char *pagetype[] = {
"INVALID", "COARSE PAGE", "SECTION", "FINE PAGE"
};
const char *cachetype[] = {
"NONCACHED NONBUFFERED", "NONCACHED BUFFERED",
"WRITETHROUGH CACHEABLE", "WRITEBACK CACHEABLE"
};
int main(int argc, char *argv[]) {
assert(sizeof(uint32_t) == 4);
printf("ttparse 0.1a by Wolfvak\n");
if (argc > 1) {
printf("Reads from stdin, use `cat` or similar!\n");
return 1;
}
for (int i=0; i<4096; i++) {
uint32_t tte;
read(STDIN_FILENO, &tte, 4);
printf("[%03X00000] -> [%03X00000], DOMAIN %02d, %s, %s\n",
i, (tte & 0xFFF00000)>>20, (tte>>5)&15,
cachetype[(tte >> 2)&3], pagetype[tte&3]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment