boot.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  1. /*
  2. * boot.c - Architecture-Specific Low-Level ACPI Boot Support
  3. *
  4. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  5. * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. */
  25. #include <linux/init.h>
  26. #include <linux/config.h>
  27. #include <linux/acpi.h>
  28. #include <linux/efi.h>
  29. #include <linux/module.h>
  30. #include <linux/dmi.h>
  31. #include <linux/irq.h>
  32. #include <asm/pgtable.h>
  33. #include <asm/io_apic.h>
  34. #include <asm/apic.h>
  35. #include <asm/io.h>
  36. #include <asm/mpspec.h>
  37. #ifdef CONFIG_X86_64
  38. extern void __init clustered_apic_check(void);
  39. extern int gsi_irq_sharing(int gsi);
  40. #include <asm/proto.h>
  41. static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; }
  42. #else /* X86 */
  43. #ifdef CONFIG_X86_LOCAL_APIC
  44. #include <mach_apic.h>
  45. #include <mach_mpparse.h>
  46. #endif /* CONFIG_X86_LOCAL_APIC */
  47. static inline int gsi_irq_sharing(int gsi) { return gsi; }
  48. #endif /* X86 */
  49. #define BAD_MADT_ENTRY(entry, end) ( \
  50. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  51. ((acpi_table_entry_header *)entry)->length != sizeof(*entry))
  52. #define PREFIX "ACPI: "
  53. int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
  54. int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
  55. int acpi_ht __initdata = 1; /* enable HT */
  56. int acpi_lapic;
  57. int acpi_ioapic;
  58. int acpi_strict;
  59. EXPORT_SYMBOL(acpi_strict);
  60. acpi_interrupt_flags acpi_sci_flags __initdata;
  61. int acpi_sci_override_gsi __initdata;
  62. int acpi_skip_timer_override __initdata;
  63. #ifdef CONFIG_X86_LOCAL_APIC
  64. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  65. #endif
  66. #ifndef __HAVE_ARCH_CMPXCHG
  67. #warning ACPI uses CMPXCHG, i486 and later hardware
  68. #endif
  69. #define MAX_MADT_ENTRIES 256
  70. u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
  71. {[0 ... MAX_MADT_ENTRIES - 1] = 0xff };
  72. EXPORT_SYMBOL(x86_acpiid_to_apicid);
  73. /* --------------------------------------------------------------------------
  74. Boot-time Configuration
  75. -------------------------------------------------------------------------- */
  76. /*
  77. * The default interrupt routing model is PIC (8259). This gets
  78. * overriden if IOAPICs are enumerated (below).
  79. */
  80. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  81. #ifdef CONFIG_X86_64
  82. /* rely on all ACPI tables being in the direct mapping */
  83. char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
  84. {
  85. if (!phys_addr || !size)
  86. return NULL;
  87. if (phys_addr+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
  88. return __va(phys_addr);
  89. return NULL;
  90. }
  91. #else
  92. /*
  93. * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  94. * to map the target physical address. The problem is that set_fixmap()
  95. * provides a single page, and it is possible that the page is not
  96. * sufficient.
  97. * By using this area, we can map up to MAX_IO_APICS pages temporarily,
  98. * i.e. until the next __va_range() call.
  99. *
  100. * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
  101. * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
  102. * count idx down while incrementing the phys address.
  103. */
  104. char *__acpi_map_table(unsigned long phys, unsigned long size)
  105. {
  106. unsigned long base, offset, mapped_size;
  107. int idx;
  108. if (phys + size < 8 * 1024 * 1024)
  109. return __va(phys);
  110. offset = phys & (PAGE_SIZE - 1);
  111. mapped_size = PAGE_SIZE - offset;
  112. set_fixmap(FIX_ACPI_END, phys);
  113. base = fix_to_virt(FIX_ACPI_END);
  114. /*
  115. * Most cases can be covered by the below.
  116. */
  117. idx = FIX_ACPI_END;
  118. while (mapped_size < size) {
  119. if (--idx < FIX_ACPI_BEGIN)
  120. return NULL; /* cannot handle this */
  121. phys += PAGE_SIZE;
  122. set_fixmap(idx, phys);
  123. mapped_size += PAGE_SIZE;
  124. }
  125. return ((unsigned char *)base + offset);
  126. }
  127. #endif
  128. #ifdef CONFIG_PCI_MMCONFIG
  129. /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
  130. struct acpi_table_mcfg_config *pci_mmcfg_config;
  131. int pci_mmcfg_config_num;
  132. int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
  133. {
  134. struct acpi_table_mcfg *mcfg;
  135. unsigned long i;
  136. int config_size;
  137. if (!phys_addr || !size)
  138. return -EINVAL;
  139. mcfg = (struct acpi_table_mcfg *)__acpi_map_table(phys_addr, size);
  140. if (!mcfg) {
  141. printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
  142. return -ENODEV;
  143. }
  144. /* how many config structures do we have */
  145. pci_mmcfg_config_num = 0;
  146. i = size - sizeof(struct acpi_table_mcfg);
  147. while (i >= sizeof(struct acpi_table_mcfg_config)) {
  148. ++pci_mmcfg_config_num;
  149. i -= sizeof(struct acpi_table_mcfg_config);
  150. };
  151. if (pci_mmcfg_config_num == 0) {
  152. printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
  153. return -ENODEV;
  154. }
  155. config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
  156. pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
  157. if (!pci_mmcfg_config) {
  158. printk(KERN_WARNING PREFIX
  159. "No memory for MCFG config tables\n");
  160. return -ENOMEM;
  161. }
  162. memcpy(pci_mmcfg_config, &mcfg->config, config_size);
  163. for (i = 0; i < pci_mmcfg_config_num; ++i) {
  164. if (mcfg->config[i].base_reserved) {
  165. printk(KERN_ERR PREFIX
  166. "MMCONFIG not in low 4GB of memory\n");
  167. return -ENODEV;
  168. }
  169. }
  170. return 0;
  171. }
  172. #endif /* CONFIG_PCI_MMCONFIG */
  173. #ifdef CONFIG_X86_LOCAL_APIC
  174. static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
  175. {
  176. struct acpi_table_madt *madt = NULL;
  177. if (!phys_addr || !size || !cpu_has_apic)
  178. return -EINVAL;
  179. madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);
  180. if (!madt) {
  181. printk(KERN_WARNING PREFIX "Unable to map MADT\n");
  182. return -ENODEV;
  183. }
  184. if (madt->lapic_address) {
  185. acpi_lapic_addr = (u64) madt->lapic_address;
  186. printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
  187. madt->lapic_address);
  188. }
  189. acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
  190. return 0;
  191. }
  192. static int __init
  193. acpi_parse_lapic(acpi_table_entry_header * header, const unsigned long end)
  194. {
  195. struct acpi_table_lapic *processor = NULL;
  196. processor = (struct acpi_table_lapic *)header;
  197. if (BAD_MADT_ENTRY(processor, end))
  198. return -EINVAL;
  199. acpi_table_print_madt_entry(header);
  200. /* Record local apic id only when enabled */
  201. if (processor->flags.enabled)
  202. x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
  203. /*
  204. * We need to register disabled CPU as well to permit
  205. * counting disabled CPUs. This allows us to size
  206. * cpus_possible_map more accurately, to permit
  207. * to not preallocating memory for all NR_CPUS
  208. * when we use CPU hotplug.
  209. */
  210. mp_register_lapic(processor->id, /* APIC ID */
  211. processor->flags.enabled); /* Enabled? */
  212. return 0;
  213. }
  214. static int __init
  215. acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
  216. const unsigned long end)
  217. {
  218. struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
  219. lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr *)header;
  220. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  221. return -EINVAL;
  222. acpi_lapic_addr = lapic_addr_ovr->address;
  223. return 0;
  224. }
  225. static int __init
  226. acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
  227. {
  228. struct acpi_table_lapic_nmi *lapic_nmi = NULL;
  229. lapic_nmi = (struct acpi_table_lapic_nmi *)header;
  230. if (BAD_MADT_ENTRY(lapic_nmi, end))
  231. return -EINVAL;
  232. acpi_table_print_madt_entry(header);
  233. if (lapic_nmi->lint != 1)
  234. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  235. return 0;
  236. }
  237. #endif /*CONFIG_X86_LOCAL_APIC */
  238. #ifdef CONFIG_X86_IO_APIC
  239. static int __init
  240. acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
  241. {
  242. struct acpi_table_ioapic *ioapic = NULL;
  243. ioapic = (struct acpi_table_ioapic *)header;
  244. if (BAD_MADT_ENTRY(ioapic, end))
  245. return -EINVAL;
  246. acpi_table_print_madt_entry(header);
  247. mp_register_ioapic(ioapic->id,
  248. ioapic->address, ioapic->global_irq_base);
  249. return 0;
  250. }
  251. /*
  252. * Parse Interrupt Source Override for the ACPI SCI
  253. */
  254. static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  255. {
  256. if (trigger == 0) /* compatible SCI trigger is level */
  257. trigger = 3;
  258. if (polarity == 0) /* compatible SCI polarity is low */
  259. polarity = 3;
  260. /* Command-line over-ride via acpi_sci= */
  261. if (acpi_sci_flags.trigger)
  262. trigger = acpi_sci_flags.trigger;
  263. if (acpi_sci_flags.polarity)
  264. polarity = acpi_sci_flags.polarity;
  265. /*
  266. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  267. * If GSI is < 16, this will update its flags,
  268. * else it will create a new mp_irqs[] entry.
  269. */
  270. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  271. /*
  272. * stash over-ride to indicate we've been here
  273. * and for later update of acpi_fadt
  274. */
  275. acpi_sci_override_gsi = gsi;
  276. return;
  277. }
  278. static int __init
  279. acpi_parse_int_src_ovr(acpi_table_entry_header * header,
  280. const unsigned long end)
  281. {
  282. struct acpi_table_int_src_ovr *intsrc = NULL;
  283. intsrc = (struct acpi_table_int_src_ovr *)header;
  284. if (BAD_MADT_ENTRY(intsrc, end))
  285. return -EINVAL;
  286. acpi_table_print_madt_entry(header);
  287. if (intsrc->bus_irq == acpi_fadt.sci_int) {
  288. acpi_sci_ioapic_setup(intsrc->global_irq,
  289. intsrc->flags.polarity,
  290. intsrc->flags.trigger);
  291. return 0;
  292. }
  293. if (acpi_skip_timer_override &&
  294. intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
  295. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  296. return 0;
  297. }
  298. mp_override_legacy_irq(intsrc->bus_irq,
  299. intsrc->flags.polarity,
  300. intsrc->flags.trigger, intsrc->global_irq);
  301. return 0;
  302. }
  303. static int __init
  304. acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
  305. {
  306. struct acpi_table_nmi_src *nmi_src = NULL;
  307. nmi_src = (struct acpi_table_nmi_src *)header;
  308. if (BAD_MADT_ENTRY(nmi_src, end))
  309. return -EINVAL;
  310. acpi_table_print_madt_entry(header);
  311. /* TBD: Support nimsrc entries? */
  312. return 0;
  313. }
  314. #endif /* CONFIG_X86_IO_APIC */
  315. /*
  316. * acpi_pic_sci_set_trigger()
  317. *
  318. * use ELCR to set PIC-mode trigger type for SCI
  319. *
  320. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  321. * it may require Edge Trigger -- use "acpi_sci=edge"
  322. *
  323. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  324. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  325. * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
  326. * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
  327. */
  328. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  329. {
  330. unsigned int mask = 1 << irq;
  331. unsigned int old, new;
  332. /* Real old ELCR mask */
  333. old = inb(0x4d0) | (inb(0x4d1) << 8);
  334. /*
  335. * If we use ACPI to set PCI irq's, then we should clear ELCR
  336. * since we will set it correctly as we enable the PCI irq
  337. * routing.
  338. */
  339. new = acpi_noirq ? old : 0;
  340. /*
  341. * Update SCI information in the ELCR, it isn't in the PCI
  342. * routing tables..
  343. */
  344. switch (trigger) {
  345. case 1: /* Edge - clear */
  346. new &= ~mask;
  347. break;
  348. case 3: /* Level - set */
  349. new |= mask;
  350. break;
  351. }
  352. if (old == new)
  353. return;
  354. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  355. outb(new, 0x4d0);
  356. outb(new >> 8, 0x4d1);
  357. }
  358. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  359. {
  360. #ifdef CONFIG_X86_IO_APIC
  361. if (use_pci_vector() && !platform_legacy_irq(gsi))
  362. *irq = IO_APIC_VECTOR(gsi);
  363. else
  364. #endif
  365. *irq = gsi_irq_sharing(gsi);
  366. return 0;
  367. }
  368. /*
  369. * success: return IRQ number (>=0)
  370. * failure: return < 0
  371. */
  372. int acpi_register_gsi(u32 gsi, int triggering, int polarity)
  373. {
  374. unsigned int irq;
  375. unsigned int plat_gsi = gsi;
  376. #ifdef CONFIG_PCI
  377. /*
  378. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  379. */
  380. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  381. extern void eisa_set_level_irq(unsigned int irq);
  382. if (triggering == ACPI_LEVEL_SENSITIVE)
  383. eisa_set_level_irq(gsi);
  384. }
  385. #endif
  386. #ifdef CONFIG_X86_IO_APIC
  387. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  388. plat_gsi = mp_register_gsi(gsi, triggering, polarity);
  389. }
  390. #endif
  391. acpi_gsi_to_irq(plat_gsi, &irq);
  392. return irq;
  393. }
  394. EXPORT_SYMBOL(acpi_register_gsi);
  395. /*
  396. * ACPI based hotplug support for CPU
  397. */
  398. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  399. int acpi_map_lsapic(acpi_handle handle, int *pcpu)
  400. {
  401. /* TBD */
  402. return -EINVAL;
  403. }
  404. EXPORT_SYMBOL(acpi_map_lsapic);
  405. int acpi_unmap_lsapic(int cpu)
  406. {
  407. /* TBD */
  408. return -EINVAL;
  409. }
  410. EXPORT_SYMBOL(acpi_unmap_lsapic);
  411. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  412. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  413. {
  414. /* TBD */
  415. return -EINVAL;
  416. }
  417. EXPORT_SYMBOL(acpi_register_ioapic);
  418. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  419. {
  420. /* TBD */
  421. return -EINVAL;
  422. }
  423. EXPORT_SYMBOL(acpi_unregister_ioapic);
  424. static unsigned long __init
  425. acpi_scan_rsdp(unsigned long start, unsigned long length)
  426. {
  427. unsigned long offset = 0;
  428. unsigned long sig_len = sizeof("RSD PTR ") - 1;
  429. /*
  430. * Scan all 16-byte boundaries of the physical memory region for the
  431. * RSDP signature.
  432. */
  433. for (offset = 0; offset < length; offset += 16) {
  434. if (strncmp((char *)(phys_to_virt(start) + offset), "RSD PTR ", sig_len))
  435. continue;
  436. return (start + offset);
  437. }
  438. return 0;
  439. }
  440. static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
  441. {
  442. struct acpi_table_sbf *sb;
  443. if (!phys_addr || !size)
  444. return -EINVAL;
  445. sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
  446. if (!sb) {
  447. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  448. return -ENODEV;
  449. }
  450. sbf_port = sb->sbf_cmos; /* Save CMOS port */
  451. return 0;
  452. }
  453. #ifdef CONFIG_HPET_TIMER
  454. static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
  455. {
  456. struct acpi_table_hpet *hpet_tbl;
  457. if (!phys || !size)
  458. return -EINVAL;
  459. hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
  460. if (!hpet_tbl) {
  461. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  462. return -ENODEV;
  463. }
  464. if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
  465. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  466. "memory.\n");
  467. return -1;
  468. }
  469. #ifdef CONFIG_X86_64
  470. vxtime.hpet_address = hpet_tbl->addr.addrl |
  471. ((long)hpet_tbl->addr.addrh << 32);
  472. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  473. hpet_tbl->id, vxtime.hpet_address);
  474. #else /* X86 */
  475. {
  476. extern unsigned long hpet_address;
  477. hpet_address = hpet_tbl->addr.addrl;
  478. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  479. hpet_tbl->id, hpet_address);
  480. }
  481. #endif /* X86 */
  482. return 0;
  483. }
  484. #else
  485. #define acpi_parse_hpet NULL
  486. #endif
  487. #ifdef CONFIG_X86_PM_TIMER
  488. extern u32 pmtmr_ioport;
  489. #endif
  490. static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
  491. {
  492. struct fadt_descriptor_rev2 *fadt = NULL;
  493. fadt = (struct fadt_descriptor_rev2 *)__acpi_map_table(phys, size);
  494. if (!fadt) {
  495. printk(KERN_WARNING PREFIX "Unable to map FADT\n");
  496. return 0;
  497. }
  498. /* initialize sci_int early for INT_SRC_OVR MADT parsing */
  499. acpi_fadt.sci_int = fadt->sci_int;
  500. /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
  501. acpi_fadt.revision = fadt->revision;
  502. acpi_fadt.force_apic_physical_destination_mode =
  503. fadt->force_apic_physical_destination_mode;
  504. #ifdef CONFIG_X86_PM_TIMER
  505. /* detect the location of the ACPI PM Timer */
  506. if (fadt->revision >= FADT2_REVISION_ID) {
  507. /* FADT rev. 2 */
  508. if (fadt->xpm_tmr_blk.address_space_id !=
  509. ACPI_ADR_SPACE_SYSTEM_IO)
  510. return 0;
  511. pmtmr_ioport = fadt->xpm_tmr_blk.address;
  512. /*
  513. * "X" fields are optional extensions to the original V1.0
  514. * fields, so we must selectively expand V1.0 fields if the
  515. * corresponding X field is zero.
  516. */
  517. if (!pmtmr_ioport)
  518. pmtmr_ioport = fadt->V1_pm_tmr_blk;
  519. } else {
  520. /* FADT rev. 1 */
  521. pmtmr_ioport = fadt->V1_pm_tmr_blk;
  522. }
  523. if (pmtmr_ioport)
  524. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  525. pmtmr_ioport);
  526. #endif
  527. return 0;
  528. }
  529. unsigned long __init acpi_find_rsdp(void)
  530. {
  531. unsigned long rsdp_phys = 0;
  532. if (efi_enabled) {
  533. if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
  534. return efi.acpi20;
  535. else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
  536. return efi.acpi;
  537. }
  538. /*
  539. * Scan memory looking for the RSDP signature. First search EBDA (low
  540. * memory) paragraphs and then search upper memory (E0000-FFFFF).
  541. */
  542. rsdp_phys = acpi_scan_rsdp(0, 0x400);
  543. if (!rsdp_phys)
  544. rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
  545. return rsdp_phys;
  546. }
  547. #ifdef CONFIG_X86_LOCAL_APIC
  548. /*
  549. * Parse LAPIC entries in MADT
  550. * returns 0 on success, < 0 on error
  551. */
  552. static int __init acpi_parse_madt_lapic_entries(void)
  553. {
  554. int count;
  555. if (!cpu_has_apic)
  556. return -ENODEV;
  557. /*
  558. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  559. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  560. */
  561. count =
  562. acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR,
  563. acpi_parse_lapic_addr_ovr, 0);
  564. if (count < 0) {
  565. printk(KERN_ERR PREFIX
  566. "Error parsing LAPIC address override entry\n");
  567. return count;
  568. }
  569. mp_register_lapic_address(acpi_lapic_addr);
  570. count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
  571. MAX_APICS);
  572. if (!count) {
  573. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  574. /* TBD: Cleanup to allow fallback to MPS */
  575. return -ENODEV;
  576. } else if (count < 0) {
  577. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  578. /* TBD: Cleanup to allow fallback to MPS */
  579. return count;
  580. }
  581. count =
  582. acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
  583. if (count < 0) {
  584. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  585. /* TBD: Cleanup to allow fallback to MPS */
  586. return count;
  587. }
  588. return 0;
  589. }
  590. #endif /* CONFIG_X86_LOCAL_APIC */
  591. #ifdef CONFIG_X86_IO_APIC
  592. /*
  593. * Parse IOAPIC related entries in MADT
  594. * returns 0 on success, < 0 on error
  595. */
  596. static int __init acpi_parse_madt_ioapic_entries(void)
  597. {
  598. int count;
  599. /*
  600. * ACPI interpreter is required to complete interrupt setup,
  601. * so if it is off, don't enumerate the io-apics with ACPI.
  602. * If MPS is present, it will handle them,
  603. * otherwise the system will stay in PIC mode
  604. */
  605. if (acpi_disabled || acpi_noirq) {
  606. return -ENODEV;
  607. }
  608. if (!cpu_has_apic)
  609. return -ENODEV;
  610. /*
  611. * if "noapic" boot option, don't look for IO-APICs
  612. */
  613. if (skip_ioapic_setup) {
  614. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  615. "due to 'noapic' option.\n");
  616. return -ENODEV;
  617. }
  618. count =
  619. acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic,
  620. MAX_IO_APICS);
  621. if (!count) {
  622. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  623. return -ENODEV;
  624. } else if (count < 0) {
  625. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  626. return count;
  627. }
  628. count =
  629. acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr,
  630. NR_IRQ_VECTORS);
  631. if (count < 0) {
  632. printk(KERN_ERR PREFIX
  633. "Error parsing interrupt source overrides entry\n");
  634. /* TBD: Cleanup to allow fallback to MPS */
  635. return count;
  636. }
  637. /*
  638. * If BIOS did not supply an INT_SRC_OVR for the SCI
  639. * pretend we got one so we can set the SCI flags.
  640. */
  641. if (!acpi_sci_override_gsi)
  642. acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
  643. /* Fill in identity legacy mapings where no override */
  644. mp_config_acpi_legacy_irqs();
  645. count =
  646. acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src,
  647. NR_IRQ_VECTORS);
  648. if (count < 0) {
  649. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  650. /* TBD: Cleanup to allow fallback to MPS */
  651. return count;
  652. }
  653. return 0;
  654. }
  655. #else
  656. static inline int acpi_parse_madt_ioapic_entries(void)
  657. {
  658. return -1;
  659. }
  660. #endif /* !CONFIG_X86_IO_APIC */
  661. static void __init acpi_process_madt(void)
  662. {
  663. #ifdef CONFIG_X86_LOCAL_APIC
  664. int count, error;
  665. count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
  666. if (count >= 1) {
  667. /*
  668. * Parse MADT LAPIC entries
  669. */
  670. error = acpi_parse_madt_lapic_entries();
  671. if (!error) {
  672. acpi_lapic = 1;
  673. #ifdef CONFIG_X86_GENERICARCH
  674. generic_bigsmp_probe();
  675. #endif
  676. /*
  677. * Parse MADT IO-APIC entries
  678. */
  679. error = acpi_parse_madt_ioapic_entries();
  680. if (!error) {
  681. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  682. acpi_irq_balance_set(NULL);
  683. acpi_ioapic = 1;
  684. smp_found_config = 1;
  685. clustered_apic_check();
  686. }
  687. }
  688. if (error == -EINVAL) {
  689. /*
  690. * Dell Precision Workstation 410, 610 come here.
  691. */
  692. printk(KERN_ERR PREFIX
  693. "Invalid BIOS MADT, disabling ACPI\n");
  694. disable_acpi();
  695. }
  696. }
  697. #endif
  698. return;
  699. }
  700. extern int acpi_force;
  701. #ifdef __i386__
  702. static int __init disable_acpi_irq(struct dmi_system_id *d)
  703. {
  704. if (!acpi_force) {
  705. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  706. d->ident);
  707. acpi_noirq_set();
  708. }
  709. return 0;
  710. }
  711. static int __init disable_acpi_pci(struct dmi_system_id *d)
  712. {
  713. if (!acpi_force) {
  714. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  715. d->ident);
  716. acpi_disable_pci();
  717. }
  718. return 0;
  719. }
  720. static int __init dmi_disable_acpi(struct dmi_system_id *d)
  721. {
  722. if (!acpi_force) {
  723. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  724. disable_acpi();
  725. } else {
  726. printk(KERN_NOTICE
  727. "Warning: DMI blacklist says broken, but acpi forced\n");
  728. }
  729. return 0;
  730. }
  731. /*
  732. * Limit ACPI to CPU enumeration for HT
  733. */
  734. static int __init force_acpi_ht(struct dmi_system_id *d)
  735. {
  736. if (!acpi_force) {
  737. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  738. d->ident);
  739. disable_acpi();
  740. acpi_ht = 1;
  741. } else {
  742. printk(KERN_NOTICE
  743. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  744. }
  745. return 0;
  746. }
  747. /*
  748. * If your system is blacklisted here, but you find that acpi=force
  749. * works for you, please contact acpi-devel@sourceforge.net
  750. */
  751. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  752. /*
  753. * Boxes that need ACPI disabled
  754. */
  755. {
  756. .callback = dmi_disable_acpi,
  757. .ident = "IBM Thinkpad",
  758. .matches = {
  759. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  760. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  761. },
  762. },
  763. /*
  764. * Boxes that need acpi=ht
  765. */
  766. {
  767. .callback = force_acpi_ht,
  768. .ident = "FSC Primergy T850",
  769. .matches = {
  770. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  771. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  772. },
  773. },
  774. {
  775. .callback = force_acpi_ht,
  776. .ident = "DELL GX240",
  777. .matches = {
  778. DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
  779. DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
  780. },
  781. },
  782. {
  783. .callback = force_acpi_ht,
  784. .ident = "HP VISUALIZE NT Workstation",
  785. .matches = {
  786. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  787. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  788. },
  789. },
  790. {
  791. .callback = force_acpi_ht,
  792. .ident = "Compaq Workstation W8000",
  793. .matches = {
  794. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  795. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  796. },
  797. },
  798. {
  799. .callback = force_acpi_ht,
  800. .ident = "ASUS P4B266",
  801. .matches = {
  802. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  803. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  804. },
  805. },
  806. {
  807. .callback = force_acpi_ht,
  808. .ident = "ASUS P2B-DS",
  809. .matches = {
  810. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  811. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  812. },
  813. },
  814. {
  815. .callback = force_acpi_ht,
  816. .ident = "ASUS CUR-DLS",
  817. .matches = {
  818. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  819. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  820. },
  821. },
  822. {
  823. .callback = force_acpi_ht,
  824. .ident = "ABIT i440BX-W83977",
  825. .matches = {
  826. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  827. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  828. },
  829. },
  830. {
  831. .callback = force_acpi_ht,
  832. .ident = "IBM Bladecenter",
  833. .matches = {
  834. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  835. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  836. },
  837. },
  838. {
  839. .callback = force_acpi_ht,
  840. .ident = "IBM eServer xSeries 360",
  841. .matches = {
  842. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  843. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  844. },
  845. },
  846. {
  847. .callback = force_acpi_ht,
  848. .ident = "IBM eserver xSeries 330",
  849. .matches = {
  850. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  851. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  852. },
  853. },
  854. {
  855. .callback = force_acpi_ht,
  856. .ident = "IBM eserver xSeries 440",
  857. .matches = {
  858. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  859. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  860. },
  861. },
  862. /*
  863. * Boxes that need ACPI PCI IRQ routing disabled
  864. */
  865. {
  866. .callback = disable_acpi_irq,
  867. .ident = "ASUS A7V",
  868. .matches = {
  869. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  870. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  871. /* newer BIOS, Revision 1011, does work */
  872. DMI_MATCH(DMI_BIOS_VERSION,
  873. "ASUS A7V ACPI BIOS Revision 1007"),
  874. },
  875. },
  876. /*
  877. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  878. */
  879. { /* _BBN 0 bug */
  880. .callback = disable_acpi_pci,
  881. .ident = "ASUS PR-DLS",
  882. .matches = {
  883. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  884. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  885. DMI_MATCH(DMI_BIOS_VERSION,
  886. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  887. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  888. },
  889. },
  890. {
  891. .callback = disable_acpi_pci,
  892. .ident = "Acer TravelMate 36x Laptop",
  893. .matches = {
  894. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  895. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  896. },
  897. },
  898. {}
  899. };
  900. #endif /* __i386__ */
  901. /*
  902. * acpi_boot_table_init() and acpi_boot_init()
  903. * called from setup_arch(), always.
  904. * 1. checksums all tables
  905. * 2. enumerates lapics
  906. * 3. enumerates io-apics
  907. *
  908. * acpi_table_init() is separate to allow reading SRAT without
  909. * other side effects.
  910. *
  911. * side effects of acpi_boot_init:
  912. * acpi_lapic = 1 if LAPIC found
  913. * acpi_ioapic = 1 if IOAPIC found
  914. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  915. * if acpi_blacklisted() acpi_disabled = 1;
  916. * acpi_irq_model=...
  917. * ...
  918. *
  919. * return value: (currently ignored)
  920. * 0: success
  921. * !0: failure
  922. */
  923. int __init acpi_boot_table_init(void)
  924. {
  925. int error;
  926. #ifdef __i386__
  927. dmi_check_system(acpi_dmi_table);
  928. #endif
  929. if (!cpu_has_apic)
  930. return -ENODEV;
  931. /*
  932. * If acpi_disabled, bail out
  933. * One exception: acpi=ht continues far enough to enumerate LAPICs
  934. */
  935. if (acpi_disabled && !acpi_ht)
  936. return 1;
  937. /*
  938. * Initialize the ACPI boot-time table parser.
  939. */
  940. error = acpi_table_init();
  941. if (error) {
  942. disable_acpi();
  943. return error;
  944. }
  945. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  946. /*
  947. * blacklist may disable ACPI entirely
  948. */
  949. error = acpi_blacklisted();
  950. if (error) {
  951. if (acpi_force) {
  952. printk(KERN_WARNING PREFIX "acpi=force override\n");
  953. } else {
  954. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  955. disable_acpi();
  956. return error;
  957. }
  958. }
  959. return 0;
  960. }
  961. int __init acpi_boot_init(void)
  962. {
  963. /*
  964. * If acpi_disabled, bail out
  965. * One exception: acpi=ht continues far enough to enumerate LAPICs
  966. */
  967. if (acpi_disabled && !acpi_ht)
  968. return 1;
  969. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  970. /*
  971. * set sci_int and PM timer address
  972. */
  973. acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
  974. /*
  975. * Process the Multiple APIC Description Table (MADT), if present
  976. */
  977. acpi_process_madt();
  978. acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
  979. return 0;
  980. }