设为首页 加入收藏

TOP

Linux驱动设计:Hello World
2014-11-24 08:17:51 来源: 作者: 【 】 浏览:0
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

评论

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

·求navicat for mysql (2025-12-26 13:21:33)
·有哪位大哥推荐一下m (2025-12-26 13:21:30)
·MySQL下载与安装教程 (2025-12-26 13:21:26)
·Linux_百度百科 (2025-12-26 12:51:52)
·Shell 流程控制 | 菜 (2025-12-26 12:51:49)