[新增] 华清 源码
This commit is contained in:
22
module/ex1/Makefile
Executable file
22
module/ex1/Makefile
Executable file
@ -0,0 +1,22 @@
|
||||
ifeq ($(KERNELRELEASE),)
|
||||
|
||||
ifeq ($(ARCH),arm)
|
||||
KERNELDIR ?= /home/farsight/fs4412/linux-3.14.25-fs4412
|
||||
ROOTFS ?= /nfs/rootfs
|
||||
else
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
endif
|
||||
PWD := $(shell pwd)
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
|
||||
modules_install:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=$(ROOTFS) modules_install
|
||||
clean:
|
||||
rm -rf *.o *.ko .*.cmd *.mod.* modules.order Module.symvers .tmp_versions
|
||||
else
|
||||
|
||||
obj-m := vser.o
|
||||
|
||||
endif
|
||||
|
||||
14
module/ex1/vser.c
Executable file
14
module/ex1/vser.c
Executable file
@ -0,0 +1,14 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
printk("module init\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
printk("cleanup module\n");
|
||||
}
|
||||
22
module/ex2/Makefile
Executable file
22
module/ex2/Makefile
Executable file
@ -0,0 +1,22 @@
|
||||
ifeq ($(KERNELRELEASE),)
|
||||
|
||||
ifeq ($(ARCH),arm)
|
||||
KERNELDIR ?= /home/farsight/fs4412/linux-3.14.25-fs4412
|
||||
ROOTFS ?= /nfs/rootfs
|
||||
else
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
endif
|
||||
PWD := $(shell pwd)
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
|
||||
modules_install:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=$(ROOTFS) modules_install
|
||||
clean:
|
||||
rm -rf *.o *.ko .*.cmd *.mod.* modules.order Module.symvers .tmp_versions
|
||||
else
|
||||
|
||||
obj-m := vser.o
|
||||
|
||||
endif
|
||||
|
||||
22
module/ex2/vser.c
Executable file
22
module/ex2/vser.c
Executable file
@ -0,0 +1,22 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
static int __init vser_init(void)
|
||||
{
|
||||
printk("vser_init\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit vser_exit(void)
|
||||
{
|
||||
printk("vser_exit\n");
|
||||
}
|
||||
|
||||
module_init(vser_init);
|
||||
module_exit(vser_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Kevin Jiang <jiangxg@farsight.com.cn>");
|
||||
MODULE_DESCRIPTION("A simple module");
|
||||
MODULE_ALIAS("virtual-serial");
|
||||
23
module/ex3/Makefile
Executable file
23
module/ex3/Makefile
Executable file
@ -0,0 +1,23 @@
|
||||
ifeq ($(KERNELRELEASE),)
|
||||
|
||||
ifeq ($(ARCH),arm)
|
||||
KERNELDIR ?= /home/farsight/fs4412/linux-3.14.25-fs4412
|
||||
ROOTFS ?= /nfs/rootfs
|
||||
else
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
endif
|
||||
PWD := $(shell pwd)
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
|
||||
modules_install:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=$(ROOTFS) modules_install
|
||||
clean:
|
||||
rm -rf *.o *.ko .*.cmd *.mod.* modules.order Module.symvers .tmp_versions
|
||||
else
|
||||
|
||||
obj-m := vser.o
|
||||
vser-objs = foo.o bar.o
|
||||
|
||||
endif
|
||||
|
||||
6
module/ex3/bar.c
Executable file
6
module/ex3/bar.c
Executable file
@ -0,0 +1,6 @@
|
||||
#include <linux/kernel.h>
|
||||
|
||||
void bar(void)
|
||||
{
|
||||
printk("bar\n");
|
||||
}
|
||||
25
module/ex3/foo.c
Executable file
25
module/ex3/foo.c
Executable file
@ -0,0 +1,25 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
extern void bar(void);
|
||||
|
||||
static int __init vser_init(void)
|
||||
{
|
||||
printk("vser_init\n");
|
||||
bar();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit vser_exit(void)
|
||||
{
|
||||
printk("vser_exit\n");
|
||||
}
|
||||
|
||||
module_init(vser_init);
|
||||
module_exit(vser_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Kevin Jiang <jiangxg@farsight.com.cn>");
|
||||
MODULE_DESCRIPTION("A simple module");
|
||||
MODULE_ALIAS("virtual-serial");
|
||||
22
module/ex4/Makefile
Executable file
22
module/ex4/Makefile
Executable file
@ -0,0 +1,22 @@
|
||||
ifeq ($(KERNELRELEASE),)
|
||||
|
||||
ifeq ($(ARCH),arm)
|
||||
KERNELDIR ?= /home/farsight/fs4412/linux-3.14.25-fs4412
|
||||
ROOTFS ?= /nfs/rootfs
|
||||
else
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
endif
|
||||
PWD := $(shell pwd)
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
|
||||
modules_install:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=$(ROOTFS) modules_install
|
||||
clean:
|
||||
rm -rf *.o *.ko .*.cmd *.mod.* modules.order Module.symvers .tmp_versions
|
||||
else
|
||||
|
||||
obj-m := vser.o
|
||||
|
||||
endif
|
||||
|
||||
39
module/ex4/vser.c
Executable file
39
module/ex4/vser.c
Executable file
@ -0,0 +1,39 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
static int baudrate = 9600;
|
||||
static int port[4] = {0, 1, 2, 3};
|
||||
static char *name = "vser";
|
||||
|
||||
module_param(baudrate, int, S_IRUGO);
|
||||
module_param_array(port, int, NULL, S_IRUGO);
|
||||
module_param(name, charp, S_IRUGO);
|
||||
|
||||
static int __init vser_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printk("vser_init\n");
|
||||
printk("baudrate: %d\n", baudrate);
|
||||
printk("port: ");
|
||||
for (i = 0; i < ARRAY_SIZE(port); i++)
|
||||
printk("%d ", port[i]);
|
||||
printk("\n");
|
||||
printk("name: %s\n", name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit vser_exit(void)
|
||||
{
|
||||
printk("vser_exit\n");
|
||||
}
|
||||
|
||||
module_init(vser_init);
|
||||
module_exit(vser_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Kevin Jiang <jiangxg@farsight.com.cn>");
|
||||
MODULE_DESCRIPTION("A simple module");
|
||||
MODULE_ALIAS("virtual-serial");
|
||||
23
module/ex5/Makefile
Executable file
23
module/ex5/Makefile
Executable file
@ -0,0 +1,23 @@
|
||||
ifeq ($(KERNELRELEASE),)
|
||||
|
||||
ifeq ($(ARCH),arm)
|
||||
KERNELDIR ?= /home/farsight/fs4412/linux-3.14.25-fs4412
|
||||
ROOTFS ?= /nfs/rootfs
|
||||
else
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
endif
|
||||
PWD := $(shell pwd)
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
|
||||
modules_install:
|
||||
$(MAKE) -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=$(ROOTFS) modules_install
|
||||
clean:
|
||||
rm -rf *.o *.ko .*.cmd *.mod.* modules.order Module.symvers .tmp_versions
|
||||
else
|
||||
|
||||
obj-m := vser.o
|
||||
obj-m += dep.o
|
||||
|
||||
endif
|
||||
|
||||
15
module/ex5/dep.c
Executable file
15
module/ex5/dep.c
Executable file
@ -0,0 +1,15 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
static int expval = 5;
|
||||
EXPORT_SYMBOL(expval);
|
||||
|
||||
static void expfun(void)
|
||||
{
|
||||
printk("expfun\n");
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL_GPL(expfun);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Kevin Jiang <jiangxg@farsight.com.cn>");
|
||||
28
module/ex5/vser.c
Executable file
28
module/ex5/vser.c
Executable file
@ -0,0 +1,28 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
extern int expval;
|
||||
extern void expfun(void);
|
||||
|
||||
static int __init vser_init(void)
|
||||
{
|
||||
printk("vser_init\n");
|
||||
printk("expval: %d\n", expval);
|
||||
expfun();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit vser_exit(void)
|
||||
{
|
||||
printk("vser_exit\n");
|
||||
}
|
||||
|
||||
module_init(vser_init);
|
||||
module_exit(vser_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Kevin Jiang <jiangxg@farsight.com.cn>");
|
||||
MODULE_DESCRIPTION("A simple module");
|
||||
MODULE_ALIAS("virtual-serial");
|
||||
Reference in New Issue
Block a user