tizen 2.0
[external/module-init-tools.git] / elfops.h
1 #ifndef MODINITTOOLS_MODULEOPS_H
2 #define MODINITTOOLS_MODULEOPS_H
3 #include <stdio.h>
4 #include <stdint.h>
5 #include "logging.h"
6
7 /* All the icky stuff to do with manipulating 64 and 32-bit modules
8    belongs here. */
9 struct modver_info32
10 {
11         uint32_t crc;
12         char name[64 - sizeof(uint32_t)];
13 };
14
15 struct modver_info64
16 {
17         uint64_t crc;
18         char name[64 - sizeof(uint64_t)];
19 };
20
21 struct elf_file
22 {
23         char *pathname;
24
25         /* File operations */
26         struct module_ops *ops;
27
28         /* Convert endian? */
29         int conv;
30
31         /* File contents and length. */
32         void *data;
33         unsigned long len;
34 };
35
36 /* Tables extracted from module by ops->fetch_tables(). */
37 struct module_tables
38 {
39         unsigned int pci_size;
40         void *pci_table;
41         unsigned int usb_size;
42         void *usb_table;
43         unsigned int ieee1394_size;
44         void *ieee1394_table;
45         unsigned int ccw_size;
46         void *ccw_table;
47         unsigned int pnp_size;
48         void *pnp_table;
49         unsigned int pnp_card_size;
50         unsigned int pnp_card_offset;
51         void *pnp_card_table;
52         unsigned int input_size;
53         void *input_table;
54         unsigned int input_table_size;
55         unsigned int serio_size;
56         void *serio_table;
57         unsigned int of_size;
58         void *of_table;
59 };
60
61 struct module_ops
62 {
63         void *(*load_section)(struct elf_file *module,
64                 const char *secname, unsigned long *secsize);
65         struct string_table *(*load_strings)(struct elf_file *module,
66                 const char *secname, struct string_table *tbl);
67         struct string_table *(*load_symbols)(struct elf_file *module,
68                 uint64_t **versions);
69         struct string_table *(*load_dep_syms)(struct elf_file *module,
70                 struct string_table **types, uint64_t **versions);
71         void (*fetch_tables)(struct elf_file *module,
72                 struct module_tables *tables);
73         char *(*get_aliases)(struct elf_file *module, unsigned long *size);
74         char *(*get_modinfo)(struct elf_file *module, unsigned long *size);
75         void (*strip_section)(struct elf_file *module, const char *secname);
76         int (*dump_modvers)(struct elf_file *module);
77 };
78
79 extern struct module_ops mod_ops32, mod_ops64;
80
81 struct elf_file *grab_elf_file(const char *pathname);
82 void release_elf_file(struct elf_file *file);
83
84 #endif /* MODINITTOOLS_MODULEOPS_H */