设为首页 加入收藏

TOP

Linux驱动设计:Hello World
2014-11-24 08:17:51 来源: 作者: 【 】 浏览:1
Tags:Linux 驱动 设计 Hello World

步骤一、编写hello.c。
代码如下:
#include
#include
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_INFO " Hello World enter\n");
return 0;
}


static void hello_exit(void)
{
printk(KERN_INFO " Hello World exit\n ");
}


module_init(hello_init);
module_exit(hello_exit);


步骤二、编写makefile。
内容如下:
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR = /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux SA_RESTART的问题 下一篇Linux移植笔记----S3C2410

评论

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

·微服务 Spring Boot (2025-12-26 18:20:10)
·如何调整 Redis 内存 (2025-12-26 18:20:07)
·MySQL 数据类型:从 (2025-12-26 18:20:03)
·Linux Shell脚本教程 (2025-12-26 17:51:10)
·Qt教程,Qt5编程入门 (2025-12-26 17:51:07)