boot.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924
  1. /*
  2. * boot.c - Architecture-Specific Low-Level ACPI Boot Support
  3. *
  4. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  5. * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. */
  25. #include <linux/init.h>
  26. #include <linux/acpi.h>
  27. #include <linux/acpi_pmtmr.h>
  28. #include <linux/efi.h>
  29. #include <linux/cpumask.h>
  30. #include <linux/module.h>
  31. #include <linux/dmi.h>
  32. #include <linux/irq.h>
  33. #include <linux/bootmem.h>
  34. #include <linux/ioport.h>
  35. #include <linux/pci.h>
  36. #include <asm/pgtable.h>
  37. #include <asm/io_apic.h>
  38. #include <asm/apic.h>
  39. #include <asm/io.h>
  40. #include <asm/mpspec.h>
  41. #include <asm/smp.h>
  42. static int __initdata acpi_force = 0;
  43. u32 acpi_rsdt_forced;
  44. #ifdef CONFIG_ACPI
  45. int acpi_disabled = 0;
  46. #else
  47. int acpi_disabled = 1;
  48. #endif
  49. EXPORT_SYMBOL(acpi_disabled);
  50. #ifdef CONFIG_X86_64
  51. # include <asm/proto.h>
  52. #endif /* X86 */
  53. #define BAD_MADT_ENTRY(entry, end) ( \
  54. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  55. ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
  56. #define PREFIX "ACPI: "
  57. int acpi_noirq; /* skip ACPI IRQ initialization */
  58. int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
  59. EXPORT_SYMBOL(acpi_pci_disabled);
  60. int acpi_ht __initdata = 1; /* enable HT */
  61. int acpi_lapic;
  62. int acpi_ioapic;
  63. int acpi_strict;
  64. u8 acpi_sci_flags __initdata;
  65. int acpi_sci_override_gsi __initdata;
  66. int acpi_skip_timer_override __initdata;
  67. int acpi_use_timer_override __initdata;
  68. #ifdef CONFIG_X86_LOCAL_APIC
  69. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  70. #endif
  71. #ifndef __HAVE_ARCH_CMPXCHG
  72. #warning ACPI uses CMPXCHG, i486 and later hardware
  73. #endif
  74. /* --------------------------------------------------------------------------
  75. Boot-time Configuration
  76. -------------------------------------------------------------------------- */
  77. /*
  78. * The default interrupt routing model is PIC (8259). This gets
  79. * overridden if IOAPICs are enumerated (below).
  80. */
  81. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  82. /*
  83. * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  84. * to map the target physical address. The problem is that set_fixmap()
  85. * provides a single page, and it is possible that the page is not
  86. * sufficient.
  87. * By using this area, we can map up to MAX_IO_APICS pages temporarily,
  88. * i.e. until the next __va_range() call.
  89. *
  90. * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
  91. * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
  92. * count idx down while incrementing the phys address.
  93. */
  94. char *__init __acpi_map_table(unsigned long phys, unsigned long size)
  95. {
  96. if (!phys || !size)
  97. return NULL;
  98. return early_ioremap(phys, size);
  99. }
  100. void __init __acpi_unmap_table(char *map, unsigned long size)
  101. {
  102. if (!map || !size)
  103. return;
  104. early_iounmap(map, size);
  105. }
  106. #ifdef CONFIG_PCI_MMCONFIG
  107. static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
  108. /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
  109. struct acpi_mcfg_allocation *pci_mmcfg_config;
  110. int pci_mmcfg_config_num;
  111. static int __init acpi_mcfg_oem_check(struct acpi_table_mcfg *mcfg)
  112. {
  113. if (!strcmp(mcfg->header.oem_id, "SGI"))
  114. acpi_mcfg_64bit_base_addr = TRUE;
  115. return 0;
  116. }
  117. int __init acpi_parse_mcfg(struct acpi_table_header *header)
  118. {
  119. struct acpi_table_mcfg *mcfg;
  120. unsigned long i;
  121. int config_size;
  122. if (!header)
  123. return -EINVAL;
  124. mcfg = (struct acpi_table_mcfg *)header;
  125. /* how many config structures do we have */
  126. pci_mmcfg_config_num = 0;
  127. i = header->length - sizeof(struct acpi_table_mcfg);
  128. while (i >= sizeof(struct acpi_mcfg_allocation)) {
  129. ++pci_mmcfg_config_num;
  130. i -= sizeof(struct acpi_mcfg_allocation);
  131. };
  132. if (pci_mmcfg_config_num == 0) {
  133. printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
  134. return -ENODEV;
  135. }
  136. config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
  137. pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
  138. if (!pci_mmcfg_config) {
  139. printk(KERN_WARNING PREFIX
  140. "No memory for MCFG config tables\n");
  141. return -ENOMEM;
  142. }
  143. memcpy(pci_mmcfg_config, &mcfg[1], config_size);
  144. acpi_mcfg_oem_check(mcfg);
  145. for (i = 0; i < pci_mmcfg_config_num; ++i) {
  146. if ((pci_mmcfg_config[i].address > 0xFFFFFFFF) &&
  147. !acpi_mcfg_64bit_base_addr) {
  148. printk(KERN_ERR PREFIX
  149. "MMCONFIG not in low 4GB of memory\n");
  150. kfree(pci_mmcfg_config);
  151. pci_mmcfg_config_num = 0;
  152. return -ENODEV;
  153. }
  154. }
  155. return 0;
  156. }
  157. #endif /* CONFIG_PCI_MMCONFIG */
  158. #ifdef CONFIG_X86_LOCAL_APIC
  159. static int __init acpi_parse_madt(struct acpi_table_header *table)
  160. {
  161. struct acpi_table_madt *madt = NULL;
  162. if (!cpu_has_apic)
  163. return -EINVAL;
  164. madt = (struct acpi_table_madt *)table;
  165. if (!madt) {
  166. printk(KERN_WARNING PREFIX "Unable to map MADT\n");
  167. return -ENODEV;
  168. }
  169. if (madt->address) {
  170. acpi_lapic_addr = (u64) madt->address;
  171. printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
  172. madt->address);
  173. }
  174. default_acpi_madt_oem_check(madt->header.oem_id,
  175. madt->header.oem_table_id);
  176. return 0;
  177. }
  178. static void __cpuinit acpi_register_lapic(int id, u8 enabled)
  179. {
  180. unsigned int ver = 0;
  181. if (!enabled) {
  182. ++disabled_cpus;
  183. return;
  184. }
  185. if (boot_cpu_physical_apicid != -1U)
  186. ver = apic_version[boot_cpu_physical_apicid];
  187. generic_processor_info(id, ver);
  188. }
  189. static int __init
  190. acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
  191. {
  192. struct acpi_madt_local_x2apic *processor = NULL;
  193. processor = (struct acpi_madt_local_x2apic *)header;
  194. if (BAD_MADT_ENTRY(processor, end))
  195. return -EINVAL;
  196. acpi_table_print_madt_entry(header);
  197. #ifdef CONFIG_X86_X2APIC
  198. /*
  199. * We need to register disabled CPU as well to permit
  200. * counting disabled CPUs. This allows us to size
  201. * cpus_possible_map more accurately, to permit
  202. * to not preallocating memory for all NR_CPUS
  203. * when we use CPU hotplug.
  204. */
  205. acpi_register_lapic(processor->local_apic_id, /* APIC ID */
  206. processor->lapic_flags & ACPI_MADT_ENABLED);
  207. #else
  208. printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
  209. #endif
  210. return 0;
  211. }
  212. static int __init
  213. acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
  214. {
  215. struct acpi_madt_local_apic *processor = NULL;
  216. processor = (struct acpi_madt_local_apic *)header;
  217. if (BAD_MADT_ENTRY(processor, end))
  218. return -EINVAL;
  219. acpi_table_print_madt_entry(header);
  220. /*
  221. * We need to register disabled CPU as well to permit
  222. * counting disabled CPUs. This allows us to size
  223. * cpus_possible_map more accurately, to permit
  224. * to not preallocating memory for all NR_CPUS
  225. * when we use CPU hotplug.
  226. */
  227. acpi_register_lapic(processor->id, /* APIC ID */
  228. processor->lapic_flags & ACPI_MADT_ENABLED);
  229. return 0;
  230. }
  231. static int __init
  232. acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
  233. {
  234. struct acpi_madt_local_sapic *processor = NULL;
  235. processor = (struct acpi_madt_local_sapic *)header;
  236. if (BAD_MADT_ENTRY(processor, end))
  237. return -EINVAL;
  238. acpi_table_print_madt_entry(header);
  239. acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
  240. processor->lapic_flags & ACPI_MADT_ENABLED);
  241. return 0;
  242. }
  243. static int __init
  244. acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
  245. const unsigned long end)
  246. {
  247. struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
  248. lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
  249. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  250. return -EINVAL;
  251. acpi_lapic_addr = lapic_addr_ovr->address;
  252. return 0;
  253. }
  254. static int __init
  255. acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
  256. const unsigned long end)
  257. {
  258. struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
  259. x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header;
  260. if (BAD_MADT_ENTRY(x2apic_nmi, end))
  261. return -EINVAL;
  262. acpi_table_print_madt_entry(header);
  263. if (x2apic_nmi->lint != 1)
  264. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  265. return 0;
  266. }
  267. static int __init
  268. acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
  269. {
  270. struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
  271. lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
  272. if (BAD_MADT_ENTRY(lapic_nmi, end))
  273. return -EINVAL;
  274. acpi_table_print_madt_entry(header);
  275. if (lapic_nmi->lint != 1)
  276. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  277. return 0;
  278. }
  279. #endif /*CONFIG_X86_LOCAL_APIC */
  280. #ifdef CONFIG_X86_IO_APIC
  281. static int __init
  282. acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
  283. {
  284. struct acpi_madt_io_apic *ioapic = NULL;
  285. ioapic = (struct acpi_madt_io_apic *)header;
  286. if (BAD_MADT_ENTRY(ioapic, end))
  287. return -EINVAL;
  288. acpi_table_print_madt_entry(header);
  289. mp_register_ioapic(ioapic->id,
  290. ioapic->address, ioapic->global_irq_base);
  291. return 0;
  292. }
  293. /*
  294. * Parse Interrupt Source Override for the ACPI SCI
  295. */
  296. static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  297. {
  298. if (trigger == 0) /* compatible SCI trigger is level */
  299. trigger = 3;
  300. if (polarity == 0) /* compatible SCI polarity is low */
  301. polarity = 3;
  302. /* Command-line over-ride via acpi_sci= */
  303. if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
  304. trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
  305. if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
  306. polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
  307. /*
  308. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  309. * If GSI is < 16, this will update its flags,
  310. * else it will create a new mp_irqs[] entry.
  311. */
  312. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  313. /*
  314. * stash over-ride to indicate we've been here
  315. * and for later update of acpi_gbl_FADT
  316. */
  317. acpi_sci_override_gsi = gsi;
  318. return;
  319. }
  320. static int __init
  321. acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
  322. const unsigned long end)
  323. {
  324. struct acpi_madt_interrupt_override *intsrc = NULL;
  325. intsrc = (struct acpi_madt_interrupt_override *)header;
  326. if (BAD_MADT_ENTRY(intsrc, end))
  327. return -EINVAL;
  328. acpi_table_print_madt_entry(header);
  329. if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
  330. acpi_sci_ioapic_setup(intsrc->global_irq,
  331. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  332. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
  333. return 0;
  334. }
  335. if (acpi_skip_timer_override &&
  336. intsrc->source_irq == 0 && intsrc->global_irq == 2) {
  337. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  338. return 0;
  339. }
  340. mp_override_legacy_irq(intsrc->source_irq,
  341. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  342. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
  343. intsrc->global_irq);
  344. return 0;
  345. }
  346. static int __init
  347. acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
  348. {
  349. struct acpi_madt_nmi_source *nmi_src = NULL;
  350. nmi_src = (struct acpi_madt_nmi_source *)header;
  351. if (BAD_MADT_ENTRY(nmi_src, end))
  352. return -EINVAL;
  353. acpi_table_print_madt_entry(header);
  354. /* TBD: Support nimsrc entries? */
  355. return 0;
  356. }
  357. #endif /* CONFIG_X86_IO_APIC */
  358. /*
  359. * acpi_pic_sci_set_trigger()
  360. *
  361. * use ELCR to set PIC-mode trigger type for SCI
  362. *
  363. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  364. * it may require Edge Trigger -- use "acpi_sci=edge"
  365. *
  366. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  367. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  368. * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
  369. * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
  370. */
  371. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  372. {
  373. unsigned int mask = 1 << irq;
  374. unsigned int old, new;
  375. /* Real old ELCR mask */
  376. old = inb(0x4d0) | (inb(0x4d1) << 8);
  377. /*
  378. * If we use ACPI to set PCI IRQs, then we should clear ELCR
  379. * since we will set it correctly as we enable the PCI irq
  380. * routing.
  381. */
  382. new = acpi_noirq ? old : 0;
  383. /*
  384. * Update SCI information in the ELCR, it isn't in the PCI
  385. * routing tables..
  386. */
  387. switch (trigger) {
  388. case 1: /* Edge - clear */
  389. new &= ~mask;
  390. break;
  391. case 3: /* Level - set */
  392. new |= mask;
  393. break;
  394. }
  395. if (old == new)
  396. return;
  397. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  398. outb(new, 0x4d0);
  399. outb(new >> 8, 0x4d1);
  400. }
  401. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  402. {
  403. *irq = gsi;
  404. return 0;
  405. }
  406. /*
  407. * success: return IRQ number (>=0)
  408. * failure: return < 0
  409. */
  410. int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
  411. {
  412. unsigned int irq;
  413. unsigned int plat_gsi = gsi;
  414. #ifdef CONFIG_PCI
  415. /*
  416. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  417. */
  418. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  419. if (trigger == ACPI_LEVEL_SENSITIVE)
  420. eisa_set_level_irq(gsi);
  421. }
  422. #endif
  423. #ifdef CONFIG_X86_IO_APIC
  424. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  425. plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
  426. }
  427. #endif
  428. acpi_gsi_to_irq(plat_gsi, &irq);
  429. return irq;
  430. }
  431. /*
  432. * ACPI based hotplug support for CPU
  433. */
  434. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  435. static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
  436. {
  437. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  438. union acpi_object *obj;
  439. struct acpi_madt_local_apic *lapic;
  440. cpumask_var_t tmp_map, new_map;
  441. u8 physid;
  442. int cpu;
  443. int retval = -ENOMEM;
  444. if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
  445. return -EINVAL;
  446. if (!buffer.length || !buffer.pointer)
  447. return -EINVAL;
  448. obj = buffer.pointer;
  449. if (obj->type != ACPI_TYPE_BUFFER ||
  450. obj->buffer.length < sizeof(*lapic)) {
  451. kfree(buffer.pointer);
  452. return -EINVAL;
  453. }
  454. lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
  455. if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
  456. !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
  457. kfree(buffer.pointer);
  458. return -EINVAL;
  459. }
  460. physid = lapic->id;
  461. kfree(buffer.pointer);
  462. buffer.length = ACPI_ALLOCATE_BUFFER;
  463. buffer.pointer = NULL;
  464. if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
  465. goto out;
  466. if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
  467. goto free_tmp_map;
  468. cpumask_copy(tmp_map, cpu_present_mask);
  469. acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
  470. /*
  471. * If mp_register_lapic successfully generates a new logical cpu
  472. * number, then the following will get us exactly what was mapped
  473. */
  474. cpumask_andnot(new_map, cpu_present_mask, tmp_map);
  475. if (cpumask_empty(new_map)) {
  476. printk ("Unable to map lapic to logical cpu number\n");
  477. retval = -EINVAL;
  478. goto free_new_map;
  479. }
  480. cpu = cpumask_first(new_map);
  481. *pcpu = cpu;
  482. retval = 0;
  483. free_new_map:
  484. free_cpumask_var(new_map);
  485. free_tmp_map:
  486. free_cpumask_var(tmp_map);
  487. out:
  488. return retval;
  489. }
  490. /* wrapper to silence section mismatch warning */
  491. int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
  492. {
  493. return _acpi_map_lsapic(handle, pcpu);
  494. }
  495. EXPORT_SYMBOL(acpi_map_lsapic);
  496. int acpi_unmap_lsapic(int cpu)
  497. {
  498. per_cpu(x86_cpu_to_apicid, cpu) = -1;
  499. set_cpu_present(cpu, false);
  500. num_processors--;
  501. return (0);
  502. }
  503. EXPORT_SYMBOL(acpi_unmap_lsapic);
  504. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  505. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  506. {
  507. /* TBD */
  508. return -EINVAL;
  509. }
  510. EXPORT_SYMBOL(acpi_register_ioapic);
  511. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  512. {
  513. /* TBD */
  514. return -EINVAL;
  515. }
  516. EXPORT_SYMBOL(acpi_unregister_ioapic);
  517. static int __init acpi_parse_sbf(struct acpi_table_header *table)
  518. {
  519. struct acpi_table_boot *sb;
  520. sb = (struct acpi_table_boot *)table;
  521. if (!sb) {
  522. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  523. return -ENODEV;
  524. }
  525. sbf_port = sb->cmos_index; /* Save CMOS port */
  526. return 0;
  527. }
  528. #ifdef CONFIG_HPET_TIMER
  529. #include <asm/hpet.h>
  530. static struct __initdata resource *hpet_res;
  531. static int __init acpi_parse_hpet(struct acpi_table_header *table)
  532. {
  533. struct acpi_table_hpet *hpet_tbl;
  534. hpet_tbl = (struct acpi_table_hpet *)table;
  535. if (!hpet_tbl) {
  536. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  537. return -ENODEV;
  538. }
  539. if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
  540. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  541. "memory.\n");
  542. return -1;
  543. }
  544. hpet_address = hpet_tbl->address.address;
  545. /*
  546. * Some broken BIOSes advertise HPET at 0x0. We really do not
  547. * want to allocate a resource there.
  548. */
  549. if (!hpet_address) {
  550. printk(KERN_WARNING PREFIX
  551. "HPET id: %#x base: %#lx is invalid\n",
  552. hpet_tbl->id, hpet_address);
  553. return 0;
  554. }
  555. #ifdef CONFIG_X86_64
  556. /*
  557. * Some even more broken BIOSes advertise HPET at
  558. * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
  559. * some noise:
  560. */
  561. if (hpet_address == 0xfed0000000000000UL) {
  562. if (!hpet_force_user) {
  563. printk(KERN_WARNING PREFIX "HPET id: %#x "
  564. "base: 0xfed0000000000000 is bogus\n "
  565. "try hpet=force on the kernel command line to "
  566. "fix it up to 0xfed00000.\n", hpet_tbl->id);
  567. hpet_address = 0;
  568. return 0;
  569. }
  570. printk(KERN_WARNING PREFIX
  571. "HPET id: %#x base: 0xfed0000000000000 fixed up "
  572. "to 0xfed00000.\n", hpet_tbl->id);
  573. hpet_address >>= 32;
  574. }
  575. #endif
  576. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  577. hpet_tbl->id, hpet_address);
  578. /*
  579. * Allocate and initialize the HPET firmware resource for adding into
  580. * the resource tree during the lateinit timeframe.
  581. */
  582. #define HPET_RESOURCE_NAME_SIZE 9
  583. hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
  584. hpet_res->name = (void *)&hpet_res[1];
  585. hpet_res->flags = IORESOURCE_MEM;
  586. snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
  587. hpet_tbl->sequence);
  588. hpet_res->start = hpet_address;
  589. hpet_res->end = hpet_address + (1 * 1024) - 1;
  590. return 0;
  591. }
  592. /*
  593. * hpet_insert_resource inserts the HPET resources used into the resource
  594. * tree.
  595. */
  596. static __init int hpet_insert_resource(void)
  597. {
  598. if (!hpet_res)
  599. return 1;
  600. return insert_resource(&iomem_resource, hpet_res);
  601. }
  602. late_initcall(hpet_insert_resource);
  603. #else
  604. #define acpi_parse_hpet NULL
  605. #endif
  606. static int __init acpi_parse_fadt(struct acpi_table_header *table)
  607. {
  608. #ifdef CONFIG_X86_PM_TIMER
  609. /* detect the location of the ACPI PM Timer */
  610. if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
  611. /* FADT rev. 2 */
  612. if (acpi_gbl_FADT.xpm_timer_block.space_id !=
  613. ACPI_ADR_SPACE_SYSTEM_IO)
  614. return 0;
  615. pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
  616. /*
  617. * "X" fields are optional extensions to the original V1.0
  618. * fields, so we must selectively expand V1.0 fields if the
  619. * corresponding X field is zero.
  620. */
  621. if (!pmtmr_ioport)
  622. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  623. } else {
  624. /* FADT rev. 1 */
  625. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  626. }
  627. if (pmtmr_ioport)
  628. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  629. pmtmr_ioport);
  630. #endif
  631. return 0;
  632. }
  633. #ifdef CONFIG_X86_LOCAL_APIC
  634. /*
  635. * Parse LAPIC entries in MADT
  636. * returns 0 on success, < 0 on error
  637. */
  638. static void __init acpi_register_lapic_address(unsigned long address)
  639. {
  640. mp_lapic_addr = address;
  641. set_fixmap_nocache(FIX_APIC_BASE, address);
  642. if (boot_cpu_physical_apicid == -1U) {
  643. boot_cpu_physical_apicid = read_apic_id();
  644. apic_version[boot_cpu_physical_apicid] =
  645. GET_APIC_VERSION(apic_read(APIC_LVR));
  646. }
  647. }
  648. static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
  649. {
  650. int count;
  651. if (!cpu_has_apic)
  652. return -ENODEV;
  653. /*
  654. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  655. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  656. */
  657. count =
  658. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  659. acpi_parse_lapic_addr_ovr, 0);
  660. if (count < 0) {
  661. printk(KERN_ERR PREFIX
  662. "Error parsing LAPIC address override entry\n");
  663. return count;
  664. }
  665. acpi_register_lapic_address(acpi_lapic_addr);
  666. return count;
  667. }
  668. static int __init acpi_parse_madt_lapic_entries(void)
  669. {
  670. int count;
  671. int x2count = 0;
  672. if (!cpu_has_apic)
  673. return -ENODEV;
  674. /*
  675. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  676. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  677. */
  678. count =
  679. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  680. acpi_parse_lapic_addr_ovr, 0);
  681. if (count < 0) {
  682. printk(KERN_ERR PREFIX
  683. "Error parsing LAPIC address override entry\n");
  684. return count;
  685. }
  686. acpi_register_lapic_address(acpi_lapic_addr);
  687. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
  688. acpi_parse_sapic, MAX_APICS);
  689. if (!count) {
  690. x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC,
  691. acpi_parse_x2apic, MAX_APICS);
  692. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
  693. acpi_parse_lapic, MAX_APICS);
  694. }
  695. if (!count && !x2count) {
  696. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  697. /* TBD: Cleanup to allow fallback to MPS */
  698. return -ENODEV;
  699. } else if (count < 0 || x2count < 0) {
  700. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  701. /* TBD: Cleanup to allow fallback to MPS */
  702. return count;
  703. }
  704. x2count =
  705. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI,
  706. acpi_parse_x2apic_nmi, 0);
  707. count =
  708. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
  709. if (count < 0 || x2count < 0) {
  710. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  711. /* TBD: Cleanup to allow fallback to MPS */
  712. return count;
  713. }
  714. return 0;
  715. }
  716. #endif /* CONFIG_X86_LOCAL_APIC */
  717. #ifdef CONFIG_X86_IO_APIC
  718. #define MP_ISA_BUS 0
  719. #ifdef CONFIG_X86_ES7000
  720. extern int es7000_plat;
  721. #endif
  722. static struct {
  723. int gsi_base;
  724. int gsi_end;
  725. } mp_ioapic_routing[MAX_IO_APICS];
  726. int mp_find_ioapic(int gsi)
  727. {
  728. int i = 0;
  729. /* Find the IOAPIC that manages this GSI. */
  730. for (i = 0; i < nr_ioapics; i++) {
  731. if ((gsi >= mp_ioapic_routing[i].gsi_base)
  732. && (gsi <= mp_ioapic_routing[i].gsi_end))
  733. return i;
  734. }
  735. printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
  736. return -1;
  737. }
  738. int mp_find_ioapic_pin(int ioapic, int gsi)
  739. {
  740. if (WARN_ON(ioapic == -1))
  741. return -1;
  742. if (WARN_ON(gsi > mp_ioapic_routing[ioapic].gsi_end))
  743. return -1;
  744. return gsi - mp_ioapic_routing[ioapic].gsi_base;
  745. }
  746. static u8 __init uniq_ioapic_id(u8 id)
  747. {
  748. #ifdef CONFIG_X86_32
  749. if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
  750. !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
  751. return io_apic_get_unique_id(nr_ioapics, id);
  752. else
  753. return id;
  754. #else
  755. int i;
  756. DECLARE_BITMAP(used, 256);
  757. bitmap_zero(used, 256);
  758. for (i = 0; i < nr_ioapics; i++) {
  759. struct mpc_ioapic *ia = &mp_ioapics[i];
  760. __set_bit(ia->apicid, used);
  761. }
  762. if (!test_bit(id, used))
  763. return id;
  764. return find_first_zero_bit(used, 256);
  765. #endif
  766. }
  767. static int bad_ioapic(unsigned long address)
  768. {
  769. if (nr_ioapics >= MAX_IO_APICS) {
  770. printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
  771. "(found %d)\n", MAX_IO_APICS, nr_ioapics);
  772. panic("Recompile kernel with bigger MAX_IO_APICS!\n");
  773. }
  774. if (!address) {
  775. printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
  776. " found in table, skipping!\n");
  777. return 1;
  778. }
  779. return 0;
  780. }
  781. void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
  782. {
  783. int idx = 0;
  784. if (bad_ioapic(address))
  785. return;
  786. idx = nr_ioapics;
  787. mp_ioapics[idx].type = MP_IOAPIC;
  788. mp_ioapics[idx].flags = MPC_APIC_USABLE;
  789. mp_ioapics[idx].apicaddr = address;
  790. set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
  791. mp_ioapics[idx].apicid = uniq_ioapic_id(id);
  792. mp_ioapics[idx].apicver = io_apic_get_version(idx);
  793. /*
  794. * Build basic GSI lookup table to facilitate gsi->io_apic lookups
  795. * and to prevent reprogramming of IOAPIC pins (PCI GSIs).
  796. */
  797. mp_ioapic_routing[idx].gsi_base = gsi_base;
  798. mp_ioapic_routing[idx].gsi_end = gsi_base +
  799. io_apic_get_redir_entries(idx);
  800. printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%x, "
  801. "GSI %d-%d\n", idx, mp_ioapics[idx].apicid,
  802. mp_ioapics[idx].apicver, mp_ioapics[idx].apicaddr,
  803. mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end);
  804. nr_ioapics++;
  805. }
  806. int __init acpi_probe_gsi(void)
  807. {
  808. int idx;
  809. int gsi;
  810. int max_gsi = 0;
  811. if (acpi_disabled)
  812. return 0;
  813. if (!acpi_ioapic)
  814. return 0;
  815. max_gsi = 0;
  816. for (idx = 0; idx < nr_ioapics; idx++) {
  817. gsi = mp_ioapic_routing[idx].gsi_end;
  818. if (gsi > max_gsi)
  819. max_gsi = gsi;
  820. }
  821. return max_gsi + 1;
  822. }
  823. static void assign_to_mp_irq(struct mpc_intsrc *m,
  824. struct mpc_intsrc *mp_irq)
  825. {
  826. memcpy(mp_irq, m, sizeof(struct mpc_intsrc));
  827. }
  828. static int mp_irq_cmp(struct mpc_intsrc *mp_irq,
  829. struct mpc_intsrc *m)
  830. {
  831. return memcmp(mp_irq, m, sizeof(struct mpc_intsrc));
  832. }
  833. static void save_mp_irq(struct mpc_intsrc *m)
  834. {
  835. int i;
  836. for (i = 0; i < mp_irq_entries; i++) {
  837. if (!mp_irq_cmp(&mp_irqs[i], m))
  838. return;
  839. }
  840. assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
  841. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  842. panic("Max # of irq sources exceeded!!\n");
  843. }
  844. void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
  845. {
  846. int ioapic;
  847. int pin;
  848. struct mpc_intsrc mp_irq;
  849. /*
  850. * Convert 'gsi' to 'ioapic.pin'.
  851. */
  852. ioapic = mp_find_ioapic(gsi);
  853. if (ioapic < 0)
  854. return;
  855. pin = mp_find_ioapic_pin(ioapic, gsi);
  856. /*
  857. * TBD: This check is for faulty timer entries, where the override
  858. * erroneously sets the trigger to level, resulting in a HUGE
  859. * increase of timer interrupts!
  860. */
  861. if ((bus_irq == 0) && (trigger == 3))
  862. trigger = 1;
  863. mp_irq.type = MP_INTSRC;
  864. mp_irq.irqtype = mp_INT;
  865. mp_irq.irqflag = (trigger << 2) | polarity;
  866. mp_irq.srcbus = MP_ISA_BUS;
  867. mp_irq.srcbusirq = bus_irq; /* IRQ */
  868. mp_irq.dstapic = mp_ioapics[ioapic].apicid; /* APIC ID */
  869. mp_irq.dstirq = pin; /* INTIN# */
  870. save_mp_irq(&mp_irq);
  871. }
  872. void __init mp_config_acpi_legacy_irqs(void)
  873. {
  874. int i;
  875. int ioapic;
  876. unsigned int dstapic;
  877. struct mpc_intsrc mp_irq;
  878. #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
  879. /*
  880. * Fabricate the legacy ISA bus (bus #31).
  881. */
  882. mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
  883. #endif
  884. set_bit(MP_ISA_BUS, mp_bus_not_pci);
  885. pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
  886. #ifdef CONFIG_X86_ES7000
  887. /*
  888. * Older generations of ES7000 have no legacy identity mappings
  889. */
  890. if (es7000_plat == 1)
  891. return;
  892. #endif
  893. /*
  894. * Locate the IOAPIC that manages the ISA IRQs (0-15).
  895. */
  896. ioapic = mp_find_ioapic(0);
  897. if (ioapic < 0)
  898. return;
  899. dstapic = mp_ioapics[ioapic].apicid;
  900. /*
  901. * Use the default configuration for the IRQs 0-15. Unless
  902. * overridden by (MADT) interrupt source override entries.
  903. */
  904. for (i = 0; i < 16; i++) {
  905. int idx;
  906. for (idx = 0; idx < mp_irq_entries; idx++) {
  907. struct mpc_intsrc *irq = mp_irqs + idx;
  908. /* Do we already have a mapping for this ISA IRQ? */
  909. if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
  910. break;
  911. /* Do we already have a mapping for this IOAPIC pin */
  912. if (irq->dstapic == dstapic && irq->dstirq == i)
  913. break;
  914. }
  915. if (idx != mp_irq_entries) {
  916. printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
  917. continue; /* IRQ already used */
  918. }
  919. mp_irq.type = MP_INTSRC;
  920. mp_irq.irqflag = 0; /* Conforming */
  921. mp_irq.srcbus = MP_ISA_BUS;
  922. mp_irq.dstapic = dstapic;
  923. mp_irq.irqtype = mp_INT;
  924. mp_irq.srcbusirq = i; /* Identity mapped */
  925. mp_irq.dstirq = i;
  926. save_mp_irq(&mp_irq);
  927. }
  928. }
  929. static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
  930. int polarity)
  931. {
  932. #ifdef CONFIG_X86_MPPARSE
  933. struct mpc_intsrc mp_irq;
  934. struct pci_dev *pdev;
  935. unsigned char number;
  936. unsigned int devfn;
  937. int ioapic;
  938. u8 pin;
  939. if (!acpi_ioapic)
  940. return 0;
  941. if (!dev)
  942. return 0;
  943. if (dev->bus != &pci_bus_type)
  944. return 0;
  945. pdev = to_pci_dev(dev);
  946. number = pdev->bus->number;
  947. devfn = pdev->devfn;
  948. pin = pdev->pin;
  949. /* print the entry should happen on mptable identically */
  950. mp_irq.type = MP_INTSRC;
  951. mp_irq.irqtype = mp_INT;
  952. mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
  953. (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
  954. mp_irq.srcbus = number;
  955. mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
  956. ioapic = mp_find_ioapic(gsi);
  957. mp_irq.dstapic = mp_ioapics[ioapic].apicid;
  958. mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
  959. save_mp_irq(&mp_irq);
  960. #endif
  961. return 0;
  962. }
  963. int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
  964. {
  965. int ioapic;
  966. int ioapic_pin;
  967. struct io_apic_irq_attr irq_attr;
  968. if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
  969. return gsi;
  970. /* Don't set up the ACPI SCI because it's already set up */
  971. if (acpi_gbl_FADT.sci_interrupt == gsi)
  972. return gsi;
  973. ioapic = mp_find_ioapic(gsi);
  974. if (ioapic < 0) {
  975. printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
  976. return gsi;
  977. }
  978. ioapic_pin = mp_find_ioapic_pin(ioapic, gsi);
  979. #ifdef CONFIG_X86_32
  980. if (ioapic_renumber_irq)
  981. gsi = ioapic_renumber_irq(ioapic, gsi);
  982. #endif
  983. if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
  984. printk(KERN_ERR "Invalid reference to IOAPIC pin "
  985. "%d-%d\n", mp_ioapics[ioapic].apicid,
  986. ioapic_pin);
  987. return gsi;
  988. }
  989. if (enable_update_mptable)
  990. mp_config_acpi_gsi(dev, gsi, trigger, polarity);
  991. set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin,
  992. trigger == ACPI_EDGE_SENSITIVE ? 0 : 1,
  993. polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
  994. io_apic_set_pci_routing(dev, gsi, &irq_attr);
  995. return gsi;
  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_BIGSMP
  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 linux-acpi@vger.kernel.org
  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. }