xref: /titanic_44/usr/src/psm/stand/boot/sparc/common/sun4dep.c (revision fe0e7ec4d916b05b52d8c7cc8a3e6a1b28e77b6f)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/types.h>
30 #include <sys/param.h>
31 #include <sys/fcntl.h>
32 #include <sys/promif.h>
33 #include <sys/prom_plat.h>
34 #include <sys/salib.h>
35 
36 int pagesize = PAGESIZE;
37 
38 void
39 fiximp(void)
40 {
41 	extern int use_align;
42 
43 	use_align = 1;
44 }
45 
46 void
47 setup_aux(void)
48 {
49 	pnode_t node;
50 	/* big enough for OBP_NAME and for a reasonably sized OBP_COMPATIBLE. */
51 	static char cpubuf[5 * OBP_MAXDRVNAME];
52 	extern uint_t icache_flush;
53 	extern char *cpulist;
54 
55 	icache_flush = 1;
56 	node = prom_findnode_bydevtype(prom_rootnode(), OBP_CPU);
57 	if (node != OBP_NONODE && node != OBP_BADNODE) {
58 		int nlen, clen, i;
59 
60 		if ((nlen = prom_getproplen(node, OBP_NAME)) <= 0 ||
61 		    nlen > sizeof (cpubuf) ||
62 		    prom_getprop(node, OBP_NAME, cpubuf) <= 0)
63 			prom_panic("no name in cpu node");
64 		/* nlen includes the terminating null character */
65 		if ((clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0) {
66 			if ((clen + nlen) > sizeof (cpubuf))
67 				prom_panic("cpu node \"compatible\" too long");
68 			/* read in compatible, leaving space for ':' */
69 			if (prom_getprop(node, OBP_COMPATIBLE,
70 			    &cpubuf[nlen]) != clen)
71 				prom_panic("cpu node \"compatible\" error");
72 			clen += nlen;	/* total length */
73 			/* convert all null characters to ':' */
74 			clen--;	/* except the final one... */
75 			for (i = 0; i < clen; i++)
76 				if (cpubuf[i] == '\0')
77 					cpubuf[i] = ':';
78 		}
79 		cpulist = cpubuf;
80 	} else
81 		prom_panic("no cpu node");
82 }
83 
84 
85 #ifdef MPSAS
86 
87 void sas_symtab(int start, int end);
88 extern int sas_command(char *cmdstr);
89 
90 /*
91  * SAS support - inform SAS of new symbols being dynamically added
92  * during simulation via the first standalone.
93  */
94 
95 #ifndef	BUFSIZ
96 #define	BUFSIZ	1024		/* for cmd string buffer allocation */
97 #endif
98 
99 int	sas_symdebug = 0;		/* SAS support */
100 
101 void
102 sas_symtab(int start, int end)
103 {
104 	char *addstr = "symtab add $LD_KERNEL_PATH/%s%s 0x%x 0x%x\n";
105 	char *file, *prefix, cmdstr[BUFSIZ];
106 	extern char filename[];
107 
108 	file = filename;
109 	prefix = *file == '/' ? "../../.." : "";
110 
111 	(void) sprintf(cmdstr, addstr, prefix, file, start, end);
112 
113 	/* add the symbol table */
114 	if (sas_symdebug) (void) printf("sas_symtab: %s", cmdstr);
115 	sas_command(cmdstr);
116 }
117 
118 void
119 sas_bpts()
120 {
121 	sas_command("file $KERN_SCRIPT_FILE\n");
122 }
123 #endif	/* MPSAS */
124 
125 /*
126  * Allocate a region of virtual address space, unmapped.
127  */
128 caddr_t
129 resalloc_virt(caddr_t virt, size_t size)
130 {
131 	if (prom_claim_virt(size, virt) == (caddr_t)-1)
132 		return ((caddr_t)0);
133 
134 	return (virt);
135 }
136