boot.c 31 KB

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