devmem to tabs

This commit is contained in:
Ciro Santilli
2017-06-28 07:14:21 +01:00
parent 7ae74bfcce
commit 88f1211409
2 changed files with 20 additions and 20 deletions

View File

@@ -209,7 +209,6 @@ static int pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
* after boot with device_add: * after boot with device_add:
* https://stackoverflow.com/questions/44740254/how-to-handle-interrupts-from-a-pci-device-that-already-have-a-non-shareable-han?noredirect=1#comment76558680_44740254 * https://stackoverflow.com/questions/44740254/how-to-handle-interrupts-from-a-pci-device-that-already-have-a-non-shareable-han?noredirect=1#comment76558680_44740254
*/ */
pr_info("pdev->irq %u\n", pdev->irq);
if (request_irq(pdev->irq, irq_handler, IRQF_SHARED, "pci_irq_handler0", &major) < 0) { if (request_irq(pdev->irq, irq_handler, IRQF_SHARED, "pci_irq_handler0", &major) < 0) {
dev_err(&(dev->dev), "request_irq\n"); dev_err(&(dev->dev), "request_irq\n");
goto error; goto error;
@@ -242,7 +241,7 @@ static int pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
pci_read_config_byte(pdev, i, &val); pci_read_config_byte(pdev, i, &val);
pr_info("config %x %x\n", i, val); pr_info("config %x %x\n", i, val);
} }
pr_info("irq %x\n", pdev->irq); pr_info("pdev->irq %x\n", pdev->irq);
/* Initial value of the IO memory. */ /* Initial value of the IO memory. */
for (i = 0; i < 0x28; i += 4) { for (i = 0; i < 0x28; i += 4) {

View File

@@ -17,26 +17,27 @@ Confirm memory from QEMU monitor with:
#include <unistd.h> #include <unistd.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc < 3) { if (argc < 3) {
printf("Usage: %s <phys_addr> <len>\n", argv[0]); printf("Usage: %s <phys_addr> <len>\n", argv[0]);
return 0; return 0;
} }
off_t offset = strtoul(argv[1], NULL, 0); off_t offset = strtoul(argv[1], NULL, 0);
size_t len = strtoul(argv[2], NULL, 0); size_t len = strtoul(argv[2], NULL, 0);
size_t pagesize = sysconf(_SC_PAGE_SIZE); size_t pagesize = sysconf(_SC_PAGE_SIZE);
off_t page_base = (offset / pagesize) * pagesize; off_t page_base = (offset / pagesize) * pagesize;
off_t page_offset = offset - page_base; off_t page_offset = offset - page_base;
int fd = open("/dev/mem", O_SYNC); int fd = open("/dev/mem", O_SYNC);
size_t reallen = page_offset + len; size_t reallen = page_offset + len;
unsigned char *mem = mmap(NULL, reallen, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, page_base); unsigned char *mem = mmap(NULL, reallen, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, page_base);
if (mem == MAP_FAILED) { if (mem == MAP_FAILED) {
perror("mmap"); /* TODO why does it fail for some addreses but not for others? */
perror("mmap");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
printf("%02x ", (unsigned int)mem[page_offset + i]); printf("%02x ", (unsigned int)mem[page_offset + i]);
/* TODO can't edit memory? */ /* TODO can't edit memory? */
mem[page_offset + i] = i % 256; mem[page_offset + i] = i % 256;
} }
puts(""); puts("");
@@ -44,5 +45,5 @@ int main(int argc, char *argv[]) {
perror("munmap"); perror("munmap");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }