Florian Fainelli | e4dace3 | 2017-09-08 16:15:31 -0700 | [diff] [blame] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/module.h> |
| 3 | #include <linux/export.h> |
| 4 | #include <linux/mm.h> |
| 5 | #include <linux/vmalloc.h> |
| 6 | #include <linux/slab.h> |
| 7 | #include <linux/sizes.h> |
Christophe Leroy | 4f44e58 | 2018-12-10 08:08:28 +0000 | [diff] [blame] | 8 | #include <linux/io.h> |
Florian Fainelli | e4dace3 | 2017-09-08 16:15:31 -0700 | [diff] [blame] | 9 | |
| 10 | #include <asm/page.h> |
| 11 | #ifdef CONFIG_MIPS |
| 12 | #include <asm/bootinfo.h> |
| 13 | #endif |
| 14 | |
| 15 | struct foo { |
| 16 | unsigned int bar; |
| 17 | }; |
| 18 | |
Colin Ian King | b15f5f1 | 2018-08-21 21:57:07 -0700 | [diff] [blame] | 19 | static struct foo *foo; |
Florian Fainelli | e4dace3 | 2017-09-08 16:15:31 -0700 | [diff] [blame] | 20 | |
| 21 | static int __init test_debug_virtual_init(void) |
| 22 | { |
| 23 | phys_addr_t pa; |
| 24 | void *va; |
| 25 | |
| 26 | va = (void *)VMALLOC_START; |
| 27 | pa = virt_to_phys(va); |
| 28 | |
| 29 | pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va); |
| 30 | |
| 31 | foo = kzalloc(sizeof(*foo), GFP_KERNEL); |
| 32 | if (!foo) |
| 33 | return -ENOMEM; |
| 34 | |
| 35 | pa = virt_to_phys(foo); |
| 36 | va = foo; |
| 37 | pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | module_init(test_debug_virtual_init); |
| 42 | |
| 43 | static void __exit test_debug_virtual_exit(void) |
| 44 | { |
| 45 | kfree(foo); |
| 46 | } |
| 47 | module_exit(test_debug_virtual_exit); |
| 48 | |
| 49 | MODULE_LICENSE("GPL"); |
| 50 | MODULE_DESCRIPTION("Test module for CONFIG_DEBUG_VIRTUAL"); |