Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 #include <linux/kernel.h>
0003 #include <linux/module.h>
0004 #include <linux/export.h>
0005 #include <linux/mm.h>
0006 #include <linux/vmalloc.h>
0007 #include <linux/slab.h>
0008 #include <linux/sizes.h>
0009 #include <linux/io.h>
0010 
0011 #include <asm/page.h>
0012 #ifdef CONFIG_MIPS
0013 #include <asm/bootinfo.h>
0014 #endif
0015 
0016 struct foo {
0017     unsigned int bar;
0018 };
0019 
0020 static struct foo *foo;
0021 
0022 static int __init test_debug_virtual_init(void)
0023 {
0024     phys_addr_t pa;
0025     void *va;
0026 
0027     va = (void *)VMALLOC_START;
0028     pa = virt_to_phys(va);
0029 
0030     pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va);
0031 
0032     foo = kzalloc(sizeof(*foo), GFP_KERNEL);
0033     if (!foo)
0034         return -ENOMEM;
0035 
0036     pa = virt_to_phys(foo);
0037     va = foo;
0038     pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va);
0039 
0040     return 0;
0041 }
0042 module_init(test_debug_virtual_init);
0043 
0044 static void __exit test_debug_virtual_exit(void)
0045 {
0046     kfree(foo);
0047 }
0048 module_exit(test_debug_virtual_exit);
0049 
0050 MODULE_LICENSE("GPL");
0051 MODULE_DESCRIPTION("Test module for CONFIG_DEBUG_VIRTUAL");