87823

Accessing IRQ description array within a module and displaying action names

I am programming a kernel module in C which is struggling to access IRQ description array elements and to display all action names of these elements.

At the beginning, I thought that this irq_desc array is sonething like a macro but after compiling i understood it is not. Then I used for_each_irq_desc(irq, desc) function. but this time it returned a warning:

WARNING: "irq_to_desc" [/home/samet/Masaüstü/Assignment3/Ass-1.ko] undefined!

and after this warning, i tried to insmod the module into kernel this time an error message popped:

insmod: error inserting './Ass-1.ko': -1 Unknown symbol in module

after this i included all header files that i think relevant to this process, but nothing changed.

since it is very short i am attaching the code:

#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/sched.h> #include <linux/irq.h> #include <linux/irqdesc.h> #include <linux/irqnr.h> struct task_struct* p; struct irq_desc* irqElement; int irq, desc; static int __init ass_1_init(void) { printk(KERN_INFO "Ass-1 module is starting...\n"); for_each_process(p){printk("%d\t%s\n", p->pid, p->comm);} for_each_irq_desc(irq, irqElement){printk("%p\n", irqElement);} return 0; } static void __exit ass_1_exit(void) { printk(KERN_INFO "Ass-1 module is finishing...\n"); } module_init(ass_1_init); module_exit(ass_1_exit);

Answer1:

I think you really overestimate my abilities. This is my first hello world kernel module. But if anything, experience has taught me that the programmer is king. If you want something, define it.

The kernel headers don't want to expose irq's to modules, that's clear, so I'll bet this won't be supported and this may be generally a bad idea. But we don't care about that. We're hackers!

#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/sched.h> #include <linux/irq.h> #include <linux/irqnr.h> #include <linux/irqdesc.h> #define irq_to_desc(irq) (&irq_desc[irq]) #define nr_irqs NR_IRQS struct irq_desc irq_desc[NR_IRQS]; struct irq_desc *irqElement; int irq; int init_module(void) { printk(KERN_INFO "I HAZ MODULE\n"); for_each_irq_desc(irq, irqElement){printk("%p\n", irqElement);} return 0; } void cleanup_module(void) { printk(KERN_INFO "BAI MODULE!!!1\n"); }

Recommend

  • Modify the MPU3050 driver in linux kernel (Android) to use MPU6050
  • Different between native C code run in jni and run in the shell in Android
  • Android: NAT table: “FIX ME! impliment getnetbyaddr() bionic/libc/bionic/stubs.c:444” what does it m
  • How to correctly configure interrupt for INT line of Atmel MXT641T touch chip in Android 5 kernel de
  • Knockout.js mapping options being ignored on nested values
  • Knockout/Select2: Triggering select2 to update based on an observable option updating
  • Can't connect to MySQL for .NET application deployed in Wine using Ubuntu
  • How to use jQuery in a Knockout.js Template?
  • Angular 2.0 routing - TS 2305 … has no exported member 'ModulewithProviders'
  • iphone - Hide the annotation view in map view
  • What's the alternative to IValueFormatter in AutoMapper?
  • Angular Ui-router can't access $stateParams inside my controller
  • Google App Engine - SSL InsecurePlatformWarning
  • Error Processing Request: Mage registry key “_singleton/inchoo_notes/feed_updates” already exists
  • Convert symmetric matrix between packed and full storage?
  • Grunt watch Running “watch” task Waiting
  • QueryString id parameter not being used
  • Open an application in a space using applescripts
  • py4j.protocol.Py4JJavaError when selecting nested column in dataframe using select statetment
  • How can I extend PHP DOMElement?
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • Can my PDF ping my server when it is opened?
  • Angular2 - Template reference inside NgSwitch
  • Getting different value with placeholder over CPU/GPU
  • Getting error 'Cannot read property 'document' of undefined' while importing exp
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • htaccess add www if not subdomain, if subdomain remove www
  • Retrieve list of sent friend requests from friend_request FQL table
  • JSON response opens as a file, but I can't access it with JavaScript
  • Android full screen on only one activity?
  • NHibernate Validation Localization with S#arp Architecture
  • How can I send an e-mail from a vbs script
  • Dynamically accessing properties of knockoutjs observable array
  • Javascript Callbacks with Object constructor
  • Where to put my custom functions in Wordpress?
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Getting Messege Twice Using IMvxMessenger
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass