staticunsignedlong mmio_address;
module_param_hw(mmio_address, ulong, iomem, 0);
MODULE_PARM_DESC(mmio_address, " Start address of the mapping of 16 kB " "(or 8 MB if read_far is non-zero).");
staticunsignedlong read_far = 0x400100;
module_param(read_far, ulong, 0);
MODULE_PARM_DESC(read_far, " Offset of a 32-bit read within 8 MB " "(default: 0x400100).");
staticvoid do_read_far_test(void __iomem *p)
{
pr_info("read far test.\n");
mmiotrace_printk("Read far test.\n");
ioread32(p + read_far);
}
staticvoid do_test(unsignedlong size)
{ void __iomem *p = ioremap(mmio_address, size); if (!p) {
pr_err("could not ioremap, aborting.\n"); return;
}
mmiotrace_printk("ioremap returned %p.\n", p);
do_write_test(p);
do_read_test(p); if (read_far && read_far < size - 4)
do_read_far_test(p);
iounmap(p);
}
/* * Tests how mmiotrace behaves in face of multiple ioremap / iounmaps in * a short time. We had a bug in deferred freeing procedure which tried * to free this region multiple times (ioremap can reuse the same address * for many mappings).
*/ staticvoid do_test_bulk_ioremapping(void)
{ void __iomem *p; int i;
for (i = 0; i < 10; ++i) {
p = ioremap(mmio_address, PAGE_SIZE); if (p)
iounmap(p);
}
/* Force freeing. If it will crash we will know why. */
synchronize_rcu();
}
staticint __init init(void)
{ unsignedlong size = (read_far) ? (8 << 20) : (16 << 10); int ret = security_locked_down(LOCKDOWN_MMIOTRACE);
if (ret) return ret;
if (mmio_address == 0) {
pr_err("you have to use the module argument mmio_address.\n");
pr_err("DO NOT LOAD THIS MODULE UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!\n"); return -ENXIO;
}
pr_warn("WARNING: mapping %lu kB @ 0x%08lx in PCI address space, " "and writing 16 kB of rubbish in there.\n",
size >> 10, mmio_address);
do_test(size);
do_test_bulk_ioremapping();
pr_info("All done.\n"); return 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.