boot.c 31 KB

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