LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   irq_vectors.h not found (https://www.linuxquestions.org/questions/linux-kernel-70/irq_vectors-h-not-found-827946/)

tilman1 08-23-2010 03:46 AM

irq_vectors.h not found
 
Hello

I am rewriting the code of a kernel module which was.
The flags of request_irq have changed. Hence I changed

request_irq(irq, vme_isr, SA_SHIRQ, MODULE_NAME, &file_ops))
to
request_irq(irq, (void*) vme_isr, IRQF_SHARED, MODULE_NAME, &file_ops)).

I also need to include linux/interrupt.h now. This results in irq_vectors.h not being found. NR_VECTORS, and NR_IRQS are undeclarded. I am using kernel version 2.6.24

Here my includes:

#include "common.h" // this includes /linux/version.h , /linux/autoconf.h
and linux/modversions.h

#include <linux/types.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <linux/interrupt.h>

And here the error message
Code:

cc -D__KERNEL__ -DMODULE -DNO_RT -I/usr/src/linux-2.6.24/include/config  -I/usr/src/linux-2.6.24/include  -O -Wall  -c -o vme_pb1650_main.o vme_pb1650_main.c
In file included from /usr/src/linux-2.6.24/include/asm/irq.h:2,
                from /usr/src/linux-2.6.24/include/linux/irq.h:23,
                from /usr/src/linux-2.6.24/include/asm/hardirq_32.h:5,
                from /usr/src/linux-2.6.24/include/asm/hardirq.h:2,
                from /usr/src/linux-2.6.24/include/linux/hardirq.h:7,
                from /usr/src/linux-2.6.24/include/linux/interrupt.h:11,
                from vme_pb1650_main.c:11:
/usr/src/linux-2.6.24/include/asm/irq_32.h:15:25: error: irq_vectors.h: No such file or directory
In file included from /usr/src/linux-2.6.24/include/asm/irq.h:2,
                from /usr/src/linux-2.6.24/include/linux/irq.h:23,
                from /usr/src/linux-2.6.24/include/asm/hardirq_32.h:5,
                from /usr/src/linux-2.6.24/include/asm/hardirq.h:2,
                from /usr/src/linux-2.6.24/include/linux/hardirq.h:7,
                from /usr/src/linux-2.6.24/include/linux/interrupt.h:11,
                from vme_pb1650_main.c:11:
/usr/src/linux-2.6.24/include/asm/irq_32.h:49: error: 'NR_VECTORS' undeclared here (not in a function)
In file included from /usr/src/linux-2.6.24/include/asm/hardirq_32.h:5,
                from /usr/src/linux-2.6.24/include/asm/hardirq.h:2,
                from /usr/src/linux-2.6.24/include/linux/hardirq.h:7,
                from /usr/src/linux-2.6.24/include/linux/interrupt.h:11,
                from vme_pb1650_main.c:11:
/usr/src/linux-2.6.24/include/linux/irq.h:180: error: 'NR_IRQS' undeclared here (not in a function)
make: *** [vme_pb1650_main.o] Error 1

Any ideas of what I am doing wrong ?

Thanks

Tilman

Aquarius_Girl 08-23-2010 07:23 AM

Should we assume that you have *successfully* installed the kernel-devel package ?

tilman1 08-23-2010 07:36 AM

I would think so: I have successfully compiled the kernel 2.6.24. It runs fine.

And I have successfully compiled a driver (kernel module for vme bus support) external to kernel.

The question of yours is however a very valid one, as I do a cross compilation for an x86 embedded platlform.
Maybe some paths are missing from my makefile.
I given only /usr/src/linux-2.6.24/include as -I to gcc


Tilman

tilman1 08-23-2010 04:04 PM

Here the files.

Makefile:
Code:

KERNELREV:=2.6.24
KERNELSRC:=/usr/src/linux-2.6.24

MODNAME:=vme_pb1650.o
MODDIR:=/var/nfs/vmic7750/lib/modules/2.6.24/build

CFLAGS = -D__KERNEL__ -DNO_RT -DMODULE
#CFLAGS += -I$(KERNELSRC)/include/config
CFLAGS += -I$(KERNELSRC)/include
CFLAGS += -Wall
CFLAGS += -O2 -fPIC


all: $(MODNAME)

install: all
        install -m0644 -oroot -groot -D $(MODNAME) $(MODDIR)/$(MODNAME)
        /sbin/depmod

uninstall:
        rm -f $(MODDIR)/$(MODNAME)

$(MODNAME): test1.o
        $(LD) -r $^ -o $@

.PHONY : clean
clean:
        rm -f *.o *

test1.c
Code:

#include "common.h"

//****************************************************************************
// INCLUDES
#include <linux/types.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <linux/interrupt.h>



#include <linux/module.h>

common.h
Code:

#ifndef __COMMON_H__
#define __COMMON_H__

//****************************************************************************
// DEFINES
#ifndef __KERNEL__
  #define __KERNEL__
#endif
#ifndef MODULE
  #define MODULE
#endif

#include <linux/version.h>  // if this file is not found: please look @ /boot/vmlinuz.version.h and make a symlink

// support for MODVERSIONS
#ifndef AUTOCONF_INCLUDED
#include <linux/autoconf.h>
#endif

#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
  #define MODVERSIONS
#endif

#ifdef MODVERSIONS
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
      #include <config/modversions.h>
  #endif
  #else
    #include <linux/modversions.h>
  #endif
#endif

  #define DO_GETTIMEOFDAY(tv) do_gettimeofday(&tv)


// support only versions 2.4.x and 2.6.x
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
  #error "This kernel is too old and not supported"
#else
  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
    #define LINUX_24 // >= LINUX 2.4.x && < LINUX 2.6
  #else
    #define LINUX_26 // >= LINUX 2.6
  #endif
#endif

// some preparative definitions for kernel 2.6.x
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
  typedef void irqreturn_t;
  #define IRQ_NONE
  #define IRQ_HANDLED
  #define IRQ_RETVAL(x)
#endif

  //#define PCAN_IRQ_RETVAL(x) IRQ_RETVAL(x)

  #define INIT_LOCK(lock) spin_lock_init(lock)
  #define DECLARE_SPIN_LOCK_IRQSAVE_FLAGS unsigned long flags
  #define SPIN_LOCK_IRQSAVE(lock) spin_lock_irqsave(lock, flags)
  #define SPIN_UNLOCK_IRQRESTORE(lock) spin_unlock_irqrestore(lock, flags)

//#endif

// count of function variables changed from 2.6.19
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
#define  IRQHANDLER(name, p1, p2, p3) name(p1, p2, p3)
#else
#define  IRQHANDLER(name, p1, p2, p3) name(p1, p2)
#endif

// switch to disable all printks for not debugging
#ifdef DEBUG
  #define DPRINTK printk
#else
  #define DPRINTK(stuff...)
#endif

// to manage differences between kernel versions

// to get smoothly into udev
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
#define UDEV_SUPPORT
#endif

// follow current interrupt definition changes
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
#define IRQF_DISABLED SA_INTERRUPT
#define IRQF_SHARED  SA_SHIRQ
#endif

// different data sink alternatives


#define DEVICE_NAME      "pb1650"                            // the name of the module and the proc entry


#endif // __COMMON_H


Aquarius_Girl 08-23-2010 09:03 PM

Try including this:
Code:

#include <asm/irq_vectors.h>
and see this thread too:
http://osdir.com/ml/linux.newbie/2003-02/msg00142.html

tilman1 08-25-2010 02:20 PM

I added an additional include path:
-I/usr/src/linux-2.6.24/include/asm-x86/mach-default/

Now I am getting a warning message. Does it point to a serious issue ? Can I ignote it ?

gcc -D__KERNEL__ -DNO_RT -DMODULE -I/usr/src/linux-2.6.24/include -I/usr/src/linux-2.6.24/include/asm-x86/mach-default/ -Wall -O2 -fPIC -c -o test1.o test1.c

In file included from /usr/src/linux-2.6.24/include/asm/cmpxchg.h:2,
from /usr/src/linux-2.6.24/include/asm/system_32.h:7,
from /usr/src/linux-2.6.24/include/asm/system.h:2,
from /usr/src/linux-2.6.24/include/asm/processor_32.h:18,
from /usr/src/linux-2.6.24/include/asm/processor.h:2,
from /usr/src/linux-2.6.24/include/asm/thread_info_32.h:16,
from /usr/src/linux-2.6.24/include/asm/thread_info.h:2,
from /usr/src/linux-2.6.24/include/linux/thread_info.h:34,
from /usr/src/linux-2.6.24/include/linux/preempt.h:9,
from /usr/src/linux-2.6.24/include/linux/interrupt.h:8,
from test1.c:8:
/usr/src/linux-2.6.24/include/asm/cmpxchg_32.h: In function '__set_64bit_var':
/usr/src/linux-2.6.24/include/asm/cmpxchg_32.h:57: warning: dereferencing type-punned pointer will break strict-aliasing rules

Aquarius_Girl 08-25-2010 02:26 PM

Do you mind thanking the person who's trying to help you ? I expected a little courtesy !

May be someone else can help you from here now.

tilman1 08-27-2010 11:30 AM

Dear Anisha

I do appreciate the time you invested to help me. I was just not sure if the issue is closed or if this is just the start of the next round :-)

Thank you for your help
Tilman

archieval 08-27-2010 05:52 PM

Quote:

Originally Posted by tilman1 (Post 4077547)
I added an additional include path:
-I/usr/src/linux-2.6.24/include/asm-x86/mach-default/

Why do you need to add this? This is too deep as it is not an include directory. I was about to reply to this but anishakaul already said to #include <asm/irq_vectors.h> which is supposed to be answer also. Doesn't this work?

tilman1 09-01-2010 05:22 PM

It did not work.

I then read a little bit about 2.6 kernel module developement and adapted the Makefile accordingly. That worked.

Code:

KERNEL_VER := linux-2.6.24
KDIR := /usr/src/$(KERNEL_VER)
PWD  := $(shell pwd)

obj-m := test1.o

all:
        $(MAKE)  -C $(KDIR) SUBDIRS=$(PWD) modules

Here the includes I used

Code:

//****************************************************************************
// INCLUDES
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>



All times are GMT -5. The time now is 09:48 AM.