linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Memory map?
@ 2000-09-30  7:36 Jari
  2000-10-01 21:31 ` Dan Malek
  2000-10-02 14:51 ` TWG - pat, mark & steve
  0 siblings, 2 replies; 3+ messages in thread
From: Jari @ 2000-09-30  7:36 UTC (permalink / raw)
  To: linuxppc-embedded


Hello,

After booting kernel, I want to access the physical address in rom ,
for example:
my rom begins at 0xFE00 0000, and I want to read 1 byte at this address.

currently, the MMU has been turned on, the RAM begin at 0x0C00 0000,
and I don't know what the address of the ROM is.

what do I have to do?
is there anybody know how to take the address of the ROM?

Help me, pls.
Thank you,
Jari

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Memory map?
  2000-09-30  7:36 Memory map? Jari
@ 2000-10-01 21:31 ` Dan Malek
  2000-10-02 14:51 ` TWG - pat, mark & steve
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Malek @ 2000-10-01 21:31 UTC (permalink / raw)
  To: jari.nguyen; +Cc: linuxppc-embedded


Jari wrote:

> After booting kernel, I want to access the physical address in rom ,
> for example:
> my rom begins at 0xFE00 0000, and I want to read 1 byte at this address.

When exactly do you want to do this, is it in the kernel or by an
application, and what kind of system are you using?  There are many
ways to do this....


	-- Dan

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Memory map?
  2000-09-30  7:36 Memory map? Jari
  2000-10-01 21:31 ` Dan Malek
@ 2000-10-02 14:51 ` TWG - pat, mark & steve
  1 sibling, 0 replies; 3+ messages in thread
From: TWG - pat, mark & steve @ 2000-10-02 14:51 UTC (permalink / raw)
  To: Jari; +Cc: linuxppc-embedded


Jari,
I take it you're trying to do this from an application (i.e. not within
the kernel).  Here is a (hack) piece of code which performs a similar
task.  I use it to access a dual-port RAM connecting me to another
processor.  First, it needs access to the (860T)'s internal memory map, to
set up the chip selects so that CS5 decodes at 0x50000000.  Then it gets a
pointer I can use to access the memory.  You probably only need to do the
last mmap (and the fopen of /dev/mem!), since (presumably) there are
already chip selects decoding your ROM.  (additional comments after the
code)

#include <stdio.h>
#include <asm/io.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

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

char *MapDpRam(void)
{
  int *paddr1;
  char *paddr2;
  int fd;
  // figure out the page size (since we can only mmap in pagesize
increments)
  size_t size = getpagesize();
  // get an FD to /dev/mem
  fd = open("/dev/mem",O_RDWR);
  // these 3 lines change the internal chip-selects in the 860T
  paddr1 = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0xfa200000);
  *(paddr1+0x4b) = 0xffff8d84;
  *(paddr1+0x4a) = 0x50007401;
  // done messing with chip-selects, unmap them
  munmap(paddr1,size);
  // this one does the real work, gives me a pointer which, when accessed,
points to the memory at physical address 50000000
  paddr2 = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x50000000);
  return(paddr2);
}

Notes: It's a bit sloppy, I assume that getpagesize() returns at least 1K
(which is all I need).  If you need more space, you will have to set
"size" to some multiple of pagesize that's big enough.  It also assumes it
knows where the MCR points to (0xfa200000) rather than reading it directly
(I'm too lazy to figure out how to do that! :)
Hope it helps...

Mark Phillips


On Sat, 30 Sep 2000, Jari wrote:

>
> Hello,
>
> After booting kernel, I want to access the physical address in rom ,
> for example:
> my rom begins at 0xFE00 0000, and I want to read 1 byte at this address.
>
> currently, the MMU has been turned on, the RAM begin at 0x0C00 0000,
> and I don't know what the address of the ROM is.
>
> what do I have to do?
> is there anybody know how to take the address of the ROM?
>
> Help me, pls.
> Thank you,
> Jari
>
>

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-10-02 14:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-09-30  7:36 Memory map? Jari
2000-10-01 21:31 ` Dan Malek
2000-10-02 14:51 ` TWG - pat, mark & steve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).