boot.c 29 KB

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