how an application program utilizes the driver.
Eric Nuckols
jrocnuck at hotmail.com
Fri Sep 22 03:06:44 EST 2006
this probably isn't the level /topic to ask on the list, so I suggest
reading the Linux Device Drivers book...
you'll want to access the device via ioctl() calls , but there has to be a
little more involved to get to that point:
experiment with the scull device driver in this book
http://lwn.net/images/pdf/LDD3/ch06.pdf
----Original Message Follows----
From: "Ming Liu" <eemingliu at hotmail.com>
To: linuxppc-embedded at ozlabs.org
Subject: how an application program utilizes the driver.
Date: Wed, 20 Sep 2006 13:48:25 +0000
Dear all,
Maybe this question sounds stupid for most software engineers. But I really
have much confusion on this topic. So I have to ask for explanation.
My situation is: I want to write a driver for my custom device.(In the
driver there are some functions defined to read or write my device.) Then
in my application program, I use these defined functions to operate my
hardware device. I think this is a normal process to operate the hardware
with driver+app, right?
My driver is defined in drv_hello.c. I have compiled it into a module
drv_hello.ko and it could be insmoded or rmmoded correctly. It looks like:
//drv_hello.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
void show_hello(){
printk("hello.\n");
}
static int hello_init(void){
printk(KERN_ALERT "module starts.\n");
return 0;
}
static void hello_exit(void){
printk(KERN_ALERT "module exits.\n");
}
module_init(hello_init);
module_exit(hello_exit);
EXPORT_SYMBOL(show_hello);
In my application program app_hello.c, I use the function show_hello to
achieve the simple task: print "hello" on the console. Here is my app
program:
//app_hello.c
extern void show_hello();
int main(int argc, char** argv)
{
show_hello();
return 0;
}
Then, here comes my problem: I don't know how to compile my application
program and then it could dynamically refer to the function show_hello()
defined in the memory area of the driver module. How can I tell the
compiler and linker that the app program is expected to be linked with the
driver module dynamically? If possible, please give me a detailed
explanation.
Waiting for your suggestion. Thanks for your help.
Regards
Ming
_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger: http://messenger.msn.com/cn
_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded at ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded
More information about the Linuxppc-embedded
mailing list