niagara2.c revision fe70c9cf90dfc23d18485fb7b4b20a1175d53a8b
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/archsystm.h>
#include <sys/machparam.h>
#include <sys/machsystm.h>
#include <sys/elf_SPARC.h>
#include <vm/hat_sfmmu.h>
#include <sys/dditypes.h>
#include <sys/cpu_module.h>
#include <sys/prom_debug.h>
#include <sys/prom_plat.h>
#include <sys/sysmacros.h>
#include <sys/machtrap.h>
#include <sys/simulate.h>
#include <sys/niagara2regs.h>
#include <sys/trapstat.h>
char cpu_module_name[] = "SUNW,UltraSPARC-T2";
/*
* Hypervisor services information for the NIAGARA2 CPU module
*/
static hsvc_info_t niagara2_hsvc = {
};
#ifdef N2_1x_CPC_WORKAROUNDS
/* Niagara2 CPU version register */
#define VER_MASK_MAJOR_SHIFT 28
#define VER_MASK_MAJOR_MASK 0xf
#endif
void
cpu_setup(void)
{
extern int mmu_exported_pagesize_mask;
extern int cpc_has_overflow_intr;
int status;
#ifdef N2_1x_CPC_WORKAROUNDS
/*
* Get CPU version for Niagara2 part.
*/
#endif
/*
* Negotiate the API version for Niagara2 specific hypervisor
* services.
*/
if (status != 0) {
"group: 0x%lx major: 0x%lx minor: 0x%lx errno: %d",
}
/*
* The setup common to all CPU modules is done in cpu_setup_common
* routine.
*/
if ((mmu_exported_pagesize_mask &
" does not have required sun4v page sizes"
" 8K, 64K and 4M: MD mask is 0x%x",
/*
* Niagara2 supports a 48-bit subset of the full 64-bit virtual
* address space. Virtual addresses between 0x0000800000000000
* and 0xffff.7fff.ffff.ffff inclusive lie within a "VA Hole"
* and must never be mapped. In addition, software must not use
* pages within 4GB of the VA hole as instruction pages to
* avoid problems with prefetching into the VA hole.
*/
/*
* Niagara2 has a performance counter overflow interrupt
*/
/*
* Enable 4M pages for OOB.
*/
}
/*
* Set the magic constants of the implementation.
*/
void
{
/*
* The Cache node is optional in MD. Therefore in case "Cache"
* node does not exists in MD, set the default L2 cache associativity,
* size, linesize.
*/
if (cpunode->ecache_size == 0)
if (cpunode->ecache_linesize == 0)
if (cpunode->ecache_associativity == 0)
}
static int niagara2_cpucnt;
void
{
extern int niagara_kstat_init(void);
/*
* The cpu_ipipe and cpu_fpu fields are initialized based on
* the execution unit sharing information from the MD. They default
* to the virtual CPU id in the absence of such information.
*/
/*
* Niagara 2 defines the core to be at the FPU level
*/
(void) niagara_kstat_init();
}
/*ARGSUSED*/
void
{
extern int niagara_kstat_fini(void);
(void) niagara_kstat_fini();
}
/*
* On Niagara2, any flush will cause all preceding stores to be
* synchronized wrt the i$, regardless of address or ASI. In fact,
* the address is ignored, so we always flush address 0.
*/
/*ARGSUSED*/
void
{
doflush(0);
}
/*
* Trapstat support for Niagara2 processor
* The Niagara2 provides HWTW support for TSB lookup and with HWTW
* enabled no TSB hit information will be available. Therefore setting
* the time spent in TLB miss handler for TSB hits to 0.
*/
int
cpu_trapstat_conf(int cmd)
{
int status = 0;
switch (cmd) {
case CPU_TSTATCONF_INIT:
case CPU_TSTATCONF_FINI:
case CPU_TSTATCONF_ENABLE:
case CPU_TSTATCONF_DISABLE:
break;
default:
break;
}
return (status);
}
void
{
int i;
for (i = 0; i < tstat_pgszs; i++, tstatp++) {
}
}
/* NI2 L2$ index is pa[32:28]^pa[17:13].pa[19:18]^pa[12:11].pa[10:6] */
{
return (color);
}
#if TTE256M != 5
#endif
{
}
{
}
{
return (1);
return (0);
}
/*ARGSUSED*/
{
/* we start from the page with correct color */
/* page color is PA[32:28] */
} else {
/* page color is PA[32:28].PA[19:19] */
}
return (pfn);
} else {
/*
* We deal 64K or 8K page. Check if we could the
* satisfy the request without changing PA[32:28]
*/
return (npfn);
/*
* for next pfn we have to change bits PA[32:28]
* set PA[63:28] and PA[19:18] of the next pfn
*/
/*
* set bits PA[17:13] to match the color
*/
ceq_mask >>= 2;
return (npfn);
}
}
/*
* we start from the page with incorrect color - rare case
*/
/* page color is in bits PA[32:28] */
} else {
/* try get the right color by changing bit PA[19:19] */
ceq_mask) == 0)
return (npfn);
/* page color is PA[32:28].PA[19:19] */
}
}
return (npfn);
}
/*
* We deal 64K or 8K page of incorrect color.
* Try correcting color without changing PA[32:28]
*/
/* the color is fixed - find the next page */
}
return (npfn);
}
/* to fix the color need to touch PA[32:28] */
}
/* set bits PA[19:13] to match the color */
return (npfn);
}
/*
* init page coloring
*/
void
{
int i;
for (i = 3; i < mmu_page_sizes; i++) {
}
}
/*
* group colorequiv colors on N2 by low order bits of the color first
*/
void
{
if (colorequiv > 1) {
int i;
if (sv_a > 15)
sv_a = 15;
for (i = 0; i < MMU_PAGE_SIZES; i++) {
continue;
while ((colors >> a) == 0)
a--;
if (a > (colorequivszc[i] & 0xf) +
(colorequivszc[i] >> 4)) {
if (a <= nequiv_shades_log2[i]) {
colorequivszc[i] = a;
} else {
colorequivszc[i] =
((a - nequiv_shades_log2[i]) << 4) |
}
}
}
}
}