Reading from physical addresses..

Till Straumann strauman at
Fri May 2 14:56:49 UTC 2003

Fernando RUIZ wrote:

>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>
>>List-Unsubscribe: <mailto:rtems-users-unsubscribe at>
>>From: Shailesh Hingole <shingole at>
>>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 (HELO
>>	by ( 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; 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>
>>Subject: Reading from physical addresses..
>>In-Reply-To: <3EB119D5.A4BAF0BC at>
>>List-Subscribe: <mailto:rtems-users-subscribe at>
>>X-No-Archive: yes
>>Precedence: bulk
>>Delivered-To: at
>>Delivered-To: mailing list rtems-users at
>>Return-Path: < at>
>>MIME-Version: 1.0
>>X-Sender: shingole at opal
>>To: rtems-users at
>>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
>>What is the best way to do it?
>>Is it possible to do it from an application?
>  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.
NO, that's a bad idea. Doing I/O this way breaks e.g. when you switch to 
a CPU of different endianness.
There might be other CPU specific issues. Your approach makes porting a 
driver difficult because it's
hard to find the places where I/O is done. Use specific macros or inline 
functions for IO (plus, you
should declare the IO address a 'volatile' variable). RTEMS (at least on 
some architectures) has
libcpu/io.h which can/should be used.

-- Till

>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).
>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?
>69730 GENAY
>TELEPHONE: 04 72 08 99 25
>PORTABLE : 06 80 38 54 10      
>EMAIL    : correo at

More information about the users mailing list