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 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
31 #include <sys/sysmacros.h>
32 #include <sys/promif.h>
33 #include <sys/bootconf.h>
34 #include <sys/salib.h>
37 static int resalloc_debug
= 1;
39 static int resalloc_debug
= 0;
41 #define dprintf if (resalloc_debug) printf
43 extern caddr_t
resalloc(enum RESOURCES type
,
44 size_t bytes
, caddr_t virthint
, int align
);
45 extern void resfree(enum RESOURCES type
,
46 caddr_t virtaddr
, size_t bytes
);
52 * This routine should be called get_a_page().
53 * It allocates from the appropriate entity one or
54 * more pages and maps them in.
58 kern_resalloc(caddr_t virthint
, size_t size
, int align
)
61 return (resalloc(RES_CHILDVIRT
, size
, virthint
, align
));
63 return (resalloc(RES_BOOTSCRATCH
, size
, NULL
, NULL
));
68 * This is called only on sparcv9 for freeing scratch memory.
69 * The standalone allocator cannot free other types of memory.
72 kern_resfree(caddr_t virtaddr
, size_t size
)
74 resfree(RES_BOOTSCRATCH
, virtaddr
, size
);
78 get_progmemory(caddr_t vaddr
, size_t size
, int align
)
83 * if the vaddr given is not a mult of PAGESIZE,
84 * then we rounddown to a page, but keep the same
87 n
= (uintptr_t)vaddr
& (pagesize
- 1);
93 dprintf("get_progmemory: requesting %lx bytes at %p\n", size
,
95 if (resalloc(RES_CHILDVIRT
, size
, vaddr
, align
) != vaddr
)