Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
766 Views

I/o irq

Hello my system has two CPUs- CPU1 w/ linux and cpu2 w/o linux. 

I want to handle an IRQ inside CPU1 Linux generated by CPU2 when it writes to a PIO . 

[cpu1]---[cpu2]
0 Kudos
5 Replies
Altera_Forum
Honored Contributor I
42 Views

I suppose you need to create a hardware device that issues the interrupt to the CPU. Maybe a MUTEX can be extended to do this, as usually you want to transfer data in a memory region with the interrupt and same often need to be protexted via a Mutex. Another good way is creating a FIFO that transfers the data and issues an interrupt on getting not empty (-> Linux) or empty (<- other CPU).  

 

-Michael
Altera_Forum
Honored Contributor I
42 Views

Yes i've done that. But now all i need is that Linux handles the IRQ PIO (that is already working)

Altera_Forum
Honored Contributor I
42 Views

In the device driver you need to register the IRQ with the Kernel to have it call a function of yours when an interrupt occurs. 

 

Take a look at another driver (e.g. TTY) on how this is done.  

 

-Michael
Altera_Forum
Honored Contributor I
42 Views

Linux device drivers book says you must not read/write from I/O nor change information between userspace/kernel space inside an IRQ. 

 

I have a char device driver and i want to call my Read function when an ISR happens.. how can i do that? I can't do a while loop when i call read from userspace since i don't know when the data is ready therefore i can't just call it from anywhere
Altera_Forum
Honored Contributor I
42 Views

Obviously, when in an ISR, the device driver has no knowledge at all about user space memory.  

 

In the ISR the driver will communicate information between the hardware and a buffer allocated in Kernel space (allocated by the driver in the initialization function).  

 

When a user program accesses the driver (read/write/ioctrl), the driver can transfer the buffer content from/to user space.  

 

Alternative: the driver can offer doing a memory mapped file for the user space. Once allocated, same can be accessed by the driver and by the user space program. Of course here synchronizing issues can easily arise.  

 

To have the driver inform the user space program that an interrupt has happened, blocking read, select(), or epoll() can be used. 

 

If the user program needs to do other stuff while waiting for the interrupt to happen, besides select() or (more versatile) epoll(), you can simply use blocking read in a thread (spawned via TThreadlib) or another process (e.g. spawned via fork() (no additional executable file necessary). 

 

I suppose signals (a kind of user space interrupt) can be used, too, but I have no decent knowledge about this. 

 

-Michael
Reply