comp.lang.ada
 help / color / mirror / Atom feed
* OS specific support in ADA
@ 1996-06-29  0:00 Rich Maggio
  1996-06-29  0:00 ` Robert Dewar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rich Maggio @ 1996-06-29  0:00 UTC (permalink / raw)


I am an experienced 'C' programmer.  For a course that I will be taking in the fall, I will need to learn ADA. 
 I have downloaded GNAT for DOS and I have poked around some tutorials to get familiar with the language 
philosophies, purpose, and over-all general structure.

I noticed that GNAT is available for a multitude of OS's as well as hardware platforms.  What kind of OS calls 
are supported in GNAT?  For example, can you call a DOS interrupt directly from an ADA program?  Can you 
utilize OS/2's or Win32 semaphore API's?  Or do you have to rely upon the ADA implementation of these OS 
features, hoping that the compiler's RTL didn't leave anything out.

Also, is it possible to do ISR's in DOS using the GNAT compiler?  I understand that GNAT supports calling 'C' 
functions from and ADA application.  I was wondering if functions that call the OS directly would need to be 
written in 'C' and these functions would need to be called from the ADA program.

My understanding is that ADA was originally developed as an embedded system language, so I was surprised when 
I saw no mention of ISR's or OS calls in any of the docs that I have read so far.

Any info would be appreciated.

Thanks,
Rich Maggio




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

* Re: OS specific support in ADA
  1996-06-29  0:00 OS specific support in ADA Rich Maggio
@ 1996-06-29  0:00 ` Robert Dewar
  1996-07-01  0:00 ` Jerry van Dijk
  1996-07-03  0:00 ` Scott H. James
  2 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1996-06-29  0:00 UTC (permalink / raw)



Note that you cannot call DOS interrupts from C either (if by C you
mean the language described by the ANSI standard, as oppoosed to some
particular implementation).





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

* Re: OS specific support in ADA
  1996-06-29  0:00 OS specific support in ADA Rich Maggio
  1996-06-29  0:00 ` Robert Dewar
@ 1996-07-01  0:00 ` Jerry van Dijk
  1996-07-03  0:00 ` Scott H. James
  2 siblings, 0 replies; 5+ messages in thread
From: Jerry van Dijk @ 1996-07-01  0:00 UTC (permalink / raw)



Rich Maggio (maggior@world2u.com) wrote:

: For example, can you call a DOS interrupt directly from an ADA program?  

Yes, through binding to the djgpp runtime library. See VGAPCK in EZ2LOAD for
examples.

: Also, is it possible to do ISR's in DOS using the GNAT compiler?

Theoretically you can, but given the nature of interrupt handling in a
virtual memory enviroment you cannot reliably do so in practice. Note that
this has nothing to do with GNAT, the same goes for C/C++. Reliable interrupt
handling in DJGPP can only be done in assembler, since that is the only way
to lock all memory (code, data, stack,...) used by the interrupt handler in
a safe way.
-- 
-----------------------------------------------------------------------
--  Jerry van Dijk       --   e-mail: jerry@jvdsys.nextjk.stuyts.nl  --
--  Banking Consultant   --              Member Team-Ada             -- 
--  Ordina Finance BV    --    Located at Haarlem, The Netherlands   --




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

* Re: OS specific support in ADA
  1996-06-29  0:00 OS specific support in ADA Rich Maggio
  1996-06-29  0:00 ` Robert Dewar
  1996-07-01  0:00 ` Jerry van Dijk
@ 1996-07-03  0:00 ` Scott H. James
  1996-07-04  0:00   ` Jerry van Dijk
  2 siblings, 1 reply; 5+ messages in thread
From: Scott H. James @ 1996-07-03  0:00 UTC (permalink / raw)



As noted already, some OS support, and DOS support in particular, is
not properly speaking an Ada (or C) issue, however other Ada compilers
do in fact provide interrupt packages, port, and direct memory access
services.  Through the C interface to DJGPP functions you will find
GNAT readily suitable for the first two tasks, however, direct memory
access will not be as straight forward since using representation
clauses to access physical memory is, AFAIK, not possible in GNAT.

Another option for a cheap, more DOS friendly compiler is through R&R
software: (800)722-3248.  DOS and BIOS interrupts (procedures
provided) and direct memory access (through rep clauses) are
available.  It is not free, but if you are a student I believe the
16-bit version costs all of 75 bucks. (I'm not associated with R&R but
I did live in Madison WI once :-)

Have fun
scott






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

* Re: OS specific support in ADA
  1996-07-03  0:00 ` Scott H. James
@ 1996-07-04  0:00   ` Jerry van Dijk
  0 siblings, 0 replies; 5+ messages in thread
From: Jerry van Dijk @ 1996-07-04  0:00 UTC (permalink / raw)



Scott H. James (sjames@wam.umd.edu) wrote:

: Through the C interface to DJGPP functions you will find
: GNAT readily suitable for the first two tasks, however, direct memory
: access will not be as straight forward

If you use CWSDPMI (or another DPMI 1.0 compliant) dpmi provider with GNAT/DOS
you can access memory directly by using the djgpp dpmi functions to map your 
Ada data structures upon physical memory.

If you cannot be sure about the dpmi provider used, the djgpp library offers
several alternatives to accessing memory directly, the example below uses the
sys/farptr package:


   --  Example program that shows how to do direct memory access in GNAT/DOS.
   --  Assuming a color screen it fills the screen with the specified video
   --  attribute and character. Look up the djgpp functions with 'info'
   --  to see how this works.

   with Unchecked_Conversion;
   with Ada.Characters.Latin_1;

   with Interfaces; use Interfaces;

   procedure Demo is

      -----------------------
      -- DJGPP INTERFACING --
      -----------------------

      --  Define DOS extender information block
      type Go32_Info_Block is
         record
            Size_Of_This_Structure_In_Bytes       : Unsigned_32;
            Linear_Address_Of_Primary_Screen      : Unsigned_32;
            Linear_Address_Of_Secondary_Screen    : Unsigned_32;
            Linear_Address_Of_Transfer_Buffer     : Unsigned_32;
            Size_Of_Transfer_Buffer               : Unsigned_32;
            Pid                                   : Unsigned_32;
            Master_Interrupt_Controller_Base      : Unsigned_8;
            Slave_Interrupt_Controller_Base       : Unsigned_8;
            Selector_For_Linear_Memory            : Unsigned_16;
            Linear_Address_Of_Stub_Info_Structure : Unsigned_32;
            Linear_Address_Of_Original_Psp        : Unsigned_32;
            Run_Mode                              : Unsigned_16;
            Run_Mode_Info                         : Unsigned_16;
         end record;
      pragma Convention (C, Go32_Info_Block);

      --  Make current extender info block available
      Current_Info : Go32_Info_Block;
      pragma Import (C, Current_Info, "_go32_info_block");

      --  Set the selector for the poke function
      procedure Set_Selector
        (Selector : in Unsigned_16);
      pragma Import (C, Set_Selector, "_farsetsel");

      --  Poke a byte into memory
      procedure Poke_Byte
        (Offset : in Unsigned_32;
         Value  : in Unsigned_8);
      pragma Import (C, Poke_Byte, "_farnspokeb");


      -------------------------
      -- DOS VIDEO ATTRIBUTE --
      -------------------------

      type Video_Blink is new Boolean;

      type Background_Color is (Black,
                                Blue,
                                Green,
                                Cyan,
                                Red,
                                Magenta,
                                Brown,
                                Light_Gray);

      type Foreground_Color is (Black,
                                Blue,
                                Green,
                                Cyan,
                                Red,
                                Magenta,
                                Brown,
                                Light_Gray,
                                Dark_Gray,
                                Light_Blue,
                                Light_Green,
                                Light_Cyan,
                                Light_Red,
                                Light_Magenta,
                                Yellow,
                                White);

      type Video_Attribute is
         record
            Blink      : Video_Blink;
            Background : Background_Color;
            Foreground : Foreground_Color;
         end record;

      for Video_Attribute use
         record
            Blink      at 0 range 7 .. 7;
            Background at 0 range 4 .. 6;
            Foreground at 0 range 0 .. 3;
         end record;

      for Video_Attribute'Size use 8;

      function To_Unsigned_8 is
        new Unchecked_Conversion (Video_Attribute, Unsigned_8);

      --  Default values
      Default_Fill_Char : constant Character :=
        Ada.Characters.Latin_1.Space;
      Default_Fill_Attr : constant Video_Attribute :=
        (Blink      => False,
         Background => Black,
         Foreground => Light_Gray);


      ------------------
      -- Clear Screen --
      ------------------

      procedure Clear_Screen
        (Attr  : in Video_Attribute := Default_Fill_Attr;
         Char  : in Character       := Default_Fill_Char) is
         Color_Screen : Unsigned_32 := 16#B8000#;
      begin
         Set_Selector (Current_Info.Selector_For_Linear_Memory);
         for I in 0 .. 2 * 80 * 25 loop
            Poke_Byte (Color_Screen, Unsigned_8 (Character'Pos (Char)));
            Poke_Byte (Color_Screen + 1, To_Unsigned_8 (Attr));
            Color_Screen := Color_Screen + 2;
         end loop;
      end Clear_Screen;


   ------------------
   -- MAIN PROGRAM --
   ------------------
   begin
      Clear_Screen;
   end Demo;

-- 
-----------------------------------------------------------------------
--  Jerry van Dijk       --   e-mail: jerry@jvdsys.nextjk.stuyts.nl  --
--  Banking Consultant   --              Member Team-Ada             -- 
--  Ordina Finance BV    --    Located at Haarlem, The Netherlands   --




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

end of thread, other threads:[~1996-07-04  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-06-29  0:00 OS specific support in ADA Rich Maggio
1996-06-29  0:00 ` Robert Dewar
1996-07-01  0:00 ` Jerry van Dijk
1996-07-03  0:00 ` Scott H. James
1996-07-04  0:00   ` Jerry van Dijk

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