[ELDK] R: R: Userland memory access

Luigi Rizzi rizzi at algorab.com
Thu Oct 14 11:07:07 CEST 2010


Hello Detlev,

I'm using a TMQ885D board with kernel 2.4.25. 
In the driver, mapping this external SRAM with a simple ioremap and using
the returned pointer, I'm able to access the memory without problems:

		
	dp_mem_base = ioremap(0x90000000, 0x80000);	

	// write and read first location in SRAM
	*((unsigned long*)dp_mem_base) = 0x11223344;	
	value = *((unsigned long*)dp_mem_base); 	


Now, I would like to access my External SRAM this way also from user-land.
Basically in the mmap entry point I call: 

remap_page_range(vma->vm_start, 0x90000000, 0x80000, vma->vm_page_prot)

And in my application:

ptr_mem = mmap(0,0x80000,(PROT_READ|PROT_WRITE),MAP_SHARED,DP_Fd,0);

But in this case, when I try to use ptr_mem pointer to write directly in
SRAM, I have always  an "EMT trap" with no kernel log. 
Reading things are just a little bit different: sometimes I have the correct
values and  sometimes I have some errors like "EMT trap" or "Floating
exception" with log:

Bad emulation writemem/34
 NIP: 0fef6e60 instruction: 9421ff70 opcode: 25 A: 1 B: 1f C: 1d code: 3b8
rc: 0
 pte @ 0x fef6e60:  (0xc7bc80fc)->(0xc7b94bd8)->0x07e36889
 RPN: 07e36 PP: 2 SPS: 1 SH: 0 CI: 0 v: 1
Kernel VA for NIP 0xc7e36e60  pte @ 0xc7e36e60: no pmd
ttyS: 1 input overrun(s)
Close IDT70V659 module.

I hope everything is clear,
Regards

Luigi





-----Messaggio originale-----
Da: Detlev Zundel [mailto:dzu at denx.de] 
Inviato: mercoledì 13 ottobre 2010 18.00
A: Luigi Rizzi
Cc: 'Stefano Babic'; eldk at lists.denx.de
Oggetto: Re: [ELDK] R: Userland memory access

Hi Luigi,

> I implemented the entry point in my driver and  from user-land with the
> pointer returned from mmap() I can access my SRAM. Unfortunately, every
time
> I try to write I have an "EMT trap". Actually, sometimes I have  this
error
> also reading...
>
> Have you got any idea about this misbehave?

It's about time you provide us with more informatino on the problem in
order for us to help you.  I.e. what kernel version do you work with,
how does your driver implement the mmap call, how do you "try to write"
from userspace, what is the actual error, i.e. provide logs from the
kernel, etc.

As long as we don't have this info, we can only speculate.

Cheers
  Detlev

-- 
Q: What is a compact city?
A: It's a city that can be guarded by finitely many near-sighted
   policemen.
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de



More information about the eldk mailing list