comp.lang.ada
 help / color / mirror / Atom feed
From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Subject: Re: inb/outb for GNAT (Linux) ??
Date: 1998/01/28
Date: 1998-01-28T00:00:00+00:00	[thread overview]
Message-ID: <34CE7805.6AED6789@cl.cam.ac.uk> (raw)
In-Reply-To: 6al3th$ptb$1@muller.loria.fr


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.

If you are running as root, you can access ports indirectly via the
/dev/port device (read "man 4 port" on this) using the open(),
lseek(), read(), and write() system calls or their Ada equivalents.
For everything more sophisticated, you'll have to write a
loadable kernel module (either in Ada or in C, as you wish) to
do the job as a device driver.

>  I' have searched through the packages for functions like
>  inb()/outb() but without result.

Not surprising, because these functions would be useless except
for kernel developers. You can always directly include these
assembler instructions, but it will cause a Bus Error and abort
your process unless you are inside the kernel. This has nothing
to do with Ada, it happens under C exactly the same way.

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.

Hope this helped ...

Markus

-- 
Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at acm.org,  home page: <http://www.cl.cam.ac.uk/~mgk25/>




  parent 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 [this message]
1998-01-28  0:00   ` Corey Minyard
replies disabled

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