boot.c 31 KB

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