* Address representation clause is getting 0
@ 2003-12-31 12:29 Luke A. Guest
2003-12-31 13:53 ` Luke A. Guest
0 siblings, 1 reply; 5+ messages in thread
From: Luke A. Guest @ 2003-12-31 12:29 UTC (permalink / raw)
Hi,
I'm working on an embedded project on an SGI O2 machine. I have a GNAT/GCC
compiler set for mips-elf compiled and All I'm trying to do is to get the
System Program Block from the ARCS PROM.
I have the following types:
type T_SPB is
record
SPBSignature : ULONG; -- Must be SPBSIGNATURE.
SPBLength : ULONG;
Version : USHORT;
Revision : USHORT;
RestartBlock : T_RESTARTBLOCK_PTR;
DebugBlock : VOID_PTR;
GEVector : VOID_PTR;
UTLBMissVector : VOID_PTR;
FirmwareVectorLength : ULONG;
FirmwareVector : T_FIRMWAREVECTOR_PTR;
PrivateVectorLength : ULONG;
PrivateVector : VOID_PTR;
AdapterCount : ULONG;
Adapters : aliased T_ADAPTERS;
end record;
type T_SPB_PTR is access T_SPB;
SP_Block : T_SPB;
for SP_Block'Address use To_Address(16#80001000#); -- 0x80001000
Inside a procedure I have tested the address:
package body ARCS_Prom is
procedure PutChar(C : CHAR) is
Count : aliased ULONG;
OutputChar : CHAR := c;
Output : LONG_PTR;
begin
-- if SP_Block'Address = To_Address(16#80001000#) then
if SP_Block'Address = To_Address(0) then
Output := SP_Block.FirmwareVector.ArcWrite(1, OutputChar'Address, 1, Count'Access);
end if;
end PutChar;
end ARCS_Prom;
Now, if I execute the PutChar procedure the program crashes (because of
the null pointer).
Here's the code for the ArcWrite function as well:
--typedef LONG (*_ArcWrite)(ULONG FileID, VOID *Buffer, ULONG N, ULONG *Count);
type Arc_Write is access function(FileID : ULONG; Buffer : System.Address; N : ULONG; Count : access ULONG) return LONG_PTR;
pragma Convention(C, Arc_Write);
Anyway, I think i've got everything else working ok, just not the
SP_Block'Address. Can anyone help?
FYI: I have no startup code, just a simple "main" procedure called start
in which I call PutChar(65); the program is linked at the correct address
for the O2.
Thanks,
Luke.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Address representation clause is getting 0
2003-12-31 12:29 Address representation clause is getting 0 Luke A. Guest
@ 2003-12-31 13:53 ` Luke A. Guest
2003-12-31 21:48 ` Randy Brukardt
0 siblings, 1 reply; 5+ messages in thread
From: Luke A. Guest @ 2003-12-31 13:53 UTC (permalink / raw)
I think that this is an elaboration problem. Now as I don't have a runtime
or any tools, I need to rely on my own code (think of this as an OS
kernel).
Does anyone know what I need to do to get this to work?
Thanks,
Luke.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Address representation clause is getting 0
2003-12-31 13:53 ` Luke A. Guest
@ 2003-12-31 21:48 ` Randy Brukardt
2003-12-31 23:03 ` Luke A. Guest
2004-01-01 17:24 ` Luke A. Guest
0 siblings, 2 replies; 5+ messages in thread
From: Randy Brukardt @ 2003-12-31 21:48 UTC (permalink / raw)
"Luke A. Guest" <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> wrote
in message
news:pan.2003.12.31.13.53.00.912339@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.
uk...
> I think that this is an elaboration problem. Now as I don't have a runtime
> or any tools, I need to rely on my own code (think of this as an OS
> kernel).
>
> Does anyone know what I need to do to get this to work?
Ada access objects are initialized to null by default. The object to which
you applied the address clause is thus getting initialized. You have to tell
the compiler not to do that, and the way you do that is to give a pragma
Import. Something like
pragma Import (SB_Block, Ada);
will suppress the initialization, allowing you to read the data.
As to why you can't read the 'Address itself, I don't know. That looks like
a bug to me.
Randy.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Address representation clause is getting 0
2003-12-31 21:48 ` Randy Brukardt
@ 2003-12-31 23:03 ` Luke A. Guest
2004-01-01 17:24 ` Luke A. Guest
1 sibling, 0 replies; 5+ messages in thread
From: Luke A. Guest @ 2003-12-31 23:03 UTC (permalink / raw)
On Wed, 31 Dec 2003 15:48:36 -0600, Randy Brukardt wrote:
> pragma Import (SB_Block, Ada);
>
> will suppress the initialization, allowing you to read the data.
>
> As to why you can't read the 'Address itself, I don't know. That looks like
> a bug to me.
I've been able to set this up by calling:
ARCS_Prom'Elab_Spec;
Inside my start procedure. But this just hangs the machine :-(
Now, if I do what you say, will this still be initialised to the correct
address?
Luke.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Address representation clause is getting 0
2003-12-31 21:48 ` Randy Brukardt
2003-12-31 23:03 ` Luke A. Guest
@ 2004-01-01 17:24 ` Luke A. Guest
1 sibling, 0 replies; 5+ messages in thread
From: Luke A. Guest @ 2004-01-01 17:24 UTC (permalink / raw)
On Wed, 31 Dec 2003 15:48:36 -0600, Randy Brukardt wrote:
> "Luke A. Guest" <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> wrote
> in message
> news:pan.2003.12.31.13.53.00.912339@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.
> uk...
>> I think that this is an elaboration problem. Now as I don't have a runtime
>> or any tools, I need to rely on my own code (think of this as an OS
>> kernel).
>>
>> Does anyone know what I need to do to get this to work?
>
> Ada access objects are initialized to null by default. The object to which
> you applied the address clause is thus getting initialized. You have to tell
> the compiler not to do that, and the way you do that is to give a pragma
> Import. Something like
>
> pragma Import (SB_Block, Ada);
>
> will suppress the initialization, allowing you to read the data.
Not only this, but I had to change all To_Address(*) to
System'To_Address(*) so that I had a static address rather than a function
call.
Also, by adding:
pragma Restrictions(No_Elaboration_Code);
to the start of my spec, I didn't have to call any elaboration code ;-)
All this worked and I can now dump a character to the screen, yay!
Thanks,
Luke.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-01-01 17:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-31 12:29 Address representation clause is getting 0 Luke A. Guest
2003-12-31 13:53 ` Luke A. Guest
2003-12-31 21:48 ` Randy Brukardt
2003-12-31 23:03 ` Luke A. Guest
2004-01-01 17:24 ` Luke A. Guest
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox