fork download
  1. #include <linux/init.h>
  2. #include <linux/module.h>
  3. #include <linux/kernel.h>
  4. #include <linux/fs.h>
  5. #include <linux/sched.h>
  6. #include <linux/irq.h>
  7. #include <linux/interrupt.h>
  8. #include <asm/uaccess.h>
  9. #include <asm/current.h>
  10.  
  11. // from arch/arm/mach-bcm2708/include/mach/platform.h
  12. #include "platform.h"
  13.  
  14. MODULE_LICENSE("GPL");
  15.  
  16. int sigtest_open(struct inode *inode,struct file *filep);
  17. int sigtest_release(struct inode *inode,struct file *filep);
  18.  
  19. struct file_operations sigtest_fops =
  20. {
  21. open: sigtest_open,
  22. release: sigtest_release
  23. };
  24.  
  25. struct task_struct *t = NULL;
  26. struct siginfo info;
  27.  
  28. static int sigtest_init(void)
  29. {
  30. if(register_chrdev(666, "sigtest", &sigtest_fops))
  31. {
  32. printk("<1>failed to register");
  33. }
  34.  
  35. memset(&info, 0, sizeof(struct siginfo));
  36. info.si_signo = SIGUSR1;
  37. info.si_code = SI_QUEUE;
  38. info.si_int = 0;
  39.  
  40. return 0;
  41. }
  42.  
  43. static void sigtest_exit(void)
  44. {
  45. unregister_chrdev(666, "sigtest");
  46. }
  47.  
  48. static irqreturn_t sigtest_interrupt(int irq, void *dev_id)
  49. {
  50. /*if(t != NULL)
  51.   {
  52.   send_sig_info(SIGUSR1, &info, t);
  53.   }*/
  54.  
  55. return IRQ_HANDLED;
  56. }
  57.  
  58. int sigtest_open(struct inode *inode,struct file *filep)
  59. {
  60. printk("<1>sigtest signaled process changed to %d\n", current->pid);
  61.  
  62. t = current;
  63.  
  64. if(request_irq(INTERRUPT_GPIO3, sigtest_interrupt, IRQF_SHARED, "sigtest", (void *)&info) != 0)
  65. {
  66. printk("<1>Error Requesting IRQ\n");
  67. }
  68.  
  69. return 0;
  70. }
  71.  
  72. int sigtest_release(struct inode *inode,struct file *filep)
  73. {
  74. t = NULL;
  75.  
  76. free_irq(INTERRUPT_GPIO3, (void *)&info);
  77.  
  78. return 0;
  79. }
  80.  
  81. module_init(sigtest_init);
  82. module_exit(sigtest_exit);
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty