// SPDX-License-Identifier: GPL-2.0-only /* * Exercise /dev/mem mmap cases that have been troublesome in the past * * (c) Copyright 2007 Hewlett-Packard Development Company, L.P. * Bjorn Helgaas <bjorn.helgaas@hp.com>
*/
if (fnmatch(file, name, 0) == 0) {
rc = read_rom(path2);
/* * It's OK if the ROM is unreadable. Maybe there * is no ROM, or some other error occurred. The * important thing is that no MCA happened.
*/ if (rc > 0)
fprintf(stderr, "PASS: %s read %d bytes\n", path2, rc); else {
fprintf(stderr, "PASS: %s not readable\n", path2); return rc;
}
} else {
r = lstat(path2, &buf); if (r == 0 && S_ISDIR(buf.st_mode)) {
rc = scan_rom(path2, file); if (rc < 0) return rc;
}
}
if (map_mem("/dev/mem", 0, 0xA0000, 1) == 0)
fprintf(stderr, "PASS: /dev/mem 0x0-0xa0000 is readable\n"); else
fprintf(stderr, "FAIL: /dev/mem 0x0-0xa0000 not accessible\n");
/* * It's not safe to blindly read the VGA frame buffer. If you know * how to poke the card the right way, it should respond, but it's * not safe in general. Many machines, e.g., Intel chipsets, cover * up a non-responding card by just returning -1, but others will * report the failure as a machine check.
*/ if (map_mem("/dev/mem", 0xA0000, 0x20000, 0) == 0)
fprintf(stderr, "PASS: /dev/mem 0xa0000-0xc0000 is mappable\n"); else
fprintf(stderr, "FAIL: /dev/mem 0xa0000-0xc0000 not accessible\n");
if (map_mem("/dev/mem", 0xC0000, 0x40000, 1) == 0)
fprintf(stderr, "PASS: /dev/mem 0xc0000-0x100000 is readable\n"); else
fprintf(stderr, "FAIL: /dev/mem 0xc0000-0x100000 not accessible\n");
/* * Often you can map all the individual pieces above (0-0xA0000, * 0xA0000-0xC0000, and 0xC0000-0x100000), but can't map the whole * thing at once. This is because the individual pieces use different * attributes, and there's no single attribute supported over the * whole region.
*/
rc = map_mem("/dev/mem", 0, 1024*1024, 0); if (rc == 0)
fprintf(stderr, "PASS: /dev/mem 0x0-0x100000 is mappable\n"); elseif (rc > 0)
fprintf(stderr, "PASS: /dev/mem 0x0-0x100000 not mappable\n"); else
fprintf(stderr, "FAIL: /dev/mem 0x0-0x100000 not accessible\n");
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.