comp.lang.ada
 help / color / mirror / Atom feed
From: anon@att.net
Subject: Re: Memory Access
Date: Mon, 7 Nov 2011 22:03:06 +0000 (UTC)
Date: 2011-11-07T22:03:06+00:00	[thread overview]
Message-ID: <j99kip$pf$1@speranza.aioe.org> (raw)
In-Reply-To: f4a52e5d-2514-4713-a68d-877f09af7ec3@d17g2000yql.googlegroups.com

Normally, Address is used for interfacing other languages and 
Machine_Code programming. Under Ada the standard is to use the 
"Access" statements such as 

  Dev_0 := Dev_Table ( index ) 'Access ;

then use 
  Dev0.all to reference  Dev_Table ( index ) 'Access ;


The 

  for Dev_Table'Address use {address_of_memory_array}

is to assign a specific address to Dev_Table. Like setting the 
interrupt table to memory location zero.

  -- Interrupt_Vector_Type defined as either 32-bit or 64-bit
  --                       Interrupt record.

  Interrupt_Vector : Interrupt_Vector_Type ( 0 .. 255 ) ;
  for Interrupt_Vector'Address use System.Null_Address ;
  -- simplest way because Null_Address (GNAT) is define as Address 0.



In <f4a52e5d-2514-4713-a68d-877f09af7ec3@d17g2000yql.googlegroups.com>, awdorrin <awdorrin@gmail.com> writes:
>I am trying to migrate source code from an older AdaMulti compiler
>than ran on Solaris to GNAT on Linux.
>
>The original program makes use of shared memory and has structures
>populated in C code that are accessed within Ada code.
>
>The original developers used some AdaMulti 'features' that do not
>appear to exist within GNAT to play some tricks on setting up a
>pointer as an array of records.
>
>For instance:
>
>Config_Type is an Ada Record which matches a C struct.
>A Dev_Table is used as an array of these Config_Type records.
>
>The original code has the following statements:
>
>type Dev_Table_Type is array (Device_Num_Type range <>) of
>Config_Type;
>type Dev_Table_Ptr_Type is access Dev_Table_Type;
>Dev_Table := Dev_Table_Ptr_Type;
>Bounds_Ptr : Global_Types.Int_Ptr_Type;
>
>Then, in the Ada Procedure we have:
>
>Dev_Data_Obj := Get_Object_Pointer( Dev_Data_Obj_Name );
>
>Dev_Table := To_Dev_Table_Ptr( Get_UDP( Dev_Data_Obj) );
>
>Bounds_Ptr := Dev_Table_Ptr_To_Int_Ptr( Dev_Table );
>Bounds_Ptr.all := 1;
>
>Bounds_Ptr := Int_To_Int_Ptr( Dev_Table_Ptr_To_Int( Dev_Table ) + 4);
>Bounds_Ptr.all := Int32( Num_Devs_Cnst );
>
>The To_Dev_Table_Ptr, Dev_Table_Ptr_To_Int_Ptr, Int_To_Int_Ptr are all
>unchecked conversion methods.
>
>I understand that the Bounds_Ptr is being used to assign array
>constraints to the dope vector. But I'm guessing that GNAT doesn't
>define these dope vectors using this sort of definition.
>
>I haven't done much development in Ada, so I'm at a loss here. I'm
>making the assumption that the way this code was implemented
>(somewhere between 1992 and 98) was not really the right way to
>approach this problem. But I'm not sure what method should be used,
>and haven't had much luck the past few days searching the web and
>newsgroups.
>
>I would have thought I could have defined the Dev_Table differently,
>perhaps:
>
>Dev_Table : Dev_Table_Ptr_Type := new Dev_Table_Type( 1 ..
>Num_Devs_Cnst );
>
>If I knew the address of pointer at the time of declaration I figured
>I could do:
>
>for Dev_Table'Address use {address_of_memory_array} - but I won't know
>that until run time, so I'm not sure how I can assign that properly.
>
>I hope I'm making sense here - because I'm pretty confused about all
>of this at the moment... :-)
>
>Thanks
>-Al
>




  parent reply	other threads:[~2011-11-07 22:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 20:09 Memory Access awdorrin
2011-11-07 21:26 ` Simon Wright
2011-11-07 22:03 ` anon [this message]
2011-11-07 22:21 ` Adam Beneschan
2011-11-07 22:42   ` Adam Beneschan
2011-11-07 23:13   ` Simon Wright
2011-11-07 23:32     ` Adam Beneschan
2011-11-08 12:22       ` awdorrin
2011-11-08 16:00         ` Adam Beneschan
2011-11-08 17:46           ` awdorrin
2011-11-08 20:11             ` Adam Beneschan
2011-11-08 20:24               ` awdorrin
2011-11-09 14:42                 ` awdorrin
2011-11-08 16:10         ` awdorrin
2011-11-08 18:33           ` Simon Wright
2011-11-08 18:34             ` Simon Wright
2011-11-08 20:18             ` awdorrin
2011-11-08 12:44       ` Simon Wright
2011-11-07 22:26 ` Niklas Holsti
2011-11-07 22:53   ` Adam Beneschan
replies disabled

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