comp.lang.ada
 help / color / mirror / Atom feed
From: case@shamash.cdc.com (Steven V. Case)
Subject: Re: Types defining h/w r/o or w/o registers
Date: 6 Jun 91 03:02:04 GMT	[thread overview]
Message-ID: <33884@shamash.cdc.com> (raw)


> Well, it's been 2.5 years since I did this, but IMHO "the right way" to do 
> what you are trying is to encapsulate the READ operation in a FUNCTION and the
> WRITE operation in a one-parameter procedure.  Several replies to your message
> correctly stated that you should "hide the operations in a package," but 
> didn't show how to implement the desired functionality.

I was wondering when someone would mention this.  I too agree that this is the
prefered approach.  It is the method that I have used on all of the projects
I have worked on which have had a similar requirement.

I have read several papers addressing the use of LOW_LEVEL_IO to also serve
this purpose.  Unfortunately, I have not had the pleasure to use a compiler
which provides LOW_LEVEL_IO support.  I would be interested in hearing from
anyone who has some "real life" experience with LOW_LEVEL_IO, especially if
it was used in an embedded, real-time system.

Using the READ function and WRITE procedure approach that you mention, the
biggest problem that I have run into is not that of inefficient code generated
due to the procedure calls.  As you pointed out, using PRAGMA INLINE has always
been able to take care of it.  The problem I have had is with compilers that
have been too aggressive in their optimizations.  Specifically, most of the
systems I have developed for have memory-mapped I/O.  On these systems (that
I am familiar with) the I/O will only work if a read or write operation is
performed at the proper address with the properly "sized" access.  

In such systems, problems appear when the hardware expects a 32-bit access
and one attempts to perform the I/O with something other than a 32-bit access.
This is a problem that I have had to work around frequently.  Typically I 
will define a record which describes the content of the I/O register to be
accessed.  Then if the compiler detects that I am only accessing a portion of
the record, it might attempt to "optimize" the access by using an 8-bit or
a 16-bit access rather than a 32-bit access as required by the hardware.

Since I have been able to deliver these systems, there are obvious ways to
work around the "optimizations" if the compiler demonstrates such behavior.
They just require me to write code that is not quite what I would have 
preferred.  I would also like to hear of others experience with memory 
mapped I/O when LOW_LEVEL_IO support is not present.

Regards,
Steve

-- 
  ____  ____        Steve Case - HQG526           email: case@shamash.cdc.com
 / ___||___ \       Control Data Corporation      AT&T : (612) 853-3345
| |___  ___| |      3101 East 80th Street                 
 \____||____/       Bloomington, MN 55425

             reply	other threads:[~1991-06-06  3:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-06-06  3:02 Steven V. Case [this message]
1991-06-09  0:15 ` Types defining h/w r/o or w/o registers rharwood
  -- strict thread matches above, loose matches on Subject: below --
1991-06-05 18:59 John Goodenough
1991-05-30 13:03 Don Gardner
1991-05-31 17:03 ` david.c.willett
1991-05-31 17:10   ` david.c.willett
1991-05-31 17:26 ` J o s e D u a r t e
1991-06-01  8:34   ` Orville R. Weyrich
1991-06-02 16:54 ` rharwood
1991-06-03  7:57   ` Orville R. Weyrich
1991-06-04 14:08     ` John Goodenough
1991-06-04 14:48     ` Anthony Shipman
1991-06-05 13:59       ` John Goodenough
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox