boot.c 47 KB

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