boot.c 45 KB

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