boot.c 45 KB

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