10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
51772Sjl139090 * Common Development and Distribution License (the "License").
61772Sjl139090 * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*11112SJerry.Gilliam@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate #include <sys/param.h>
280Sstevel@tonic-gate #include <sys/fcntl.h>
290Sstevel@tonic-gate #include <sys/promif.h>
300Sstevel@tonic-gate #include <sys/prom_plat.h>
310Sstevel@tonic-gate #include <sys/salib.h>
320Sstevel@tonic-gate
330Sstevel@tonic-gate int pagesize = PAGESIZE;
340Sstevel@tonic-gate
350Sstevel@tonic-gate void
fiximp(void)360Sstevel@tonic-gate fiximp(void)
370Sstevel@tonic-gate {
380Sstevel@tonic-gate extern int use_align;
390Sstevel@tonic-gate
400Sstevel@tonic-gate use_align = 1;
410Sstevel@tonic-gate }
420Sstevel@tonic-gate
430Sstevel@tonic-gate void
setup_aux(void)440Sstevel@tonic-gate setup_aux(void)
450Sstevel@tonic-gate {
46789Sahrens pnode_t node;
470Sstevel@tonic-gate /* big enough for OBP_NAME and for a reasonably sized OBP_COMPATIBLE. */
480Sstevel@tonic-gate static char cpubuf[5 * OBP_MAXDRVNAME];
491772Sjl139090 char dname[OBP_MAXDRVNAME];
500Sstevel@tonic-gate extern uint_t icache_flush;
510Sstevel@tonic-gate extern char *cpulist;
520Sstevel@tonic-gate
530Sstevel@tonic-gate icache_flush = 1;
540Sstevel@tonic-gate node = prom_findnode_bydevtype(prom_rootnode(), OBP_CPU);
550Sstevel@tonic-gate if (node != OBP_NONODE && node != OBP_BADNODE) {
560Sstevel@tonic-gate int nlen, clen, i;
570Sstevel@tonic-gate
580Sstevel@tonic-gate if ((nlen = prom_getproplen(node, OBP_NAME)) <= 0 ||
590Sstevel@tonic-gate nlen > sizeof (cpubuf) ||
600Sstevel@tonic-gate prom_getprop(node, OBP_NAME, cpubuf) <= 0)
610Sstevel@tonic-gate prom_panic("no name in cpu node");
621772Sjl139090
630Sstevel@tonic-gate /* nlen includes the terminating null character */
641772Sjl139090
651772Sjl139090 /*
661772Sjl139090 * For the CMT case, need check the parent "core"
671772Sjl139090 * node for the compatible property.
681772Sjl139090 */
691772Sjl139090 if ((clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0 ||
701772Sjl139090 ((node = prom_parentnode(node)) != OBP_NONODE &&
711772Sjl139090 node != OBP_BADNODE &&
721772Sjl139090 (clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0 &&
731772Sjl139090 prom_getprop(node, OBP_DEVICETYPE, dname) > 0 &&
741772Sjl139090 strcmp(dname, "core") == 0)) {
750Sstevel@tonic-gate if ((clen + nlen) > sizeof (cpubuf))
760Sstevel@tonic-gate prom_panic("cpu node \"compatible\" too long");
770Sstevel@tonic-gate /* read in compatible, leaving space for ':' */
780Sstevel@tonic-gate if (prom_getprop(node, OBP_COMPATIBLE,
790Sstevel@tonic-gate &cpubuf[nlen]) != clen)
800Sstevel@tonic-gate prom_panic("cpu node \"compatible\" error");
810Sstevel@tonic-gate clen += nlen; /* total length */
820Sstevel@tonic-gate /* convert all null characters to ':' */
830Sstevel@tonic-gate clen--; /* except the final one... */
840Sstevel@tonic-gate for (i = 0; i < clen; i++)
850Sstevel@tonic-gate if (cpubuf[i] == '\0')
860Sstevel@tonic-gate cpubuf[i] = ':';
870Sstevel@tonic-gate }
880Sstevel@tonic-gate cpulist = cpubuf;
890Sstevel@tonic-gate } else
900Sstevel@tonic-gate prom_panic("no cpu node");
910Sstevel@tonic-gate }
920Sstevel@tonic-gate
930Sstevel@tonic-gate /*
940Sstevel@tonic-gate * Allocate a region of virtual address space, unmapped.
950Sstevel@tonic-gate */
960Sstevel@tonic-gate caddr_t
resalloc_virt(caddr_t virt,size_t size)970Sstevel@tonic-gate resalloc_virt(caddr_t virt, size_t size)
980Sstevel@tonic-gate {
990Sstevel@tonic-gate if (prom_claim_virt(size, virt) == (caddr_t)-1)
1000Sstevel@tonic-gate return ((caddr_t)0);
1010Sstevel@tonic-gate
1020Sstevel@tonic-gate return (virt);
1030Sstevel@tonic-gate }
104