boot.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445
  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/acpi_pmtmr.h>
  28. #include <linux/efi.h>
  29. #include <linux/cpumask.h>
  30. #include <linux/module.h>
  31. #include <linux/dmi.h>
  32. #include <linux/irq.h>
  33. #include <linux/bootmem.h>
  34. #include <linux/ioport.h>
  35. #include <asm/pgtable.h>
  36. #include <asm/io_apic.h>
  37. #include <asm/apic.h>
  38. #include <asm/io.h>
  39. #include <asm/mpspec.h>
  40. #include <asm/smp.h>
  41. #ifdef CONFIG_X86_LOCAL_APIC
  42. # include <mach_apic.h>
  43. #endif
  44. static int __initdata acpi_force = 0;
  45. #ifdef CONFIG_ACPI
  46. int acpi_disabled = 0;
  47. #else
  48. int acpi_disabled = 1;
  49. #endif
  50. EXPORT_SYMBOL(acpi_disabled);
  51. #ifdef CONFIG_X86_64
  52. #include <asm/proto.h>
  53. #include <asm/genapic.h>
  54. #else /* X86 */
  55. #ifdef CONFIG_X86_LOCAL_APIC
  56. #include <mach_apic.h>
  57. #include <mach_mpparse.h>
  58. #endif /* CONFIG_X86_LOCAL_APIC */
  59. #endif /* X86 */
  60. #define BAD_MADT_ENTRY(entry, end) ( \
  61. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  62. ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
  63. #define PREFIX "ACPI: "
  64. int acpi_noirq; /* skip ACPI IRQ initialization */
  65. int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
  66. EXPORT_SYMBOL(acpi_pci_disabled);
  67. int acpi_ht __initdata = 1; /* enable HT */
  68. int acpi_lapic;
  69. int acpi_ioapic;
  70. int acpi_strict;
  71. u8 acpi_sci_flags __initdata;
  72. int acpi_sci_override_gsi __initdata;
  73. int acpi_skip_timer_override __initdata;
  74. int acpi_use_timer_override __initdata;
  75. #ifdef CONFIG_X86_LOCAL_APIC
  76. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  77. #endif
  78. #ifndef __HAVE_ARCH_CMPXCHG
  79. #warning ACPI uses CMPXCHG, i486 and later hardware
  80. #endif
  81. /* --------------------------------------------------------------------------
  82. Boot-time Configuration
  83. -------------------------------------------------------------------------- */
  84. /*
  85. * The default interrupt routing model is PIC (8259). This gets
  86. * overridden if IOAPICs are enumerated (below).
  87. */
  88. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  89. #ifdef CONFIG_X86_64
  90. /* rely on all ACPI tables being in the direct mapping */
  91. char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
  92. {
  93. if (!phys_addr || !size)
  94. return NULL;
  95. if (phys_addr+size <= (max_pfn_mapped << PAGE_SHIFT) + PAGE_SIZE)
  96. return __va(phys_addr);
  97. return NULL;
  98. }
  99. #else
  100. /*
  101. * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  102. * to map the target physical address. The problem is that set_fixmap()
  103. * provides a single page, and it is possible that the page is not
  104. * sufficient.
  105. * By using this area, we can map up to MAX_IO_APICS pages temporarily,
  106. * i.e. until the next __va_range() call.
  107. *
  108. * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
  109. * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
  110. * count idx down while incrementing the phys address.
  111. */
  112. char *__init __acpi_map_table(unsigned long phys, unsigned long size)
  113. {
  114. unsigned long base, offset, mapped_size;
  115. int idx;
  116. if (phys + size < 8 * 1024 * 1024)
  117. return __va(phys);
  118. offset = phys & (PAGE_SIZE - 1);
  119. mapped_size = PAGE_SIZE - offset;
  120. set_fixmap(FIX_ACPI_END, phys);
  121. base = fix_to_virt(FIX_ACPI_END);
  122. /*
  123. * Most cases can be covered by the below.
  124. */
  125. idx = FIX_ACPI_END;
  126. while (mapped_size < size) {
  127. if (--idx < FIX_ACPI_BEGIN)
  128. return NULL; /* cannot handle this */
  129. phys += PAGE_SIZE;
  130. set_fixmap(idx, phys);
  131. mapped_size += PAGE_SIZE;
  132. }
  133. return ((unsigned char *)base + offset);
  134. }
  135. #endif
  136. #ifdef CONFIG_PCI_MMCONFIG
  137. /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
  138. struct acpi_mcfg_allocation *pci_mmcfg_config;
  139. int pci_mmcfg_config_num;
  140. int __init acpi_parse_mcfg(struct acpi_table_header *header)
  141. {
  142. struct acpi_table_mcfg *mcfg;
  143. unsigned long i;
  144. int config_size;
  145. if (!header)
  146. return -EINVAL;
  147. mcfg = (struct acpi_table_mcfg *)header;
  148. /* how many config structures do we have */
  149. pci_mmcfg_config_num = 0;
  150. i = header->length - sizeof(struct acpi_table_mcfg);
  151. while (i >= sizeof(struct acpi_mcfg_allocation)) {
  152. ++pci_mmcfg_config_num;
  153. i -= sizeof(struct acpi_mcfg_allocation);
  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[1], config_size);
  167. for (i = 0; i < pci_mmcfg_config_num; ++i) {
  168. if (pci_mmcfg_config[i].address > 0xFFFFFFFF) {
  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(struct acpi_table_header *table)
  181. {
  182. struct acpi_table_madt *madt = NULL;
  183. if (!cpu_has_apic)
  184. return -EINVAL;
  185. madt = (struct acpi_table_madt *)table;
  186. if (!madt) {
  187. printk(KERN_WARNING PREFIX "Unable to map MADT\n");
  188. return -ENODEV;
  189. }
  190. if (madt->address) {
  191. acpi_lapic_addr = (u64) madt->address;
  192. printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
  193. madt->address);
  194. }
  195. acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
  196. return 0;
  197. }
  198. static void __cpuinit acpi_register_lapic(int id, u8 enabled)
  199. {
  200. unsigned int ver = 0;
  201. if (!enabled) {
  202. ++disabled_cpus;
  203. return;
  204. }
  205. #ifdef CONFIG_X86_32
  206. if (boot_cpu_physical_apicid != -1U)
  207. ver = apic_version[boot_cpu_physical_apicid];
  208. #endif
  209. generic_processor_info(id, ver);
  210. }
  211. static int __init
  212. acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
  213. {
  214. struct acpi_madt_local_apic *processor = NULL;
  215. processor = (struct acpi_madt_local_apic *)header;
  216. if (BAD_MADT_ENTRY(processor, end))
  217. return -EINVAL;
  218. acpi_table_print_madt_entry(header);
  219. /*
  220. * We need to register disabled CPU as well to permit
  221. * counting disabled CPUs. This allows us to size
  222. * cpus_possible_map more accurately, to permit
  223. * to not preallocating memory for all NR_CPUS
  224. * when we use CPU hotplug.
  225. */
  226. acpi_register_lapic(processor->id, /* APIC ID */
  227. processor->lapic_flags & ACPI_MADT_ENABLED);
  228. return 0;
  229. }
  230. static int __init
  231. acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
  232. {
  233. struct acpi_madt_local_sapic *processor = NULL;
  234. processor = (struct acpi_madt_local_sapic *)header;
  235. if (BAD_MADT_ENTRY(processor, end))
  236. return -EINVAL;
  237. acpi_table_print_madt_entry(header);
  238. acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
  239. processor->lapic_flags & ACPI_MADT_ENABLED);
  240. return 0;
  241. }
  242. static int __init
  243. acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
  244. const unsigned long end)
  245. {
  246. struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
  247. lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
  248. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  249. return -EINVAL;
  250. acpi_lapic_addr = lapic_addr_ovr->address;
  251. return 0;
  252. }
  253. static int __init
  254. acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
  255. {
  256. struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
  257. lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
  258. if (BAD_MADT_ENTRY(lapic_nmi, end))
  259. return -EINVAL;
  260. acpi_table_print_madt_entry(header);
  261. if (lapic_nmi->lint != 1)
  262. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  263. return 0;
  264. }
  265. #endif /*CONFIG_X86_LOCAL_APIC */
  266. #ifdef CONFIG_X86_IO_APIC
  267. struct mp_ioapic_routing mp_ioapic_routing[MAX_IO_APICS];
  268. static int __init
  269. acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
  270. {
  271. struct acpi_madt_io_apic *ioapic = NULL;
  272. ioapic = (struct acpi_madt_io_apic *)header;
  273. if (BAD_MADT_ENTRY(ioapic, end))
  274. return -EINVAL;
  275. acpi_table_print_madt_entry(header);
  276. mp_register_ioapic(ioapic->id,
  277. ioapic->address, ioapic->global_irq_base);
  278. return 0;
  279. }
  280. /*
  281. * Parse Interrupt Source Override for the ACPI SCI
  282. */
  283. static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  284. {
  285. if (trigger == 0) /* compatible SCI trigger is level */
  286. trigger = 3;
  287. if (polarity == 0) /* compatible SCI polarity is low */
  288. polarity = 3;
  289. /* Command-line over-ride via acpi_sci= */
  290. if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
  291. trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
  292. if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
  293. polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
  294. /*
  295. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  296. * If GSI is < 16, this will update its flags,
  297. * else it will create a new mp_irqs[] entry.
  298. */
  299. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  300. /*
  301. * stash over-ride to indicate we've been here
  302. * and for later update of acpi_gbl_FADT
  303. */
  304. acpi_sci_override_gsi = gsi;
  305. return;
  306. }
  307. static int __init
  308. acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
  309. const unsigned long end)
  310. {
  311. struct acpi_madt_interrupt_override *intsrc = NULL;
  312. intsrc = (struct acpi_madt_interrupt_override *)header;
  313. if (BAD_MADT_ENTRY(intsrc, end))
  314. return -EINVAL;
  315. acpi_table_print_madt_entry(header);
  316. if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
  317. acpi_sci_ioapic_setup(intsrc->global_irq,
  318. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  319. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
  320. return 0;
  321. }
  322. if (acpi_skip_timer_override &&
  323. intsrc->source_irq == 0 && intsrc->global_irq == 2) {
  324. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  325. return 0;
  326. }
  327. mp_override_legacy_irq(intsrc->source_irq,
  328. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  329. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
  330. intsrc->global_irq);
  331. return 0;
  332. }
  333. static int __init
  334. acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
  335. {
  336. struct acpi_madt_nmi_source *nmi_src = NULL;
  337. nmi_src = (struct acpi_madt_nmi_source *)header;
  338. if (BAD_MADT_ENTRY(nmi_src, end))
  339. return -EINVAL;
  340. acpi_table_print_madt_entry(header);
  341. /* TBD: Support nimsrc entries? */
  342. return 0;
  343. }
  344. #endif /* CONFIG_X86_IO_APIC */
  345. /*
  346. * acpi_pic_sci_set_trigger()
  347. *
  348. * use ELCR to set PIC-mode trigger type for SCI
  349. *
  350. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  351. * it may require Edge Trigger -- use "acpi_sci=edge"
  352. *
  353. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  354. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  355. * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
  356. * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
  357. */
  358. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  359. {
  360. unsigned int mask = 1 << irq;
  361. unsigned int old, new;
  362. /* Real old ELCR mask */
  363. old = inb(0x4d0) | (inb(0x4d1) << 8);
  364. /*
  365. * If we use ACPI to set PCI IRQs, then we should clear ELCR
  366. * since we will set it correctly as we enable the PCI irq
  367. * routing.
  368. */
  369. new = acpi_noirq ? old : 0;
  370. /*
  371. * Update SCI information in the ELCR, it isn't in the PCI
  372. * routing tables..
  373. */
  374. switch (trigger) {
  375. case 1: /* Edge - clear */
  376. new &= ~mask;
  377. break;
  378. case 3: /* Level - set */
  379. new |= mask;
  380. break;
  381. }
  382. if (old == new)
  383. return;
  384. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  385. outb(new, 0x4d0);
  386. outb(new >> 8, 0x4d1);
  387. }
  388. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  389. {
  390. *irq = gsi;
  391. return 0;
  392. }
  393. /*
  394. * success: return IRQ number (>=0)
  395. * failure: return < 0
  396. */
  397. int acpi_register_gsi(u32 gsi, int triggering, int polarity)
  398. {
  399. unsigned int irq;
  400. unsigned int plat_gsi = gsi;
  401. #ifdef CONFIG_PCI
  402. /*
  403. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  404. */
  405. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  406. if (triggering == ACPI_LEVEL_SENSITIVE)
  407. eisa_set_level_irq(gsi);
  408. }
  409. #endif
  410. #ifdef CONFIG_X86_IO_APIC
  411. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  412. plat_gsi = mp_register_gsi(gsi, triggering, polarity);
  413. }
  414. #endif
  415. acpi_gsi_to_irq(plat_gsi, &irq);
  416. return irq;
  417. }
  418. /*
  419. * ACPI based hotplug support for CPU
  420. */
  421. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  422. static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
  423. {
  424. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  425. union acpi_object *obj;
  426. struct acpi_madt_local_apic *lapic;
  427. cpumask_t tmp_map, new_map;
  428. u8 physid;
  429. int cpu;
  430. if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
  431. return -EINVAL;
  432. if (!buffer.length || !buffer.pointer)
  433. return -EINVAL;
  434. obj = buffer.pointer;
  435. if (obj->type != ACPI_TYPE_BUFFER ||
  436. obj->buffer.length < sizeof(*lapic)) {
  437. kfree(buffer.pointer);
  438. return -EINVAL;
  439. }
  440. lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
  441. if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
  442. !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
  443. kfree(buffer.pointer);
  444. return -EINVAL;
  445. }
  446. physid = lapic->id;
  447. kfree(buffer.pointer);
  448. buffer.length = ACPI_ALLOCATE_BUFFER;
  449. buffer.pointer = NULL;
  450. tmp_map = cpu_present_map;
  451. acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
  452. /*
  453. * If mp_register_lapic successfully generates a new logical cpu
  454. * number, then the following will get us exactly what was mapped
  455. */
  456. cpus_andnot(new_map, cpu_present_map, tmp_map);
  457. if (cpus_empty(new_map)) {
  458. printk ("Unable to map lapic to logical cpu number\n");
  459. return -EINVAL;
  460. }
  461. cpu = first_cpu(new_map);
  462. *pcpu = cpu;
  463. return 0;
  464. }
  465. /* wrapper to silence section mismatch warning */
  466. int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
  467. {
  468. return _acpi_map_lsapic(handle, pcpu);
  469. }
  470. EXPORT_SYMBOL(acpi_map_lsapic);
  471. int acpi_unmap_lsapic(int cpu)
  472. {
  473. per_cpu(x86_cpu_to_apicid, cpu) = -1;
  474. cpu_clear(cpu, cpu_present_map);
  475. num_processors--;
  476. return (0);
  477. }
  478. EXPORT_SYMBOL(acpi_unmap_lsapic);
  479. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  480. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  481. {
  482. /* TBD */
  483. return -EINVAL;
  484. }
  485. EXPORT_SYMBOL(acpi_register_ioapic);
  486. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  487. {
  488. /* TBD */
  489. return -EINVAL;
  490. }
  491. EXPORT_SYMBOL(acpi_unregister_ioapic);
  492. static int __init acpi_parse_sbf(struct acpi_table_header *table)
  493. {
  494. struct acpi_table_boot *sb;
  495. sb = (struct acpi_table_boot *)table;
  496. if (!sb) {
  497. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  498. return -ENODEV;
  499. }
  500. sbf_port = sb->cmos_index; /* Save CMOS port */
  501. return 0;
  502. }
  503. #ifdef CONFIG_HPET_TIMER
  504. #include <asm/hpet.h>
  505. static struct __initdata resource *hpet_res;
  506. static int __init acpi_parse_hpet(struct acpi_table_header *table)
  507. {
  508. struct acpi_table_hpet *hpet_tbl;
  509. hpet_tbl = (struct acpi_table_hpet *)table;
  510. if (!hpet_tbl) {
  511. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  512. return -ENODEV;
  513. }
  514. if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
  515. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  516. "memory.\n");
  517. return -1;
  518. }
  519. hpet_address = hpet_tbl->address.address;
  520. /*
  521. * Some broken BIOSes advertise HPET at 0x0. We really do not
  522. * want to allocate a resource there.
  523. */
  524. if (!hpet_address) {
  525. printk(KERN_WARNING PREFIX
  526. "HPET id: %#x base: %#lx is invalid\n",
  527. hpet_tbl->id, hpet_address);
  528. return 0;
  529. }
  530. #ifdef CONFIG_X86_64
  531. /*
  532. * Some even more broken BIOSes advertise HPET at
  533. * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
  534. * some noise:
  535. */
  536. if (hpet_address == 0xfed0000000000000UL) {
  537. if (!hpet_force_user) {
  538. printk(KERN_WARNING PREFIX "HPET id: %#x "
  539. "base: 0xfed0000000000000 is bogus\n "
  540. "try hpet=force on the kernel command line to "
  541. "fix it up to 0xfed00000.\n", hpet_tbl->id);
  542. hpet_address = 0;
  543. return 0;
  544. }
  545. printk(KERN_WARNING PREFIX
  546. "HPET id: %#x base: 0xfed0000000000000 fixed up "
  547. "to 0xfed00000.\n", hpet_tbl->id);
  548. hpet_address >>= 32;
  549. }
  550. #endif
  551. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  552. hpet_tbl->id, hpet_address);
  553. /*
  554. * Allocate and initialize the HPET firmware resource for adding into
  555. * the resource tree during the lateinit timeframe.
  556. */
  557. #define HPET_RESOURCE_NAME_SIZE 9
  558. hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
  559. hpet_res->name = (void *)&hpet_res[1];
  560. hpet_res->flags = IORESOURCE_MEM;
  561. snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
  562. hpet_tbl->sequence);
  563. hpet_res->start = hpet_address;
  564. hpet_res->end = hpet_address + (1 * 1024) - 1;
  565. return 0;
  566. }
  567. /*
  568. * hpet_insert_resource inserts the HPET resources used into the resource
  569. * tree.
  570. */
  571. static __init int hpet_insert_resource(void)
  572. {
  573. if (!hpet_res)
  574. return 1;
  575. return insert_resource(&iomem_resource, hpet_res);
  576. }
  577. late_initcall(hpet_insert_resource);
  578. #else
  579. #define acpi_parse_hpet NULL
  580. #endif
  581. static int __init acpi_parse_fadt(struct acpi_table_header *table)
  582. {
  583. #ifdef CONFIG_X86_PM_TIMER
  584. /* detect the location of the ACPI PM Timer */
  585. if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
  586. /* FADT rev. 2 */
  587. if (acpi_gbl_FADT.xpm_timer_block.space_id !=
  588. ACPI_ADR_SPACE_SYSTEM_IO)
  589. return 0;
  590. pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
  591. /*
  592. * "X" fields are optional extensions to the original V1.0
  593. * fields, so we must selectively expand V1.0 fields if the
  594. * corresponding X field is zero.
  595. */
  596. if (!pmtmr_ioport)
  597. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  598. } else {
  599. /* FADT rev. 1 */
  600. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  601. }
  602. if (pmtmr_ioport)
  603. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  604. pmtmr_ioport);
  605. #endif
  606. return 0;
  607. }
  608. #ifdef CONFIG_X86_LOCAL_APIC
  609. /*
  610. * Parse LAPIC entries in MADT
  611. * returns 0 on success, < 0 on error
  612. */
  613. static void __init acpi_register_lapic_address(unsigned long address)
  614. {
  615. mp_lapic_addr = address;
  616. set_fixmap_nocache(FIX_APIC_BASE, address);
  617. if (boot_cpu_physical_apicid == -1U) {
  618. boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id());
  619. #ifdef CONFIG_X86_32
  620. apic_version[boot_cpu_physical_apicid] =
  621. GET_APIC_VERSION(apic_read(APIC_LVR));
  622. #endif
  623. }
  624. }
  625. static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
  626. {
  627. int count;
  628. if (!cpu_has_apic)
  629. return -ENODEV;
  630. /*
  631. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  632. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  633. */
  634. count =
  635. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  636. acpi_parse_lapic_addr_ovr, 0);
  637. if (count < 0) {
  638. printk(KERN_ERR PREFIX
  639. "Error parsing LAPIC address override entry\n");
  640. return count;
  641. }
  642. acpi_register_lapic_address(acpi_lapic_addr);
  643. return count;
  644. }
  645. static int __init acpi_parse_madt_lapic_entries(void)
  646. {
  647. int count;
  648. if (!cpu_has_apic)
  649. return -ENODEV;
  650. /*
  651. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  652. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  653. */
  654. count =
  655. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  656. acpi_parse_lapic_addr_ovr, 0);
  657. if (count < 0) {
  658. printk(KERN_ERR PREFIX
  659. "Error parsing LAPIC address override entry\n");
  660. return count;
  661. }
  662. acpi_register_lapic_address(acpi_lapic_addr);
  663. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
  664. acpi_parse_sapic, MAX_APICS);
  665. if (!count)
  666. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
  667. acpi_parse_lapic, MAX_APICS);
  668. if (!count) {
  669. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  670. /* TBD: Cleanup to allow fallback to MPS */
  671. return -ENODEV;
  672. } else if (count < 0) {
  673. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  674. /* TBD: Cleanup to allow fallback to MPS */
  675. return count;
  676. }
  677. count =
  678. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
  679. if (count < 0) {
  680. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  681. /* TBD: Cleanup to allow fallback to MPS */
  682. return count;
  683. }
  684. return 0;
  685. }
  686. #endif /* CONFIG_X86_LOCAL_APIC */
  687. #ifdef CONFIG_X86_IO_APIC
  688. /*
  689. * Parse IOAPIC related entries in MADT
  690. * returns 0 on success, < 0 on error
  691. */
  692. static int __init acpi_parse_madt_ioapic_entries(void)
  693. {
  694. int count;
  695. /*
  696. * ACPI interpreter is required to complete interrupt setup,
  697. * so if it is off, don't enumerate the io-apics with ACPI.
  698. * If MPS is present, it will handle them,
  699. * otherwise the system will stay in PIC mode
  700. */
  701. if (acpi_disabled || acpi_noirq) {
  702. return -ENODEV;
  703. }
  704. if (!cpu_has_apic)
  705. return -ENODEV;
  706. /*
  707. * if "noapic" boot option, don't look for IO-APICs
  708. */
  709. if (skip_ioapic_setup) {
  710. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  711. "due to 'noapic' option.\n");
  712. return -ENODEV;
  713. }
  714. count =
  715. acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
  716. MAX_IO_APICS);
  717. if (!count) {
  718. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  719. return -ENODEV;
  720. } else if (count < 0) {
  721. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  722. return count;
  723. }
  724. count =
  725. acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
  726. NR_IRQ_VECTORS);
  727. if (count < 0) {
  728. printk(KERN_ERR PREFIX
  729. "Error parsing interrupt source overrides entry\n");
  730. /* TBD: Cleanup to allow fallback to MPS */
  731. return count;
  732. }
  733. /*
  734. * If BIOS did not supply an INT_SRC_OVR for the SCI
  735. * pretend we got one so we can set the SCI flags.
  736. */
  737. if (!acpi_sci_override_gsi)
  738. acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
  739. /* Fill in identity legacy mapings where no override */
  740. mp_config_acpi_legacy_irqs();
  741. count =
  742. acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
  743. NR_IRQ_VECTORS);
  744. if (count < 0) {
  745. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  746. /* TBD: Cleanup to allow fallback to MPS */
  747. return count;
  748. }
  749. return 0;
  750. }
  751. #else
  752. static inline int acpi_parse_madt_ioapic_entries(void)
  753. {
  754. return -1;
  755. }
  756. #endif /* !CONFIG_X86_IO_APIC */
  757. static void __init early_acpi_process_madt(void)
  758. {
  759. #ifdef CONFIG_X86_LOCAL_APIC
  760. int error;
  761. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  762. /*
  763. * Parse MADT LAPIC entries
  764. */
  765. error = early_acpi_parse_madt_lapic_addr_ovr();
  766. if (!error) {
  767. acpi_lapic = 1;
  768. smp_found_config = 1;
  769. }
  770. if (error == -EINVAL) {
  771. /*
  772. * Dell Precision Workstation 410, 610 come here.
  773. */
  774. printk(KERN_ERR PREFIX
  775. "Invalid BIOS MADT, disabling ACPI\n");
  776. disable_acpi();
  777. }
  778. }
  779. #endif
  780. }
  781. static void __init acpi_process_madt(void)
  782. {
  783. #ifdef CONFIG_X86_LOCAL_APIC
  784. int error;
  785. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  786. /*
  787. * Parse MADT LAPIC entries
  788. */
  789. error = acpi_parse_madt_lapic_entries();
  790. if (!error) {
  791. acpi_lapic = 1;
  792. #ifdef CONFIG_X86_GENERICARCH
  793. generic_bigsmp_probe();
  794. #endif
  795. /*
  796. * Parse MADT IO-APIC entries
  797. */
  798. error = acpi_parse_madt_ioapic_entries();
  799. if (!error) {
  800. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  801. acpi_irq_balance_set(NULL);
  802. acpi_ioapic = 1;
  803. smp_found_config = 1;
  804. setup_apic_routing();
  805. }
  806. }
  807. if (error == -EINVAL) {
  808. /*
  809. * Dell Precision Workstation 410, 610 come here.
  810. */
  811. printk(KERN_ERR PREFIX
  812. "Invalid BIOS MADT, disabling ACPI\n");
  813. disable_acpi();
  814. }
  815. }
  816. #endif
  817. return;
  818. }
  819. #ifdef __i386__
  820. static int __init disable_acpi_irq(const struct dmi_system_id *d)
  821. {
  822. if (!acpi_force) {
  823. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  824. d->ident);
  825. acpi_noirq_set();
  826. }
  827. return 0;
  828. }
  829. static int __init disable_acpi_pci(const struct dmi_system_id *d)
  830. {
  831. if (!acpi_force) {
  832. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  833. d->ident);
  834. acpi_disable_pci();
  835. }
  836. return 0;
  837. }
  838. static int __init dmi_disable_acpi(const struct dmi_system_id *d)
  839. {
  840. if (!acpi_force) {
  841. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  842. disable_acpi();
  843. } else {
  844. printk(KERN_NOTICE
  845. "Warning: DMI blacklist says broken, but acpi forced\n");
  846. }
  847. return 0;
  848. }
  849. /*
  850. * Limit ACPI to CPU enumeration for HT
  851. */
  852. static int __init force_acpi_ht(const struct dmi_system_id *d)
  853. {
  854. if (!acpi_force) {
  855. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  856. d->ident);
  857. disable_acpi();
  858. acpi_ht = 1;
  859. } else {
  860. printk(KERN_NOTICE
  861. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  862. }
  863. return 0;
  864. }
  865. /*
  866. * If your system is blacklisted here, but you find that acpi=force
  867. * works for you, please contact acpi-devel@sourceforge.net
  868. */
  869. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  870. /*
  871. * Boxes that need ACPI disabled
  872. */
  873. {
  874. .callback = dmi_disable_acpi,
  875. .ident = "IBM Thinkpad",
  876. .matches = {
  877. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  878. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  879. },
  880. },
  881. /*
  882. * Boxes that need acpi=ht
  883. */
  884. {
  885. .callback = force_acpi_ht,
  886. .ident = "FSC Primergy T850",
  887. .matches = {
  888. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  889. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  890. },
  891. },
  892. {
  893. .callback = force_acpi_ht,
  894. .ident = "HP VISUALIZE NT Workstation",
  895. .matches = {
  896. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  897. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  898. },
  899. },
  900. {
  901. .callback = force_acpi_ht,
  902. .ident = "Compaq Workstation W8000",
  903. .matches = {
  904. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  905. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  906. },
  907. },
  908. {
  909. .callback = force_acpi_ht,
  910. .ident = "ASUS P4B266",
  911. .matches = {
  912. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  913. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  914. },
  915. },
  916. {
  917. .callback = force_acpi_ht,
  918. .ident = "ASUS P2B-DS",
  919. .matches = {
  920. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  921. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  922. },
  923. },
  924. {
  925. .callback = force_acpi_ht,
  926. .ident = "ASUS CUR-DLS",
  927. .matches = {
  928. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  929. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  930. },
  931. },
  932. {
  933. .callback = force_acpi_ht,
  934. .ident = "ABIT i440BX-W83977",
  935. .matches = {
  936. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  937. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  938. },
  939. },
  940. {
  941. .callback = force_acpi_ht,
  942. .ident = "IBM Bladecenter",
  943. .matches = {
  944. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  945. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  946. },
  947. },
  948. {
  949. .callback = force_acpi_ht,
  950. .ident = "IBM eServer xSeries 360",
  951. .matches = {
  952. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  953. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  954. },
  955. },
  956. {
  957. .callback = force_acpi_ht,
  958. .ident = "IBM eserver xSeries 330",
  959. .matches = {
  960. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  961. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  962. },
  963. },
  964. {
  965. .callback = force_acpi_ht,
  966. .ident = "IBM eserver xSeries 440",
  967. .matches = {
  968. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  969. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  970. },
  971. },
  972. /*
  973. * Boxes that need ACPI PCI IRQ routing disabled
  974. */
  975. {
  976. .callback = disable_acpi_irq,
  977. .ident = "ASUS A7V",
  978. .matches = {
  979. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  980. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  981. /* newer BIOS, Revision 1011, does work */
  982. DMI_MATCH(DMI_BIOS_VERSION,
  983. "ASUS A7V ACPI BIOS Revision 1007"),
  984. },
  985. },
  986. {
  987. /*
  988. * Latest BIOS for IBM 600E (1.16) has bad pcinum
  989. * for LPC bridge, which is needed for the PCI
  990. * interrupt links to work. DSDT fix is in bug 5966.
  991. * 2645, 2646 model numbers are shared with 600/600E/600X
  992. */
  993. .callback = disable_acpi_irq,
  994. .ident = "IBM Thinkpad 600 Series 2645",
  995. .matches = {
  996. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  997. DMI_MATCH(DMI_BOARD_NAME, "2645"),
  998. },
  999. },
  1000. {
  1001. .callback = disable_acpi_irq,
  1002. .ident = "IBM Thinkpad 600 Series 2646",
  1003. .matches = {
  1004. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1005. DMI_MATCH(DMI_BOARD_NAME, "2646"),
  1006. },
  1007. },
  1008. /*
  1009. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  1010. */
  1011. { /* _BBN 0 bug */
  1012. .callback = disable_acpi_pci,
  1013. .ident = "ASUS PR-DLS",
  1014. .matches = {
  1015. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1016. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  1017. DMI_MATCH(DMI_BIOS_VERSION,
  1018. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  1019. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  1020. },
  1021. },
  1022. {
  1023. .callback = disable_acpi_pci,
  1024. .ident = "Acer TravelMate 36x Laptop",
  1025. .matches = {
  1026. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  1027. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  1028. },
  1029. },
  1030. {}
  1031. };
  1032. #endif /* __i386__ */
  1033. /*
  1034. * acpi_boot_table_init() and acpi_boot_init()
  1035. * called from setup_arch(), always.
  1036. * 1. checksums all tables
  1037. * 2. enumerates lapics
  1038. * 3. enumerates io-apics
  1039. *
  1040. * acpi_table_init() is separate to allow reading SRAT without
  1041. * other side effects.
  1042. *
  1043. * side effects of acpi_boot_init:
  1044. * acpi_lapic = 1 if LAPIC found
  1045. * acpi_ioapic = 1 if IOAPIC found
  1046. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  1047. * if acpi_blacklisted() acpi_disabled = 1;
  1048. * acpi_irq_model=...
  1049. * ...
  1050. *
  1051. * return value: (currently ignored)
  1052. * 0: success
  1053. * !0: failure
  1054. */
  1055. int __init acpi_boot_table_init(void)
  1056. {
  1057. int error;
  1058. #ifdef __i386__
  1059. dmi_check_system(acpi_dmi_table);
  1060. #endif
  1061. /*
  1062. * If acpi_disabled, bail out
  1063. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1064. */
  1065. if (acpi_disabled && !acpi_ht)
  1066. return 1;
  1067. /*
  1068. * Initialize the ACPI boot-time table parser.
  1069. */
  1070. error = acpi_table_init();
  1071. if (error) {
  1072. disable_acpi();
  1073. return error;
  1074. }
  1075. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1076. /*
  1077. * blacklist may disable ACPI entirely
  1078. */
  1079. error = acpi_blacklisted();
  1080. if (error) {
  1081. if (acpi_force) {
  1082. printk(KERN_WARNING PREFIX "acpi=force override\n");
  1083. } else {
  1084. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  1085. disable_acpi();
  1086. return error;
  1087. }
  1088. }
  1089. return 0;
  1090. }
  1091. int __init early_acpi_boot_init(void)
  1092. {
  1093. /*
  1094. * If acpi_disabled, bail out
  1095. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1096. */
  1097. if (acpi_disabled && !acpi_ht)
  1098. return 1;
  1099. /*
  1100. * Process the Multiple APIC Description Table (MADT), if present
  1101. */
  1102. early_acpi_process_madt();
  1103. return 0;
  1104. }
  1105. int __init acpi_boot_init(void)
  1106. {
  1107. /*
  1108. * If acpi_disabled, bail out
  1109. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1110. */
  1111. if (acpi_disabled && !acpi_ht)
  1112. return 1;
  1113. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1114. /*
  1115. * set sci_int and PM timer address
  1116. */
  1117. acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
  1118. /*
  1119. * Process the Multiple APIC Description Table (MADT), if present
  1120. */
  1121. acpi_process_madt();
  1122. acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
  1123. return 0;
  1124. }
  1125. static int __init parse_acpi(char *arg)
  1126. {
  1127. if (!arg)
  1128. return -EINVAL;
  1129. /* "acpi=off" disables both ACPI table parsing and interpreter */
  1130. if (strcmp(arg, "off") == 0) {
  1131. disable_acpi();
  1132. }
  1133. /* acpi=force to over-ride black-list */
  1134. else if (strcmp(arg, "force") == 0) {
  1135. acpi_force = 1;
  1136. acpi_ht = 1;
  1137. acpi_disabled = 0;
  1138. }
  1139. /* acpi=strict disables out-of-spec workarounds */
  1140. else if (strcmp(arg, "strict") == 0) {
  1141. acpi_strict = 1;
  1142. }
  1143. /* Limit ACPI just to boot-time to enable HT */
  1144. else if (strcmp(arg, "ht") == 0) {
  1145. if (!acpi_force)
  1146. disable_acpi();
  1147. acpi_ht = 1;
  1148. }
  1149. /* "acpi=noirq" disables ACPI interrupt routing */
  1150. else if (strcmp(arg, "noirq") == 0) {
  1151. acpi_noirq_set();
  1152. } else {
  1153. /* Core will printk when we return error. */
  1154. return -EINVAL;
  1155. }
  1156. return 0;
  1157. }
  1158. early_param("acpi", parse_acpi);
  1159. /* FIXME: Using pci= for an ACPI parameter is a travesty. */
  1160. static int __init parse_pci(char *arg)
  1161. {
  1162. if (arg && strcmp(arg, "noacpi") == 0)
  1163. acpi_disable_pci();
  1164. return 0;
  1165. }
  1166. early_param("pci", parse_pci);
  1167. #ifdef CONFIG_X86_IO_APIC
  1168. static int __init parse_acpi_skip_timer_override(char *arg)
  1169. {
  1170. acpi_skip_timer_override = 1;
  1171. return 0;
  1172. }
  1173. early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
  1174. static int __init parse_acpi_use_timer_override(char *arg)
  1175. {
  1176. acpi_use_timer_override = 1;
  1177. return 0;
  1178. }
  1179. early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
  1180. #endif /* CONFIG_X86_IO_APIC */
  1181. static int __init setup_acpi_sci(char *s)
  1182. {
  1183. if (!s)
  1184. return -EINVAL;
  1185. if (!strcmp(s, "edge"))
  1186. acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
  1187. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1188. else if (!strcmp(s, "level"))
  1189. acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
  1190. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1191. else if (!strcmp(s, "high"))
  1192. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
  1193. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1194. else if (!strcmp(s, "low"))
  1195. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
  1196. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1197. else
  1198. return -EINVAL;
  1199. return 0;
  1200. }
  1201. early_param("acpi_sci", setup_acpi_sci);
  1202. int __acpi_acquire_global_lock(unsigned int *lock)
  1203. {
  1204. unsigned int old, new, val;
  1205. do {
  1206. old = *lock;
  1207. new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
  1208. val = cmpxchg(lock, old, new);
  1209. } while (unlikely (val != old));
  1210. return (new < 3) ? -1 : 0;
  1211. }
  1212. int __acpi_release_global_lock(unsigned int *lock)
  1213. {
  1214. unsigned int old, new, val;
  1215. do {
  1216. old = *lock;
  1217. new = old & ~0x3;
  1218. val = cmpxchg(lock, old, new);
  1219. } while (unlikely (val != old));
  1220. return old & 0x1;
  1221. }