boot.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  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 <asm/pgtable.h>
  32. #include <asm/io_apic.h>
  33. #include <asm/apic.h>
  34. #include <asm/io.h>
  35. #include <asm/irq.h>
  36. #include <asm/mpspec.h>
  37. #ifdef CONFIG_X86_64
  38. static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) { }
  39. extern void __init clustered_apic_check(void);
  40. static inline int ioapic_setup_disabled(void) { return 0; }
  41. #include <asm/proto.h>
  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. #endif /* X86 */
  48. #define BAD_MADT_ENTRY(entry, end) ( \
  49. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  50. ((acpi_table_entry_header *)entry)->length != sizeof(*entry))
  51. #define PREFIX "ACPI: "
  52. #ifdef CONFIG_ACPI_PCI
  53. int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
  54. int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
  55. #else
  56. int acpi_noirq __initdata = 1;
  57. int acpi_pci_disabled __initdata = 1;
  58. #endif
  59. int acpi_ht __initdata = 1; /* enable HT */
  60. int acpi_lapic;
  61. int acpi_ioapic;
  62. int acpi_strict;
  63. EXPORT_SYMBOL(acpi_strict);
  64. acpi_interrupt_flags acpi_sci_flags __initdata;
  65. int acpi_sci_override_gsi __initdata;
  66. int acpi_skip_timer_override __initdata;
  67. #ifdef CONFIG_X86_LOCAL_APIC
  68. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  69. #endif
  70. #ifndef __HAVE_ARCH_CMPXCHG
  71. #warning ACPI uses CMPXCHG, i486 and later hardware
  72. #endif
  73. #define MAX_MADT_ENTRIES 256
  74. u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
  75. { [0 ... MAX_MADT_ENTRIES-1] = 0xff };
  76. EXPORT_SYMBOL(x86_acpiid_to_apicid);
  77. /* --------------------------------------------------------------------------
  78. Boot-time Configuration
  79. -------------------------------------------------------------------------- */
  80. /*
  81. * The default interrupt routing model is PIC (8259). This gets
  82. * overriden if IOAPICs are enumerated (below).
  83. */
  84. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  85. #ifdef CONFIG_X86_64
  86. /* rely on all ACPI tables being in the direct mapping */
  87. char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
  88. {
  89. if (!phys_addr || !size)
  90. return NULL;
  91. if (phys_addr < (end_pfn_map << PAGE_SHIFT))
  92. return __va(phys_addr);
  93. return NULL;
  94. }
  95. #else
  96. /*
  97. * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
  98. * to map the target physical address. The problem is that set_fixmap()
  99. * provides a single page, and it is possible that the page is not
  100. * sufficient.
  101. * By using this area, we can map up to MAX_IO_APICS pages temporarily,
  102. * i.e. until the next __va_range() call.
  103. *
  104. * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
  105. * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
  106. * count idx down while incrementing the phys address.
  107. */
  108. char *__acpi_map_table(unsigned long phys, unsigned long size)
  109. {
  110. unsigned long base, offset, mapped_size;
  111. int idx;
  112. if (phys + size < 8*1024*1024)
  113. return __va(phys);
  114. offset = phys & (PAGE_SIZE - 1);
  115. mapped_size = PAGE_SIZE - offset;
  116. set_fixmap(FIX_ACPI_END, phys);
  117. base = fix_to_virt(FIX_ACPI_END);
  118. /*
  119. * Most cases can be covered by the below.
  120. */
  121. idx = FIX_ACPI_END;
  122. while (mapped_size < size) {
  123. if (--idx < FIX_ACPI_BEGIN)
  124. return NULL; /* cannot handle this */
  125. phys += PAGE_SIZE;
  126. set_fixmap(idx, phys);
  127. mapped_size += PAGE_SIZE;
  128. }
  129. return ((unsigned char *) base + offset);
  130. }
  131. #endif
  132. #ifdef CONFIG_PCI_MMCONFIG
  133. static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
  134. {
  135. struct acpi_table_mcfg *mcfg;
  136. if (!phys_addr || !size)
  137. return -EINVAL;
  138. mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size);
  139. if (!mcfg) {
  140. printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
  141. return -ENODEV;
  142. }
  143. if (mcfg->base_reserved) {
  144. printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n");
  145. return -ENODEV;
  146. }
  147. pci_mmcfg_base_addr = mcfg->base_address;
  148. return 0;
  149. }
  150. #else
  151. #define acpi_parse_mcfg NULL
  152. #endif /* !CONFIG_PCI_MMCONFIG */
  153. #ifdef CONFIG_X86_LOCAL_APIC
  154. static int __init
  155. acpi_parse_madt (
  156. unsigned long phys_addr,
  157. unsigned long size)
  158. {
  159. struct acpi_table_madt *madt = NULL;
  160. if (!phys_addr || !size)
  161. return -EINVAL;
  162. madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size);
  163. if (!madt) {
  164. printk(KERN_WARNING PREFIX "Unable to map MADT\n");
  165. return -ENODEV;
  166. }
  167. if (madt->lapic_address) {
  168. acpi_lapic_addr = (u64) madt->lapic_address;
  169. printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
  170. madt->lapic_address);
  171. }
  172. acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
  173. return 0;
  174. }
  175. static int __init
  176. acpi_parse_lapic (
  177. acpi_table_entry_header *header, const unsigned long end)
  178. {
  179. struct acpi_table_lapic *processor = NULL;
  180. processor = (struct acpi_table_lapic*) header;
  181. if (BAD_MADT_ENTRY(processor, end))
  182. return -EINVAL;
  183. acpi_table_print_madt_entry(header);
  184. /* no utility in registering a disabled processor */
  185. if (processor->flags.enabled == 0)
  186. return 0;
  187. x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
  188. mp_register_lapic (
  189. processor->id, /* APIC ID */
  190. processor->flags.enabled); /* Enabled? */
  191. return 0;
  192. }
  193. static int __init
  194. acpi_parse_lapic_addr_ovr (
  195. acpi_table_entry_header *header, const unsigned long end)
  196. {
  197. struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
  198. lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header;
  199. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  200. return -EINVAL;
  201. acpi_lapic_addr = lapic_addr_ovr->address;
  202. return 0;
  203. }
  204. static int __init
  205. acpi_parse_lapic_nmi (
  206. acpi_table_entry_header *header, const unsigned long end)
  207. {
  208. struct acpi_table_lapic_nmi *lapic_nmi = NULL;
  209. lapic_nmi = (struct acpi_table_lapic_nmi*) header;
  210. if (BAD_MADT_ENTRY(lapic_nmi, end))
  211. return -EINVAL;
  212. acpi_table_print_madt_entry(header);
  213. if (lapic_nmi->lint != 1)
  214. printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
  215. return 0;
  216. }
  217. #endif /*CONFIG_X86_LOCAL_APIC*/
  218. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
  219. static int __init
  220. acpi_parse_ioapic (
  221. acpi_table_entry_header *header, const unsigned long end)
  222. {
  223. struct acpi_table_ioapic *ioapic = NULL;
  224. ioapic = (struct acpi_table_ioapic*) header;
  225. if (BAD_MADT_ENTRY(ioapic, end))
  226. return -EINVAL;
  227. acpi_table_print_madt_entry(header);
  228. mp_register_ioapic (
  229. ioapic->id,
  230. ioapic->address,
  231. ioapic->global_irq_base);
  232. return 0;
  233. }
  234. /*
  235. * Parse Interrupt Source Override for the ACPI SCI
  236. */
  237. static void
  238. acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
  239. {
  240. if (trigger == 0) /* compatible SCI trigger is level */
  241. trigger = 3;
  242. if (polarity == 0) /* compatible SCI polarity is low */
  243. polarity = 3;
  244. /* Command-line over-ride via acpi_sci= */
  245. if (acpi_sci_flags.trigger)
  246. trigger = acpi_sci_flags.trigger;
  247. if (acpi_sci_flags.polarity)
  248. polarity = acpi_sci_flags.polarity;
  249. /*
  250. * mp_config_acpi_legacy_irqs() already setup IRQs < 16
  251. * If GSI is < 16, this will update its flags,
  252. * else it will create a new mp_irqs[] entry.
  253. */
  254. mp_override_legacy_irq(gsi, polarity, trigger, gsi);
  255. /*
  256. * stash over-ride to indicate we've been here
  257. * and for later update of acpi_fadt
  258. */
  259. acpi_sci_override_gsi = gsi;
  260. return;
  261. }
  262. static int __init
  263. acpi_parse_int_src_ovr (
  264. acpi_table_entry_header *header, const unsigned long end)
  265. {
  266. struct acpi_table_int_src_ovr *intsrc = NULL;
  267. intsrc = (struct acpi_table_int_src_ovr*) header;
  268. if (BAD_MADT_ENTRY(intsrc, end))
  269. return -EINVAL;
  270. acpi_table_print_madt_entry(header);
  271. if (intsrc->bus_irq == acpi_fadt.sci_int) {
  272. acpi_sci_ioapic_setup(intsrc->global_irq,
  273. intsrc->flags.polarity, intsrc->flags.trigger);
  274. return 0;
  275. }
  276. if (acpi_skip_timer_override &&
  277. intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
  278. printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
  279. return 0;
  280. }
  281. mp_override_legacy_irq (
  282. intsrc->bus_irq,
  283. intsrc->flags.polarity,
  284. intsrc->flags.trigger,
  285. intsrc->global_irq);
  286. return 0;
  287. }
  288. static int __init
  289. acpi_parse_nmi_src (
  290. acpi_table_entry_header *header, const unsigned long end)
  291. {
  292. struct acpi_table_nmi_src *nmi_src = NULL;
  293. nmi_src = (struct acpi_table_nmi_src*) header;
  294. if (BAD_MADT_ENTRY(nmi_src, end))
  295. return -EINVAL;
  296. acpi_table_print_madt_entry(header);
  297. /* TBD: Support nimsrc entries? */
  298. return 0;
  299. }
  300. #endif /* CONFIG_X86_IO_APIC */
  301. #ifdef CONFIG_ACPI_BUS
  302. /*
  303. * acpi_pic_sci_set_trigger()
  304. *
  305. * use ELCR to set PIC-mode trigger type for SCI
  306. *
  307. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  308. * it may require Edge Trigger -- use "acpi_sci=edge"
  309. *
  310. * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
  311. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  312. * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
  313. * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
  314. */
  315. void __init
  316. acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  317. {
  318. unsigned int mask = 1 << irq;
  319. unsigned int old, new;
  320. /* Real old ELCR mask */
  321. old = inb(0x4d0) | (inb(0x4d1) << 8);
  322. /*
  323. * If we use ACPI to set PCI irq's, then we should clear ELCR
  324. * since we will set it correctly as we enable the PCI irq
  325. * routing.
  326. */
  327. new = acpi_noirq ? old : 0;
  328. /*
  329. * Update SCI information in the ELCR, it isn't in the PCI
  330. * routing tables..
  331. */
  332. switch (trigger) {
  333. case 1: /* Edge - clear */
  334. new &= ~mask;
  335. break;
  336. case 3: /* Level - set */
  337. new |= mask;
  338. break;
  339. }
  340. if (old == new)
  341. return;
  342. printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
  343. outb(new, 0x4d0);
  344. outb(new >> 8, 0x4d1);
  345. }
  346. #endif /* CONFIG_ACPI_BUS */
  347. int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  348. {
  349. #ifdef CONFIG_X86_IO_APIC
  350. if (use_pci_vector() && !platform_legacy_irq(gsi))
  351. *irq = IO_APIC_VECTOR(gsi);
  352. else
  353. #endif
  354. *irq = gsi;
  355. return 0;
  356. }
  357. unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
  358. {
  359. unsigned int irq;
  360. unsigned int plat_gsi = gsi;
  361. #ifdef CONFIG_PCI
  362. /*
  363. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  364. */
  365. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  366. extern void eisa_set_level_irq(unsigned int irq);
  367. if (edge_level == ACPI_LEVEL_SENSITIVE)
  368. eisa_set_level_irq(gsi);
  369. }
  370. #endif
  371. #ifdef CONFIG_X86_IO_APIC
  372. if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  373. plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
  374. }
  375. #endif
  376. acpi_gsi_to_irq(plat_gsi, &irq);
  377. return irq;
  378. }
  379. EXPORT_SYMBOL(acpi_register_gsi);
  380. /*
  381. * ACPI based hotplug support for CPU
  382. */
  383. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  384. int
  385. acpi_map_lsapic(acpi_handle handle, int *pcpu)
  386. {
  387. /* TBD */
  388. return -EINVAL;
  389. }
  390. EXPORT_SYMBOL(acpi_map_lsapic);
  391. int
  392. acpi_unmap_lsapic(int cpu)
  393. {
  394. /* TBD */
  395. return -EINVAL;
  396. }
  397. EXPORT_SYMBOL(acpi_unmap_lsapic);
  398. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  399. static unsigned long __init
  400. acpi_scan_rsdp (
  401. unsigned long start,
  402. unsigned long length)
  403. {
  404. unsigned long offset = 0;
  405. unsigned long sig_len = sizeof("RSD PTR ") - 1;
  406. /*
  407. * Scan all 16-byte boundaries of the physical memory region for the
  408. * RSDP signature.
  409. */
  410. for (offset = 0; offset < length; offset += 16) {
  411. if (strncmp((char *) (start + offset), "RSD PTR ", sig_len))
  412. continue;
  413. return (start + offset);
  414. }
  415. return 0;
  416. }
  417. static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
  418. {
  419. struct acpi_table_sbf *sb;
  420. if (!phys_addr || !size)
  421. return -EINVAL;
  422. sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size);
  423. if (!sb) {
  424. printk(KERN_WARNING PREFIX "Unable to map SBF\n");
  425. return -ENODEV;
  426. }
  427. sbf_port = sb->sbf_cmos; /* Save CMOS port */
  428. return 0;
  429. }
  430. #ifdef CONFIG_HPET_TIMER
  431. static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
  432. {
  433. struct acpi_table_hpet *hpet_tbl;
  434. if (!phys || !size)
  435. return -EINVAL;
  436. hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size);
  437. if (!hpet_tbl) {
  438. printk(KERN_WARNING PREFIX "Unable to map HPET\n");
  439. return -ENODEV;
  440. }
  441. if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
  442. printk(KERN_WARNING PREFIX "HPET timers must be located in "
  443. "memory.\n");
  444. return -1;
  445. }
  446. #ifdef CONFIG_X86_64
  447. vxtime.hpet_address = hpet_tbl->addr.addrl |
  448. ((long) hpet_tbl->addr.addrh << 32);
  449. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  450. hpet_tbl->id, vxtime.hpet_address);
  451. #else /* X86 */
  452. {
  453. extern unsigned long hpet_address;
  454. hpet_address = hpet_tbl->addr.addrl;
  455. printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
  456. hpet_tbl->id, hpet_address);
  457. }
  458. #endif /* X86 */
  459. return 0;
  460. }
  461. #else
  462. #define acpi_parse_hpet NULL
  463. #endif
  464. #ifdef CONFIG_X86_PM_TIMER
  465. extern u32 pmtmr_ioport;
  466. #endif
  467. static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
  468. {
  469. struct fadt_descriptor_rev2 *fadt = NULL;
  470. fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size);
  471. if(!fadt) {
  472. printk(KERN_WARNING PREFIX "Unable to map FADT\n");
  473. return 0;
  474. }
  475. #ifdef CONFIG_ACPI_INTERPRETER
  476. /* initialize sci_int early for INT_SRC_OVR MADT parsing */
  477. acpi_fadt.sci_int = fadt->sci_int;
  478. #endif
  479. #ifdef CONFIG_ACPI_BUS
  480. /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
  481. acpi_fadt.revision = fadt->revision;
  482. acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode;
  483. #endif
  484. #ifdef CONFIG_X86_PM_TIMER
  485. /* detect the location of the ACPI PM Timer */
  486. if (fadt->revision >= FADT2_REVISION_ID) {
  487. /* FADT rev. 2 */
  488. if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO)
  489. return 0;
  490. pmtmr_ioport = fadt->xpm_tmr_blk.address;
  491. } else {
  492. /* FADT rev. 1 */
  493. pmtmr_ioport = fadt->V1_pm_tmr_blk;
  494. }
  495. if (pmtmr_ioport)
  496. printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport);
  497. #endif
  498. return 0;
  499. }
  500. unsigned long __init
  501. acpi_find_rsdp (void)
  502. {
  503. unsigned long rsdp_phys = 0;
  504. if (efi_enabled) {
  505. if (efi.acpi20)
  506. return __pa(efi.acpi20);
  507. else if (efi.acpi)
  508. return __pa(efi.acpi);
  509. }
  510. /*
  511. * Scan memory looking for the RSDP signature. First search EBDA (low
  512. * memory) paragraphs and then search upper memory (E0000-FFFFF).
  513. */
  514. rsdp_phys = acpi_scan_rsdp (0, 0x400);
  515. if (!rsdp_phys)
  516. rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000);
  517. return rsdp_phys;
  518. }
  519. #ifdef CONFIG_X86_LOCAL_APIC
  520. /*
  521. * Parse LAPIC entries in MADT
  522. * returns 0 on success, < 0 on error
  523. */
  524. static int __init
  525. acpi_parse_madt_lapic_entries(void)
  526. {
  527. int count;
  528. /*
  529. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  530. * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
  531. */
  532. count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0);
  533. if (count < 0) {
  534. printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
  535. return count;
  536. }
  537. mp_register_lapic_address(acpi_lapic_addr);
  538. count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
  539. MAX_APICS);
  540. if (!count) {
  541. printk(KERN_ERR PREFIX "No LAPIC entries present\n");
  542. /* TBD: Cleanup to allow fallback to MPS */
  543. return -ENODEV;
  544. }
  545. else if (count < 0) {
  546. printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
  547. /* TBD: Cleanup to allow fallback to MPS */
  548. return count;
  549. }
  550. count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
  551. if (count < 0) {
  552. printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
  553. /* TBD: Cleanup to allow fallback to MPS */
  554. return count;
  555. }
  556. return 0;
  557. }
  558. #endif /* CONFIG_X86_LOCAL_APIC */
  559. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
  560. /*
  561. * Parse IOAPIC related entries in MADT
  562. * returns 0 on success, < 0 on error
  563. */
  564. static int __init
  565. acpi_parse_madt_ioapic_entries(void)
  566. {
  567. int count;
  568. /*
  569. * ACPI interpreter is required to complete interrupt setup,
  570. * so if it is off, don't enumerate the io-apics with ACPI.
  571. * If MPS is present, it will handle them,
  572. * otherwise the system will stay in PIC mode
  573. */
  574. if (acpi_disabled || acpi_noirq) {
  575. return -ENODEV;
  576. }
  577. /*
  578. * if "noapic" boot option, don't look for IO-APICs
  579. */
  580. if (skip_ioapic_setup) {
  581. printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
  582. "due to 'noapic' option.\n");
  583. return -ENODEV;
  584. }
  585. count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS);
  586. if (!count) {
  587. printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
  588. return -ENODEV;
  589. }
  590. else if (count < 0) {
  591. printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
  592. return count;
  593. }
  594. count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS);
  595. if (count < 0) {
  596. printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
  597. /* TBD: Cleanup to allow fallback to MPS */
  598. return count;
  599. }
  600. /*
  601. * If BIOS did not supply an INT_SRC_OVR for the SCI
  602. * pretend we got one so we can set the SCI flags.
  603. */
  604. if (!acpi_sci_override_gsi)
  605. acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
  606. /* Fill in identity legacy mapings where no override */
  607. mp_config_acpi_legacy_irqs();
  608. count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS);
  609. if (count < 0) {
  610. printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
  611. /* TBD: Cleanup to allow fallback to MPS */
  612. return count;
  613. }
  614. return 0;
  615. }
  616. #else
  617. static inline int acpi_parse_madt_ioapic_entries(void)
  618. {
  619. return -1;
  620. }
  621. #endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */
  622. static void __init
  623. acpi_process_madt(void)
  624. {
  625. #ifdef CONFIG_X86_LOCAL_APIC
  626. int count, error;
  627. count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
  628. if (count >= 1) {
  629. /*
  630. * Parse MADT LAPIC entries
  631. */
  632. error = acpi_parse_madt_lapic_entries();
  633. if (!error) {
  634. acpi_lapic = 1;
  635. /*
  636. * Parse MADT IO-APIC entries
  637. */
  638. error = acpi_parse_madt_ioapic_entries();
  639. if (!error) {
  640. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  641. acpi_irq_balance_set(NULL);
  642. acpi_ioapic = 1;
  643. smp_found_config = 1;
  644. clustered_apic_check();
  645. }
  646. }
  647. if (error == -EINVAL) {
  648. /*
  649. * Dell Precision Workstation 410, 610 come here.
  650. */
  651. printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n");
  652. disable_acpi();
  653. }
  654. }
  655. #endif
  656. return;
  657. }
  658. /*
  659. * acpi_boot_table_init() and acpi_boot_init()
  660. * called from setup_arch(), always.
  661. * 1. checksums all tables
  662. * 2. enumerates lapics
  663. * 3. enumerates io-apics
  664. *
  665. * acpi_table_init() is separate to allow reading SRAT without
  666. * other side effects.
  667. *
  668. * side effects of acpi_boot_init:
  669. * acpi_lapic = 1 if LAPIC found
  670. * acpi_ioapic = 1 if IOAPIC found
  671. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  672. * if acpi_blacklisted() acpi_disabled = 1;
  673. * acpi_irq_model=...
  674. * ...
  675. *
  676. * return value: (currently ignored)
  677. * 0: success
  678. * !0: failure
  679. */
  680. int __init
  681. acpi_boot_table_init(void)
  682. {
  683. int error;
  684. /*
  685. * If acpi_disabled, bail out
  686. * One exception: acpi=ht continues far enough to enumerate LAPICs
  687. */
  688. if (acpi_disabled && !acpi_ht)
  689. return 1;
  690. /*
  691. * Initialize the ACPI boot-time table parser.
  692. */
  693. error = acpi_table_init();
  694. if (error) {
  695. disable_acpi();
  696. return error;
  697. }
  698. #ifdef __i386__
  699. check_acpi_pci();
  700. #endif
  701. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  702. /*
  703. * blacklist may disable ACPI entirely
  704. */
  705. error = acpi_blacklisted();
  706. if (error) {
  707. extern int acpi_force;
  708. if (acpi_force) {
  709. printk(KERN_WARNING PREFIX "acpi=force override\n");
  710. } else {
  711. printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
  712. disable_acpi();
  713. return error;
  714. }
  715. }
  716. return 0;
  717. }
  718. int __init acpi_boot_init(void)
  719. {
  720. /*
  721. * If acpi_disabled, bail out
  722. * One exception: acpi=ht continues far enough to enumerate LAPICs
  723. */
  724. if (acpi_disabled && !acpi_ht)
  725. return 1;
  726. acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
  727. /*
  728. * set sci_int and PM timer address
  729. */
  730. acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
  731. /*
  732. * Process the Multiple APIC Description Table (MADT), if present
  733. */
  734. acpi_process_madt();
  735. acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
  736. acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
  737. return 0;
  738. }