setup.c 34 KB

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