mmap : please help !
From: <hidden>
Date: 2005-04-13 16:18:24
Hi all,
I need somme help : I wrote driver like /dev/mem to read and write into=
physical memory at specific addresses. For that, I use instruction mmap=
like that :
if((mem_mc_fd =3D open("/dev/map_mc",O_RDWR | O_SYNC)) < 0)
{
printf("\nProbleme pour ouvrir /dev/map_mc\n");
exit(-1);
}
// mapping de la zone correspondante
pmapMC =3D (DisqueMC *)mmap (0,MC_SIZE, PROT_READ | PROT_WRITE |
PROT_EXEC, MAP_SHARED, mem_mc_fd, MC_BASE_ADDRESS);
if (pmapMC =3D=3D MAP_FAILED)
{
printf("Erreur de mmap pour MC:%d,%s\n",errno, strerror(errno))=
;
close(mem_mc_fd);
}
I use function pread, pwrite to access datas within the driver function=
s
but, I should prefer to use pmapMC pointer (by the mean of this virtual=
address) that points to a structure. I thought that it was the same to
access to the physical memory to use the pointer or to use read, write =
on
the file (by mem_mc_fd), but it seems to have different results. What i=
s
wrong ? What is the good manner to read or write in the physical memory=
?
Thanks a lot.
----------------------------------------------------------
Sophie CARAYOL
TECHNOLOGIES & SYSTEMES
50 rue du Pr=E9sident Sadate
F - 29337 QUIMPER CEDEX
T=E9l: +33 2 98 10 30 06
mailto:scarayol@assystembrime.com
----------------------------------------------------------
=