1 /*
2  * ARM AArch64 VM parameters definitions for bsd-user.
3  *
4  * Copyright (c) 2015 Stacey D. Son <sson at FreeBSD>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef TARGET_ARCH_VMPARAM_H
21 #define TARGET_ARCH_VMPARAM_H
22 
23 #include "cpu.h"
24 
25 /**
26  * FreeBSD/arm64 Address space layout.
27  *
28  * ARMv8 implements up to a 48 bit virtual address space. The address space is
29  * split into 2 regions at each end of the 64 bit address space, with an
30  * out of range "hole" in the middle.
31  *
32  * We limit the size of the two spaces to 39 bits each.
33  *
34  * Upper region:        0xffffffffffffffff
35  *                      0xffffff8000000000
36  *
37  * Hole:                0xffffff7fffffffff
38  *                      0x0000008000000000
39  *
40  * Lower region:        0x0000007fffffffff
41  *                      0x0000000000000000
42  *
43  * The upper region for the kernel, and the lower region for userland.
44  */
45 
46 
47 /* compare to sys/arm64/include/vmparam.h */
48 #define TARGET_MAXTSIZ      (1 * GiB)           /* max text size */
49 #define TARGET_DFLDSIZ      (128 * MiB)         /* initial data size limit */
50 #define TARGET_MAXDSIZ      (1 * GiB)           /* max data size */
51 #define TARGET_DFLSSIZ      (128 * MiB)         /* initial stack size limit */
52 #define TARGET_MAXSSIZ      (1 * GiB)           /* max stack size */
53 #define TARGET_SGROWSIZ     (128 * KiB)         /* amount to grow stack */
54 
55                 /* KERNBASE - 512 MB */
56 #define TARGET_VM_MAXUSER_ADDRESS   (0x00007fffff000000ULL - (512 * MiB))
57 #define TARGET_USRSTACK             TARGET_VM_MAXUSER_ADDRESS
58 
get_sp_from_cpustate(CPUARMState * state)59 static inline abi_ulong get_sp_from_cpustate(CPUARMState *state)
60 {
61     return state->xregs[31]; /* sp */
62 }
63 
set_second_rval(CPUARMState * state,abi_ulong retval2)64 static inline void set_second_rval(CPUARMState *state, abi_ulong retval2)
65 {
66     state->xregs[1] = retval2; /* XXX not really used on 64-bit arch */
67 }
68 
get_second_rval(CPUARMState * state)69 static inline abi_ulong get_second_rval(CPUARMState *state)
70 {
71     return state->xregs[1];
72 }
73 
74 #endif /* TARGET_ARCH_VMPARAM_H */
75