setup.c 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  1. /*
  2. * linux/arch/x86-64/kernel/setup.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. *
  6. * Nov 2001 Dave Jones <davej@suse.de>
  7. * Forked from i386 setup code.
  8. *
  9. * $Id$
  10. */
  11. /*
  12. * This file handles the architecture-dependent parts of initialization
  13. */
  14. #include <linux/errno.h>
  15. #include <linux/sched.h>
  16. #include <linux/kernel.h>
  17. #include <linux/mm.h>
  18. #include <linux/stddef.h>
  19. #include <linux/unistd.h>
  20. #include <linux/ptrace.h>
  21. #include <linux/slab.h>
  22. #include <linux/user.h>
  23. #include <linux/a.out.h>
  24. #include <linux/tty.h>
  25. #include <linux/ioport.h>
  26. #include <linux/delay.h>
  27. #include <linux/config.h>
  28. #include <linux/init.h>
  29. #include <linux/initrd.h>
  30. #include <linux/highmem.h>
  31. #include <linux/bootmem.h>
  32. #include <linux/module.h>
  33. #include <asm/processor.h>
  34. #include <linux/console.h>
  35. #include <linux/seq_file.h>
  36. #include <linux/crash_dump.h>
  37. #include <linux/root_dev.h>
  38. #include <linux/pci.h>
  39. #include <linux/acpi.h>
  40. #include <linux/kallsyms.h>
  41. #include <linux/edd.h>
  42. #include <linux/mmzone.h>
  43. #include <linux/kexec.h>
  44. #include <linux/cpufreq.h>
  45. #include <linux/dmi.h>
  46. #include <linux/dma-mapping.h>
  47. #include <asm/mtrr.h>
  48. #include <asm/uaccess.h>
  49. #include <asm/system.h>
  50. #include <asm/io.h>
  51. #include <asm/smp.h>
  52. #include <asm/msr.h>
  53. #include <asm/desc.h>
  54. #include <video/edid.h>
  55. #include <asm/e820.h>
  56. #include <asm/dma.h>
  57. #include <asm/mpspec.h>
  58. #include <asm/mmu_context.h>
  59. #include <asm/bootsetup.h>
  60. #include <asm/proto.h>
  61. #include <asm/setup.h>
  62. #include <asm/mach_apic.h>
  63. #include <asm/numa.h>
  64. #include <asm/swiotlb.h>
  65. #include <asm/sections.h>
  66. #include <asm/gart-mapping.h>
  67. /*
  68. * Machine setup..
  69. */
  70. struct cpuinfo_x86 boot_cpu_data __read_mostly;
  71. unsigned long mmu_cr4_features;
  72. int acpi_disabled;
  73. EXPORT_SYMBOL(acpi_disabled);
  74. #ifdef CONFIG_ACPI
  75. extern int __initdata acpi_ht;
  76. extern acpi_interrupt_flags acpi_sci_flags;
  77. int __initdata acpi_force = 0;
  78. #endif
  79. int acpi_numa __initdata;
  80. /* Boot loader ID as an integer, for the benefit of proc_dointvec */
  81. int bootloader_type;
  82. unsigned long saved_video_mode;
  83. /*
  84. * Setup options
  85. */
  86. struct drive_info_struct { char dummy[32]; } drive_info;
  87. struct screen_info screen_info;
  88. struct sys_desc_table_struct {
  89. unsigned short length;
  90. unsigned char table[0];
  91. };
  92. struct edid_info edid_info;
  93. struct e820map e820;
  94. extern int root_mountflags;
  95. char command_line[COMMAND_LINE_SIZE];
  96. struct resource standard_io_resources[] = {
  97. { .name = "dma1", .start = 0x00, .end = 0x1f,
  98. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  99. { .name = "pic1", .start = 0x20, .end = 0x21,
  100. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  101. { .name = "timer0", .start = 0x40, .end = 0x43,
  102. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  103. { .name = "timer1", .start = 0x50, .end = 0x53,
  104. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  105. { .name = "keyboard", .start = 0x60, .end = 0x6f,
  106. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  107. { .name = "dma page reg", .start = 0x80, .end = 0x8f,
  108. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  109. { .name = "pic2", .start = 0xa0, .end = 0xa1,
  110. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  111. { .name = "dma2", .start = 0xc0, .end = 0xdf,
  112. .flags = IORESOURCE_BUSY | IORESOURCE_IO },
  113. { .name = "fpu", .start = 0xf0, .end = 0xff,
  114. .flags = IORESOURCE_BUSY | IORESOURCE_IO }
  115. };
  116. #define STANDARD_IO_RESOURCES \
  117. (sizeof standard_io_resources / sizeof standard_io_resources[0])
  118. #define IORESOURCE_RAM (IORESOURCE_BUSY | IORESOURCE_MEM)
  119. struct resource data_resource = {
  120. .name = "Kernel data",
  121. .start = 0,
  122. .end = 0,
  123. .flags = IORESOURCE_RAM,
  124. };
  125. struct resource code_resource = {
  126. .name = "Kernel code",
  127. .start = 0,
  128. .end = 0,
  129. .flags = IORESOURCE_RAM,
  130. };
  131. #define IORESOURCE_ROM (IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM)
  132. static struct resource system_rom_resource = {
  133. .name = "System ROM",
  134. .start = 0xf0000,
  135. .end = 0xfffff,
  136. .flags = IORESOURCE_ROM,
  137. };
  138. static struct resource extension_rom_resource = {
  139. .name = "Extension ROM",
  140. .start = 0xe0000,
  141. .end = 0xeffff,
  142. .flags = IORESOURCE_ROM,
  143. };
  144. static struct resource adapter_rom_resources[] = {
  145. { .name = "Adapter ROM", .start = 0xc8000, .end = 0,
  146. .flags = IORESOURCE_ROM },
  147. { .name = "Adapter ROM", .start = 0, .end = 0,
  148. .flags = IORESOURCE_ROM },
  149. { .name = "Adapter ROM", .start = 0, .end = 0,
  150. .flags = IORESOURCE_ROM },
  151. { .name = "Adapter ROM", .start = 0, .end = 0,
  152. .flags = IORESOURCE_ROM },
  153. { .name = "Adapter ROM", .start = 0, .end = 0,
  154. .flags = IORESOURCE_ROM },
  155. { .name = "Adapter ROM", .start = 0, .end = 0,
  156. .flags = IORESOURCE_ROM }
  157. };
  158. #define ADAPTER_ROM_RESOURCES \
  159. (sizeof adapter_rom_resources / sizeof adapter_rom_resources[0])
  160. static struct resource video_rom_resource = {
  161. .name = "Video ROM",
  162. .start = 0xc0000,
  163. .end = 0xc7fff,
  164. .flags = IORESOURCE_ROM,
  165. };
  166. static struct resource video_ram_resource = {
  167. .name = "Video RAM area",
  168. .start = 0xa0000,
  169. .end = 0xbffff,
  170. .flags = IORESOURCE_RAM,
  171. };
  172. #define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
  173. static int __init romchecksum(unsigned char *rom, unsigned long length)
  174. {
  175. unsigned char *p, sum = 0;
  176. for (p = rom; p < rom + length; p++)
  177. sum += *p;
  178. return sum == 0;
  179. }
  180. static void __init probe_roms(void)
  181. {
  182. unsigned long start, length, upper;
  183. unsigned char *rom;
  184. int i;
  185. /* video rom */
  186. upper = adapter_rom_resources[0].start;
  187. for (start = video_rom_resource.start; start < upper; start += 2048) {
  188. rom = isa_bus_to_virt(start);
  189. if (!romsignature(rom))
  190. continue;
  191. video_rom_resource.start = start;
  192. /* 0 < length <= 0x7f * 512, historically */
  193. length = rom[2] * 512;
  194. /* if checksum okay, trust length byte */
  195. if (length && romchecksum(rom, length))
  196. video_rom_resource.end = start + length - 1;
  197. request_resource(&iomem_resource, &video_rom_resource);
  198. break;
  199. }
  200. start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
  201. if (start < upper)
  202. start = upper;
  203. /* system rom */
  204. request_resource(&iomem_resource, &system_rom_resource);
  205. upper = system_rom_resource.start;
  206. /* check for extension rom (ignore length byte!) */
  207. rom = isa_bus_to_virt(extension_rom_resource.start);
  208. if (romsignature(rom)) {
  209. length = extension_rom_resource.end - extension_rom_resource.start + 1;
  210. if (romchecksum(rom, length)) {
  211. request_resource(&iomem_resource, &extension_rom_resource);
  212. upper = extension_rom_resource.start;
  213. }
  214. }
  215. /* check for adapter roms on 2k boundaries */
  216. for (i = 0; i < ADAPTER_ROM_RESOURCES && start < upper; start += 2048) {
  217. rom = isa_bus_to_virt(start);
  218. if (!romsignature(rom))
  219. continue;
  220. /* 0 < length <= 0x7f * 512, historically */
  221. length = rom[2] * 512;
  222. /* but accept any length that fits if checksum okay */
  223. if (!length || start + length > upper || !romchecksum(rom, length))
  224. continue;
  225. adapter_rom_resources[i].start = start;
  226. adapter_rom_resources[i].end = start + length - 1;
  227. request_resource(&iomem_resource, &adapter_rom_resources[i]);
  228. start = adapter_rom_resources[i++].end & ~2047UL;
  229. }
  230. }
  231. static __init void parse_cmdline_early (char ** cmdline_p)
  232. {
  233. char c = ' ', *to = command_line, *from = COMMAND_LINE;
  234. int len = 0;
  235. int userdef = 0;
  236. for (;;) {
  237. if (c != ' ')
  238. goto next_char;
  239. #ifdef CONFIG_SMP
  240. /*
  241. * If the BIOS enumerates physical processors before logical,
  242. * maxcpus=N at enumeration-time can be used to disable HT.
  243. */
  244. else if (!memcmp(from, "maxcpus=", 8)) {
  245. extern unsigned int maxcpus;
  246. maxcpus = simple_strtoul(from + 8, NULL, 0);
  247. }
  248. #endif
  249. #ifdef CONFIG_ACPI
  250. /* "acpi=off" disables both ACPI table parsing and interpreter init */
  251. if (!memcmp(from, "acpi=off", 8))
  252. disable_acpi();
  253. if (!memcmp(from, "acpi=force", 10)) {
  254. /* add later when we do DMI horrors: */
  255. acpi_force = 1;
  256. acpi_disabled = 0;
  257. }
  258. /* acpi=ht just means: do ACPI MADT parsing
  259. at bootup, but don't enable the full ACPI interpreter */
  260. if (!memcmp(from, "acpi=ht", 7)) {
  261. if (!acpi_force)
  262. disable_acpi();
  263. acpi_ht = 1;
  264. }
  265. else if (!memcmp(from, "pci=noacpi", 10))
  266. acpi_disable_pci();
  267. else if (!memcmp(from, "acpi=noirq", 10))
  268. acpi_noirq_set();
  269. else if (!memcmp(from, "acpi_sci=edge", 13))
  270. acpi_sci_flags.trigger = 1;
  271. else if (!memcmp(from, "acpi_sci=level", 14))
  272. acpi_sci_flags.trigger = 3;
  273. else if (!memcmp(from, "acpi_sci=high", 13))
  274. acpi_sci_flags.polarity = 1;
  275. else if (!memcmp(from, "acpi_sci=low", 12))
  276. acpi_sci_flags.polarity = 3;
  277. /* acpi=strict disables out-of-spec workarounds */
  278. else if (!memcmp(from, "acpi=strict", 11)) {
  279. acpi_strict = 1;
  280. }
  281. #ifdef CONFIG_X86_IO_APIC
  282. else if (!memcmp(from, "acpi_skip_timer_override", 24))
  283. acpi_skip_timer_override = 1;
  284. #endif
  285. #endif
  286. if (!memcmp(from, "disable_timer_pin_1", 19))
  287. disable_timer_pin_1 = 1;
  288. if (!memcmp(from, "enable_timer_pin_1", 18))
  289. disable_timer_pin_1 = -1;
  290. if (!memcmp(from, "nolapic", 7) ||
  291. !memcmp(from, "disableapic", 11))
  292. disable_apic = 1;
  293. /* Don't confuse with noapictimer */
  294. if (!memcmp(from, "noapic", 6) &&
  295. (from[6] == ' ' || from[6] == 0))
  296. skip_ioapic_setup = 1;
  297. /* Make sure to not confuse with apic= */
  298. if (!memcmp(from, "apic", 4) &&
  299. (from[4] == ' ' || from[4] == 0)) {
  300. skip_ioapic_setup = 0;
  301. ioapic_force = 1;
  302. }
  303. if (!memcmp(from, "mem=", 4))
  304. parse_memopt(from+4, &from);
  305. if (!memcmp(from, "memmap=", 7)) {
  306. /* exactmap option is for used defined memory */
  307. if (!memcmp(from+7, "exactmap", 8)) {
  308. #ifdef CONFIG_CRASH_DUMP
  309. /* If we are doing a crash dump, we
  310. * still need to know the real mem
  311. * size before original memory map is
  312. * reset.
  313. */
  314. saved_max_pfn = e820_end_of_ram();
  315. #endif
  316. from += 8+7;
  317. end_pfn_map = 0;
  318. e820.nr_map = 0;
  319. userdef = 1;
  320. }
  321. else {
  322. parse_memmapopt(from+7, &from);
  323. userdef = 1;
  324. }
  325. }
  326. #ifdef CONFIG_NUMA
  327. if (!memcmp(from, "numa=", 5))
  328. numa_setup(from+5);
  329. #endif
  330. if (!memcmp(from,"iommu=",6)) {
  331. iommu_setup(from+6);
  332. }
  333. if (!memcmp(from,"oops=panic", 10))
  334. panic_on_oops = 1;
  335. if (!memcmp(from, "noexec=", 7))
  336. nonx_setup(from + 7);
  337. #ifdef CONFIG_KEXEC
  338. /* crashkernel=size@addr specifies the location to reserve for
  339. * a crash kernel. By reserving this memory we guarantee
  340. * that linux never set's it up as a DMA target.
  341. * Useful for holding code to do something appropriate
  342. * after a kernel panic.
  343. */
  344. else if (!memcmp(from, "crashkernel=", 12)) {
  345. unsigned long size, base;
  346. size = memparse(from+12, &from);
  347. if (*from == '@') {
  348. base = memparse(from+1, &from);
  349. /* FIXME: Do I want a sanity check
  350. * to validate the memory range?
  351. */
  352. crashk_res.start = base;
  353. crashk_res.end = base + size - 1;
  354. }
  355. }
  356. #endif
  357. #ifdef CONFIG_PROC_VMCORE
  358. /* elfcorehdr= specifies the location of elf core header
  359. * stored by the crashed kernel. This option will be passed
  360. * by kexec loader to the capture kernel.
  361. */
  362. else if(!memcmp(from, "elfcorehdr=", 11))
  363. elfcorehdr_addr = memparse(from+11, &from);
  364. #endif
  365. next_char:
  366. c = *(from++);
  367. if (!c)
  368. break;
  369. if (COMMAND_LINE_SIZE <= ++len)
  370. break;
  371. *(to++) = c;
  372. }
  373. if (userdef) {
  374. printk(KERN_INFO "user-defined physical RAM map:\n");
  375. e820_print_map("user");
  376. }
  377. *to = '\0';
  378. *cmdline_p = command_line;
  379. }
  380. #ifndef CONFIG_NUMA
  381. static void __init
  382. contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
  383. {
  384. unsigned long bootmap_size, bootmap;
  385. bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
  386. bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size);
  387. if (bootmap == -1L)
  388. panic("Cannot find bootmem map of size %ld\n",bootmap_size);
  389. bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn);
  390. e820_bootmem_free(NODE_DATA(0), 0, end_pfn << PAGE_SHIFT);
  391. reserve_bootmem(bootmap, bootmap_size);
  392. }
  393. #endif
  394. /* Use inline assembly to define this because the nops are defined
  395. as inline assembly strings in the include files and we cannot
  396. get them easily into strings. */
  397. asm("\t.data\nk8nops: "
  398. K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
  399. K8_NOP7 K8_NOP8);
  400. extern unsigned char k8nops[];
  401. static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
  402. NULL,
  403. k8nops,
  404. k8nops + 1,
  405. k8nops + 1 + 2,
  406. k8nops + 1 + 2 + 3,
  407. k8nops + 1 + 2 + 3 + 4,
  408. k8nops + 1 + 2 + 3 + 4 + 5,
  409. k8nops + 1 + 2 + 3 + 4 + 5 + 6,
  410. k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
  411. };
  412. extern char __vsyscall_0;
  413. /* Replace instructions with better alternatives for this CPU type.
  414. This runs before SMP is initialized to avoid SMP problems with
  415. self modifying code. This implies that assymetric systems where
  416. APs have less capabilities than the boot processor are not handled.
  417. In this case boot with "noreplacement". */
  418. void apply_alternatives(void *start, void *end)
  419. {
  420. struct alt_instr *a;
  421. int diff, i, k;
  422. for (a = start; (void *)a < end; a++) {
  423. u8 *instr;
  424. if (!boot_cpu_has(a->cpuid))
  425. continue;
  426. BUG_ON(a->replacementlen > a->instrlen);
  427. instr = a->instr;
  428. /* vsyscall code is not mapped yet. resolve it manually. */
  429. if (instr >= (u8 *)VSYSCALL_START && instr < (u8*)VSYSCALL_END)
  430. instr = __va(instr - (u8*)VSYSCALL_START + (u8*)__pa_symbol(&__vsyscall_0));
  431. __inline_memcpy(instr, a->replacement, a->replacementlen);
  432. diff = a->instrlen - a->replacementlen;
  433. /* Pad the rest with nops */
  434. for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
  435. k = diff;
  436. if (k > ASM_NOP_MAX)
  437. k = ASM_NOP_MAX;
  438. __inline_memcpy(instr + i, k8_nops[k], k);
  439. }
  440. }
  441. }
  442. static int no_replacement __initdata = 0;
  443. void __init alternative_instructions(void)
  444. {
  445. extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
  446. if (no_replacement)
  447. return;
  448. apply_alternatives(__alt_instructions, __alt_instructions_end);
  449. }
  450. static int __init noreplacement_setup(char *s)
  451. {
  452. no_replacement = 1;
  453. return 0;
  454. }
  455. __setup("noreplacement", noreplacement_setup);
  456. #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
  457. struct edd edd;
  458. #ifdef CONFIG_EDD_MODULE
  459. EXPORT_SYMBOL(edd);
  460. #endif
  461. /**
  462. * copy_edd() - Copy the BIOS EDD information
  463. * from boot_params into a safe place.
  464. *
  465. */
  466. static inline void copy_edd(void)
  467. {
  468. memcpy(edd.mbr_signature, EDD_MBR_SIGNATURE, sizeof(edd.mbr_signature));
  469. memcpy(edd.edd_info, EDD_BUF, sizeof(edd.edd_info));
  470. edd.mbr_signature_nr = EDD_MBR_SIG_NR;
  471. edd.edd_info_nr = EDD_NR;
  472. }
  473. #else
  474. static inline void copy_edd(void)
  475. {
  476. }
  477. #endif
  478. #define EBDA_ADDR_POINTER 0x40E
  479. static void __init reserve_ebda_region(void)
  480. {
  481. unsigned int addr;
  482. /**
  483. * there is a real-mode segmented pointer pointing to the
  484. * 4K EBDA area at 0x40E
  485. */
  486. addr = *(unsigned short *)phys_to_virt(EBDA_ADDR_POINTER);
  487. addr <<= 4;
  488. if (addr)
  489. reserve_bootmem_generic(addr, PAGE_SIZE);
  490. }
  491. void __init setup_arch(char **cmdline_p)
  492. {
  493. unsigned long kernel_end;
  494. ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
  495. drive_info = DRIVE_INFO;
  496. screen_info = SCREEN_INFO;
  497. edid_info = EDID_INFO;
  498. saved_video_mode = SAVED_VIDEO_MODE;
  499. bootloader_type = LOADER_TYPE;
  500. #ifdef CONFIG_BLK_DEV_RAM
  501. rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
  502. rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
  503. rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
  504. #endif
  505. setup_memory_region();
  506. copy_edd();
  507. if (!MOUNT_ROOT_RDONLY)
  508. root_mountflags &= ~MS_RDONLY;
  509. init_mm.start_code = (unsigned long) &_text;
  510. init_mm.end_code = (unsigned long) &_etext;
  511. init_mm.end_data = (unsigned long) &_edata;
  512. init_mm.brk = (unsigned long) &_end;
  513. code_resource.start = virt_to_phys(&_text);
  514. code_resource.end = virt_to_phys(&_etext)-1;
  515. data_resource.start = virt_to_phys(&_etext);
  516. data_resource.end = virt_to_phys(&_edata)-1;
  517. parse_cmdline_early(cmdline_p);
  518. early_identify_cpu(&boot_cpu_data);
  519. /*
  520. * partially used pages are not usable - thus
  521. * we are rounding upwards:
  522. */
  523. end_pfn = e820_end_of_ram();
  524. check_efer();
  525. init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
  526. zap_low_mappings(0);
  527. #ifdef CONFIG_ACPI
  528. /*
  529. * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
  530. * Call this early for SRAT node setup.
  531. */
  532. acpi_boot_table_init();
  533. #endif
  534. #ifdef CONFIG_ACPI_NUMA
  535. /*
  536. * Parse SRAT to discover nodes.
  537. */
  538. acpi_numa_init();
  539. #endif
  540. #ifdef CONFIG_NUMA
  541. numa_initmem_init(0, end_pfn);
  542. #else
  543. contig_initmem_init(0, end_pfn);
  544. #endif
  545. /* Reserve direct mapping */
  546. reserve_bootmem_generic(table_start << PAGE_SHIFT,
  547. (table_end - table_start) << PAGE_SHIFT);
  548. /* reserve kernel */
  549. kernel_end = round_up(__pa_symbol(&_end),PAGE_SIZE);
  550. reserve_bootmem_generic(HIGH_MEMORY, kernel_end - HIGH_MEMORY);
  551. /*
  552. * reserve physical page 0 - it's a special BIOS page on many boxes,
  553. * enabling clean reboots, SMP operation, laptop functions.
  554. */
  555. reserve_bootmem_generic(0, PAGE_SIZE);
  556. /* reserve ebda region */
  557. reserve_ebda_region();
  558. #ifdef CONFIG_SMP
  559. /*
  560. * But first pinch a few for the stack/trampoline stuff
  561. * FIXME: Don't need the extra page at 4K, but need to fix
  562. * trampoline before removing it. (see the GDT stuff)
  563. */
  564. reserve_bootmem_generic(PAGE_SIZE, PAGE_SIZE);
  565. /* Reserve SMP trampoline */
  566. reserve_bootmem_generic(SMP_TRAMPOLINE_BASE, PAGE_SIZE);
  567. #endif
  568. #ifdef CONFIG_ACPI_SLEEP
  569. /*
  570. * Reserve low memory region for sleep support.
  571. */
  572. acpi_reserve_bootmem();
  573. #endif
  574. #ifdef CONFIG_X86_LOCAL_APIC
  575. /*
  576. * Find and reserve possible boot-time SMP configuration:
  577. */
  578. find_smp_config();
  579. #endif
  580. #ifdef CONFIG_BLK_DEV_INITRD
  581. if (LOADER_TYPE && INITRD_START) {
  582. if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
  583. reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
  584. initrd_start =
  585. INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
  586. initrd_end = initrd_start+INITRD_SIZE;
  587. }
  588. else {
  589. printk(KERN_ERR "initrd extends beyond end of memory "
  590. "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
  591. (unsigned long)(INITRD_START + INITRD_SIZE),
  592. (unsigned long)(end_pfn << PAGE_SHIFT));
  593. initrd_start = 0;
  594. }
  595. }
  596. #endif
  597. #ifdef CONFIG_KEXEC
  598. if (crashk_res.start != crashk_res.end) {
  599. reserve_bootmem(crashk_res.start,
  600. crashk_res.end - crashk_res.start + 1);
  601. }
  602. #endif
  603. paging_init();
  604. check_ioapic();
  605. #ifdef CONFIG_ACPI
  606. /*
  607. * Read APIC and some other early information from ACPI tables.
  608. */
  609. acpi_boot_init();
  610. #endif
  611. init_cpu_to_node();
  612. #ifdef CONFIG_X86_LOCAL_APIC
  613. /*
  614. * get boot-time SMP configuration:
  615. */
  616. if (smp_found_config)
  617. get_smp_config();
  618. init_apic_mappings();
  619. #endif
  620. /*
  621. * Request address space for all standard RAM and ROM resources
  622. * and also for regions reported as reserved by the e820.
  623. */
  624. probe_roms();
  625. e820_reserve_resources();
  626. request_resource(&iomem_resource, &video_ram_resource);
  627. {
  628. unsigned i;
  629. /* request I/O space for devices used on all i[345]86 PCs */
  630. for (i = 0; i < STANDARD_IO_RESOURCES; i++)
  631. request_resource(&ioport_resource, &standard_io_resources[i]);
  632. }
  633. e820_setup_gap();
  634. #ifdef CONFIG_GART_IOMMU
  635. iommu_hole_init();
  636. #endif
  637. #ifdef CONFIG_VT
  638. #if defined(CONFIG_VGA_CONSOLE)
  639. conswitchp = &vga_con;
  640. #elif defined(CONFIG_DUMMY_CONSOLE)
  641. conswitchp = &dummy_con;
  642. #endif
  643. #endif
  644. }
  645. static int __cpuinit get_model_name(struct cpuinfo_x86 *c)
  646. {
  647. unsigned int *v;
  648. if (c->extended_cpuid_level < 0x80000004)
  649. return 0;
  650. v = (unsigned int *) c->x86_model_id;
  651. cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
  652. cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
  653. cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
  654. c->x86_model_id[48] = 0;
  655. return 1;
  656. }
  657. static void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
  658. {
  659. unsigned int n, dummy, eax, ebx, ecx, edx;
  660. n = c->extended_cpuid_level;
  661. if (n >= 0x80000005) {
  662. cpuid(0x80000005, &dummy, &ebx, &ecx, &edx);
  663. printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), D cache %dK (%d bytes/line)\n",
  664. edx>>24, edx&0xFF, ecx>>24, ecx&0xFF);
  665. c->x86_cache_size=(ecx>>24)+(edx>>24);
  666. /* On K8 L1 TLB is inclusive, so don't count it */
  667. c->x86_tlbsize = 0;
  668. }
  669. if (n >= 0x80000006) {
  670. cpuid(0x80000006, &dummy, &ebx, &ecx, &edx);
  671. ecx = cpuid_ecx(0x80000006);
  672. c->x86_cache_size = ecx >> 16;
  673. c->x86_tlbsize += ((ebx >> 16) & 0xfff) + (ebx & 0xfff);
  674. printk(KERN_INFO "CPU: L2 Cache: %dK (%d bytes/line)\n",
  675. c->x86_cache_size, ecx & 0xFF);
  676. }
  677. if (n >= 0x80000007)
  678. cpuid(0x80000007, &dummy, &dummy, &dummy, &c->x86_power);
  679. if (n >= 0x80000008) {
  680. cpuid(0x80000008, &eax, &dummy, &dummy, &dummy);
  681. c->x86_virt_bits = (eax >> 8) & 0xff;
  682. c->x86_phys_bits = eax & 0xff;
  683. }
  684. }
  685. #ifdef CONFIG_NUMA
  686. static int nearby_node(int apicid)
  687. {
  688. int i;
  689. for (i = apicid - 1; i >= 0; i--) {
  690. int node = apicid_to_node[i];
  691. if (node != NUMA_NO_NODE && node_online(node))
  692. return node;
  693. }
  694. for (i = apicid + 1; i < MAX_LOCAL_APIC; i++) {
  695. int node = apicid_to_node[i];
  696. if (node != NUMA_NO_NODE && node_online(node))
  697. return node;
  698. }
  699. return first_node(node_online_map); /* Shouldn't happen */
  700. }
  701. #endif
  702. /*
  703. * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
  704. * Assumes number of cores is a power of two.
  705. */
  706. static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
  707. {
  708. #ifdef CONFIG_SMP
  709. int cpu = smp_processor_id();
  710. unsigned bits;
  711. #ifdef CONFIG_NUMA
  712. int node = 0;
  713. unsigned apicid = phys_proc_id[cpu];
  714. #endif
  715. bits = 0;
  716. while ((1 << bits) < c->x86_max_cores)
  717. bits++;
  718. /* Low order bits define the core id (index of core in socket) */
  719. cpu_core_id[cpu] = phys_proc_id[cpu] & ((1 << bits)-1);
  720. /* Convert the APIC ID into the socket ID */
  721. phys_proc_id[cpu] >>= bits;
  722. #ifdef CONFIG_NUMA
  723. node = phys_proc_id[cpu];
  724. if (apicid_to_node[apicid] != NUMA_NO_NODE)
  725. node = apicid_to_node[apicid];
  726. if (!node_online(node)) {
  727. /* Two possibilities here:
  728. - The CPU is missing memory and no node was created.
  729. In that case try picking one from a nearby CPU
  730. - The APIC IDs differ from the HyperTransport node IDs
  731. which the K8 northbridge parsing fills in.
  732. Assume they are all increased by a constant offset,
  733. but in the same order as the HT nodeids.
  734. If that doesn't result in a usable node fall back to the
  735. path for the previous case. */
  736. int ht_nodeid = apicid - (phys_proc_id[0] << bits);
  737. if (ht_nodeid >= 0 &&
  738. apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
  739. node = apicid_to_node[ht_nodeid];
  740. /* Pick a nearby node */
  741. if (!node_online(node))
  742. node = nearby_node(apicid);
  743. }
  744. numa_set_node(cpu, node);
  745. printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",
  746. cpu, c->x86_max_cores, node, cpu_core_id[cpu]);
  747. #endif
  748. #endif
  749. }
  750. static int __init init_amd(struct cpuinfo_x86 *c)
  751. {
  752. int r;
  753. unsigned level;
  754. #ifdef CONFIG_SMP
  755. unsigned long value;
  756. /*
  757. * Disable TLB flush filter by setting HWCR.FFDIS on K8
  758. * bit 6 of msr C001_0015
  759. *
  760. * Errata 63 for SH-B3 steppings
  761. * Errata 122 for all steppings (F+ have it disabled by default)
  762. */
  763. if (c->x86 == 15) {
  764. rdmsrl(MSR_K8_HWCR, value);
  765. value |= 1 << 6;
  766. wrmsrl(MSR_K8_HWCR, value);
  767. }
  768. #endif
  769. /* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
  770. 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
  771. clear_bit(0*32+31, &c->x86_capability);
  772. /* On C+ stepping K8 rep microcode works well for copy/memset */
  773. level = cpuid_eax(1);
  774. if (c->x86 == 15 && ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58))
  775. set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
  776. r = get_model_name(c);
  777. if (!r) {
  778. switch (c->x86) {
  779. case 15:
  780. /* Should distinguish Models here, but this is only
  781. a fallback anyways. */
  782. strcpy(c->x86_model_id, "Hammer");
  783. break;
  784. }
  785. }
  786. display_cacheinfo(c);
  787. /* c->x86_power is 8000_0007 edx. Bit 8 is constant TSC */
  788. if (c->x86_power & (1<<8))
  789. set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
  790. if (c->extended_cpuid_level >= 0x80000008) {
  791. c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
  792. if (c->x86_max_cores & (c->x86_max_cores - 1))
  793. c->x86_max_cores = 1;
  794. amd_detect_cmp(c);
  795. }
  796. return r;
  797. }
  798. static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
  799. {
  800. #ifdef CONFIG_SMP
  801. u32 eax, ebx, ecx, edx;
  802. int index_msb, core_bits;
  803. int cpu = smp_processor_id();
  804. cpuid(1, &eax, &ebx, &ecx, &edx);
  805. c->apicid = phys_pkg_id(0);
  806. if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
  807. return;
  808. smp_num_siblings = (ebx & 0xff0000) >> 16;
  809. if (smp_num_siblings == 1) {
  810. printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
  811. } else if (smp_num_siblings > 1 ) {
  812. if (smp_num_siblings > NR_CPUS) {
  813. printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings);
  814. smp_num_siblings = 1;
  815. return;
  816. }
  817. index_msb = get_count_order(smp_num_siblings);
  818. phys_proc_id[cpu] = phys_pkg_id(index_msb);
  819. printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
  820. phys_proc_id[cpu]);
  821. smp_num_siblings = smp_num_siblings / c->x86_max_cores;
  822. index_msb = get_count_order(smp_num_siblings) ;
  823. core_bits = get_count_order(c->x86_max_cores);
  824. cpu_core_id[cpu] = phys_pkg_id(index_msb) &
  825. ((1 << core_bits) - 1);
  826. if (c->x86_max_cores > 1)
  827. printk(KERN_INFO "CPU: Processor Core ID: %d\n",
  828. cpu_core_id[cpu]);
  829. }
  830. #endif
  831. }
  832. /*
  833. * find out the number of processor cores on the die
  834. */
  835. static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
  836. {
  837. unsigned int eax;
  838. if (c->cpuid_level < 4)
  839. return 1;
  840. __asm__("cpuid"
  841. : "=a" (eax)
  842. : "0" (4), "c" (0)
  843. : "bx", "dx");
  844. if (eax & 0x1f)
  845. return ((eax >> 26) + 1);
  846. else
  847. return 1;
  848. }
  849. static void srat_detect_node(void)
  850. {
  851. #ifdef CONFIG_NUMA
  852. unsigned node;
  853. int cpu = smp_processor_id();
  854. /* Don't do the funky fallback heuristics the AMD version employs
  855. for now. */
  856. node = apicid_to_node[hard_smp_processor_id()];
  857. if (node == NUMA_NO_NODE)
  858. node = 0;
  859. numa_set_node(cpu, node);
  860. if (acpi_numa > 0)
  861. printk(KERN_INFO "CPU %d -> Node %d\n", cpu, node);
  862. #endif
  863. }
  864. static void __cpuinit init_intel(struct cpuinfo_x86 *c)
  865. {
  866. /* Cache sizes */
  867. unsigned n;
  868. init_intel_cacheinfo(c);
  869. n = c->extended_cpuid_level;
  870. if (n >= 0x80000008) {
  871. unsigned eax = cpuid_eax(0x80000008);
  872. c->x86_virt_bits = (eax >> 8) & 0xff;
  873. c->x86_phys_bits = eax & 0xff;
  874. /* CPUID workaround for Intel 0F34 CPU */
  875. if (c->x86_vendor == X86_VENDOR_INTEL &&
  876. c->x86 == 0xF && c->x86_model == 0x3 &&
  877. c->x86_mask == 0x4)
  878. c->x86_phys_bits = 36;
  879. }
  880. if (c->x86 == 15)
  881. c->x86_cache_alignment = c->x86_clflush_size * 2;
  882. if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
  883. (c->x86 == 0x6 && c->x86_model >= 0x0e))
  884. set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
  885. set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
  886. c->x86_max_cores = intel_num_cpu_cores(c);
  887. srat_detect_node();
  888. }
  889. static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
  890. {
  891. char *v = c->x86_vendor_id;
  892. if (!strcmp(v, "AuthenticAMD"))
  893. c->x86_vendor = X86_VENDOR_AMD;
  894. else if (!strcmp(v, "GenuineIntel"))
  895. c->x86_vendor = X86_VENDOR_INTEL;
  896. else
  897. c->x86_vendor = X86_VENDOR_UNKNOWN;
  898. }
  899. struct cpu_model_info {
  900. int vendor;
  901. int family;
  902. char *model_names[16];
  903. };
  904. /* Do some early cpuid on the boot CPU to get some parameter that are
  905. needed before check_bugs. Everything advanced is in identify_cpu
  906. below. */
  907. void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
  908. {
  909. u32 tfms;
  910. c->loops_per_jiffy = loops_per_jiffy;
  911. c->x86_cache_size = -1;
  912. c->x86_vendor = X86_VENDOR_UNKNOWN;
  913. c->x86_model = c->x86_mask = 0; /* So far unknown... */
  914. c->x86_vendor_id[0] = '\0'; /* Unset */
  915. c->x86_model_id[0] = '\0'; /* Unset */
  916. c->x86_clflush_size = 64;
  917. c->x86_cache_alignment = c->x86_clflush_size;
  918. c->x86_max_cores = 1;
  919. c->extended_cpuid_level = 0;
  920. memset(&c->x86_capability, 0, sizeof c->x86_capability);
  921. /* Get vendor name */
  922. cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
  923. (unsigned int *)&c->x86_vendor_id[0],
  924. (unsigned int *)&c->x86_vendor_id[8],
  925. (unsigned int *)&c->x86_vendor_id[4]);
  926. get_cpu_vendor(c);
  927. /* Initialize the standard set of capabilities */
  928. /* Note that the vendor-specific code below might override */
  929. /* Intel-defined flags: level 0x00000001 */
  930. if (c->cpuid_level >= 0x00000001) {
  931. __u32 misc;
  932. cpuid(0x00000001, &tfms, &misc, &c->x86_capability[4],
  933. &c->x86_capability[0]);
  934. c->x86 = (tfms >> 8) & 0xf;
  935. c->x86_model = (tfms >> 4) & 0xf;
  936. c->x86_mask = tfms & 0xf;
  937. if (c->x86 == 0xf)
  938. c->x86 += (tfms >> 20) & 0xff;
  939. if (c->x86 >= 0x6)
  940. c->x86_model += ((tfms >> 16) & 0xF) << 4;
  941. if (c->x86_capability[0] & (1<<19))
  942. c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
  943. } else {
  944. /* Have CPUID level 0 only - unheard of */
  945. c->x86 = 4;
  946. }
  947. #ifdef CONFIG_SMP
  948. phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
  949. #endif
  950. }
  951. /*
  952. * This does the hard work of actually picking apart the CPU stuff...
  953. */
  954. void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
  955. {
  956. int i;
  957. u32 xlvl;
  958. early_identify_cpu(c);
  959. /* AMD-defined flags: level 0x80000001 */
  960. xlvl = cpuid_eax(0x80000000);
  961. c->extended_cpuid_level = xlvl;
  962. if ((xlvl & 0xffff0000) == 0x80000000) {
  963. if (xlvl >= 0x80000001) {
  964. c->x86_capability[1] = cpuid_edx(0x80000001);
  965. c->x86_capability[6] = cpuid_ecx(0x80000001);
  966. }
  967. if (xlvl >= 0x80000004)
  968. get_model_name(c); /* Default name */
  969. }
  970. /* Transmeta-defined flags: level 0x80860001 */
  971. xlvl = cpuid_eax(0x80860000);
  972. if ((xlvl & 0xffff0000) == 0x80860000) {
  973. /* Don't set x86_cpuid_level here for now to not confuse. */
  974. if (xlvl >= 0x80860001)
  975. c->x86_capability[2] = cpuid_edx(0x80860001);
  976. }
  977. /*
  978. * Vendor-specific initialization. In this section we
  979. * canonicalize the feature flags, meaning if there are
  980. * features a certain CPU supports which CPUID doesn't
  981. * tell us, CPUID claiming incorrect flags, or other bugs,
  982. * we handle them here.
  983. *
  984. * At the end of this section, c->x86_capability better
  985. * indicate the features this CPU genuinely supports!
  986. */
  987. switch (c->x86_vendor) {
  988. case X86_VENDOR_AMD:
  989. init_amd(c);
  990. break;
  991. case X86_VENDOR_INTEL:
  992. init_intel(c);
  993. break;
  994. case X86_VENDOR_UNKNOWN:
  995. default:
  996. display_cacheinfo(c);
  997. break;
  998. }
  999. select_idle_routine(c);
  1000. detect_ht(c);
  1001. /*
  1002. * On SMP, boot_cpu_data holds the common feature set between
  1003. * all CPUs; so make sure that we indicate which features are
  1004. * common between the CPUs. The first time this routine gets
  1005. * executed, c == &boot_cpu_data.
  1006. */
  1007. if (c != &boot_cpu_data) {
  1008. /* AND the already accumulated flags with these */
  1009. for (i = 0 ; i < NCAPINTS ; i++)
  1010. boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
  1011. }
  1012. #ifdef CONFIG_X86_MCE
  1013. mcheck_init(c);
  1014. #endif
  1015. if (c == &boot_cpu_data)
  1016. mtrr_bp_init();
  1017. else
  1018. mtrr_ap_init();
  1019. #ifdef CONFIG_NUMA
  1020. numa_add_cpu(smp_processor_id());
  1021. #endif
  1022. }
  1023. void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
  1024. {
  1025. if (c->x86_model_id[0])
  1026. printk("%s", c->x86_model_id);
  1027. if (c->x86_mask || c->cpuid_level >= 0)
  1028. printk(" stepping %02x\n", c->x86_mask);
  1029. else
  1030. printk("\n");
  1031. }
  1032. /*
  1033. * Get CPU information for use by the procfs.
  1034. */
  1035. static int show_cpuinfo(struct seq_file *m, void *v)
  1036. {
  1037. struct cpuinfo_x86 *c = v;
  1038. /*
  1039. * These flag bits must match the definitions in <asm/cpufeature.h>.
  1040. * NULL means this bit is undefined or reserved; either way it doesn't
  1041. * have meaning as far as Linux is concerned. Note that it's important
  1042. * to realize there is a difference between this table and CPUID -- if
  1043. * applications want to get the raw CPUID data, they should access
  1044. * /dev/cpu/<cpu_nr>/cpuid instead.
  1045. */
  1046. static char *x86_cap_flags[] = {
  1047. /* Intel-defined */
  1048. "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
  1049. "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
  1050. "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
  1051. "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL,
  1052. /* AMD-defined */
  1053. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1054. NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
  1055. NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL,
  1056. NULL, "fxsr_opt", "rdtscp", NULL, NULL, "lm", "3dnowext", "3dnow",
  1057. /* Transmeta-defined */
  1058. "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
  1059. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1060. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1061. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1062. /* Other (Linux-defined) */
  1063. "cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
  1064. "constant_tsc", NULL, NULL,
  1065. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1066. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1067. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1068. /* Intel-defined (#2) */
  1069. "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", NULL, "est",
  1070. "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
  1071. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1072. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1073. /* VIA/Cyrix/Centaur-defined */
  1074. NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
  1075. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1076. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1077. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1078. /* AMD-defined (#2) */
  1079. "lahf_lm", "cmp_legacy", "svm", NULL, "cr8_legacy", NULL, NULL, NULL,
  1080. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1081. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1082. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1083. };
  1084. static char *x86_power_flags[] = {
  1085. "ts", /* temperature sensor */
  1086. "fid", /* frequency id control */
  1087. "vid", /* voltage id control */
  1088. "ttp", /* thermal trip */
  1089. "tm",
  1090. "stc",
  1091. NULL,
  1092. /* nothing */ /* constant_tsc - moved to flags */
  1093. };
  1094. #ifdef CONFIG_SMP
  1095. if (!cpu_online(c-cpu_data))
  1096. return 0;
  1097. #endif
  1098. seq_printf(m,"processor\t: %u\n"
  1099. "vendor_id\t: %s\n"
  1100. "cpu family\t: %d\n"
  1101. "model\t\t: %d\n"
  1102. "model name\t: %s\n",
  1103. (unsigned)(c-cpu_data),
  1104. c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
  1105. c->x86,
  1106. (int)c->x86_model,
  1107. c->x86_model_id[0] ? c->x86_model_id : "unknown");
  1108. if (c->x86_mask || c->cpuid_level >= 0)
  1109. seq_printf(m, "stepping\t: %d\n", c->x86_mask);
  1110. else
  1111. seq_printf(m, "stepping\t: unknown\n");
  1112. if (cpu_has(c,X86_FEATURE_TSC)) {
  1113. unsigned int freq = cpufreq_quick_get((unsigned)(c-cpu_data));
  1114. if (!freq)
  1115. freq = cpu_khz;
  1116. seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
  1117. freq / 1000, (freq % 1000));
  1118. }
  1119. /* Cache size */
  1120. if (c->x86_cache_size >= 0)
  1121. seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
  1122. #ifdef CONFIG_SMP
  1123. if (smp_num_siblings * c->x86_max_cores > 1) {
  1124. int cpu = c - cpu_data;
  1125. seq_printf(m, "physical id\t: %d\n", phys_proc_id[cpu]);
  1126. seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[cpu]));
  1127. seq_printf(m, "core id\t\t: %d\n", cpu_core_id[cpu]);
  1128. seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
  1129. }
  1130. #endif
  1131. seq_printf(m,
  1132. "fpu\t\t: yes\n"
  1133. "fpu_exception\t: yes\n"
  1134. "cpuid level\t: %d\n"
  1135. "wp\t\t: yes\n"
  1136. "flags\t\t:",
  1137. c->cpuid_level);
  1138. {
  1139. int i;
  1140. for ( i = 0 ; i < 32*NCAPINTS ; i++ )
  1141. if ( test_bit(i, &c->x86_capability) &&
  1142. x86_cap_flags[i] != NULL )
  1143. seq_printf(m, " %s", x86_cap_flags[i]);
  1144. }
  1145. seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
  1146. c->loops_per_jiffy/(500000/HZ),
  1147. (c->loops_per_jiffy/(5000/HZ)) % 100);
  1148. if (c->x86_tlbsize > 0)
  1149. seq_printf(m, "TLB size\t: %d 4K pages\n", c->x86_tlbsize);
  1150. seq_printf(m, "clflush size\t: %d\n", c->x86_clflush_size);
  1151. seq_printf(m, "cache_alignment\t: %d\n", c->x86_cache_alignment);
  1152. seq_printf(m, "address sizes\t: %u bits physical, %u bits virtual\n",
  1153. c->x86_phys_bits, c->x86_virt_bits);
  1154. seq_printf(m, "power management:");
  1155. {
  1156. unsigned i;
  1157. for (i = 0; i < 32; i++)
  1158. if (c->x86_power & (1 << i)) {
  1159. if (i < ARRAY_SIZE(x86_power_flags) &&
  1160. x86_power_flags[i])
  1161. seq_printf(m, "%s%s",
  1162. x86_power_flags[i][0]?" ":"",
  1163. x86_power_flags[i]);
  1164. else
  1165. seq_printf(m, " [%d]", i);
  1166. }
  1167. }
  1168. seq_printf(m, "\n\n");
  1169. return 0;
  1170. }
  1171. static void *c_start(struct seq_file *m, loff_t *pos)
  1172. {
  1173. return *pos < NR_CPUS ? cpu_data + *pos : NULL;
  1174. }
  1175. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  1176. {
  1177. ++*pos;
  1178. return c_start(m, pos);
  1179. }
  1180. static void c_stop(struct seq_file *m, void *v)
  1181. {
  1182. }
  1183. struct seq_operations cpuinfo_op = {
  1184. .start =c_start,
  1185. .next = c_next,
  1186. .stop = c_stop,
  1187. .show = show_cpuinfo,
  1188. };
  1189. static int __init run_dmi_scan(void)
  1190. {
  1191. dmi_scan_machine();
  1192. return 0;
  1193. }
  1194. core_initcall(run_dmi_scan);