From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,641105de50ec2788 X-Google-Attributes: gid103376,public From: Markus Kuhn Subject: Re: 2nd help about handling HW interrupt and apologizes. Date: 1998/04/08 Message-ID: <352BB2AE.1DC7325E@cl.cam.ac.uk>#1/1 X-Deja-AN: 342131114 Content-Transfer-Encoding: 7bit References: <6gft3m$rib$1@nnrp1.dejanews.com> Content-Type: text/plain; charset=us-ascii Organization: Cambridge University, Computer Laboratory Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-04-08T00:00:00+00:00 List-Id: 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: