/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Portions Copyright 2009 Advanced Micro Devices, Inc.
*/
/*
* Copyright 2012 Jens Elkner <jel+illumos@cs.uni-magdeburg.de>
* Copyright 2012 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
*/
/*
* Support functions that interpret CPUID and similar information.
* These should not be used from anywhere other than cpuid.c and
* cmi_hw.c - as such we will not list them in any header file
* such as x86_archext.h.
*
* In cpuid.c we process CPUID information for each cpu_t instance
* we're presented with, and stash this raw information and material
* derived from it in per-cpu_t structures.
*
* If we are virtualized then the CPUID information derived from CPUID
* instructions executed in the guest is based on whatever the hypervisor
* wanted to make things look like, and the cpu_t are not necessarily in 1:1
* or fixed correspondence with real processor execution resources. In cmi_hw.c
* we are interested in the native properties of a processor - for fault
* management (and potentially other, such as power management) purposes;
* it will tunnel through to real hardware information, and use the
* functionality provided in this file to process it.
*/
#include <sys/x86_archext.h>
#include <sys/pci_cfgspace.h>
#ifdef __xpv
#include <sys/hypervisor.h>
#endif
/*
* AMD socket types.
* First index :
* 0 for family 0xf, revs B thru E
* 1 for family 0xf, revs F and G
* 2 for family 0x10
* 3 for family 0x11
* 4 for family 0x12
* 5 for family 0x14
* 6 for family 0x15, models 00 - 0f
* 7 for family 0x15, models 10 - 1f
* Second index by (model & 0x3) for family 0fh,
* CPUID pkg bits (Fn8000_0001_EBX[31:28]) for later families.
*/
/*
* Family 0xf revisions B through E
*/
#define A_SKTS_0 0
{
X86_SOCKET_754, /* 0b000 */
X86_SOCKET_940, /* 0b001 */
X86_SOCKET_754, /* 0b010 */
X86_SOCKET_939, /* 0b011 */
X86_SOCKET_UNKNOWN, /* 0b100 */
X86_SOCKET_UNKNOWN, /* 0b101 */
X86_SOCKET_UNKNOWN, /* 0b110 */
X86_SOCKET_UNKNOWN /* 0b111 */
},
/*
* Family 0xf revisions F and G
*/
{
X86_SOCKET_S1g1, /* 0b000 */
X86_SOCKET_F1207, /* 0b001 */
X86_SOCKET_UNKNOWN, /* 0b010 */
X86_SOCKET_AM2, /* 0b011 */
X86_SOCKET_UNKNOWN, /* 0b100 */
X86_SOCKET_UNKNOWN, /* 0b101 */
X86_SOCKET_UNKNOWN, /* 0b110 */
X86_SOCKET_UNKNOWN /* 0b111 */
},
/*
* Family 0x10
*/
{
X86_SOCKET_F1207, /* 0b000 */
X86_SOCKET_AM2R2, /* 0b001 */
X86_SOCKET_S1g3, /* 0b010 */
X86_SOCKET_G34, /* 0b011 */
X86_SOCKET_ASB2, /* 0b100 */
X86_SOCKET_C32, /* 0b101 */
X86_SOCKET_UNKNOWN, /* 0b110 */
X86_SOCKET_UNKNOWN /* 0b111 */
},
/*
* Family 0x11
*/
{
X86_SOCKET_UNKNOWN, /* 0b000 */
X86_SOCKET_UNKNOWN, /* 0b001 */
X86_SOCKET_S1g2, /* 0b010 */
X86_SOCKET_UNKNOWN, /* 0b011 */
X86_SOCKET_UNKNOWN, /* 0b100 */
X86_SOCKET_UNKNOWN, /* 0b101 */
X86_SOCKET_UNKNOWN, /* 0b110 */
X86_SOCKET_UNKNOWN /* 0b111 */
},
/*
* Family 0x12
*/
{
X86_SOCKET_UNKNOWN, /* 0b000 */
X86_SOCKET_FS1, /* 0b001 */
X86_SOCKET_FM1, /* 0b010 */
X86_SOCKET_UNKNOWN, /* 0b011 */
X86_SOCKET_UNKNOWN, /* 0b100 */
X86_SOCKET_UNKNOWN, /* 0b101 */
X86_SOCKET_UNKNOWN, /* 0b110 */
X86_SOCKET_UNKNOWN /* 0b111 */
},
/*
* Family 0x14
*/
{
X86_SOCKET_FT1, /* 0b000 */
X86_SOCKET_UNKNOWN, /* 0b001 */
X86_SOCKET_UNKNOWN, /* 0b010 */
X86_SOCKET_UNKNOWN, /* 0b011 */
X86_SOCKET_UNKNOWN, /* 0b100 */
X86_SOCKET_UNKNOWN, /* 0b101 */
X86_SOCKET_UNKNOWN, /* 0b110 */
X86_SOCKET_UNKNOWN /* 0b111 */
},
/*
* Family 0x15 models 00 - 0f
*/
{
X86_SOCKET_UNKNOWN, /* 0b000 */
X86_SOCKET_AM3R2, /* 0b001 */
X86_SOCKET_UNKNOWN, /* 0b010 */
X86_SOCKET_G34, /* 0b011 */
X86_SOCKET_UNKNOWN, /* 0b100 */
X86_SOCKET_C32, /* 0b101 */
X86_SOCKET_UNKNOWN, /* 0b110 */
X86_SOCKET_UNKNOWN /* 0b111 */
},
/*
* Family 0x15 models 10 - 1f
*/
{
X86_SOCKET_FP2, /* 0b000 */
X86_SOCKET_FS1R2, /* 0b001 */
X86_SOCKET_FM2, /* 0b010 */
X86_SOCKET_UNKNOWN, /* 0b011 */
X86_SOCKET_UNKNOWN, /* 0b100 */
X86_SOCKET_UNKNOWN, /* 0b101 */
X86_SOCKET_UNKNOWN, /* 0b110 */
X86_SOCKET_UNKNOWN /* 0b111 */
},
};
struct amd_sktmap_s {
};
{ X86_SOCKET_754, "754" },
{ X86_SOCKET_939, "939" },
{ X86_SOCKET_940, "940" },
{ X86_SOCKET_S1g1, "S1g1" },
{ X86_SOCKET_AM2, "AM2" },
{ X86_SOCKET_F1207, "F(1207)" },
{ X86_SOCKET_S1g2, "S1g2" },
{ X86_SOCKET_S1g3, "S1g3" },
{ X86_SOCKET_AM, "AM" },
{ X86_SOCKET_AM2R2, "AM2r2" },
{ X86_SOCKET_AM3, "AM3" },
{ X86_SOCKET_G34, "G34" },
{ X86_SOCKET_ASB2, "ASB2" },
{ X86_SOCKET_C32, "C32" },
{ X86_SOCKET_FT1, "FT1" },
{ X86_SOCKET_FM1, "FM1" },
{ X86_SOCKET_FS1, "FS1" },
{ X86_SOCKET_AM3R2, "AM3r2" },
{ X86_SOCKET_FP2, "FP2" },
{ X86_SOCKET_FS1R2, "FS1r2" },
{ X86_SOCKET_FM2, "FM2" },
{ X86_SOCKET_UNKNOWN, "Unknown" }
};
/*
* combination to chip "revision" and socket type.
*
* The first member of this array that matches a given family, extended model
* plus model range, and stepping range will be considered a match.
*/
static const struct amd_rev_mapent {
const char *rm_chiprevstr;
int rm_sktidx;
} amd_revmap[] = {
/*
* =============== AuthenticAMD Family 0xf ===============
*/
/*
* Rev B includes model 0x4 stepping 0 and model 0x5 stepping 0 and 1.
*/
/*
* Rev C0 includes model 0x4 stepping 8 and model 0x5 stepping 8
*/
/*
* Rev CG is the rest of extended model 0x0 - i.e., everything
* but the rev B and C0 combinations covered above.
*/
/*
* Rev D has extended model 0x1.
*/
/*
* Rev E has extended model 0x2.
* Extended model 0x3 is unused but available to grow into.
*/
/*
* Rev F has extended models 0x4 and 0x5.
*/
/*
* Rev G has extended model 0x6.
*/
/*
* =============== AuthenticAMD Family 0x10 ===============
*/
/*
* Rev A has model 0 and stepping 0/1/2 for DR-{A0,A1,A2}.
* Give all of model 0 stepping range to rev A.
*/
/*
* Rev B has model 2 and steppings 0/1/0xa/2 for DR-{B0,B1,BA,B2}.
* Give all of model 2 stepping range to rev B.
*/
/*
* Rev C has models 4-6 (depending on L3 cache configuration)
* Give all of models 4-6 stepping range 0-2 to rev C2.
*/
/*
* Rev C has models 4-6 (depending on L3 cache configuration)
* Give all of models 4-6 stepping range >= 3 to rev C3.
*/
/*
* Rev D has models 8 and 9
* Give all of model 8 and 9 stepping 0 to rev D0.
*/
/*
* Rev D has models 8 and 9
* Give all of model 8 and 9 stepping range >= 1 to rev D1.
*/
/*
* Rev E has models A and stepping 0
* Give all of model A stepping range to rev E.
*/
/*
* =============== AuthenticAMD Family 0x11 ===============
*/
/*
* =============== AuthenticAMD Family 0x12 ===============
*/
/*
* =============== AuthenticAMD Family 0x14 ===============
*/
/*
* =============== AuthenticAMD Family 0x15 ===============
*/
A_SKTS_6 },
A_SKTS_7 },
};
static void
{
int found = 0;
int i;
if (family < 0xf)
return;
i++, rmp++) {
found = 1;
break;
}
}
if (!found)
return;
if (chiprevstr_p != NULL)
int platform;
#ifdef __xpv
/* PV guest */
if (!is_controldom()) {
return;
}
#endif
if ((platform & HW_VIRTUAL) != 0) {
} else if (family == 0xf) {
} else {
/*
* Starting with family 10h, socket type is stored in
* CPUID Fn8000_0001_EBX
*/
int idx;
(void) __cpuid_insn(&cp);
/* PkgType bits */
if (idx > 7) {
/* Reserved bits */
} else {
}
if (family == 0x10) {
/*
* Look at Ddr3Mode bit of DRAM Configuration
* High Register to decide whether this is
* actually AM3 or S1g4.
*/
if (*skt_p == X86_SOCKET_AM2R2)
*skt_p = X86_SOCKET_AM3;
else if (*skt_p == X86_SOCKET_S1g3)
*skt_p = X86_SOCKET_S1g4;
}
}
}
}
}
{
switch (vendor) {
case X86_VENDOR_AMD:
break;
default:
break;
}
return (skt);
}
const char *
{
switch (vendor) {
case X86_VENDOR_AMD:
break;
sktmapp++;
}
break;
default:
break;
}
return (sktstr);
}
{
switch (vendor) {
case X86_VENDOR_AMD:
break;
default:
break;
}
return (chiprev);
}
const char *
{
switch (vendor) {
case X86_VENDOR_AMD:
break;
default:
break;
}
return (revstr);
}
/*
* CyrixInstead is a variable used by the Cyrix detection code
* in locore.
*/
/*
* Map the vendor string to a type code
*/
{
return (X86_VENDOR_Intel);
return (X86_VENDOR_AMD);
return (X86_VENDOR_TM);
return (X86_VENDOR_Cyrix);
return (X86_VENDOR_UMC);
return (X86_VENDOR_NexGen);
return (X86_VENDOR_Centaur);
return (X86_VENDOR_Rise);
return (X86_VENDOR_SiS);
return (X86_VENDOR_NSC);
else
return (X86_VENDOR_IntelClone);
}