]>
Commit | Line | Data |
---|---|---|
3ad0a769 PM |
1 | /* |
2 | * loader.h: prototypes for linux-user guest binary loader | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | ||
18 | #ifndef LINUX_USER_LOADER_H | |
19 | #define LINUX_USER_LOADER_H | |
20 | ||
7d2c5526 RH |
21 | typedef struct { |
22 | const void *cache; | |
23 | unsigned int cache_size; | |
24 | int fd; | |
25 | } ImageSource; | |
26 | ||
27 | /** | |
28 | * imgsrc_read: Read from ImageSource | |
29 | * @dst: destination for read | |
30 | * @offset: offset within file for read | |
31 | * @len: size of the read | |
32 | * @img: ImageSource to read from | |
33 | * @errp: Error details. | |
34 | * | |
35 | * Read into @dst, using the cache when possible. | |
36 | */ | |
37 | bool imgsrc_read(void *dst, off_t offset, size_t len, | |
38 | const ImageSource *img, Error **errp); | |
39 | ||
40 | /** | |
41 | * imgsrc_read_alloc: Read from ImageSource | |
42 | * @offset: offset within file for read | |
43 | * @size: size of the read | |
44 | * @img: ImageSource to read from | |
45 | * @errp: Error details. | |
46 | * | |
47 | * Read into newly allocated memory, using the cache when possible. | |
48 | */ | |
49 | void *imgsrc_read_alloc(off_t offset, size_t len, | |
50 | const ImageSource *img, Error **errp); | |
51 | ||
52 | /** | |
53 | * imgsrc_mmap: Map from ImageSource | |
54 | * | |
55 | * If @src has a file descriptor, pass on to target_mmap. Otherwise, | |
56 | * this is "mapping" from a host buffer, which resolves to memcpy. | |
57 | * Therefore, flags must be MAP_PRIVATE | MAP_FIXED; the argument is | |
58 | * retained for clarity. | |
59 | */ | |
60 | abi_long imgsrc_mmap(abi_ulong start, abi_ulong len, int prot, | |
61 | int flags, const ImageSource *src, abi_ulong offset); | |
62 | ||
3ad0a769 PM |
63 | /* |
64 | * Read a good amount of data initially, to hopefully get all the | |
65 | * program headers loaded. | |
66 | */ | |
67 | #define BPRM_BUF_SIZE 1024 | |
68 | ||
69 | /* | |
70 | * This structure is used to hold the arguments that are | |
71 | * used when loading binaries. | |
72 | */ | |
73 | struct linux_binprm { | |
7d2c5526 RH |
74 | char buf[BPRM_BUF_SIZE] __attribute__((aligned)); |
75 | ImageSource src; | |
76 | abi_ulong p; | |
7d2c5526 RH |
77 | int e_uid, e_gid; |
78 | int argc, envc; | |
79 | char **argv; | |
80 | char **envp; | |
81 | char *filename; /* Name of binary */ | |
82 | int (*core_dump)(int, const CPUArchState *); /* coredump routine */ | |
3ad0a769 PM |
83 | }; |
84 | ||
85 | void do_init_thread(struct target_pt_regs *regs, struct image_info *infop); | |
86 | abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, | |
87 | abi_ulong stringp, int push_ptr); | |
88 | int loader_exec(int fdexec, const char *filename, char **argv, char **envp, | |
89 | struct target_pt_regs *regs, struct image_info *infop, | |
90 | struct linux_binprm *); | |
91 | ||
92 | uint32_t get_elf_eflags(int fd); | |
93 | int load_elf_binary(struct linux_binprm *bprm, struct image_info *info); | |
94 | int load_flt_binary(struct linux_binprm *bprm, struct image_info *info); | |
95 | ||
96 | abi_long memcpy_to_target(abi_ulong dest, const void *src, | |
97 | unsigned long len); | |
98 | ||
99 | extern unsigned long guest_stack_size; | |
100 | ||
a55b9e72 | 101 | #if defined(TARGET_S390X) || defined(TARGET_AARCH64) || defined(TARGET_ARM) |
e1b819c8 | 102 | uint32_t get_elf_hwcap(void); |
e19807be | 103 | const char *elf_hwcap_str(uint32_t bit); |
e1b819c8 | 104 | #endif |
a55b9e72 | 105 | #if defined(TARGET_AARCH64) || defined(TARGET_ARM) |
63c1b7de | 106 | uint64_t get_elf_hwcap2(void); |
a55b9e72 HD |
107 | const char *elf_hwcap2_str(uint32_t bit); |
108 | #endif | |
e1b819c8 | 109 | |
3ad0a769 | 110 | #endif /* LINUX_USER_LOADER_H */ |