setup.c 31 KB

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