Reading from physical addresses..

Ralf Corsepius corsepiu at faw.uni-ulm.de
Fri May 2 11:05:22 UTC 2003


Am Fre, 2003-05-02 um 12.26 schrieb Fernando RUIZ:
> On Thu, 1 May 2003 23:24:29 -0400 (EDT), Shailesh Hingole wrote:
> 
> > Message-Id: <Pine.SOL.4.21.0305012317230.21925-100000 at opal>
> > List-Help: <mailto:rtems-users-help at oarcorp.com>
> > List-Unsubscribe: <mailto:rtems-users-unsubscribe at oarcorp.com>
> > From: Shailesh Hingole <shingole at cs.binghamton.edu>
> > Date: Thu, 1 May 2003 23:24:29 -0400 (EDT)
> > Received: (cpmta 5901 invoked from network); 1 May 2003 20:26:01 -0700
> > Received: from 216.107.91.226 (HELO mail.oarcorp.com)
> > 	by smtp.c007.snv.cp.net (209.228.33.248) with SMTP; 1 May 2003 20:26:01 -0700
> > Received: (qmail 19729 invoked by uid 330); 2 May 2003 03:24:32 -0000
> > Received: (qmail 19723 invoked from network); 2 May 2003 03:24:32 -0000
> > Mailing-List: contact rtems-users-help at oarcorp.com; run by ezmlm
> > Content-Type: TEXT/PLAIN; charset=US-ASCII
> > X-Received: 2 May 2003 03:26:01 GMT
> > List-Post: <mailto:rtems-users at oarcorp.com>
> > Subject: Reading from physical addresses..
> > In-Reply-To: <3EB119D5.A4BAF0BC at OARcorp.com>
> > List-Subscribe: <mailto:rtems-users-subscribe at oarcorp.com>
> > X-No-Archive: yes
> > Precedence: bulk
> > Delivered-To: fernando-ruiz.com%correo at fernando-ruiz.com
> > Delivered-To: mailing list rtems-users at oarcorp.com
> > Return-Path: <rtems-users-return-7579-correo=fernando-ruiz.com at oarcorp.com>
> > MIME-Version: 1.0
> > X-Sender: shingole at opal
> > To: rtems-users at oarcorp.com
> > 
> > 
> > Hi there,
> >  I need to read from a range of physical addresses (for
> > ex. 0x000-0x1000) from an application in RTEMS. When I say that, these are
> > the actual locations on the physical memory and not on the process address
> > space. 
> > 
> > What is the best way to do it?
> > 
> > Is it possible to do it from an application?
> > 
> 
> Hi,
>   My experience is that you are free to build a C pointer in order to read/write the I/O memory
> mapped space.
> 
> unsigned short char * pb = (unsigned short char *) 0x008000;
> 
> *pb=15  by example.
Generally speaking, no. This is highly cpu (and sometime BSP) dependent.
It works on some cpus but doesn't on others. 

It depends on various factors such as presence of a MMU and memory
management in general.

Additionally, even if it works (physical memory == virtual memory) you
normally want to use some volatile pointers somewhere:

cf. cpukit/score/cpu/sh/rtems/score/sh_io.h

> You can do this always like a label in your link file memory map and declare like an external
> variable in your C program.
> 
> The physical memory is the real memory at least in my experience (sh HITACHI and pc386 cpus).
This is correct for the SH1 and SH2, but doesn't hold for newer SHes and
the i*86 family in general.

> Drivers need to do this. I have flash memory, rtc, uarts, and more devices and always I declare a
> structure and declare like external variable from C. 
> I can set up the memory adress after in the link file when the linking process.
> 
> Is it right for all CPU's?

No, cf. above.

Ralf





More information about the users mailing list