boot.c 46 KB

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