boot.c 46 KB

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