boot.c 27 KB

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