boot.c 34 KB

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