1 #ifndef _ASM_MIPS64_MODULE_H
2 #define _ASM_MIPS64_MODULE_H
3 /*
4  * This file contains the mips64 architecture specific module code.
5  */
6 
7 #include <linux/module.h>
8 #include <asm/uaccess.h>
9 
10 #define module_map(x)		vmalloc(x)
11 #define module_unmap(x)		vfree(x)
12 #define module_arch_init(x)	mips64_module_init(x)
13 #define arch_init_modules(x)	mips64_init_modules(x)
14 
15 /*
16  * This must match in size and layout the data created by
17  * modutils/obj/obj-mips64.c
18  */
19 struct archdata {
20 	const struct exception_table_entry *dbe_table_start;
21 	const struct exception_table_entry *dbe_table_end;
22 };
23 
24 static inline int
mips64_module_init(struct module * mod)25 mips64_module_init(struct module *mod)
26 {
27 	struct archdata *archdata;
28 
29 	if (!mod_member_present(mod, archdata_end))
30 		return 0;
31 
32 	archdata = (struct archdata *)(mod->archdata_start);
33 	if (!mod_archdata_member_present(mod, struct archdata, dbe_table_end))
34 		return 0;
35 
36 	if (archdata->dbe_table_start > archdata->dbe_table_end ||
37 	    (archdata->dbe_table_start &&
38 	     !((unsigned long)archdata->dbe_table_start >=
39 	       ((unsigned long)mod + mod->size_of_struct) &&
40 	       ((unsigned long)archdata->dbe_table_end <
41 	        (unsigned long)mod + mod->size))) ||
42             (((unsigned long)archdata->dbe_table_start -
43 	      (unsigned long)archdata->dbe_table_end) %
44 	     sizeof(struct exception_table_entry))) {
45 		printk(KERN_ERR
46 			"module_arch_init: archdata->dbe_table_* invalid.\n");
47 		return 1;
48 	}
49 
50 	return 0;
51 }
52 
53 static inline void
mips64_init_modules(struct module * mod)54 mips64_init_modules(struct module *mod)
55 {
56 	extern const struct exception_table_entry __start___dbe_table[];
57 	extern const struct exception_table_entry __stop___dbe_table[];
58 	static struct archdata archdata = {
59 		.dbe_table_start	= __start___dbe_table,
60 		.dbe_table_end		= __stop___dbe_table,
61 	};
62 
63 	mod->archdata_start = (char *)&archdata;
64 	mod->archdata_end = mod->archdata_start + sizeof(archdata);
65 }
66 
67 #endif /* _ASM_MIPS64_MODULE_H */
68