comp.lang.ada
 help / color / mirror / Atom feed
* Re: Types defining h/w r/o or w/o registers
@ 1991-06-05 18:59 John Goodenough
  0 siblings, 0 replies; 13+ messages in thread
From: John Goodenough @ 1991-06-05 18:59 UTC (permalink / raw)


In article Re: Types defining h/w r/o or w/o registers of 4 Jun 91 14:48:21
GMT als@bohra.cpg.oz.au (Anthony Shipman) writes:

>Wasn't there something in the tasking part of the language for this?  Ada's
>multi-tasking model is shared memory between tasks.  I vaguely recall there
was
>a pragma, or something in the machine-dependant chapter, to declare certain
>memory locations as volatile.  Certainly what you have is logically
equivalent
>to multi-tasking except that one of the tasks is implemented in hardware.

You are talking here about pragma SHARED, which is not suitable for use with
volatile data.  The Ada 9X study report on shared variables (available from
the usual sources) discusses why pragma SHARED doesn't fit the bill.

John B. Goodenough					Goodenough@sei.cmu.edu
Software Engineering Institute				412-268-6391

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: Types defining h/w r/o or w/o registers
@ 1991-06-06  3:02 Steven V. Case
  1991-06-09  0:15 ` rharwood
  0 siblings, 1 reply; 13+ messages in thread
From: Steven V. Case @ 1991-06-06  3:02 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Types defining h/w r/o or w/o registers
@ 1991-05-30 13:03 Don Gardner
  1991-05-31 17:03 ` david.c.willett
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Don Gardner @ 1991-05-30 13:03 UTC (permalink / raw)


Is there some way to define a type such that all variables of that
type can be only read or only written?  For instance, I have a type that
defines the status register of some peripheral which can only be 
read.  It would be best if the compiler could flag any assignments 
to variables of such a type as errors.

Is there some other means for commonly handling this problem?  The 
compiler being used is VADSWorks, if an implementation-defined solution
is required.

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

end of thread, other threads:[~1991-06-09  0:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-06-05 18:59 Types defining h/w r/o or w/o registers John Goodenough
  -- strict thread matches above, loose matches on Subject: below --
1991-06-06  3:02 Steven V. Case
1991-06-09  0:15 ` rharwood
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

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