#include #include #include #include #include #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)); } static int __get_cpuid(char *buffer, size_t sz, const char *fmt) { 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 = scnprintf(buffer, sz, fmt, 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; } int get_cpuid(char *buffer, size_t sz) { return __get_cpuid(buffer, sz, "%s,%u,%u,%u$"); } char * get_cpuid_str(void) { char *buf = malloc(128); if (__get_cpuid(buf, 128, "%s-%u-%X$") < 0) { free(buf); return NULL; } return buf; } able>
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-11 10:17:39 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-11 10:17:39 -0800
commit2e4333c14de06a333783d6812cf3c4998f78b0c8 (patch)
tree368428514d70f34f2261c7f954f241f886d6bb51 /fs/9p/vfs_addr.c
parent045169816b31b10faed984b01c390db1b32ee4c1 (diff)
parentba735155b9647b6167fd50276ca0fbfbce4e836c (diff)
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS fixes from Ralf Baechle: "Two more MIPS fixes for 4.9: - RTC: Return -ENODEV so an external RTC will be tried - Fix mask of GPE frequency These two have been tested on Imagination's automated test system and also both received positive reviews on the linux-mips mailing list" * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: MIPS: Lantiq: Fix mask of GPE frequency MIPS: Return -ENODEV from weak implementation of rtc_mips_set_time
Diffstat (limited to 'fs/9p/vfs_addr.c')