boot.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  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/config.h>
  27. #include <linux/acpi.h>
  28. #include <linux/efi.h>
  29. #include <linux/irq.h>
  30. #include <linux/module.h>
  31. #include <linux/dmi.h>
  32. #include <asm/pgtable.h>
  33. #include <asm/io_apic.h>
  34. #include <asm/apic.h>
  35. #include <asm/io.h>
  36. #include <asm/irq.h>
  37. #include <asm/mpspec.h>
  38. #ifdef CONFIG_X86_64
  39. static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) { }
  40. extern void __init clustered_apic_check(void);
  41. static inline int ioapic_setup_disabled(void) { return 0; }
  42. #include <asm/proto.h>
  43. #else /* X86 */
  44. #ifdef CONFIG_X86_LOCAL_APIC
  45. #include <mach_apic.h>
  46. #include <mach_mpparse.h>
  47. #endif /* CONFIG_X86_LOCAL_APIC */
  48. #endif /* X86 */
  49. #define BAD_MADT_ENTRY(entry, end) ( \
  50. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  51. ((acpi_table_entry_header *)entry)->length != sizeof(*entry))
  52. #define PREFIX "ACPI: "
  53. #ifdef CONFIG_ACPI_PCI
  54. int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
  55. int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
  56. #else
  57. int acpi_noirq __initdata = 1;
  58. int acpi_pci_disabled __initdata = 1;
  59. #endif
  60. int acpi_ht __initdata = 1; /* enable HT */
  61. int acpi_lapic;
  62. int acpi_ioapic;
  63. int acpi_strict;
  64. EXPORT_SYMBOL(acpi_strict);
  65. acpi_interrupt_flags acpi_sci_flags __initdata;
  66. int acpi_sci_override_gsi __initdata;
  67. int acpi_skip_timer_override __initdata;
  68. #ifdef CONFIG_X86_LOCAL_APIC
  69. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  70. #endif
  71. #ifndef __HAVE_ARCH_CMPXCHG
  72. #warning ACPI uses CMPXCHG, i486 and later hardware
  73. #endif
  74. #define MAX_MADT_ENTRIES 256
  75. u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
  76. { [0 ... MAX_MADT_ENTRIES-1] = 0xff };
  77. EXPORT_SYMBOL(x86_acpiid_to_apicid);
  78. /* --------------------------------------------------------------------------
  79. Boot-time Configuration
  80. -------------------------------------------------------------------------- */
  81. /*
  82. * The default interrupt routing model is PIC (8259). This gets
  83. * overriden if IOAPICs are enumerated (below).
  84. */
  85. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  86. #ifdef CONFIG_X86_64
  87. /* rely on all ACPI tables being in the direct mapping */
  88. char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
  89. {
  90. if (!phys_addr || !size)
  91. return NULL;
  92. if (phys_addr < (end_pfn_map << PAGE_SHIFT))
  93. return __va(phys_addr);
  94. return NULL;
  95. }
  96. #else
  97. /*
  98. * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  99. * to map the target physical address. The problem is that set_fixmap()
  100. * provides a single page, and it is possible that the page is not
  101. * sufficient.
  102. * By using this area, we can map up to MAX_IO_APICS pages temporarily,
  103. * i.e. until the next __va_range() call.
  104. *
  105. * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
  106. * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
  107. * count idx down while incrementing the phys address.
  108. */
  109. char *__acpi_map_table(unsigned long phys, unsigned long size)
  110. {
  111. unsigned long base, offset, mapped_size;
  112. int idx;
  113. if (phys + size < 8*1024*1024)
  114. return __va(phys);
  115. offset = phys & (PAGE_SIZE - 1);
  116. mapped_size = PAGE_SIZE - offset;
  117. set_fixmap(FIX_ACPI_END, phys);
  118. base = fix_to_virt(FIX_ACPI_END);
  119. /*
  120. * Most cases can be covered by the below.
  121. */
  122. idx = FIX_ACPI_END;
  123. while (mapped_size < size) {
  124. if (--idx < FIX_ACPI_BEGIN)
  125. return NULL; /* cannot handle this */
  126. phys += PAGE_SIZE;
  127. set_fixmap(idx, phys);
  128. mapped_size += PAGE_SIZE;
  129. }
  130. return ((unsigned char *) base + offset);
  131. }
  132. #endif
  133. #ifdef CONFIG_PCI_MMCONFIG
  134. static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
  135. {
  136. struct acpi_table_mcfg *mcfg;
  137. if (!phys_addr || !size)
  138. return -EINVAL;
  139. mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size);
  140. if (!mcfg) {
  141. printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
  142. return -ENODEV;
  143. }
  144. if (mcfg->base_reserved) {
  145. printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n");
  146. return -ENODEV;
  147. }
  148. pci_mmcfg_base_addr = mcfg->base_address;
  149. return 0;
  150. }
  151. #else
  152. #define acpi_parse_mcfg NULL
  153. #endif /* !CONFIG_PCI_MMCONFIG */
  154. #ifdef CONFIG_X86_LOCAL_APIC
  155. static int __init
  156. acpi_parse_madt (
  157. unsigned long phys_addr,
  158. unsigned long size)
  159. {
  160. struct acpi_table_madt *madt = NULL;
  161. if (!phys_addr || !size)
  162. return -EINVAL;
  163. madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size);
  164. if (!madt) {
  165. printk(KERN_WARNING PREFIX "Unable to map MADT\n");
  166. return -ENODEV;
  167. }
  168. if (madt->lapic_address) {
  169. acpi_lapic_addr = (u64) madt->lapic_address;
  170. printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
  171. madt->lapic_address);
  172. }
  173. acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
  174. return 0;
  175. }
  176. static int __init
  177. acpi_parse_lapic (
  178. acpi_table_entry_header *header, const unsigned long end)
  179. {
  180. struct acpi_table_lapic *processor = NULL;
  181. processor = (struct acpi_table_lapic*) header;
  182. if (BAD_MADT_ENTRY(processor, end))
  183. return -EINVAL;
  184. acpi_table_print_madt_entry(header);
  185. /* no utility in registering a disabled processor */
  186. if (processor->flags.enabled == 0)
  187. return 0;
  188. x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
  189. mp_register_lapic (
  190. processor->id, /* APIC ID */
  191. processor->flags.enabled); /* Enabled? */
  192. return 0;
  193. }
  194. static int __init
  195. acpi_parse_lapic_addr_ovr (
  196. acpi_table_entry_header *header, const unsigned long end)
  197. {
  198. struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
  199. lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header;
  200. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  201. return -EINVAL;
  202. acpi_lapic_addr = lapic_addr_ovr->address;
  203. return 0;
  204. }
  205. static int __init
  206. acpi_parse_lapic_nmi (
  207. acpi_table_entry_header *header, const unsigned long end)
  208. {
  209. struct acpi_table_lapic_nmi *lapic_nmi = NULL;
  210. lapic_nmi = (struct acpi_table_lapic_nmi*) header;
  211. if (BAD_MADT_ENTRY(lapic_nmi, end))
  212. return -EINVAL;
  213. acpi_table_print_madt_entry(header);
  214. if (lapic_nmi->lint != 1)
  215. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  216. return 0;
  217. }
  218. #endif /*CONFIG_X86_LOCAL_APIC*/
  219. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
  220. static int __init
  221. acpi_parse_ioapic (
  222. acpi_table_entry_header *header, const unsigned long end)
  223. {
  224. struct acpi_table_ioapic *ioapic = NULL;
  225. ioapic = (struct acpi_table_ioapic*) header;
  226. if (BAD_MADT_ENTRY(ioapic, end))
  227. return -EINVAL;
  228. acpi_table_print_madt_entry(header);
  229. mp_register_ioapic (
  230. ioapic->id,
  231. ioapic->address,
  232. ioapic->global_irq_base);
  233. return 0;
  234. }
  235. /*
  236. * Parse Interrupt Source Override for the ACPI SCI
  237. */
  238. static void
  239. acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  240. {
  241. if (trigger == 0) /* compatible SCI trigger is level */
  242. trigger = 3;
  243. if (polarity == 0) /* compatible SCI polarity is low */
  244. polarity = 3;
  245. /* Command-line over-ride via acpi_sci= */
  246. if (acpi_sci_flags.trigger)
  247. trigger = acpi_sci_flags.trigger;
  248. if (acpi_sci_flags.polarity)
  249. polarity = acpi_sci_flags.polarity;
  250. /*
  251. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  252. * If GSI is < 16, this will update its flags,
  253. * else it will create a new mp_irqs[] entry.
  254. */
  255. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  256. /*
  257. * stash over-ride to indicate we've been here
  258. * and for later update of acpi_fadt
  259. */
  260. acpi_sci_override_gsi = gsi;
  261. return;
  262. }
  263. static int __init
  264. acpi_parse_int_src_ovr (
  265. acpi_table_entry_header *header, const unsigned long end)
  266. {
  267. struct acpi_table_int_src_ovr *intsrc = NULL;
  268. intsrc = (struct acpi_table_int_src_ovr*) header;
  269. if (BAD_MADT_ENTRY(intsrc, end))
  270. return -EINVAL;
  271. acpi_table_print_madt_entry(header);
  272. if (intsrc->bus_irq == acpi_fadt.sci_int) {
  273. acpi_sci_ioapic_setup(intsrc->global_irq,
  274. intsrc->flags.polarity, intsrc->flags.trigger);
  275. return 0;
  276. }
  277. if (acpi_skip_timer_override &&
  278. intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
  279. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  280. return 0;
  281. }
  282. mp_override_legacy_irq (
  283. intsrc->bus_irq,
  284. intsrc->flags.polarity,
  285. intsrc->flags.trigger,
  286. intsrc->global_irq);
  287. return 0;
  288. }
  289. static int __init
  290. acpi_parse_nmi_src (
  291. acpi_table_entry_header *header, const unsigned long end)
  292. {
  293. struct acpi_table_nmi_src *nmi_src = NULL;
  294. nmi_src = (struct acpi_table_nmi_src*) header;
  295. if (BAD_MADT_ENTRY(nmi_src, end))
  296. return -EINVAL;
  297. acpi_table_print_madt_entry(header);
  298. /* TBD: Support nimsrc entries? */
  299. return 0;
  300. }
  301. #endif /* CONFIG_X86_IO_APIC */
  302. #ifdef CONFIG_ACPI_BUS
  303. /*
  304. * acpi_pic_sci_set_trigger()
  305. *
  306. * use ELCR to set PIC-mode trigger type for SCI
  307. *
  308. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  309. * it may require Edge Trigger -- use "acpi_sci=edge"
  310. *
  311. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  312. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  313. * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
  314. * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
  315. */
  316. void __init
  317. acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  318. {
  319. unsigned int mask = 1 << irq;
  320. unsigned int old, new;
  321. /* Real old ELCR mask */
  322. old = inb(0x4d0) | (inb(0x4d1) << 8);
  323. /*
  324. * If we use ACPI to set PCI irq's, then we should clear ELCR
  325. * since we will set it correctly as we enable the PCI irq
  326. * routing.
  327. */
  328. new = acpi_noirq ? old : 0;
  329. /*
  330. * Update SCI information in the ELCR, it isn't in the PCI
  331. * routing tables..
  332. */
  333. switch (trigger) {
  334. case 1: /* Edge - clear */
  335. new &= ~mask;
  336. break;
  337. case 3: /* Level - set */
  338. new |= mask;
  339. break;
  340. }
  341. if (old == new)
  342. return;
  343. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  344. outb(new, 0x4d0);
  345. outb(new >> 8, 0x4d1);
  346. }
  347. #endif /* CONFIG_ACPI_BUS */
  348. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  349. {
  350. #ifdef CONFIG_X86_IO_APIC
  351. if (use_pci_vector() && !platform_legacy_irq(gsi))
  352. *irq = IO_APIC_VECTOR(gsi);
  353. else
  354. #endif
  355. *irq = gsi;
  356. return 0;
  357. }
  358. unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
  359. {
  360. unsigned int irq;
  361. unsigned int plat_gsi = gsi;
  362. #ifdef CONFIG_PCI
  363. /*
  364. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  365. */
  366. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  367. extern void eisa_set_level_irq(unsigned int irq);
  368. if (edge_level == ACPI_LEVEL_SENSITIVE)
  369. eisa_set_level_irq(gsi);
  370. }
  371. #endif
  372. #ifdef CONFIG_X86_IO_APIC
  373. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  374. plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
  375. }
  376. #endif
  377. acpi_gsi_to_irq(plat_gsi, &irq);
  378. return irq;
  379. }
  380. EXPORT_SYMBOL(acpi_register_gsi);
  381. /*
  382. * ACPI based hotplug support for CPU
  383. */
  384. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  385. int
  386. acpi_map_lsapic(acpi_handle handle, int *pcpu)
  387. {
  388. /* TBD */
  389. return -EINVAL;
  390. }
  391. EXPORT_SYMBOL(acpi_map_lsapic);
  392. int
  393. acpi_unmap_lsapic(int cpu)
  394. {
  395. /* TBD */
  396. return -EINVAL;
  397. }
  398. EXPORT_SYMBOL(acpi_unmap_lsapic);
  399. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  400. int
  401. acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  402. {
  403. /* TBD */
  404. return -EINVAL;
  405. }
  406. EXPORT_SYMBOL(acpi_register_ioapic);
  407. int
  408. acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  409. {
  410. /* TBD */
  411. return -EINVAL;
  412. }
  413. EXPORT_SYMBOL(acpi_unregister_ioapic);
  414. static unsigned long __init
  415. acpi_scan_rsdp (
  416. unsigned long start,
  417. unsigned long length)
  418. {
  419. unsigned long offset = 0;
  420. unsigned long sig_len = sizeof("RSD PTR ") - 1;
  421. /*
  422. * Scan all 16-byte boundaries of the physical memory region for the
  423. * RSDP signature.
  424. */
  425. for (offset = 0; offset < length; offset += 16) {
  426. if (strncmp((char *) (start + offset), "RSD PTR ", sig_len))
  427. continue;
  428. return (start + offset);
  429. }
  430. return 0;
  431. }
  432. static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
  433. {
  434. struct acpi_table_sbf *sb;
  435. if (!phys_addr || !size)
  436. return -EINVAL;
  437. sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size);
  438. if (!sb) {
  439. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  440. return -ENODEV;
  441. }
  442. sbf_port = sb->sbf_cmos; /* Save CMOS port */
  443. return 0;
  444. }
  445. #ifdef CONFIG_HPET_TIMER
  446. static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
  447. {
  448. struct acpi_table_hpet *hpet_tbl;
  449. if (!phys || !size)
  450. return -EINVAL;
  451. hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size);
  452. if (!hpet_tbl) {
  453. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  454. return -ENODEV;
  455. }
  456. if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
  457. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  458. "memory.\n");
  459. return -1;
  460. }
  461. #ifdef CONFIG_X86_64
  462. vxtime.hpet_address = hpet_tbl->addr.addrl |
  463. ((long) hpet_tbl->addr.addrh << 32);
  464. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  465. hpet_tbl->id, vxtime.hpet_address);
  466. #else /* X86 */
  467. {
  468. extern unsigned long hpet_address;
  469. hpet_address = hpet_tbl->addr.addrl;
  470. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  471. hpet_tbl->id, hpet_address);
  472. }
  473. #endif /* X86 */
  474. return 0;
  475. }
  476. #else
  477. #define acpi_parse_hpet NULL
  478. #endif
  479. #ifdef CONFIG_X86_PM_TIMER
  480. extern u32 pmtmr_ioport;
  481. #endif
  482. static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
  483. {
  484. struct fadt_descriptor_rev2 *fadt = NULL;
  485. fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size);
  486. if(!fadt) {
  487. printk(KERN_WARNING PREFIX "Unable to map FADT\n");
  488. return 0;
  489. }
  490. #ifdef CONFIG_ACPI_INTERPRETER
  491. /* initialize sci_int early for INT_SRC_OVR MADT parsing */
  492. acpi_fadt.sci_int = fadt->sci_int;
  493. #endif
  494. #ifdef CONFIG_ACPI_BUS
  495. /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
  496. acpi_fadt.revision = fadt->revision;
  497. acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode;
  498. #endif
  499. #ifdef CONFIG_X86_PM_TIMER
  500. /* detect the location of the ACPI PM Timer */
  501. if (fadt->revision >= FADT2_REVISION_ID) {
  502. /* FADT rev. 2 */
  503. if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO)
  504. return 0;
  505. pmtmr_ioport = fadt->xpm_tmr_blk.address;
  506. } else {
  507. /* FADT rev. 1 */
  508. pmtmr_ioport = fadt->V1_pm_tmr_blk;
  509. }
  510. if (pmtmr_ioport)
  511. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport);
  512. #endif
  513. return 0;
  514. }
  515. unsigned long __init
  516. acpi_find_rsdp (void)
  517. {
  518. unsigned long rsdp_phys = 0;
  519. if (efi_enabled) {
  520. if (efi.acpi20)
  521. return __pa(efi.acpi20);
  522. else if (efi.acpi)
  523. return __pa(efi.acpi);
  524. }
  525. /*
  526. * Scan memory looking for the RSDP signature. First search EBDA (low
  527. * memory) paragraphs and then search upper memory (E0000-FFFFF).
  528. */
  529. rsdp_phys = acpi_scan_rsdp (0, 0x400);
  530. if (!rsdp_phys)
  531. rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000);
  532. return rsdp_phys;
  533. }
  534. #ifdef CONFIG_X86_LOCAL_APIC
  535. /*
  536. * Parse LAPIC entries in MADT
  537. * returns 0 on success, < 0 on error
  538. */
  539. static int __init
  540. acpi_parse_madt_lapic_entries(void)
  541. {
  542. int count;
  543. /*
  544. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  545. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  546. */
  547. count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0);
  548. if (count < 0) {
  549. printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
  550. return count;
  551. }
  552. mp_register_lapic_address(acpi_lapic_addr);
  553. count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
  554. MAX_APICS);
  555. if (!count) {
  556. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  557. /* TBD: Cleanup to allow fallback to MPS */
  558. return -ENODEV;
  559. }
  560. else if (count < 0) {
  561. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  562. /* TBD: Cleanup to allow fallback to MPS */
  563. return count;
  564. }
  565. count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
  566. if (count < 0) {
  567. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  568. /* TBD: Cleanup to allow fallback to MPS */
  569. return count;
  570. }
  571. return 0;
  572. }
  573. #endif /* CONFIG_X86_LOCAL_APIC */
  574. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
  575. /*
  576. * Parse IOAPIC related entries in MADT
  577. * returns 0 on success, < 0 on error
  578. */
  579. static int __init
  580. acpi_parse_madt_ioapic_entries(void)
  581. {
  582. int count;
  583. /*
  584. * ACPI interpreter is required to complete interrupt setup,
  585. * so if it is off, don't enumerate the io-apics with ACPI.
  586. * If MPS is present, it will handle them,
  587. * otherwise the system will stay in PIC mode
  588. */
  589. if (acpi_disabled || acpi_noirq) {
  590. return -ENODEV;
  591. }
  592. /*
  593. * if "noapic" boot option, don't look for IO-APICs
  594. */
  595. if (skip_ioapic_setup) {
  596. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  597. "due to 'noapic' option.\n");
  598. return -ENODEV;
  599. }
  600. count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS);
  601. if (!count) {
  602. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  603. return -ENODEV;
  604. }
  605. else if (count < 0) {
  606. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  607. return count;
  608. }
  609. count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS);
  610. if (count < 0) {
  611. printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
  612. /* TBD: Cleanup to allow fallback to MPS */
  613. return count;
  614. }
  615. /*
  616. * If BIOS did not supply an INT_SRC_OVR for the SCI
  617. * pretend we got one so we can set the SCI flags.
  618. */
  619. if (!acpi_sci_override_gsi)
  620. acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
  621. /* Fill in identity legacy mapings where no override */
  622. mp_config_acpi_legacy_irqs();
  623. count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS);
  624. if (count < 0) {
  625. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  626. /* TBD: Cleanup to allow fallback to MPS */
  627. return count;
  628. }
  629. return 0;
  630. }
  631. #else
  632. static inline int acpi_parse_madt_ioapic_entries(void)
  633. {
  634. return -1;
  635. }
  636. #endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */
  637. static void __init
  638. acpi_process_madt(void)
  639. {
  640. #ifdef CONFIG_X86_LOCAL_APIC
  641. int count, error;
  642. count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
  643. if (count >= 1) {
  644. /*
  645. * Parse MADT LAPIC entries
  646. */
  647. error = acpi_parse_madt_lapic_entries();
  648. if (!error) {
  649. acpi_lapic = 1;
  650. /*
  651. * Parse MADT IO-APIC entries
  652. */
  653. error = acpi_parse_madt_ioapic_entries();
  654. if (!error) {
  655. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  656. acpi_irq_balance_set(NULL);
  657. acpi_ioapic = 1;
  658. smp_found_config = 1;
  659. clustered_apic_check();
  660. }
  661. }
  662. if (error == -EINVAL) {
  663. /*
  664. * Dell Precision Workstation 410, 610 come here.
  665. */
  666. printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n");
  667. disable_acpi();
  668. }
  669. }
  670. #endif
  671. return;
  672. }
  673. extern int acpi_force;
  674. #ifdef __i386__
  675. #ifdef CONFIG_ACPI_PCI
  676. static int __init disable_acpi_irq(struct dmi_system_id *d)
  677. {
  678. if (!acpi_force) {
  679. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  680. d->ident);
  681. acpi_noirq_set();
  682. }
  683. return 0;
  684. }
  685. static int __init disable_acpi_pci(struct dmi_system_id *d)
  686. {
  687. if (!acpi_force) {
  688. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  689. d->ident);
  690. acpi_disable_pci();
  691. }
  692. return 0;
  693. }
  694. #endif
  695. static int __init dmi_disable_acpi(struct dmi_system_id *d)
  696. {
  697. if (!acpi_force) {
  698. printk(KERN_NOTICE "%s detected: acpi off\n",d->ident);
  699. disable_acpi();
  700. } else {
  701. printk(KERN_NOTICE
  702. "Warning: DMI blacklist says broken, but acpi forced\n");
  703. }
  704. return 0;
  705. }
  706. /*
  707. * Limit ACPI to CPU enumeration for HT
  708. */
  709. static int __init force_acpi_ht(struct dmi_system_id *d)
  710. {
  711. if (!acpi_force) {
  712. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", d->ident);
  713. disable_acpi();
  714. acpi_ht = 1;
  715. } else {
  716. printk(KERN_NOTICE
  717. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  718. }
  719. return 0;
  720. }
  721. /*
  722. * If your system is blacklisted here, but you find that acpi=force
  723. * works for you, please contact acpi-devel@sourceforge.net
  724. */
  725. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  726. /*
  727. * Boxes that need ACPI disabled
  728. */
  729. {
  730. .callback = dmi_disable_acpi,
  731. .ident = "IBM Thinkpad",
  732. .matches = {
  733. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  734. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  735. },
  736. },
  737. /*
  738. * Boxes that need acpi=ht
  739. */
  740. {
  741. .callback = force_acpi_ht,
  742. .ident = "FSC Primergy T850",
  743. .matches = {
  744. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  745. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  746. },
  747. },
  748. {
  749. .callback = force_acpi_ht,
  750. .ident = "DELL GX240",
  751. .matches = {
  752. DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
  753. DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
  754. },
  755. },
  756. {
  757. .callback = force_acpi_ht,
  758. .ident = "HP VISUALIZE NT Workstation",
  759. .matches = {
  760. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  761. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  762. },
  763. },
  764. {
  765. .callback = force_acpi_ht,
  766. .ident = "Compaq Workstation W8000",
  767. .matches = {
  768. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  769. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  770. },
  771. },
  772. {
  773. .callback = force_acpi_ht,
  774. .ident = "ASUS P4B266",
  775. .matches = {
  776. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  777. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  778. },
  779. },
  780. {
  781. .callback = force_acpi_ht,
  782. .ident = "ASUS P2B-DS",
  783. .matches = {
  784. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  785. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  786. },
  787. },
  788. {
  789. .callback = force_acpi_ht,
  790. .ident = "ASUS CUR-DLS",
  791. .matches = {
  792. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  793. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  794. },
  795. },
  796. {
  797. .callback = force_acpi_ht,
  798. .ident = "ABIT i440BX-W83977",
  799. .matches = {
  800. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  801. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  802. },
  803. },
  804. {
  805. .callback = force_acpi_ht,
  806. .ident = "IBM Bladecenter",
  807. .matches = {
  808. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  809. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  810. },
  811. },
  812. {
  813. .callback = force_acpi_ht,
  814. .ident = "IBM eServer xSeries 360",
  815. .matches = {
  816. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  817. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  818. },
  819. },
  820. {
  821. .callback = force_acpi_ht,
  822. .ident = "IBM eserver xSeries 330",
  823. .matches = {
  824. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  825. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  826. },
  827. },
  828. {
  829. .callback = force_acpi_ht,
  830. .ident = "IBM eserver xSeries 440",
  831. .matches = {
  832. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  833. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  834. },
  835. },
  836. #ifdef CONFIG_ACPI_PCI
  837. /*
  838. * Boxes that need ACPI PCI IRQ routing disabled
  839. */
  840. {
  841. .callback = disable_acpi_irq,
  842. .ident = "ASUS A7V",
  843. .matches = {
  844. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  845. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  846. /* newer BIOS, Revision 1011, does work */
  847. DMI_MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"),
  848. },
  849. },
  850. /*
  851. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  852. */
  853. { /* _BBN 0 bug */
  854. .callback = disable_acpi_pci,
  855. .ident = "ASUS PR-DLS",
  856. .matches = {
  857. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  858. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  859. DMI_MATCH(DMI_BIOS_VERSION, "ASUS PR-DLS ACPI BIOS Revision 1010"),
  860. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  861. },
  862. },
  863. {
  864. .callback = disable_acpi_pci,
  865. .ident = "Acer TravelMate 36x Laptop",
  866. .matches = {
  867. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  868. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  869. },
  870. },
  871. #endif
  872. { }
  873. };
  874. #endif /* __i386__ */
  875. /*
  876. * acpi_boot_table_init() and acpi_boot_init()
  877. * called from setup_arch(), always.
  878. * 1. checksums all tables
  879. * 2. enumerates lapics
  880. * 3. enumerates io-apics
  881. *
  882. * acpi_table_init() is separate to allow reading SRAT without
  883. * other side effects.
  884. *
  885. * side effects of acpi_boot_init:
  886. * acpi_lapic = 1 if LAPIC found
  887. * acpi_ioapic = 1 if IOAPIC found
  888. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  889. * if acpi_blacklisted() acpi_disabled = 1;
  890. * acpi_irq_model=...
  891. * ...
  892. *
  893. * return value: (currently ignored)
  894. * 0: success
  895. * !0: failure
  896. */
  897. int __init
  898. acpi_boot_table_init(void)
  899. {
  900. int error;
  901. #ifdef __i386__
  902. dmi_check_system(acpi_dmi_table);
  903. #endif
  904. /*
  905. * If acpi_disabled, bail out
  906. * One exception: acpi=ht continues far enough to enumerate LAPICs
  907. */
  908. if (acpi_disabled && !acpi_ht)
  909. return 1;
  910. /*
  911. * Initialize the ACPI boot-time table parser.
  912. */
  913. error = acpi_table_init();
  914. if (error) {
  915. disable_acpi();
  916. return error;
  917. }
  918. #ifdef __i386__
  919. check_acpi_pci();
  920. #endif
  921. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  922. /*
  923. * blacklist may disable ACPI entirely
  924. */
  925. error = acpi_blacklisted();
  926. if (error) {
  927. if (acpi_force) {
  928. printk(KERN_WARNING PREFIX "acpi=force override\n");
  929. } else {
  930. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  931. disable_acpi();
  932. return error;
  933. }
  934. }
  935. return 0;
  936. }
  937. int __init acpi_boot_init(void)
  938. {
  939. /*
  940. * If acpi_disabled, bail out
  941. * One exception: acpi=ht continues far enough to enumerate LAPICs
  942. */
  943. if (acpi_disabled && !acpi_ht)
  944. return 1;
  945. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  946. /*
  947. * set sci_int and PM timer address
  948. */
  949. acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
  950. /*
  951. * Process the Multiple APIC Description Table (MADT), if present
  952. */
  953. acpi_process_madt();
  954. acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
  955. acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
  956. return 0;
  957. }