boot.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158
  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+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
  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. /* Record local apic id only when enabled */
  201. if (processor->flags.enabled)
  202. x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
  203. /*
  204. * We need to register disabled CPU as well to permit
  205. * counting disabled CPUs. This allows us to size
  206. * cpus_possible_map more accurately, to permit
  207. * to not preallocating memory for all NR_CPUS
  208. * when we use CPU hotplug.
  209. */
  210. mp_register_lapic(processor->id, /* APIC ID */
  211. processor->flags.enabled); /* Enabled? */
  212. return 0;
  213. }
  214. static int __init
  215. acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
  216. const unsigned long end)
  217. {
  218. struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
  219. lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr *)header;
  220. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  221. return -EINVAL;
  222. acpi_lapic_addr = lapic_addr_ovr->address;
  223. return 0;
  224. }
  225. static int __init
  226. acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
  227. {
  228. struct acpi_table_lapic_nmi *lapic_nmi = NULL;
  229. lapic_nmi = (struct acpi_table_lapic_nmi *)header;
  230. if (BAD_MADT_ENTRY(lapic_nmi, end))
  231. return -EINVAL;
  232. acpi_table_print_madt_entry(header);
  233. if (lapic_nmi->lint != 1)
  234. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  235. return 0;
  236. }
  237. #endif /*CONFIG_X86_LOCAL_APIC */
  238. #ifdef CONFIG_X86_IO_APIC
  239. static int __init
  240. acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
  241. {
  242. struct acpi_table_ioapic *ioapic = NULL;
  243. ioapic = (struct acpi_table_ioapic *)header;
  244. if (BAD_MADT_ENTRY(ioapic, end))
  245. return -EINVAL;
  246. acpi_table_print_madt_entry(header);
  247. mp_register_ioapic(ioapic->id,
  248. ioapic->address, ioapic->global_irq_base);
  249. return 0;
  250. }
  251. /*
  252. * Parse Interrupt Source Override for the ACPI SCI
  253. */
  254. static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  255. {
  256. if (trigger == 0) /* compatible SCI trigger is level */
  257. trigger = 3;
  258. if (polarity == 0) /* compatible SCI polarity is low */
  259. polarity = 3;
  260. /* Command-line over-ride via acpi_sci= */
  261. if (acpi_sci_flags.trigger)
  262. trigger = acpi_sci_flags.trigger;
  263. if (acpi_sci_flags.polarity)
  264. polarity = acpi_sci_flags.polarity;
  265. /*
  266. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  267. * If GSI is < 16, this will update its flags,
  268. * else it will create a new mp_irqs[] entry.
  269. */
  270. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  271. /*
  272. * stash over-ride to indicate we've been here
  273. * and for later update of acpi_fadt
  274. */
  275. acpi_sci_override_gsi = gsi;
  276. return;
  277. }
  278. static int __init
  279. acpi_parse_int_src_ovr(acpi_table_entry_header * header,
  280. const unsigned long end)
  281. {
  282. struct acpi_table_int_src_ovr *intsrc = NULL;
  283. intsrc = (struct acpi_table_int_src_ovr *)header;
  284. if (BAD_MADT_ENTRY(intsrc, end))
  285. return -EINVAL;
  286. acpi_table_print_madt_entry(header);
  287. if (intsrc->bus_irq == acpi_fadt.sci_int) {
  288. acpi_sci_ioapic_setup(intsrc->global_irq,
  289. intsrc->flags.polarity,
  290. intsrc->flags.trigger);
  291. return 0;
  292. }
  293. if (acpi_skip_timer_override &&
  294. intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
  295. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  296. return 0;
  297. }
  298. mp_override_legacy_irq(intsrc->bus_irq,
  299. intsrc->flags.polarity,
  300. intsrc->flags.trigger, intsrc->global_irq);
  301. return 0;
  302. }
  303. static int __init
  304. acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
  305. {
  306. struct acpi_table_nmi_src *nmi_src = NULL;
  307. nmi_src = (struct acpi_table_nmi_src *)header;
  308. if (BAD_MADT_ENTRY(nmi_src, end))
  309. return -EINVAL;
  310. acpi_table_print_madt_entry(header);
  311. /* TBD: Support nimsrc entries? */
  312. return 0;
  313. }
  314. #endif /* CONFIG_X86_IO_APIC */
  315. /*
  316. * acpi_pic_sci_set_trigger()
  317. *
  318. * use ELCR to set PIC-mode trigger type for SCI
  319. *
  320. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  321. * it may require Edge Trigger -- use "acpi_sci=edge"
  322. *
  323. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  324. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  325. * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
  326. * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
  327. */
  328. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  329. {
  330. unsigned int mask = 1 << irq;
  331. unsigned int old, new;
  332. /* Real old ELCR mask */
  333. old = inb(0x4d0) | (inb(0x4d1) << 8);
  334. /*
  335. * If we use ACPI to set PCI irq's, then we should clear ELCR
  336. * since we will set it correctly as we enable the PCI irq
  337. * routing.
  338. */
  339. new = acpi_noirq ? old : 0;
  340. /*
  341. * Update SCI information in the ELCR, it isn't in the PCI
  342. * routing tables..
  343. */
  344. switch (trigger) {
  345. case 1: /* Edge - clear */
  346. new &= ~mask;
  347. break;
  348. case 3: /* Level - set */
  349. new |= mask;
  350. break;
  351. }
  352. if (old == new)
  353. return;
  354. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  355. outb(new, 0x4d0);
  356. outb(new >> 8, 0x4d1);
  357. }
  358. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  359. {
  360. #ifdef CONFIG_X86_IO_APIC
  361. if (use_pci_vector() && !platform_legacy_irq(gsi))
  362. *irq = IO_APIC_VECTOR(gsi);
  363. else
  364. #endif
  365. *irq = gsi_irq_sharing(gsi);
  366. return 0;
  367. }
  368. /*
  369. * success: return IRQ number (>=0)
  370. * failure: return < 0
  371. */
  372. int acpi_register_gsi(u32 gsi, int triggering, int polarity)
  373. {
  374. unsigned int irq;
  375. unsigned int plat_gsi = gsi;
  376. #ifdef CONFIG_PCI
  377. /*
  378. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  379. */
  380. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  381. extern void eisa_set_level_irq(unsigned int irq);
  382. if (triggering == ACPI_LEVEL_SENSITIVE)
  383. eisa_set_level_irq(gsi);
  384. }
  385. #endif
  386. #ifdef CONFIG_X86_IO_APIC
  387. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  388. plat_gsi = mp_register_gsi(gsi, triggering, polarity);
  389. }
  390. #endif
  391. acpi_gsi_to_irq(plat_gsi, &irq);
  392. return irq;
  393. }
  394. EXPORT_SYMBOL(acpi_register_gsi);
  395. /*
  396. * ACPI based hotplug support for CPU
  397. */
  398. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  399. int acpi_map_lsapic(acpi_handle handle, int *pcpu)
  400. {
  401. /* TBD */
  402. return -EINVAL;
  403. }
  404. EXPORT_SYMBOL(acpi_map_lsapic);
  405. int acpi_unmap_lsapic(int cpu)
  406. {
  407. /* TBD */
  408. return -EINVAL;
  409. }
  410. EXPORT_SYMBOL(acpi_unmap_lsapic);
  411. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  412. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  413. {
  414. /* TBD */
  415. return -EINVAL;
  416. }
  417. EXPORT_SYMBOL(acpi_register_ioapic);
  418. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  419. {
  420. /* TBD */
  421. return -EINVAL;
  422. }
  423. EXPORT_SYMBOL(acpi_unregister_ioapic);
  424. static unsigned long __init
  425. acpi_scan_rsdp(unsigned long start, unsigned long length)
  426. {
  427. unsigned long offset = 0;
  428. unsigned long sig_len = sizeof("RSD PTR ") - 1;
  429. /*
  430. * Scan all 16-byte boundaries of the physical memory region for the
  431. * RSDP signature.
  432. */
  433. for (offset = 0; offset < length; offset += 16) {
  434. if (strncmp((char *)(phys_to_virt(start) + offset), "RSD PTR ", sig_len))
  435. continue;
  436. return (start + offset);
  437. }
  438. return 0;
  439. }
  440. static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
  441. {
  442. struct acpi_table_sbf *sb;
  443. if (!phys_addr || !size)
  444. return -EINVAL;
  445. sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
  446. if (!sb) {
  447. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  448. return -ENODEV;
  449. }
  450. sbf_port = sb->sbf_cmos; /* Save CMOS port */
  451. return 0;
  452. }
  453. #ifdef CONFIG_HPET_TIMER
  454. static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
  455. {
  456. struct acpi_table_hpet *hpet_tbl;
  457. if (!phys || !size)
  458. return -EINVAL;
  459. hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
  460. if (!hpet_tbl) {
  461. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  462. return -ENODEV;
  463. }
  464. if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
  465. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  466. "memory.\n");
  467. return -1;
  468. }
  469. #ifdef CONFIG_X86_64
  470. vxtime.hpet_address = hpet_tbl->addr.addrl |
  471. ((long)hpet_tbl->addr.addrh << 32);
  472. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  473. hpet_tbl->id, vxtime.hpet_address);
  474. #else /* X86 */
  475. {
  476. extern unsigned long hpet_address;
  477. hpet_address = hpet_tbl->addr.addrl;
  478. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  479. hpet_tbl->id, hpet_address);
  480. }
  481. #endif /* X86 */
  482. return 0;
  483. }
  484. #else
  485. #define acpi_parse_hpet NULL
  486. #endif
  487. #ifdef CONFIG_X86_PM_TIMER
  488. extern u32 pmtmr_ioport;
  489. #endif
  490. static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
  491. {
  492. struct fadt_descriptor_rev2 *fadt = NULL;
  493. fadt = (struct fadt_descriptor_rev2 *)__acpi_map_table(phys, size);
  494. if (!fadt) {
  495. printk(KERN_WARNING PREFIX "Unable to map FADT\n");
  496. return 0;
  497. }
  498. /* initialize sci_int early for INT_SRC_OVR MADT parsing */
  499. acpi_fadt.sci_int = fadt->sci_int;
  500. /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
  501. acpi_fadt.revision = fadt->revision;
  502. acpi_fadt.force_apic_physical_destination_mode =
  503. fadt->force_apic_physical_destination_mode;
  504. #ifdef CONFIG_X86_PM_TIMER
  505. /* detect the location of the ACPI PM Timer */
  506. if (fadt->revision >= FADT2_REVISION_ID) {
  507. /* FADT rev. 2 */
  508. if (fadt->xpm_tmr_blk.address_space_id !=
  509. ACPI_ADR_SPACE_SYSTEM_IO)
  510. return 0;
  511. pmtmr_ioport = fadt->xpm_tmr_blk.address;
  512. /*
  513. * "X" fields are optional extensions to the original V1.0
  514. * fields, so we must selectively expand V1.0 fields if the
  515. * corresponding X field is zero.
  516. */
  517. if (!pmtmr_ioport)
  518. pmtmr_ioport = fadt->V1_pm_tmr_blk;
  519. } else {
  520. /* FADT rev. 1 */
  521. pmtmr_ioport = fadt->V1_pm_tmr_blk;
  522. }
  523. if (pmtmr_ioport)
  524. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
  525. pmtmr_ioport);
  526. #endif
  527. return 0;
  528. }
  529. unsigned long __init acpi_find_rsdp(void)
  530. {
  531. unsigned long rsdp_phys = 0;
  532. if (efi_enabled) {
  533. if (efi.acpi20)
  534. return __pa(efi.acpi20);
  535. else if (efi.acpi)
  536. return __pa(efi.acpi);
  537. }
  538. /*
  539. * Scan memory looking for the RSDP signature. First search EBDA (low
  540. * memory) paragraphs and then search upper memory (E0000-FFFFF).
  541. */
  542. rsdp_phys = acpi_scan_rsdp(0, 0x400);
  543. if (!rsdp_phys)
  544. rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
  545. return rsdp_phys;
  546. }
  547. #ifdef CONFIG_X86_LOCAL_APIC
  548. /*
  549. * Parse LAPIC entries in MADT
  550. * returns 0 on success, < 0 on error
  551. */
  552. static int __init acpi_parse_madt_lapic_entries(void)
  553. {
  554. int count;
  555. /*
  556. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  557. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  558. */
  559. count =
  560. acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR,
  561. acpi_parse_lapic_addr_ovr, 0);
  562. if (count < 0) {
  563. printk(KERN_ERR PREFIX
  564. "Error parsing LAPIC address override entry\n");
  565. return count;
  566. }
  567. mp_register_lapic_address(acpi_lapic_addr);
  568. count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
  569. MAX_APICS);
  570. if (!count) {
  571. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  572. /* TBD: Cleanup to allow fallback to MPS */
  573. return -ENODEV;
  574. } else if (count < 0) {
  575. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  576. /* TBD: Cleanup to allow fallback to MPS */
  577. return count;
  578. }
  579. count =
  580. acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
  581. if (count < 0) {
  582. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  583. /* TBD: Cleanup to allow fallback to MPS */
  584. return count;
  585. }
  586. return 0;
  587. }
  588. #endif /* CONFIG_X86_LOCAL_APIC */
  589. #ifdef CONFIG_X86_IO_APIC
  590. /*
  591. * Parse IOAPIC related entries in MADT
  592. * returns 0 on success, < 0 on error
  593. */
  594. static int __init acpi_parse_madt_ioapic_entries(void)
  595. {
  596. int count;
  597. /*
  598. * ACPI interpreter is required to complete interrupt setup,
  599. * so if it is off, don't enumerate the io-apics with ACPI.
  600. * If MPS is present, it will handle them,
  601. * otherwise the system will stay in PIC mode
  602. */
  603. if (acpi_disabled || acpi_noirq) {
  604. return -ENODEV;
  605. }
  606. /*
  607. * if "noapic" boot option, don't look for IO-APICs
  608. */
  609. if (skip_ioapic_setup) {
  610. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  611. "due to 'noapic' option.\n");
  612. return -ENODEV;
  613. }
  614. count =
  615. acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic,
  616. MAX_IO_APICS);
  617. if (!count) {
  618. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  619. return -ENODEV;
  620. } else if (count < 0) {
  621. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  622. return count;
  623. }
  624. count =
  625. acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr,
  626. NR_IRQ_VECTORS);
  627. if (count < 0) {
  628. printk(KERN_ERR PREFIX
  629. "Error parsing interrupt source overrides entry\n");
  630. /* TBD: Cleanup to allow fallback to MPS */
  631. return count;
  632. }
  633. /*
  634. * If BIOS did not supply an INT_SRC_OVR for the SCI
  635. * pretend we got one so we can set the SCI flags.
  636. */
  637. if (!acpi_sci_override_gsi)
  638. acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
  639. /* Fill in identity legacy mapings where no override */
  640. mp_config_acpi_legacy_irqs();
  641. count =
  642. acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src,
  643. NR_IRQ_VECTORS);
  644. if (count < 0) {
  645. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  646. /* TBD: Cleanup to allow fallback to MPS */
  647. return count;
  648. }
  649. return 0;
  650. }
  651. #else
  652. static inline int acpi_parse_madt_ioapic_entries(void)
  653. {
  654. return -1;
  655. }
  656. #endif /* !CONFIG_X86_IO_APIC */
  657. static void __init acpi_process_madt(void)
  658. {
  659. #ifdef CONFIG_X86_LOCAL_APIC
  660. int count, error;
  661. count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
  662. if (count >= 1) {
  663. /*
  664. * Parse MADT LAPIC entries
  665. */
  666. error = acpi_parse_madt_lapic_entries();
  667. if (!error) {
  668. acpi_lapic = 1;
  669. #ifdef CONFIG_X86_GENERICARCH
  670. generic_bigsmp_probe();
  671. #endif
  672. /*
  673. * Parse MADT IO-APIC entries
  674. */
  675. error = acpi_parse_madt_ioapic_entries();
  676. if (!error) {
  677. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  678. acpi_irq_balance_set(NULL);
  679. acpi_ioapic = 1;
  680. smp_found_config = 1;
  681. clustered_apic_check();
  682. }
  683. }
  684. if (error == -EINVAL) {
  685. /*
  686. * Dell Precision Workstation 410, 610 come here.
  687. */
  688. printk(KERN_ERR PREFIX
  689. "Invalid BIOS MADT, disabling ACPI\n");
  690. disable_acpi();
  691. }
  692. }
  693. #endif
  694. return;
  695. }
  696. extern int acpi_force;
  697. #ifdef __i386__
  698. static int __init disable_acpi_irq(struct dmi_system_id *d)
  699. {
  700. if (!acpi_force) {
  701. printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
  702. d->ident);
  703. acpi_noirq_set();
  704. }
  705. return 0;
  706. }
  707. static int __init disable_acpi_pci(struct dmi_system_id *d)
  708. {
  709. if (!acpi_force) {
  710. printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
  711. d->ident);
  712. acpi_disable_pci();
  713. }
  714. return 0;
  715. }
  716. static int __init dmi_disable_acpi(struct dmi_system_id *d)
  717. {
  718. if (!acpi_force) {
  719. printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
  720. disable_acpi();
  721. } else {
  722. printk(KERN_NOTICE
  723. "Warning: DMI blacklist says broken, but acpi forced\n");
  724. }
  725. return 0;
  726. }
  727. /*
  728. * Limit ACPI to CPU enumeration for HT
  729. */
  730. static int __init force_acpi_ht(struct dmi_system_id *d)
  731. {
  732. if (!acpi_force) {
  733. printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
  734. d->ident);
  735. disable_acpi();
  736. acpi_ht = 1;
  737. } else {
  738. printk(KERN_NOTICE
  739. "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
  740. }
  741. return 0;
  742. }
  743. /*
  744. * If your system is blacklisted here, but you find that acpi=force
  745. * works for you, please contact acpi-devel@sourceforge.net
  746. */
  747. static struct dmi_system_id __initdata acpi_dmi_table[] = {
  748. /*
  749. * Boxes that need ACPI disabled
  750. */
  751. {
  752. .callback = dmi_disable_acpi,
  753. .ident = "IBM Thinkpad",
  754. .matches = {
  755. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  756. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  757. },
  758. },
  759. /*
  760. * Boxes that need acpi=ht
  761. */
  762. {
  763. .callback = force_acpi_ht,
  764. .ident = "FSC Primergy T850",
  765. .matches = {
  766. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  767. DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
  768. },
  769. },
  770. {
  771. .callback = force_acpi_ht,
  772. .ident = "DELL GX240",
  773. .matches = {
  774. DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
  775. DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
  776. },
  777. },
  778. {
  779. .callback = force_acpi_ht,
  780. .ident = "HP VISUALIZE NT Workstation",
  781. .matches = {
  782. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  783. DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
  784. },
  785. },
  786. {
  787. .callback = force_acpi_ht,
  788. .ident = "Compaq Workstation W8000",
  789. .matches = {
  790. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  791. DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
  792. },
  793. },
  794. {
  795. .callback = force_acpi_ht,
  796. .ident = "ASUS P4B266",
  797. .matches = {
  798. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  799. DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
  800. },
  801. },
  802. {
  803. .callback = force_acpi_ht,
  804. .ident = "ASUS P2B-DS",
  805. .matches = {
  806. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  807. DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
  808. },
  809. },
  810. {
  811. .callback = force_acpi_ht,
  812. .ident = "ASUS CUR-DLS",
  813. .matches = {
  814. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  815. DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
  816. },
  817. },
  818. {
  819. .callback = force_acpi_ht,
  820. .ident = "ABIT i440BX-W83977",
  821. .matches = {
  822. DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
  823. DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
  824. },
  825. },
  826. {
  827. .callback = force_acpi_ht,
  828. .ident = "IBM Bladecenter",
  829. .matches = {
  830. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  831. DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
  832. },
  833. },
  834. {
  835. .callback = force_acpi_ht,
  836. .ident = "IBM eServer xSeries 360",
  837. .matches = {
  838. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  839. DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
  840. },
  841. },
  842. {
  843. .callback = force_acpi_ht,
  844. .ident = "IBM eserver xSeries 330",
  845. .matches = {
  846. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  847. DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
  848. },
  849. },
  850. {
  851. .callback = force_acpi_ht,
  852. .ident = "IBM eserver xSeries 440",
  853. .matches = {
  854. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  855. DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
  856. },
  857. },
  858. /*
  859. * Boxes that need ACPI PCI IRQ routing disabled
  860. */
  861. {
  862. .callback = disable_acpi_irq,
  863. .ident = "ASUS A7V",
  864. .matches = {
  865. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  866. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  867. /* newer BIOS, Revision 1011, does work */
  868. DMI_MATCH(DMI_BIOS_VERSION,
  869. "ASUS A7V ACPI BIOS Revision 1007"),
  870. },
  871. },
  872. /*
  873. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  874. */
  875. { /* _BBN 0 bug */
  876. .callback = disable_acpi_pci,
  877. .ident = "ASUS PR-DLS",
  878. .matches = {
  879. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  880. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  881. DMI_MATCH(DMI_BIOS_VERSION,
  882. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  883. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  884. },
  885. },
  886. {
  887. .callback = disable_acpi_pci,
  888. .ident = "Acer TravelMate 36x Laptop",
  889. .matches = {
  890. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  891. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  892. },
  893. },
  894. {}
  895. };
  896. #endif /* __i386__ */
  897. /*
  898. * acpi_boot_table_init() and acpi_boot_init()
  899. * called from setup_arch(), always.
  900. * 1. checksums all tables
  901. * 2. enumerates lapics
  902. * 3. enumerates io-apics
  903. *
  904. * acpi_table_init() is separate to allow reading SRAT without
  905. * other side effects.
  906. *
  907. * side effects of acpi_boot_init:
  908. * acpi_lapic = 1 if LAPIC found
  909. * acpi_ioapic = 1 if IOAPIC found
  910. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  911. * if acpi_blacklisted() acpi_disabled = 1;
  912. * acpi_irq_model=...
  913. * ...
  914. *
  915. * return value: (currently ignored)
  916. * 0: success
  917. * !0: failure
  918. */
  919. int __init acpi_boot_table_init(void)
  920. {
  921. int error;
  922. #ifdef __i386__
  923. dmi_check_system(acpi_dmi_table);
  924. #endif
  925. /*
  926. * If acpi_disabled, bail out
  927. * One exception: acpi=ht continues far enough to enumerate LAPICs
  928. */
  929. if (acpi_disabled && !acpi_ht)
  930. return 1;
  931. /*
  932. * Initialize the ACPI boot-time table parser.
  933. */
  934. error = acpi_table_init();
  935. if (error) {
  936. disable_acpi();
  937. return error;
  938. }
  939. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  940. /*
  941. * blacklist may disable ACPI entirely
  942. */
  943. error = acpi_blacklisted();
  944. if (error) {
  945. if (acpi_force) {
  946. printk(KERN_WARNING PREFIX "acpi=force override\n");
  947. } else {
  948. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  949. disable_acpi();
  950. return error;
  951. }
  952. }
  953. return 0;
  954. }
  955. int __init acpi_boot_init(void)
  956. {
  957. /*
  958. * If acpi_disabled, bail out
  959. * One exception: acpi=ht continues far enough to enumerate LAPICs
  960. */
  961. if (acpi_disabled && !acpi_ht)
  962. return 1;
  963. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  964. /*
  965. * set sci_int and PM timer address
  966. */
  967. acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
  968. /*
  969. * Process the Multiple APIC Description Table (MADT), if present
  970. */
  971. acpi_process_madt();
  972. acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
  973. return 0;
  974. }