#include <sys/types.h>
#include <sys/machsystm.h>
#include <sys/x_call.h>
#include <sys/cmp.h>
#include <sys/cmt.h>
#include <sys/debug.h>
#include <sys/disp.h>
#include <sys/cheetahregs.h>
static cpuset_t chips[MAX_CPU_CHIPID];
int
cmp_cpu_is_cmp(processorid_t cpuid)
{
chipid_t chipid;
chipid = cpunodes[cpuid].portid;
return (!CPUSET_ISNULL(chips[chipid]));
}
void
cmp_add_cpu(chipid_t chipid, processorid_t cpuid)
{
CPUSET_ADD(chips[chipid], cpuid);
}
void
cmp_delete_cpu(processorid_t cpuid)
{
chipid_t chipid;
chipid = cpunodes[cpuid].portid;
CPUSET_DEL(chips[chipid], cpuid);
}
void
cmp_error_resteer(processorid_t cpuid)
{
#ifndef _CMP_NO_ERROR_STEERING
cpuset_t mycores;
cpu_t *cpu;
chipid_t chipid;
int i;
if (!cmp_cpu_is_cmp(cpuid))
return;
ASSERT(MUTEX_HELD(&cpu_lock));
chipid = cpunodes[cpuid].portid;
mycores = chips[chipid];
for (i = 0; i < NCPU; i++) {
if (i == cpuid)
continue;
if (CPU_IN_SET(mycores, i) &&
(cpu = cpu_get(i)) != NULL && cpu_is_active(cpu)) {
xc_one(i, (xcfunc_t *)set_cmp_error_steering, 0, 0);
break;
}
}
if (i == NCPU) {
xc_one(cpuid, (xcfunc_t *)set_cmp_error_steering, 0, 0);
}
#else
return;
#endif
}
chipid_t
cmp_cpu_to_chip(processorid_t cpuid)
{
if (!cmp_cpu_is_cmp(cpuid)) {
ASSERT(cpuid < MAX_CPU_CHIPID && CPUSET_ISNULL(chips[cpuid]));
return (cpuid);
}
return (cpunodes[cpuid].portid);
}
int
pg_plat_hw_shared(cpu_t *cp, pghw_type_t hw)
{
int impl;
impl = cpunodes[cp->cpu_id].implementation;
switch (hw) {
case PGHW_IPIPE:
if ((IS_OLYMPUS_C(impl)) || (IS_JUPITER(impl)))
return (1);
break;
case PGHW_CHIP:
if (IS_JAGUAR(impl) || IS_PANTHER(impl) ||
IS_OLYMPUS_C(impl) || IS_JUPITER(impl))
return (1);
break;
case PGHW_CACHE:
if (IS_PANTHER(impl) || IS_OLYMPUS_C(impl) || IS_JUPITER(impl))
return (1);
break;
}
return (0);
}
int
pg_plat_cpus_share(cpu_t *cpu_a, cpu_t *cpu_b, pghw_type_t hw)
{
int impl;
impl = cpunodes[cpu_a->cpu_id].implementation;
switch (hw) {
case PGHW_IPIPE:
case PGHW_CHIP:
return (pg_plat_hw_instance_id(cpu_a, hw) ==
pg_plat_hw_instance_id(cpu_b, hw));
case PGHW_CACHE:
if ((IS_PANTHER(impl) || IS_OLYMPUS_C(impl) ||
IS_JUPITER(impl)) && pg_plat_cpus_share(cpu_a,
cpu_b, PGHW_CHIP)) {
return (1);
} else {
return (0);
}
}
return (0);
}
id_t
pg_plat_hw_instance_id(cpu_t *cpu, pghw_type_t hw)
{
int impl;
impl = cpunodes[cpu->cpu_id].implementation;
switch (hw) {
case PGHW_IPIPE:
if (IS_OLYMPUS_C(impl) || IS_JUPITER(impl)) {
return ((id_t)((uint_t)cpu->cpu_id & ~(0x1)));
} else {
return (cpu->cpu_id);
}
case PGHW_CHIP:
return (cmp_cpu_to_chip(cpu->cpu_id));
case PGHW_CACHE:
if (IS_PANTHER(impl) ||
IS_OLYMPUS_C(impl) || IS_JUPITER(impl))
return (pg_plat_hw_instance_id(cpu, PGHW_CHIP));
else
return (cpu->cpu_id);
default:
return (-1);
}
}
pghw_type_t
pg_plat_hw_rank(pghw_type_t hw1, pghw_type_t hw2)
{
int i;
int rank1 = 0;
int rank2 = 0;
static pghw_type_t hw_hier[] = {
PGHW_IPIPE,
PGHW_CHIP,
PGHW_CACHE,
PGHW_NUM_COMPONENTS
};
for (i = 0; hw_hier[i] != PGHW_NUM_COMPONENTS; i++) {
if (hw_hier[i] == hw1)
rank1 = i;
if (hw_hier[i] == hw2)
rank2 = i;
}
if (rank1 > rank2)
return (hw1);
else
return (hw2);
}
pg_cmt_policy_t
pg_plat_cmt_policy(pghw_type_t hw)
{
return (CMT_NO_POLICY);
}
id_t
pg_plat_get_core_id(cpu_t *cp)
{
return (pg_plat_hw_instance_id(cp, PGHW_IPIPE));
}
void
cmp_set_nosteal_interval(void)
{
nosteal_nsec = 100000UL;
}
int
pg_cmt_load_bal_hw(pghw_type_t hw)
{
if (hw == PGHW_IPIPE ||
hw == PGHW_FPU ||
hw == PGHW_CHIP)
return (1);
else
return (0);
}
int
pg_cmt_affinity_hw(pghw_type_t hw)
{
if (hw == PGHW_CACHE)
return (1);
else
return (0);
}
int
cu_plat_cpc_init(cpu_t *cp, kcpc_request_list_t *reqs, int nreqs)
{
return (-1);
}