boot.c 27 KB

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