target: Improve error reporting for CpuModelInfo member @props
[qemu/kevin.git] / linux-user / loader.h
blobe102e6f4108f470c08c6c755d1a8bcf91a8afbb4
1 /*
2 * loader.h: prototypes for linux-user guest binary loader
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.
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.
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/>.
18 #ifndef LINUX_USER_LOADER_H
19 #define LINUX_USER_LOADER_H
21 typedef struct {
22 const void *cache;
23 unsigned int cache_size;
24 int fd;
25 } ImageSource;
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.
35 * Read into @dst, using the cache when possible.
37 bool imgsrc_read(void *dst, off_t offset, size_t len,
38 const ImageSource *img, Error **errp);
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.
47 * Read into newly allocated memory, using the cache when possible.
49 void *imgsrc_read_alloc(off_t offset, size_t len,
50 const ImageSource *img, Error **errp);
52 /**
53 * imgsrc_mmap: Map from ImageSource
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.
60 abi_long imgsrc_mmap(abi_ulong start, abi_ulong len, int prot,
61 int flags, const ImageSource *src, abi_ulong offset);
64 * Read a good amount of data initially, to hopefully get all the
65 * program headers loaded.
67 #define BPRM_BUF_SIZE 1024
70 * This structure is used to hold the arguments that are
71 * used when loading binaries.
73 struct linux_binprm {
74 char buf[BPRM_BUF_SIZE] __attribute__((aligned));
75 ImageSource src;
76 abi_ulong p;
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 */
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 *);
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);
96 abi_long memcpy_to_target(abi_ulong dest, const void *src,
97 unsigned long len);
99 extern unsigned long guest_stack_size;
101 #if defined(TARGET_S390X) || defined(TARGET_AARCH64) || defined(TARGET_ARM)
102 uint32_t get_elf_hwcap(void);
103 const char *elf_hwcap_str(uint32_t bit);
104 #endif
105 #if defined(TARGET_AARCH64) || defined(TARGET_ARM)
106 uint64_t get_elf_hwcap2(void);
107 const char *elf_hwcap2_str(uint32_t bit);
108 #endif
110 #endif /* LINUX_USER_LOADER_H */