-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 269055 b: refs/heads/master c: fbe96f2 h: refs/heads/master i: 269053: f40c5c2 269051: 78b585e 269047: a3e93f6 269039: c4de203 269023: 7b286e7 268991: 027c7c4 268927: eeb58de 268799: e3ba49f v: v3
- Loading branch information
Stephane Eranian
authored and
Arnaldo Carvalho de Melo
committed
Oct 7, 2011
1 parent
178302b
commit 1a7b06a
Showing
16 changed files
with
1,309 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: be83f5ed6bc46cd89b4a102b6e341ecddf7abf91 | ||
refs/heads/master: fbe96f29ce4b33e0a22219cc7f5996d9157717e3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include "../../util/header.h" | ||
|
||
#define __stringify_1(x) #x | ||
#define __stringify(x) __stringify_1(x) | ||
|
||
#define mfspr(rn) ({unsigned long rval; \ | ||
asm volatile("mfspr %0," __stringify(rn) \ | ||
: "=r" (rval)); rval; }) | ||
|
||
#define SPRN_PVR 0x11F /* Processor Version Register */ | ||
#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */ | ||
#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */ | ||
|
||
int | ||
get_cpuid(char *buffer, size_t sz) | ||
{ | ||
unsigned long pvr; | ||
int nb; | ||
|
||
pvr = mfspr(SPRN_PVR); | ||
|
||
nb = snprintf(buffer, sz, "%lu,%lu$", PVR_VER(pvr), PVR_REV(pvr)); | ||
|
||
/* look for end marker to ensure the entire data fit */ | ||
if (strchr(buffer, '$')) { | ||
buffer[nb-1] = '\0'; | ||
return 0; | ||
} | ||
return -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include "../../util/header.h" | ||
|
||
static inline void | ||
cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c, | ||
unsigned int *d) | ||
{ | ||
__asm__ __volatile__ (".byte 0x53\n\tcpuid\n\t" | ||
"movl %%ebx, %%esi\n\t.byte 0x5b" | ||
: "=a" (*a), | ||
"=S" (*b), | ||
"=c" (*c), | ||
"=d" (*d) | ||
: "a" (op)); | ||
} | ||
|
||
int | ||
get_cpuid(char *buffer, size_t sz) | ||
{ | ||
unsigned int a, b, c, d, lvl; | ||
int family = -1, model = -1, step = -1; | ||
int nb; | ||
char vendor[16]; | ||
|
||
cpuid(0, &lvl, &b, &c, &d); | ||
strncpy(&vendor[0], (char *)(&b), 4); | ||
strncpy(&vendor[4], (char *)(&d), 4); | ||
strncpy(&vendor[8], (char *)(&c), 4); | ||
vendor[12] = '\0'; | ||
|
||
if (lvl >= 1) { | ||
cpuid(1, &a, &b, &c, &d); | ||
|
||
family = (a >> 8) & 0xf; /* bits 11 - 8 */ | ||
model = (a >> 4) & 0xf; /* Bits 7 - 4 */ | ||
step = a & 0xf; | ||
|
||
/* extended family */ | ||
if (family == 0xf) | ||
family += (a >> 20) & 0xff; | ||
|
||
/* extended model */ | ||
if (family >= 0x6) | ||
model += ((a >> 16) & 0xf) << 4; | ||
} | ||
nb = snprintf(buffer, sz, "%s,%u,%u,%u$", vendor, family, model, step); | ||
|
||
/* look for end marker to ensure the entire data fit */ | ||
if (strchr(buffer, '$')) { | ||
buffer[nb-1] = '\0'; | ||
return 0; | ||
} | ||
return -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.