boot.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917
  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 mpc_ioapic *ia = &mp_ioapics[i];
  733. __set_bit(ia->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].type = MP_IOAPIC;
  761. mp_ioapics[idx].flags = MPC_APIC_USABLE;
  762. mp_ioapics[idx].apicaddr = address;
  763. set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
  764. mp_ioapics[idx].apicid = uniq_ioapic_id(id);
  765. #ifdef CONFIG_X86_32
  766. mp_ioapics[idx].apicver = io_apic_get_version(idx);
  767. #else
  768. mp_ioapics[idx].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].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%x, "
  779. "GSI %d-%d\n", idx, mp_ioapics[idx].apicid,
  780. mp_ioapics[idx].apicver, mp_ioapics[idx].apicaddr,
  781. mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end);
  782. nr_ioapics++;
  783. }
  784. static void assign_to_mp_irq(struct mpc_intsrc *m,
  785. struct mpc_intsrc *mp_irq)
  786. {
  787. memcpy(mp_irq, m, sizeof(struct mpc_intsrc));
  788. }
  789. static int mp_irq_cmp(struct mpc_intsrc *mp_irq,
  790. struct mpc_intsrc *m)
  791. {
  792. return memcmp(mp_irq, m, sizeof(struct mpc_intsrc));
  793. }
  794. static void save_mp_irq(struct mpc_intsrc *m)
  795. {
  796. int i;
  797. for (i = 0; i < mp_irq_entries; i++) {
  798. if (!mp_irq_cmp(&mp_irqs[i], m))
  799. return;
  800. }
  801. assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
  802. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  803. panic("Max # of irq sources exceeded!!\n");
  804. }
  805. void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
  806. {
  807. int ioapic;
  808. int pin;
  809. struct mpc_intsrc mp_irq;
  810. /*
  811. * Convert 'gsi' to 'ioapic.pin'.
  812. */
  813. ioapic = mp_find_ioapic(gsi);
  814. if (ioapic < 0)
  815. return;
  816. pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  817. /*
  818. * TBD: This check is for faulty timer entries, where the override
  819. * erroneously sets the trigger to level, resulting in a HUGE
  820. * increase of timer interrupts!
  821. */
  822. if ((bus_irq == 0) && (trigger == 3))
  823. trigger = 1;
  824. mp_irq.type = MP_INTSRC;
  825. mp_irq.irqtype = mp_INT;
  826. mp_irq.irqflag = (trigger << 2) | polarity;
  827. mp_irq.srcbus = MP_ISA_BUS;
  828. mp_irq.srcbusirq = bus_irq; /* IRQ */
  829. mp_irq.dstapic = mp_ioapics[ioapic].apicid; /* APIC ID */
  830. mp_irq.dstirq = pin; /* INTIN# */
  831. save_mp_irq(&mp_irq);
  832. }
  833. void __init mp_config_acpi_legacy_irqs(void)
  834. {
  835. int i;
  836. int ioapic;
  837. unsigned int dstapic;
  838. struct mpc_intsrc mp_irq;
  839. #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
  840. /*
  841. * Fabricate the legacy ISA bus (bus #31).
  842. */
  843. mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
  844. #endif
  845. set_bit(MP_ISA_BUS, mp_bus_not_pci);
  846. pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
  847. #ifdef CONFIG_X86_ES7000
  848. /*
  849. * Older generations of ES7000 have no legacy identity mappings
  850. */
  851. if (es7000_plat == 1)
  852. return;
  853. #endif
  854. /*
  855. * Locate the IOAPIC that manages the ISA IRQs (0-15).
  856. */
  857. ioapic = mp_find_ioapic(0);
  858. if (ioapic < 0)
  859. return;
  860. dstapic = mp_ioapics[ioapic].apicid;
  861. /*
  862. * Use the default configuration for the IRQs 0-15. Unless
  863. * overridden by (MADT) interrupt source override entries.
  864. */
  865. for (i = 0; i < 16; i++) {
  866. int idx;
  867. for (idx = 0; idx < mp_irq_entries; idx++) {
  868. struct mpc_intsrc *irq = mp_irqs + idx;
  869. /* Do we already have a mapping for this ISA IRQ? */
  870. if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
  871. break;
  872. /* Do we already have a mapping for this IOAPIC pin */
  873. if (irq->dstapic == dstapic && irq->dstirq == i)
  874. break;
  875. }
  876. if (idx != mp_irq_entries) {
  877. printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
  878. continue; /* IRQ already used */
  879. }
  880. mp_irq.type = MP_INTSRC;
  881. mp_irq.irqflag = 0; /* Conforming */
  882. mp_irq.srcbus = MP_ISA_BUS;
  883. mp_irq.dstapic = dstapic;
  884. mp_irq.irqtype = mp_INT;
  885. mp_irq.srcbusirq = i; /* Identity mapped */
  886. mp_irq.dstirq = i;
  887. save_mp_irq(&mp_irq);
  888. }
  889. }
  890. int mp_register_gsi(u32 gsi, int triggering, int polarity)
  891. {
  892. int ioapic;
  893. int ioapic_pin;
  894. #ifdef CONFIG_X86_32
  895. #define MAX_GSI_NUM 4096
  896. #define IRQ_COMPRESSION_START 64
  897. static int pci_irq = IRQ_COMPRESSION_START;
  898. /*
  899. * Mapping between Global System Interrupts, which
  900. * represent all possible interrupts, and IRQs
  901. * assigned to actual devices.
  902. */
  903. static int gsi_to_irq[MAX_GSI_NUM];
  904. #else
  905. if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
  906. return gsi;
  907. #endif
  908. /* Don't set up the ACPI SCI because it's already set up */
  909. if (acpi_gbl_FADT.sci_interrupt == gsi)
  910. return gsi;
  911. ioapic = mp_find_ioapic(gsi);
  912. if (ioapic < 0) {
  913. printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
  914. return gsi;
  915. }
  916. ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  917. #ifdef CONFIG_X86_32
  918. if (ioapic_renumber_irq)
  919. gsi = ioapic_renumber_irq(ioapic, gsi);
  920. #endif
  921. /*
  922. * Avoid pin reprogramming. PRTs typically include entries
  923. * with redundant pin->gsi mappings (but unique PCI devices);
  924. * we only program the IOAPIC on the first.
  925. */
  926. if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
  927. printk(KERN_ERR "Invalid reference to IOAPIC pin "
  928. "%d-%d\n", mp_ioapic_routing[ioapic].apic_id,
  929. ioapic_pin);
  930. return gsi;
  931. }
  932. if (test_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed)) {
  933. pr_debug("Pin %d-%d already programmed\n",
  934. mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
  935. #ifdef CONFIG_X86_32
  936. return (gsi < IRQ_COMPRESSION_START ? gsi : gsi_to_irq[gsi]);
  937. #else
  938. return gsi;
  939. #endif
  940. }
  941. set_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed);
  942. #ifdef CONFIG_X86_32
  943. /*
  944. * For GSI >= 64, use IRQ compression
  945. */
  946. if ((gsi >= IRQ_COMPRESSION_START)
  947. && (triggering == ACPI_LEVEL_SENSITIVE)) {
  948. /*
  949. * For PCI devices assign IRQs in order, avoiding gaps
  950. * due to unused I/O APIC pins.
  951. */
  952. int irq = gsi;
  953. if (gsi < MAX_GSI_NUM) {
  954. /*
  955. * Retain the VIA chipset work-around (gsi > 15), but
  956. * avoid a problem where the 8254 timer (IRQ0) is setup
  957. * via an override (so it's not on pin 0 of the ioapic),
  958. * and at the same time, the pin 0 interrupt is a PCI
  959. * type. The gsi > 15 test could cause these two pins
  960. * to be shared as IRQ0, and they are not shareable.
  961. * So test for this condition, and if necessary, avoid
  962. * the pin collision.
  963. */
  964. gsi = pci_irq++;
  965. /*
  966. * Don't assign IRQ used by ACPI SCI
  967. */
  968. if (gsi == acpi_gbl_FADT.sci_interrupt)
  969. gsi = pci_irq++;
  970. gsi_to_irq[irq] = gsi;
  971. } else {
  972. printk(KERN_ERR "GSI %u is too high\n", gsi);
  973. return gsi;
  974. }
  975. }
  976. #endif
  977. io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
  978. triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
  979. polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
  980. return gsi;
  981. }
  982. int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
  983. u32 gsi, int triggering, int polarity)
  984. {
  985. #ifdef CONFIG_X86_MPPARSE
  986. struct mpc_intsrc mp_irq;
  987. int ioapic;
  988. if (!acpi_ioapic)
  989. return 0;
  990. /* print the entry should happen on mptable identically */
  991. mp_irq.type = MP_INTSRC;
  992. mp_irq.irqtype = mp_INT;
  993. mp_irq.irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
  994. (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
  995. mp_irq.srcbus = number;
  996. mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
  997. ioapic = mp_find_ioapic(gsi);
  998. mp_irq.dstapic = mp_ioapic_routing[ioapic].apic_id;
  999. mp_irq.dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base;
  1000. save_mp_irq(&mp_irq);
  1001. #endif
  1002. return 0;
  1003. }
  1004. /*
  1005. * Parse IOAPIC related entries in MADT
  1006. * returns 0 on success, < 0 on error
  1007. */
  1008. static int __init acpi_parse_madt_ioapic_entries(void)
  1009. {
  1010. int count;
  1011. /*
  1012. * ACPI interpreter is required to complete interrupt setup,
  1013. * so if it is off, don't enumerate the io-apics with ACPI.
  1014. * If MPS is present, it will handle them,
  1015. * otherwise the system will stay in PIC mode
  1016. */
  1017. if (acpi_disabled || acpi_noirq) {
  1018. return -ENODEV;
  1019. }
  1020. if (!cpu_has_apic)
  1021. return -ENODEV;
  1022. /*
  1023. * if "noapic" boot option, don't look for IO-APICs
  1024. */
  1025. if (skip_ioapic_setup) {
  1026. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  1027. "due to 'noapic' option.\n");
  1028. return -ENODEV;
  1029. }
  1030. count =
  1031. acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
  1032. MAX_IO_APICS);
  1033. if (!count) {
  1034. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  1035. return -ENODEV;
  1036. } else if (count < 0) {
  1037. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  1038. return count;
  1039. }
  1040. count =
  1041. acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
  1042. nr_irqs);
  1043. if (count < 0) {
  1044. printk(KERN_ERR PREFIX
  1045. "Error parsing interrupt source overrides entry\n");
  1046. /* TBD: Cleanup to allow fallback to MPS */
  1047. return count;
  1048. }
  1049. /*
  1050. * If BIOS did not supply an INT_SRC_OVR for the SCI
  1051. * pretend we got one so we can set the SCI flags.
  1052. */
  1053. if (!acpi_sci_override_gsi)
  1054. acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
  1055. /* Fill in identity legacy mapings where no override */
  1056. mp_config_acpi_legacy_irqs();
  1057. count =
  1058. acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
  1059. nr_irqs);
  1060. if (count < 0) {
  1061. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  1062. /* TBD: Cleanup to allow fallback to MPS */
  1063. return count;
  1064. }
  1065. return 0;
  1066. }
  1067. #else
  1068. static inline int acpi_parse_madt_ioapic_entries(void)
  1069. {
  1070. return -1;
  1071. }
  1072. #endif /* !CONFIG_X86_IO_APIC */
  1073. static void __init early_acpi_process_madt(void)
  1074. {
  1075. #ifdef CONFIG_X86_LOCAL_APIC
  1076. int error;
  1077. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  1078. /*
  1079. * Parse MADT LAPIC entries
  1080. */
  1081. error = early_acpi_parse_madt_lapic_addr_ovr();
  1082. if (!error) {
  1083. acpi_lapic = 1;
  1084. smp_found_config = 1;
  1085. }
  1086. if (error == -EINVAL) {
  1087. /*
  1088. * Dell Precision Workstation 410, 610 come here.
  1089. */
  1090. printk(KERN_ERR PREFIX
  1091. "Invalid BIOS MADT, disabling ACPI\n");
  1092. disable_acpi();
  1093. }
  1094. }
  1095. #endif
  1096. }
  1097. static void __init acpi_process_madt(void)
  1098. {
  1099. #ifdef CONFIG_X86_LOCAL_APIC
  1100. int error;
  1101. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  1102. /*
  1103. * Parse MADT LAPIC entries
  1104. */
  1105. error = acpi_parse_madt_lapic_entries();
  1106. if (!error) {
  1107. acpi_lapic = 1;
  1108. #ifdef CONFIG_X86_GENERICARCH
  1109. generic_bigsmp_probe();
  1110. #endif
  1111. /*
  1112. * Parse MADT IO-APIC entries
  1113. */
  1114. error = acpi_parse_madt_ioapic_entries();
  1115. if (!error) {
  1116. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  1117. acpi_ioapic = 1;
  1118. smp_found_config = 1;
  1119. #ifdef CONFIG_X86_32
  1120. setup_apic_routing();
  1121. #endif
  1122. }
  1123. }
  1124. if (error == -EINVAL) {
  1125. /*
  1126. * Dell Precision Workstation 410, 610 come here.
  1127. */
  1128. printk(KERN_ERR PREFIX
  1129. "Invalid BIOS MADT, disabling ACPI\n");
  1130. disable_acpi();
  1131. }
  1132. } else {
  1133. /*
  1134. * ACPI found no MADT, and so ACPI wants UP PIC mode.
  1135. * In the event an MPS table was found, forget it.
  1136. * Boot with "acpi=off" to use MPS on such a system.
  1137. */
  1138. if (smp_found_config) {
  1139. printk(KERN_WARNING PREFIX
  1140. "No APIC-table, disabling MPS\n");
  1141. smp_found_config = 0;
  1142. }
  1143. }
  1144. /*
  1145. * ACPI supports both logical (e.g. Hyper-Threading) and physical
  1146. * processors, where MPS only supports physical.
  1147. */
  1148. if (acpi_lapic && acpi_ioapic)
  1149. printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
  1150. "information\n");
  1151. else if (acpi_lapic)
  1152. printk(KERN_INFO "Using ACPI for processor (LAPIC) "
  1153. "configuration information\n");
  1154. #endif
  1155. return;
  1156. }
  1157. static int __init disable_acpi_irq(const struct dmi_system_id *d)
  1158. {
  1159. if (!acpi_force) {
  1160. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  1161. d->ident);
  1162. acpi_noirq_set();
  1163. }
  1164. return 0;
  1165. }
  1166. static int __init disable_acpi_pci(const struct dmi_system_id *d)
  1167. {
  1168. if (!acpi_force) {
  1169. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  1170. d->ident);
  1171. acpi_disable_pci();
  1172. }
  1173. return 0;
  1174. }
  1175. static int __init dmi_disable_acpi(const struct dmi_system_id *d)
  1176. {
  1177. if (!acpi_force) {
  1178. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  1179. disable_acpi();
  1180. } else {
  1181. printk(KERN_NOTICE
  1182. "Warning: DMI blacklist says broken, but acpi forced\n");
  1183. }
  1184. return 0;
  1185. }
  1186. /*
  1187. * Limit ACPI to CPU enumeration for HT
  1188. */
  1189. static int __init force_acpi_ht(const struct dmi_system_id *d)
  1190. {
  1191. if (!acpi_force) {
  1192. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  1193. d->ident);
  1194. disable_acpi();
  1195. acpi_ht = 1;
  1196. } else {
  1197. printk(KERN_NOTICE
  1198. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  1199. }
  1200. return 0;
  1201. }
  1202. /*
  1203. * Force ignoring BIOS IRQ0 pin2 override
  1204. */
  1205. static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
  1206. {
  1207. /*
  1208. * The ati_ixp4x0_rev() early PCI quirk should have set
  1209. * the acpi_skip_timer_override flag already:
  1210. */
  1211. if (!acpi_skip_timer_override) {
  1212. WARN(1, KERN_ERR "ati_ixp4x0 quirk not complete.\n");
  1213. pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n",
  1214. d->ident);
  1215. acpi_skip_timer_override = 1;
  1216. }
  1217. return 0;
  1218. }
  1219. /*
  1220. * If your system is blacklisted here, but you find that acpi=force
  1221. * works for you, please contact acpi-devel@sourceforge.net
  1222. */
  1223. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  1224. /*
  1225. * Boxes that need ACPI disabled
  1226. */
  1227. {
  1228. .callback = dmi_disable_acpi,
  1229. .ident = "IBM Thinkpad",
  1230. .matches = {
  1231. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1232. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  1233. },
  1234. },
  1235. /*
  1236. * Boxes that need acpi=ht
  1237. */
  1238. {
  1239. .callback = force_acpi_ht,
  1240. .ident = "FSC Primergy T850",
  1241. .matches = {
  1242. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  1243. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  1244. },
  1245. },
  1246. {
  1247. .callback = force_acpi_ht,
  1248. .ident = "HP VISUALIZE NT Workstation",
  1249. .matches = {
  1250. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  1251. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  1252. },
  1253. },
  1254. {
  1255. .callback = force_acpi_ht,
  1256. .ident = "Compaq Workstation W8000",
  1257. .matches = {
  1258. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  1259. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  1260. },
  1261. },
  1262. {
  1263. .callback = force_acpi_ht,
  1264. .ident = "ASUS P4B266",
  1265. .matches = {
  1266. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1267. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  1268. },
  1269. },
  1270. {
  1271. .callback = force_acpi_ht,
  1272. .ident = "ASUS P2B-DS",
  1273. .matches = {
  1274. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1275. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  1276. },
  1277. },
  1278. {
  1279. .callback = force_acpi_ht,
  1280. .ident = "ASUS CUR-DLS",
  1281. .matches = {
  1282. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1283. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  1284. },
  1285. },
  1286. {
  1287. .callback = force_acpi_ht,
  1288. .ident = "ABIT i440BX-W83977",
  1289. .matches = {
  1290. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  1291. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  1292. },
  1293. },
  1294. {
  1295. .callback = force_acpi_ht,
  1296. .ident = "IBM Bladecenter",
  1297. .matches = {
  1298. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1299. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  1300. },
  1301. },
  1302. {
  1303. .callback = force_acpi_ht,
  1304. .ident = "IBM eServer xSeries 360",
  1305. .matches = {
  1306. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1307. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  1308. },
  1309. },
  1310. {
  1311. .callback = force_acpi_ht,
  1312. .ident = "IBM eserver xSeries 330",
  1313. .matches = {
  1314. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1315. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  1316. },
  1317. },
  1318. {
  1319. .callback = force_acpi_ht,
  1320. .ident = "IBM eserver xSeries 440",
  1321. .matches = {
  1322. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1323. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  1324. },
  1325. },
  1326. /*
  1327. * Boxes that need ACPI PCI IRQ routing disabled
  1328. */
  1329. {
  1330. .callback = disable_acpi_irq,
  1331. .ident = "ASUS A7V",
  1332. .matches = {
  1333. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  1334. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  1335. /* newer BIOS, Revision 1011, does work */
  1336. DMI_MATCH(DMI_BIOS_VERSION,
  1337. "ASUS A7V ACPI BIOS Revision 1007"),
  1338. },
  1339. },
  1340. {
  1341. /*
  1342. * Latest BIOS for IBM 600E (1.16) has bad pcinum
  1343. * for LPC bridge, which is needed for the PCI
  1344. * interrupt links to work. DSDT fix is in bug 5966.
  1345. * 2645, 2646 model numbers are shared with 600/600E/600X
  1346. */
  1347. .callback = disable_acpi_irq,
  1348. .ident = "IBM Thinkpad 600 Series 2645",
  1349. .matches = {
  1350. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1351. DMI_MATCH(DMI_BOARD_NAME, "2645"),
  1352. },
  1353. },
  1354. {
  1355. .callback = disable_acpi_irq,
  1356. .ident = "IBM Thinkpad 600 Series 2646",
  1357. .matches = {
  1358. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1359. DMI_MATCH(DMI_BOARD_NAME, "2646"),
  1360. },
  1361. },
  1362. /*
  1363. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  1364. */
  1365. { /* _BBN 0 bug */
  1366. .callback = disable_acpi_pci,
  1367. .ident = "ASUS PR-DLS",
  1368. .matches = {
  1369. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1370. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  1371. DMI_MATCH(DMI_BIOS_VERSION,
  1372. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  1373. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  1374. },
  1375. },
  1376. {
  1377. .callback = disable_acpi_pci,
  1378. .ident = "Acer TravelMate 36x Laptop",
  1379. .matches = {
  1380. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  1381. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  1382. },
  1383. },
  1384. {}
  1385. };
  1386. /* second table for DMI checks that should run after early-quirks */
  1387. static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
  1388. /*
  1389. * HP laptops which use a DSDT reporting as HP/SB400/10000,
  1390. * which includes some code which overrides all temperature
  1391. * trip points to 16C if the INTIN2 input of the I/O APIC
  1392. * is enabled. This input is incorrectly designated the
  1393. * ISA IRQ 0 via an interrupt source override even though
  1394. * it is wired to the output of the master 8259A and INTIN0
  1395. * is not connected at all. Force ignoring BIOS IRQ0 pin2
  1396. * override in that cases.
  1397. */
  1398. {
  1399. .callback = dmi_ignore_irq0_timer_override,
  1400. .ident = "HP nx6115 laptop",
  1401. .matches = {
  1402. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1403. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
  1404. },
  1405. },
  1406. {
  1407. .callback = dmi_ignore_irq0_timer_override,
  1408. .ident = "HP NX6125 laptop",
  1409. .matches = {
  1410. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1411. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
  1412. },
  1413. },
  1414. {
  1415. .callback = dmi_ignore_irq0_timer_override,
  1416. .ident = "HP NX6325 laptop",
  1417. .matches = {
  1418. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1419. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
  1420. },
  1421. },
  1422. {
  1423. .callback = dmi_ignore_irq0_timer_override,
  1424. .ident = "HP 6715b laptop",
  1425. .matches = {
  1426. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1427. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
  1428. },
  1429. },
  1430. {}
  1431. };
  1432. /*
  1433. * acpi_boot_table_init() and acpi_boot_init()
  1434. * called from setup_arch(), always.
  1435. * 1. checksums all tables
  1436. * 2. enumerates lapics
  1437. * 3. enumerates io-apics
  1438. *
  1439. * acpi_table_init() is separate to allow reading SRAT without
  1440. * other side effects.
  1441. *
  1442. * side effects of acpi_boot_init:
  1443. * acpi_lapic = 1 if LAPIC found
  1444. * acpi_ioapic = 1 if IOAPIC found
  1445. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  1446. * if acpi_blacklisted() acpi_disabled = 1;
  1447. * acpi_irq_model=...
  1448. * ...
  1449. *
  1450. * return value: (currently ignored)
  1451. * 0: success
  1452. * !0: failure
  1453. */
  1454. int __init acpi_boot_table_init(void)
  1455. {
  1456. int error;
  1457. dmi_check_system(acpi_dmi_table);
  1458. /*
  1459. * If acpi_disabled, bail out
  1460. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1461. */
  1462. if (acpi_disabled && !acpi_ht)
  1463. return 1;
  1464. /*
  1465. * Initialize the ACPI boot-time table parser.
  1466. */
  1467. error = acpi_table_init();
  1468. if (error) {
  1469. disable_acpi();
  1470. return error;
  1471. }
  1472. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1473. /*
  1474. * blacklist may disable ACPI entirely
  1475. */
  1476. error = acpi_blacklisted();
  1477. if (error) {
  1478. if (acpi_force) {
  1479. printk(KERN_WARNING PREFIX "acpi=force override\n");
  1480. } else {
  1481. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  1482. disable_acpi();
  1483. return error;
  1484. }
  1485. }
  1486. return 0;
  1487. }
  1488. int __init early_acpi_boot_init(void)
  1489. {
  1490. /*
  1491. * If acpi_disabled, bail out
  1492. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1493. */
  1494. if (acpi_disabled && !acpi_ht)
  1495. return 1;
  1496. /*
  1497. * Process the Multiple APIC Description Table (MADT), if present
  1498. */
  1499. early_acpi_process_madt();
  1500. return 0;
  1501. }
  1502. int __init acpi_boot_init(void)
  1503. {
  1504. /* those are executed after early-quirks are executed */
  1505. dmi_check_system(acpi_dmi_table_late);
  1506. /*
  1507. * If acpi_disabled, bail out
  1508. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1509. */
  1510. if (acpi_disabled && !acpi_ht)
  1511. return 1;
  1512. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1513. /*
  1514. * set sci_int and PM timer address
  1515. */
  1516. acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
  1517. /*
  1518. * Process the Multiple APIC Description Table (MADT), if present
  1519. */
  1520. acpi_process_madt();
  1521. acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
  1522. return 0;
  1523. }
  1524. static int __init parse_acpi(char *arg)
  1525. {
  1526. if (!arg)
  1527. return -EINVAL;
  1528. /* "acpi=off" disables both ACPI table parsing and interpreter */
  1529. if (strcmp(arg, "off") == 0) {
  1530. disable_acpi();
  1531. }
  1532. /* acpi=force to over-ride black-list */
  1533. else if (strcmp(arg, "force") == 0) {
  1534. acpi_force = 1;
  1535. acpi_ht = 1;
  1536. acpi_disabled = 0;
  1537. }
  1538. /* acpi=strict disables out-of-spec workarounds */
  1539. else if (strcmp(arg, "strict") == 0) {
  1540. acpi_strict = 1;
  1541. }
  1542. /* Limit ACPI just to boot-time to enable HT */
  1543. else if (strcmp(arg, "ht") == 0) {
  1544. if (!acpi_force)
  1545. disable_acpi();
  1546. acpi_ht = 1;
  1547. }
  1548. /* acpi=rsdt use RSDT instead of XSDT */
  1549. else if (strcmp(arg, "rsdt") == 0) {
  1550. acpi_rsdt_forced = 1;
  1551. }
  1552. /* "acpi=noirq" disables ACPI interrupt routing */
  1553. else if (strcmp(arg, "noirq") == 0) {
  1554. acpi_noirq_set();
  1555. } else {
  1556. /* Core will printk when we return error. */
  1557. return -EINVAL;
  1558. }
  1559. return 0;
  1560. }
  1561. early_param("acpi", parse_acpi);
  1562. /* FIXME: Using pci= for an ACPI parameter is a travesty. */
  1563. static int __init parse_pci(char *arg)
  1564. {
  1565. if (arg && strcmp(arg, "noacpi") == 0)
  1566. acpi_disable_pci();
  1567. return 0;
  1568. }
  1569. early_param("pci", parse_pci);
  1570. int __init acpi_mps_check(void)
  1571. {
  1572. #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
  1573. /* mptable code is not built-in*/
  1574. if (acpi_disabled || acpi_noirq) {
  1575. printk(KERN_WARNING "MPS support code is not built-in.\n"
  1576. "Using acpi=off or acpi=noirq or pci=noacpi "
  1577. "may have problem\n");
  1578. return 1;
  1579. }
  1580. #endif
  1581. return 0;
  1582. }
  1583. #ifdef CONFIG_X86_IO_APIC
  1584. static int __init parse_acpi_skip_timer_override(char *arg)
  1585. {
  1586. acpi_skip_timer_override = 1;
  1587. return 0;
  1588. }
  1589. early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
  1590. static int __init parse_acpi_use_timer_override(char *arg)
  1591. {
  1592. acpi_use_timer_override = 1;
  1593. return 0;
  1594. }
  1595. early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
  1596. #endif /* CONFIG_X86_IO_APIC */
  1597. static int __init setup_acpi_sci(char *s)
  1598. {
  1599. if (!s)
  1600. return -EINVAL;
  1601. if (!strcmp(s, "edge"))
  1602. acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
  1603. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1604. else if (!strcmp(s, "level"))
  1605. acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
  1606. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1607. else if (!strcmp(s, "high"))
  1608. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
  1609. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1610. else if (!strcmp(s, "low"))
  1611. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
  1612. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1613. else
  1614. return -EINVAL;
  1615. return 0;
  1616. }
  1617. early_param("acpi_sci", setup_acpi_sci);
  1618. int __acpi_acquire_global_lock(unsigned int *lock)
  1619. {
  1620. unsigned int old, new, val;
  1621. do {
  1622. old = *lock;
  1623. new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
  1624. val = cmpxchg(lock, old, new);
  1625. } while (unlikely (val != old));
  1626. return (new < 3) ? -1 : 0;
  1627. }
  1628. int __acpi_release_global_lock(unsigned int *lock)
  1629. {
  1630. unsigned int old, new, val;
  1631. do {
  1632. old = *lock;
  1633. new = old & ~0x3;
  1634. val = cmpxchg(lock, old, new);
  1635. } while (unlikely (val != old));
  1636. return old & 0x1;
  1637. }