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