* mmap : please help !
@ 2005-04-13 16:17 scarayol
0 siblings, 0 replies; 3+ messages in thread
From: scarayol @ 2005-04-13 16:17 UTC (permalink / raw)
To: akpm; +Cc: linuxppc-embedded
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
----------------------------------------------------------
=
^ permalink raw reply [flat|nested] 3+ messages in thread* mmap : please help !
@ 2005-04-13 16:19 scarayol
0 siblings, 0 replies; 3+ messages in thread
From: scarayol @ 2005-04-13 16:19 UTC (permalink / raw)
To: akpm; +Cc: linuxppc-embedded
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
----------------------------------------------------------
=
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: mmap : please help !
@ 2005-04-13 16:33 Fillod Stephane
0 siblings, 0 replies; 3+ messages in thread
From: Fillod Stephane @ 2005-04-13 16:33 UTC (permalink / raw)
To: scarayol; +Cc: linuxppc-embedded
Sophie CARAYOL wrote:
[...]
> What is the good manner to read or write in the physical memory?
Please have a look at Denx's FAQ for accessing memory bus:
=20
http://www.denx.de/twiki/bin/view/PPCEmbedded/DeviceDrivers#Section_Acce
ssingPeripheralsFromUserSpace
or shorter: http://tinyurl.com/6c7th
Depending on the O_SYNC flag passed to open, the mmap'ed memory will be
accessed through non guarded cache or not. See linux/drivers/char/mem.c.
The ppc instruction "eieio" deals with I/O ordering.
Kenavo
--=20
Stephane
PS: be careful not sending twice the same mail to the list=20
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-04-13 16:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-13 16:17 mmap : please help ! scarayol
-- strict thread matches above, loose matches on Subject: below --
2005-04-13 16:19 scarayol
2005-04-13 16:33 Fillod Stephane
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox