QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2882|回复: 8

谁能给我一个2.6内核“hello world!”的例子~~

[复制链接]
发表于 2006-9-21 21:59:29 | 显示全部楼层 |阅读模式
以及相关的Makefile文件
多谢多谢,能找到的都失败了~
顺便再问一下:内核模块的执行过程是怎么样的?
是按照module_init的过程执行,还是按/proc/kallsyms其他export的函数,用到什么函数就执行什么函数?
发表于 2006-9-22 09:25:43 | 显示全部楼层
insmod
回复

使用道具 举报

 楼主| 发表于 2006-9-22 17:08:25 | 显示全部楼层
insmod什么模块啊?林丽,
回复

使用道具 举报

 楼主| 发表于 2006-9-25 09:39:25 | 显示全部楼层
以后我会天天顶一下这个帖子,希望它别沉了,大家有谁能提供一个2.6“hello world”的模块程序,如果我自己实验出来了也会马上贴上来的~
回复

使用道具 举报

发表于 2006-9-25 13:59:14 | 显示全部楼层
不用每天顶了,你搜索一下,原来坛子里发过一个教程,自己看也许更快一些。
回复

使用道具 举报

 楼主| 发表于 2006-9-25 15:40:17 | 显示全部楼层
终于找到一个
http://www.dirac.org/linux/writing/lkmpg/2.6/chinese/lkmpg_chs/#AEN148
回复

使用道具 举报

发表于 2006-9-25 18:26:21 | 显示全部楼层
<linux device drivers>里讲过吧?
回复

使用道具 举报

 楼主| 发表于 2006-9-25 18:30:12 | 显示全部楼层
在不懈的努力下终于成功了
http://www.dirac.org/linux/writing/lkmpg/2.6/chinese/lkmpg_chs/#AEN46
2.6的例子;http://www.linuxfans.org/nuke/modules.php?name=Forums&file=posting&mode=reply&t=166726

hello-1.c
/*  
*  hello-1.c - The simplest kernel module.
*/
#include <linux/module.h>        /* Needed by all modules */
#include <linux/kernel.h>        /* Needed for KERN_ALERT */

int init_module(void)
{
        printk("<1>Hello world 1.\n");

        /*
         * A non 0 return means init_module failed; module can't be loaded.
         */
        return 0;
}

void cleanup_module(void)
{
        printk(KERN_ALERT "Goodbye world 1.\n");
}

Makefile文件:
obj-m += hello-1.o
PWD := $(shell pwd)

编译命令:
make -C /lib/modules/linux-2.6.16.1/build/  SUBDIRS=$PWD modules
回复

使用道具 举报

发表于 2006-9-25 23:00:14 | 显示全部楼层
:)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-3-29 17:23 , Processed in 0.094023 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

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