boot.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864
  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. /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
  130. struct acpi_mcfg_allocation *pci_mmcfg_config;
  131. int pci_mmcfg_config_num;
  132. static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
  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. #ifdef CONFIG_X86_32
  207. if (boot_cpu_physical_apicid != -1U)
  208. ver = apic_version[boot_cpu_physical_apicid];
  209. #endif
  210. generic_processor_info(id, ver);
  211. }
  212. static int __init
  213. acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
  214. {
  215. struct acpi_madt_local_apic *processor = NULL;
  216. processor = (struct acpi_madt_local_apic *)header;
  217. if (BAD_MADT_ENTRY(processor, end))
  218. return -EINVAL;
  219. acpi_table_print_madt_entry(header);
  220. /*
  221. * We need to register disabled CPU as well to permit
  222. * counting disabled CPUs. This allows us to size
  223. * cpus_possible_map more accurately, to permit
  224. * to not preallocating memory for all NR_CPUS
  225. * when we use CPU hotplug.
  226. */
  227. acpi_register_lapic(processor->id, /* APIC ID */
  228. processor->lapic_flags & ACPI_MADT_ENABLED);
  229. return 0;
  230. }
  231. static int __init
  232. acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
  233. {
  234. struct acpi_madt_local_sapic *processor = NULL;
  235. processor = (struct acpi_madt_local_sapic *)header;
  236. if (BAD_MADT_ENTRY(processor, end))
  237. return -EINVAL;
  238. acpi_table_print_madt_entry(header);
  239. acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
  240. processor->lapic_flags & ACPI_MADT_ENABLED);
  241. return 0;
  242. }
  243. static int __init
  244. acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
  245. const unsigned long end)
  246. {
  247. struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
  248. lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
  249. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  250. return -EINVAL;
  251. acpi_lapic_addr = lapic_addr_ovr->address;
  252. return 0;
  253. }
  254. static int __init
  255. acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
  256. {
  257. struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
  258. lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
  259. if (BAD_MADT_ENTRY(lapic_nmi, end))
  260. return -EINVAL;
  261. acpi_table_print_madt_entry(header);
  262. if (lapic_nmi->lint != 1)
  263. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  264. return 0;
  265. }
  266. #endif /*CONFIG_X86_LOCAL_APIC */
  267. #ifdef CONFIG_X86_IO_APIC
  268. static int __init
  269. acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
  270. {
  271. struct acpi_madt_io_apic *ioapic = NULL;
  272. ioapic = (struct acpi_madt_io_apic *)header;
  273. if (BAD_MADT_ENTRY(ioapic, end))
  274. return -EINVAL;
  275. acpi_table_print_madt_entry(header);
  276. mp_register_ioapic(ioapic->id,
  277. ioapic->address, ioapic->global_irq_base);
  278. return 0;
  279. }
  280. /*
  281. * Parse Interrupt Source Override for the ACPI SCI
  282. */
  283. static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  284. {
  285. if (trigger == 0) /* compatible SCI trigger is level */
  286. trigger = 3;
  287. if (polarity == 0) /* compatible SCI polarity is low */
  288. polarity = 3;
  289. /* Command-line over-ride via acpi_sci= */
  290. if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
  291. trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
  292. if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
  293. polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
  294. /*
  295. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  296. * If GSI is < 16, this will update its flags,
  297. * else it will create a new mp_irqs[] entry.
  298. */
  299. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  300. /*
  301. * stash over-ride to indicate we've been here
  302. * and for later update of acpi_gbl_FADT
  303. */
  304. acpi_sci_override_gsi = gsi;
  305. return;
  306. }
  307. static int __init
  308. acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
  309. const unsigned long end)
  310. {
  311. struct acpi_madt_interrupt_override *intsrc = NULL;
  312. intsrc = (struct acpi_madt_interrupt_override *)header;
  313. if (BAD_MADT_ENTRY(intsrc, end))
  314. return -EINVAL;
  315. acpi_table_print_madt_entry(header);
  316. if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
  317. acpi_sci_ioapic_setup(intsrc->global_irq,
  318. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  319. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
  320. return 0;
  321. }
  322. if (acpi_skip_timer_override &&
  323. intsrc->source_irq == 0 && intsrc->global_irq == 2) {
  324. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  325. return 0;
  326. }
  327. mp_override_legacy_irq(intsrc->source_irq,
  328. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  329. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
  330. intsrc->global_irq);
  331. return 0;
  332. }
  333. static int __init
  334. acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
  335. {
  336. struct acpi_madt_nmi_source *nmi_src = NULL;
  337. nmi_src = (struct acpi_madt_nmi_source *)header;
  338. if (BAD_MADT_ENTRY(nmi_src, end))
  339. return -EINVAL;
  340. acpi_table_print_madt_entry(header);
  341. /* TBD: Support nimsrc entries? */
  342. return 0;
  343. }
  344. #endif /* CONFIG_X86_IO_APIC */
  345. /*
  346. * acpi_pic_sci_set_trigger()
  347. *
  348. * use ELCR to set PIC-mode trigger type for SCI
  349. *
  350. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  351. * it may require Edge Trigger -- use "acpi_sci=edge"
  352. *
  353. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  354. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  355. * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
  356. * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
  357. */
  358. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  359. {
  360. unsigned int mask = 1 << irq;
  361. unsigned int old, new;
  362. /* Real old ELCR mask */
  363. old = inb(0x4d0) | (inb(0x4d1) << 8);
  364. /*
  365. * If we use ACPI to set PCI IRQs, then we should clear ELCR
  366. * since we will set it correctly as we enable the PCI irq
  367. * routing.
  368. */
  369. new = acpi_noirq ? old : 0;
  370. /*
  371. * Update SCI information in the ELCR, it isn't in the PCI
  372. * routing tables..
  373. */
  374. switch (trigger) {
  375. case 1: /* Edge - clear */
  376. new &= ~mask;
  377. break;
  378. case 3: /* Level - set */
  379. new |= mask;
  380. break;
  381. }
  382. if (old == new)
  383. return;
  384. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  385. outb(new, 0x4d0);
  386. outb(new >> 8, 0x4d1);
  387. }
  388. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  389. {
  390. *irq = gsi;
  391. return 0;
  392. }
  393. /*
  394. * success: return IRQ number (>=0)
  395. * failure: return < 0
  396. */
  397. int acpi_register_gsi(u32 gsi, int triggering, int polarity)
  398. {
  399. unsigned int irq;
  400. unsigned int plat_gsi = gsi;
  401. #ifdef CONFIG_PCI
  402. /*
  403. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  404. */
  405. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  406. if (triggering == ACPI_LEVEL_SENSITIVE)
  407. eisa_set_level_irq(gsi);
  408. }
  409. #endif
  410. #ifdef CONFIG_X86_IO_APIC
  411. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  412. plat_gsi = mp_register_gsi(gsi, triggering, polarity);
  413. }
  414. #endif
  415. acpi_gsi_to_irq(plat_gsi, &irq);
  416. return irq;
  417. }
  418. /*
  419. * ACPI based hotplug support for CPU
  420. */
  421. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  422. static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
  423. {
  424. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  425. union acpi_object *obj;
  426. struct acpi_madt_local_apic *lapic;
  427. cpumask_t tmp_map, new_map;
  428. u8 physid;
  429. int cpu;
  430. if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
  431. return -EINVAL;
  432. if (!buffer.length || !buffer.pointer)
  433. return -EINVAL;
  434. obj = buffer.pointer;
  435. if (obj->type != ACPI_TYPE_BUFFER ||
  436. obj->buffer.length < sizeof(*lapic)) {
  437. kfree(buffer.pointer);
  438. return -EINVAL;
  439. }
  440. lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
  441. if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
  442. !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
  443. kfree(buffer.pointer);
  444. return -EINVAL;
  445. }
  446. physid = lapic->id;
  447. kfree(buffer.pointer);
  448. buffer.length = ACPI_ALLOCATE_BUFFER;
  449. buffer.pointer = NULL;
  450. tmp_map = cpu_present_map;
  451. acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
  452. /*
  453. * If mp_register_lapic successfully generates a new logical cpu
  454. * number, then the following will get us exactly what was mapped
  455. */
  456. cpus_andnot(new_map, cpu_present_map, tmp_map);
  457. if (cpus_empty(new_map)) {
  458. printk ("Unable to map lapic to logical cpu number\n");
  459. return -EINVAL;
  460. }
  461. cpu = first_cpu(new_map);
  462. *pcpu = cpu;
  463. return 0;
  464. }
  465. /* wrapper to silence section mismatch warning */
  466. int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
  467. {
  468. return _acpi_map_lsapic(handle, pcpu);
  469. }
  470. EXPORT_SYMBOL(acpi_map_lsapic);
  471. int acpi_unmap_lsapic(int cpu)
  472. {
  473. per_cpu(x86_cpu_to_apicid, cpu) = -1;
  474. cpu_clear(cpu, cpu_present_map);
  475. num_processors--;
  476. return (0);
  477. }
  478. EXPORT_SYMBOL(acpi_unmap_lsapic);
  479. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  480. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  481. {
  482. /* TBD */
  483. return -EINVAL;
  484. }
  485. EXPORT_SYMBOL(acpi_register_ioapic);
  486. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  487. {
  488. /* TBD */
  489. return -EINVAL;
  490. }
  491. EXPORT_SYMBOL(acpi_unregister_ioapic);
  492. static int __init acpi_parse_sbf(struct acpi_table_header *table)
  493. {
  494. struct acpi_table_boot *sb;
  495. sb = (struct acpi_table_boot *)table;
  496. if (!sb) {
  497. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  498. return -ENODEV;
  499. }
  500. sbf_port = sb->cmos_index; /* Save CMOS port */
  501. return 0;
  502. }
  503. #ifdef CONFIG_HPET_TIMER
  504. #include <asm/hpet.h>
  505. static struct __initdata resource *hpet_res;
  506. static int __init acpi_parse_hpet(struct acpi_table_header *table)
  507. {
  508. struct acpi_table_hpet *hpet_tbl;
  509. hpet_tbl = (struct acpi_table_hpet *)table;
  510. if (!hpet_tbl) {
  511. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  512. return -ENODEV;
  513. }
  514. if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
  515. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  516. "memory.\n");
  517. return -1;
  518. }
  519. hpet_address = hpet_tbl->address.address;
  520. /*
  521. * Some broken BIOSes advertise HPET at 0x0. We really do not
  522. * want to allocate a resource there.
  523. */
  524. if (!hpet_address) {
  525. printk(KERN_WARNING PREFIX
  526. "HPET id: %#x base: %#lx is invalid\n",
  527. hpet_tbl->id, hpet_address);
  528. return 0;
  529. }
  530. #ifdef CONFIG_X86_64
  531. /*
  532. * Some even more broken BIOSes advertise HPET at
  533. * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
  534. * some noise:
  535. */
  536. if (hpet_address == 0xfed0000000000000UL) {
  537. if (!hpet_force_user) {
  538. printk(KERN_WARNING PREFIX "HPET id: %#x "
  539. "base: 0xfed0000000000000 is bogus\n "
  540. "try hpet=force on the kernel command line to "
  541. "fix it up to 0xfed00000.\n", hpet_tbl->id);
  542. hpet_address = 0;
  543. return 0;
  544. }
  545. printk(KERN_WARNING PREFIX
  546. "HPET id: %#x base: 0xfed0000000000000 fixed up "
  547. "to 0xfed00000.\n", hpet_tbl->id);
  548. hpet_address >>= 32;
  549. }
  550. #endif
  551. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  552. hpet_tbl->id, hpet_address);
  553. /*
  554. * Allocate and initialize the HPET firmware resource for adding into
  555. * the resource tree during the lateinit timeframe.
  556. */
  557. #define HPET_RESOURCE_NAME_SIZE 9
  558. hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
  559. hpet_res->name = (void *)&hpet_res[1];
  560. hpet_res->flags = IORESOURCE_MEM;
  561. snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
  562. hpet_tbl->sequence);
  563. hpet_res->start = hpet_address;
  564. hpet_res->end = hpet_address + (1 * 1024) - 1;
  565. return 0;
  566. }
  567. /*
  568. * hpet_insert_resource inserts the HPET resources used into the resource
  569. * tree.
  570. */
  571. static __init int hpet_insert_resource(void)
  572. {
  573. if (!hpet_res)
  574. return 1;
  575. return insert_resource(&iomem_resource, hpet_res);
  576. }
  577. late_initcall(hpet_insert_resource);
  578. #else
  579. #define acpi_parse_hpet NULL
  580. #endif
  581. static int __init acpi_parse_fadt(struct acpi_table_header *table)
  582. {
  583. #ifdef CONFIG_X86_PM_TIMER
  584. /* detect the location of the ACPI PM Timer */
  585. if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
  586. /* FADT rev. 2 */
  587. if (acpi_gbl_FADT.xpm_timer_block.space_id !=
  588. ACPI_ADR_SPACE_SYSTEM_IO)
  589. return 0;
  590. pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
  591. /*
  592. * "X" fields are optional extensions to the original V1.0
  593. * fields, so we must selectively expand V1.0 fields if the
  594. * corresponding X field is zero.
  595. */
  596. if (!pmtmr_ioport)
  597. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  598. } else {
  599. /* FADT rev. 1 */
  600. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  601. }
  602. if (pmtmr_ioport)
  603. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  604. pmtmr_ioport);
  605. #endif
  606. return 0;
  607. }
  608. #ifdef CONFIG_X86_LOCAL_APIC
  609. /*
  610. * Parse LAPIC entries in MADT
  611. * returns 0 on success, < 0 on error
  612. */
  613. static void __init acpi_register_lapic_address(unsigned long address)
  614. {
  615. mp_lapic_addr = address;
  616. set_fixmap_nocache(FIX_APIC_BASE, address);
  617. if (boot_cpu_physical_apicid == -1U) {
  618. boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id());
  619. #ifdef CONFIG_X86_32
  620. apic_version[boot_cpu_physical_apicid] =
  621. GET_APIC_VERSION(apic_read(APIC_LVR));
  622. #endif
  623. }
  624. }
  625. static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
  626. {
  627. int count;
  628. if (!cpu_has_apic)
  629. return -ENODEV;
  630. /*
  631. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  632. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  633. */
  634. count =
  635. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  636. acpi_parse_lapic_addr_ovr, 0);
  637. if (count < 0) {
  638. printk(KERN_ERR PREFIX
  639. "Error parsing LAPIC address override entry\n");
  640. return count;
  641. }
  642. acpi_register_lapic_address(acpi_lapic_addr);
  643. return count;
  644. }
  645. static int __init acpi_parse_madt_lapic_entries(void)
  646. {
  647. int count;
  648. if (!cpu_has_apic)
  649. return -ENODEV;
  650. /*
  651. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  652. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  653. */
  654. count =
  655. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  656. acpi_parse_lapic_addr_ovr, 0);
  657. if (count < 0) {
  658. printk(KERN_ERR PREFIX
  659. "Error parsing LAPIC address override entry\n");
  660. return count;
  661. }
  662. acpi_register_lapic_address(acpi_lapic_addr);
  663. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
  664. acpi_parse_sapic, MAX_APICS);
  665. if (!count)
  666. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
  667. acpi_parse_lapic, MAX_APICS);
  668. if (!count) {
  669. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  670. /* TBD: Cleanup to allow fallback to MPS */
  671. return -ENODEV;
  672. } else if (count < 0) {
  673. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  674. /* TBD: Cleanup to allow fallback to MPS */
  675. return count;
  676. }
  677. count =
  678. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
  679. if (count < 0) {
  680. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  681. /* TBD: Cleanup to allow fallback to MPS */
  682. return count;
  683. }
  684. return 0;
  685. }
  686. #endif /* CONFIG_X86_LOCAL_APIC */
  687. #ifdef CONFIG_X86_IO_APIC
  688. #define MP_ISA_BUS 0
  689. #ifdef CONFIG_X86_ES7000
  690. extern int es7000_plat;
  691. #endif
  692. static struct {
  693. int apic_id;
  694. int gsi_base;
  695. int gsi_end;
  696. DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1);
  697. } mp_ioapic_routing[MAX_IO_APICS];
  698. static int mp_find_ioapic(int gsi)
  699. {
  700. int i = 0;
  701. /* Find the IOAPIC that manages this GSI. */
  702. for (i = 0; i < nr_ioapics; i++) {
  703. if ((gsi >= mp_ioapic_routing[i].gsi_base)
  704. && (gsi <= mp_ioapic_routing[i].gsi_end))
  705. return i;
  706. }
  707. printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
  708. return -1;
  709. }
  710. static u8 __init uniq_ioapic_id(u8 id)
  711. {
  712. #ifdef CONFIG_X86_32
  713. if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
  714. !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
  715. return io_apic_get_unique_id(nr_ioapics, id);
  716. else
  717. return id;
  718. #else
  719. int i;
  720. DECLARE_BITMAP(used, 256);
  721. bitmap_zero(used, 256);
  722. for (i = 0; i < nr_ioapics; i++) {
  723. struct mp_config_ioapic *ia = &mp_ioapics[i];
  724. __set_bit(ia->mp_apicid, used);
  725. }
  726. if (!test_bit(id, used))
  727. return id;
  728. return find_first_zero_bit(used, 256);
  729. #endif
  730. }
  731. static int bad_ioapic(unsigned long address)
  732. {
  733. if (nr_ioapics >= MAX_IO_APICS) {
  734. printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
  735. "(found %d)\n", MAX_IO_APICS, nr_ioapics);
  736. panic("Recompile kernel with bigger MAX_IO_APICS!\n");
  737. }
  738. if (!address) {
  739. printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
  740. " found in table, skipping!\n");
  741. return 1;
  742. }
  743. return 0;
  744. }
  745. void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
  746. {
  747. int idx = 0;
  748. if (bad_ioapic(address))
  749. return;
  750. idx = nr_ioapics;
  751. mp_ioapics[idx].mp_type = MP_IOAPIC;
  752. mp_ioapics[idx].mp_flags = MPC_APIC_USABLE;
  753. mp_ioapics[idx].mp_apicaddr = address;
  754. set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
  755. mp_ioapics[idx].mp_apicid = uniq_ioapic_id(id);
  756. #ifdef CONFIG_X86_32
  757. mp_ioapics[idx].mp_apicver = io_apic_get_version(idx);
  758. #else
  759. mp_ioapics[idx].mp_apicver = 0;
  760. #endif
  761. /*
  762. * Build basic GSI lookup table to facilitate gsi->io_apic lookups
  763. * and to prevent reprogramming of IOAPIC pins (PCI GSIs).
  764. */
  765. mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mp_apicid;
  766. mp_ioapic_routing[idx].gsi_base = gsi_base;
  767. mp_ioapic_routing[idx].gsi_end = gsi_base +
  768. io_apic_get_redir_entries(idx);
  769. printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%lx, "
  770. "GSI %d-%d\n", idx, mp_ioapics[idx].mp_apicid,
  771. mp_ioapics[idx].mp_apicver, mp_ioapics[idx].mp_apicaddr,
  772. mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end);
  773. nr_ioapics++;
  774. }
  775. static void assign_to_mp_irq(struct mp_config_intsrc *m,
  776. struct mp_config_intsrc *mp_irq)
  777. {
  778. memcpy(mp_irq, m, sizeof(struct mp_config_intsrc));
  779. }
  780. static int mp_irq_cmp(struct mp_config_intsrc *mp_irq,
  781. struct mp_config_intsrc *m)
  782. {
  783. return memcmp(mp_irq, m, sizeof(struct mp_config_intsrc));
  784. }
  785. static void save_mp_irq(struct mp_config_intsrc *m)
  786. {
  787. int i;
  788. for (i = 0; i < mp_irq_entries; i++) {
  789. if (!mp_irq_cmp(&mp_irqs[i], m))
  790. return;
  791. }
  792. assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
  793. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  794. panic("Max # of irq sources exceeded!!\n");
  795. }
  796. void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
  797. {
  798. int ioapic;
  799. int pin;
  800. struct mp_config_intsrc mp_irq;
  801. /*
  802. * Convert 'gsi' to 'ioapic.pin'.
  803. */
  804. ioapic = mp_find_ioapic(gsi);
  805. if (ioapic < 0)
  806. return;
  807. pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  808. /*
  809. * TBD: This check is for faulty timer entries, where the override
  810. * erroneously sets the trigger to level, resulting in a HUGE
  811. * increase of timer interrupts!
  812. */
  813. if ((bus_irq == 0) && (trigger == 3))
  814. trigger = 1;
  815. mp_irq.mp_type = MP_INTSRC;
  816. mp_irq.mp_irqtype = mp_INT;
  817. mp_irq.mp_irqflag = (trigger << 2) | polarity;
  818. mp_irq.mp_srcbus = MP_ISA_BUS;
  819. mp_irq.mp_srcbusirq = bus_irq; /* IRQ */
  820. mp_irq.mp_dstapic = mp_ioapics[ioapic].mp_apicid; /* APIC ID */
  821. mp_irq.mp_dstirq = pin; /* INTIN# */
  822. save_mp_irq(&mp_irq);
  823. }
  824. void __init mp_config_acpi_legacy_irqs(void)
  825. {
  826. int i;
  827. int ioapic;
  828. unsigned int dstapic;
  829. struct mp_config_intsrc mp_irq;
  830. #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
  831. /*
  832. * Fabricate the legacy ISA bus (bus #31).
  833. */
  834. mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
  835. #endif
  836. set_bit(MP_ISA_BUS, mp_bus_not_pci);
  837. pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
  838. #ifdef CONFIG_X86_ES7000
  839. /*
  840. * Older generations of ES7000 have no legacy identity mappings
  841. */
  842. if (es7000_plat == 1)
  843. return;
  844. #endif
  845. /*
  846. * Locate the IOAPIC that manages the ISA IRQs (0-15).
  847. */
  848. ioapic = mp_find_ioapic(0);
  849. if (ioapic < 0)
  850. return;
  851. dstapic = mp_ioapics[ioapic].mp_apicid;
  852. /*
  853. * Use the default configuration for the IRQs 0-15. Unless
  854. * overridden by (MADT) interrupt source override entries.
  855. */
  856. for (i = 0; i < 16; i++) {
  857. int idx;
  858. for (idx = 0; idx < mp_irq_entries; idx++) {
  859. struct mp_config_intsrc *irq = mp_irqs + idx;
  860. /* Do we already have a mapping for this ISA IRQ? */
  861. if (irq->mp_srcbus == MP_ISA_BUS
  862. && irq->mp_srcbusirq == i)
  863. break;
  864. /* Do we already have a mapping for this IOAPIC pin */
  865. if (irq->mp_dstapic == dstapic &&
  866. irq->mp_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.mp_type = MP_INTSRC;
  874. mp_irq.mp_irqflag = 0; /* Conforming */
  875. mp_irq.mp_srcbus = MP_ISA_BUS;
  876. mp_irq.mp_dstapic = dstapic;
  877. mp_irq.mp_irqtype = mp_INT;
  878. mp_irq.mp_srcbusirq = i; /* Identity mapped */
  879. mp_irq.mp_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(KERN_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 mp_config_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.mp_type = MP_INTSRC;
  985. mp_irq.mp_irqtype = mp_INT;
  986. mp_irq.mp_irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
  987. (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
  988. mp_irq.mp_srcbus = number;
  989. mp_irq.mp_srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
  990. ioapic = mp_find_ioapic(gsi);
  991. mp_irq.mp_dstapic = mp_ioapic_routing[ioapic].apic_id;
  992. mp_irq.mp_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_IRQ_VECTORS);
  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_IRQ_VECTORS);
  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_irq_balance_set(NULL);
  1111. acpi_ioapic = 1;
  1112. smp_found_config = 1;
  1113. 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. }
  1125. #endif
  1126. return;
  1127. }
  1128. static int __init disable_acpi_irq(const struct dmi_system_id *d)
  1129. {
  1130. if (!acpi_force) {
  1131. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  1132. d->ident);
  1133. acpi_noirq_set();
  1134. }
  1135. return 0;
  1136. }
  1137. static int __init disable_acpi_pci(const struct dmi_system_id *d)
  1138. {
  1139. if (!acpi_force) {
  1140. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  1141. d->ident);
  1142. acpi_disable_pci();
  1143. }
  1144. return 0;
  1145. }
  1146. static int __init dmi_disable_acpi(const struct dmi_system_id *d)
  1147. {
  1148. if (!acpi_force) {
  1149. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  1150. disable_acpi();
  1151. } else {
  1152. printk(KERN_NOTICE
  1153. "Warning: DMI blacklist says broken, but acpi forced\n");
  1154. }
  1155. return 0;
  1156. }
  1157. /*
  1158. * Limit ACPI to CPU enumeration for HT
  1159. */
  1160. static int __init force_acpi_ht(const struct dmi_system_id *d)
  1161. {
  1162. if (!acpi_force) {
  1163. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  1164. d->ident);
  1165. disable_acpi();
  1166. acpi_ht = 1;
  1167. } else {
  1168. printk(KERN_NOTICE
  1169. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  1170. }
  1171. return 0;
  1172. }
  1173. /*
  1174. * Force ignoring BIOS IRQ0 pin2 override
  1175. */
  1176. static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
  1177. {
  1178. pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n", d->ident);
  1179. acpi_skip_timer_override = 1;
  1180. return 0;
  1181. }
  1182. /*
  1183. * If your system is blacklisted here, but you find that acpi=force
  1184. * works for you, please contact acpi-devel@sourceforge.net
  1185. */
  1186. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  1187. /*
  1188. * Boxes that need ACPI disabled
  1189. */
  1190. {
  1191. .callback = dmi_disable_acpi,
  1192. .ident = "IBM Thinkpad",
  1193. .matches = {
  1194. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1195. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  1196. },
  1197. },
  1198. /*
  1199. * Boxes that need acpi=ht
  1200. */
  1201. {
  1202. .callback = force_acpi_ht,
  1203. .ident = "FSC Primergy T850",
  1204. .matches = {
  1205. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  1206. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  1207. },
  1208. },
  1209. {
  1210. .callback = force_acpi_ht,
  1211. .ident = "HP VISUALIZE NT Workstation",
  1212. .matches = {
  1213. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  1214. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  1215. },
  1216. },
  1217. {
  1218. .callback = force_acpi_ht,
  1219. .ident = "Compaq Workstation W8000",
  1220. .matches = {
  1221. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  1222. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  1223. },
  1224. },
  1225. {
  1226. .callback = force_acpi_ht,
  1227. .ident = "ASUS P4B266",
  1228. .matches = {
  1229. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1230. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  1231. },
  1232. },
  1233. {
  1234. .callback = force_acpi_ht,
  1235. .ident = "ASUS P2B-DS",
  1236. .matches = {
  1237. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1238. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  1239. },
  1240. },
  1241. {
  1242. .callback = force_acpi_ht,
  1243. .ident = "ASUS CUR-DLS",
  1244. .matches = {
  1245. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1246. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  1247. },
  1248. },
  1249. {
  1250. .callback = force_acpi_ht,
  1251. .ident = "ABIT i440BX-W83977",
  1252. .matches = {
  1253. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  1254. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  1255. },
  1256. },
  1257. {
  1258. .callback = force_acpi_ht,
  1259. .ident = "IBM Bladecenter",
  1260. .matches = {
  1261. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1262. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  1263. },
  1264. },
  1265. {
  1266. .callback = force_acpi_ht,
  1267. .ident = "IBM eServer xSeries 360",
  1268. .matches = {
  1269. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1270. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  1271. },
  1272. },
  1273. {
  1274. .callback = force_acpi_ht,
  1275. .ident = "IBM eserver xSeries 330",
  1276. .matches = {
  1277. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1278. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  1279. },
  1280. },
  1281. {
  1282. .callback = force_acpi_ht,
  1283. .ident = "IBM eserver xSeries 440",
  1284. .matches = {
  1285. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1286. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  1287. },
  1288. },
  1289. /*
  1290. * Boxes that need ACPI PCI IRQ routing disabled
  1291. */
  1292. {
  1293. .callback = disable_acpi_irq,
  1294. .ident = "ASUS A7V",
  1295. .matches = {
  1296. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  1297. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  1298. /* newer BIOS, Revision 1011, does work */
  1299. DMI_MATCH(DMI_BIOS_VERSION,
  1300. "ASUS A7V ACPI BIOS Revision 1007"),
  1301. },
  1302. },
  1303. {
  1304. /*
  1305. * Latest BIOS for IBM 600E (1.16) has bad pcinum
  1306. * for LPC bridge, which is needed for the PCI
  1307. * interrupt links to work. DSDT fix is in bug 5966.
  1308. * 2645, 2646 model numbers are shared with 600/600E/600X
  1309. */
  1310. .callback = disable_acpi_irq,
  1311. .ident = "IBM Thinkpad 600 Series 2645",
  1312. .matches = {
  1313. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1314. DMI_MATCH(DMI_BOARD_NAME, "2645"),
  1315. },
  1316. },
  1317. {
  1318. .callback = disable_acpi_irq,
  1319. .ident = "IBM Thinkpad 600 Series 2646",
  1320. .matches = {
  1321. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1322. DMI_MATCH(DMI_BOARD_NAME, "2646"),
  1323. },
  1324. },
  1325. /*
  1326. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  1327. */
  1328. { /* _BBN 0 bug */
  1329. .callback = disable_acpi_pci,
  1330. .ident = "ASUS PR-DLS",
  1331. .matches = {
  1332. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1333. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  1334. DMI_MATCH(DMI_BIOS_VERSION,
  1335. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  1336. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  1337. },
  1338. },
  1339. {
  1340. .callback = disable_acpi_pci,
  1341. .ident = "Acer TravelMate 36x Laptop",
  1342. .matches = {
  1343. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  1344. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  1345. },
  1346. },
  1347. /*
  1348. * HP laptops which use a DSDT reporting as HP/SB400/10000,
  1349. * which includes some code which overrides all temperature
  1350. * trip points to 16C if the INTIN2 input of the I/O APIC
  1351. * is enabled. This input is incorrectly designated the
  1352. * ISA IRQ 0 via an interrupt source override even though
  1353. * it is wired to the output of the master 8259A and INTIN0
  1354. * is not connected at all. Force ignoring BIOS IRQ0 pin2
  1355. * override in that cases.
  1356. */
  1357. {
  1358. .callback = dmi_ignore_irq0_timer_override,
  1359. .ident = "HP nx6115 laptop",
  1360. .matches = {
  1361. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1362. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
  1363. },
  1364. },
  1365. {
  1366. .callback = dmi_ignore_irq0_timer_override,
  1367. .ident = "HP NX6125 laptop",
  1368. .matches = {
  1369. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1370. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
  1371. },
  1372. },
  1373. {
  1374. .callback = dmi_ignore_irq0_timer_override,
  1375. .ident = "HP NX6325 laptop",
  1376. .matches = {
  1377. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1378. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
  1379. },
  1380. },
  1381. {
  1382. .callback = dmi_ignore_irq0_timer_override,
  1383. .ident = "HP 6715b laptop",
  1384. .matches = {
  1385. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1386. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
  1387. },
  1388. },
  1389. {}
  1390. };
  1391. /*
  1392. * acpi_boot_table_init() and acpi_boot_init()
  1393. * called from setup_arch(), always.
  1394. * 1. checksums all tables
  1395. * 2. enumerates lapics
  1396. * 3. enumerates io-apics
  1397. *
  1398. * acpi_table_init() is separate to allow reading SRAT without
  1399. * other side effects.
  1400. *
  1401. * side effects of acpi_boot_init:
  1402. * acpi_lapic = 1 if LAPIC found
  1403. * acpi_ioapic = 1 if IOAPIC found
  1404. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  1405. * if acpi_blacklisted() acpi_disabled = 1;
  1406. * acpi_irq_model=...
  1407. * ...
  1408. *
  1409. * return value: (currently ignored)
  1410. * 0: success
  1411. * !0: failure
  1412. */
  1413. int __init acpi_boot_table_init(void)
  1414. {
  1415. int error;
  1416. dmi_check_system(acpi_dmi_table);
  1417. /*
  1418. * If acpi_disabled, bail out
  1419. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1420. */
  1421. if (acpi_disabled && !acpi_ht)
  1422. return 1;
  1423. /*
  1424. * Initialize the ACPI boot-time table parser.
  1425. */
  1426. error = acpi_table_init();
  1427. if (error) {
  1428. disable_acpi();
  1429. return error;
  1430. }
  1431. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1432. /*
  1433. * blacklist may disable ACPI entirely
  1434. */
  1435. error = acpi_blacklisted();
  1436. if (error) {
  1437. if (acpi_force) {
  1438. printk(KERN_WARNING PREFIX "acpi=force override\n");
  1439. } else {
  1440. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  1441. disable_acpi();
  1442. return error;
  1443. }
  1444. }
  1445. return 0;
  1446. }
  1447. int __init early_acpi_boot_init(void)
  1448. {
  1449. /*
  1450. * If acpi_disabled, bail out
  1451. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1452. */
  1453. if (acpi_disabled && !acpi_ht)
  1454. return 1;
  1455. /*
  1456. * Process the Multiple APIC Description Table (MADT), if present
  1457. */
  1458. early_acpi_process_madt();
  1459. return 0;
  1460. }
  1461. int __init acpi_boot_init(void)
  1462. {
  1463. /*
  1464. * If acpi_disabled, bail out
  1465. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1466. */
  1467. if (acpi_disabled && !acpi_ht)
  1468. return 1;
  1469. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1470. /*
  1471. * set sci_int and PM timer address
  1472. */
  1473. acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
  1474. /*
  1475. * Process the Multiple APIC Description Table (MADT), if present
  1476. */
  1477. acpi_process_madt();
  1478. acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
  1479. return 0;
  1480. }
  1481. static int __init parse_acpi(char *arg)
  1482. {
  1483. if (!arg)
  1484. return -EINVAL;
  1485. /* "acpi=off" disables both ACPI table parsing and interpreter */
  1486. if (strcmp(arg, "off") == 0) {
  1487. disable_acpi();
  1488. }
  1489. /* acpi=force to over-ride black-list */
  1490. else if (strcmp(arg, "force") == 0) {
  1491. acpi_force = 1;
  1492. acpi_ht = 1;
  1493. acpi_disabled = 0;
  1494. }
  1495. /* acpi=strict disables out-of-spec workarounds */
  1496. else if (strcmp(arg, "strict") == 0) {
  1497. acpi_strict = 1;
  1498. }
  1499. /* Limit ACPI just to boot-time to enable HT */
  1500. else if (strcmp(arg, "ht") == 0) {
  1501. if (!acpi_force)
  1502. disable_acpi();
  1503. acpi_ht = 1;
  1504. }
  1505. /* "acpi=noirq" disables ACPI interrupt routing */
  1506. else if (strcmp(arg, "noirq") == 0) {
  1507. acpi_noirq_set();
  1508. } else {
  1509. /* Core will printk when we return error. */
  1510. return -EINVAL;
  1511. }
  1512. return 0;
  1513. }
  1514. early_param("acpi", parse_acpi);
  1515. /* FIXME: Using pci= for an ACPI parameter is a travesty. */
  1516. static int __init parse_pci(char *arg)
  1517. {
  1518. if (arg && strcmp(arg, "noacpi") == 0)
  1519. acpi_disable_pci();
  1520. return 0;
  1521. }
  1522. early_param("pci", parse_pci);
  1523. int __init acpi_mps_check(void)
  1524. {
  1525. #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
  1526. /* mptable code is not built-in*/
  1527. if (acpi_disabled || acpi_noirq) {
  1528. printk(KERN_WARNING "MPS support code is not built-in.\n"
  1529. "Using acpi=off or acpi=noirq or pci=noacpi "
  1530. "may have problem\n");
  1531. return 1;
  1532. }
  1533. #endif
  1534. return 0;
  1535. }
  1536. #ifdef CONFIG_X86_IO_APIC
  1537. static int __init parse_acpi_skip_timer_override(char *arg)
  1538. {
  1539. acpi_skip_timer_override = 1;
  1540. return 0;
  1541. }
  1542. early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
  1543. static int __init parse_acpi_use_timer_override(char *arg)
  1544. {
  1545. acpi_use_timer_override = 1;
  1546. return 0;
  1547. }
  1548. early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
  1549. #endif /* CONFIG_X86_IO_APIC */
  1550. static int __init setup_acpi_sci(char *s)
  1551. {
  1552. if (!s)
  1553. return -EINVAL;
  1554. if (!strcmp(s, "edge"))
  1555. acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
  1556. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1557. else if (!strcmp(s, "level"))
  1558. acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
  1559. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1560. else if (!strcmp(s, "high"))
  1561. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
  1562. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1563. else if (!strcmp(s, "low"))
  1564. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
  1565. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1566. else
  1567. return -EINVAL;
  1568. return 0;
  1569. }
  1570. early_param("acpi_sci", setup_acpi_sci);
  1571. int __acpi_acquire_global_lock(unsigned int *lock)
  1572. {
  1573. unsigned int old, new, val;
  1574. do {
  1575. old = *lock;
  1576. new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
  1577. val = cmpxchg(lock, old, new);
  1578. } while (unlikely (val != old));
  1579. return (new < 3) ? -1 : 0;
  1580. }
  1581. int __acpi_release_global_lock(unsigned int *lock)
  1582. {
  1583. unsigned int old, new, val;
  1584. do {
  1585. old = *lock;
  1586. new = old & ~0x3;
  1587. val = cmpxchg(lock, old, new);
  1588. } while (unlikely (val != old));
  1589. return old & 0x1;
  1590. }