找回密码
 注册
搜索
查看: 1246|回复: 1

Linux驱动程序设计

[复制链接]
发表于 2007-11-14 19:44:15 | 显示全部楼层 |阅读模式
【文件名】:071114@52RD_Linux设备驱动程序(1).doc
【格 式】:doc
【大 小】:130K
【简 介】:
【目 录】:




简单的hello驱动程序
编辑文件
vi hello.c

#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif
#include <linux/config.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
#ifdef CONFIG_SMP
#define __SMP__
#endif

#include <linux/kernel.h>  /* printk()...... */

static int init_module(){
printk("Hello,World!
");
return 0;
}

static void cleanup_module(){
printk("Bye!
");
}

1.2 编译
gcc –c hello.c –I /usr/src/linux/include –o hello.o
如果用于嵌入式运行环境 arm-linux-gcc –c hello.c –I …./include –o hello.o

1.3 运行
insmod hello.o  //装载hello驱动
rmmod  hello //卸载hello驱动
此时在控制台上看不到prink打出的信息,使用dmesg可以看到 hello,world! Bye!等信息。


scull驱动程序
编辑文件
scull.c
Vi scull.c
#ifndef __KERNEL__
#define __KERNEL__

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2014-1-18 23:42:19 | 显示全部楼层
真好的资料,好好学习!
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-4-20 20:41 , Processed in 0.049601 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表