boot.c 27 KB

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