boot.c 46 KB

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