boot.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  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. EXPORT_SYMBOL(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 *__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 *__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. EXPORT_SYMBOL(acpi_register_gsi);
  390. /*
  391. * ACPI based hotplug support for CPU
  392. */
  393. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  394. int acpi_map_lsapic(acpi_handle handle, int *pcpu)
  395. {
  396. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  397. union acpi_object *obj;
  398. struct acpi_madt_local_apic *lapic;
  399. cpumask_t tmp_map, new_map;
  400. u8 physid;
  401. int cpu;
  402. if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
  403. return -EINVAL;
  404. if (!buffer.length || !buffer.pointer)
  405. return -EINVAL;
  406. obj = buffer.pointer;
  407. if (obj->type != ACPI_TYPE_BUFFER ||
  408. obj->buffer.length < sizeof(*lapic)) {
  409. kfree(buffer.pointer);
  410. return -EINVAL;
  411. }
  412. lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
  413. if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
  414. !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
  415. kfree(buffer.pointer);
  416. return -EINVAL;
  417. }
  418. physid = lapic->id;
  419. kfree(buffer.pointer);
  420. buffer.length = ACPI_ALLOCATE_BUFFER;
  421. buffer.pointer = NULL;
  422. tmp_map = cpu_present_map;
  423. mp_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
  424. /*
  425. * If mp_register_lapic successfully generates a new logical cpu
  426. * number, then the following will get us exactly what was mapped
  427. */
  428. cpus_andnot(new_map, cpu_present_map, tmp_map);
  429. if (cpus_empty(new_map)) {
  430. printk ("Unable to map lapic to logical cpu number\n");
  431. return -EINVAL;
  432. }
  433. cpu = first_cpu(new_map);
  434. *pcpu = cpu;
  435. return 0;
  436. }
  437. EXPORT_SYMBOL(acpi_map_lsapic);
  438. int acpi_unmap_lsapic(int cpu)
  439. {
  440. per_cpu(x86_cpu_to_apicid, cpu) = -1;
  441. cpu_clear(cpu, cpu_present_map);
  442. num_processors--;
  443. return (0);
  444. }
  445. EXPORT_SYMBOL(acpi_unmap_lsapic);
  446. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  447. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  448. {
  449. /* TBD */
  450. return -EINVAL;
  451. }
  452. EXPORT_SYMBOL(acpi_register_ioapic);
  453. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  454. {
  455. /* TBD */
  456. return -EINVAL;
  457. }
  458. EXPORT_SYMBOL(acpi_unregister_ioapic);
  459. static unsigned long __init
  460. acpi_scan_rsdp(unsigned long start, unsigned long length)
  461. {
  462. unsigned long offset = 0;
  463. unsigned long sig_len = sizeof("RSD PTR ") - 1;
  464. /*
  465. * Scan all 16-byte boundaries of the physical memory region for the
  466. * RSDP signature.
  467. */
  468. for (offset = 0; offset < length; offset += 16) {
  469. if (strncmp((char *)(phys_to_virt(start) + offset), "RSD PTR ", sig_len))
  470. continue;
  471. return (start + offset);
  472. }
  473. return 0;
  474. }
  475. static int __init acpi_parse_sbf(struct acpi_table_header *table)
  476. {
  477. struct acpi_table_boot *sb;
  478. sb = (struct acpi_table_boot *)table;
  479. if (!sb) {
  480. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  481. return -ENODEV;
  482. }
  483. sbf_port = sb->cmos_index; /* Save CMOS port */
  484. return 0;
  485. }
  486. #ifdef CONFIG_HPET_TIMER
  487. #include <asm/hpet.h>
  488. static struct __initdata resource *hpet_res;
  489. static int __init acpi_parse_hpet(struct acpi_table_header *table)
  490. {
  491. struct acpi_table_hpet *hpet_tbl;
  492. hpet_tbl = (struct acpi_table_hpet *)table;
  493. if (!hpet_tbl) {
  494. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  495. return -ENODEV;
  496. }
  497. if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
  498. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  499. "memory.\n");
  500. return -1;
  501. }
  502. hpet_address = hpet_tbl->address.address;
  503. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  504. hpet_tbl->id, hpet_address);
  505. /*
  506. * Allocate and initialize the HPET firmware resource for adding into
  507. * the resource tree during the lateinit timeframe.
  508. */
  509. #define HPET_RESOURCE_NAME_SIZE 9
  510. hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
  511. if (!hpet_res)
  512. return 0;
  513. memset(hpet_res, 0, sizeof(*hpet_res));
  514. hpet_res->name = (void *)&hpet_res[1];
  515. hpet_res->flags = IORESOURCE_MEM;
  516. snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
  517. hpet_tbl->sequence);
  518. hpet_res->start = hpet_address;
  519. hpet_res->end = hpet_address + (1 * 1024) - 1;
  520. return 0;
  521. }
  522. /*
  523. * hpet_insert_resource inserts the HPET resources used into the resource
  524. * tree.
  525. */
  526. static __init int hpet_insert_resource(void)
  527. {
  528. if (!hpet_res)
  529. return 1;
  530. return insert_resource(&iomem_resource, hpet_res);
  531. }
  532. late_initcall(hpet_insert_resource);
  533. #else
  534. #define acpi_parse_hpet NULL
  535. #endif
  536. static int __init acpi_parse_fadt(struct acpi_table_header *table)
  537. {
  538. #ifdef CONFIG_X86_PM_TIMER
  539. /* detect the location of the ACPI PM Timer */
  540. if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
  541. /* FADT rev. 2 */
  542. if (acpi_gbl_FADT.xpm_timer_block.space_id !=
  543. ACPI_ADR_SPACE_SYSTEM_IO)
  544. return 0;
  545. pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
  546. /*
  547. * "X" fields are optional extensions to the original V1.0
  548. * fields, so we must selectively expand V1.0 fields if the
  549. * corresponding X field is zero.
  550. */
  551. if (!pmtmr_ioport)
  552. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  553. } else {
  554. /* FADT rev. 1 */
  555. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  556. }
  557. if (pmtmr_ioport)
  558. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  559. pmtmr_ioport);
  560. #endif
  561. return 0;
  562. }
  563. unsigned long __init acpi_find_rsdp(void)
  564. {
  565. unsigned long rsdp_phys = 0;
  566. if (efi_enabled) {
  567. if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
  568. return efi.acpi20;
  569. else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
  570. return efi.acpi;
  571. }
  572. /*
  573. * Scan memory looking for the RSDP signature. First search EBDA (low
  574. * memory) paragraphs and then search upper memory (E0000-FFFFF).
  575. */
  576. rsdp_phys = acpi_scan_rsdp(0, 0x400);
  577. if (!rsdp_phys)
  578. rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
  579. return rsdp_phys;
  580. }
  581. #ifdef CONFIG_X86_LOCAL_APIC
  582. /*
  583. * Parse LAPIC entries in MADT
  584. * returns 0 on success, < 0 on error
  585. */
  586. static int __init acpi_parse_madt_lapic_entries(void)
  587. {
  588. int count;
  589. if (!cpu_has_apic)
  590. return -ENODEV;
  591. /*
  592. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  593. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  594. */
  595. count =
  596. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  597. acpi_parse_lapic_addr_ovr, 0);
  598. if (count < 0) {
  599. printk(KERN_ERR PREFIX
  600. "Error parsing LAPIC address override entry\n");
  601. return count;
  602. }
  603. mp_register_lapic_address(acpi_lapic_addr);
  604. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, acpi_parse_lapic,
  605. MAX_APICS);
  606. if (!count) {
  607. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  608. /* TBD: Cleanup to allow fallback to MPS */
  609. return -ENODEV;
  610. } else if (count < 0) {
  611. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  612. /* TBD: Cleanup to allow fallback to MPS */
  613. return count;
  614. }
  615. count =
  616. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
  617. if (count < 0) {
  618. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  619. /* TBD: Cleanup to allow fallback to MPS */
  620. return count;
  621. }
  622. return 0;
  623. }
  624. #endif /* CONFIG_X86_LOCAL_APIC */
  625. #ifdef CONFIG_X86_IO_APIC
  626. /*
  627. * Parse IOAPIC related entries in MADT
  628. * returns 0 on success, < 0 on error
  629. */
  630. static int __init acpi_parse_madt_ioapic_entries(void)
  631. {
  632. int count;
  633. /*
  634. * ACPI interpreter is required to complete interrupt setup,
  635. * so if it is off, don't enumerate the io-apics with ACPI.
  636. * If MPS is present, it will handle them,
  637. * otherwise the system will stay in PIC mode
  638. */
  639. if (acpi_disabled || acpi_noirq) {
  640. return -ENODEV;
  641. }
  642. if (!cpu_has_apic)
  643. return -ENODEV;
  644. /*
  645. * if "noapic" boot option, don't look for IO-APICs
  646. */
  647. if (skip_ioapic_setup) {
  648. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  649. "due to 'noapic' option.\n");
  650. return -ENODEV;
  651. }
  652. count =
  653. acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
  654. MAX_IO_APICS);
  655. if (!count) {
  656. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  657. return -ENODEV;
  658. } else if (count < 0) {
  659. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  660. return count;
  661. }
  662. count =
  663. acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
  664. NR_IRQ_VECTORS);
  665. if (count < 0) {
  666. printk(KERN_ERR PREFIX
  667. "Error parsing interrupt source overrides entry\n");
  668. /* TBD: Cleanup to allow fallback to MPS */
  669. return count;
  670. }
  671. /*
  672. * If BIOS did not supply an INT_SRC_OVR for the SCI
  673. * pretend we got one so we can set the SCI flags.
  674. */
  675. if (!acpi_sci_override_gsi)
  676. acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
  677. /* Fill in identity legacy mapings where no override */
  678. mp_config_acpi_legacy_irqs();
  679. count =
  680. acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
  681. NR_IRQ_VECTORS);
  682. if (count < 0) {
  683. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  684. /* TBD: Cleanup to allow fallback to MPS */
  685. return count;
  686. }
  687. return 0;
  688. }
  689. #else
  690. static inline int acpi_parse_madt_ioapic_entries(void)
  691. {
  692. return -1;
  693. }
  694. #endif /* !CONFIG_X86_IO_APIC */
  695. static void __init acpi_process_madt(void)
  696. {
  697. #ifdef CONFIG_X86_LOCAL_APIC
  698. int error;
  699. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  700. /*
  701. * Parse MADT LAPIC entries
  702. */
  703. error = acpi_parse_madt_lapic_entries();
  704. if (!error) {
  705. acpi_lapic = 1;
  706. #ifdef CONFIG_X86_GENERICARCH
  707. generic_bigsmp_probe();
  708. #endif
  709. /*
  710. * Parse MADT IO-APIC entries
  711. */
  712. error = acpi_parse_madt_ioapic_entries();
  713. if (!error) {
  714. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  715. acpi_irq_balance_set(NULL);
  716. acpi_ioapic = 1;
  717. smp_found_config = 1;
  718. setup_apic_routing();
  719. }
  720. }
  721. if (error == -EINVAL) {
  722. /*
  723. * Dell Precision Workstation 410, 610 come here.
  724. */
  725. printk(KERN_ERR PREFIX
  726. "Invalid BIOS MADT, disabling ACPI\n");
  727. disable_acpi();
  728. }
  729. }
  730. #endif
  731. return;
  732. }
  733. #ifdef __i386__
  734. static int __init disable_acpi_irq(const struct dmi_system_id *d)
  735. {
  736. if (!acpi_force) {
  737. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  738. d->ident);
  739. acpi_noirq_set();
  740. }
  741. return 0;
  742. }
  743. static int __init disable_acpi_pci(const struct dmi_system_id *d)
  744. {
  745. if (!acpi_force) {
  746. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  747. d->ident);
  748. acpi_disable_pci();
  749. }
  750. return 0;
  751. }
  752. static int __init dmi_disable_acpi(const struct dmi_system_id *d)
  753. {
  754. if (!acpi_force) {
  755. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  756. disable_acpi();
  757. } else {
  758. printk(KERN_NOTICE
  759. "Warning: DMI blacklist says broken, but acpi forced\n");
  760. }
  761. return 0;
  762. }
  763. /*
  764. * Limit ACPI to CPU enumeration for HT
  765. */
  766. static int __init force_acpi_ht(const struct dmi_system_id *d)
  767. {
  768. if (!acpi_force) {
  769. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  770. d->ident);
  771. disable_acpi();
  772. acpi_ht = 1;
  773. } else {
  774. printk(KERN_NOTICE
  775. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  776. }
  777. return 0;
  778. }
  779. /*
  780. * If your system is blacklisted here, but you find that acpi=force
  781. * works for you, please contact acpi-devel@sourceforge.net
  782. */
  783. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  784. /*
  785. * Boxes that need ACPI disabled
  786. */
  787. {
  788. .callback = dmi_disable_acpi,
  789. .ident = "IBM Thinkpad",
  790. .matches = {
  791. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  792. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  793. },
  794. },
  795. /*
  796. * Boxes that need acpi=ht
  797. */
  798. {
  799. .callback = force_acpi_ht,
  800. .ident = "FSC Primergy T850",
  801. .matches = {
  802. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  803. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  804. },
  805. },
  806. {
  807. .callback = force_acpi_ht,
  808. .ident = "HP VISUALIZE NT Workstation",
  809. .matches = {
  810. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  811. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  812. },
  813. },
  814. {
  815. .callback = force_acpi_ht,
  816. .ident = "Compaq Workstation W8000",
  817. .matches = {
  818. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  819. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  820. },
  821. },
  822. {
  823. .callback = force_acpi_ht,
  824. .ident = "ASUS P4B266",
  825. .matches = {
  826. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  827. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  828. },
  829. },
  830. {
  831. .callback = force_acpi_ht,
  832. .ident = "ASUS P2B-DS",
  833. .matches = {
  834. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  835. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  836. },
  837. },
  838. {
  839. .callback = force_acpi_ht,
  840. .ident = "ASUS CUR-DLS",
  841. .matches = {
  842. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  843. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  844. },
  845. },
  846. {
  847. .callback = force_acpi_ht,
  848. .ident = "ABIT i440BX-W83977",
  849. .matches = {
  850. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  851. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  852. },
  853. },
  854. {
  855. .callback = force_acpi_ht,
  856. .ident = "IBM Bladecenter",
  857. .matches = {
  858. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  859. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  860. },
  861. },
  862. {
  863. .callback = force_acpi_ht,
  864. .ident = "IBM eServer xSeries 360",
  865. .matches = {
  866. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  867. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  868. },
  869. },
  870. {
  871. .callback = force_acpi_ht,
  872. .ident = "IBM eserver xSeries 330",
  873. .matches = {
  874. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  875. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  876. },
  877. },
  878. {
  879. .callback = force_acpi_ht,
  880. .ident = "IBM eserver xSeries 440",
  881. .matches = {
  882. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  883. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  884. },
  885. },
  886. /*
  887. * Boxes that need ACPI PCI IRQ routing disabled
  888. */
  889. {
  890. .callback = disable_acpi_irq,
  891. .ident = "ASUS A7V",
  892. .matches = {
  893. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  894. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  895. /* newer BIOS, Revision 1011, does work */
  896. DMI_MATCH(DMI_BIOS_VERSION,
  897. "ASUS A7V ACPI BIOS Revision 1007"),
  898. },
  899. },
  900. {
  901. /*
  902. * Latest BIOS for IBM 600E (1.16) has bad pcinum
  903. * for LPC bridge, which is needed for the PCI
  904. * interrupt links to work. DSDT fix is in bug 5966.
  905. * 2645, 2646 model numbers are shared with 600/600E/600X
  906. */
  907. .callback = disable_acpi_irq,
  908. .ident = "IBM Thinkpad 600 Series 2645",
  909. .matches = {
  910. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  911. DMI_MATCH(DMI_BOARD_NAME, "2645"),
  912. },
  913. },
  914. {
  915. .callback = disable_acpi_irq,
  916. .ident = "IBM Thinkpad 600 Series 2646",
  917. .matches = {
  918. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  919. DMI_MATCH(DMI_BOARD_NAME, "2646"),
  920. },
  921. },
  922. /*
  923. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  924. */
  925. { /* _BBN 0 bug */
  926. .callback = disable_acpi_pci,
  927. .ident = "ASUS PR-DLS",
  928. .matches = {
  929. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  930. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  931. DMI_MATCH(DMI_BIOS_VERSION,
  932. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  933. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  934. },
  935. },
  936. {
  937. .callback = disable_acpi_pci,
  938. .ident = "Acer TravelMate 36x Laptop",
  939. .matches = {
  940. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  941. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  942. },
  943. },
  944. {}
  945. };
  946. #endif /* __i386__ */
  947. /*
  948. * acpi_boot_table_init() and acpi_boot_init()
  949. * called from setup_arch(), always.
  950. * 1. checksums all tables
  951. * 2. enumerates lapics
  952. * 3. enumerates io-apics
  953. *
  954. * acpi_table_init() is separate to allow reading SRAT without
  955. * other side effects.
  956. *
  957. * side effects of acpi_boot_init:
  958. * acpi_lapic = 1 if LAPIC found
  959. * acpi_ioapic = 1 if IOAPIC found
  960. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  961. * if acpi_blacklisted() acpi_disabled = 1;
  962. * acpi_irq_model=...
  963. * ...
  964. *
  965. * return value: (currently ignored)
  966. * 0: success
  967. * !0: failure
  968. */
  969. int __init acpi_boot_table_init(void)
  970. {
  971. int error;
  972. #ifdef __i386__
  973. dmi_check_system(acpi_dmi_table);
  974. #endif
  975. /*
  976. * If acpi_disabled, bail out
  977. * One exception: acpi=ht continues far enough to enumerate LAPICs
  978. */
  979. if (acpi_disabled && !acpi_ht)
  980. return 1;
  981. /*
  982. * Initialize the ACPI boot-time table parser.
  983. */
  984. error = acpi_table_init();
  985. if (error) {
  986. disable_acpi();
  987. return error;
  988. }
  989. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  990. /*
  991. * blacklist may disable ACPI entirely
  992. */
  993. error = acpi_blacklisted();
  994. if (error) {
  995. if (acpi_force) {
  996. printk(KERN_WARNING PREFIX "acpi=force override\n");
  997. } else {
  998. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  999. disable_acpi();
  1000. return error;
  1001. }
  1002. }
  1003. return 0;
  1004. }
  1005. int __init acpi_boot_init(void)
  1006. {
  1007. /*
  1008. * If acpi_disabled, bail out
  1009. * One exception: acpi=ht continues far enough to enumerate LAPICs
  1010. */
  1011. if (acpi_disabled && !acpi_ht)
  1012. return 1;
  1013. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1014. /*
  1015. * set sci_int and PM timer address
  1016. */
  1017. acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
  1018. /*
  1019. * Process the Multiple APIC Description Table (MADT), if present
  1020. */
  1021. acpi_process_madt();
  1022. acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
  1023. return 0;
  1024. }
  1025. static int __init parse_acpi(char *arg)
  1026. {
  1027. if (!arg)
  1028. return -EINVAL;
  1029. /* "acpi=off" disables both ACPI table parsing and interpreter */
  1030. if (strcmp(arg, "off") == 0) {
  1031. disable_acpi();
  1032. }
  1033. /* acpi=force to over-ride black-list */
  1034. else if (strcmp(arg, "force") == 0) {
  1035. acpi_force = 1;
  1036. acpi_ht = 1;
  1037. acpi_disabled = 0;
  1038. }
  1039. /* acpi=strict disables out-of-spec workarounds */
  1040. else if (strcmp(arg, "strict") == 0) {
  1041. acpi_strict = 1;
  1042. }
  1043. /* Limit ACPI just to boot-time to enable HT */
  1044. else if (strcmp(arg, "ht") == 0) {
  1045. if (!acpi_force)
  1046. disable_acpi();
  1047. acpi_ht = 1;
  1048. }
  1049. /* "acpi=noirq" disables ACPI interrupt routing */
  1050. else if (strcmp(arg, "noirq") == 0) {
  1051. acpi_noirq_set();
  1052. } else {
  1053. /* Core will printk when we return error. */
  1054. return -EINVAL;
  1055. }
  1056. return 0;
  1057. }
  1058. early_param("acpi", parse_acpi);
  1059. /* FIXME: Using pci= for an ACPI parameter is a travesty. */
  1060. static int __init parse_pci(char *arg)
  1061. {
  1062. if (arg && strcmp(arg, "noacpi") == 0)
  1063. acpi_disable_pci();
  1064. return 0;
  1065. }
  1066. early_param("pci", parse_pci);
  1067. #ifdef CONFIG_X86_IO_APIC
  1068. static int __init parse_acpi_skip_timer_override(char *arg)
  1069. {
  1070. acpi_skip_timer_override = 1;
  1071. return 0;
  1072. }
  1073. early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
  1074. static int __init parse_acpi_use_timer_override(char *arg)
  1075. {
  1076. acpi_use_timer_override = 1;
  1077. return 0;
  1078. }
  1079. early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
  1080. #endif /* CONFIG_X86_IO_APIC */
  1081. static int __init setup_acpi_sci(char *s)
  1082. {
  1083. if (!s)
  1084. return -EINVAL;
  1085. if (!strcmp(s, "edge"))
  1086. acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
  1087. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1088. else if (!strcmp(s, "level"))
  1089. acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
  1090. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1091. else if (!strcmp(s, "high"))
  1092. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
  1093. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1094. else if (!strcmp(s, "low"))
  1095. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
  1096. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1097. else
  1098. return -EINVAL;
  1099. return 0;
  1100. }
  1101. early_param("acpi_sci", setup_acpi_sci);
  1102. int __acpi_acquire_global_lock(unsigned int *lock)
  1103. {
  1104. unsigned int old, new, val;
  1105. do {
  1106. old = *lock;
  1107. new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
  1108. val = cmpxchg(lock, old, new);
  1109. } while (unlikely (val != old));
  1110. return (new < 3) ? -1 : 0;
  1111. }
  1112. int __acpi_release_global_lock(unsigned int *lock)
  1113. {
  1114. unsigned int old, new, val;
  1115. do {
  1116. old = *lock;
  1117. new = old & ~0x3;
  1118. val = cmpxchg(lock, old, new);
  1119. } while (unlikely (val != old));
  1120. return old & 0x1;
  1121. }