boot.c 29 KB

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