how an application program utilizes the driver.

Ming Liu eemingliu at hotmail.com
Wed Sep 20 23:48:25 EST 2006


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  




More information about the Linuxppc-embedded mailing list