boot.c 27 KB

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