mirror of
https://github.com/gatieme/LDD-LinuxDeviceDrivers.git
synced 2026-08-20 22:04:56 +08:00
添加对比crs和pgd的值的驱动...
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
|
||||
obj-m := crs_pgd.o
|
||||
|
||||
else
|
||||
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
|
||||
PWD := $(shell pwd)
|
||||
|
||||
all:
|
||||
make -C $(KERNELDIR) M=$(PWD) modules
|
||||
|
||||
clean:
|
||||
make -C $(KERNELDIR) M=$(PWD) clean
|
||||
|
||||
|
||||
endif
|
||||
@@ -0,0 +1,31 @@
|
||||
//#include <asm/system.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/mm_types.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
static unsigned long read_pgd(void)
|
||||
{
|
||||
return (unsigned long)current->mm->pgd;
|
||||
}
|
||||
|
||||
static int __init init_cr3_pgd(void)
|
||||
{
|
||||
unsigned long cr3;
|
||||
unsigned long pgd = 0;
|
||||
|
||||
cr3 = read_cr3();
|
||||
printk("cr3----------------->0x%lx\n",cr3);
|
||||
pgd = __pa(read_pgd());
|
||||
printk("pgd----------------->0x%lx\n",pgd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit exit_cr3_pgd(void)
|
||||
{
|
||||
printk("--------------------->exit!\n");
|
||||
return ;
|
||||
}
|
||||
|
||||
module_init(init_cr3_pgd);
|
||||
module_exit(exit_cr3_pgd);
|
||||
Reference in New Issue
Block a user