~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/kernel/cpu/match.c

Version: ~ [ linux-5.5-rc7 ] ~ [ linux-5.4.13 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.97 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.166 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.210 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.210 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <asm/cpu_device_id.h>
  2 #include <asm/processor.h>
  3 #include <linux/cpu.h>
  4 #include <linux/module.h>
  5 #include <linux/slab.h>
  6 
  7 /**
  8  * x86_match_cpu - match current CPU again an array of x86_cpu_ids
  9  * @match: Pointer to array of x86_cpu_ids. Last entry terminated with
 10  *         {}.
 11  *
 12  * Return the entry if the current CPU matches the entries in the
 13  * passed x86_cpu_id match table. Otherwise NULL.  The match table
 14  * contains vendor (X86_VENDOR_*), family, model and feature bits or
 15  * respective wildcard entries.
 16  *
 17  * A typical table entry would be to match a specific CPU
 18  * { X86_VENDOR_INTEL, 6, 0x12 }
 19  * or to match a specific CPU feature
 20  * { X86_FEATURE_MATCH(X86_FEATURE_FOOBAR) }
 21  *
 22  * Fields can be wildcarded with %X86_VENDOR_ANY, %X86_FAMILY_ANY,
 23  * %X86_MODEL_ANY, %X86_FEATURE_ANY or 0 (except for vendor)
 24  *
 25  * Arrays used to match for this should also be declared using
 26  * MODULE_DEVICE_TABLE(x86cpu, ...)
 27  *
 28  * This always matches against the boot cpu, assuming models and features are
 29  * consistent over all CPUs.
 30  */
 31 const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match)
 32 {
 33         const struct x86_cpu_id *m;
 34         struct cpuinfo_x86 *c = &boot_cpu_data;
 35 
 36         for (m = match; m->vendor | m->family | m->model | m->feature; m++) {
 37                 if (m->vendor != X86_VENDOR_ANY && c->x86_vendor != m->vendor)
 38                         continue;
 39                 if (m->family != X86_FAMILY_ANY && c->x86 != m->family)
 40                         continue;
 41                 if (m->model != X86_MODEL_ANY && c->x86_model != m->model)
 42                         continue;
 43                 if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))
 44                         continue;
 45                 return m;
 46         }
 47         return NULL;
 48 }
 49 EXPORT_SYMBOL(x86_match_cpu);
 50 
 51 ssize_t arch_print_cpu_modalias(struct device *dev,
 52                                 struct device_attribute *attr,
 53                                 char *bufptr)
 54 {
 55         int size = PAGE_SIZE;
 56         int i, n;
 57         char *buf = bufptr;
 58 
 59         n = snprintf(buf, size, "x86cpu:vendor:%04X:family:%04X:"
 60                      "model:%04X:feature:",
 61                 boot_cpu_data.x86_vendor,
 62                 boot_cpu_data.x86,
 63                 boot_cpu_data.x86_model);
 64         size -= n;
 65         buf += n;
 66         size -= 1;
 67         for (i = 0; i < NCAPINTS*32; i++) {
 68                 if (boot_cpu_has(i)) {
 69                         n = snprintf(buf, size, ",%04X", i);
 70                         if (n >= size) {
 71                                 WARN(1, "x86 features overflow page\n");
 72                                 break;
 73                         }
 74                         size -= n;
 75                         buf += n;
 76                 }
 77         }
 78         *buf++ = '\n';
 79         return buf - bufptr;
 80 }
 81 
 82 int arch_cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
 83 {
 84         char *buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
 85         if (buf) {
 86                 arch_print_cpu_modalias(NULL, NULL, buf);
 87                 add_uevent_var(env, "MODALIAS=%s", buf);
 88                 kfree(buf);
 89         }
 90         return 0;
 91 }
 92 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp