boot.c 26 KB

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