boot.c 45 KB

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