Chinaunix首页 | 论坛 | 博客
  • 博客访问: 233082
  • 博文数量: 56
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 375
  • 用 户 组: 普通用户
  • 注册时间: 2014-10-26 20:56
个人简介

http://www.csdn.net/ http://www.arm.com/zh/ https://www.kernel.org/ http://www.linuxpk.com/ http://www.51develop.net/ http://linux.chinaitlab.com/ http://www.embeddedlinux.org.cn http://bbs.pediy.com/

文章分类

全部博文(56)

文章存档

2018年(3)

2017年(12)

2016年(4)

2015年(22)

2014年(15)

分类: 其他平台

2015-11-24 11:30:34

//hello world driver for linux 2.6  
#include   
#include   
#include   
//MODULE_LICENCE("GPL");  
static int __init hello_init(void)  
{  
    printk(KERN_ALERT "Hello, world! from kernel space....\n");  
    return 0;  
}  
 
static void __exit hello_exit(void)  
{  
    printk(KERN_ALERT "Goodbye, world! Leaving kernel space....\n");  
}  
module_init(hello_init);  
module_exit(hello_exit); 

Makefile文件

obj-m += hello.o
all:
 make -C /lib/modules/`uname -r`/build SUBDIRS=$(PWD) modules
clean:
 make -C /lib/modules/`uname -r`/build SUBDIRS=$(PWD) clean

插入模块

#insmod hello.ko

查看模块插入情况

#lsmod | grep hello

#tail /var/log/messages

移除模块

#rmmod hello

#taile /var/log/messages


转载自 Linux公社网站()  原文链接:

阅读(1105) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~