设为首页 加入收藏

TOP

Linux 多个文件.c 一个模块
2014-11-24 07:34:51 来源: 作者: 【 】 浏览:0
Tags:Linux 多个 文件 一个 模块

test.h
--------------------------------------------
#define BUF_SIZE 100


typedef struct {
void * base_addr;
int buf_size;
} buf_info;


extern buf_info skb_info;
void init_buf(buf_info * skb_info);


test.c
--------------------------------------------
#include "test.h"
buf_info skb_info;


void init_buf(buf_info * skb_info)
{
skb_info->base_addr = 0;
skb_info->buf_size = BUF_SIZE;
}


hello.c
--------------------------------------------
#include
#include
#include
#include "test.h"


static int __init hello_init(void)
{
printk("<1>Hello world 1.\n");
printk("<1>HZ = %d\n", HZ);
init_buf(&skb_info);
return 0;
}


static void __exit hello_exit(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}


module_init(hello_init);
module_exit(hello_exit);


MODULE_LICENSE("GPL");
MODULE_AUTHOR("zengxiaolong ");
MODULE_DESCRIPTION("A sample driver");
MODULE_SUPPORTED_DEVICE("testdevice");


Makefile
--------------------------------------------
KERNEL_LOCATION := /home/zengxiaolong/soft/s3c2410/linux-2.6.24
obj-m += helloworld.o
helloworld-y += hello.o
helloworld-y += test.o



all:
make -C $(KERNEL_LOCATION) M=`pwd` modules
clean:
make -C $(KERNEL_LOCATION) M=`pwd` clean


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux 自动生成设备节点 下一篇Linux程序源码编译安装的configur..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Redis 分布式锁全解 (2025-12-25 17:19:51)
·SpringBoot 整合 Red (2025-12-25 17:19:48)
·MongoDB 索引 - 菜鸟 (2025-12-25 17:19:45)
·What Is Linux (2025-12-25 16:57:17)
·Linux小白必备:超全 (2025-12-25 16:57:14)