Linux设备驱动程序学习(一)入门必须的hello world
来源:互联网 发布:人工智能芯片上市公司 编辑:程序博客网 时间:2024/06/05 23:55
还是从最简单的“hello world”开始,源代码文件hello_world.c:
#include <linux/init.h>#include <linux/module.h>static int hello_world_init(void){printk(KERN_ALERT "hello, world!\n");return 0;}static void hello_world_exit(void){printk(KERN_ALERT "goodbye, cruel world!\n");}module_init(hello_world_init);module_exit(hello_world_exit);MODULE_LICENSE("Dual BSD/GPL");MODULE_AUTHOR("Keith Liu");
编译代码的Makefile文件内容如下:
ifneq ($(KERNELRELEASE),)obj-m := hello_world.oelseKERNELDIR ?= /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd)default:$(MAKE) -C $(KERNELDIR) M=$(PWD) modulesecho $(KERNELRELEASE)echo $(KERNELDIR)echo $(PWD)endif
其中的echo语句是我为了方便查看变量的内容而添加的,可以取消掉。需要注意的一点是:
ifneq与
($(KERNELRELEASE),)
之间必须要有空格分割,否则编译时会报错误。
- Linux设备驱动程序学习(一)入门必须的hello world
- Linux 驱动程序入门(hello world)
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world模块
- Linux设备驱动程序,个人学习,第一个模块hello world
- Linux设备驱动程序0-hello world
- linux 驱动程序的hello world
- <linux设备驱动程序>hello world 模块——不用main函数的hello world
- Linux驱动程序入门—Hello World
- Linux驱动程序入门—Hello World
- Linux驱动程序入门—Hello World
- Linux驱动程序入门—Hello World
- Linux设备驱动程序学习(0) -设备驱动介绍& Hello, world!模块
- 链式队列的简单实现
- 进程优先级逆转问题的解决
- Linux命令全称
- perl中grep用法总结 z
- 网络流题目
- Linux设备驱动程序学习(一)入门必须的hello world
- 堆排序
- Fedora 15
- 一个学习通信人网址
- gfxboot,gfxmenu源代码编写教程
- IBM大型主机(Mainframe)技术简介之七——应用开发摘要(三)
- 陈省身的一些讲话
- emacs 使用
- gnome-shell 字体更改