main.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. /* Generic MTRR (Memory Type Range Register) driver.
  2. Copyright (C) 1997-2000 Richard Gooch
  3. Copyright (c) 2002 Patrick Mochel
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. Richard Gooch may be reached by email at rgooch@atnf.csiro.au
  16. The postal address is:
  17. Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
  18. Source: "Pentium Pro Family Developer's Manual, Volume 3:
  19. Operating System Writer's Guide" (Intel document number 242692),
  20. section 11.11.7
  21. This was cleaned and made readable by Patrick Mochel <mochel@osdl.org>
  22. on 6-7 March 2002.
  23. Source: Intel Architecture Software Developers Manual, Volume 3:
  24. System Programming Guide; Section 9.11. (1997 edition - PPro).
  25. */
  26. #include <linux/module.h>
  27. #include <linux/init.h>
  28. #include <linux/pci.h>
  29. #include <linux/smp.h>
  30. #include <linux/cpu.h>
  31. #include <asm/mtrr.h>
  32. #include <asm/uaccess.h>
  33. #include <asm/processor.h>
  34. #include <asm/msr.h>
  35. #include "mtrr.h"
  36. #define MTRR_VERSION "2.0 (20020519)"
  37. u32 num_var_ranges = 0;
  38. unsigned int *usage_table;
  39. static DECLARE_MUTEX(main_lock);
  40. u32 size_or_mask, size_and_mask;
  41. static struct mtrr_ops * mtrr_ops[X86_VENDOR_NUM] = {};
  42. struct mtrr_ops * mtrr_if = NULL;
  43. static void set_mtrr(unsigned int reg, unsigned long base,
  44. unsigned long size, mtrr_type type);
  45. extern int arr3_protected;
  46. void set_mtrr_ops(struct mtrr_ops * ops)
  47. {
  48. if (ops->vendor && ops->vendor < X86_VENDOR_NUM)
  49. mtrr_ops[ops->vendor] = ops;
  50. }
  51. /* Returns non-zero if we have the write-combining memory type */
  52. static int have_wrcomb(void)
  53. {
  54. struct pci_dev *dev;
  55. u8 rev;
  56. if ((dev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, NULL)) != NULL) {
  57. /* ServerWorks LE chipsets < rev 6 have problems with write-combining
  58. Don't allow it and leave room for other chipsets to be tagged */
  59. if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
  60. dev->device == PCI_DEVICE_ID_SERVERWORKS_LE) {
  61. pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev);
  62. if (rev <= 5) {
  63. printk(KERN_INFO "mtrr: Serverworks LE rev < 6 detected. Write-combining disabled.\n");
  64. pci_dev_put(dev);
  65. return 0;
  66. }
  67. }
  68. /* Intel 450NX errata # 23. Non ascending cacheline evictions to
  69. write combining memory may resulting in data corruption */
  70. if (dev->vendor == PCI_VENDOR_ID_INTEL &&
  71. dev->device == PCI_DEVICE_ID_INTEL_82451NX) {
  72. printk(KERN_INFO "mtrr: Intel 450NX MMC detected. Write-combining disabled.\n");
  73. pci_dev_put(dev);
  74. return 0;
  75. }
  76. pci_dev_put(dev);
  77. }
  78. return (mtrr_if->have_wrcomb ? mtrr_if->have_wrcomb() : 0);
  79. }
  80. /* This function returns the number of variable MTRRs */
  81. static void __init set_num_var_ranges(void)
  82. {
  83. unsigned long config = 0, dummy;
  84. if (use_intel()) {
  85. rdmsr(MTRRcap_MSR, config, dummy);
  86. } else if (is_cpu(AMD))
  87. config = 2;
  88. else if (is_cpu(CYRIX) || is_cpu(CENTAUR))
  89. config = 8;
  90. num_var_ranges = config & 0xff;
  91. }
  92. static void __init init_table(void)
  93. {
  94. int i, max;
  95. max = num_var_ranges;
  96. if ((usage_table = kmalloc(max * sizeof *usage_table, GFP_KERNEL))
  97. == NULL) {
  98. printk(KERN_ERR "mtrr: could not allocate\n");
  99. return;
  100. }
  101. for (i = 0; i < max; i++)
  102. usage_table[i] = 1;
  103. }
  104. struct set_mtrr_data {
  105. atomic_t count;
  106. atomic_t gate;
  107. unsigned long smp_base;
  108. unsigned long smp_size;
  109. unsigned int smp_reg;
  110. mtrr_type smp_type;
  111. };
  112. #ifdef CONFIG_SMP
  113. static void ipi_handler(void *info)
  114. /* [SUMMARY] Synchronisation handler. Executed by "other" CPUs.
  115. [RETURNS] Nothing.
  116. */
  117. {
  118. struct set_mtrr_data *data = info;
  119. unsigned long flags;
  120. local_irq_save(flags);
  121. atomic_dec(&data->count);
  122. while(!atomic_read(&data->gate))
  123. cpu_relax();
  124. /* The master has cleared me to execute */
  125. if (data->smp_reg != ~0U)
  126. mtrr_if->set(data->smp_reg, data->smp_base,
  127. data->smp_size, data->smp_type);
  128. else
  129. mtrr_if->set_all();
  130. atomic_dec(&data->count);
  131. while(atomic_read(&data->gate))
  132. cpu_relax();
  133. atomic_dec(&data->count);
  134. local_irq_restore(flags);
  135. }
  136. #endif
  137. /**
  138. * set_mtrr - update mtrrs on all processors
  139. * @reg: mtrr in question
  140. * @base: mtrr base
  141. * @size: mtrr size
  142. * @type: mtrr type
  143. *
  144. * This is kinda tricky, but fortunately, Intel spelled it out for us cleanly:
  145. *
  146. * 1. Send IPI to do the following:
  147. * 2. Disable Interrupts
  148. * 3. Wait for all procs to do so
  149. * 4. Enter no-fill cache mode
  150. * 5. Flush caches
  151. * 6. Clear PGE bit
  152. * 7. Flush all TLBs
  153. * 8. Disable all range registers
  154. * 9. Update the MTRRs
  155. * 10. Enable all range registers
  156. * 11. Flush all TLBs and caches again
  157. * 12. Enter normal cache mode and reenable caching
  158. * 13. Set PGE
  159. * 14. Wait for buddies to catch up
  160. * 15. Enable interrupts.
  161. *
  162. * What does that mean for us? Well, first we set data.count to the number
  163. * of CPUs. As each CPU disables interrupts, it'll decrement it once. We wait
  164. * until it hits 0 and proceed. We set the data.gate flag and reset data.count.
  165. * Meanwhile, they are waiting for that flag to be set. Once it's set, each
  166. * CPU goes through the transition of updating MTRRs. The CPU vendors may each do it
  167. * differently, so we call mtrr_if->set() callback and let them take care of it.
  168. * When they're done, they again decrement data->count and wait for data.gate to
  169. * be reset.
  170. * When we finish, we wait for data.count to hit 0 and toggle the data.gate flag.
  171. * Everyone then enables interrupts and we all continue on.
  172. *
  173. * Note that the mechanism is the same for UP systems, too; all the SMP stuff
  174. * becomes nops.
  175. */
  176. static void set_mtrr(unsigned int reg, unsigned long base,
  177. unsigned long size, mtrr_type type)
  178. {
  179. struct set_mtrr_data data;
  180. unsigned long flags;
  181. data.smp_reg = reg;
  182. data.smp_base = base;
  183. data.smp_size = size;
  184. data.smp_type = type;
  185. atomic_set(&data.count, num_booting_cpus() - 1);
  186. atomic_set(&data.gate,0);
  187. /* Start the ball rolling on other CPUs */
  188. if (smp_call_function(ipi_handler, &data, 1, 0) != 0)
  189. panic("mtrr: timed out waiting for other CPUs\n");
  190. local_irq_save(flags);
  191. while(atomic_read(&data.count))
  192. cpu_relax();
  193. /* ok, reset count and toggle gate */
  194. atomic_set(&data.count, num_booting_cpus() - 1);
  195. atomic_set(&data.gate,1);
  196. /* do our MTRR business */
  197. /* HACK!
  198. * We use this same function to initialize the mtrrs on boot.
  199. * The state of the boot cpu's mtrrs has been saved, and we want
  200. * to replicate across all the APs.
  201. * If we're doing that @reg is set to something special...
  202. */
  203. if (reg != ~0U)
  204. mtrr_if->set(reg,base,size,type);
  205. /* wait for the others */
  206. while(atomic_read(&data.count))
  207. cpu_relax();
  208. atomic_set(&data.count, num_booting_cpus() - 1);
  209. atomic_set(&data.gate,0);
  210. /*
  211. * Wait here for everyone to have seen the gate change
  212. * So we're the last ones to touch 'data'
  213. */
  214. while(atomic_read(&data.count))
  215. cpu_relax();
  216. local_irq_restore(flags);
  217. }
  218. /**
  219. * mtrr_add_page - Add a memory type region
  220. * @base: Physical base address of region in pages (4 KB)
  221. * @size: Physical size of region in pages (4 KB)
  222. * @type: Type of MTRR desired
  223. * @increment: If this is true do usage counting on the region
  224. *
  225. * Memory type region registers control the caching on newer Intel and
  226. * non Intel processors. This function allows drivers to request an
  227. * MTRR is added. The details and hardware specifics of each processor's
  228. * implementation are hidden from the caller, but nevertheless the
  229. * caller should expect to need to provide a power of two size on an
  230. * equivalent power of two boundary.
  231. *
  232. * If the region cannot be added either because all regions are in use
  233. * or the CPU cannot support it a negative value is returned. On success
  234. * the register number for this entry is returned, but should be treated
  235. * as a cookie only.
  236. *
  237. * On a multiprocessor machine the changes are made to all processors.
  238. * This is required on x86 by the Intel processors.
  239. *
  240. * The available types are
  241. *
  242. * %MTRR_TYPE_UNCACHABLE - No caching
  243. *
  244. * %MTRR_TYPE_WRBACK - Write data back in bursts whenever
  245. *
  246. * %MTRR_TYPE_WRCOMB - Write data back soon but allow bursts
  247. *
  248. * %MTRR_TYPE_WRTHROUGH - Cache reads but not writes
  249. *
  250. * BUGS: Needs a quiet flag for the cases where drivers do not mind
  251. * failures and do not wish system log messages to be sent.
  252. */
  253. int mtrr_add_page(unsigned long base, unsigned long size,
  254. unsigned int type, char increment)
  255. {
  256. int i;
  257. mtrr_type ltype;
  258. unsigned long lbase;
  259. unsigned int lsize;
  260. int error;
  261. if (!mtrr_if)
  262. return -ENXIO;
  263. if ((error = mtrr_if->validate_add_page(base,size,type)))
  264. return error;
  265. if (type >= MTRR_NUM_TYPES) {
  266. printk(KERN_WARNING "mtrr: type: %u invalid\n", type);
  267. return -EINVAL;
  268. }
  269. /* If the type is WC, check that this processor supports it */
  270. if ((type == MTRR_TYPE_WRCOMB) && !have_wrcomb()) {
  271. printk(KERN_WARNING
  272. "mtrr: your processor doesn't support write-combining\n");
  273. return -ENOSYS;
  274. }
  275. if (base & size_or_mask || size & size_or_mask) {
  276. printk(KERN_WARNING "mtrr: base or size exceeds the MTRR width\n");
  277. return -EINVAL;
  278. }
  279. error = -EINVAL;
  280. /* Search for existing MTRR */
  281. down(&main_lock);
  282. for (i = 0; i < num_var_ranges; ++i) {
  283. mtrr_if->get(i, &lbase, &lsize, &ltype);
  284. if (base >= lbase + lsize)
  285. continue;
  286. if ((base < lbase) && (base + size <= lbase))
  287. continue;
  288. /* At this point we know there is some kind of overlap/enclosure */
  289. if ((base < lbase) || (base + size > lbase + lsize)) {
  290. printk(KERN_WARNING
  291. "mtrr: 0x%lx000,0x%lx000 overlaps existing"
  292. " 0x%lx000,0x%x000\n", base, size, lbase,
  293. lsize);
  294. goto out;
  295. }
  296. /* New region is enclosed by an existing region */
  297. if (ltype != type) {
  298. if (type == MTRR_TYPE_UNCACHABLE)
  299. continue;
  300. printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
  301. base, size, mtrr_attrib_to_str(ltype),
  302. mtrr_attrib_to_str(type));
  303. goto out;
  304. }
  305. if (increment)
  306. ++usage_table[i];
  307. error = i;
  308. goto out;
  309. }
  310. /* Search for an empty MTRR */
  311. i = mtrr_if->get_free_region(base, size);
  312. if (i >= 0) {
  313. set_mtrr(i, base, size, type);
  314. usage_table[i] = 1;
  315. } else
  316. printk(KERN_INFO "mtrr: no more MTRRs available\n");
  317. error = i;
  318. out:
  319. up(&main_lock);
  320. return error;
  321. }
  322. /**
  323. * mtrr_add - Add a memory type region
  324. * @base: Physical base address of region
  325. * @size: Physical size of region
  326. * @type: Type of MTRR desired
  327. * @increment: If this is true do usage counting on the region
  328. *
  329. * Memory type region registers control the caching on newer Intel and
  330. * non Intel processors. This function allows drivers to request an
  331. * MTRR is added. The details and hardware specifics of each processor's
  332. * implementation are hidden from the caller, but nevertheless the
  333. * caller should expect to need to provide a power of two size on an
  334. * equivalent power of two boundary.
  335. *
  336. * If the region cannot be added either because all regions are in use
  337. * or the CPU cannot support it a negative value is returned. On success
  338. * the register number for this entry is returned, but should be treated
  339. * as a cookie only.
  340. *
  341. * On a multiprocessor machine the changes are made to all processors.
  342. * This is required on x86 by the Intel processors.
  343. *
  344. * The available types are
  345. *
  346. * %MTRR_TYPE_UNCACHABLE - No caching
  347. *
  348. * %MTRR_TYPE_WRBACK - Write data back in bursts whenever
  349. *
  350. * %MTRR_TYPE_WRCOMB - Write data back soon but allow bursts
  351. *
  352. * %MTRR_TYPE_WRTHROUGH - Cache reads but not writes
  353. *
  354. * BUGS: Needs a quiet flag for the cases where drivers do not mind
  355. * failures and do not wish system log messages to be sent.
  356. */
  357. int
  358. mtrr_add(unsigned long base, unsigned long size, unsigned int type,
  359. char increment)
  360. {
  361. if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
  362. printk(KERN_WARNING "mtrr: size and base must be multiples of 4 kiB\n");
  363. printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
  364. return -EINVAL;
  365. }
  366. return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
  367. increment);
  368. }
  369. /**
  370. * mtrr_del_page - delete a memory type region
  371. * @reg: Register returned by mtrr_add
  372. * @base: Physical base address
  373. * @size: Size of region
  374. *
  375. * If register is supplied then base and size are ignored. This is
  376. * how drivers should call it.
  377. *
  378. * Releases an MTRR region. If the usage count drops to zero the
  379. * register is freed and the region returns to default state.
  380. * On success the register is returned, on failure a negative error
  381. * code.
  382. */
  383. int mtrr_del_page(int reg, unsigned long base, unsigned long size)
  384. {
  385. int i, max;
  386. mtrr_type ltype;
  387. unsigned long lbase;
  388. unsigned int lsize;
  389. int error = -EINVAL;
  390. if (!mtrr_if)
  391. return -ENXIO;
  392. max = num_var_ranges;
  393. down(&main_lock);
  394. if (reg < 0) {
  395. /* Search for existing MTRR */
  396. for (i = 0; i < max; ++i) {
  397. mtrr_if->get(i, &lbase, &lsize, &ltype);
  398. if (lbase == base && lsize == size) {
  399. reg = i;
  400. break;
  401. }
  402. }
  403. if (reg < 0) {
  404. printk(KERN_DEBUG "mtrr: no MTRR for %lx000,%lx000 found\n", base,
  405. size);
  406. goto out;
  407. }
  408. }
  409. if (reg >= max) {
  410. printk(KERN_WARNING "mtrr: register: %d too big\n", reg);
  411. goto out;
  412. }
  413. if (is_cpu(CYRIX) && !use_intel()) {
  414. if ((reg == 3) && arr3_protected) {
  415. printk(KERN_WARNING "mtrr: ARR3 cannot be changed\n");
  416. goto out;
  417. }
  418. }
  419. mtrr_if->get(reg, &lbase, &lsize, &ltype);
  420. if (lsize < 1) {
  421. printk(KERN_WARNING "mtrr: MTRR %d not used\n", reg);
  422. goto out;
  423. }
  424. if (usage_table[reg] < 1) {
  425. printk(KERN_WARNING "mtrr: reg: %d has count=0\n", reg);
  426. goto out;
  427. }
  428. if (--usage_table[reg] < 1)
  429. set_mtrr(reg, 0, 0, 0);
  430. error = reg;
  431. out:
  432. up(&main_lock);
  433. return error;
  434. }
  435. /**
  436. * mtrr_del - delete a memory type region
  437. * @reg: Register returned by mtrr_add
  438. * @base: Physical base address
  439. * @size: Size of region
  440. *
  441. * If register is supplied then base and size are ignored. This is
  442. * how drivers should call it.
  443. *
  444. * Releases an MTRR region. If the usage count drops to zero the
  445. * register is freed and the region returns to default state.
  446. * On success the register is returned, on failure a negative error
  447. * code.
  448. */
  449. int
  450. mtrr_del(int reg, unsigned long base, unsigned long size)
  451. {
  452. if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
  453. printk(KERN_INFO "mtrr: size and base must be multiples of 4 kiB\n");
  454. printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
  455. return -EINVAL;
  456. }
  457. return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
  458. }
  459. EXPORT_SYMBOL(mtrr_add);
  460. EXPORT_SYMBOL(mtrr_del);
  461. /* HACK ALERT!
  462. * These should be called implicitly, but we can't yet until all the initcall
  463. * stuff is done...
  464. */
  465. extern void amd_init_mtrr(void);
  466. extern void cyrix_init_mtrr(void);
  467. extern void centaur_init_mtrr(void);
  468. static void __init init_ifs(void)
  469. {
  470. amd_init_mtrr();
  471. cyrix_init_mtrr();
  472. centaur_init_mtrr();
  473. }
  474. static void __init init_other_cpus(void)
  475. {
  476. if (use_intel())
  477. get_mtrr_state();
  478. /* bring up the other processors */
  479. set_mtrr(~0U,0,0,0);
  480. if (use_intel()) {
  481. finalize_mtrr_state();
  482. mtrr_state_warn();
  483. }
  484. }
  485. struct mtrr_value {
  486. mtrr_type ltype;
  487. unsigned long lbase;
  488. unsigned int lsize;
  489. };
  490. static struct mtrr_value * mtrr_state;
  491. static int mtrr_save(struct sys_device * sysdev, u32 state)
  492. {
  493. int i;
  494. int size = num_var_ranges * sizeof(struct mtrr_value);
  495. mtrr_state = kmalloc(size,GFP_ATOMIC);
  496. if (mtrr_state)
  497. memset(mtrr_state,0,size);
  498. else
  499. return -ENOMEM;
  500. for (i = 0; i < num_var_ranges; i++) {
  501. mtrr_if->get(i,
  502. &mtrr_state[i].lbase,
  503. &mtrr_state[i].lsize,
  504. &mtrr_state[i].ltype);
  505. }
  506. return 0;
  507. }
  508. static int mtrr_restore(struct sys_device * sysdev)
  509. {
  510. int i;
  511. for (i = 0; i < num_var_ranges; i++) {
  512. if (mtrr_state[i].lsize)
  513. set_mtrr(i,
  514. mtrr_state[i].lbase,
  515. mtrr_state[i].lsize,
  516. mtrr_state[i].ltype);
  517. }
  518. kfree(mtrr_state);
  519. return 0;
  520. }
  521. static struct sysdev_driver mtrr_sysdev_driver = {
  522. .suspend = mtrr_save,
  523. .resume = mtrr_restore,
  524. };
  525. /**
  526. * mtrr_init - initialize mtrrs on the boot CPU
  527. *
  528. * This needs to be called early; before any of the other CPUs are
  529. * initialized (i.e. before smp_init()).
  530. *
  531. */
  532. static int __init mtrr_init(void)
  533. {
  534. init_ifs();
  535. if (cpu_has_mtrr) {
  536. mtrr_if = &generic_mtrr_ops;
  537. size_or_mask = 0xff000000; /* 36 bits */
  538. size_and_mask = 0x00f00000;
  539. /* This is an AMD specific MSR, but we assume(hope?) that
  540. Intel will implement it to when they extend the address
  541. bus of the Xeon. */
  542. if (cpuid_eax(0x80000000) >= 0x80000008) {
  543. u32 phys_addr;
  544. phys_addr = cpuid_eax(0x80000008) & 0xff;
  545. size_or_mask = ~((1 << (phys_addr - PAGE_SHIFT)) - 1);
  546. size_and_mask = ~size_or_mask & 0xfff00000;
  547. } else if (boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR &&
  548. boot_cpu_data.x86 == 6) {
  549. /* VIA C* family have Intel style MTRRs, but
  550. don't support PAE */
  551. size_or_mask = 0xfff00000; /* 32 bits */
  552. size_and_mask = 0;
  553. }
  554. } else {
  555. switch (boot_cpu_data.x86_vendor) {
  556. case X86_VENDOR_AMD:
  557. if (cpu_has_k6_mtrr) {
  558. /* Pre-Athlon (K6) AMD CPU MTRRs */
  559. mtrr_if = mtrr_ops[X86_VENDOR_AMD];
  560. size_or_mask = 0xfff00000; /* 32 bits */
  561. size_and_mask = 0;
  562. }
  563. break;
  564. case X86_VENDOR_CENTAUR:
  565. if (cpu_has_centaur_mcr) {
  566. mtrr_if = mtrr_ops[X86_VENDOR_CENTAUR];
  567. size_or_mask = 0xfff00000; /* 32 bits */
  568. size_and_mask = 0;
  569. }
  570. break;
  571. case X86_VENDOR_CYRIX:
  572. if (cpu_has_cyrix_arr) {
  573. mtrr_if = mtrr_ops[X86_VENDOR_CYRIX];
  574. size_or_mask = 0xfff00000; /* 32 bits */
  575. size_and_mask = 0;
  576. }
  577. break;
  578. default:
  579. break;
  580. }
  581. }
  582. printk(KERN_INFO "mtrr: v%s\n",MTRR_VERSION);
  583. if (mtrr_if) {
  584. set_num_var_ranges();
  585. init_table();
  586. init_other_cpus();
  587. return sysdev_driver_register(&cpu_sysdev_class,
  588. &mtrr_sysdev_driver);
  589. }
  590. return -ENXIO;
  591. }
  592. subsys_initcall(mtrr_init);