LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-11-2004, 05:07 PM   #1
malacma
LQ Newbie
 
Registered: Nov 2004
Posts: 1

Rep: Reputation: 0
Unhappy Linux Device Driver


Hi!

i'm trying to install a module into the Linux Red Hat 9 Kernel, using the insmod directive. It happens that when i try to insmod dParalela.o the follow message appears;

[root@Webthread tcd]# gcc -O2 -c -pthread -D__KERNEL__ -D_MODULE_ -DOUTSIDE_KERNEL dParalela.c
[root@Webthread tcd]# insmod -f dParalela.o
dParalela.o: couldn't find the kernel version the module was compiled for
[root@Webthread tcd]#

please somebody help me!!!

Thanks a LOT!!!

here the code i've denveloped....

/*
Diretiva de ompilação no GCC LINUX
gcc -O2 -pthread -c dParalela.c
*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#include <linux/version.h>

#define MODULE
#define MODULE_VERSION "1.00001"
#define MODULE_NAME "Device Paralela"

#define __NO_VERSION__

#define BIT0LIGALED1 3
#define BIT1LIGALED2 15
#define BIT2LIGALED3 9
#define BIT3LIGALED4 10
#define DESLIGALEDCTR 11
#define PORTADEDADOS 0x378
#define PORTADESTATUS (PORTADEDADOS + 1)
#define PORTADECONTROLE (PORTADEDADOS + 2)
#define SINALINTERRUPCAO 0x10
#define INTERRUPCAO 7
#define DEVICE_NAME "dParalelaV1.00001" //Nome que aparece em /proc/devices

static int Major; //Major numero a ser registrado pelo device
static unsigned char estado=0; //Estado do Device aberto

pthread_t thread_paralela; //Thread para escrever na saida
char *n_thread = "Thread dParalelaV1.00001"; //Nome da thread
int i_thread = 0; //Número Thread

void libera_stream(void){
int flsh = fflush(NULL);
if(flsh == errno){
printk("<1>Não consegui liberar os streams de saída.....");
}
}

void zera_paralela(void){
outb(0x00,PORTADEDADOS); //Apaga o LED de status
outb(0x00,PORTADESTATUS); //Desabilita a porta
outb(0x00,PORTADECONTROLE); //Desabilita a porta
outb(PORTADECONTROLE,DESLIGALEDCTR);
free_irq (INTERRUPCAO,NULL); //Libera a interrupção
MOD_DEC_USE_COUNT; //Decrementa o contador de uso do kernel
libera_stream();

}

void interrupcao_paralela(void){
estado++;
if (estado == 0xFF){
estado = 0;
}
outb(estado, PORTADEDADOS);
printk("<1>Estado = %d\n",estado);
MOD_INC_USE_COUNT; //Incrementa o contador de uso do módulo no Kernel
outb(PORTADECONTROLE,BIT0LIGALED1); //Liga led 1 de controle;
getchar();
outb(PORTADECONTROLE,BIT1LIGALED2); //Liga led 2 de controle;
getchar();
outb(PORTADECONTROLE,BIT2LIGALED3); //Liga led 3 de controle;
getchar();
outb(PORTADECONTROLE,BIT3LIGALED4); //Liga led 4 de controle;
getchar();
libera_stream();
}

int init_module(void) {
Major = register_chrdev(0, DEVICE_NAME,NULL); //Registra no Kernel o major do Device

if (Major < 0) {
printk ("<1>Não foi possível registrar este device de paralela com o major n°: %d\n", Major);
return Major;
}
else{
printk ("<1>Módulo do device acoplado no Kernel com o numero Major:%d\n", Major);
return Major;

int rv = 0;
rv = request_irq(INTERRUPCAO,NULL,NULL,"Paralela Device Driver",NULL); //Solicita IRQ faltam as operações....

if(rv){ //Valida para ver se conseguiu fazer a interrupção
printk("<1>Não foi possível habilitar a interrupção N° %d\n", INTERRUPCAO);
}
else{
printk("<1>Modulo Device Driver paralela inicializado\n");
i_thread = pthread_create( &thread_paralela, NULL, (void*)&interrupcao_paralela, (void*) n_thread);

if(i_thread == 0){
printk("<1>%dThread de controle acionou o dispositivo\n",thread_paralela);
return 0;
}
else{
printk("<1>Não foi possível criar Thread de controle para escrever no dispositivo\n");
}
}
pthread_exit(NULL);
}

}

void cleanup_module(void) {
i_thread = pthread_create( &thread_paralela, NULL, (void*)&zera_paralela, (void*) n_thread);
if(i_thread == 0){
printk("<1>%dThread de controle Liberou o dispositivo\n",thread_paralela);
}
pthread_exit(NULL);
int ret = unregister_chrdev(Major, DEVICE_NAME); //Remove o módulo do kernel

if (ret < 0){
printk("Erro ao remover o módulo Device Driver paralela: %d\n", ret);
}
else{
printk("<1>Modulo Device Driver paralela finalizado\n");
}
}

MODULE_AUTHOR("Luís Augusto Machado Moretto");
MODULE_DESCRIPTION("TCD - Teste da Paralela - SO/2004-2");
MODULE_LICENSE("GPL");
EXPORT_NO_SYMBOLS;
 
Old 11-12-2004, 05:09 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 67
It looks like you are compiling the module without the #define statement that tells it to embed versioning information in the module file.

Is your /usr/src/linux tree configured in the same way as the kernel you're actually running? If this isn't the case, it's likely that your module won't be runnable anyway, especially if you're using your distribution's defaults which tend to differ from the source defaults.

If it is, have you tried insmod --force? It can overcome some problems like that.
 
Old 11-12-2004, 10:02 AM   #3
klopex
LQ Newbie
 
Registered: Nov 2004
Location: USA
Distribution: Redhat, Mandrake
Posts: 9

Rep: Reputation: 0
I am currently struggling with a slightly different module/kernel version problem. Perhaps something I found will help...

In the Oreilly book "Linux Device Drivers" Second Edition (available for free download from http://www.xml.com/ldd/chapter/book/ ) in chapter 11 it discusses module versioning. Try looking there for some help!

klopex
 
Old 12-07-2004, 08:50 AM   #4
nirav.jani
Member
 
Registered: Nov 2004
Location: Hyderabad, India
Distribution: Fedora Core - II, RedHat - 9
Posts: 45

Rep: Reputation: 15
Hello,
Uptill I know this type of problem is generated when your kernel is not compiled with your current gcc version, so try to compile your kernel using curent gcc you will solve this problem, that is one way another way you can found at following link
just check it out
http://www.linuxforum.com/forums/ind...owtopic=115437
I have solved my problem using above solution also,
Nirav
 
Old 09-03-2007, 03:32 PM   #5
clnbabu
LQ Newbie
 
Registered: Aug 2007
Posts: 8

Rep: Reputation: 0
pci driver

i wamt to develope a add on realy card based on pci...please help me out how to proceed for that.
 
Old 09-05-2007, 04:09 AM   #6
us_ed
Member
 
Registered: Nov 2006
Posts: 41

Rep: Reputation: 15
Hi all
OS Scientific Linux 5.0
Driver matrox_driver-x86_32-src-4.4.0.tar.gz from Matrox.com for Millenium G450
Configure without error
make :
mga_dacG.c:121: error: 'UCHAR' undeclared (first use in this function)
after i add #include "binding.h" in mga_dacG.c
old error disappeared
and add new
mga_driver.c:2049: error: 'struct <anonymous>' has no member named 'pMgaHwInfo'
 
Old 09-05-2007, 07:43 AM   #7
johnhamiltion
Member
 
Registered: Aug 2007
Posts: 92

Rep: Reputation: 15
You guys should try reading Greg Kroah-Hartman's book

"Linux Device Drivers 3."

You can download it (as a single web-page) from

Last edited by reddazz; 10-10-2007 at 11:59 PM.
 
Old 09-06-2007, 08:30 AM   #8
johnhamiltion
Member
 
Registered: Aug 2007
Posts: 92

Rep: Reputation: 15
Greg Kroah-Hartman writes a good book, doesn't he?
 
Old 09-07-2007, 03:37 AM   #9
us_ed
Member
 
Registered: Nov 2006
Posts: 41

Rep: Reputation: 15
Thank!
i am will thought.
 
Old 09-16-2007, 07:31 AM   #10
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
[QUOTE=johnhamiltion;2881911]You guys should try reading Greg Kroah-Hartman's book

"Linux Device Drivers 3."

You can download it (as a single web-page) from

Last edited by reddazz; 10-10-2007 at 11:59 PM.
 
Old 10-09-2007, 06:14 AM   #11
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Not much happens here, does it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ or pure C for Linux kernel module, Linux device driver development. What to use? Igor007 Programming 91 07-19-2014 11:55 AM
Linux device driver programming iammisc Programming 1 11-26-2005 10:46 AM
linux device driver programming chandansingh Programming 1 03-26-2005 07:30 AM
Linux Device Driver Development aslv Linux - Certification 0 09-27-2004 08:42 AM
Info about Linux Device Driver rajatnaik Linux - Software 2 07-28-2003 04:07 AM


All times are GMT -5. The time now is 05:19 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration