17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 525cf1a30Sjl139090 * Common Development and Distribution License (the "License"). 625cf1a30Sjl139090 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*db9ce1c9SJerry Gilliam * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #include <sys/types.h> 277c478bd9Sstevel@tonic-gate #include <sys/param.h> 287c478bd9Sstevel@tonic-gate #include <sys/fcntl.h> 297c478bd9Sstevel@tonic-gate #include <sys/promif.h> 307c478bd9Sstevel@tonic-gate #include <sys/prom_plat.h> 317c478bd9Sstevel@tonic-gate #include <sys/salib.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate int pagesize = PAGESIZE; 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate void 367c478bd9Sstevel@tonic-gate fiximp(void) 377c478bd9Sstevel@tonic-gate { 387c478bd9Sstevel@tonic-gate extern int use_align; 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate use_align = 1; 417c478bd9Sstevel@tonic-gate } 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate void 447c478bd9Sstevel@tonic-gate setup_aux(void) 457c478bd9Sstevel@tonic-gate { 46fa9e4066Sahrens pnode_t node; 477c478bd9Sstevel@tonic-gate /* big enough for OBP_NAME and for a reasonably sized OBP_COMPATIBLE. */ 487c478bd9Sstevel@tonic-gate static char cpubuf[5 * OBP_MAXDRVNAME]; 4925cf1a30Sjl139090 char dname[OBP_MAXDRVNAME]; 507c478bd9Sstevel@tonic-gate extern uint_t icache_flush; 517c478bd9Sstevel@tonic-gate extern char *cpulist; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate icache_flush = 1; 547c478bd9Sstevel@tonic-gate node = prom_findnode_bydevtype(prom_rootnode(), OBP_CPU); 557c478bd9Sstevel@tonic-gate if (node != OBP_NONODE && node != OBP_BADNODE) { 567c478bd9Sstevel@tonic-gate int nlen, clen, i; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate if ((nlen = prom_getproplen(node, OBP_NAME)) <= 0 || 597c478bd9Sstevel@tonic-gate nlen > sizeof (cpubuf) || 607c478bd9Sstevel@tonic-gate prom_getprop(node, OBP_NAME, cpubuf) <= 0) 617c478bd9Sstevel@tonic-gate prom_panic("no name in cpu node"); 6225cf1a30Sjl139090 637c478bd9Sstevel@tonic-gate /* nlen includes the terminating null character */ 6425cf1a30Sjl139090 6525cf1a30Sjl139090 /* 6625cf1a30Sjl139090 * For the CMT case, need check the parent "core" 6725cf1a30Sjl139090 * node for the compatible property. 6825cf1a30Sjl139090 */ 6925cf1a30Sjl139090 if ((clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0 || 7025cf1a30Sjl139090 ((node = prom_parentnode(node)) != OBP_NONODE && 7125cf1a30Sjl139090 node != OBP_BADNODE && 7225cf1a30Sjl139090 (clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0 && 7325cf1a30Sjl139090 prom_getprop(node, OBP_DEVICETYPE, dname) > 0 && 7425cf1a30Sjl139090 strcmp(dname, "core") == 0)) { 757c478bd9Sstevel@tonic-gate if ((clen + nlen) > sizeof (cpubuf)) 767c478bd9Sstevel@tonic-gate prom_panic("cpu node \"compatible\" too long"); 777c478bd9Sstevel@tonic-gate /* read in compatible, leaving space for ':' */ 787c478bd9Sstevel@tonic-gate if (prom_getprop(node, OBP_COMPATIBLE, 797c478bd9Sstevel@tonic-gate &cpubuf[nlen]) != clen) 807c478bd9Sstevel@tonic-gate prom_panic("cpu node \"compatible\" error"); 817c478bd9Sstevel@tonic-gate clen += nlen; /* total length */ 827c478bd9Sstevel@tonic-gate /* convert all null characters to ':' */ 837c478bd9Sstevel@tonic-gate clen--; /* except the final one... */ 847c478bd9Sstevel@tonic-gate for (i = 0; i < clen; i++) 857c478bd9Sstevel@tonic-gate if (cpubuf[i] == '\0') 867c478bd9Sstevel@tonic-gate cpubuf[i] = ':'; 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate cpulist = cpubuf; 897c478bd9Sstevel@tonic-gate } else 907c478bd9Sstevel@tonic-gate prom_panic("no cpu node"); 917c478bd9Sstevel@tonic-gate } 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * Allocate a region of virtual address space, unmapped. 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate caddr_t 977c478bd9Sstevel@tonic-gate resalloc_virt(caddr_t virt, size_t size) 987c478bd9Sstevel@tonic-gate { 997c478bd9Sstevel@tonic-gate if (prom_claim_virt(size, virt) == (caddr_t)-1) 1007c478bd9Sstevel@tonic-gate return ((caddr_t)0); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate return (virt); 1037c478bd9Sstevel@tonic-gate } 104