]> git.proxmox.com Git - mirror_qemu.git/blame - bsd-user/i386/target_arch_elf.h
bsd-user: Move per-cpu code into target_arch_cpu.h
[mirror_qemu.git] / bsd-user / i386 / target_arch_elf.h
CommitLineData
66ef252f
WL
1/*
2 * i386 ELF definitions
3 *
4 * Copyright (c) 2013 Stacey D. Son
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef _TARGET_ARCH_ELF_H_
20#define _TARGET_ARCH_ELF_H_
21
22#define ELF_PLATFORM get_elf_platform()
23
24static const char *get_elf_platform(void)
25{
26 static char elf_platform[] = "i386";
27 int family = object_property_get_int(OBJECT(thread_cpu), "family", NULL);
28 if (family > 6) {
29 family = 6;
30 }
31 if (family >= 3) {
32 elf_platform[1] = '0' + family;
33 }
34 return elf_platform;
35}
36
37#define ELF_HWCAP get_elf_hwcap()
38
39static uint32_t get_elf_hwcap(void)
40{
41 X86CPU *cpu = X86_CPU(thread_cpu);
42
43 return cpu->env.features[FEAT_1_EDX];
44}
45
46#define ELF_START_MMAP 0x80000000
47
48/*
49 * This is used to ensure we don't load something for the wrong architecture.
50 */
51#define elf_check_arch(x) (((x) == EM_386) || ((x) == EM_486))
52
53/*
54 * These are used to set parameters in the core dumps.
55 */
56#define ELF_CLASS ELFCLASS32
57#define ELF_DATA ELFDATA2LSB
58#define ELF_ARCH EM_386
59
60static inline void init_thread(struct target_pt_regs *regs,
61 struct image_info *infop)
62{
63 regs->esp = infop->start_stack;
64 regs->eip = infop->entry;
65
66 /*
67 * SVR4/i386 ABI (pages 3-31, 3-32) says that when the program
68 * starts %edx contains a pointer to a function which might be
69 * registered using `atexit'. This provides a mean for the
70 * dynamic linker to call DT_FINI functions for shared libraries
71 * that have been loaded before the code runs.
72 *
73 * A value of 0 tells we have no such handler.
74 */
75 regs->edx = 0;
76}
77
78#define USE_ELF_CORE_DUMP
79#define ELF_EXEC_PAGESIZE 4096
80
81#endif /* _TARGET_ARCH_ELF_H_ */