boot.c 32 KB

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