boot.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883
  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/genapic.h>
  39. #include <asm/io.h>
  40. #include <asm/mpspec.h>
  41. #include <asm/smp.h>
  42. #ifdef CONFIG_X86_LOCAL_APIC
  43. # include <mach_apic.h>
  44. #endif
  45. static int __initdata acpi_force = 0;
  46. #ifdef CONFIG_ACPI
  47. int acpi_disabled = 0;
  48. #else
  49. int acpi_disabled = 1;
  50. #endif
  51. EXPORT_SYMBOL(acpi_disabled);
  52. #ifdef CONFIG_X86_64
  53. #include <asm/proto.h>
  54. #include <asm/genapic.h>
  55. #else /* X86 */
  56. #ifdef CONFIG_X86_LOCAL_APIC
  57. #include <mach_apic.h>
  58. #include <mach_mpparse.h>
  59. #endif /* CONFIG_X86_LOCAL_APIC */
  60. #endif /* X86 */
  61. #define BAD_MADT_ENTRY(entry, end) ( \
  62. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  63. ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
  64. #define PREFIX "ACPI: "
  65. int acpi_noirq; /* skip ACPI IRQ initialization */
  66. int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
  67. EXPORT_SYMBOL(acpi_pci_disabled);
  68. int acpi_ht __initdata = 1; /* enable HT */
  69. int acpi_lapic;
  70. int acpi_ioapic;
  71. int acpi_strict;
  72. static int disable_irq0_through_ioapic __initdata;
  73. u8 acpi_sci_flags __initdata;
  74. int acpi_sci_override_gsi __initdata;
  75. int acpi_skip_timer_override __initdata;
  76. int acpi_use_timer_override __initdata;
  77. #ifdef CONFIG_X86_LOCAL_APIC
  78. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  79. #endif
  80. #ifndef __HAVE_ARCH_CMPXCHG
  81. #warning ACPI uses CMPXCHG, i486 and later hardware
  82. #endif
  83. /* --------------------------------------------------------------------------
  84. Boot-time Configuration
  85. -------------------------------------------------------------------------- */
  86. /*
  87. * The default interrupt routing model is PIC (8259). This gets
  88. * overridden if IOAPICs are enumerated (below).
  89. */
  90. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  91. /*
  92. * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  93. * to map the target physical address. The problem is that set_fixmap()
  94. * provides a single page, and it is possible that the page is not
  95. * sufficient.
  96. * By using this area, we can map up to MAX_IO_APICS pages temporarily,
  97. * i.e. until the next __va_range() call.
  98. *
  99. * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
  100. * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
  101. * count idx down while incrementing the phys address.
  102. */
  103. char *__init __acpi_map_table(unsigned long phys, unsigned long size)
  104. {
  105. unsigned long base, offset, mapped_size;
  106. int idx;
  107. if (!phys || !size)
  108. return NULL;
  109. if (phys+size <= (max_pfn_mapped << PAGE_SHIFT))
  110. return __va(phys);
  111. offset = phys & (PAGE_SIZE - 1);
  112. mapped_size = PAGE_SIZE - offset;
  113. clear_fixmap(FIX_ACPI_END);
  114. set_fixmap(FIX_ACPI_END, phys);
  115. base = fix_to_virt(FIX_ACPI_END);
  116. /*
  117. * Most cases can be covered by the below.
  118. */
  119. idx = FIX_ACPI_END;
  120. while (mapped_size < size) {
  121. if (--idx < FIX_ACPI_BEGIN)
  122. return NULL; /* cannot handle this */
  123. phys += PAGE_SIZE;
  124. clear_fixmap(idx);
  125. set_fixmap(idx, phys);
  126. mapped_size += PAGE_SIZE;
  127. }
  128. return ((unsigned char *)base + offset);
  129. }
  130. #ifdef CONFIG_PCI_MMCONFIG
  131. /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
  132. struct acpi_mcfg_allocation *pci_mmcfg_config;
  133. int pci_mmcfg_config_num;
  134. int __init acpi_parse_mcfg(struct acpi_table_header *header)
  135. {
  136. struct acpi_table_mcfg *mcfg;
  137. unsigned long i;
  138. int config_size;
  139. if (!header)
  140. return -EINVAL;
  141. mcfg = (struct acpi_table_mcfg *)header;
  142. /* how many config structures do we have */
  143. pci_mmcfg_config_num = 0;
  144. i = header->length - sizeof(struct acpi_table_mcfg);
  145. while (i >= sizeof(struct acpi_mcfg_allocation)) {
  146. ++pci_mmcfg_config_num;
  147. i -= sizeof(struct acpi_mcfg_allocation);
  148. };
  149. if (pci_mmcfg_config_num == 0) {
  150. printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
  151. return -ENODEV;
  152. }
  153. config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
  154. pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
  155. if (!pci_mmcfg_config) {
  156. printk(KERN_WARNING PREFIX
  157. "No memory for MCFG config tables\n");
  158. return -ENOMEM;
  159. }
  160. memcpy(pci_mmcfg_config, &mcfg[1], config_size);
  161. for (i = 0; i < pci_mmcfg_config_num; ++i) {
  162. if (pci_mmcfg_config[i].address > 0xFFFFFFFF) {
  163. printk(KERN_ERR PREFIX
  164. "MMCONFIG not in low 4GB of memory\n");
  165. kfree(pci_mmcfg_config);
  166. pci_mmcfg_config_num = 0;
  167. return -ENODEV;
  168. }
  169. }
  170. return 0;
  171. }
  172. #endif /* CONFIG_PCI_MMCONFIG */
  173. #ifdef CONFIG_X86_LOCAL_APIC
  174. static int __init acpi_parse_madt(struct acpi_table_header *table)
  175. {
  176. struct acpi_table_madt *madt = NULL;
  177. if (!cpu_has_apic)
  178. return -EINVAL;
  179. madt = (struct acpi_table_madt *)table;
  180. if (!madt) {
  181. printk(KERN_WARNING PREFIX "Unable to map MADT\n");
  182. return -ENODEV;
  183. }
  184. if (madt->address) {
  185. acpi_lapic_addr = (u64) madt->address;
  186. printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
  187. madt->address);
  188. }
  189. acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
  190. return 0;
  191. }
  192. static void __cpuinit acpi_register_lapic(int id, u8 enabled)
  193. {
  194. unsigned int ver = 0;
  195. if (!enabled) {
  196. ++disabled_cpus;
  197. return;
  198. }
  199. #ifdef CONFIG_X86_32
  200. if (boot_cpu_physical_apicid != -1U)
  201. ver = apic_version[boot_cpu_physical_apicid];
  202. #endif
  203. generic_processor_info(id, ver);
  204. }
  205. static int __init
  206. acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
  207. {
  208. struct acpi_madt_local_apic *processor = NULL;
  209. processor = (struct acpi_madt_local_apic *)header;
  210. if (BAD_MADT_ENTRY(processor, end))
  211. return -EINVAL;
  212. acpi_table_print_madt_entry(header);
  213. /*
  214. * We need to register disabled CPU as well to permit
  215. * counting disabled CPUs. This allows us to size
  216. * cpus_possible_map more accurately, to permit
  217. * to not preallocating memory for all NR_CPUS
  218. * when we use CPU hotplug.
  219. */
  220. acpi_register_lapic(processor->id, /* APIC ID */
  221. processor->lapic_flags & ACPI_MADT_ENABLED);
  222. return 0;
  223. }
  224. static int __init
  225. acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
  226. {
  227. struct acpi_madt_local_sapic *processor = NULL;
  228. processor = (struct acpi_madt_local_sapic *)header;
  229. if (BAD_MADT_ENTRY(processor, end))
  230. return -EINVAL;
  231. acpi_table_print_madt_entry(header);
  232. acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
  233. processor->lapic_flags & ACPI_MADT_ENABLED);
  234. return 0;
  235. }
  236. static int __init
  237. acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
  238. const unsigned long end)
  239. {
  240. struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
  241. lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
  242. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  243. return -EINVAL;
  244. acpi_lapic_addr = lapic_addr_ovr->address;
  245. return 0;
  246. }
  247. static int __init
  248. acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
  249. {
  250. struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
  251. lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
  252. if (BAD_MADT_ENTRY(lapic_nmi, end))
  253. return -EINVAL;
  254. acpi_table_print_madt_entry(header);
  255. if (lapic_nmi->lint != 1)
  256. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  257. return 0;
  258. }
  259. #endif /*CONFIG_X86_LOCAL_APIC */
  260. #ifdef CONFIG_X86_IO_APIC
  261. static int __init
  262. acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
  263. {
  264. struct acpi_madt_io_apic *ioapic = NULL;
  265. ioapic = (struct acpi_madt_io_apic *)header;
  266. if (BAD_MADT_ENTRY(ioapic, end))
  267. return -EINVAL;
  268. acpi_table_print_madt_entry(header);
  269. mp_register_ioapic(ioapic->id,
  270. ioapic->address, ioapic->global_irq_base);
  271. return 0;
  272. }
  273. /*
  274. * Parse Interrupt Source Override for the ACPI SCI
  275. */
  276. static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  277. {
  278. if (trigger == 0) /* compatible SCI trigger is level */
  279. trigger = 3;
  280. if (polarity == 0) /* compatible SCI polarity is low */
  281. polarity = 3;
  282. /* Command-line over-ride via acpi_sci= */
  283. if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
  284. trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
  285. if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
  286. polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
  287. /*
  288. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  289. * If GSI is < 16, this will update its flags,
  290. * else it will create a new mp_irqs[] entry.
  291. */
  292. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  293. /*
  294. * stash over-ride to indicate we've been here
  295. * and for later update of acpi_gbl_FADT
  296. */
  297. acpi_sci_override_gsi = gsi;
  298. return;
  299. }
  300. static int __init
  301. acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
  302. const unsigned long end)
  303. {
  304. struct acpi_madt_interrupt_override *intsrc = NULL;
  305. intsrc = (struct acpi_madt_interrupt_override *)header;
  306. if (BAD_MADT_ENTRY(intsrc, end))
  307. return -EINVAL;
  308. acpi_table_print_madt_entry(header);
  309. if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
  310. acpi_sci_ioapic_setup(intsrc->global_irq,
  311. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  312. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
  313. return 0;
  314. }
  315. if (acpi_skip_timer_override &&
  316. intsrc->source_irq == 0 && intsrc->global_irq == 2) {
  317. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  318. return 0;
  319. }
  320. mp_override_legacy_irq(intsrc->source_irq,
  321. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  322. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
  323. intsrc->global_irq);
  324. return 0;
  325. }
  326. static int __init
  327. acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
  328. {
  329. struct acpi_madt_nmi_source *nmi_src = NULL;
  330. nmi_src = (struct acpi_madt_nmi_source *)header;
  331. if (BAD_MADT_ENTRY(nmi_src, end))
  332. return -EINVAL;
  333. acpi_table_print_madt_entry(header);
  334. /* TBD: Support nimsrc entries? */
  335. return 0;
  336. }
  337. #endif /* CONFIG_X86_IO_APIC */
  338. /*
  339. * acpi_pic_sci_set_trigger()
  340. *
  341. * use ELCR to set PIC-mode trigger type for SCI
  342. *
  343. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  344. * it may require Edge Trigger -- use "acpi_sci=edge"
  345. *
  346. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  347. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  348. * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
  349. * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
  350. */
  351. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  352. {
  353. unsigned int mask = 1 << irq;
  354. unsigned int old, new;
  355. /* Real old ELCR mask */
  356. old = inb(0x4d0) | (inb(0x4d1) << 8);
  357. /*
  358. * If we use ACPI to set PCI IRQs, then we should clear ELCR
  359. * since we will set it correctly as we enable the PCI irq
  360. * routing.
  361. */
  362. new = acpi_noirq ? old : 0;
  363. /*
  364. * Update SCI information in the ELCR, it isn't in the PCI
  365. * routing tables..
  366. */
  367. switch (trigger) {
  368. case 1: /* Edge - clear */
  369. new &= ~mask;
  370. break;
  371. case 3: /* Level - set */
  372. new |= mask;
  373. break;
  374. }
  375. if (old == new)
  376. return;
  377. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  378. outb(new, 0x4d0);
  379. outb(new >> 8, 0x4d1);
  380. }
  381. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  382. {
  383. *irq = gsi;
  384. return 0;
  385. }
  386. /*
  387. * success: return IRQ number (>=0)
  388. * failure: return < 0
  389. */
  390. int acpi_register_gsi(u32 gsi, int triggering, int polarity)
  391. {
  392. unsigned int irq;
  393. unsigned int plat_gsi = gsi;
  394. #ifdef CONFIG_PCI
  395. /*
  396. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  397. */
  398. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  399. if (triggering == ACPI_LEVEL_SENSITIVE)
  400. eisa_set_level_irq(gsi);
  401. }
  402. #endif
  403. #ifdef CONFIG_X86_IO_APIC
  404. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  405. plat_gsi = mp_register_gsi(gsi, triggering, polarity);
  406. }
  407. #endif
  408. acpi_gsi_to_irq(plat_gsi, &irq);
  409. return irq;
  410. }
  411. /*
  412. * ACPI based hotplug support for CPU
  413. */
  414. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  415. static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
  416. {
  417. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  418. union acpi_object *obj;
  419. struct acpi_madt_local_apic *lapic;
  420. cpumask_t tmp_map, new_map;
  421. u8 physid;
  422. int cpu;
  423. if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
  424. return -EINVAL;
  425. if (!buffer.length || !buffer.pointer)
  426. return -EINVAL;
  427. obj = buffer.pointer;
  428. if (obj->type != ACPI_TYPE_BUFFER ||
  429. obj->buffer.length < sizeof(*lapic)) {
  430. kfree(buffer.pointer);
  431. return -EINVAL;
  432. }
  433. lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
  434. if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
  435. !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
  436. kfree(buffer.pointer);
  437. return -EINVAL;
  438. }
  439. physid = lapic->id;
  440. kfree(buffer.pointer);
  441. buffer.length = ACPI_ALLOCATE_BUFFER;
  442. buffer.pointer = NULL;
  443. tmp_map = cpu_present_map;
  444. acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
  445. /*
  446. * If mp_register_lapic successfully generates a new logical cpu
  447. * number, then the following will get us exactly what was mapped
  448. */
  449. cpus_andnot(new_map, cpu_present_map, tmp_map);
  450. if (cpus_empty(new_map)) {
  451. printk ("Unable to map lapic to logical cpu number\n");
  452. return -EINVAL;
  453. }
  454. cpu = first_cpu(new_map);
  455. *pcpu = cpu;
  456. return 0;
  457. }
  458. /* wrapper to silence section mismatch warning */
  459. int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
  460. {
  461. return _acpi_map_lsapic(handle, pcpu);
  462. }
  463. EXPORT_SYMBOL(acpi_map_lsapic);
  464. int acpi_unmap_lsapic(int cpu)
  465. {
  466. per_cpu(x86_cpu_to_apicid, cpu) = -1;
  467. cpu_clear(cpu, cpu_present_map);
  468. num_processors--;
  469. return (0);
  470. }
  471. EXPORT_SYMBOL(acpi_unmap_lsapic);
  472. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  473. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  474. {
  475. /* TBD */
  476. return -EINVAL;
  477. }
  478. EXPORT_SYMBOL(acpi_register_ioapic);
  479. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  480. {
  481. /* TBD */
  482. return -EINVAL;
  483. }
  484. EXPORT_SYMBOL(acpi_unregister_ioapic);
  485. static int __init acpi_parse_sbf(struct acpi_table_header *table)
  486. {
  487. struct acpi_table_boot *sb;
  488. sb = (struct acpi_table_boot *)table;
  489. if (!sb) {
  490. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  491. return -ENODEV;
  492. }
  493. sbf_port = sb->cmos_index; /* Save CMOS port */
  494. return 0;
  495. }
  496. #ifdef CONFIG_HPET_TIMER
  497. #include <asm/hpet.h>
  498. static struct __initdata resource *hpet_res;
  499. static int __init acpi_parse_hpet(struct acpi_table_header *table)
  500. {
  501. struct acpi_table_hpet *hpet_tbl;
  502. hpet_tbl = (struct acpi_table_hpet *)table;
  503. if (!hpet_tbl) {
  504. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  505. return -ENODEV;
  506. }
  507. if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
  508. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  509. "memory.\n");
  510. return -1;
  511. }
  512. hpet_address = hpet_tbl->address.address;
  513. /*
  514. * Some broken BIOSes advertise HPET at 0x0. We really do not
  515. * want to allocate a resource there.
  516. */
  517. if (!hpet_address) {
  518. printk(KERN_WARNING PREFIX
  519. "HPET id: %#x base: %#lx is invalid\n",
  520. hpet_tbl->id, hpet_address);
  521. return 0;
  522. }
  523. #ifdef CONFIG_X86_64
  524. /*
  525. * Some even more broken BIOSes advertise HPET at
  526. * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
  527. * some noise:
  528. */
  529. if (hpet_address == 0xfed0000000000000UL) {
  530. if (!hpet_force_user) {
  531. printk(KERN_WARNING PREFIX "HPET id: %#x "
  532. "base: 0xfed0000000000000 is bogus\n "
  533. "try hpet=force on the kernel command line to "
  534. "fix it up to 0xfed00000.\n", hpet_tbl->id);
  535. hpet_address = 0;
  536. return 0;
  537. }
  538. printk(KERN_WARNING PREFIX
  539. "HPET id: %#x base: 0xfed0000000000000 fixed up "
  540. "to 0xfed00000.\n", hpet_tbl->id);
  541. hpet_address >>= 32;
  542. }
  543. #endif
  544. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  545. hpet_tbl->id, hpet_address);
  546. /*
  547. * Allocate and initialize the HPET firmware resource for adding into
  548. * the resource tree during the lateinit timeframe.
  549. */
  550. #define HPET_RESOURCE_NAME_SIZE 9
  551. hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
  552. hpet_res->name = (void *)&hpet_res[1];
  553. hpet_res->flags = IORESOURCE_MEM;
  554. snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
  555. hpet_tbl->sequence);
  556. hpet_res->start = hpet_address;
  557. hpet_res->end = hpet_address + (1 * 1024) - 1;
  558. return 0;
  559. }
  560. /*
  561. * hpet_insert_resource inserts the HPET resources used into the resource
  562. * tree.
  563. */
  564. static __init int hpet_insert_resource(void)
  565. {
  566. if (!hpet_res)
  567. return 1;
  568. return insert_resource(&iomem_resource, hpet_res);
  569. }
  570. late_initcall(hpet_insert_resource);
  571. #else
  572. #define acpi_parse_hpet NULL
  573. #endif
  574. static int __init acpi_parse_fadt(struct acpi_table_header *table)
  575. {
  576. #ifdef CONFIG_X86_PM_TIMER
  577. /* detect the location of the ACPI PM Timer */
  578. if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
  579. /* FADT rev. 2 */
  580. if (acpi_gbl_FADT.xpm_timer_block.space_id !=
  581. ACPI_ADR_SPACE_SYSTEM_IO)
  582. return 0;
  583. pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
  584. /*
  585. * "X" fields are optional extensions to the original V1.0
  586. * fields, so we must selectively expand V1.0 fields if the
  587. * corresponding X field is zero.
  588. */
  589. if (!pmtmr_ioport)
  590. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  591. } else {
  592. /* FADT rev. 1 */
  593. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  594. }
  595. if (pmtmr_ioport)
  596. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  597. pmtmr_ioport);
  598. #endif
  599. return 0;
  600. }
  601. #ifdef CONFIG_X86_LOCAL_APIC
  602. /*
  603. * Parse LAPIC entries in MADT
  604. * returns 0 on success, < 0 on error
  605. */
  606. static void __init acpi_register_lapic_address(unsigned long address)
  607. {
  608. mp_lapic_addr = address;
  609. set_fixmap_nocache(FIX_APIC_BASE, address);
  610. if (boot_cpu_physical_apicid == -1U) {
  611. boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id());
  612. #ifdef CONFIG_X86_32
  613. apic_version[boot_cpu_physical_apicid] =
  614. GET_APIC_VERSION(apic_read(APIC_LVR));
  615. #endif
  616. }
  617. }
  618. static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
  619. {
  620. int count;
  621. if (!cpu_has_apic)
  622. return -ENODEV;
  623. /*
  624. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  625. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  626. */
  627. count =
  628. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  629. acpi_parse_lapic_addr_ovr, 0);
  630. if (count < 0) {
  631. printk(KERN_ERR PREFIX
  632. "Error parsing LAPIC address override entry\n");
  633. return count;
  634. }
  635. acpi_register_lapic_address(acpi_lapic_addr);
  636. return count;
  637. }
  638. static int __init acpi_parse_madt_lapic_entries(void)
  639. {
  640. int count;
  641. if (!cpu_has_apic)
  642. return -ENODEV;
  643. /*
  644. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  645. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  646. */
  647. count =
  648. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  649. acpi_parse_lapic_addr_ovr, 0);
  650. if (count < 0) {
  651. printk(KERN_ERR PREFIX
  652. "Error parsing LAPIC address override entry\n");
  653. return count;
  654. }
  655. acpi_register_lapic_address(acpi_lapic_addr);
  656. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
  657. acpi_parse_sapic, MAX_APICS);
  658. if (!count)
  659. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
  660. acpi_parse_lapic, MAX_APICS);
  661. if (!count) {
  662. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  663. /* TBD: Cleanup to allow fallback to MPS */
  664. return -ENODEV;
  665. } else if (count < 0) {
  666. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  667. /* TBD: Cleanup to allow fallback to MPS */
  668. return count;
  669. }
  670. count =
  671. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
  672. if (count < 0) {
  673. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  674. /* TBD: Cleanup to allow fallback to MPS */
  675. return count;
  676. }
  677. return 0;
  678. }
  679. #endif /* CONFIG_X86_LOCAL_APIC */
  680. #ifdef CONFIG_X86_IO_APIC
  681. #define MP_ISA_BUS 0
  682. #ifdef CONFIG_X86_ES7000
  683. extern int es7000_plat;
  684. #endif
  685. static struct {
  686. int apic_id;
  687. int gsi_base;
  688. int gsi_end;
  689. DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1);
  690. } mp_ioapic_routing[MAX_IO_APICS];
  691. static int mp_find_ioapic(int gsi)
  692. {
  693. int i = 0;
  694. /* Find the IOAPIC that manages this GSI. */
  695. for (i = 0; i < nr_ioapics; i++) {
  696. if ((gsi >= mp_ioapic_routing[i].gsi_base)
  697. && (gsi <= mp_ioapic_routing[i].gsi_end))
  698. return i;
  699. }
  700. printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
  701. return -1;
  702. }
  703. static u8 __init uniq_ioapic_id(u8 id)
  704. {
  705. #ifdef CONFIG_X86_32
  706. if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
  707. !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
  708. return io_apic_get_unique_id(nr_ioapics, id);
  709. else
  710. return id;
  711. #else
  712. int i;
  713. DECLARE_BITMAP(used, 256);
  714. bitmap_zero(used, 256);
  715. for (i = 0; i < nr_ioapics; i++) {
  716. struct mp_config_ioapic *ia = &mp_ioapics[i];
  717. __set_bit(ia->mp_apicid, used);
  718. }
  719. if (!test_bit(id, used))
  720. return id;
  721. return find_first_zero_bit(used, 256);
  722. #endif
  723. }
  724. static int bad_ioapic(unsigned long address)
  725. {
  726. if (nr_ioapics >= MAX_IO_APICS) {
  727. printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
  728. "(found %d)\n", MAX_IO_APICS, nr_ioapics);
  729. panic("Recompile kernel with bigger MAX_IO_APICS!\n");
  730. }
  731. if (!address) {
  732. printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
  733. " found in table, skipping!\n");
  734. return 1;
  735. }
  736. return 0;
  737. }
  738. void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
  739. {
  740. int idx = 0;
  741. if (bad_ioapic(address))
  742. return;
  743. idx = nr_ioapics;
  744. mp_ioapics[idx].mp_type = MP_IOAPIC;
  745. mp_ioapics[idx].mp_flags = MPC_APIC_USABLE;
  746. mp_ioapics[idx].mp_apicaddr = address;
  747. set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
  748. mp_ioapics[idx].mp_apicid = uniq_ioapic_id(id);
  749. #ifdef CONFIG_X86_32
  750. mp_ioapics[idx].mp_apicver = io_apic_get_version(idx);
  751. #else
  752. mp_ioapics[idx].mp_apicver = 0;
  753. #endif
  754. /*
  755. * Build basic GSI lookup table to facilitate gsi->io_apic lookups
  756. * and to prevent reprogramming of IOAPIC pins (PCI GSIs).
  757. */
  758. mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mp_apicid;
  759. mp_ioapic_routing[idx].gsi_base = gsi_base;
  760. mp_ioapic_routing[idx].gsi_end = gsi_base +
  761. io_apic_get_redir_entries(idx);
  762. printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%lx, "
  763. "GSI %d-%d\n", idx, mp_ioapics[idx].mp_apicid,
  764. mp_ioapics[idx].mp_apicver, mp_ioapics[idx].mp_apicaddr,
  765. mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end);
  766. nr_ioapics++;
  767. }
  768. static void assign_to_mp_irq(struct mp_config_intsrc *m,
  769. struct mp_config_intsrc *mp_irq)
  770. {
  771. memcpy(mp_irq, m, sizeof(struct mp_config_intsrc));
  772. }
  773. static int mp_irq_cmp(struct mp_config_intsrc *mp_irq,
  774. struct mp_config_intsrc *m)
  775. {
  776. return memcmp(mp_irq, m, sizeof(struct mp_config_intsrc));
  777. }
  778. static void save_mp_irq(struct mp_config_intsrc *m)
  779. {
  780. int i;
  781. for (i = 0; i < mp_irq_entries; i++) {
  782. if (!mp_irq_cmp(&mp_irqs[i], m))
  783. return;
  784. }
  785. assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
  786. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  787. panic("Max # of irq sources exceeded!!\n");
  788. }
  789. void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
  790. {
  791. int ioapic;
  792. int pin;
  793. struct mp_config_intsrc mp_irq;
  794. /* Skip the 8254 timer interrupt (IRQ 0) if requested. */
  795. if (bus_irq == 0 && disable_irq0_through_ioapic)
  796. return;
  797. /*
  798. * Convert 'gsi' to 'ioapic.pin'.
  799. */
  800. ioapic = mp_find_ioapic(gsi);
  801. if (ioapic < 0)
  802. return;
  803. pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  804. /*
  805. * TBD: This check is for faulty timer entries, where the override
  806. * erroneously sets the trigger to level, resulting in a HUGE
  807. * increase of timer interrupts!
  808. */
  809. if ((bus_irq == 0) && (trigger == 3))
  810. trigger = 1;
  811. mp_irq.mp_type = MP_INTSRC;
  812. mp_irq.mp_irqtype = mp_INT;
  813. mp_irq.mp_irqflag = (trigger << 2) | polarity;
  814. mp_irq.mp_srcbus = MP_ISA_BUS;
  815. mp_irq.mp_srcbusirq = bus_irq; /* IRQ */
  816. mp_irq.mp_dstapic = mp_ioapics[ioapic].mp_apicid; /* APIC ID */
  817. mp_irq.mp_dstirq = pin; /* INTIN# */
  818. save_mp_irq(&mp_irq);
  819. }
  820. void __init mp_config_acpi_legacy_irqs(void)
  821. {
  822. int i;
  823. int ioapic;
  824. unsigned int dstapic;
  825. struct mp_config_intsrc mp_irq;
  826. #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
  827. /*
  828. * Fabricate the legacy ISA bus (bus #31).
  829. */
  830. mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
  831. #endif
  832. set_bit(MP_ISA_BUS, mp_bus_not_pci);
  833. Dprintk("Bus #%d is ISA\n", MP_ISA_BUS);
  834. #ifdef CONFIG_X86_ES7000
  835. /*
  836. * Older generations of ES7000 have no legacy identity mappings
  837. */
  838. if (es7000_plat == 1)
  839. return;
  840. #endif
  841. /*
  842. * Locate the IOAPIC that manages the ISA IRQs (0-15).
  843. */
  844. ioapic = mp_find_ioapic(0);
  845. if (ioapic < 0)
  846. return;
  847. dstapic = mp_ioapics[ioapic].mp_apicid;
  848. /*
  849. * Use the default configuration for the IRQs 0-15. Unless
  850. * overridden by (MADT) interrupt source override entries.
  851. */
  852. for (i = 0; i < 16; i++) {
  853. int idx;
  854. /* Skip the 8254 timer interrupt (IRQ 0) if requested. */
  855. if (i == 0 && disable_irq0_through_ioapic)
  856. continue;
  857. for (idx = 0; idx < mp_irq_entries; idx++) {
  858. struct mp_config_intsrc *irq = mp_irqs + idx;
  859. /* Do we already have a mapping for this ISA IRQ? */
  860. if (irq->mp_srcbus == MP_ISA_BUS
  861. && irq->mp_srcbusirq == i)
  862. break;
  863. /* Do we already have a mapping for this IOAPIC pin */
  864. if (irq->mp_dstapic == dstapic &&
  865. irq->mp_dstirq == i)
  866. break;
  867. }
  868. if (idx != mp_irq_entries) {
  869. printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
  870. continue; /* IRQ already used */
  871. }
  872. mp_irq.mp_type = MP_INTSRC;
  873. mp_irq.mp_irqflag = 0; /* Conforming */
  874. mp_irq.mp_srcbus = MP_ISA_BUS;
  875. mp_irq.mp_dstapic = dstapic;
  876. mp_irq.mp_irqtype = mp_INT;
  877. mp_irq.mp_srcbusirq = i; /* Identity mapped */
  878. mp_irq.mp_dstirq = i;
  879. save_mp_irq(&mp_irq);
  880. }
  881. }
  882. int mp_register_gsi(u32 gsi, int triggering, int polarity)
  883. {
  884. int ioapic;
  885. int ioapic_pin;
  886. #ifdef CONFIG_X86_32
  887. #define MAX_GSI_NUM 4096
  888. #define IRQ_COMPRESSION_START 64
  889. static int pci_irq = IRQ_COMPRESSION_START;
  890. /*
  891. * Mapping between Global System Interrupts, which
  892. * represent all possible interrupts, and IRQs
  893. * assigned to actual devices.
  894. */
  895. static int gsi_to_irq[MAX_GSI_NUM];
  896. #else
  897. if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
  898. return gsi;
  899. #endif
  900. /* Don't set up the ACPI SCI because it's already set up */
  901. if (acpi_gbl_FADT.sci_interrupt == gsi)
  902. return gsi;
  903. ioapic = mp_find_ioapic(gsi);
  904. if (ioapic < 0) {
  905. printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
  906. return gsi;
  907. }
  908. ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  909. #ifdef CONFIG_X86_32
  910. if (ioapic_renumber_irq)
  911. gsi = ioapic_renumber_irq(ioapic, gsi);
  912. #endif
  913. /*
  914. * Avoid pin reprogramming. PRTs typically include entries
  915. * with redundant pin->gsi mappings (but unique PCI devices);
  916. * we only program the IOAPIC on the first.
  917. */
  918. if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
  919. printk(KERN_ERR "Invalid reference to IOAPIC pin "
  920. "%d-%d\n", mp_ioapic_routing[ioapic].apic_id,
  921. ioapic_pin);
  922. return gsi;
  923. }
  924. if (test_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed)) {
  925. Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
  926. mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
  927. #ifdef CONFIG_X86_32
  928. return (gsi < IRQ_COMPRESSION_START ? gsi : gsi_to_irq[gsi]);
  929. #else
  930. return gsi;
  931. #endif
  932. }
  933. set_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed);
  934. #ifdef CONFIG_X86_32
  935. /*
  936. * For GSI >= 64, use IRQ compression
  937. */
  938. if ((gsi >= IRQ_COMPRESSION_START)
  939. && (triggering == ACPI_LEVEL_SENSITIVE)) {
  940. /*
  941. * For PCI devices assign IRQs in order, avoiding gaps
  942. * due to unused I/O APIC pins.
  943. */
  944. int irq = gsi;
  945. if (gsi < MAX_GSI_NUM) {
  946. /*
  947. * Retain the VIA chipset work-around (gsi > 15), but
  948. * avoid a problem where the 8254 timer (IRQ0) is setup
  949. * via an override (so it's not on pin 0 of the ioapic),
  950. * and at the same time, the pin 0 interrupt is a PCI
  951. * type. The gsi > 15 test could cause these two pins
  952. * to be shared as IRQ0, and they are not shareable.
  953. * So test for this condition, and if necessary, avoid
  954. * the pin collision.
  955. */
  956. gsi = pci_irq++;
  957. /*
  958. * Don't assign IRQ used by ACPI SCI
  959. */
  960. if (gsi == acpi_gbl_FADT.sci_interrupt)
  961. gsi = pci_irq++;
  962. gsi_to_irq[irq] = gsi;
  963. } else {
  964. printk(KERN_ERR "GSI %u is too high\n", gsi);
  965. return gsi;
  966. }
  967. }
  968. #endif
  969. io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
  970. triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
  971. polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
  972. return gsi;
  973. }
  974. int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
  975. u32 gsi, int triggering, int polarity)
  976. {
  977. #ifdef CONFIG_X86_MPPARSE
  978. struct mp_config_intsrc mp_irq;
  979. int ioapic;
  980. if (!acpi_ioapic)
  981. return 0;
  982. /* print the entry should happen on mptable identically */
  983. mp_irq.mp_type = MP_INTSRC;
  984. mp_irq.mp_irqtype = mp_INT;
  985. mp_irq.mp_irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
  986. (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
  987. mp_irq.mp_srcbus = number;
  988. mp_irq.mp_srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
  989. ioapic = mp_find_ioapic(gsi);
  990. mp_irq.mp_dstapic = mp_ioapic_routing[ioapic].apic_id;
  991. mp_irq.mp_dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base;
  992. save_mp_irq(&mp_irq);
  993. #endif
  994. return 0;
  995. }
  996. /*
  997. * Parse IOAPIC related entries in MADT
  998. * returns 0 on success, < 0 on error
  999. */
  1000. static int __init acpi_parse_madt_ioapic_entries(void)
  1001. {
  1002. int count;
  1003. /*
  1004. * ACPI interpreter is required to complete interrupt setup,
  1005. * so if it is off, don't enumerate the io-apics with ACPI.
  1006. * If MPS is present, it will handle them,
  1007. * otherwise the system will stay in PIC mode
  1008. */
  1009. if (acpi_disabled || acpi_noirq) {
  1010. return -ENODEV;
  1011. }
  1012. if (!cpu_has_apic)
  1013. return -ENODEV;
  1014. /*
  1015. * if "noapic" boot option, don't look for IO-APICs
  1016. */
  1017. if (skip_ioapic_setup) {
  1018. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  1019. "due to 'noapic' option.\n");
  1020. return -ENODEV;
  1021. }
  1022. count =
  1023. acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
  1024. MAX_IO_APICS);
  1025. if (!count) {
  1026. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  1027. return -ENODEV;
  1028. } else if (count < 0) {
  1029. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  1030. return count;
  1031. }
  1032. count =
  1033. acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
  1034. NR_IRQ_VECTORS);
  1035. if (count < 0) {
  1036. printk(KERN_ERR PREFIX
  1037. "Error parsing interrupt source overrides entry\n");
  1038. /* TBD: Cleanup to allow fallback to MPS */
  1039. return count;
  1040. }
  1041. /*
  1042. * If BIOS did not supply an INT_SRC_OVR for the SCI
  1043. * pretend we got one so we can set the SCI flags.
  1044. */
  1045. if (!acpi_sci_override_gsi)
  1046. acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
  1047. /* Fill in identity legacy mapings where no override */
  1048. mp_config_acpi_legacy_irqs();
  1049. count =
  1050. acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
  1051. NR_IRQ_VECTORS);
  1052. if (count < 0) {
  1053. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  1054. /* TBD: Cleanup to allow fallback to MPS */
  1055. return count;
  1056. }
  1057. return 0;
  1058. }
  1059. #else
  1060. static inline int acpi_parse_madt_ioapic_entries(void)
  1061. {
  1062. return -1;
  1063. }
  1064. #endif /* !CONFIG_X86_IO_APIC */
  1065. static void __init early_acpi_process_madt(void)
  1066. {
  1067. #ifdef CONFIG_X86_LOCAL_APIC
  1068. int error;
  1069. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  1070. /*
  1071. * Parse MADT LAPIC entries
  1072. */
  1073. error = early_acpi_parse_madt_lapic_addr_ovr();
  1074. if (!error) {
  1075. acpi_lapic = 1;
  1076. smp_found_config = 1;
  1077. }
  1078. if (error == -EINVAL) {
  1079. /*
  1080. * Dell Precision Workstation 410, 610 come here.
  1081. */
  1082. printk(KERN_ERR PREFIX
  1083. "Invalid BIOS MADT, disabling ACPI\n");
  1084. disable_acpi();
  1085. }
  1086. }
  1087. #endif
  1088. }
  1089. static void __init acpi_process_madt(void)
  1090. {
  1091. #ifdef CONFIG_X86_LOCAL_APIC
  1092. int error;
  1093. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  1094. /*
  1095. * Parse MADT LAPIC entries
  1096. */
  1097. error = acpi_parse_madt_lapic_entries();
  1098. if (!error) {
  1099. acpi_lapic = 1;
  1100. #ifdef CONFIG_X86_GENERICARCH
  1101. generic_bigsmp_probe();
  1102. #endif
  1103. /*
  1104. * Parse MADT IO-APIC entries
  1105. */
  1106. error = acpi_parse_madt_ioapic_entries();
  1107. if (!error) {
  1108. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  1109. acpi_irq_balance_set(NULL);
  1110. acpi_ioapic = 1;
  1111. smp_found_config = 1;
  1112. setup_apic_routing();
  1113. }
  1114. }
  1115. if (error == -EINVAL) {
  1116. /*
  1117. * Dell Precision Workstation 410, 610 come here.
  1118. */
  1119. printk(KERN_ERR PREFIX
  1120. "Invalid BIOS MADT, disabling ACPI\n");
  1121. disable_acpi();
  1122. }
  1123. }
  1124. #endif
  1125. return;
  1126. }
  1127. static int __init disable_acpi_irq(const struct dmi_system_id *d)
  1128. {
  1129. if (!acpi_force) {
  1130. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  1131. d->ident);
  1132. acpi_noirq_set();
  1133. }
  1134. return 0;
  1135. }
  1136. static int __init disable_acpi_pci(const struct dmi_system_id *d)
  1137. {
  1138. if (!acpi_force) {
  1139. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  1140. d->ident);
  1141. acpi_disable_pci();
  1142. }
  1143. return 0;
  1144. }
  1145. static int __init dmi_disable_acpi(const struct dmi_system_id *d)
  1146. {
  1147. if (!acpi_force) {
  1148. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  1149. disable_acpi();
  1150. } else {
  1151. printk(KERN_NOTICE
  1152. "Warning: DMI blacklist says broken, but acpi forced\n");
  1153. }
  1154. return 0;
  1155. }
  1156. /*
  1157. * Limit ACPI to CPU enumeration for HT
  1158. */
  1159. static int __init force_acpi_ht(const struct dmi_system_id *d)
  1160. {
  1161. if (!acpi_force) {
  1162. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  1163. d->ident);
  1164. disable_acpi();
  1165. acpi_ht = 1;
  1166. } else {
  1167. printk(KERN_NOTICE
  1168. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  1169. }
  1170. return 0;
  1171. }
  1172. /*
  1173. * Don't register any I/O APIC entries for the 8254 timer IRQ.
  1174. */
  1175. static int __init
  1176. dmi_disable_irq0_through_ioapic(const struct dmi_system_id *d)
  1177. {
  1178. pr_notice("%s detected: disabling IRQ 0 through I/O APIC\n", d->ident);
  1179. disable_irq0_through_ioapic = 1;
  1180. return 0;
  1181. }
  1182. /*
  1183. * Force ignoring BIOS IRQ0 pin2 override
  1184. */
  1185. static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
  1186. {
  1187. pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n", d->ident);
  1188. acpi_skip_timer_override = 1;
  1189. force_mask_ioapic_irq_2();
  1190. return 0;
  1191. }
  1192. /*
  1193. * If your system is blacklisted here, but you find that acpi=force
  1194. * works for you, please contact acpi-devel@sourceforge.net
  1195. */
  1196. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  1197. /*
  1198. * Boxes that need ACPI disabled
  1199. */
  1200. {
  1201. .callback = dmi_disable_acpi,
  1202. .ident = "IBM Thinkpad",
  1203. .matches = {
  1204. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1205. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  1206. },
  1207. },
  1208. /*
  1209. * Boxes that need acpi=ht
  1210. */
  1211. {
  1212. .callback = force_acpi_ht,
  1213. .ident = "FSC Primergy T850",
  1214. .matches = {
  1215. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  1216. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  1217. },
  1218. },
  1219. {
  1220. .callback = force_acpi_ht,
  1221. .ident = "HP VISUALIZE NT Workstation",
  1222. .matches = {
  1223. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  1224. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  1225. },
  1226. },
  1227. {
  1228. .callback = force_acpi_ht,
  1229. .ident = "Compaq Workstation W8000",
  1230. .matches = {
  1231. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  1232. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  1233. },
  1234. },
  1235. {
  1236. .callback = force_acpi_ht,
  1237. .ident = "ASUS P4B266",
  1238. .matches = {
  1239. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1240. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  1241. },
  1242. },
  1243. {
  1244. .callback = force_acpi_ht,
  1245. .ident = "ASUS P2B-DS",
  1246. .matches = {
  1247. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1248. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  1249. },
  1250. },
  1251. {
  1252. .callback = force_acpi_ht,
  1253. .ident = "ASUS CUR-DLS",
  1254. .matches = {
  1255. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1256. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  1257. },
  1258. },
  1259. {
  1260. .callback = force_acpi_ht,
  1261. .ident = "ABIT i440BX-W83977",
  1262. .matches = {
  1263. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  1264. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  1265. },
  1266. },
  1267. {
  1268. .callback = force_acpi_ht,
  1269. .ident = "IBM Bladecenter",
  1270. .matches = {
  1271. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1272. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  1273. },
  1274. },
  1275. {
  1276. .callback = force_acpi_ht,
  1277. .ident = "IBM eServer xSeries 360",
  1278. .matches = {
  1279. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1280. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  1281. },
  1282. },
  1283. {
  1284. .callback = force_acpi_ht,
  1285. .ident = "IBM eserver xSeries 330",
  1286. .matches = {
  1287. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1288. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  1289. },
  1290. },
  1291. {
  1292. .callback = force_acpi_ht,
  1293. .ident = "IBM eserver xSeries 440",
  1294. .matches = {
  1295. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1296. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  1297. },
  1298. },
  1299. /*
  1300. * Boxes that need ACPI PCI IRQ routing disabled
  1301. */
  1302. {
  1303. .callback = disable_acpi_irq,
  1304. .ident = "ASUS A7V",
  1305. .matches = {
  1306. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  1307. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  1308. /* newer BIOS, Revision 1011, does work */
  1309. DMI_MATCH(DMI_BIOS_VERSION,
  1310. "ASUS A7V ACPI BIOS Revision 1007"),
  1311. },
  1312. },
  1313. {
  1314. /*
  1315. * Latest BIOS for IBM 600E (1.16) has bad pcinum
  1316. * for LPC bridge, which is needed for the PCI
  1317. * interrupt links to work. DSDT fix is in bug 5966.
  1318. * 2645, 2646 model numbers are shared with 600/600E/600X
  1319. */
  1320. .callback = disable_acpi_irq,
  1321. .ident = "IBM Thinkpad 600 Series 2645",
  1322. .matches = {
  1323. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1324. DMI_MATCH(DMI_BOARD_NAME, "2645"),
  1325. },
  1326. },
  1327. {
  1328. .callback = disable_acpi_irq,
  1329. .ident = "IBM Thinkpad 600 Series 2646",
  1330. .matches = {
  1331. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1332. DMI_MATCH(DMI_BOARD_NAME, "2646"),
  1333. },
  1334. },
  1335. /*
  1336. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  1337. */
  1338. { /* _BBN 0 bug */
  1339. .callback = disable_acpi_pci,
  1340. .ident = "ASUS PR-DLS",
  1341. .matches = {
  1342. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1343. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  1344. DMI_MATCH(DMI_BIOS_VERSION,
  1345. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  1346. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  1347. },
  1348. },
  1349. {
  1350. .callback = disable_acpi_pci,
  1351. .ident = "Acer TravelMate 36x Laptop",
  1352. .matches = {
  1353. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  1354. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  1355. },
  1356. },
  1357. /*
  1358. * HP laptops which use a DSDT reporting as HP/SB400/10000,
  1359. * which includes some code which overrides all temperature
  1360. * trip points to 16C if the INTIN2 input of the I/O APIC
  1361. * is enabled. This input is incorrectly designated the
  1362. * ISA IRQ 0 via an interrupt source override even though
  1363. * it is wired to the output of the master 8259A and INTIN0
  1364. * is not connected at all. Abandon any attempts to route
  1365. * IRQ 0 through the I/O APIC therefore.
  1366. */
  1367. {
  1368. .callback = dmi_disable_irq0_through_ioapic,
  1369. .ident = "HP NX6125 laptop",
  1370. .matches = {
  1371. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1372. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
  1373. },
  1374. },
  1375. {
  1376. .callback = dmi_disable_irq0_through_ioapic,
  1377. .ident = "HP NX6325 laptop",
  1378. .matches = {
  1379. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1380. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
  1381. },
  1382. },
  1383. /*
  1384. * HP laptops which use a DSDT reporting as HP/SB400/10000,
  1385. * which includes some code which overrides all temperature
  1386. * trip points to 16C if the INTIN2 input of the I/O APIC
  1387. * is enabled. This input is incorrectly designated the
  1388. * ISA IRQ 0 via an interrupt source override even though
  1389. * it is wired to the output of the master 8259A and INTIN0
  1390. * is not connected at all. Force ignoring BIOS IRQ0 pin2
  1391. * override in that cases.
  1392. */
  1393. {
  1394. .callback = dmi_ignore_irq0_timer_override,
  1395. .ident = "HP NX6125 laptop",
  1396. .matches = {
  1397. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1398. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
  1399. },
  1400. },
  1401. {
  1402. .callback = dmi_ignore_irq0_timer_override,
  1403. .ident = "HP NX6325 laptop",
  1404. .matches = {
  1405. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1406. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
  1407. },
  1408. },
  1409. {}
  1410. };
  1411. /*
  1412. * acpi_boot_table_init() and acpi_boot_init()
  1413. * called from setup_arch(), always.
  1414. * 1. checksums all tables
  1415. * 2. enumerates lapics
  1416. * 3. enumerates io-apics
  1417. *
  1418. * acpi_table_init() is separate to allow reading SRAT without
  1419. * other side effects.
  1420. *
  1421. * side effects of acpi_boot_init:
  1422. * acpi_lapic = 1 if LAPIC found
  1423. * acpi_ioapic = 1 if IOAPIC found
  1424. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  1425. * if acpi_blacklisted() acpi_disabled = 1;
  1426. * acpi_irq_model=...
  1427. * ...
  1428. *
  1429. * return value: (currently ignored)
  1430. * 0: success
  1431. * !0: failure
  1432. */
  1433. int __init acpi_boot_table_init(void)
  1434. {
  1435. int error;
  1436. dmi_check_system(acpi_dmi_table);
  1437. /*
  1438. * If acpi_disabled, bail out
  1439. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1440. */
  1441. if (acpi_disabled && !acpi_ht)
  1442. return 1;
  1443. /*
  1444. * Initialize the ACPI boot-time table parser.
  1445. */
  1446. error = acpi_table_init();
  1447. if (error) {
  1448. disable_acpi();
  1449. return error;
  1450. }
  1451. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1452. /*
  1453. * blacklist may disable ACPI entirely
  1454. */
  1455. error = acpi_blacklisted();
  1456. if (error) {
  1457. if (acpi_force) {
  1458. printk(KERN_WARNING PREFIX "acpi=force override\n");
  1459. } else {
  1460. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  1461. disable_acpi();
  1462. return error;
  1463. }
  1464. }
  1465. return 0;
  1466. }
  1467. int __init early_acpi_boot_init(void)
  1468. {
  1469. /*
  1470. * If acpi_disabled, bail out
  1471. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1472. */
  1473. if (acpi_disabled && !acpi_ht)
  1474. return 1;
  1475. /*
  1476. * Process the Multiple APIC Description Table (MADT), if present
  1477. */
  1478. early_acpi_process_madt();
  1479. return 0;
  1480. }
  1481. int __init acpi_boot_init(void)
  1482. {
  1483. /*
  1484. * If acpi_disabled, bail out
  1485. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1486. */
  1487. if (acpi_disabled && !acpi_ht)
  1488. return 1;
  1489. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1490. /*
  1491. * set sci_int and PM timer address
  1492. */
  1493. acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
  1494. /*
  1495. * Process the Multiple APIC Description Table (MADT), if present
  1496. */
  1497. acpi_process_madt();
  1498. acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
  1499. return 0;
  1500. }
  1501. static int __init parse_acpi(char *arg)
  1502. {
  1503. if (!arg)
  1504. return -EINVAL;
  1505. /* "acpi=off" disables both ACPI table parsing and interpreter */
  1506. if (strcmp(arg, "off") == 0) {
  1507. disable_acpi();
  1508. }
  1509. /* acpi=force to over-ride black-list */
  1510. else if (strcmp(arg, "force") == 0) {
  1511. acpi_force = 1;
  1512. acpi_ht = 1;
  1513. acpi_disabled = 0;
  1514. }
  1515. /* acpi=strict disables out-of-spec workarounds */
  1516. else if (strcmp(arg, "strict") == 0) {
  1517. acpi_strict = 1;
  1518. }
  1519. /* Limit ACPI just to boot-time to enable HT */
  1520. else if (strcmp(arg, "ht") == 0) {
  1521. if (!acpi_force)
  1522. disable_acpi();
  1523. acpi_ht = 1;
  1524. }
  1525. /* "acpi=noirq" disables ACPI interrupt routing */
  1526. else if (strcmp(arg, "noirq") == 0) {
  1527. acpi_noirq_set();
  1528. } else {
  1529. /* Core will printk when we return error. */
  1530. return -EINVAL;
  1531. }
  1532. return 0;
  1533. }
  1534. early_param("acpi", parse_acpi);
  1535. /* FIXME: Using pci= for an ACPI parameter is a travesty. */
  1536. static int __init parse_pci(char *arg)
  1537. {
  1538. if (arg && strcmp(arg, "noacpi") == 0)
  1539. acpi_disable_pci();
  1540. return 0;
  1541. }
  1542. early_param("pci", parse_pci);
  1543. int __init acpi_mps_check(void)
  1544. {
  1545. #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
  1546. /* mptable code is not built-in*/
  1547. if (acpi_disabled || acpi_noirq) {
  1548. printk(KERN_WARNING "MPS support code is not built-in.\n"
  1549. "Using acpi=off or acpi=noirq or pci=noacpi "
  1550. "may have problem\n");
  1551. return 1;
  1552. }
  1553. #endif
  1554. return 0;
  1555. }
  1556. #ifdef CONFIG_X86_IO_APIC
  1557. static int __init parse_acpi_skip_timer_override(char *arg)
  1558. {
  1559. acpi_skip_timer_override = 1;
  1560. return 0;
  1561. }
  1562. early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
  1563. static int __init parse_acpi_use_timer_override(char *arg)
  1564. {
  1565. acpi_use_timer_override = 1;
  1566. return 0;
  1567. }
  1568. early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
  1569. #endif /* CONFIG_X86_IO_APIC */
  1570. static int __init setup_acpi_sci(char *s)
  1571. {
  1572. if (!s)
  1573. return -EINVAL;
  1574. if (!strcmp(s, "edge"))
  1575. acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
  1576. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1577. else if (!strcmp(s, "level"))
  1578. acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
  1579. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1580. else if (!strcmp(s, "high"))
  1581. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
  1582. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1583. else if (!strcmp(s, "low"))
  1584. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
  1585. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1586. else
  1587. return -EINVAL;
  1588. return 0;
  1589. }
  1590. early_param("acpi_sci", setup_acpi_sci);
  1591. int __acpi_acquire_global_lock(unsigned int *lock)
  1592. {
  1593. unsigned int old, new, val;
  1594. do {
  1595. old = *lock;
  1596. new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
  1597. val = cmpxchg(lock, old, new);
  1598. } while (unlikely (val != old));
  1599. return (new < 3) ? -1 : 0;
  1600. }
  1601. int __acpi_release_global_lock(unsigned int *lock)
  1602. {
  1603. unsigned int old, new, val;
  1604. do {
  1605. old = *lock;
  1606. new = old & ~0x3;
  1607. val = cmpxchg(lock, old, new);
  1608. } while (unlikely (val != old));
  1609. return old & 0x1;
  1610. }