boot.c 26 KB

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