4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Function to allocate memory in target process (used by combinations).
37 #include "tnfctl_int.h"
38 #include "prb_internals.h"
43 * _tnfctl_targmem_alloc() - allocates memory in the target process.
46 _tnfctl_targmem_alloc(tnfctl_handle_t
*hndl
, size_t size
, uintptr_t *addr_p
)
51 assert(hndl
->memseg_p
!= NULL
);
54 /* read the memseg block from the target process */
55 miscstat
= hndl
->p_read(hndl
->proc_p
, hndl
->memseg_p
, &memseg
,
58 return (TNFCTL_ERR_INTERNAL
);
60 /* if there is memory left, allocate it */
61 if ((memseg
.min_p
+ memseg
.i_reqsz
) <= (memseg
.max_p
- size
)) {
64 miscstat
= hndl
->p_write(hndl
->proc_p
, hndl
->memseg_p
,
65 &memseg
, sizeof (memseg
));
67 return (TNFCTL_ERR_INTERNAL
);
69 *addr_p
= (uintptr_t) memseg
.max_p
;
71 DBG_TNF_PROBE_2(_tnfctl_targmem_alloc_1
, "libtnfctl",
73 tnf_long
, size_allocated
, size
,
74 tnf_opaque
, at_location
, *addr_p
);
76 return (TNFCTL_ERR_NONE
);
78 return (TNFCTL_ERR_INTERNAL
);