mirror of
https://github.com/anrieff/libcpuid
synced 2025-10-03 11:01:30 +00:00
Support for Nehalem Xeons added
git-svn-id: https://svn.code.sf.net/p/libcpuid/code/HEAD/libcpuid@60 3b4be424-7ac5-41d7-8526-f4ddcb85d872
This commit is contained in:
parent
8f1f12828d
commit
103bb027c6
5 changed files with 159 additions and 11 deletions
|
@ -131,3 +131,39 @@ void generic_get_cpu_list(const struct match_entry_t* matchtable, int count,
|
|||
}
|
||||
list->num_entries = n;
|
||||
}
|
||||
|
||||
static int xmatch_entry(char c, const char* p)
|
||||
{
|
||||
int i, j;
|
||||
if (c == 0) return -1;
|
||||
if (c == p[0]) return 1;
|
||||
if (p[0] == '.') return 1;
|
||||
if (p[0] == '#' && isdigit(c)) return 1;
|
||||
if (p[0] == '[') {
|
||||
j = 1;
|
||||
while (p[j] && p[j] != ']') j++;
|
||||
if (!p[j]) return -1;
|
||||
for (i = 1; i < j; i++)
|
||||
if (p[i] == c) return j + 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int match_pattern(const char* s, const char* p)
|
||||
{
|
||||
int i, j, dj, k, n, m;
|
||||
n = (int) strlen(s);
|
||||
m = (int) strlen(p);
|
||||
for (i = 0; i < n; i++) {
|
||||
if (xmatch_entry(s[i], p)) {
|
||||
j = 0;
|
||||
k = 0;
|
||||
while (j < m && ((dj = xmatch_entry(s[i + k], p + j)) != -1)) {
|
||||
k++;
|
||||
j += dj;
|
||||
}
|
||||
if (j == m) return i + 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,18 @@ __attribute__((format(printf, 2, 3)))
|
|||
void generic_get_cpu_list(const struct match_entry_t* matchtable, int count,
|
||||
struct cpu_list_t* list);
|
||||
|
||||
/*
|
||||
* Seek for a pattern in `haystack'.
|
||||
* Pattern may be an fixed string, or contain the special metacharacters
|
||||
* '.' - match any single character
|
||||
* '#' - match any digit
|
||||
* '[<chars>] - match any of the given chars (regex-like ranges are not
|
||||
* supported)
|
||||
* Return val: 0 if the pattern is not found. Nonzero if it is found (actually,
|
||||
* x + 1 where x is the index where the match is found).
|
||||
*/
|
||||
int match_pattern(const char* haystack, const char* pattern);
|
||||
|
||||
extern libcpuid_warn_fn_t _warn_fun;
|
||||
extern int _current_verboselevel;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ enum _intel_code_t {
|
|||
XEON_IRWIN,
|
||||
XEONMP,
|
||||
XEON_POTOMAC,
|
||||
XEON_I7,
|
||||
MOBILE_PENTIUM_M,
|
||||
CELERON,
|
||||
MOBILE_CELERON,
|
||||
|
@ -239,6 +240,8 @@ const struct match_entry_t cpudb_intel[] = {
|
|||
|
||||
{ 6, 10, -1, -1, 26, 1, -1, CORE_Ix , 0, "Intel Core i7" },
|
||||
{ 6, 10, -1, -1, 26, 4, -1, CORE_Ix , 0, "Bloomfield (Core i7)" },
|
||||
{ 6, 10, -1, -1, 26, 4, -1, XEON_I7 , 0, "Xeon (Bloomfield)" },
|
||||
|
||||
|
||||
/* Core microarchitecture-based Xeons: */
|
||||
{ 6, 14, -1, -1, 14, 1, -1, XEON , 0, "Xeon LV" },
|
||||
|
@ -521,7 +524,7 @@ static intel_code_t get_brand_code(struct cpu_id_t* data)
|
|||
intel_code_t code = NO_CODE;
|
||||
int i, need_matchtable = 1;
|
||||
const char* bs = data->brand_str;
|
||||
const char* s, *ixs;
|
||||
const char* s;
|
||||
const struct { intel_code_t c; const char *search; } matchtable[] = {
|
||||
{ XEONMP, "Xeon MP" },
|
||||
{ XEONMP, "Xeon(TM) MP" },
|
||||
|
@ -546,13 +549,10 @@ static intel_code_t get_brand_code(struct cpu_id_t* data)
|
|||
else if (strstr(bs, "Pentium"))
|
||||
code = MOBILE_PENTIUM;
|
||||
}
|
||||
ixs = strstr(bs, "Core(TM) i");
|
||||
if (ixs) {
|
||||
if (ixs[10] == '3' || ixs[10] == '5' || ixs[10] == '7') {
|
||||
/* Core i3, Core i5 or Core i7 */
|
||||
need_matchtable = 0;
|
||||
code = CORE_Ix;
|
||||
}
|
||||
if (match_pattern(bs, "Core(TM) i[357]")) {
|
||||
/* Core i3, Core i5 or Core i7 */
|
||||
need_matchtable = 0;
|
||||
code = CORE_Ix;
|
||||
}
|
||||
if (need_matchtable) {
|
||||
for (i = 0; i < COUNT_OF(matchtable); i++)
|
||||
|
@ -561,9 +561,12 @@ static intel_code_t get_brand_code(struct cpu_id_t* data)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (code == XEON && data->l3_cache > 0)
|
||||
code = XEON_IRWIN;
|
||||
if (code == XEON) {
|
||||
if (match_pattern(bs, "W####"))
|
||||
code = XEON_I7;
|
||||
else if (data->l3_cache > 0)
|
||||
code = XEON_IRWIN;
|
||||
}
|
||||
if (code == XEONMP && data->l3_cache > 0)
|
||||
code = XEON_POTOMAC;
|
||||
if (code == CORE_SOLO) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue