I have a question about making device driver
I have a question about device driver.
I'm writing device driver for parallel port on Linux.
In initial function which is argument of module_init() in my device driver, I reserved I/O address region, 0x378-0x37a, with using request_region() and regist my charactor device driver calling register_chrdev().
After I compile and link it. I insert this module and I can confirm that I obtaind the range of I/O address at /proc/ioports. But I cannot write data on I/O address line, It means that following check program shows "false".
--- check program ---
#include <linux/types.h>
#include <asm/io.h>
#include <stdio.h>
int main(void){
int base = 0x378;
char read, write;
ioperm(base, 1, 1);
write = 0xa;
outb(write, base);
read = inb(base);
if((read & 0xf) == write){
printf("true\n");
}else{
printf("false\n");
}
return 0;
}---
At this time, I unloaded kernel modules which are related to parallel port. they are 'ppdev', 'lp', 'parport_pc' and 'parport'.
What should I do at initial funtion in my module to do I/O. (The version of kernel that I use is 2.6.19-7.)
===
by Hiroyasu Ohyama
Quoted 2 lines · On Feb 4 2008 18:54, [email protected] wrote:
I'm writing device driver for parallel port on Linux.
Another one?
Quoted 10 lines
In initial function which is argument of
module_init()in my device driver, I reserved I/O address region, 0x378-0x37a, with usingrequest_region()and regist my charactor device driver callingregister_chrdev().After I compile and link it. I insert this module and I can confirm that I obtaind the range of I/O address at
/proc/ioports. But I cannot write data on I/O address line, It means that following check program shows "false".
Quoted 4 lines
--- check program ---
#include <linux/types.h>
#include <asm/io.h>
#include <stdio.h>
A userspace program? I thought this was about kernel device drivers.
Quoted 10 lines
int main(void){
int base = 0x378;
char read, write;
ioperm(base, 1, 1);
write = 0xa;
outb(write, base);
read = inb(base);
if((read & 0xf) == write){Some parallel port chips always return 0 on inb(base), for example the AMD K6 boards that shipped with VIA Apollo chipsets (1998). On the other hand, a chipset as old as to carry a i386DX CPU (probably was all Intel back then) returns the desired 0xA on inb(base).
Quoted 6 lines
printf("true\n"); }else{ printf("false\n");}
return 0;
}