linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* how an application program utilizes the driver.
@ 2006-09-20 13:48 Ming Liu
  2006-09-20 16:14 ` David Hawkins
  2006-09-21 17:06 ` Eric Nuckols
  0 siblings, 2 replies; 5+ messages in thread
From: Ming Liu @ 2006-09-20 13:48 UTC (permalink / raw)
  To: linuxppc-embedded

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  

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-09-21 17:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-20 13:48 how an application program utilizes the driver Ming Liu
2006-09-20 16:14 ` David Hawkins
2006-09-20 16:30   ` Josh Boyer
2006-09-21  8:13   ` Ming Liu
2006-09-21 17:06 ` Eric Nuckols

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).