boot.c 27 KB

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