boot.c 45 KB

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