Reading from physical addresses..
strauman at slac.stanford.edu
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 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 220.127.116.11 (HELO mail.oarcorp.com)
>> by smtp.c007.snv.cp.net (18.104.22.168) 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>
>>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>
>>X-Sender: shingole at opal
>>To: rtems-users at oarcorp.com
>> 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
>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.
>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?
>RUE DE LA GARE
>LE CLOS DES GENETS, VILLA 51
>TELEPHONE: 04 72 08 99 25
>PORTABLE : 06 80 38 54 10
>EMAIL : correo at fernando-ruiz.com
More information about the users