boot.c 45 KB

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