mirror of
https://github.com/gatieme/LDD-LinuxDeviceDrivers.git
synced 2026-09-22 12:43:39 +08:00
android驱动代码测试...
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile for the LDD-LinuxDeviceDrivers.
|
||||
#
|
||||
# Author: gatieme
|
||||
# Create: 2016-07-29 15:50:46
|
||||
# Last modified: 2016-07-29 16:10:29
|
||||
# Description:
|
||||
# This program is loaded as a kernel(v2.6.18 or later) module.
|
||||
# Use "make install" to load it into kernel.
|
||||
# Use "make remove" to remove the module out of kernel.
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
ROOT=..
|
||||
#PLATFORM=$(shell $(ROOT)/systype.sh)
|
||||
#include $(ROOT)/Make.defines.$(PLATFORM)
|
||||
|
||||
# my driver description
|
||||
DRIVER_VERSION := "1.0.0"
|
||||
DRIVER_AUTHOR := "Gatieme @ AderStep Inc..."
|
||||
DRIVER_DESC := "Linux input module for Elo MultiTouch(MT) devices"
|
||||
DRIVER_LICENSE := "Dual BSD/GPL"
|
||||
|
||||
|
||||
MODULE_NAME := test
|
||||
#MODCFLAGS:=-O2 -Wall -DMODULE -D__KERNEL__ -DLINUX -std=c99
|
||||
#EXTRA_CFLAGS += $(MODULE_FLAGS) $(CFG_INC) $(CFG_INC)
|
||||
|
||||
|
||||
|
||||
ifneq ($(KERNELRELEASE),) # kernelspace
|
||||
|
||||
obj-m := $(MODULE_NAME).o
|
||||
|
||||
else # userspace
|
||||
|
||||
CURRENT_PATH ?= $(shell pwd)
|
||||
ifeq ($(ARCH),arm64)
|
||||
LINUX_KERNEL_PATH ?= /home/rockchip/rk3399/Android/7.1/android/kernel
|
||||
else
|
||||
LINUX_KERNEL ?= $(shell uname -r)
|
||||
LINUX_KERNEL_PATH ?= /lib/modules/$(LINUX_KERNEL)/build
|
||||
endif
|
||||
|
||||
|
||||
modules:
|
||||
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules
|
||||
|
||||
modules_install:
|
||||
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules_install
|
||||
|
||||
|
||||
|
||||
insmod:
|
||||
sudo insmod $(MODULE_NAME).ko
|
||||
|
||||
reinsmod:
|
||||
sudo rmmod $(MODULE_NAME)
|
||||
sudo insmod $(MODULE_NAME).ko
|
||||
|
||||
github:
|
||||
cd $(ROOT) && make github
|
||||
|
||||
rmmod:
|
||||
sudo rmmod $(MODULE_NAME)
|
||||
|
||||
test :
|
||||
sudo ../injector/memInjector -l stack -m random -t word_0 --time 1 --timeout 3 -p 1
|
||||
|
||||
clean:
|
||||
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean
|
||||
rm -f modules.order Module.symvers Module.markers
|
||||
|
||||
.PHNOY:
|
||||
modules modules_install clean
|
||||
|
||||
|
||||
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/sched.h>
|
||||
//#include <linux/list.h>
|
||||
//#include <linux/mm.h>
|
||||
//#include <linux/mm_types.h>
|
||||
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_AUTHOR("Gatieme");
|
||||
MODULE_DESCRIPTION("test world");
|
||||
|
||||
/*
|
||||
* print the module information
|
||||
*/
|
||||
static void print_module(void)
|
||||
{
|
||||
struct module *mod;
|
||||
|
||||
printk(KERN_ALERT "this module: %p==%p\n", &__this_module, THIS_MODULE);
|
||||
printk(KERN_ALERT "module state: %d\n", THIS_MODULE->state);
|
||||
printk(KERN_ALERT "module name: %s\n", THIS_MODULE->name);
|
||||
|
||||
list_for_each_entry(mod, *(&THIS_MODULE->list.prev), list);
|
||||
printk(KERN_ALERT "module name: %s\n", mod->name);
|
||||
printk(KERN_ALERT "module state: %d\n", THIS_MODULE->state);
|
||||
}
|
||||
|
||||
|
||||
static int test_init(void)
|
||||
{
|
||||
print_module( );
|
||||
|
||||
printk(KERN_ALERT "run in cpu %d\n", get_cpu());
|
||||
|
||||
printk(KERN_ALERT "PAGE_OFFSET : 0x%lx, TASK_SIZE : 0x%lx", PAGE_OFFSET, TASK_SIZE);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void test_exit(void)
|
||||
{
|
||||
printk(KERN_ERR"exit");
|
||||
}
|
||||
|
||||
|
||||
module_init(test_init);
|
||||
module_exit(test_exit);
|
||||
Reference in New Issue
Block a user