comp.lang.ada
 help / color / mirror / Atom feed
From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Subject: Re: 2nd help about handling HW interrupt and apologizes.
Date: 1998/04/08
Date: 1998-04-08T00:00:00+00:00	[thread overview]
Message-ID: <352BB2AE.1DC7325E@cl.cam.ac.uk> (raw)
In-Reply-To: 6gft3m$rib$1@nnrp1.dejanews.com


jtapasai@bipa162.bi.ehu.es wrote:
> Secondly, I would like to thank you for your help.
> My problem is that I must program an interrupt service routine that is
> executed when the predeterminated IRQ is rised, because the data adquisition
> card has finished the A/Dconversion.
> 
> I have read all the responses, but there is already two doubts in my mind :
>  - Does Linux allow to define a hardware interrupt service routine ?

Yes, but only inside the kernel.

>  - Does GNAT for Linux support this feature ?

Yes, because GNAT allows you to call all the C kernel functions
that you need to call to get this done and because the Linux
kernel is also compiled by gcc and therefore GNAT output can
easily be linked into the kernel.

My previous reply still applies:

Only code in the kernel, not normal user processes can handle
interrupt, this is completely independent of the programming
language.

In the kernel, you have to call request_irq() in order to register
your interrupt handler. For instance, the keyboard driver
in /usr/src/linux/drivers/char/keyboard.c contains the line

 request_irq(KEYBOARD_IRQ, keyboard_interrupt, 0, "keyboard", NULL);

to register its interrupt handler routine. You can call this
C routine also from Ada using pragma Import. The important thing
is that your Ada program has either to be compiled into the kernel
or you have to load your program as a loadable kernel module
using the system calls described on "man 2 modules".

Recommended reading to get started with Linux device driver
programming:

http://www.redhat.com:8080/HyperNews/get/khg.html
http://sunsite.unc.edu/mdw/HOWTO/Kernel-HOWTO.html
http://sunsite.unc.edu/mdw/HOWTO/mini/Modules.html
http://sunsite.unc.edu/mdw/linux.html

Unfortunately, I do not know any text that specificaly discusses
writing Linux device drivers in Ada, but I do not think many
special considerations beyond the normal Ada/C interfacing
issues have to be made. Read the sections of the GNAT user manual
that discuss how you can add Ada code to C programs such that
C can call Ada routines.

It is just important that GNAT does not do any fancy things with
its tasking run-time system once your Ada code is running inside
the kernel, because you do not have the system call interface
available inside the kernel.

Has anyone here practical experience with using GNAT output
as part of the Linux kernel? What happens if I call Ada routines
without calling 

   __gnat_initialize();
   adainit();

and

   adafinal();
   __gnat_finalize();

which might not work inside the kernel?

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/>




  reply	other threads:[~1998-04-08  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-08  0:00 2nd help about handling HW interrupt and apologizes jtapasai
1998-04-08  0:00 ` Markus Kuhn [this message]
1998-04-10  0:00   ` Andi Kleen
1998-04-10  0:00     ` Geert Bosch
1998-04-11  0:00       ` Andi Kleen
1998-04-10  0:00     ` Simon Wright
1998-04-10  0:00     ` Using GNAT for Linux kernel hacking Markus Kuhn
replies disabled

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