boot.c 31 KB

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