Last active
July 15, 2024 17:11
-
-
Save cyyself/295113206e0fc6a26860a4b6847cbe16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstdint> | |
#include <fcntl.h> | |
#include <sys/mman.h> | |
#include <unistd.h> | |
void dump_regs(volatile void *regs) { | |
for (int i=0;i<122;i++) { | |
uint32_t ctl_reg = *(uint32_t *)(regs + 0x1000 * i); | |
uint32_t io_reg = *(uint32_t *)(regs + 0x1000 * i + 0x4); | |
bool oe = ctl_reg >> 9 & 1; | |
printf("%02d: CTL: 0x%08x, IO: 0x%08x, oe=%d\n", i, ctl_reg, io_reg, oe); | |
} | |
} | |
int main() { | |
int mem_fd = open("/dev/mem", O_RDWR | O_SYNC); | |
volatile void *regs = mmap(0, 0x300000, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, 0x1000000); | |
dump_regs(regs); | |
return 0; | |
} |
Author
cyyself
commented
Jul 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment