1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate * Starfire Post Descriptor Array (post2obp) management.
31*7c478bd9Sstevel@tonic-gate */
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gate #include <sys/debug.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
35*7c478bd9Sstevel@tonic-gate #include <sys/errno.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/conf.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
40*7c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/sunndi.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/vm.h>
44*7c478bd9Sstevel@tonic-gate #include <vm/seg.h>
45*7c478bd9Sstevel@tonic-gate #include <vm/seg_kmem.h>
46*7c478bd9Sstevel@tonic-gate #include <vm/seg_kp.h>
47*7c478bd9Sstevel@tonic-gate #include <sys/machsystm.h>
48*7c478bd9Sstevel@tonic-gate #include <sys/starfire.h>
49*7c478bd9Sstevel@tonic-gate
50*7c478bd9Sstevel@tonic-gate #include <sys/cpu_sgnblk_defs.h>
51*7c478bd9Sstevel@tonic-gate #include <sys/pda.h>
52*7c478bd9Sstevel@tonic-gate #include <sys/cpu_sgn.h>
53*7c478bd9Sstevel@tonic-gate
54*7c478bd9Sstevel@tonic-gate extern struct cpu *SIGBCPU;
55*7c478bd9Sstevel@tonic-gate extern cpu_sgnblk_t *cpu_sgnblkp[];
56*7c478bd9Sstevel@tonic-gate
57*7c478bd9Sstevel@tonic-gate extern uint64_t mc_get_mem_alignment();
58*7c478bd9Sstevel@tonic-gate extern uint64_t mc_asr_to_pa(uint_t mcreg);
59*7c478bd9Sstevel@tonic-gate
60*7c478bd9Sstevel@tonic-gate static post2obp_info_t *cpu_p2o_mapin(int cpuid);
61*7c478bd9Sstevel@tonic-gate static void cpu_p2o_mapout(int cpuid, post2obp_info_t *p2o);
62*7c478bd9Sstevel@tonic-gate static void p2o_update_checksum(post2obp_info_t *p2o);
63*7c478bd9Sstevel@tonic-gate static uint_t p2o_calc_checksum(post2obp_info_t *p2o);
64*7c478bd9Sstevel@tonic-gate static void p2o_mem_sort(post2obp_info_t *p2o);
65*7c478bd9Sstevel@tonic-gate static void p2o_mem_coalesce(post2obp_info_t *p2o);
66*7c478bd9Sstevel@tonic-gate
67*7c478bd9Sstevel@tonic-gate typedef struct {
68*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o_ptr;
69*7c478bd9Sstevel@tonic-gate int p2o_cpuid;
70*7c478bd9Sstevel@tonic-gate } p2o_info_t;
71*7c478bd9Sstevel@tonic-gate
72*7c478bd9Sstevel@tonic-gate /*
73*7c478bd9Sstevel@tonic-gate * PDA management routines. Should ultimately be made
74*7c478bd9Sstevel@tonic-gate * accessible to other Starfire subsystems, but for
75*7c478bd9Sstevel@tonic-gate * now we'll leave it here.
76*7c478bd9Sstevel@tonic-gate */
77*7c478bd9Sstevel@tonic-gate pda_handle_t
pda_open()78*7c478bd9Sstevel@tonic-gate pda_open()
79*7c478bd9Sstevel@tonic-gate {
80*7c478bd9Sstevel@tonic-gate p2o_info_t *pip;
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gate if (SIGBCPU == NULL) {
83*7c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "pda_open: SIGBCPU is NULL");
84*7c478bd9Sstevel@tonic-gate return (NULL);
85*7c478bd9Sstevel@tonic-gate }
86*7c478bd9Sstevel@tonic-gate
87*7c478bd9Sstevel@tonic-gate pip = (p2o_info_t *)kmem_alloc(sizeof (p2o_info_t), KM_SLEEP);
88*7c478bd9Sstevel@tonic-gate
89*7c478bd9Sstevel@tonic-gate pip->p2o_cpuid = (int)SIGBCPU->cpu_id;
90*7c478bd9Sstevel@tonic-gate pip->p2o_ptr = cpu_p2o_mapin(pip->p2o_cpuid);
91*7c478bd9Sstevel@tonic-gate
92*7c478bd9Sstevel@tonic-gate if (pip->p2o_ptr == NULL) {
93*7c478bd9Sstevel@tonic-gate kmem_free((caddr_t)pip, sizeof (p2o_info_t));
94*7c478bd9Sstevel@tonic-gate return ((pda_handle_t)NULL);
95*7c478bd9Sstevel@tonic-gate } else {
96*7c478bd9Sstevel@tonic-gate return ((pda_handle_t)pip);
97*7c478bd9Sstevel@tonic-gate }
98*7c478bd9Sstevel@tonic-gate }
99*7c478bd9Sstevel@tonic-gate
100*7c478bd9Sstevel@tonic-gate void
pda_close(pda_handle_t ph)101*7c478bd9Sstevel@tonic-gate pda_close(pda_handle_t ph)
102*7c478bd9Sstevel@tonic-gate {
103*7c478bd9Sstevel@tonic-gate p2o_info_t *pip;
104*7c478bd9Sstevel@tonic-gate
105*7c478bd9Sstevel@tonic-gate if ((pip = (p2o_info_t *)ph) == NULL)
106*7c478bd9Sstevel@tonic-gate return;
107*7c478bd9Sstevel@tonic-gate
108*7c478bd9Sstevel@tonic-gate cpu_p2o_mapout(pip->p2o_cpuid, pip->p2o_ptr);
109*7c478bd9Sstevel@tonic-gate
110*7c478bd9Sstevel@tonic-gate kmem_free((caddr_t)pip, sizeof (p2o_info_t));
111*7c478bd9Sstevel@tonic-gate }
112*7c478bd9Sstevel@tonic-gate
113*7c478bd9Sstevel@tonic-gate int
pda_board_present(pda_handle_t ph,int boardnum)114*7c478bd9Sstevel@tonic-gate pda_board_present(pda_handle_t ph, int boardnum)
115*7c478bd9Sstevel@tonic-gate {
116*7c478bd9Sstevel@tonic-gate ushort_t bda_board;
117*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o = ((p2o_info_t *)ph)->p2o_ptr;
118*7c478bd9Sstevel@tonic-gate
119*7c478bd9Sstevel@tonic-gate bda_board = p2o->p2o_bdinfo[boardnum].bda_board;
120*7c478bd9Sstevel@tonic-gate
121*7c478bd9Sstevel@tonic-gate if ((bda_board & BDAN_MASK) != BDAN_GOOD)
122*7c478bd9Sstevel@tonic-gate return (0);
123*7c478bd9Sstevel@tonic-gate else
124*7c478bd9Sstevel@tonic-gate return (1);
125*7c478bd9Sstevel@tonic-gate }
126*7c478bd9Sstevel@tonic-gate
127*7c478bd9Sstevel@tonic-gate void *
pda_get_board_info(pda_handle_t ph,int boardnum)128*7c478bd9Sstevel@tonic-gate pda_get_board_info(pda_handle_t ph, int boardnum)
129*7c478bd9Sstevel@tonic-gate {
130*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o = ((p2o_info_t *)ph)->p2o_ptr;
131*7c478bd9Sstevel@tonic-gate
132*7c478bd9Sstevel@tonic-gate return ((void *)&(p2o->p2o_bdinfo[boardnum]));
133*7c478bd9Sstevel@tonic-gate }
134*7c478bd9Sstevel@tonic-gate
135*7c478bd9Sstevel@tonic-gate uint_t
pda_get_mem_size(pda_handle_t ph,int boardnum)136*7c478bd9Sstevel@tonic-gate pda_get_mem_size(pda_handle_t ph, int boardnum)
137*7c478bd9Sstevel@tonic-gate {
138*7c478bd9Sstevel@tonic-gate int c;
139*7c478bd9Sstevel@tonic-gate pgcnt_t npages;
140*7c478bd9Sstevel@tonic-gate uint_t asr;
141*7c478bd9Sstevel@tonic-gate pfn_t basepfn, endpfn;
142*7c478bd9Sstevel@tonic-gate uint64_t basepa, endpa;
143*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o = ((p2o_info_t *)ph)->p2o_ptr;
144*7c478bd9Sstevel@tonic-gate
145*7c478bd9Sstevel@tonic-gate if (boardnum == -1)
146*7c478bd9Sstevel@tonic-gate return (p2o->p2o_memtotal.Memt_NumPages);
147*7c478bd9Sstevel@tonic-gate
148*7c478bd9Sstevel@tonic-gate asr = p2o->p2o_bdminfo[boardnum].bmda_adr;
149*7c478bd9Sstevel@tonic-gate
150*7c478bd9Sstevel@tonic-gate basepa = mc_asr_to_pa(asr);
151*7c478bd9Sstevel@tonic-gate /*
152*7c478bd9Sstevel@tonic-gate * Put on MC alignment.
153*7c478bd9Sstevel@tonic-gate */
154*7c478bd9Sstevel@tonic-gate endpa = mc_get_mem_alignment();
155*7c478bd9Sstevel@tonic-gate basepa &= ~(endpa - 1);
156*7c478bd9Sstevel@tonic-gate endpa += basepa;
157*7c478bd9Sstevel@tonic-gate basepfn = (pfn_t)(basepa >> PAGESHIFT);
158*7c478bd9Sstevel@tonic-gate endpfn = (pfn_t)(endpa >> PAGESHIFT);
159*7c478bd9Sstevel@tonic-gate
160*7c478bd9Sstevel@tonic-gate npages = 0;
161*7c478bd9Sstevel@tonic-gate
162*7c478bd9Sstevel@tonic-gate for (c = 0; c < p2o->p2o_memtotal.Memt_NumChunks; c++) {
163*7c478bd9Sstevel@tonic-gate pfn_t c_basepfn, c_endpfn;
164*7c478bd9Sstevel@tonic-gate
165*7c478bd9Sstevel@tonic-gate c_basepfn = (pfn_t)p2o->p2o_mchunks[c].Memc_StartAddress
166*7c478bd9Sstevel@tonic-gate >> (PAGESHIFT - BDA_PAGESHIFT);
167*7c478bd9Sstevel@tonic-gate c_endpfn = (pfn_t)p2o->p2o_mchunks[c].Memc_Size
168*7c478bd9Sstevel@tonic-gate >> (PAGESHIFT - BDA_PAGESHIFT);
169*7c478bd9Sstevel@tonic-gate c_endpfn += c_basepfn;
170*7c478bd9Sstevel@tonic-gate
171*7c478bd9Sstevel@tonic-gate if ((endpfn <= c_basepfn) || (basepfn >= c_endpfn))
172*7c478bd9Sstevel@tonic-gate continue;
173*7c478bd9Sstevel@tonic-gate
174*7c478bd9Sstevel@tonic-gate c_basepfn = MAX(c_basepfn, basepfn);
175*7c478bd9Sstevel@tonic-gate c_endpfn = MIN(c_endpfn, endpfn);
176*7c478bd9Sstevel@tonic-gate ASSERT(c_basepfn <= c_endpfn);
177*7c478bd9Sstevel@tonic-gate
178*7c478bd9Sstevel@tonic-gate npages += c_endpfn - c_basepfn;
179*7c478bd9Sstevel@tonic-gate }
180*7c478bd9Sstevel@tonic-gate
181*7c478bd9Sstevel@tonic-gate return (npages);
182*7c478bd9Sstevel@tonic-gate }
183*7c478bd9Sstevel@tonic-gate
184*7c478bd9Sstevel@tonic-gate void
pda_mem_add_span(pda_handle_t ph,uint64_t basepa,uint64_t nbytes)185*7c478bd9Sstevel@tonic-gate pda_mem_add_span(pda_handle_t ph, uint64_t basepa, uint64_t nbytes)
186*7c478bd9Sstevel@tonic-gate {
187*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o = ((p2o_info_t *)ph)->p2o_ptr;
188*7c478bd9Sstevel@tonic-gate int c, nchunks;
189*7c478bd9Sstevel@tonic-gate pfn_t a_pfn, a_npgs;
190*7c478bd9Sstevel@tonic-gate
191*7c478bd9Sstevel@tonic-gate ASSERT(p2o);
192*7c478bd9Sstevel@tonic-gate
193*7c478bd9Sstevel@tonic-gate nchunks = p2o->p2o_memtotal.Memt_NumChunks;
194*7c478bd9Sstevel@tonic-gate a_pfn = (pfn_t)(basepa >> BDA_PAGESHIFT);
195*7c478bd9Sstevel@tonic-gate a_npgs = (pfn_t)(nbytes >> BDA_PAGESHIFT);
196*7c478bd9Sstevel@tonic-gate
197*7c478bd9Sstevel@tonic-gate for (c = 0; c < nchunks; c++) {
198*7c478bd9Sstevel@tonic-gate int cend;
199*7c478bd9Sstevel@tonic-gate
200*7c478bd9Sstevel@tonic-gate if (a_pfn <= p2o->p2o_mchunks[c].Memc_StartAddress) {
201*7c478bd9Sstevel@tonic-gate for (cend = nchunks; cend > c; cend--)
202*7c478bd9Sstevel@tonic-gate p2o->p2o_mchunks[cend] =
203*7c478bd9Sstevel@tonic-gate p2o->p2o_mchunks[cend - 1];
204*7c478bd9Sstevel@tonic-gate break;
205*7c478bd9Sstevel@tonic-gate }
206*7c478bd9Sstevel@tonic-gate }
207*7c478bd9Sstevel@tonic-gate p2o->p2o_mchunks[c].Memc_StartAddress = a_pfn;
208*7c478bd9Sstevel@tonic-gate p2o->p2o_mchunks[c].Memc_Size = a_npgs;
209*7c478bd9Sstevel@tonic-gate nchunks++;
210*7c478bd9Sstevel@tonic-gate
211*7c478bd9Sstevel@tonic-gate p2o->p2o_memtotal.Memt_NumChunks = nchunks;
212*7c478bd9Sstevel@tonic-gate p2o->p2o_memtotal.Memt_NumPages += a_npgs;
213*7c478bd9Sstevel@tonic-gate
214*7c478bd9Sstevel@tonic-gate p2o_mem_sort(p2o);
215*7c478bd9Sstevel@tonic-gate p2o_mem_coalesce(p2o);
216*7c478bd9Sstevel@tonic-gate p2o_update_checksum(p2o);
217*7c478bd9Sstevel@tonic-gate }
218*7c478bd9Sstevel@tonic-gate
219*7c478bd9Sstevel@tonic-gate void
pda_mem_del_span(pda_handle_t ph,uint64_t basepa,uint64_t nbytes)220*7c478bd9Sstevel@tonic-gate pda_mem_del_span(pda_handle_t ph, uint64_t basepa, uint64_t nbytes)
221*7c478bd9Sstevel@tonic-gate {
222*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o = ((p2o_info_t *)ph)->p2o_ptr;
223*7c478bd9Sstevel@tonic-gate int c, o_nchunks, n_nchunks;
224*7c478bd9Sstevel@tonic-gate pfn_t d_pfn;
225*7c478bd9Sstevel@tonic-gate pgcnt_t d_npgs, npages;
226*7c478bd9Sstevel@tonic-gate MemChunk_t *mp, *endp;
227*7c478bd9Sstevel@tonic-gate
228*7c478bd9Sstevel@tonic-gate ASSERT(p2o);
229*7c478bd9Sstevel@tonic-gate
230*7c478bd9Sstevel@tonic-gate d_pfn = (pfn_t)(basepa >> BDA_PAGESHIFT);
231*7c478bd9Sstevel@tonic-gate d_npgs = (pgcnt_t)(nbytes >> BDA_PAGESHIFT);
232*7c478bd9Sstevel@tonic-gate n_nchunks = o_nchunks = p2o->p2o_memtotal.Memt_NumChunks;
233*7c478bd9Sstevel@tonic-gate endp = &(p2o->p2o_mchunks[o_nchunks]);
234*7c478bd9Sstevel@tonic-gate npages = 0;
235*7c478bd9Sstevel@tonic-gate
236*7c478bd9Sstevel@tonic-gate for (c = 0; c < o_nchunks; c++) {
237*7c478bd9Sstevel@tonic-gate uint_t p_pfn, p_npgs;
238*7c478bd9Sstevel@tonic-gate
239*7c478bd9Sstevel@tonic-gate p_pfn = p2o->p2o_mchunks[c].Memc_StartAddress;
240*7c478bd9Sstevel@tonic-gate p_npgs = p2o->p2o_mchunks[c].Memc_Size;
241*7c478bd9Sstevel@tonic-gate if (p_npgs == 0)
242*7c478bd9Sstevel@tonic-gate continue;
243*7c478bd9Sstevel@tonic-gate
244*7c478bd9Sstevel@tonic-gate if (((d_pfn + d_npgs) <= p_pfn) ||
245*7c478bd9Sstevel@tonic-gate (d_pfn >= (p_pfn + p_npgs))) {
246*7c478bd9Sstevel@tonic-gate npages += p_npgs;
247*7c478bd9Sstevel@tonic-gate continue;
248*7c478bd9Sstevel@tonic-gate }
249*7c478bd9Sstevel@tonic-gate
250*7c478bd9Sstevel@tonic-gate if (d_pfn < p_pfn) {
251*7c478bd9Sstevel@tonic-gate if ((d_pfn + d_npgs) >= (p_pfn + p_npgs)) {
252*7c478bd9Sstevel@tonic-gate /*
253*7c478bd9Sstevel@tonic-gate * Entire chunk goes away.
254*7c478bd9Sstevel@tonic-gate */
255*7c478bd9Sstevel@tonic-gate p_pfn = p_npgs = 0;
256*7c478bd9Sstevel@tonic-gate } else {
257*7c478bd9Sstevel@tonic-gate p_npgs -= d_pfn + d_npgs - p_pfn;
258*7c478bd9Sstevel@tonic-gate p_pfn = d_pfn + d_npgs;
259*7c478bd9Sstevel@tonic-gate }
260*7c478bd9Sstevel@tonic-gate } else if (d_pfn == p_pfn) {
261*7c478bd9Sstevel@tonic-gate if ((d_pfn + d_npgs) >= (p_pfn + p_npgs)) {
262*7c478bd9Sstevel@tonic-gate p_pfn = p_npgs = 0;
263*7c478bd9Sstevel@tonic-gate } else {
264*7c478bd9Sstevel@tonic-gate p_npgs -= d_npgs;
265*7c478bd9Sstevel@tonic-gate p_pfn += d_npgs;
266*7c478bd9Sstevel@tonic-gate }
267*7c478bd9Sstevel@tonic-gate } else {
268*7c478bd9Sstevel@tonic-gate if ((d_pfn + d_npgs) >= (p_pfn + p_npgs)) {
269*7c478bd9Sstevel@tonic-gate p_npgs = d_pfn - p_pfn;
270*7c478bd9Sstevel@tonic-gate npages += p_npgs;
271*7c478bd9Sstevel@tonic-gate } else {
272*7c478bd9Sstevel@tonic-gate /*
273*7c478bd9Sstevel@tonic-gate * Ugh, got to split a
274*7c478bd9Sstevel@tonic-gate * memchunk, we're going to
275*7c478bd9Sstevel@tonic-gate * need an extra one. It's
276*7c478bd9Sstevel@tonic-gate * gotten from the end.
277*7c478bd9Sstevel@tonic-gate */
278*7c478bd9Sstevel@tonic-gate endp->Memc_StartAddress = d_pfn + d_npgs;
279*7c478bd9Sstevel@tonic-gate endp->Memc_Size = (p_pfn + p_npgs)
280*7c478bd9Sstevel@tonic-gate - (d_pfn + d_npgs);
281*7c478bd9Sstevel@tonic-gate npages += endp->Memc_Size;
282*7c478bd9Sstevel@tonic-gate endp++;
283*7c478bd9Sstevel@tonic-gate n_nchunks++;
284*7c478bd9Sstevel@tonic-gate p_npgs = d_pfn - p_pfn;
285*7c478bd9Sstevel@tonic-gate }
286*7c478bd9Sstevel@tonic-gate }
287*7c478bd9Sstevel@tonic-gate
288*7c478bd9Sstevel@tonic-gate p2o->p2o_mchunks[c].Memc_StartAddress = p_pfn;
289*7c478bd9Sstevel@tonic-gate p2o->p2o_mchunks[c].Memc_Size = p_npgs;
290*7c478bd9Sstevel@tonic-gate if (p_npgs == 0)
291*7c478bd9Sstevel@tonic-gate n_nchunks--;
292*7c478bd9Sstevel@tonic-gate npages += p_npgs;
293*7c478bd9Sstevel@tonic-gate }
294*7c478bd9Sstevel@tonic-gate p2o->p2o_memtotal.Memt_NumChunks = n_nchunks;
295*7c478bd9Sstevel@tonic-gate p2o->p2o_memtotal.Memt_NumPages = npages;
296*7c478bd9Sstevel@tonic-gate
297*7c478bd9Sstevel@tonic-gate /*
298*7c478bd9Sstevel@tonic-gate * There is a possibility we created holes in the memchunk list
299*7c478bd9Sstevel@tonic-gate * due to memchunks that went away. Before we can sort and
300*7c478bd9Sstevel@tonic-gate * coalesce we need to "pull up" the end of the memchunk list
301*7c478bd9Sstevel@tonic-gate * and get rid of any holes.
302*7c478bd9Sstevel@tonic-gate * endp = points to the last empty memchunk entry.
303*7c478bd9Sstevel@tonic-gate */
304*7c478bd9Sstevel@tonic-gate for (mp = &(p2o->p2o_mchunks[0]); mp < endp; mp++) {
305*7c478bd9Sstevel@tonic-gate register MemChunk_t *mmp;
306*7c478bd9Sstevel@tonic-gate
307*7c478bd9Sstevel@tonic-gate if (mp->Memc_Size)
308*7c478bd9Sstevel@tonic-gate continue;
309*7c478bd9Sstevel@tonic-gate
310*7c478bd9Sstevel@tonic-gate for (mmp = mp; mmp < endp; mmp++)
311*7c478bd9Sstevel@tonic-gate *mmp = *(mmp + 1);
312*7c478bd9Sstevel@tonic-gate mp--;
313*7c478bd9Sstevel@tonic-gate endp--;
314*7c478bd9Sstevel@tonic-gate }
315*7c478bd9Sstevel@tonic-gate ASSERT(endp == &(p2o->p2o_mchunks[n_nchunks]));
316*7c478bd9Sstevel@tonic-gate
317*7c478bd9Sstevel@tonic-gate p2o_mem_sort(p2o);
318*7c478bd9Sstevel@tonic-gate p2o_mem_coalesce(p2o);
319*7c478bd9Sstevel@tonic-gate p2o_update_checksum(p2o);
320*7c478bd9Sstevel@tonic-gate }
321*7c478bd9Sstevel@tonic-gate
322*7c478bd9Sstevel@tonic-gate /*
323*7c478bd9Sstevel@tonic-gate * Synchonize all memory attributes (currently just MC ADRs [aka ASR])
324*7c478bd9Sstevel@tonic-gate * with PDA representative values for the given board. A board value
325*7c478bd9Sstevel@tonic-gate * of (-1) indicates all boards.
326*7c478bd9Sstevel@tonic-gate */
327*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
328*7c478bd9Sstevel@tonic-gate void
pda_mem_sync(pda_handle_t ph,int board,int unit)329*7c478bd9Sstevel@tonic-gate pda_mem_sync(pda_handle_t ph, int board, int unit)
330*7c478bd9Sstevel@tonic-gate {
331*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o = ((p2o_info_t *)ph)->p2o_ptr;
332*7c478bd9Sstevel@tonic-gate register int b;
333*7c478bd9Sstevel@tonic-gate
334*7c478bd9Sstevel@tonic-gate for (b = 0; b < MAX_SYSBDS; b++) {
335*7c478bd9Sstevel@tonic-gate if ((board != -1) && (board != b))
336*7c478bd9Sstevel@tonic-gate continue;
337*7c478bd9Sstevel@tonic-gate
338*7c478bd9Sstevel@tonic-gate if (pda_board_present(ph, b)) {
339*7c478bd9Sstevel@tonic-gate uint64_t masr;
340*7c478bd9Sstevel@tonic-gate uint_t masr_value;
341*7c478bd9Sstevel@tonic-gate
342*7c478bd9Sstevel@tonic-gate masr = STARFIRE_MC_ASR_ADDR_BOARD(b);
343*7c478bd9Sstevel@tonic-gate masr_value = ldphysio(masr);
344*7c478bd9Sstevel@tonic-gate
345*7c478bd9Sstevel@tonic-gate p2o->p2o_bdminfo[b].bmda_adr = masr_value;
346*7c478bd9Sstevel@tonic-gate }
347*7c478bd9Sstevel@tonic-gate
348*7c478bd9Sstevel@tonic-gate if (board == b)
349*7c478bd9Sstevel@tonic-gate break;
350*7c478bd9Sstevel@tonic-gate }
351*7c478bd9Sstevel@tonic-gate
352*7c478bd9Sstevel@tonic-gate p2o_update_checksum(p2o);
353*7c478bd9Sstevel@tonic-gate }
354*7c478bd9Sstevel@tonic-gate
355*7c478bd9Sstevel@tonic-gate void
pda_get_busmask(pda_handle_t ph,short * amask,short * dmask)356*7c478bd9Sstevel@tonic-gate pda_get_busmask(pda_handle_t ph, short *amask, short *dmask)
357*7c478bd9Sstevel@tonic-gate {
358*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o = ((p2o_info_t *)ph)->p2o_ptr;
359*7c478bd9Sstevel@tonic-gate
360*7c478bd9Sstevel@tonic-gate if (amask)
361*7c478bd9Sstevel@tonic-gate *amask = p2o ? p2o->p2o_abus_mask : 0;
362*7c478bd9Sstevel@tonic-gate
363*7c478bd9Sstevel@tonic-gate if (dmask)
364*7c478bd9Sstevel@tonic-gate *dmask = p2o ? p2o->p2o_dbus_mask : 0;
365*7c478bd9Sstevel@tonic-gate }
366*7c478bd9Sstevel@tonic-gate
367*7c478bd9Sstevel@tonic-gate int
pda_is_valid(pda_handle_t ph)368*7c478bd9Sstevel@tonic-gate pda_is_valid(pda_handle_t ph)
369*7c478bd9Sstevel@tonic-gate {
370*7c478bd9Sstevel@tonic-gate post2obp_info_t *p2o = ((p2o_info_t *)ph)->p2o_ptr;
371*7c478bd9Sstevel@tonic-gate uint_t csum;
372*7c478bd9Sstevel@tonic-gate
373*7c478bd9Sstevel@tonic-gate if (p2o == NULL)
374*7c478bd9Sstevel@tonic-gate return (0);
375*7c478bd9Sstevel@tonic-gate
376*7c478bd9Sstevel@tonic-gate csum = p2o_calc_checksum(p2o);
377*7c478bd9Sstevel@tonic-gate
378*7c478bd9Sstevel@tonic-gate return (csum == p2o->p2o_csum);
379*7c478bd9Sstevel@tonic-gate }
380*7c478bd9Sstevel@tonic-gate
381*7c478bd9Sstevel@tonic-gate /*
382*7c478bd9Sstevel@tonic-gate * Post2obp support functions below here. Internal to PDA module.
383*7c478bd9Sstevel@tonic-gate *
384*7c478bd9Sstevel@tonic-gate * p2o_update_checksum
385*7c478bd9Sstevel@tonic-gate *
386*7c478bd9Sstevel@tonic-gate * Calculate checksum for post2obp structure and insert it so
387*7c478bd9Sstevel@tonic-gate * when POST reads it he'll be happy.
388*7c478bd9Sstevel@tonic-gate */
389*7c478bd9Sstevel@tonic-gate static void
p2o_update_checksum(post2obp_info_t * p2o)390*7c478bd9Sstevel@tonic-gate p2o_update_checksum(post2obp_info_t *p2o)
391*7c478bd9Sstevel@tonic-gate {
392*7c478bd9Sstevel@tonic-gate uint_t new_csum;
393*7c478bd9Sstevel@tonic-gate
394*7c478bd9Sstevel@tonic-gate ASSERT(p2o);
395*7c478bd9Sstevel@tonic-gate
396*7c478bd9Sstevel@tonic-gate new_csum = p2o_calc_checksum(p2o);
397*7c478bd9Sstevel@tonic-gate p2o->p2o_csum = new_csum;
398*7c478bd9Sstevel@tonic-gate }
399*7c478bd9Sstevel@tonic-gate
400*7c478bd9Sstevel@tonic-gate static uint_t
p2o_calc_checksum(post2obp_info_t * p2o)401*7c478bd9Sstevel@tonic-gate p2o_calc_checksum(post2obp_info_t *p2o)
402*7c478bd9Sstevel@tonic-gate {
403*7c478bd9Sstevel@tonic-gate int i, nchunks;
404*7c478bd9Sstevel@tonic-gate uint_t *csumptr;
405*7c478bd9Sstevel@tonic-gate uint_t p2o_size;
406*7c478bd9Sstevel@tonic-gate uint_t csum, o_csum;
407*7c478bd9Sstevel@tonic-gate
408*7c478bd9Sstevel@tonic-gate ASSERT(p2o != NULL);
409*7c478bd9Sstevel@tonic-gate
410*7c478bd9Sstevel@tonic-gate nchunks = p2o->p2o_memtotal.Memt_NumChunks;
411*7c478bd9Sstevel@tonic-gate p2o_size = sizeof (post2obp_info_t)
412*7c478bd9Sstevel@tonic-gate + ((nchunks - VAR_ARRAY_LEN) * sizeof (MemChunk_t));
413*7c478bd9Sstevel@tonic-gate p2o_size /= sizeof (uint_t);
414*7c478bd9Sstevel@tonic-gate
415*7c478bd9Sstevel@tonic-gate o_csum = p2o->p2o_csum;
416*7c478bd9Sstevel@tonic-gate p2o->p2o_csum = 0;
417*7c478bd9Sstevel@tonic-gate csum = 0;
418*7c478bd9Sstevel@tonic-gate for (i = 0, csumptr = (uint_t *)p2o; i < p2o_size; i++)
419*7c478bd9Sstevel@tonic-gate csum += *csumptr++;
420*7c478bd9Sstevel@tonic-gate p2o->p2o_csum = o_csum;
421*7c478bd9Sstevel@tonic-gate
422*7c478bd9Sstevel@tonic-gate return (-csum);
423*7c478bd9Sstevel@tonic-gate }
424*7c478bd9Sstevel@tonic-gate
425*7c478bd9Sstevel@tonic-gate /*
426*7c478bd9Sstevel@tonic-gate * Sort the mchunk list in ascending order based on the
427*7c478bd9Sstevel@tonic-gate * Memc_StartAddress field.
428*7c478bd9Sstevel@tonic-gate *
429*7c478bd9Sstevel@tonic-gate * disclosure: This is based on the qsort() library routine.
430*7c478bd9Sstevel@tonic-gate */
431*7c478bd9Sstevel@tonic-gate static void
p2o_mem_sort(post2obp_info_t * p2o)432*7c478bd9Sstevel@tonic-gate p2o_mem_sort(post2obp_info_t *p2o)
433*7c478bd9Sstevel@tonic-gate {
434*7c478bd9Sstevel@tonic-gate MemChunk_t *base;
435*7c478bd9Sstevel@tonic-gate int nchunks;
436*7c478bd9Sstevel@tonic-gate uint_t c1, c2;
437*7c478bd9Sstevel@tonic-gate char *min, *max;
438*7c478bd9Sstevel@tonic-gate register char c, *i, *j, *lo, *hi;
439*7c478bd9Sstevel@tonic-gate
440*7c478bd9Sstevel@tonic-gate ASSERT(p2o != NULL);
441*7c478bd9Sstevel@tonic-gate
442*7c478bd9Sstevel@tonic-gate nchunks = p2o->p2o_memtotal.Memt_NumChunks;
443*7c478bd9Sstevel@tonic-gate base = &p2o->p2o_mchunks[0];
444*7c478bd9Sstevel@tonic-gate
445*7c478bd9Sstevel@tonic-gate /* ala qsort() */
446*7c478bd9Sstevel@tonic-gate max = (char *)base + nchunks * sizeof (MemChunk_t);
447*7c478bd9Sstevel@tonic-gate hi = max;
448*7c478bd9Sstevel@tonic-gate for (j = lo = (char *)base; (lo += sizeof (MemChunk_t)) < hi; ) {
449*7c478bd9Sstevel@tonic-gate c1 = ((MemChunk_t *)j)->Memc_StartAddress;
450*7c478bd9Sstevel@tonic-gate c2 = ((MemChunk_t *)lo)->Memc_StartAddress;
451*7c478bd9Sstevel@tonic-gate if (c1 > c2)
452*7c478bd9Sstevel@tonic-gate j = lo;
453*7c478bd9Sstevel@tonic-gate }
454*7c478bd9Sstevel@tonic-gate if (j != (char *)base) {
455*7c478bd9Sstevel@tonic-gate for (i = (char *)base,
456*7c478bd9Sstevel@tonic-gate hi = (char *)base + sizeof (MemChunk_t);
457*7c478bd9Sstevel@tonic-gate /* CSTYLED */
458*7c478bd9Sstevel@tonic-gate i < hi;) {
459*7c478bd9Sstevel@tonic-gate c = *j;
460*7c478bd9Sstevel@tonic-gate *j++ = *i;
461*7c478bd9Sstevel@tonic-gate *i++ = c;
462*7c478bd9Sstevel@tonic-gate }
463*7c478bd9Sstevel@tonic-gate }
464*7c478bd9Sstevel@tonic-gate for (min = (char *)base;
465*7c478bd9Sstevel@tonic-gate /* CSTYLED */
466*7c478bd9Sstevel@tonic-gate (hi = min += sizeof (MemChunk_t)) < max;) {
467*7c478bd9Sstevel@tonic-gate do {
468*7c478bd9Sstevel@tonic-gate hi -= sizeof (MemChunk_t);
469*7c478bd9Sstevel@tonic-gate c1 = ((MemChunk_t *)hi)->Memc_StartAddress;
470*7c478bd9Sstevel@tonic-gate c2 = ((MemChunk_t *)min)->Memc_StartAddress;
471*7c478bd9Sstevel@tonic-gate } while (c1 > c2);
472*7c478bd9Sstevel@tonic-gate if ((hi += sizeof (MemChunk_t)) != min) {
473*7c478bd9Sstevel@tonic-gate for (lo = min + sizeof (MemChunk_t);
474*7c478bd9Sstevel@tonic-gate /* CSTYLED */
475*7c478bd9Sstevel@tonic-gate --lo >= min;) {
476*7c478bd9Sstevel@tonic-gate c = *lo;
477*7c478bd9Sstevel@tonic-gate for (i = j = lo;
478*7c478bd9Sstevel@tonic-gate (j -= sizeof (MemChunk_t)) >= hi;
479*7c478bd9Sstevel@tonic-gate i = j) {
480*7c478bd9Sstevel@tonic-gate *i = *j;
481*7c478bd9Sstevel@tonic-gate }
482*7c478bd9Sstevel@tonic-gate *i = c;
483*7c478bd9Sstevel@tonic-gate }
484*7c478bd9Sstevel@tonic-gate }
485*7c478bd9Sstevel@tonic-gate }
486*7c478bd9Sstevel@tonic-gate }
487*7c478bd9Sstevel@tonic-gate
488*7c478bd9Sstevel@tonic-gate static void
p2o_mem_coalesce(post2obp_info_t * p2o)489*7c478bd9Sstevel@tonic-gate p2o_mem_coalesce(post2obp_info_t *p2o)
490*7c478bd9Sstevel@tonic-gate {
491*7c478bd9Sstevel@tonic-gate MemChunk_t *mc;
492*7c478bd9Sstevel@tonic-gate int nchunks, new_nchunks;
493*7c478bd9Sstevel@tonic-gate uint_t addr, size, naddr, nsize;
494*7c478bd9Sstevel@tonic-gate uint_t npages;
495*7c478bd9Sstevel@tonic-gate register int i, cp, ncp;
496*7c478bd9Sstevel@tonic-gate
497*7c478bd9Sstevel@tonic-gate ASSERT(p2o != NULL);
498*7c478bd9Sstevel@tonic-gate
499*7c478bd9Sstevel@tonic-gate nchunks = new_nchunks = p2o->p2o_memtotal.Memt_NumChunks;
500*7c478bd9Sstevel@tonic-gate mc = &p2o->p2o_mchunks[0];
501*7c478bd9Sstevel@tonic-gate
502*7c478bd9Sstevel@tonic-gate for (cp = i = 0; i < (nchunks-1); i++, cp = ncp) {
503*7c478bd9Sstevel@tonic-gate ncp = cp + 1;
504*7c478bd9Sstevel@tonic-gate addr = mc[cp].Memc_StartAddress;
505*7c478bd9Sstevel@tonic-gate size = mc[cp].Memc_Size;
506*7c478bd9Sstevel@tonic-gate naddr = mc[ncp].Memc_StartAddress;
507*7c478bd9Sstevel@tonic-gate nsize = mc[ncp].Memc_Size;
508*7c478bd9Sstevel@tonic-gate
509*7c478bd9Sstevel@tonic-gate if ((addr + size) >= naddr) {
510*7c478bd9Sstevel@tonic-gate uint_t overlap;
511*7c478bd9Sstevel@tonic-gate
512*7c478bd9Sstevel@tonic-gate overlap = addr + size - naddr;
513*7c478bd9Sstevel@tonic-gate /*
514*7c478bd9Sstevel@tonic-gate * if (nsize < overlap) then
515*7c478bd9Sstevel@tonic-gate * next entry fits within the current
516*7c478bd9Sstevel@tonic-gate * entry so no need to update size.
517*7c478bd9Sstevel@tonic-gate */
518*7c478bd9Sstevel@tonic-gate if (nsize >= overlap) {
519*7c478bd9Sstevel@tonic-gate size += nsize - overlap;
520*7c478bd9Sstevel@tonic-gate mc[cp].Memc_Size = size;
521*7c478bd9Sstevel@tonic-gate }
522*7c478bd9Sstevel@tonic-gate bcopy((char *)&mc[ncp+1],
523*7c478bd9Sstevel@tonic-gate (char *)&mc[ncp],
524*7c478bd9Sstevel@tonic-gate (nchunks - ncp - 1) * sizeof (MemChunk_t));
525*7c478bd9Sstevel@tonic-gate ncp = cp;
526*7c478bd9Sstevel@tonic-gate new_nchunks--;
527*7c478bd9Sstevel@tonic-gate }
528*7c478bd9Sstevel@tonic-gate }
529*7c478bd9Sstevel@tonic-gate
530*7c478bd9Sstevel@tonic-gate npages = 0;
531*7c478bd9Sstevel@tonic-gate for (i = 0; i < new_nchunks; i++)
532*7c478bd9Sstevel@tonic-gate npages += p2o->p2o_mchunks[i].Memc_Size;
533*7c478bd9Sstevel@tonic-gate
534*7c478bd9Sstevel@tonic-gate p2o->p2o_memtotal.Memt_NumChunks = new_nchunks;
535*7c478bd9Sstevel@tonic-gate p2o->p2o_memtotal.Memt_NumPages = npages;
536*7c478bd9Sstevel@tonic-gate }
537*7c478bd9Sstevel@tonic-gate
538*7c478bd9Sstevel@tonic-gate /*
539*7c478bd9Sstevel@tonic-gate * Mapin the the cpu's post2obp structure.
540*7c478bd9Sstevel@tonic-gate */
541*7c478bd9Sstevel@tonic-gate static post2obp_info_t *
cpu_p2o_mapin(int cpuid)542*7c478bd9Sstevel@tonic-gate cpu_p2o_mapin(int cpuid)
543*7c478bd9Sstevel@tonic-gate {
544*7c478bd9Sstevel@tonic-gate uint64_t cpu_p2o_physaddr;
545*7c478bd9Sstevel@tonic-gate uint32_t cpu_p2o_offset;
546*7c478bd9Sstevel@tonic-gate caddr_t cvaddr;
547*7c478bd9Sstevel@tonic-gate uint_t num_pages;
548*7c478bd9Sstevel@tonic-gate pfn_t pfn;
549*7c478bd9Sstevel@tonic-gate
550*7c478bd9Sstevel@tonic-gate ASSERT(cpu_sgnblkp[cpuid] != NULL);
551*7c478bd9Sstevel@tonic-gate /*
552*7c478bd9Sstevel@tonic-gate * Construct the physical base address of the bbsram
553*7c478bd9Sstevel@tonic-gate * in PSI space associated with this cpu in question.
554*7c478bd9Sstevel@tonic-gate */
555*7c478bd9Sstevel@tonic-gate cpu_p2o_offset = (uint32_t)cpu_sgnblkp[cpuid]->sigb_postconfig;
556*7c478bd9Sstevel@tonic-gate if (cpu_p2o_offset == 0) {
557*7c478bd9Sstevel@tonic-gate cmn_err(CE_WARN,
558*7c478bd9Sstevel@tonic-gate "cpu_p2o_mapin:%d: sigb_postconfig == NULL\n",
559*7c478bd9Sstevel@tonic-gate cpuid);
560*7c478bd9Sstevel@tonic-gate return (NULL);
561*7c478bd9Sstevel@tonic-gate }
562*7c478bd9Sstevel@tonic-gate cpu_p2o_physaddr = (STARFIRE_UPAID2UPS(cpuid) | STARFIRE_PSI_BASE) +
563*7c478bd9Sstevel@tonic-gate (uint64_t)cpu_p2o_offset;
564*7c478bd9Sstevel@tonic-gate cpu_p2o_offset = (uint32_t)(cpu_p2o_physaddr & MMU_PAGEOFFSET);
565*7c478bd9Sstevel@tonic-gate cpu_p2o_physaddr -= (uint64_t)cpu_p2o_offset;
566*7c478bd9Sstevel@tonic-gate
567*7c478bd9Sstevel@tonic-gate /*
568*7c478bd9Sstevel@tonic-gate * cpu_p2o_physaddr = Beginning of page containing p2o.
569*7c478bd9Sstevel@tonic-gate * cpu_p2o_offset = Offset within page where p2o starts.
570*7c478bd9Sstevel@tonic-gate */
571*7c478bd9Sstevel@tonic-gate
572*7c478bd9Sstevel@tonic-gate pfn = (pfn_t)(cpu_p2o_physaddr >> MMU_PAGESHIFT);
573*7c478bd9Sstevel@tonic-gate
574*7c478bd9Sstevel@tonic-gate num_pages = mmu_btopr(cpu_p2o_offset + sizeof (post2obp_info_t));
575*7c478bd9Sstevel@tonic-gate
576*7c478bd9Sstevel@tonic-gate /*
577*7c478bd9Sstevel@tonic-gate * Map in the post2obp structure.
578*7c478bd9Sstevel@tonic-gate */
579*7c478bd9Sstevel@tonic-gate cvaddr = vmem_alloc(heap_arena, ptob(num_pages), VM_SLEEP);
580*7c478bd9Sstevel@tonic-gate
581*7c478bd9Sstevel@tonic-gate hat_devload(kas.a_hat, cvaddr, ptob(num_pages),
582*7c478bd9Sstevel@tonic-gate pfn, PROT_READ | PROT_WRITE, HAT_LOAD_LOCK);
583*7c478bd9Sstevel@tonic-gate
584*7c478bd9Sstevel@tonic-gate return ((post2obp_info_t *)(cvaddr + (ulong_t)cpu_p2o_offset));
585*7c478bd9Sstevel@tonic-gate }
586*7c478bd9Sstevel@tonic-gate
587*7c478bd9Sstevel@tonic-gate static void
cpu_p2o_mapout(int cpuid,post2obp_info_t * p2o)588*7c478bd9Sstevel@tonic-gate cpu_p2o_mapout(int cpuid, post2obp_info_t *p2o)
589*7c478bd9Sstevel@tonic-gate {
590*7c478bd9Sstevel@tonic-gate ulong_t cvaddr, num_pages;
591*7c478bd9Sstevel@tonic-gate uint32_t cpu_p2o_offset;
592*7c478bd9Sstevel@tonic-gate
593*7c478bd9Sstevel@tonic-gate ASSERT(cpu_sgnblkp[cpuid] != NULL);
594*7c478bd9Sstevel@tonic-gate
595*7c478bd9Sstevel@tonic-gate cpu_p2o_offset = (uint32_t)cpu_sgnblkp[cpuid]->sigb_postconfig;
596*7c478bd9Sstevel@tonic-gate if (cpu_p2o_offset == 0) {
597*7c478bd9Sstevel@tonic-gate cmn_err(CE_WARN,
598*7c478bd9Sstevel@tonic-gate "cpu_p2o_mapout:%d: sigb_postconfig == NULL\n",
599*7c478bd9Sstevel@tonic-gate cpuid);
600*7c478bd9Sstevel@tonic-gate return;
601*7c478bd9Sstevel@tonic-gate }
602*7c478bd9Sstevel@tonic-gate
603*7c478bd9Sstevel@tonic-gate cpu_p2o_offset = (uint32_t)(((STARFIRE_UPAID2UPS(cpuid) |
604*7c478bd9Sstevel@tonic-gate STARFIRE_PSI_BASE) +
605*7c478bd9Sstevel@tonic-gate (uint64_t)cpu_p2o_offset) &
606*7c478bd9Sstevel@tonic-gate MMU_PAGEOFFSET);
607*7c478bd9Sstevel@tonic-gate
608*7c478bd9Sstevel@tonic-gate num_pages = mmu_btopr(cpu_p2o_offset + sizeof (post2obp_info_t));
609*7c478bd9Sstevel@tonic-gate
610*7c478bd9Sstevel@tonic-gate cvaddr = (ulong_t)p2o - cpu_p2o_offset;
611*7c478bd9Sstevel@tonic-gate if (cvaddr & MMU_PAGEOFFSET) {
612*7c478bd9Sstevel@tonic-gate cmn_err(CE_WARN,
613*7c478bd9Sstevel@tonic-gate "cpu_p2o_mapout:%d: cvaddr (0x%x) not on page "
614*7c478bd9Sstevel@tonic-gate "boundary\n",
615*7c478bd9Sstevel@tonic-gate cpuid, (uint_t)cvaddr);
616*7c478bd9Sstevel@tonic-gate return;
617*7c478bd9Sstevel@tonic-gate }
618*7c478bd9Sstevel@tonic-gate
619*7c478bd9Sstevel@tonic-gate hat_unload(kas.a_hat, (caddr_t)cvaddr, ptob(num_pages),
620*7c478bd9Sstevel@tonic-gate HAT_UNLOAD_UNLOCK);
621*7c478bd9Sstevel@tonic-gate vmem_free(heap_arena, (caddr_t)cvaddr, ptob(num_pages));
622*7c478bd9Sstevel@tonic-gate }
623