boot.c 32 KB

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