boot.c 47 KB

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