[ELDK] R: R: Userland memory access

Detlev Zundel dzu at denx.de
Fri Oct 15 11:44:08 CEST 2010


Hi Luigi,

> I'm using a TMQ885D board with kernel 2.4.25. 

Wow, applied archeology ;)

> 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); 	

Ok.

> 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)

As far as I can tell (2.4 is a long time ago), this seems ok.  I assume
you still did setup a correct mapping with ioremap() before, correct?

> And in my application:
>
> ptr_mem = mmap(0,0x80000,(PROT_READ|PROT_WRITE),MAP_SHARED,DP_Fd,0);

Also looks ok.

> 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.

Hm, are you sure that you did the ioremap() in the driver?

Cheers
  Detlev

-- 
Two  monks went  fishing in an  electron river.  The first monk drew out his
network, and out flopped a hacker.  The second monk cried, "The poor hacker!
How can  it live outside of the  network?"   The first monk said,  "When you
have learned to live outside the network, then you will know."
--
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