setup.c 35 KB

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