boot.c 45 KB

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