comp.lang.ada
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
Subject: Re: inb/outb for GNAT (Linux) ??
Date: 1998/01/28
Date: 1998-01-28T00:00:00+00:00	[thread overview]
Message-ID: <m2soq95fs9.fsf@wf-rch.cirr.com> (raw)
In-Reply-To: 34CE7805.6AED6789@cl.cam.ac.uk


Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk> writes:

> Nicolas NAVET wrote:
> >  I'am using GNAT for Linux. I need to write
> >  data to a serial port. Is it possible to do that with ADA
> >  without using a device driver ?
> 
> This has nothing to do with Ada or GNAT:
> 
> No Linux process can directly access the peripherial hardware
> directly with in/out assembler instructions. Linux is not DOS.
> The same applies for WinNT, btw.

Wrong.  On an ix86 under linux, you can call ioperm() or iopl() with
the proper parameters then do inb and outb instructions to your
heart's content (you have to be root to do this, obviously).  Most X
servers require this to set things up properly, dosemu allows it for
direct port acess, and I have done it for writing some test drivers.

To do this , you will have to create bindings to all the functions
that you need.  I doubt any standard binding exist to do this since it
is very non-portable and non-standard.  Also note that you cannot
get interrupts from the serial port.

> What you probably really want to do instead is to access the
> serial port via the existing Linux kernel driver as the
> devices /dev/ttyS0 and /dev/ttyS1 just as any other Unix process
> is doing it.

This I agree with.  Learning the semantics of termios is kind of a
pain, but your program will be MUCH more portable between *nix system,
it will be able to use any type of serial port on Linux, etc.  Richard
Steven's book "Advanced Programming in the Unix Environment" is my
favorite book on the subject, well worth having if you do any serious
programming under Unix.  With the Posix Ada bindings, you don't even
have to write any C code.  If you are interested, I have a program to
page alphanumeric pagers on a modem on my web page written in Ada95
that uses the Posix bindings.  I also have a copy of the forest Posix
binding there that will compile on Linux with gnat-3.10p.

-- 
Corey Minyard               Internet:  minyard@acm.org
  Work: minyard@nortel.ca       UUCP:  minyard@wf-rch.cirr.com




      reply	other threads:[~1998-01-28  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-27  0:00 inb/outb for GNAT (Linux) ?? Nicolas NAVET
1998-01-27  0:00 ` David Bacon
1998-01-28  0:00 ` Markus Kuhn
1998-01-28  0:00   ` Corey Minyard [this message]
replies disabled

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