//test.c源程序
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/init.h>
int test_init(void);
void test_cleanup(void);
module_init(test_init);
module_exit(test_cleanup);
int test_int()
{
printfk(KERN_ERR "test:init OK /n");
return 0;
}
void test_cleanup(void)
{
printfk(KERN_ERR "test:remove OK/n");
}
//makefile文件
EXEC=test
OBJS=test.o
SRC=test.c
INCLUDE = /root/uClinux-dist/linux-2.4.x/include
CC=arm-elf-gcc
LD=arm-elf-ld
MODCFLAGS=-D__KERNEL__ -I$(INCLUDE) -O2 -fno-strict-aliasing -fno-common -pipe /
-fno-builtin -D__linux__ -g -DMODULE -DNO_MM -mapcs-32 -march=armv4 -mtune=arm7tdmi /
-mshort-load-bytes -msoft-float -nostdinc -iwithprefix include
LDFLAGS = -m armelf -r
all:$(EXEC)
$(EXEC):$(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS)
%.o:%.c
$(CC) $(MODCFLAGS) -mapcs -c $< -o $@
clean:
$(RM) -f $(EXEC) *.gdb *.elf *.o