boot.c 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  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 < (end_pfn_map << PAGE_SHIFT))
  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)
  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. /* Register even disabled CPUs for cpu hotplug */
  201. x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
  202. mp_register_lapic(processor->id, /* APIC ID */
  203. processor->flags.enabled); /* Enabled? */
  204. return 0;
  205. }
  206. static int __init
  207. acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
  208. const unsigned long end)
  209. {
  210. struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
  211. lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr *)header;
  212. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  213. return -EINVAL;
  214. acpi_lapic_addr = lapic_addr_ovr->address;
  215. return 0;
  216. }
  217. static int __init
  218. acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
  219. {
  220. struct acpi_table_lapic_nmi *lapic_nmi = NULL;
  221. lapic_nmi = (struct acpi_table_lapic_nmi *)header;
  222. if (BAD_MADT_ENTRY(lapic_nmi, end))
  223. return -EINVAL;
  224. acpi_table_print_madt_entry(header);
  225. if (lapic_nmi->lint != 1)
  226. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  227. return 0;
  228. }
  229. #endif /*CONFIG_X86_LOCAL_APIC */
  230. #ifdef CONFIG_X86_IO_APIC
  231. static int __init
  232. acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
  233. {
  234. struct acpi_table_ioapic *ioapic = NULL;
  235. ioapic = (struct acpi_table_ioapic *)header;
  236. if (BAD_MADT_ENTRY(ioapic, end))
  237. return -EINVAL;
  238. acpi_table_print_madt_entry(header);
  239. mp_register_ioapic(ioapic->id,
  240. ioapic->address, ioapic->global_irq_base);
  241. return 0;
  242. }
  243. /*
  244. * Parse Interrupt Source Override for the ACPI SCI
  245. */
  246. static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  247. {
  248. if (trigger == 0) /* compatible SCI trigger is level */
  249. trigger = 3;
  250. if (polarity == 0) /* compatible SCI polarity is low */
  251. polarity = 3;
  252. /* Command-line over-ride via acpi_sci= */
  253. if (acpi_sci_flags.trigger)
  254. trigger = acpi_sci_flags.trigger;
  255. if (acpi_sci_flags.polarity)
  256. polarity = acpi_sci_flags.polarity;
  257. /*
  258. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  259. * If GSI is < 16, this will update its flags,
  260. * else it will create a new mp_irqs[] entry.
  261. */
  262. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  263. /*
  264. * stash over-ride to indicate we've been here
  265. * and for later update of acpi_fadt
  266. */
  267. acpi_sci_override_gsi = gsi;
  268. return;
  269. }
  270. static int __init
  271. acpi_parse_int_src_ovr(acpi_table_entry_header * header,
  272. const unsigned long end)
  273. {
  274. struct acpi_table_int_src_ovr *intsrc = NULL;
  275. intsrc = (struct acpi_table_int_src_ovr *)header;
  276. if (BAD_MADT_ENTRY(intsrc, end))
  277. return -EINVAL;
  278. acpi_table_print_madt_entry(header);
  279. if (intsrc->bus_irq == acpi_fadt.sci_int) {
  280. acpi_sci_ioapic_setup(intsrc->global_irq,
  281. intsrc->flags.polarity,
  282. intsrc->flags.trigger);
  283. return 0;
  284. }
  285. if (acpi_skip_timer_override &&
  286. intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
  287. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  288. return 0;
  289. }
  290. mp_override_legacy_irq(intsrc->bus_irq,
  291. intsrc->flags.polarity,
  292. intsrc->flags.trigger, intsrc->global_irq);
  293. return 0;
  294. }
  295. static int __init
  296. acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
  297. {
  298. struct acpi_table_nmi_src *nmi_src = NULL;
  299. nmi_src = (struct acpi_table_nmi_src *)header;
  300. if (BAD_MADT_ENTRY(nmi_src, end))
  301. return -EINVAL;
  302. acpi_table_print_madt_entry(header);
  303. /* TBD: Support nimsrc entries? */
  304. return 0;
  305. }
  306. #endif /* CONFIG_X86_IO_APIC */
  307. /*
  308. * acpi_pic_sci_set_trigger()
  309. *
  310. * use ELCR to set PIC-mode trigger type for SCI
  311. *
  312. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  313. * it may require Edge Trigger -- use "acpi_sci=edge"
  314. *
  315. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  316. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  317. * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
  318. * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
  319. */
  320. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  321. {
  322. unsigned int mask = 1 << irq;
  323. unsigned int old, new;
  324. /* Real old ELCR mask */
  325. old = inb(0x4d0) | (inb(0x4d1) << 8);
  326. /*
  327. * If we use ACPI to set PCI irq's, then we should clear ELCR
  328. * since we will set it correctly as we enable the PCI irq
  329. * routing.
  330. */
  331. new = acpi_noirq ? old : 0;
  332. /*
  333. * Update SCI information in the ELCR, it isn't in the PCI
  334. * routing tables..
  335. */
  336. switch (trigger) {
  337. case 1: /* Edge - clear */
  338. new &= ~mask;
  339. break;
  340. case 3: /* Level - set */
  341. new |= mask;
  342. break;
  343. }
  344. if (old == new)
  345. return;
  346. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  347. outb(new, 0x4d0);
  348. outb(new >> 8, 0x4d1);
  349. }
  350. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  351. {
  352. #ifdef CONFIG_X86_IO_APIC
  353. if (use_pci_vector() && !platform_legacy_irq(gsi))
  354. *irq = IO_APIC_VECTOR(gsi);
  355. else
  356. #endif
  357. *irq = gsi_irq_sharing(gsi);
  358. return 0;
  359. }
  360. /*
  361. * success: return IRQ number (>=0)
  362. * failure: return < 0
  363. */
  364. int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
  365. {
  366. unsigned int irq;
  367. unsigned int plat_gsi = gsi;
  368. #ifdef CONFIG_PCI
  369. /*
  370. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  371. */
  372. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  373. extern void eisa_set_level_irq(unsigned int irq);
  374. if (edge_level == ACPI_LEVEL_SENSITIVE)
  375. eisa_set_level_irq(gsi);
  376. }
  377. #endif
  378. #ifdef CONFIG_X86_IO_APIC
  379. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  380. plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
  381. }
  382. #endif
  383. acpi_gsi_to_irq(plat_gsi, &irq);
  384. return irq;
  385. }
  386. EXPORT_SYMBOL(acpi_register_gsi);
  387. /*
  388. * ACPI based hotplug support for CPU
  389. */
  390. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  391. int acpi_map_lsapic(acpi_handle handle, int *pcpu)
  392. {
  393. /* TBD */
  394. return -EINVAL;
  395. }
  396. EXPORT_SYMBOL(acpi_map_lsapic);
  397. int acpi_unmap_lsapic(int cpu)
  398. {
  399. /* TBD */
  400. return -EINVAL;
  401. }
  402. EXPORT_SYMBOL(acpi_unmap_lsapic);
  403. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  404. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  405. {
  406. /* TBD */
  407. return -EINVAL;
  408. }
  409. EXPORT_SYMBOL(acpi_register_ioapic);
  410. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  411. {
  412. /* TBD */
  413. return -EINVAL;
  414. }
  415. EXPORT_SYMBOL(acpi_unregister_ioapic);
  416. static unsigned long __init
  417. acpi_scan_rsdp(unsigned long start, unsigned long length)
  418. {
  419. unsigned long offset = 0;
  420. unsigned long sig_len = sizeof("RSD PTR ") - 1;
  421. /*
  422. * Scan all 16-byte boundaries of the physical memory region for the
  423. * RSDP signature.
  424. */
  425. for (offset = 0; offset < length; offset += 16) {
  426. if (strncmp((char *)(phys_to_virt(start) + offset), "RSD PTR ", sig_len))
  427. continue;
  428. return (start + offset);
  429. }
  430. return 0;
  431. }
  432. static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
  433. {
  434. struct acpi_table_sbf *sb;
  435. if (!phys_addr || !size)
  436. return -EINVAL;
  437. sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
  438. if (!sb) {
  439. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  440. return -ENODEV;
  441. }
  442. sbf_port = sb->sbf_cmos; /* Save CMOS port */
  443. return 0;
  444. }
  445. #ifdef CONFIG_HPET_TIMER
  446. static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
  447. {
  448. struct acpi_table_hpet *hpet_tbl;
  449. if (!phys || !size)
  450. return -EINVAL;
  451. hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
  452. if (!hpet_tbl) {
  453. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  454. return -ENODEV;
  455. }
  456. if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
  457. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  458. "memory.\n");
  459. return -1;
  460. }
  461. #ifdef CONFIG_X86_64
  462. vxtime.hpet_address = hpet_tbl->addr.addrl |
  463. ((long)hpet_tbl->addr.addrh << 32);
  464. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  465. hpet_tbl->id, vxtime.hpet_address);
  466. #else /* X86 */
  467. {
  468. extern unsigned long hpet_address;
  469. hpet_address = hpet_tbl->addr.addrl;
  470. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  471. hpet_tbl->id, hpet_address);
  472. }
  473. #endif /* X86 */
  474. return 0;
  475. }
  476. #else
  477. #define acpi_parse_hpet NULL
  478. #endif
  479. #ifdef CONFIG_X86_PM_TIMER
  480. extern u32 pmtmr_ioport;
  481. #endif
  482. static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
  483. {
  484. struct fadt_descriptor_rev2 *fadt = NULL;
  485. fadt = (struct fadt_descriptor_rev2 *)__acpi_map_table(phys, size);
  486. if (!fadt) {
  487. printk(KERN_WARNING PREFIX "Unable to map FADT\n");
  488. return 0;
  489. }
  490. /* initialize sci_int early for INT_SRC_OVR MADT parsing */
  491. acpi_fadt.sci_int = fadt->sci_int;
  492. /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
  493. acpi_fadt.revision = fadt->revision;
  494. acpi_fadt.force_apic_physical_destination_mode =
  495. fadt->force_apic_physical_destination_mode;
  496. #ifdef CONFIG_X86_PM_TIMER
  497. /* detect the location of the ACPI PM Timer */
  498. if (fadt->revision >= FADT2_REVISION_ID) {
  499. /* FADT rev. 2 */
  500. if (fadt->xpm_tmr_blk.address_space_id !=
  501. ACPI_ADR_SPACE_SYSTEM_IO)
  502. return 0;
  503. pmtmr_ioport = fadt->xpm_tmr_blk.address;
  504. } else {
  505. /* FADT rev. 1 */
  506. pmtmr_ioport = fadt->V1_pm_tmr_blk;
  507. }
  508. if (pmtmr_ioport)
  509. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  510. pmtmr_ioport);
  511. #endif
  512. return 0;
  513. }
  514. unsigned long __init acpi_find_rsdp(void)
  515. {
  516. unsigned long rsdp_phys = 0;
  517. if (efi_enabled) {
  518. if (efi.acpi20)
  519. return __pa(efi.acpi20);
  520. else if (efi.acpi)
  521. return __pa(efi.acpi);
  522. }
  523. /*
  524. * Scan memory looking for the RSDP signature. First search EBDA (low
  525. * memory) paragraphs and then search upper memory (E0000-FFFFF).
  526. */
  527. rsdp_phys = acpi_scan_rsdp(0, 0x400);
  528. if (!rsdp_phys)
  529. rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
  530. return rsdp_phys;
  531. }
  532. #ifdef CONFIG_X86_LOCAL_APIC
  533. /*
  534. * Parse LAPIC entries in MADT
  535. * returns 0 on success, < 0 on error
  536. */
  537. static int __init acpi_parse_madt_lapic_entries(void)
  538. {
  539. int count;
  540. /*
  541. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  542. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  543. */
  544. count =
  545. acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR,
  546. acpi_parse_lapic_addr_ovr, 0);
  547. if (count < 0) {
  548. printk(KERN_ERR PREFIX
  549. "Error parsing LAPIC address override entry\n");
  550. return count;
  551. }
  552. mp_register_lapic_address(acpi_lapic_addr);
  553. count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
  554. MAX_APICS);
  555. if (!count) {
  556. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  557. /* TBD: Cleanup to allow fallback to MPS */
  558. return -ENODEV;
  559. } else if (count < 0) {
  560. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  561. /* TBD: Cleanup to allow fallback to MPS */
  562. return count;
  563. }
  564. count =
  565. acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
  566. if (count < 0) {
  567. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  568. /* TBD: Cleanup to allow fallback to MPS */
  569. return count;
  570. }
  571. return 0;
  572. }
  573. #endif /* CONFIG_X86_LOCAL_APIC */
  574. #ifdef CONFIG_X86_IO_APIC
  575. /*
  576. * Parse IOAPIC related entries in MADT
  577. * returns 0 on success, < 0 on error
  578. */
  579. static int __init acpi_parse_madt_ioapic_entries(void)
  580. {
  581. int count;
  582. /*
  583. * ACPI interpreter is required to complete interrupt setup,
  584. * so if it is off, don't enumerate the io-apics with ACPI.
  585. * If MPS is present, it will handle them,
  586. * otherwise the system will stay in PIC mode
  587. */
  588. if (acpi_disabled || acpi_noirq) {
  589. return -ENODEV;
  590. }
  591. /*
  592. * if "noapic" boot option, don't look for IO-APICs
  593. */
  594. if (skip_ioapic_setup) {
  595. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  596. "due to 'noapic' option.\n");
  597. return -ENODEV;
  598. }
  599. count =
  600. acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic,
  601. MAX_IO_APICS);
  602. if (!count) {
  603. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  604. return -ENODEV;
  605. } else if (count < 0) {
  606. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  607. return count;
  608. }
  609. count =
  610. acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr,
  611. NR_IRQ_VECTORS);
  612. if (count < 0) {
  613. printk(KERN_ERR PREFIX
  614. "Error parsing interrupt source overrides entry\n");
  615. /* TBD: Cleanup to allow fallback to MPS */
  616. return count;
  617. }
  618. /*
  619. * If BIOS did not supply an INT_SRC_OVR for the SCI
  620. * pretend we got one so we can set the SCI flags.
  621. */
  622. if (!acpi_sci_override_gsi)
  623. acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
  624. /* Fill in identity legacy mapings where no override */
  625. mp_config_acpi_legacy_irqs();
  626. count =
  627. acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src,
  628. NR_IRQ_VECTORS);
  629. if (count < 0) {
  630. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  631. /* TBD: Cleanup to allow fallback to MPS */
  632. return count;
  633. }
  634. return 0;
  635. }
  636. #else
  637. static inline int acpi_parse_madt_ioapic_entries(void)
  638. {
  639. return -1;
  640. }
  641. #endif /* !CONFIG_X86_IO_APIC */
  642. static void __init acpi_process_madt(void)
  643. {
  644. #ifdef CONFIG_X86_LOCAL_APIC
  645. int count, error;
  646. count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
  647. if (count >= 1) {
  648. /*
  649. * Parse MADT LAPIC entries
  650. */
  651. error = acpi_parse_madt_lapic_entries();
  652. if (!error) {
  653. acpi_lapic = 1;
  654. #ifdef CONFIG_X86_GENERICARCH
  655. generic_bigsmp_probe();
  656. #endif
  657. /*
  658. * Parse MADT IO-APIC entries
  659. */
  660. error = acpi_parse_madt_ioapic_entries();
  661. if (!error) {
  662. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  663. acpi_irq_balance_set(NULL);
  664. acpi_ioapic = 1;
  665. smp_found_config = 1;
  666. clustered_apic_check();
  667. }
  668. }
  669. if (error == -EINVAL) {
  670. /*
  671. * Dell Precision Workstation 410, 610 come here.
  672. */
  673. printk(KERN_ERR PREFIX
  674. "Invalid BIOS MADT, disabling ACPI\n");
  675. disable_acpi();
  676. }
  677. }
  678. #endif
  679. return;
  680. }
  681. extern int acpi_force;
  682. #ifdef __i386__
  683. static int __init disable_acpi_irq(struct dmi_system_id *d)
  684. {
  685. if (!acpi_force) {
  686. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  687. d->ident);
  688. acpi_noirq_set();
  689. }
  690. return 0;
  691. }
  692. static int __init disable_acpi_pci(struct dmi_system_id *d)
  693. {
  694. if (!acpi_force) {
  695. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  696. d->ident);
  697. acpi_disable_pci();
  698. }
  699. return 0;
  700. }
  701. static int __init dmi_disable_acpi(struct dmi_system_id *d)
  702. {
  703. if (!acpi_force) {
  704. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  705. disable_acpi();
  706. } else {
  707. printk(KERN_NOTICE
  708. "Warning: DMI blacklist says broken, but acpi forced\n");
  709. }
  710. return 0;
  711. }
  712. /*
  713. * Limit ACPI to CPU enumeration for HT
  714. */
  715. static int __init force_acpi_ht(struct dmi_system_id *d)
  716. {
  717. if (!acpi_force) {
  718. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  719. d->ident);
  720. disable_acpi();
  721. acpi_ht = 1;
  722. } else {
  723. printk(KERN_NOTICE
  724. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  725. }
  726. return 0;
  727. }
  728. /*
  729. * If your system is blacklisted here, but you find that acpi=force
  730. * works for you, please contact acpi-devel@sourceforge.net
  731. */
  732. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  733. /*
  734. * Boxes that need ACPI disabled
  735. */
  736. {
  737. .callback = dmi_disable_acpi,
  738. .ident = "IBM Thinkpad",
  739. .matches = {
  740. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  741. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  742. },
  743. },
  744. /*
  745. * Boxes that need acpi=ht
  746. */
  747. {
  748. .callback = force_acpi_ht,
  749. .ident = "FSC Primergy T850",
  750. .matches = {
  751. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  752. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  753. },
  754. },
  755. {
  756. .callback = force_acpi_ht,
  757. .ident = "DELL GX240",
  758. .matches = {
  759. DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
  760. DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
  761. },
  762. },
  763. {
  764. .callback = force_acpi_ht,
  765. .ident = "HP VISUALIZE NT Workstation",
  766. .matches = {
  767. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  768. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  769. },
  770. },
  771. {
  772. .callback = force_acpi_ht,
  773. .ident = "Compaq Workstation W8000",
  774. .matches = {
  775. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  776. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  777. },
  778. },
  779. {
  780. .callback = force_acpi_ht,
  781. .ident = "ASUS P4B266",
  782. .matches = {
  783. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  784. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  785. },
  786. },
  787. {
  788. .callback = force_acpi_ht,
  789. .ident = "ASUS P2B-DS",
  790. .matches = {
  791. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  792. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  793. },
  794. },
  795. {
  796. .callback = force_acpi_ht,
  797. .ident = "ASUS CUR-DLS",
  798. .matches = {
  799. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  800. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  801. },
  802. },
  803. {
  804. .callback = force_acpi_ht,
  805. .ident = "ABIT i440BX-W83977",
  806. .matches = {
  807. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  808. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  809. },
  810. },
  811. {
  812. .callback = force_acpi_ht,
  813. .ident = "IBM Bladecenter",
  814. .matches = {
  815. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  816. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  817. },
  818. },
  819. {
  820. .callback = force_acpi_ht,
  821. .ident = "IBM eServer xSeries 360",
  822. .matches = {
  823. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  824. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  825. },
  826. },
  827. {
  828. .callback = force_acpi_ht,
  829. .ident = "IBM eserver xSeries 330",
  830. .matches = {
  831. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  832. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  833. },
  834. },
  835. {
  836. .callback = force_acpi_ht,
  837. .ident = "IBM eserver xSeries 440",
  838. .matches = {
  839. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  840. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  841. },
  842. },
  843. /*
  844. * Boxes that need ACPI PCI IRQ routing disabled
  845. */
  846. {
  847. .callback = disable_acpi_irq,
  848. .ident = "ASUS A7V",
  849. .matches = {
  850. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  851. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  852. /* newer BIOS, Revision 1011, does work */
  853. DMI_MATCH(DMI_BIOS_VERSION,
  854. "ASUS A7V ACPI BIOS Revision 1007"),
  855. },
  856. },
  857. /*
  858. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  859. */
  860. { /* _BBN 0 bug */
  861. .callback = disable_acpi_pci,
  862. .ident = "ASUS PR-DLS",
  863. .matches = {
  864. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  865. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  866. DMI_MATCH(DMI_BIOS_VERSION,
  867. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  868. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  869. },
  870. },
  871. {
  872. .callback = disable_acpi_pci,
  873. .ident = "Acer TravelMate 36x Laptop",
  874. .matches = {
  875. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  876. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  877. },
  878. },
  879. {}
  880. };
  881. #endif /* __i386__ */
  882. /*
  883. * acpi_boot_table_init() and acpi_boot_init()
  884. * called from setup_arch(), always.
  885. * 1. checksums all tables
  886. * 2. enumerates lapics
  887. * 3. enumerates io-apics
  888. *
  889. * acpi_table_init() is separate to allow reading SRAT without
  890. * other side effects.
  891. *
  892. * side effects of acpi_boot_init:
  893. * acpi_lapic = 1 if LAPIC found
  894. * acpi_ioapic = 1 if IOAPIC found
  895. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  896. * if acpi_blacklisted() acpi_disabled = 1;
  897. * acpi_irq_model=...
  898. * ...
  899. *
  900. * return value: (currently ignored)
  901. * 0: success
  902. * !0: failure
  903. */
  904. int __init acpi_boot_table_init(void)
  905. {
  906. int error;
  907. #ifdef __i386__
  908. dmi_check_system(acpi_dmi_table);
  909. #endif
  910. /*
  911. * If acpi_disabled, bail out
  912. * One exception: acpi=ht continues far enough to enumerate LAPICs
  913. */
  914. if (acpi_disabled && !acpi_ht)
  915. return 1;
  916. /*
  917. * Initialize the ACPI boot-time table parser.
  918. */
  919. error = acpi_table_init();
  920. if (error) {
  921. disable_acpi();
  922. return error;
  923. }
  924. #ifdef __i386__
  925. check_acpi_pci();
  926. #endif
  927. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  928. /*
  929. * blacklist may disable ACPI entirely
  930. */
  931. error = acpi_blacklisted();
  932. if (error) {
  933. if (acpi_force) {
  934. printk(KERN_WARNING PREFIX "acpi=force override\n");
  935. } else {
  936. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  937. disable_acpi();
  938. return error;
  939. }
  940. }
  941. return 0;
  942. }
  943. int __init acpi_boot_init(void)
  944. {
  945. /*
  946. * If acpi_disabled, bail out
  947. * One exception: acpi=ht continues far enough to enumerate LAPICs
  948. */
  949. if (acpi_disabled && !acpi_ht)
  950. return 1;
  951. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  952. /*
  953. * set sci_int and PM timer address
  954. */
  955. acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
  956. /*
  957. * Process the Multiple APIC Description Table (MADT), if present
  958. */
  959. acpi_process_madt();
  960. acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
  961. return 0;
  962. }