boot.c 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. /*
  2. * boot.c - Architecture-Specific Low-Level ACPI Boot Support
  3. *
  4. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  5. * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. */
  25. #include <linux/init.h>
  26. #include <linux/config.h>
  27. #include <linux/acpi.h>
  28. #include <linux/efi.h>
  29. #include <linux/irq.h>
  30. #include <linux/module.h>
  31. #include <linux/dmi.h>
  32. #include <asm/pgtable.h>
  33. #include <asm/io_apic.h>
  34. #include <asm/apic.h>
  35. #include <asm/io.h>
  36. #include <asm/irq.h>
  37. #include <asm/mpspec.h>
  38. #ifdef CONFIG_X86_64
  39. static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) { }
  40. extern void __init clustered_apic_check(void);
  41. static inline int ioapic_setup_disabled(void) { return 0; }
  42. #include <asm/proto.h>
  43. #else /* X86 */
  44. #ifdef CONFIG_X86_LOCAL_APIC
  45. #include <mach_apic.h>
  46. #include <mach_mpparse.h>
  47. #endif /* CONFIG_X86_LOCAL_APIC */
  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. #ifdef CONFIG_ACPI_PCI
  54. int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
  55. int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
  56. #else
  57. int acpi_noirq __initdata = 1;
  58. int acpi_pci_disabled __initdata = 1;
  59. #endif
  60. int acpi_ht __initdata = 1; /* enable HT */
  61. int acpi_lapic;
  62. int acpi_ioapic;
  63. int acpi_strict;
  64. EXPORT_SYMBOL(acpi_strict);
  65. acpi_interrupt_flags acpi_sci_flags __initdata;
  66. int acpi_sci_override_gsi __initdata;
  67. int acpi_skip_timer_override __initdata;
  68. #ifdef CONFIG_X86_LOCAL_APIC
  69. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  70. #endif
  71. #ifndef __HAVE_ARCH_CMPXCHG
  72. #warning ACPI uses CMPXCHG, i486 and later hardware
  73. #endif
  74. #define MAX_MADT_ENTRIES 256
  75. u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
  76. { [0 ... MAX_MADT_ENTRIES-1] = 0xff };
  77. EXPORT_SYMBOL(x86_acpiid_to_apicid);
  78. /* --------------------------------------------------------------------------
  79. Boot-time Configuration
  80. -------------------------------------------------------------------------- */
  81. /*
  82. * The default interrupt routing model is PIC (8259). This gets
  83. * overriden if IOAPICs are enumerated (below).
  84. */
  85. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  86. #ifdef CONFIG_X86_64
  87. /* rely on all ACPI tables being in the direct mapping */
  88. char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
  89. {
  90. if (!phys_addr || !size)
  91. return NULL;
  92. if (phys_addr < (end_pfn_map << PAGE_SHIFT))
  93. return __va(phys_addr);
  94. return NULL;
  95. }
  96. #else
  97. /*
  98. * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  99. * to map the target physical address. The problem is that set_fixmap()
  100. * provides a single page, and it is possible that the page is not
  101. * sufficient.
  102. * By using this area, we can map up to MAX_IO_APICS pages temporarily,
  103. * i.e. until the next __va_range() call.
  104. *
  105. * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
  106. * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
  107. * count idx down while incrementing the phys address.
  108. */
  109. char *__acpi_map_table(unsigned long phys, unsigned long size)
  110. {
  111. unsigned long base, offset, mapped_size;
  112. int idx;
  113. if (phys + size < 8*1024*1024)
  114. return __va(phys);
  115. offset = phys & (PAGE_SIZE - 1);
  116. mapped_size = PAGE_SIZE - offset;
  117. set_fixmap(FIX_ACPI_END, phys);
  118. base = fix_to_virt(FIX_ACPI_END);
  119. /*
  120. * Most cases can be covered by the below.
  121. */
  122. idx = FIX_ACPI_END;
  123. while (mapped_size < size) {
  124. if (--idx < FIX_ACPI_BEGIN)
  125. return NULL; /* cannot handle this */
  126. phys += PAGE_SIZE;
  127. set_fixmap(idx, phys);
  128. mapped_size += PAGE_SIZE;
  129. }
  130. return ((unsigned char *) base + offset);
  131. }
  132. #endif
  133. #ifdef CONFIG_PCI_MMCONFIG
  134. /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
  135. struct acpi_table_mcfg_config *pci_mmcfg_config;
  136. int pci_mmcfg_config_num;
  137. int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
  138. {
  139. struct acpi_table_mcfg *mcfg;
  140. unsigned long i;
  141. int config_size;
  142. if (!phys_addr || !size)
  143. return -EINVAL;
  144. mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size);
  145. if (!mcfg) {
  146. printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
  147. return -ENODEV;
  148. }
  149. /* how many config structures do we have */
  150. pci_mmcfg_config_num = 0;
  151. i = size - sizeof(struct acpi_table_mcfg);
  152. while (i >= sizeof(struct acpi_table_mcfg_config)) {
  153. ++pci_mmcfg_config_num;
  154. i -= sizeof(struct acpi_table_mcfg_config);
  155. };
  156. if (pci_mmcfg_config_num == 0) {
  157. printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
  158. return -ENODEV;
  159. }
  160. config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
  161. pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
  162. if (!pci_mmcfg_config) {
  163. printk(KERN_WARNING PREFIX
  164. "No memory for MCFG config tables\n");
  165. return -ENOMEM;
  166. }
  167. memcpy(pci_mmcfg_config, &mcfg->config, config_size);
  168. for (i = 0; i < pci_mmcfg_config_num; ++i) {
  169. if (mcfg->config[i].base_reserved) {
  170. printk(KERN_ERR PREFIX
  171. "MMCONFIG not in low 4GB of memory\n");
  172. return -ENODEV;
  173. }
  174. }
  175. return 0;
  176. }
  177. #endif /* CONFIG_PCI_MMCONFIG */
  178. #ifdef CONFIG_X86_LOCAL_APIC
  179. static int __init
  180. acpi_parse_madt (
  181. unsigned long phys_addr,
  182. unsigned long size)
  183. {
  184. struct acpi_table_madt *madt = NULL;
  185. if (!phys_addr || !size)
  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 (
  202. acpi_table_entry_header *header, const unsigned long end)
  203. {
  204. struct acpi_table_lapic *processor = NULL;
  205. processor = (struct acpi_table_lapic*) header;
  206. if (BAD_MADT_ENTRY(processor, end))
  207. return -EINVAL;
  208. acpi_table_print_madt_entry(header);
  209. /* no utility in registering a disabled processor */
  210. if (processor->flags.enabled == 0)
  211. return 0;
  212. x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
  213. mp_register_lapic (
  214. processor->id, /* APIC ID */
  215. processor->flags.enabled); /* Enabled? */
  216. return 0;
  217. }
  218. static int __init
  219. acpi_parse_lapic_addr_ovr (
  220. acpi_table_entry_header *header, const unsigned long end)
  221. {
  222. struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
  223. lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header;
  224. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  225. return -EINVAL;
  226. acpi_lapic_addr = lapic_addr_ovr->address;
  227. return 0;
  228. }
  229. static int __init
  230. acpi_parse_lapic_nmi (
  231. acpi_table_entry_header *header, const unsigned long end)
  232. {
  233. struct acpi_table_lapic_nmi *lapic_nmi = NULL;
  234. lapic_nmi = (struct acpi_table_lapic_nmi*) header;
  235. if (BAD_MADT_ENTRY(lapic_nmi, end))
  236. return -EINVAL;
  237. acpi_table_print_madt_entry(header);
  238. if (lapic_nmi->lint != 1)
  239. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  240. return 0;
  241. }
  242. #endif /*CONFIG_X86_LOCAL_APIC*/
  243. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
  244. static int __init
  245. acpi_parse_ioapic (
  246. 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 (
  254. ioapic->id,
  255. ioapic->address,
  256. ioapic->global_irq_base);
  257. return 0;
  258. }
  259. /*
  260. * Parse Interrupt Source Override for the ACPI SCI
  261. */
  262. static void
  263. acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  264. {
  265. if (trigger == 0) /* compatible SCI trigger is level */
  266. trigger = 3;
  267. if (polarity == 0) /* compatible SCI polarity is low */
  268. polarity = 3;
  269. /* Command-line over-ride via acpi_sci= */
  270. if (acpi_sci_flags.trigger)
  271. trigger = acpi_sci_flags.trigger;
  272. if (acpi_sci_flags.polarity)
  273. polarity = acpi_sci_flags.polarity;
  274. /*
  275. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  276. * If GSI is < 16, this will update its flags,
  277. * else it will create a new mp_irqs[] entry.
  278. */
  279. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  280. /*
  281. * stash over-ride to indicate we've been here
  282. * and for later update of acpi_fadt
  283. */
  284. acpi_sci_override_gsi = gsi;
  285. return;
  286. }
  287. static int __init
  288. acpi_parse_int_src_ovr (
  289. acpi_table_entry_header *header, const unsigned long end)
  290. {
  291. struct acpi_table_int_src_ovr *intsrc = NULL;
  292. intsrc = (struct acpi_table_int_src_ovr*) header;
  293. if (BAD_MADT_ENTRY(intsrc, end))
  294. return -EINVAL;
  295. acpi_table_print_madt_entry(header);
  296. if (intsrc->bus_irq == acpi_fadt.sci_int) {
  297. acpi_sci_ioapic_setup(intsrc->global_irq,
  298. intsrc->flags.polarity, 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 (
  307. intsrc->bus_irq,
  308. intsrc->flags.polarity,
  309. intsrc->flags.trigger,
  310. intsrc->global_irq);
  311. return 0;
  312. }
  313. static int __init
  314. acpi_parse_nmi_src (
  315. acpi_table_entry_header *header, const unsigned long end)
  316. {
  317. struct acpi_table_nmi_src *nmi_src = NULL;
  318. nmi_src = (struct acpi_table_nmi_src*) header;
  319. if (BAD_MADT_ENTRY(nmi_src, end))
  320. return -EINVAL;
  321. acpi_table_print_madt_entry(header);
  322. /* TBD: Support nimsrc entries? */
  323. return 0;
  324. }
  325. #endif /* CONFIG_X86_IO_APIC */
  326. #ifdef CONFIG_ACPI_BUS
  327. /*
  328. * acpi_pic_sci_set_trigger()
  329. *
  330. * use ELCR to set PIC-mode trigger type for SCI
  331. *
  332. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  333. * it may require Edge Trigger -- use "acpi_sci=edge"
  334. *
  335. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  336. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  337. * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
  338. * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
  339. */
  340. void __init
  341. acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  342. {
  343. unsigned int mask = 1 << irq;
  344. unsigned int old, new;
  345. /* Real old ELCR mask */
  346. old = inb(0x4d0) | (inb(0x4d1) << 8);
  347. /*
  348. * If we use ACPI to set PCI irq's, then we should clear ELCR
  349. * since we will set it correctly as we enable the PCI irq
  350. * routing.
  351. */
  352. new = acpi_noirq ? old : 0;
  353. /*
  354. * Update SCI information in the ELCR, it isn't in the PCI
  355. * routing tables..
  356. */
  357. switch (trigger) {
  358. case 1: /* Edge - clear */
  359. new &= ~mask;
  360. break;
  361. case 3: /* Level - set */
  362. new |= mask;
  363. break;
  364. }
  365. if (old == new)
  366. return;
  367. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  368. outb(new, 0x4d0);
  369. outb(new >> 8, 0x4d1);
  370. }
  371. #endif /* CONFIG_ACPI_BUS */
  372. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  373. {
  374. #ifdef CONFIG_X86_IO_APIC
  375. if (use_pci_vector() && !platform_legacy_irq(gsi))
  376. *irq = IO_APIC_VECTOR(gsi);
  377. else
  378. #endif
  379. *irq = gsi;
  380. return 0;
  381. }
  382. /*
  383. * success: return IRQ number (>=0)
  384. * failure: return < 0
  385. */
  386. int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
  387. {
  388. unsigned int irq;
  389. unsigned int plat_gsi = gsi;
  390. #ifdef CONFIG_PCI
  391. /*
  392. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  393. */
  394. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  395. extern void eisa_set_level_irq(unsigned int irq);
  396. if (edge_level == ACPI_LEVEL_SENSITIVE)
  397. eisa_set_level_irq(gsi);
  398. }
  399. #endif
  400. #ifdef CONFIG_X86_IO_APIC
  401. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  402. plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
  403. }
  404. #endif
  405. acpi_gsi_to_irq(plat_gsi, &irq);
  406. return irq;
  407. }
  408. EXPORT_SYMBOL(acpi_register_gsi);
  409. /*
  410. * ACPI based hotplug support for CPU
  411. */
  412. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  413. int
  414. acpi_map_lsapic(acpi_handle handle, int *pcpu)
  415. {
  416. /* TBD */
  417. return -EINVAL;
  418. }
  419. EXPORT_SYMBOL(acpi_map_lsapic);
  420. int
  421. acpi_unmap_lsapic(int cpu)
  422. {
  423. /* TBD */
  424. return -EINVAL;
  425. }
  426. EXPORT_SYMBOL(acpi_unmap_lsapic);
  427. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  428. int
  429. acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  430. {
  431. /* TBD */
  432. return -EINVAL;
  433. }
  434. EXPORT_SYMBOL(acpi_register_ioapic);
  435. int
  436. acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  437. {
  438. /* TBD */
  439. return -EINVAL;
  440. }
  441. EXPORT_SYMBOL(acpi_unregister_ioapic);
  442. static unsigned long __init
  443. acpi_scan_rsdp (
  444. unsigned long start,
  445. unsigned long length)
  446. {
  447. unsigned long offset = 0;
  448. unsigned long sig_len = sizeof("RSD PTR ") - 1;
  449. /*
  450. * Scan all 16-byte boundaries of the physical memory region for the
  451. * RSDP signature.
  452. */
  453. for (offset = 0; offset < length; offset += 16) {
  454. if (strncmp((char *) (start + offset), "RSD PTR ", sig_len))
  455. continue;
  456. return (start + offset);
  457. }
  458. return 0;
  459. }
  460. static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
  461. {
  462. struct acpi_table_sbf *sb;
  463. if (!phys_addr || !size)
  464. return -EINVAL;
  465. sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size);
  466. if (!sb) {
  467. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  468. return -ENODEV;
  469. }
  470. sbf_port = sb->sbf_cmos; /* Save CMOS port */
  471. return 0;
  472. }
  473. #ifdef CONFIG_HPET_TIMER
  474. static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
  475. {
  476. struct acpi_table_hpet *hpet_tbl;
  477. if (!phys || !size)
  478. return -EINVAL;
  479. hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size);
  480. if (!hpet_tbl) {
  481. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  482. return -ENODEV;
  483. }
  484. if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
  485. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  486. "memory.\n");
  487. return -1;
  488. }
  489. #ifdef CONFIG_X86_64
  490. vxtime.hpet_address = hpet_tbl->addr.addrl |
  491. ((long) hpet_tbl->addr.addrh << 32);
  492. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  493. hpet_tbl->id, vxtime.hpet_address);
  494. #else /* X86 */
  495. {
  496. extern unsigned long hpet_address;
  497. hpet_address = hpet_tbl->addr.addrl;
  498. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  499. hpet_tbl->id, hpet_address);
  500. }
  501. #endif /* X86 */
  502. return 0;
  503. }
  504. #else
  505. #define acpi_parse_hpet NULL
  506. #endif
  507. #ifdef CONFIG_X86_PM_TIMER
  508. extern u32 pmtmr_ioport;
  509. #endif
  510. static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
  511. {
  512. struct fadt_descriptor_rev2 *fadt = NULL;
  513. fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size);
  514. if(!fadt) {
  515. printk(KERN_WARNING PREFIX "Unable to map FADT\n");
  516. return 0;
  517. }
  518. #ifdef CONFIG_ACPI_INTERPRETER
  519. /* initialize sci_int early for INT_SRC_OVR MADT parsing */
  520. acpi_fadt.sci_int = fadt->sci_int;
  521. #endif
  522. #ifdef CONFIG_ACPI_BUS
  523. /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
  524. acpi_fadt.revision = fadt->revision;
  525. acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode;
  526. #endif
  527. #ifdef CONFIG_X86_PM_TIMER
  528. /* detect the location of the ACPI PM Timer */
  529. if (fadt->revision >= FADT2_REVISION_ID) {
  530. /* FADT rev. 2 */
  531. if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO)
  532. return 0;
  533. pmtmr_ioport = fadt->xpm_tmr_blk.address;
  534. } else {
  535. /* FADT rev. 1 */
  536. pmtmr_ioport = fadt->V1_pm_tmr_blk;
  537. }
  538. if (pmtmr_ioport)
  539. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport);
  540. #endif
  541. return 0;
  542. }
  543. unsigned long __init
  544. acpi_find_rsdp (void)
  545. {
  546. unsigned long rsdp_phys = 0;
  547. if (efi_enabled) {
  548. if (efi.acpi20)
  549. return __pa(efi.acpi20);
  550. else if (efi.acpi)
  551. return __pa(efi.acpi);
  552. }
  553. /*
  554. * Scan memory looking for the RSDP signature. First search EBDA (low
  555. * memory) paragraphs and then search upper memory (E0000-FFFFF).
  556. */
  557. rsdp_phys = acpi_scan_rsdp (0, 0x400);
  558. if (!rsdp_phys)
  559. rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000);
  560. return rsdp_phys;
  561. }
  562. #ifdef CONFIG_X86_LOCAL_APIC
  563. /*
  564. * Parse LAPIC entries in MADT
  565. * returns 0 on success, < 0 on error
  566. */
  567. static int __init
  568. acpi_parse_madt_lapic_entries(void)
  569. {
  570. int count;
  571. /*
  572. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  573. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  574. */
  575. count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0);
  576. if (count < 0) {
  577. printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
  578. return count;
  579. }
  580. mp_register_lapic_address(acpi_lapic_addr);
  581. count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
  582. MAX_APICS);
  583. if (!count) {
  584. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  585. /* TBD: Cleanup to allow fallback to MPS */
  586. return -ENODEV;
  587. }
  588. else if (count < 0) {
  589. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  590. /* TBD: Cleanup to allow fallback to MPS */
  591. return count;
  592. }
  593. count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
  594. if (count < 0) {
  595. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  596. /* TBD: Cleanup to allow fallback to MPS */
  597. return count;
  598. }
  599. return 0;
  600. }
  601. #endif /* CONFIG_X86_LOCAL_APIC */
  602. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
  603. /*
  604. * Parse IOAPIC related entries in MADT
  605. * returns 0 on success, < 0 on error
  606. */
  607. static int __init
  608. acpi_parse_madt_ioapic_entries(void)
  609. {
  610. int count;
  611. /*
  612. * ACPI interpreter is required to complete interrupt setup,
  613. * so if it is off, don't enumerate the io-apics with ACPI.
  614. * If MPS is present, it will handle them,
  615. * otherwise the system will stay in PIC mode
  616. */
  617. if (acpi_disabled || acpi_noirq) {
  618. return -ENODEV;
  619. }
  620. /*
  621. * if "noapic" boot option, don't look for IO-APICs
  622. */
  623. if (skip_ioapic_setup) {
  624. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  625. "due to 'noapic' option.\n");
  626. return -ENODEV;
  627. }
  628. count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS);
  629. if (!count) {
  630. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  631. return -ENODEV;
  632. }
  633. else if (count < 0) {
  634. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  635. return count;
  636. }
  637. count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS);
  638. if (count < 0) {
  639. printk(KERN_ERR PREFIX "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 = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS);
  652. if (count < 0) {
  653. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  654. /* TBD: Cleanup to allow fallback to MPS */
  655. return count;
  656. }
  657. return 0;
  658. }
  659. #else
  660. static inline int acpi_parse_madt_ioapic_entries(void)
  661. {
  662. return -1;
  663. }
  664. #endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */
  665. static void __init
  666. acpi_process_madt(void)
  667. {
  668. #ifdef CONFIG_X86_LOCAL_APIC
  669. int count, error;
  670. count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
  671. if (count >= 1) {
  672. /*
  673. * Parse MADT LAPIC entries
  674. */
  675. error = acpi_parse_madt_lapic_entries();
  676. if (!error) {
  677. acpi_lapic = 1;
  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 "Invalid BIOS MADT, disabling ACPI\n");
  695. disable_acpi();
  696. }
  697. }
  698. #endif
  699. return;
  700. }
  701. extern int acpi_force;
  702. #ifdef __i386__
  703. #ifdef CONFIG_ACPI_PCI
  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. #endif
  723. static int __init dmi_disable_acpi(struct dmi_system_id *d)
  724. {
  725. if (!acpi_force) {
  726. printk(KERN_NOTICE "%s detected: acpi off\n",d->ident);
  727. disable_acpi();
  728. } else {
  729. printk(KERN_NOTICE
  730. "Warning: DMI blacklist says broken, but acpi forced\n");
  731. }
  732. return 0;
  733. }
  734. /*
  735. * Limit ACPI to CPU enumeration for HT
  736. */
  737. static int __init force_acpi_ht(struct dmi_system_id *d)
  738. {
  739. if (!acpi_force) {
  740. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", 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. #ifdef CONFIG_ACPI_PCI
  865. /*
  866. * Boxes that need ACPI PCI IRQ routing disabled
  867. */
  868. {
  869. .callback = disable_acpi_irq,
  870. .ident = "ASUS A7V",
  871. .matches = {
  872. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  873. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  874. /* newer BIOS, Revision 1011, does work */
  875. DMI_MATCH(DMI_BIOS_VERSION, "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, "ASUS PR-DLS ACPI BIOS Revision 1010"),
  888. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  889. },
  890. },
  891. {
  892. .callback = disable_acpi_pci,
  893. .ident = "Acer TravelMate 36x Laptop",
  894. .matches = {
  895. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  896. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  897. },
  898. },
  899. #endif
  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
  926. acpi_boot_table_init(void)
  927. {
  928. int error;
  929. #ifdef __i386__
  930. dmi_check_system(acpi_dmi_table);
  931. #endif
  932. /*
  933. * If acpi_disabled, bail out
  934. * One exception: acpi=ht continues far enough to enumerate LAPICs
  935. */
  936. if (acpi_disabled && !acpi_ht)
  937. return 1;
  938. /*
  939. * Initialize the ACPI boot-time table parser.
  940. */
  941. error = acpi_table_init();
  942. if (error) {
  943. disable_acpi();
  944. return error;
  945. }
  946. #ifdef __i386__
  947. check_acpi_pci();
  948. #endif
  949. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  950. /*
  951. * blacklist may disable ACPI entirely
  952. */
  953. error = acpi_blacklisted();
  954. if (error) {
  955. if (acpi_force) {
  956. printk(KERN_WARNING PREFIX "acpi=force override\n");
  957. } else {
  958. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  959. disable_acpi();
  960. return error;
  961. }
  962. }
  963. return 0;
  964. }
  965. int __init acpi_boot_init(void)
  966. {
  967. /*
  968. * If acpi_disabled, bail out
  969. * One exception: acpi=ht continues far enough to enumerate LAPICs
  970. */
  971. if (acpi_disabled && !acpi_ht)
  972. return 1;
  973. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  974. /*
  975. * set sci_int and PM timer address
  976. */
  977. acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
  978. /*
  979. * Process the Multiple APIC Description Table (MADT), if present
  980. */
  981. acpi_process_madt();
  982. acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
  983. return 0;
  984. }