[본문스크랩] Kernel Version 2.6.X에서 모듈 프로그래밍 방법
/* Hello.c */
#include
#include
int init_module(void)
{
printk("<1>Hello world 1.n");
return 0;
}
void cleanup_module(void)
{
printk("Goodbye world 1.n");
}
Compile하고~
# insmod hello.o
insmod: error inserting 'hello-1.o': -1 Invalid module format
Kernel Version 2.6에서부터 Module은 .O가 아니라 .KO형태로 제공됩니다.
그래서 소스(Hello.c)를 아래와 같이 바꾸어 주어야 합니다.
/* 수정된 hello.c */
#include
#include
#include
static int __init hello_2_init(void)
{
printk(KERN_ALERT "Hello, worldn");
return 0;
}
static void __exit hello_2_exit(void)
{
printk(KERN_ALERT "Goodbye, worldn");
}
module_init(hello_2_init);
module_exit(hello_2_exit);
MODULE_LICENSE("GPL");
/*Makefile*/ --> make 파일명 반드시 대문자 Makefile로 쓸것!!
KSRC=/lib/modules/2.6.4/build
obj-m = hello.o
build:
make -C $(KSRC) SUBDIRS=`pwd` modules
'Embedded System > Device Driver' 카테고리의 다른 글
[본문스크랩] 『리눅스 학당-리눅스 강좌 / 연재 (go LINUX)』 736번 (0) | 2006.12.15 |
---|---|
[본문스크랩] 드라이버의 파라미터 (0) | 2006.07.20 |
커널 2.6.x 디바이스 드라이버 (0) | 2006.07.20 |
디바이스 드라이버 작성시 고려사항 (0) | 2006.07.20 |
Linux Device Drivers, Third Edition (0) | 2006.07.20 |