From f7f2addc5c990ddaac48c4f1a6f299710baf86ca Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Fri, 4 Nov 2011 13:56:56 -0400 Subject: [PATCH] Add test-case to do wb->wc and vice-versa forever.. --- root_image/drivers/Makefile | 1 + root_image/drivers/wb_to_wc/Makefile | 37 ++++++++++++++++++ root_image/drivers/wb_to_wc/wb_to_wc.c | 53 ++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 root_image/drivers/wb_to_wc/Makefile create mode 100644 root_image/drivers/wb_to_wc/wb_to_wc.c diff --git a/root_image/drivers/Makefile b/root_image/drivers/Makefile index 3c1b76a..6dbdb75 100644 --- a/root_image/drivers/Makefile +++ b/root_image/drivers/Makefile @@ -1,4 +1,5 @@ obj-m += dump/ +obj-m += wb_to_wc/ .PHONY: distclean distclean: clean diff --git a/root_image/drivers/wb_to_wc/Makefile b/root_image/drivers/wb_to_wc/Makefile new file mode 100644 index 0000000..cc280a6 --- /dev/null +++ b/root_image/drivers/wb_to_wc/Makefile @@ -0,0 +1,37 @@ +# Comment/uncomment the following line to disable/enable debugging +#DEBUG = y + +# Add your debugging flag (or not) to CFLAGS +ifeq ($(DEBUG),y) + DEBFLAGS = -O -g # "-O" is needed to expand inlines +else + DEBFLAGS = -O2 +endif + +EXTRA_CFLAGS += $(DEBFLAGS) -I$(LDDINCDIR) + +ifneq ($(KERNELRELEASE),) +# call from kernel build system + +obj-m := wb_to_wc.o + +else + +KERNELDIR ?= /lib/modules/$(shell uname -r)/build +PWD := $(shell pwd) + +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINCDIR=$(PWD)/../include modules + +endif + +clean: + rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions + +depend .depend dep: + $(CC) $(CFLAGS) -M *.c > .depend + + +ifeq (.depend,$(wildcard .depend)) +include .depend +endif diff --git a/root_image/drivers/wb_to_wc/wb_to_wc.c b/root_image/drivers/wb_to_wc/wb_to_wc.c new file mode 100644 index 0000000..cd2439a --- /dev/null +++ b/root_image/drivers/wb_to_wc/wb_to_wc.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#define WB_TO_WC "0.1" + +MODULE_AUTHOR("Konrad Rzeszutek Wilk "); +MODULE_DESCRIPTION("wb_to_wc_and_back"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(WB_TO_WC); + +#define MAX_PAGES 20 +static int thread(void *arg) +{ + struct page *a[MAX_PAGES]; + unsigned int i, j; + do { + for (j = 0, i = 0;i < MAX_PAGES; i++, j++) { + a[i] = alloc_page(GFP_KERNEL); + if (!a[i]) + break; + } + set_pages_array_wc(a, j); + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout_interruptible(HZ); + for (i = 0; i < j; i++) { + unsigned long *addr = page_address(a[i]); + if (addr) { + memset(addr, 0xc2, PAGE_SIZE); + } + } + set_pages_array_wb(a, j); + for (i = 0; i< MAX_PAGES; i++) { + if (a[i]) + __free_page(a[i]); + a[i] = NULL; + } + } while (!kthread_should_stop()); + return 0; +} +static struct task_struct *t; +static int __init wb_to_wc_init(void) +{ + t = kthread_run(thread, NULL, "wb_to_wc_and_back"); + return 0; +} +static void __exit wb_to_wc_exit(void) +{ + if (t) + kthread_stop(t); +} +module_init(wb_to_wc_init); +module_exit(wb_to_wc_exit); -- 2.39.5