Compilation d'un module noyau

Page principale

Répondre à ce message
Auteur: Frédéric
Date:  
À: ML Guilde
Sujet: Compilation d'un module noyau
Bonsoir,

Je voudrais compiler un bout de code qui est sensé être un module noyau. Le
problème, c'est que je n'ai qu'un patch pour que les sources du noyau, et
je cherche à compiler ce module sans devoir tout installer (j'ai les
headers).

Pour faire simple, j'essaye en plus de faire ça à la mode debian ; là, ça
ne marche pas trop mal. Je suis parti d'un truc existant, et je l'ai
modifié. Mais ce qui merdouille, c'est la compilation du code lui-même. Il
doit me manquer des paramètres pour la ligne de compilation.

Quelqu'un pourait-il me dire ce qu'il faut mettre ? J'ai attaché le code à
compiler, et le Makefile. Si quelqu'un peut y jetter un oeil... Merci
d'avance.

PS : voici aussi l'erreur que j'obtiens :

make[2]: entrant dans le répertoire « /usr/src/modules/delkin »
/usr/bin/gcc-3.3
for templ in ; do \
    cp $templ `echo $templ | sed -e 's/_KVERS_/2.6.10/g'` ; \
  done
for templ in `ls debian/*.modules.in` ; do \
    test -e ${templ%.modules.in}.backup || cp ${templ%.modules.in} 
${templ%.modules.in}.backup 2>/dev/null || true; \
    sed -e 's/##KVERS##/2.6.10/g ;s/#KVERS#/2.6.10/g ; s/_KVERS_/2.6.10/g ; 
s/##KDREV##/2.6.10-10.00.Custom/g ; s/#KDREV#/2.6.10-10.00.Custom/g ; 
s/_KDREV_/2.6.10-10.00.Custom/g' < $templ > ${templ%.modules.in}; \
  done
dh_clean
/usr/bin/make clean
make[3]: entrant dans le répertoire « /usr/src/modules/delkin »
rm -rf delkin_cb.ko delkin_cb.o .*.ko.cmd .*.o.cmd *~ .tmp_versions
make[3]: quittant le répertoire « /usr/src/modules/delkin »
make[2]: Rien à faire pour « kdist_config ».
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs lib/modules/2.6.10/misc
# build and install the module
/usr/bin/make KPKG_EXTRAV_ARG= KSRC=/usr/src/linux \
        KVER=2.6.10 \
        INST_DIR=debian/delkin-modules-2.6.10/lib/modules/2.6.10/misc/ \
        install
make[3]: entrant dans le répertoire « /usr/src/modules/delkin »
gcc-3.3  -DDRIVER_VERSION=\"0.9\"   -c -o delkin_cb.o delkin_cb.c
In file included from /usr/include/linux/sched.h:12,
                 from /usr/include/linux/module.h:10,
                 from delkin_cb.c:23:
/usr/include/linux/jiffies.h:84: error: erreur de syntaxe before 
"jiffies_64"
/usr/include/linux/jiffies.h:88: error: erreur de syntaxe before 
"get_jiffies_64"
/usr/include/linux/jiffies.h: Dans la fonction « timespec_to_jiffies »:
/usr/include/linux/jiffies.h:320: error: called object is not a function
/usr/include/linux/jiffies.h:320: error: called object is not a function
/usr/include/linux/jiffies.h:320: error: `NSEC_PER_SEC' undeclared (first 
use in this function)
/usr/include/linux/jiffies.h:320: error: (Each undeclared identifier is 
reported only once
/usr/include/linux/jiffies.h:320: error: for each function it appears in.)
...


--
Frédéric

http://www.gbiloba.org
/*
* linux/drivers/ide/pci/delkin_cb.c
*
* Created 20 Oct 2004 by Mark Lord
*
* Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter
*
* Modeled after the 16-bit PCMCIA driver: ide-cs.c
*
* This is slightly peculiar, in that it is a PCI driver,
* but is NOT an IDE PCI driver -- the IDE layer does not directly
* support hot insertion/removal of PCI interfaces, so this driver
* is unable to use the IDE PCI interfaces. Instead, it uses the
* same interfaces as the ide-cs (PCMCIA) driver uses.
* On the plus side, the driver is also smaller/simpler this way.
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#include <linux/config.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/blkdev.h>
#include <linux/hdreg.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <asm/io.h>

/*
 * No chip documentation has yet been found,
 * so these configuration values were pulled from
 * a running Win98 system using "debug".
 * This gives around 3MByte/second read performance,
 * which is about 2/3 of what the chip is capable of.
 *
 * There is also a 4KByte mmio region on the card,
 * but its purpose has yet to be reverse-engineered.
 */
static const u8 setup[] = {
       0x00, 0x05, 0xbe, 0x01, 0x20, 0x8f, 0x00, 0x00,
       0xa4, 0x1f, 0xb3, 0x1b, 0x00, 0x00, 0x00, 0x80,
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
};


static int __devinit
delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
{
       unsigned long base;
       hw_regs_t hw;
       ide_hwif_t *hwif = NULL;
       ide_drive_t *drive;
       int i, rc;


       rc = pci_enable_device(dev);
       if (rc) {
           printk(KERN_ERR "delkin_cb: pci_enable_device failed (%d)\n", rc);
           return rc;
       }
       rc = pci_request_regions(dev, "delkin_cb");
       if (rc) {
           printk(KERN_ERR "delkin_cb: pci_request_regions failed (%d)\n", rc);
           pci_disable_device(dev);
           return rc;
       }
       base = pci_resource_start(dev, 0);
       outb(0x02, base + 0x1e);        /* set nIEN to block interrupts */
       inb(base + 0x17);           /* read status to clear interrupts */
       for (i = 0; i < sizeof(setup); ++i) {
           if (setup[i])
               outb(setup[i], base + i);
       }
       pci_release_regions(dev);       /* IDE layer handles regions itself */


       memset(&hw, 0, sizeof(hw));
       ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
       hw.irq = dev->irq;
       hw.chipset = ide_pci;           /* this enables IRQ sharing */


       rc = ide_register_hw_with_fixup(&hw, &hwif, ide_undecoded_slave);
       if (rc < 0) {
           printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
           pci_disable_device(dev);
           return -ENODEV;
       }
       pci_set_drvdata(dev, hwif);
       hwif->pci_dev = dev;
       drive = &hwif->drives[0];
       if (drive->present) {
           drive->io_32bit = 1;
           drive->unmask   = 1;
       }
       return 0;
}


static void
delkin_cb_remove (struct pci_dev *dev)
{
       ide_hwif_t *hwif = pci_get_drvdata(dev);


       if (hwif)
           ide_unregister(hwif->index);
    pci_disable_device(dev);
}


static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
    { PCI_VENDOR_ID_WORKBIT, PCI_DEVICE_ID_WORKBIT_CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
    { 0, },
};
MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl);


static struct pci_driver driver = {
    .name        = "Delkin-ASKA-Workbit Cardbus IDE",
    .id_table    = delkin_cb_pci_tbl,
    .probe        = delkin_cb_probe,
    .remove        = delkin_cb_remove,
};


static int
delkin_cb_init (void)
{
    return pci_module_init(&driver);
}


static void
delkin_cb_exit (void)
{
    pci_unregister_driver(&driver);
}


module_init(delkin_cb_init);
module_exit(delkin_cb_exit);

MODULE_AUTHOR("Mark Lord");
MODULE_DESCRIPTION("Basic support for Delkin/ASKA/Workbit Cardbus IDE");
MODULE_LICENSE("GPL");
-include version

DISTFILES=delkin_cb.c

KVERS ?= $(shell uname -r)
KSRC ?= /lib/modules/$(KVERS)/build

KPSUB := $(shell echo $(KVERS) | sed -e 's/\([^\.]*\)\.\([^\.]*\)\..*/\1\2/')

DESTDIR =
INST_DIR := $(DESTDIR)/lib/modules/$(KVERS)/misc

SRC_DIR=$(shell pwd)

-include $(KSRC)/.config

CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
          echo -DEXPORT_SYMTAB -DMODVERSIONS \
          -include $(KSRC)/include/linux/modversions.h)


# to produce debug trace, add option "DEBUG=<n>" where <n> is 1 to 6
ifdef DEBUG
CFLAGS += -DDEBUG=$(DEBUG) -g -DDEBUG_TIMER
endif

# to debug timers, add option "TIMER_DEBUG=1 DEBUG=<n>"
ifdef TIMER_DEBUG
CFLAGS += -DTIMER_DEBUG
endif

# to debug event layer, add option "EVENT_DEBUG=1 DEBUG=<n>"
ifdef EVENT_DEBUG
CFLAGS += -DEVENT_DEBUG
endif

# to debug USB layer, add option "USB_DEBUG=1 DEBUG=<n>"
ifdef USB_DEBUG
CFLAGS += -DUSB_DEBUG
endif

# to debug I/O layer, add option "USB_DEBUG=1 DEBUG=<n>"
ifdef IO_DEBUG
CFLAGS += -DIO_DEBUG
endif

CFLAGS += -DDRIVER_VERSION=\"${DRIVER_VERSION}\"

.PHONY: prereq_check clean dist_clean install

all : prereq_check default

OBJS := delkin_cb.o

delkin_cb.o: delkin_cb.c

prereq_check:
    @ if [ ! -f $(KSRC)/include/linux/version.h ]; then \
        echo "Can't find kernel sources in $(KSRC);"; \
        echo "  give the path to kernel sources with KSRC=<path>\
               argument to make";\
        exit 1;\
      fi


clean:
    rm -rf $(MODULE) $(OBJS) .*.ko.cmd .*.o.cmd *~ .tmp_versions


distclean: clean
    rm -f .\#*


MODULE := delkin_cb.ko
obj-m := delkin_cb.o

delkin_cb-objs := $(OBJS)

default: delkin_cb.o
    $(MAKE) -C $(KSRC) SUBDIRS=$(SRC_DIR) \
        DRIVER_VERSION=$(DRIVER_VERSION)


install: default
    mkdir -p $(INST_DIR)
    install -m 0644 $(MODULE) $(INST_DIR)
    #/sbin/depmod -a


dist:
    @for file in $(DISTFILES); do \
      cp  $$file $(distdir)/$$file; \
    done