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 Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/promif.h>
30 #include <sys/promimpl.h>
33 * Allocate retained physical memory
34 * Returns 0: Success; Non-zero: failure.
35 * Returns *phys_hi, *phys_lo only if successful.
38 prom_retain(char *id
, size_t size
, u_int align
, unsigned long long *physaddr
)
42 ihandle_t imemory
= prom_memory_ihandle();
44 if ((imemory
== (ihandle_t
)-1))
47 ci
[0] = p1275_ptr2cell("call-method"); /* Service name */
48 ci
[1] = (cell_t
)5; /* #argument cells */
49 ci
[2] = (cell_t
)3; /* #result cells */
50 ci
[3] = p1275_ptr2cell("SUNW,retain"); /* Arg1: Method name */
51 ci
[4] = p1275_ihandle2cell(imemory
); /* Arg2: memory ihandle */
52 ci
[5] = p1275_uint2cell(align
); /* Arg2: SA1: align */
53 ci
[6] = p1275_size2cell(size
); /* Arg3: SA2: size */
54 ci
[7] = p1275_ptr2cell(id
); /* Arg4: SA3: id name */
57 rv
= p1275_cif_handler(&ci
);
61 return (rv
); /* Service "call-method" failed */
62 if (ci
[8] != 0) /* Res1: catch-result */
63 return (-1); /* Method "SUNW,retain" failed */
65 *physaddr
= p1275_cells2ull(ci
[9], ci
[10]);
66 /* Res3: base.hi, Res4: base.lo */