boot.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  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. #ifdef CONFIG_X86_LOCAL_APIC
  41. # include <mach_apic.h>
  42. #endif
  43. static int __initdata acpi_force = 0;
  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. static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; }
  53. #else /* X86 */
  54. #ifdef CONFIG_X86_LOCAL_APIC
  55. #include <mach_apic.h>
  56. #include <mach_mpparse.h>
  57. #endif /* CONFIG_X86_LOCAL_APIC */
  58. #endif /* X86 */
  59. #define BAD_MADT_ENTRY(entry, end) ( \
  60. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  61. ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
  62. #define PREFIX "ACPI: "
  63. int acpi_noirq; /* skip ACPI IRQ initialization */
  64. int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
  65. EXPORT_SYMBOL(acpi_pci_disabled);
  66. int acpi_ht __initdata = 1; /* enable HT */
  67. int acpi_lapic;
  68. int acpi_ioapic;
  69. int acpi_strict;
  70. u8 acpi_sci_flags __initdata;
  71. int acpi_sci_override_gsi __initdata;
  72. int acpi_skip_timer_override __initdata;
  73. int acpi_use_timer_override __initdata;
  74. #ifdef CONFIG_X86_LOCAL_APIC
  75. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  76. #endif
  77. #ifndef __HAVE_ARCH_CMPXCHG
  78. #warning ACPI uses CMPXCHG, i486 and later hardware
  79. #endif
  80. /* --------------------------------------------------------------------------
  81. Boot-time Configuration
  82. -------------------------------------------------------------------------- */
  83. /*
  84. * The default interrupt routing model is PIC (8259). This gets
  85. * overridden if IOAPICs are enumerated (below).
  86. */
  87. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  88. #ifdef CONFIG_X86_64
  89. /* rely on all ACPI tables being in the direct mapping */
  90. char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
  91. {
  92. if (!phys_addr || !size)
  93. return NULL;
  94. if (phys_addr+size <= (max_pfn_mapped << PAGE_SHIFT) + PAGE_SIZE)
  95. return __va(phys_addr);
  96. return NULL;
  97. }
  98. #else
  99. /*
  100. * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  101. * to map the target physical address. The problem is that set_fixmap()
  102. * provides a single page, and it is possible that the page is not
  103. * sufficient.
  104. * By using this area, we can map up to MAX_IO_APICS pages temporarily,
  105. * i.e. until the next __va_range() call.
  106. *
  107. * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
  108. * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
  109. * count idx down while incrementing the phys address.
  110. */
  111. char *__init __acpi_map_table(unsigned long phys, unsigned long size)
  112. {
  113. unsigned long base, offset, mapped_size;
  114. int idx;
  115. if (phys + size < 8 * 1024 * 1024)
  116. return __va(phys);
  117. offset = phys & (PAGE_SIZE - 1);
  118. mapped_size = PAGE_SIZE - offset;
  119. set_fixmap(FIX_ACPI_END, phys);
  120. base = fix_to_virt(FIX_ACPI_END);
  121. /*
  122. * Most cases can be covered by the below.
  123. */
  124. idx = FIX_ACPI_END;
  125. while (mapped_size < size) {
  126. if (--idx < FIX_ACPI_BEGIN)
  127. return NULL; /* cannot handle this */
  128. phys += PAGE_SIZE;
  129. set_fixmap(idx, phys);
  130. mapped_size += PAGE_SIZE;
  131. }
  132. return ((unsigned char *)base + offset);
  133. }
  134. #endif
  135. #ifdef CONFIG_PCI_MMCONFIG
  136. /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
  137. struct acpi_mcfg_allocation *pci_mmcfg_config;
  138. int pci_mmcfg_config_num;
  139. int __init acpi_parse_mcfg(struct acpi_table_header *header)
  140. {
  141. struct acpi_table_mcfg *mcfg;
  142. unsigned long i;
  143. int config_size;
  144. if (!header)
  145. return -EINVAL;
  146. mcfg = (struct acpi_table_mcfg *)header;
  147. /* how many config structures do we have */
  148. pci_mmcfg_config_num = 0;
  149. i = header->length - sizeof(struct acpi_table_mcfg);
  150. while (i >= sizeof(struct acpi_mcfg_allocation)) {
  151. ++pci_mmcfg_config_num;
  152. i -= sizeof(struct acpi_mcfg_allocation);
  153. };
  154. if (pci_mmcfg_config_num == 0) {
  155. printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
  156. return -ENODEV;
  157. }
  158. config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
  159. pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
  160. if (!pci_mmcfg_config) {
  161. printk(KERN_WARNING PREFIX
  162. "No memory for MCFG config tables\n");
  163. return -ENOMEM;
  164. }
  165. memcpy(pci_mmcfg_config, &mcfg[1], config_size);
  166. for (i = 0; i < pci_mmcfg_config_num; ++i) {
  167. if (pci_mmcfg_config[i].address > 0xFFFFFFFF) {
  168. printk(KERN_ERR PREFIX
  169. "MMCONFIG not in low 4GB of memory\n");
  170. kfree(pci_mmcfg_config);
  171. pci_mmcfg_config_num = 0;
  172. return -ENODEV;
  173. }
  174. }
  175. return 0;
  176. }
  177. #endif /* CONFIG_PCI_MMCONFIG */
  178. #ifdef CONFIG_X86_LOCAL_APIC
  179. static int __init acpi_parse_madt(struct acpi_table_header *table)
  180. {
  181. struct acpi_table_madt *madt = NULL;
  182. if (!cpu_has_apic)
  183. return -EINVAL;
  184. madt = (struct acpi_table_madt *)table;
  185. if (!madt) {
  186. printk(KERN_WARNING PREFIX "Unable to map MADT\n");
  187. return -ENODEV;
  188. }
  189. if (madt->address) {
  190. acpi_lapic_addr = (u64) madt->address;
  191. printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
  192. madt->address);
  193. }
  194. acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
  195. return 0;
  196. }
  197. static int __init
  198. acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
  199. {
  200. struct acpi_madt_local_apic *processor = NULL;
  201. processor = (struct acpi_madt_local_apic *)header;
  202. if (BAD_MADT_ENTRY(processor, end))
  203. return -EINVAL;
  204. acpi_table_print_madt_entry(header);
  205. /*
  206. * We need to register disabled CPU as well to permit
  207. * counting disabled CPUs. This allows us to size
  208. * cpus_possible_map more accurately, to permit
  209. * to not preallocating memory for all NR_CPUS
  210. * when we use CPU hotplug.
  211. */
  212. mp_register_lapic(processor->id, /* APIC ID */
  213. processor->lapic_flags & ACPI_MADT_ENABLED); /* Enabled? */
  214. return 0;
  215. }
  216. static int __init
  217. acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
  218. const unsigned long end)
  219. {
  220. struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
  221. lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
  222. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  223. return -EINVAL;
  224. acpi_lapic_addr = lapic_addr_ovr->address;
  225. return 0;
  226. }
  227. static int __init
  228. acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
  229. {
  230. struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
  231. lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
  232. if (BAD_MADT_ENTRY(lapic_nmi, end))
  233. return -EINVAL;
  234. acpi_table_print_madt_entry(header);
  235. if (lapic_nmi->lint != 1)
  236. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  237. return 0;
  238. }
  239. #endif /*CONFIG_X86_LOCAL_APIC */
  240. #ifdef CONFIG_X86_IO_APIC
  241. static int __init
  242. acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
  243. {
  244. struct acpi_madt_io_apic *ioapic = NULL;
  245. ioapic = (struct acpi_madt_io_apic *)header;
  246. if (BAD_MADT_ENTRY(ioapic, end))
  247. return -EINVAL;
  248. acpi_table_print_madt_entry(header);
  249. mp_register_ioapic(ioapic->id,
  250. ioapic->address, ioapic->global_irq_base);
  251. return 0;
  252. }
  253. /*
  254. * Parse Interrupt Source Override for the ACPI SCI
  255. */
  256. static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  257. {
  258. if (trigger == 0) /* compatible SCI trigger is level */
  259. trigger = 3;
  260. if (polarity == 0) /* compatible SCI polarity is low */
  261. polarity = 3;
  262. /* Command-line over-ride via acpi_sci= */
  263. if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
  264. trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
  265. if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
  266. polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
  267. /*
  268. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  269. * If GSI is < 16, this will update its flags,
  270. * else it will create a new mp_irqs[] entry.
  271. */
  272. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  273. /*
  274. * stash over-ride to indicate we've been here
  275. * and for later update of acpi_gbl_FADT
  276. */
  277. acpi_sci_override_gsi = gsi;
  278. return;
  279. }
  280. static int __init
  281. acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
  282. const unsigned long end)
  283. {
  284. struct acpi_madt_interrupt_override *intsrc = NULL;
  285. intsrc = (struct acpi_madt_interrupt_override *)header;
  286. if (BAD_MADT_ENTRY(intsrc, end))
  287. return -EINVAL;
  288. acpi_table_print_madt_entry(header);
  289. if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
  290. acpi_sci_ioapic_setup(intsrc->global_irq,
  291. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  292. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
  293. return 0;
  294. }
  295. if (acpi_skip_timer_override &&
  296. intsrc->source_irq == 0 && intsrc->global_irq == 2) {
  297. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  298. return 0;
  299. }
  300. mp_override_legacy_irq(intsrc->source_irq,
  301. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  302. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
  303. intsrc->global_irq);
  304. return 0;
  305. }
  306. static int __init
  307. acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
  308. {
  309. struct acpi_madt_nmi_source *nmi_src = NULL;
  310. nmi_src = (struct acpi_madt_nmi_source *)header;
  311. if (BAD_MADT_ENTRY(nmi_src, end))
  312. return -EINVAL;
  313. acpi_table_print_madt_entry(header);
  314. /* TBD: Support nimsrc entries? */
  315. return 0;
  316. }
  317. #endif /* CONFIG_X86_IO_APIC */
  318. /*
  319. * acpi_pic_sci_set_trigger()
  320. *
  321. * use ELCR to set PIC-mode trigger type for SCI
  322. *
  323. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  324. * it may require Edge Trigger -- use "acpi_sci=edge"
  325. *
  326. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  327. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  328. * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
  329. * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
  330. */
  331. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  332. {
  333. unsigned int mask = 1 << irq;
  334. unsigned int old, new;
  335. /* Real old ELCR mask */
  336. old = inb(0x4d0) | (inb(0x4d1) << 8);
  337. /*
  338. * If we use ACPI to set PCI IRQs, then we should clear ELCR
  339. * since we will set it correctly as we enable the PCI irq
  340. * routing.
  341. */
  342. new = acpi_noirq ? old : 0;
  343. /*
  344. * Update SCI information in the ELCR, it isn't in the PCI
  345. * routing tables..
  346. */
  347. switch (trigger) {
  348. case 1: /* Edge - clear */
  349. new &= ~mask;
  350. break;
  351. case 3: /* Level - set */
  352. new |= mask;
  353. break;
  354. }
  355. if (old == new)
  356. return;
  357. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  358. outb(new, 0x4d0);
  359. outb(new >> 8, 0x4d1);
  360. }
  361. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  362. {
  363. *irq = gsi;
  364. return 0;
  365. }
  366. /*
  367. * success: return IRQ number (>=0)
  368. * failure: return < 0
  369. */
  370. int acpi_register_gsi(u32 gsi, int triggering, int polarity)
  371. {
  372. unsigned int irq;
  373. unsigned int plat_gsi = gsi;
  374. #ifdef CONFIG_PCI
  375. /*
  376. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  377. */
  378. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  379. extern void eisa_set_level_irq(unsigned int irq);
  380. if (triggering == ACPI_LEVEL_SENSITIVE)
  381. eisa_set_level_irq(gsi);
  382. }
  383. #endif
  384. #ifdef CONFIG_X86_IO_APIC
  385. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  386. plat_gsi = mp_register_gsi(gsi, triggering, polarity);
  387. }
  388. #endif
  389. acpi_gsi_to_irq(plat_gsi, &irq);
  390. return irq;
  391. }
  392. /*
  393. * ACPI based hotplug support for CPU
  394. */
  395. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  396. static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
  397. {
  398. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  399. union acpi_object *obj;
  400. struct acpi_madt_local_apic *lapic;
  401. cpumask_t tmp_map, new_map;
  402. u8 physid;
  403. int cpu;
  404. if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
  405. return -EINVAL;
  406. if (!buffer.length || !buffer.pointer)
  407. return -EINVAL;
  408. obj = buffer.pointer;
  409. if (obj->type != ACPI_TYPE_BUFFER ||
  410. obj->buffer.length < sizeof(*lapic)) {
  411. kfree(buffer.pointer);
  412. return -EINVAL;
  413. }
  414. lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
  415. if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
  416. !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
  417. kfree(buffer.pointer);
  418. return -EINVAL;
  419. }
  420. physid = lapic->id;
  421. kfree(buffer.pointer);
  422. buffer.length = ACPI_ALLOCATE_BUFFER;
  423. buffer.pointer = NULL;
  424. tmp_map = cpu_present_map;
  425. mp_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
  426. /*
  427. * If mp_register_lapic successfully generates a new logical cpu
  428. * number, then the following will get us exactly what was mapped
  429. */
  430. cpus_andnot(new_map, cpu_present_map, tmp_map);
  431. if (cpus_empty(new_map)) {
  432. printk ("Unable to map lapic to logical cpu number\n");
  433. return -EINVAL;
  434. }
  435. cpu = first_cpu(new_map);
  436. *pcpu = cpu;
  437. return 0;
  438. }
  439. /* wrapper to silence section mismatch warning */
  440. int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
  441. {
  442. return _acpi_map_lsapic(handle, pcpu);
  443. }
  444. EXPORT_SYMBOL(acpi_map_lsapic);
  445. int acpi_unmap_lsapic(int cpu)
  446. {
  447. per_cpu(x86_cpu_to_apicid, cpu) = -1;
  448. cpu_clear(cpu, cpu_present_map);
  449. num_processors--;
  450. return (0);
  451. }
  452. EXPORT_SYMBOL(acpi_unmap_lsapic);
  453. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  454. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  455. {
  456. /* TBD */
  457. return -EINVAL;
  458. }
  459. EXPORT_SYMBOL(acpi_register_ioapic);
  460. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  461. {
  462. /* TBD */
  463. return -EINVAL;
  464. }
  465. EXPORT_SYMBOL(acpi_unregister_ioapic);
  466. static int __init acpi_parse_sbf(struct acpi_table_header *table)
  467. {
  468. struct acpi_table_boot *sb;
  469. sb = (struct acpi_table_boot *)table;
  470. if (!sb) {
  471. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  472. return -ENODEV;
  473. }
  474. sbf_port = sb->cmos_index; /* Save CMOS port */
  475. return 0;
  476. }
  477. #ifdef CONFIG_HPET_TIMER
  478. #include <asm/hpet.h>
  479. static struct __initdata resource *hpet_res;
  480. static int __init acpi_parse_hpet(struct acpi_table_header *table)
  481. {
  482. struct acpi_table_hpet *hpet_tbl;
  483. hpet_tbl = (struct acpi_table_hpet *)table;
  484. if (!hpet_tbl) {
  485. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  486. return -ENODEV;
  487. }
  488. if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
  489. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  490. "memory.\n");
  491. return -1;
  492. }
  493. hpet_address = hpet_tbl->address.address;
  494. /*
  495. * Some broken BIOSes advertise HPET at 0x0. We really do not
  496. * want to allocate a resource there.
  497. */
  498. if (!hpet_address) {
  499. printk(KERN_WARNING PREFIX
  500. "HPET id: %#x base: %#lx is invalid\n",
  501. hpet_tbl->id, hpet_address);
  502. return 0;
  503. }
  504. #ifdef CONFIG_X86_64
  505. /*
  506. * Some even more broken BIOSes advertise HPET at
  507. * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
  508. * some noise:
  509. */
  510. if (hpet_address == 0xfed0000000000000UL) {
  511. if (!hpet_force_user) {
  512. printk(KERN_WARNING PREFIX "HPET id: %#x "
  513. "base: 0xfed0000000000000 is bogus\n "
  514. "try hpet=force on the kernel command line to "
  515. "fix it up to 0xfed00000.\n", hpet_tbl->id);
  516. hpet_address = 0;
  517. return 0;
  518. }
  519. printk(KERN_WARNING PREFIX
  520. "HPET id: %#x base: 0xfed0000000000000 fixed up "
  521. "to 0xfed00000.\n", hpet_tbl->id);
  522. hpet_address >>= 32;
  523. }
  524. #endif
  525. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  526. hpet_tbl->id, hpet_address);
  527. /*
  528. * Allocate and initialize the HPET firmware resource for adding into
  529. * the resource tree during the lateinit timeframe.
  530. */
  531. #define HPET_RESOURCE_NAME_SIZE 9
  532. hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
  533. if (!hpet_res)
  534. return 0;
  535. memset(hpet_res, 0, sizeof(*hpet_res));
  536. hpet_res->name = (void *)&hpet_res[1];
  537. hpet_res->flags = IORESOURCE_MEM;
  538. snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
  539. hpet_tbl->sequence);
  540. hpet_res->start = hpet_address;
  541. hpet_res->end = hpet_address + (1 * 1024) - 1;
  542. return 0;
  543. }
  544. /*
  545. * hpet_insert_resource inserts the HPET resources used into the resource
  546. * tree.
  547. */
  548. static __init int hpet_insert_resource(void)
  549. {
  550. if (!hpet_res)
  551. return 1;
  552. return insert_resource(&iomem_resource, hpet_res);
  553. }
  554. late_initcall(hpet_insert_resource);
  555. #else
  556. #define acpi_parse_hpet NULL
  557. #endif
  558. static int __init acpi_parse_fadt(struct acpi_table_header *table)
  559. {
  560. #ifdef CONFIG_X86_PM_TIMER
  561. /* detect the location of the ACPI PM Timer */
  562. if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
  563. /* FADT rev. 2 */
  564. if (acpi_gbl_FADT.xpm_timer_block.space_id !=
  565. ACPI_ADR_SPACE_SYSTEM_IO)
  566. return 0;
  567. pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
  568. /*
  569. * "X" fields are optional extensions to the original V1.0
  570. * fields, so we must selectively expand V1.0 fields if the
  571. * corresponding X field is zero.
  572. */
  573. if (!pmtmr_ioport)
  574. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  575. } else {
  576. /* FADT rev. 1 */
  577. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  578. }
  579. if (pmtmr_ioport)
  580. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  581. pmtmr_ioport);
  582. #endif
  583. return 0;
  584. }
  585. #ifdef CONFIG_X86_LOCAL_APIC
  586. /*
  587. * Parse LAPIC entries in MADT
  588. * returns 0 on success, < 0 on error
  589. */
  590. static int __init acpi_parse_madt_lapic_entries(void)
  591. {
  592. int count;
  593. if (!cpu_has_apic)
  594. return -ENODEV;
  595. /*
  596. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  597. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  598. */
  599. count =
  600. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  601. acpi_parse_lapic_addr_ovr, 0);
  602. if (count < 0) {
  603. printk(KERN_ERR PREFIX
  604. "Error parsing LAPIC address override entry\n");
  605. return count;
  606. }
  607. mp_register_lapic_address(acpi_lapic_addr);
  608. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, acpi_parse_lapic,
  609. MAX_APICS);
  610. if (!count) {
  611. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  612. /* TBD: Cleanup to allow fallback to MPS */
  613. return -ENODEV;
  614. } else if (count < 0) {
  615. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  616. /* TBD: Cleanup to allow fallback to MPS */
  617. return count;
  618. }
  619. count =
  620. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
  621. if (count < 0) {
  622. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  623. /* TBD: Cleanup to allow fallback to MPS */
  624. return count;
  625. }
  626. return 0;
  627. }
  628. #endif /* CONFIG_X86_LOCAL_APIC */
  629. #ifdef CONFIG_X86_IO_APIC
  630. /*
  631. * Parse IOAPIC related entries in MADT
  632. * returns 0 on success, < 0 on error
  633. */
  634. static int __init acpi_parse_madt_ioapic_entries(void)
  635. {
  636. int count;
  637. /*
  638. * ACPI interpreter is required to complete interrupt setup,
  639. * so if it is off, don't enumerate the io-apics with ACPI.
  640. * If MPS is present, it will handle them,
  641. * otherwise the system will stay in PIC mode
  642. */
  643. if (acpi_disabled || acpi_noirq) {
  644. return -ENODEV;
  645. }
  646. if (!cpu_has_apic)
  647. return -ENODEV;
  648. /*
  649. * if "noapic" boot option, don't look for IO-APICs
  650. */
  651. if (skip_ioapic_setup) {
  652. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  653. "due to 'noapic' option.\n");
  654. return -ENODEV;
  655. }
  656. count =
  657. acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
  658. MAX_IO_APICS);
  659. if (!count) {
  660. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  661. return -ENODEV;
  662. } else if (count < 0) {
  663. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  664. return count;
  665. }
  666. count =
  667. acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
  668. NR_IRQ_VECTORS);
  669. if (count < 0) {
  670. printk(KERN_ERR PREFIX
  671. "Error parsing interrupt source overrides entry\n");
  672. /* TBD: Cleanup to allow fallback to MPS */
  673. return count;
  674. }
  675. /*
  676. * If BIOS did not supply an INT_SRC_OVR for the SCI
  677. * pretend we got one so we can set the SCI flags.
  678. */
  679. if (!acpi_sci_override_gsi)
  680. acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
  681. /* Fill in identity legacy mapings where no override */
  682. mp_config_acpi_legacy_irqs();
  683. count =
  684. acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
  685. NR_IRQ_VECTORS);
  686. if (count < 0) {
  687. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  688. /* TBD: Cleanup to allow fallback to MPS */
  689. return count;
  690. }
  691. return 0;
  692. }
  693. #else
  694. static inline int acpi_parse_madt_ioapic_entries(void)
  695. {
  696. return -1;
  697. }
  698. #endif /* !CONFIG_X86_IO_APIC */
  699. static void __init acpi_process_madt(void)
  700. {
  701. #ifdef CONFIG_X86_LOCAL_APIC
  702. int error;
  703. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  704. /*
  705. * Parse MADT LAPIC entries
  706. */
  707. error = acpi_parse_madt_lapic_entries();
  708. if (!error) {
  709. acpi_lapic = 1;
  710. #ifdef CONFIG_X86_GENERICARCH
  711. generic_bigsmp_probe();
  712. #endif
  713. /*
  714. * Parse MADT IO-APIC entries
  715. */
  716. error = acpi_parse_madt_ioapic_entries();
  717. if (!error) {
  718. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  719. acpi_irq_balance_set(NULL);
  720. acpi_ioapic = 1;
  721. smp_found_config = 1;
  722. setup_apic_routing();
  723. }
  724. }
  725. if (error == -EINVAL) {
  726. /*
  727. * Dell Precision Workstation 410, 610 come here.
  728. */
  729. printk(KERN_ERR PREFIX
  730. "Invalid BIOS MADT, disabling ACPI\n");
  731. disable_acpi();
  732. }
  733. }
  734. #endif
  735. return;
  736. }
  737. #ifdef __i386__
  738. static int __init disable_acpi_irq(const struct dmi_system_id *d)
  739. {
  740. if (!acpi_force) {
  741. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  742. d->ident);
  743. acpi_noirq_set();
  744. }
  745. return 0;
  746. }
  747. static int __init disable_acpi_pci(const struct dmi_system_id *d)
  748. {
  749. if (!acpi_force) {
  750. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  751. d->ident);
  752. acpi_disable_pci();
  753. }
  754. return 0;
  755. }
  756. static int __init dmi_disable_acpi(const struct dmi_system_id *d)
  757. {
  758. if (!acpi_force) {
  759. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  760. disable_acpi();
  761. } else {
  762. printk(KERN_NOTICE
  763. "Warning: DMI blacklist says broken, but acpi forced\n");
  764. }
  765. return 0;
  766. }
  767. /*
  768. * Limit ACPI to CPU enumeration for HT
  769. */
  770. static int __init force_acpi_ht(const struct dmi_system_id *d)
  771. {
  772. if (!acpi_force) {
  773. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  774. d->ident);
  775. disable_acpi();
  776. acpi_ht = 1;
  777. } else {
  778. printk(KERN_NOTICE
  779. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  780. }
  781. return 0;
  782. }
  783. /*
  784. * If your system is blacklisted here, but you find that acpi=force
  785. * works for you, please contact acpi-devel@sourceforge.net
  786. */
  787. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  788. /*
  789. * Boxes that need ACPI disabled
  790. */
  791. {
  792. .callback = dmi_disable_acpi,
  793. .ident = "IBM Thinkpad",
  794. .matches = {
  795. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  796. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  797. },
  798. },
  799. /*
  800. * Boxes that need acpi=ht
  801. */
  802. {
  803. .callback = force_acpi_ht,
  804. .ident = "FSC Primergy T850",
  805. .matches = {
  806. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  807. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  808. },
  809. },
  810. {
  811. .callback = force_acpi_ht,
  812. .ident = "HP VISUALIZE NT Workstation",
  813. .matches = {
  814. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  815. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  816. },
  817. },
  818. {
  819. .callback = force_acpi_ht,
  820. .ident = "Compaq Workstation W8000",
  821. .matches = {
  822. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  823. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  824. },
  825. },
  826. {
  827. .callback = force_acpi_ht,
  828. .ident = "ASUS P4B266",
  829. .matches = {
  830. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  831. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  832. },
  833. },
  834. {
  835. .callback = force_acpi_ht,
  836. .ident = "ASUS P2B-DS",
  837. .matches = {
  838. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  839. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  840. },
  841. },
  842. {
  843. .callback = force_acpi_ht,
  844. .ident = "ASUS CUR-DLS",
  845. .matches = {
  846. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  847. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  848. },
  849. },
  850. {
  851. .callback = force_acpi_ht,
  852. .ident = "ABIT i440BX-W83977",
  853. .matches = {
  854. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  855. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  856. },
  857. },
  858. {
  859. .callback = force_acpi_ht,
  860. .ident = "IBM Bladecenter",
  861. .matches = {
  862. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  863. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  864. },
  865. },
  866. {
  867. .callback = force_acpi_ht,
  868. .ident = "IBM eServer xSeries 360",
  869. .matches = {
  870. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  871. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  872. },
  873. },
  874. {
  875. .callback = force_acpi_ht,
  876. .ident = "IBM eserver xSeries 330",
  877. .matches = {
  878. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  879. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  880. },
  881. },
  882. {
  883. .callback = force_acpi_ht,
  884. .ident = "IBM eserver xSeries 440",
  885. .matches = {
  886. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  887. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  888. },
  889. },
  890. /*
  891. * Boxes that need ACPI PCI IRQ routing disabled
  892. */
  893. {
  894. .callback = disable_acpi_irq,
  895. .ident = "ASUS A7V",
  896. .matches = {
  897. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  898. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  899. /* newer BIOS, Revision 1011, does work */
  900. DMI_MATCH(DMI_BIOS_VERSION,
  901. "ASUS A7V ACPI BIOS Revision 1007"),
  902. },
  903. },
  904. {
  905. /*
  906. * Latest BIOS for IBM 600E (1.16) has bad pcinum
  907. * for LPC bridge, which is needed for the PCI
  908. * interrupt links to work. DSDT fix is in bug 5966.
  909. * 2645, 2646 model numbers are shared with 600/600E/600X
  910. */
  911. .callback = disable_acpi_irq,
  912. .ident = "IBM Thinkpad 600 Series 2645",
  913. .matches = {
  914. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  915. DMI_MATCH(DMI_BOARD_NAME, "2645"),
  916. },
  917. },
  918. {
  919. .callback = disable_acpi_irq,
  920. .ident = "IBM Thinkpad 600 Series 2646",
  921. .matches = {
  922. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  923. DMI_MATCH(DMI_BOARD_NAME, "2646"),
  924. },
  925. },
  926. /*
  927. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  928. */
  929. { /* _BBN 0 bug */
  930. .callback = disable_acpi_pci,
  931. .ident = "ASUS PR-DLS",
  932. .matches = {
  933. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  934. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  935. DMI_MATCH(DMI_BIOS_VERSION,
  936. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  937. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  938. },
  939. },
  940. {
  941. .callback = disable_acpi_pci,
  942. .ident = "Acer TravelMate 36x Laptop",
  943. .matches = {
  944. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  945. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  946. },
  947. },
  948. {}
  949. };
  950. #endif /* __i386__ */
  951. /*
  952. * acpi_boot_table_init() and acpi_boot_init()
  953. * called from setup_arch(), always.
  954. * 1. checksums all tables
  955. * 2. enumerates lapics
  956. * 3. enumerates io-apics
  957. *
  958. * acpi_table_init() is separate to allow reading SRAT without
  959. * other side effects.
  960. *
  961. * side effects of acpi_boot_init:
  962. * acpi_lapic = 1 if LAPIC found
  963. * acpi_ioapic = 1 if IOAPIC found
  964. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  965. * if acpi_blacklisted() acpi_disabled = 1;
  966. * acpi_irq_model=...
  967. * ...
  968. *
  969. * return value: (currently ignored)
  970. * 0: success
  971. * !0: failure
  972. */
  973. int __init acpi_boot_table_init(void)
  974. {
  975. int error;
  976. #ifdef __i386__
  977. dmi_check_system(acpi_dmi_table);
  978. #endif
  979. /*
  980. * If acpi_disabled, bail out
  981. * One exception: acpi=ht continues far enough to enumerate LAPICs
  982. */
  983. if (acpi_disabled && !acpi_ht)
  984. return 1;
  985. /*
  986. * Initialize the ACPI boot-time table parser.
  987. */
  988. error = acpi_table_init();
  989. if (error) {
  990. disable_acpi();
  991. return error;
  992. }
  993. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  994. /*
  995. * blacklist may disable ACPI entirely
  996. */
  997. error = acpi_blacklisted();
  998. if (error) {
  999. if (acpi_force) {
  1000. printk(KERN_WARNING PREFIX "acpi=force override\n");
  1001. } else {
  1002. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  1003. disable_acpi();
  1004. return error;
  1005. }
  1006. }
  1007. return 0;
  1008. }
  1009. int __init acpi_boot_init(void)
  1010. {
  1011. /*
  1012. * If acpi_disabled, bail out
  1013. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1014. */
  1015. if (acpi_disabled && !acpi_ht)
  1016. return 1;
  1017. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1018. /*
  1019. * set sci_int and PM timer address
  1020. */
  1021. acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
  1022. /*
  1023. * Process the Multiple APIC Description Table (MADT), if present
  1024. */
  1025. acpi_process_madt();
  1026. acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
  1027. return 0;
  1028. }
  1029. static int __init parse_acpi(char *arg)
  1030. {
  1031. if (!arg)
  1032. return -EINVAL;
  1033. /* "acpi=off" disables both ACPI table parsing and interpreter */
  1034. if (strcmp(arg, "off") == 0) {
  1035. disable_acpi();
  1036. }
  1037. /* acpi=force to over-ride black-list */
  1038. else if (strcmp(arg, "force") == 0) {
  1039. acpi_force = 1;
  1040. acpi_ht = 1;
  1041. acpi_disabled = 0;
  1042. }
  1043. /* acpi=strict disables out-of-spec workarounds */
  1044. else if (strcmp(arg, "strict") == 0) {
  1045. acpi_strict = 1;
  1046. }
  1047. /* Limit ACPI just to boot-time to enable HT */
  1048. else if (strcmp(arg, "ht") == 0) {
  1049. if (!acpi_force)
  1050. disable_acpi();
  1051. acpi_ht = 1;
  1052. }
  1053. /* "acpi=noirq" disables ACPI interrupt routing */
  1054. else if (strcmp(arg, "noirq") == 0) {
  1055. acpi_noirq_set();
  1056. } else {
  1057. /* Core will printk when we return error. */
  1058. return -EINVAL;
  1059. }
  1060. return 0;
  1061. }
  1062. early_param("acpi", parse_acpi);
  1063. /* FIXME: Using pci= for an ACPI parameter is a travesty. */
  1064. static int __init parse_pci(char *arg)
  1065. {
  1066. if (arg && strcmp(arg, "noacpi") == 0)
  1067. acpi_disable_pci();
  1068. return 0;
  1069. }
  1070. early_param("pci", parse_pci);
  1071. #ifdef CONFIG_X86_IO_APIC
  1072. static int __init parse_acpi_skip_timer_override(char *arg)
  1073. {
  1074. acpi_skip_timer_override = 1;
  1075. return 0;
  1076. }
  1077. early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
  1078. static int __init parse_acpi_use_timer_override(char *arg)
  1079. {
  1080. acpi_use_timer_override = 1;
  1081. return 0;
  1082. }
  1083. early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
  1084. #endif /* CONFIG_X86_IO_APIC */
  1085. static int __init setup_acpi_sci(char *s)
  1086. {
  1087. if (!s)
  1088. return -EINVAL;
  1089. if (!strcmp(s, "edge"))
  1090. acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
  1091. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1092. else if (!strcmp(s, "level"))
  1093. acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
  1094. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1095. else if (!strcmp(s, "high"))
  1096. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
  1097. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1098. else if (!strcmp(s, "low"))
  1099. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
  1100. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1101. else
  1102. return -EINVAL;
  1103. return 0;
  1104. }
  1105. early_param("acpi_sci", setup_acpi_sci);
  1106. int __acpi_acquire_global_lock(unsigned int *lock)
  1107. {
  1108. unsigned int old, new, val;
  1109. do {
  1110. old = *lock;
  1111. new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
  1112. val = cmpxchg(lock, old, new);
  1113. } while (unlikely (val != old));
  1114. return (new < 3) ? -1 : 0;
  1115. }
  1116. int __acpi_release_global_lock(unsigned int *lock)
  1117. {
  1118. unsigned int old, new, val;
  1119. do {
  1120. old = *lock;
  1121. new = old & ~0x3;
  1122. val = cmpxchg(lock, old, new);
  1123. } while (unlikely (val != old));
  1124. return old & 0x1;
  1125. }