驱动-helloworld(第一天)

helloworl.c

 

 

 

#include<linux/init.h>

#include<linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)

{

    printk("hello world");

    return 0;

}

static void hello_exit(void)

{

    printk("exit the hello world!\n");

}

module_init(hello_init);

module_exit(hello_exit);

 

Makefile:

     obj-m :=helloworld.o

    KERNELDIR ?= /usr/src/kernel/linux-2.6.38                /内核目录,开发板和此内核名必须一致

    PWD :/ $(shell pwd)

    default:

              $(MAKE) -C $(KERNELDIR) M=$(PWD) modules    (注意:必须tab)

posted @ 2012-12-02 16:09  黑-色-柳—丁  阅读(356)  评论(0编辑  收藏  举报