comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@callnetuk.com>
Subject: Re: Help with Atomic_Components and whole array assignment
Date: Thu, 1 Feb 2001 23:38:58 -0000
Date: 2001-02-01T23:38:58+00:00	[thread overview]
Message-ID: <95ctln$ff437$2@ID-25716.news.dfncis.de> (raw)
In-Reply-To: 3A7886A7.F1BB5513@averstar.com

If it's any consolation Tuck, my interpretation of Volatile (nothing to do
with Atomic) would always have been (and still is) that:

   for i in A'Range loop
      A(i) := 0;
   end loop;

where Volatile (or Volatile_Components) applied to A, would generate
A'Length separate copies into memory, in whatever machine code it was.

My interpretation of Atomic would be simply to avoid generating code that
might bugger up multi-task access to the object Atomicked (or its components
if Atomic_Componented). Of course, Atomic shoves in a dose of Volatile
automatically, and quite right too.

I propose a representation attribute, Storage_Operations, of type
System.Storage_Operations.Operation_Profile, which is an array of Boolean
indexed on an enumerated type System.Storage_Operations.Operation_Mode,
which would have a value for every (relevant) kind of basic memory access
the compiler could generate. E.g.:

   package System.Storage_Operations is
      type Operation_Mode is (Read_8, Read_16, Read_32, Write_8, Write_16,
Write_32);
      type Operation_Profile is array (Access_Mode) of Boolean;
   end;

   A: array (...) of ...;
   for A'Storage_Operations use (Read_8, Write_8);

This attribute could be used in a representation clause to specify precisely
which kinds of memory access are allowed for an object or type. Perhaps its
use should imply or require Volatile. It would, of course, be fairly
machine-dependent, but that's unavoidable. It would often allow the
avoidance of assembly; in some situations this could be very valuable.

We could have a package e.g.:

   with Interfaces;
   package System.Port_Access is
      type Port_8_Address is mod 2**16;
      type Port_8_Element is new Interfaces.Unsigned_8;
      type Port_16_Address is mod 2**16;
      type Port_16_Element is new Interfaces.Unsigned_16;
      generic
         type Index_Type is (<>);
      package Arrays_Of is
         type Port_8_Array is array (Index_Type range <>) of Port_8_Element;
         type Port_16_Array is array (Index_Type range <>) of
Port_16_Element;
      end;
      -- also provide for offsets, arithmetic, etc.
   end;

and then:

   Flags: System.Port_Access.Port_16_Element;
   for Flags'Port_Address use 16#012E#;

   subtype Data_Port is Integer range 0..3;
   package Data_IO is System.Port_Access.Arrays_Of(Data_Port)
   Data: Data_IO.Port_8_Array(Data_Port);
   subtype Data_Area is System.Port_Access.Port_8_Address range
16#0120#..16#0123#;
   for Data'Port_Address use Data_Area;

This would often allow assembly to be avoided for port access. Better and
better, eh?

Finally, if I were writing a device driver, in any language, I would want to
look at the machine code produced - very carefully, in places - regardless
of whether it seemed to work or not, just to see what it was really doing.
(But then I'm paranoid like that ;-)

PS: I'm making proposals with the aim of putting them into an actual
compiler which will be used in a specific situation (which involves lots of
device drivers). Helpful criticism or better proposals welcome!

--
Nick Roberts
http://www.AdaOS.org






  parent reply	other threads:[~2001-02-01 23:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-22 11:22 Help with Atomic_Components and whole array assignment r_c_chapman
2001-01-22 12:51 ` Stuart Palin
2001-01-22 14:16   ` mark_lundquist
2001-01-22 16:09     ` Pat Rogers
2001-01-22 16:29     ` Robert Dewar
2001-01-22 19:52       ` Mark Lundquist
2001-01-30 15:54       ` Tucker Taft
2001-01-30 18:20         ` Robert Dewar
2001-01-31  5:08           ` DuckE
2001-01-31  5:57             ` Robert Dewar
2001-02-01  3:31               ` DuckE
2001-02-02 21:38               ` Mark Lundquist
2001-02-02 23:08                 ` Robert Dewar
2001-02-03  1:39                 ` tmoran
2001-01-22 16:21 ` Robert Dewar
2001-01-22 16:39   ` r_c_chapman
2001-01-30 15:57     ` Tucker Taft
2001-01-30 18:26       ` Robert Dewar
2001-01-30 21:30         ` Simon Wright
2001-02-01  6:11           ` Robert Dewar
2001-02-06  0:32         ` Richard Kenner
2001-02-06  3:15           ` Robert Dewar
2001-01-31 10:09       ` Rod Chapman
2001-01-31 21:41         ` Tucker Taft
2001-02-01  5:33           ` Robert Dewar
2001-02-01  9:42           ` Rod Chapman
2001-02-01 18:10             ` Robert Dewar
2001-02-01 13:14           ` SPARK flow analysis (was Help with Atomic_Components and whole array assignment) Stuart Palin
2001-02-01 23:38           ` Nick Roberts [this message]
2001-02-02  3:45             ` Help with Atomic_Components and whole array assignment Robert Dewar
2001-02-07 21:40           ` Nick Williams
replies disabled

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