Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The problem is that this code does not work correctly and I am not quite sure why, the problems I have are:
1) The code works the first time it is loaded and picks up the first generated interrupt, but when i generate a 2nd or 3rd interrupt this is not picked up, even if i rmmod the module and insmod it again does not pick up an interrupt until i reset?
this could be because of the next problem!
2) when i use the make command i get the following compile error: in function `xinit_module`:
warning: passing arg 2 of `request_irq` from incompatible pointer type
I have checked the modules (more modules) and the module is added and removed correctly, there is no error code generated by ret (from request_irq), more interrupts says that 2 interrupts have been produced!
any light you could shed over the problems would be much appreciated, obviously it would be ideal to get rid of warning, but more importantly the fact that it only picks up one interrupt per boot is the most annoying thing!!
THanks
James
static int handler(void)
{
// do stuff
printk(">>> PARALLEL PORT INT HANDLED\n");
return 0;
}
int xinit_module(void)
{
int ret;
ret = request_irq(7, handler(), SA_INTERRUPT, "parallelport", NULL);
//set port to interrupt mode; pins are output
outb_p(0x10, BASEPORT + 2);
printk("return code = %d\n", ret);
printk("Wait for interrupt to be generated\n");
return 0;
}
Got to the bottom of the repeating the interrupt problem, something to do with the kernel of vector linux 3.0 I think, am trying to install 4.0 now to see if that sorts out the problem, i still get the error message though if anyone can help with that?
thanks
James
I don't know so much about interrupt handling under linux; maybe the kernel does this automatically, but from my MS-DOS days I know you had to end a hardware interrupt by resetting the interrupt controller status. In assembler language, it was done like this:
Code:
mov al, 020h ; issue EOI to 8259 PIC
out 020h, al
pop ax
iret
I seem to recall the symptom of failing to do this was exactly as you describe.
Just a thought...
(Boy, I really miss doing that kind of stuff. I really need to get back into it somehow.)
The best way to attack this sort of problem is ... "use the Source, Luke!" Go out to some of the existing hardware-driver source-code and find some piece of existing code that's doing something similar to yours. And, read it carefully.
Then, go to the kernel directories and look at the actual source code of the routines that you are calling. Look also at the Documentation subdirectory. "grep" can be your best friend.
This is easily the best, fastest, and most authoritative way to deal with issues and questions like these. "You have All Of The Source: you don't have to guess."
The error you are talking about is not really an error, it is just a warning that there is a type mismatch. You can ignore it
For your missing interrupt problems, I think you are not clearing the interrupt status bit in your interrupt handler so you are not getting the succeeding interrupts. Try adding in your handler code some status cleanup mechanism.
If that does not work, try disabling then re-enabling the interrupt in your handler and see if that helps.
Thanks, I tried removing and adding handler but it still requires reset to pick up a second interrupt!!
The program works with the warning under redhat8.0, picking up multiple interrupts,
so i dont know if it is a vector linux problem or if it just handles it differently, and what you said is happening, Unfortunately my laptop im using isnt powerful enough for read hat 8.0, so currently trying to install slack 10.2, hoping that this will work.
Ok, thanks I will try that.
sorry i am not very experienced with c and linux, took it on as a final year uni project (which is due in next week ahhhh!!) and have had to teach myself!!
Just getting vector back up and running now will post outcome!!
Hi thanks very much for your time and help,
unfortunately what you suggested didnt make any difference, so i thought i would just have a play around with it adding different bits and pieces. and the code which works is as follows: (clearing the irq register and reloading it when an interrupt occurs)
Quite strange though, the interrupt only works when i send a signal to set all the parallel port pins to high. I have pins 9 and 10 connected together, but tried leaving the port set at high and then touching the connectors together like an external switch but no interrupt generates, does anyone know any thing about this or why its doing it?
thanks
James
Last edited by James Scrymgeour; 06-07-2006 at 12:57 PM.
good to hear that the code is working now. see if u can get the book "The Indispensable PC Hardware Book" from ur library. it should give u most of the details of the most commonly used pc hardware and more...
Sorted now thanks, just needed to condition the input signal! to make a nice square wave!!
Now all thats left to do is make the module interact with my user programs!
from what i understand before i try there is a fork command and exec which is what i require!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.