setup.c 31 KB

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