boot.c 27 KB

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