boot.c 45 KB

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