Address representation clause is getting 0

From: Luke A. Guest (laguest_at_n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk)
Date: 12/31/03


Date: Wed, 31 Dec 2003 12:29:19 +0000

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.