setup.c 35 KB

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