niagara.c revision ce0352eb406e3bc76c5885dfb72e99d53bdb985d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 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/niagararegs.h>
#include <sys/trapstat.h>
/*
* Maximum number of contexts
*/
#ifdef NIAGARA_CHK_VERSION
/* Niagara CPU version register */
#define VER_MASK_MAJOR_SHIFT 28
#define VER_MASK_MAJOR_MASK 0xf
#endif /* NIAGARA_CHK_VERSION */
void
cpu_setup(void)
{
extern int at_flags;
extern int disable_delay_tlb_flush, delay_tlb_flush;
extern int mmu_exported_pagesize_mask;
extern int get_cpu_pagesizes(void);
extern int cpc_has_overflow_intr;
/*
* Use the maximum number of contexts available for Spitfire unless
* it has been tuned for debugging.
* We are checking against 0 here since this value can be patched
* will be patched too late and thus cause the system to panic.
*/
if (nctxs == 0)
if (use_page_coloring) {
do_pg_coloring = 1;
if (use_virtual_coloring)
do_virtual_coloring = 1;
}
/*
* Initalize supported page sizes information before the PD.
* If no information is available, then initialize the
* mmu_exported_pagesize_mask to a reasonable value for that processor.
*/
if (mmu_exported_pagesize_mask <= 0) {
}
/*
* Tune pp_slots to use up to 1/8th of the tlb entries.
*/
/*
* Block stores invalidate all pages of the d$ so pagecopy
* et. al. do not need virtual translations with virtual
* coloring taken into consideration.
*/
isa_list =
"sparcv9 sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 "
"sparc sparcv9+vis sparcv9+vis2 sparcv8plus+vis sparcv8plus+vis2";
/*
* Niagara 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.
*
* VA hole information should be obtained from the machine
* description.
*/
/*
* The kpm mapping window.
* kpm_size:
* The size of a single kpm range.
* The overall size will be: kpm_size * vac_colors.
* kpm_vbase:
* The virtual start address of the kpm range within the kernel
* virtual address space. kpm_vbase has to be kpm_size aligned.
*/
kpm_size_shift = 41;
/*
* The traptrace code uses either %tick or %stick for
* timestamping. We have %stick so we can use it.
*/
traptrace_use_stick = 1;
/*
* sun4v provides demap_all
*/
if (!disable_delay_tlb_flush)
delay_tlb_flush = 1;
/*
* Niagara has a performance counter overflow interrupt
*/
}
/*
* Set the magic constants of the implementation.
*/
void
{
int i, a;
/*
* The assumption here is that fillsysinfo will eventually
* have code to fill this info in from the PD.
* We hard code this for niagara now.
* Once the PD access library is done this code
* might need to be changed to get the info from the PD
*/
if (cpunode->ecache_size == 0)
if (cpunode->ecache_linesize == 0)
if (cpunode->ecache_associativity == 0)
if (ecache_setsize == 0)
if (ecache_alignsize == 0)
i = 0; a = vac_size;
while (a >>= 1)
++i;
vac_shift = i;
vac = 0;
}
static int niagara_cpucnt;
void
{
extern int niagara_kstat_init(void);
#ifdef NIAGARA_CHK_VERSION
/*
* Prevent booting on a Niagara 1.x processor as it is no longer
* supported.
*
* This is a temporary hack until everyone has switched to the
* firmware which prevents booting on a Niagara 1.x processor.
*/
#endif /* NIAGARA_CHK_VERSION */
/*
* This code change assumes that the virtual cpu ids are identical
* to the physical cpu ids which is true for ontario but not for
* niagara in general.
* This is a temporary fix which will later be modified to obtain
* the execution unit sharing information from MD table.
*/
if (niagara_cpucnt++ == 0) {
(void) niagara_kstat_init();
}
}
void
{
extern int niagara_kstat_fini(void);
if (--niagara_cpucnt == 0) {
(void) niagara_kstat_fini();
}
}
/*
* On Niagara, 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.
*/
void
{
doflush(0);
}
#define IS_FLOAT(i) (((i) & 0x1000000) != 0)
#define IS_IBIT_SET(x) (x & 0x2000)
int
{
char *badaddr;
int instr;
return (-1);
if (IS_IBIT_SET(instr)) {
} else {
}
return (-1);
}
case SIMU_RETRY:
break; /* regs are already set up */
/*NOTREACHED*/
case SIMU_SUCCESS:
/*
* skip the successfully
* simulated instruction
*/
break;
/*NOTREACHED*/
case SIMU_FAULT:
break;
case SIMU_DZERO:
break;
case SIMU_UNALIGN:
break;
case SIMU_ILLEGAL:
default:
(op3 == IOP_V8_STDFA)))
else
break;
}
return (0);
}
/*
* Trapstat support for Niagara processor
*/
int
cpu_trapstat_conf(int cmd)
{
int status = 0;
switch (cmd) {
case CPU_TSTATCONF_INIT:
sizeof (niagara_mmustat_t));
if (cpu_tstat_va == NULL)
else {
}
break;
case CPU_TSTATCONF_FINI:
if (cpu_tstat_va) {
cpu_tstat_va = NULL;
cpu_tstat_pa = 0;
}
break;
case CPU_TSTATCONF_ENABLE:
(uint64_t *)&mmustat_pa);
break;
case CPU_TSTATCONF_DISABLE:
break;
default:
break;
}
return (status);
}
void
{
int i, pgcnt;
if (cpu_tstat_va == NULL)
return;
if (tstat_pgszs > NIAGARA_MMUSTAT_PGSZS)
for (i = 0; i < tstat_pgszs; i++, tstatp++) {
}
}