Interrupt handling in gcc?
Good morning everyone.
From what I know, gcc does not support the keyword like "interrupt" or "_interrupt". The only way to handle the interrupt is to write a small assembler to "call" the interrupt routin. But how to integrate this small piece of assembler into the final file? (to generate executable file) Thank you very much |
im not quite sure what you want to do?
do you want to write an interupt handler then have the kernel call it when necessery in this case just write your handler then call request_irq or do you want to generate an interupt, dont know why youd want to do this because no bios interupts are accessable and all the syscalls have wrappers but you would just do some inline assembly or write an assembly file and link it to your executable. theres lots of info about this if you look up operating system development. |
Sorry for the obscure words. I have written a small program to test the serial port under windows some time before. Now I want to migrate it to Linux. From my understanding, there are two ways to do it: 1. to use the POSIX programming interface. 2. to directly access to the register and handle the interrupt.
I have read the relevant document about serial port programming by POSIX. While there is no informaition there about using interrupt to handle the "read" problem. (otherwise you have to use polling to system delay, which I am using in POSIX). So I am thinking of control directly the serial port register under Linux as well as the interrupt. But soon I realized that gcc does not have the structure to handle interrupt. The only way is to write a small piece of assembler and call the interrupt routin from it. My problem is I don't know whether I need to write the interrupt vector for serial port interrupt, and I have no idea how to integrate the assembler to C. Do you any ideas or suggestions? I'll appreciate any of them:) Thank you very much |
Could you not simply open the serial port device and deal with it that way, instead of using interrupts? I mean, that's what the devices are for. (=
|
Yeah. Actually, POSIX provides a reletive ready-to-use interface on the serial port(some knows POSIX on parallel?). It is user-frendly. I have built a small testing program around this and it works. However, as I posted earlier, there is no interrupt handling for the "reading" from the port, which usually is time-critical. It indeed utilizes a function "select", but you have to block the whole program before reading a byte, though there is timeout.
Under turbo C you could just "bind" the interrupt routin vector to the interrupt, using "interrupt" keyword, which is easiler. But gcc does not have this structure. That's what I am looking for. Thank you. |
IMHO, this is how you get asm code in C (if this is what you need):
Code:
void myFunction() Question: Where can I find a list of the interrupts linux generates/uses? (something like a list of dos interrupts). Thanks |
I can't remember clearly but I think it is in /proc/interrupts (or interrupt). I think you might want to have a try.
I'll try your method and post the result here. |
Oh, in that way, I'll have to build the interrupt vector myself. I did that 3 years ago. (and I remember that was a project using 8259) ooooooo
|
Quote:
|
captain:
I'm also remembering some dealings I had with select some time ago, and IIR, select also could be given a zero length, and it would return immediately if the item/device status has not changed. yep.. according to the man page: Code:
timeout is an upper bound on the amount of time elapsed That is assuming your program will run somewhat like a daemon. |
Quote:
Anyhow this is a rather simple protocol to implement. But I have done something under windows, using the "interrupt" keyword and I am wondering whether gcc is also capable of it. |
And also thank you kev82 I also realized a way to do this is to write the program in Kernel mode, for which I need to read something. Would you recommend some materials on the internet, including the "free_irq/request_irq" information? Many thanks.
|
Quote:
for free_irq request_irq i suggest the man pages from section 9, for module programming the module programmers guide is somewhere in www.tldp.org and i guess you know enough about the serial port already but heres a good link for serial/parallel port programming. http://www.nondot.org/sabre/os/artic...cationDevices/ you could also have a look at the current serial driver in the kernel. i however recommend a userspace solution if its possible. |
Thanks again Dev82:D
|
All times are GMT -5. The time now is 12:43 PM. |