Re: physical memory access

Christer Weinigel (wingel@hog.ctrl-c.liu.se)
4 Mar 1999 16:43:13 -0000


mberti@thesis.deis.unibo.it wrote:
>I can reference only vitrual memory because I can't bypass memory paging
>(even using a kernel module).
>Is it possible to disable paging? Has anyone ever heard of a C function
>that stops paging or able to
>access actual physical addresses? Or is there a different way to do
>things?

If you want to access the BIOS from userspace, do this to map 64
kbytes of memory starting at address 0xf00000 into user space:

#include <unistd.h>
#include <sys/mman.h>

unsigned char *virt;

fd = open("/dev/mem", O_RDWR);

virt = mmap(NULL, 64*1024, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_SHARED, fd, 0xf0000);
if (virt == MAP_FAILED)
panic("mmap failed");

printf("memory address f000:0x1234 contains 0x%x\n", virt[0x1234]);

/Christer

-- 
If it's tourist season, why can't we shoot them?

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/