setup.c 32 KB

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