boot.c 45 KB

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