pci: Switch bus reset to 3-phase-reset
[qemu/armbru.git] / bsd-user / bsd-mem.c
blob2ab1334b7003ea45cf4deb2fa2561a3038568107
1 /*
2 * memory management system conversion routines
4 * Copyright (c) 2013 Stacey D. Son
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.
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.
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/>.
19 #include "qemu/osdep.h"
20 #include "qemu.h"
21 #include "qemu-bsd.h"
23 struct bsd_shm_regions bsd_shm_regions[N_BSD_SHM_REGIONS];
25 abi_ulong target_brk;
26 abi_ulong initial_target_brk;
28 void target_set_brk(abi_ulong new_brk)
30 target_brk = TARGET_PAGE_ALIGN(new_brk);
31 initial_target_brk = target_brk;
34 void target_to_host_ipc_perm__locked(struct ipc_perm *host_ip,
35 struct target_ipc_perm *target_ip)
37 __get_user(host_ip->cuid, &target_ip->cuid);
38 __get_user(host_ip->cgid, &target_ip->cgid);
39 __get_user(host_ip->uid, &target_ip->uid);
40 __get_user(host_ip->gid, &target_ip->gid);
41 __get_user(host_ip->mode, &target_ip->mode);
42 __get_user(host_ip->seq, &target_ip->seq);
43 __get_user(host_ip->key, &target_ip->key);
46 abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd,
47 abi_ulong target_addr)
49 struct target_shmid_ds *target_sd;
51 if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) {
52 return -TARGET_EFAULT;
55 target_to_host_ipc_perm__locked(&(host_sd->shm_perm),
56 &(target_sd->shm_perm));
58 __get_user(host_sd->shm_segsz, &target_sd->shm_segsz);
59 __get_user(host_sd->shm_lpid, &target_sd->shm_lpid);
60 __get_user(host_sd->shm_cpid, &target_sd->shm_cpid);
61 __get_user(host_sd->shm_nattch, &target_sd->shm_nattch);
62 __get_user(host_sd->shm_atime, &target_sd->shm_atime);
63 __get_user(host_sd->shm_dtime, &target_sd->shm_dtime);
64 __get_user(host_sd->shm_ctime, &target_sd->shm_ctime);
65 unlock_user_struct(target_sd, target_addr, 0);
67 return 0;
70 void host_to_target_ipc_perm__locked(struct target_ipc_perm *target_ip,
71 struct ipc_perm *host_ip)
73 __put_user(host_ip->cuid, &target_ip->cuid);
74 __put_user(host_ip->cgid, &target_ip->cgid);
75 __put_user(host_ip->uid, &target_ip->uid);
76 __put_user(host_ip->gid, &target_ip->gid);
77 __put_user(host_ip->mode, &target_ip->mode);
78 __put_user(host_ip->seq, &target_ip->seq);
79 __put_user(host_ip->key, &target_ip->key);
82 abi_long host_to_target_shmid_ds(abi_ulong target_addr,
83 struct shmid_ds *host_sd)
85 struct target_shmid_ds *target_sd;
87 if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) {
88 return -TARGET_EFAULT;
91 host_to_target_ipc_perm__locked(&(target_sd->shm_perm),
92 &(host_sd->shm_perm));
94 __put_user(host_sd->shm_segsz, &target_sd->shm_segsz);
95 __put_user(host_sd->shm_lpid, &target_sd->shm_lpid);
96 __put_user(host_sd->shm_cpid, &target_sd->shm_cpid);
97 __put_user(host_sd->shm_nattch, &target_sd->shm_nattch);
98 __put_user(host_sd->shm_atime, &target_sd->shm_atime);
99 __put_user(host_sd->shm_dtime, &target_sd->shm_dtime);
100 __put_user(host_sd->shm_ctime, &target_sd->shm_ctime);
101 unlock_user_struct(target_sd, target_addr, 1);
103 return 0;