boot.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * boot.c - Architecture-Specific Low-Level ACPI Boot Support
  4. *
  5. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6. * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
  7. */
  8. #define pr_fmt(fmt) "ACPI: " fmt
  9. #include <linux/init.h>
  10. #include <linux/acpi.h>
  11. #include <linux/acpi_pmtmr.h>
  12. #include <linux/efi.h>
  13. #include <linux/cpumask.h>
  14. #include <linux/export.h>
  15. #include <linux/dmi.h>
  16. #include <linux/irq.h>
  17. #include <linux/slab.h>
  18. #include <linux/memblock.h>
  19. #include <linux/ioport.h>
  20. #include <linux/pci.h>
  21. #include <linux/efi-bgrt.h>
  22. #include <linux/serial_core.h>
  23. #include <linux/pgtable.h>
  24. #include <xen/xen.h>
  25. #include <asm/e820/api.h>
  26. #include <asm/irqdomain.h>
  27. #include <asm/pci_x86.h>
  28. #include <asm/io_apic.h>
  29. #include <asm/apic.h>
  30. #include <asm/io.h>
  31. #include <asm/mpspec.h>
  32. #include <asm/smp.h>
  33. #include <asm/i8259.h>
  34. #include <asm/setup.h>
  35. #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
  36. static int __initdata acpi_force = 0;
  37. int acpi_disabled;
  38. EXPORT_SYMBOL(acpi_disabled);
  39. #ifdef CONFIG_X86_64
  40. # include <asm/proto.h>
  41. #endif /* X86 */
  42. int acpi_noirq; /* skip ACPI IRQ initialization */
  43. static int acpi_nobgrt; /* skip ACPI BGRT */
  44. int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
  45. EXPORT_SYMBOL(acpi_pci_disabled);
  46. int acpi_lapic;
  47. int acpi_ioapic;
  48. int acpi_strict;
  49. int acpi_disable_cmcff;
  50. bool acpi_int_src_ovr[NR_IRQS_LEGACY];
  51. /* ACPI SCI override configuration */
  52. u8 acpi_sci_flags __initdata;
  53. u32 acpi_sci_override_gsi __initdata = INVALID_ACPI_IRQ;
  54. int acpi_skip_timer_override __initdata;
  55. int acpi_use_timer_override __initdata;
  56. int acpi_fix_pin2_polarity __initdata;
  57. #ifdef CONFIG_X86_LOCAL_APIC
  58. static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  59. static bool has_lapic_cpus __initdata;
  60. static bool acpi_support_online_capable;
  61. #endif
  62. #ifdef CONFIG_X86_IO_APIC
  63. /*
  64. * Locks related to IOAPIC hotplug
  65. * Hotplug side:
  66. * ->device_hotplug_lock
  67. * ->acpi_ioapic_lock
  68. * ->ioapic_lock
  69. * Interrupt mapping side:
  70. * ->acpi_ioapic_lock
  71. * ->ioapic_mutex
  72. * ->ioapic_lock
  73. */
  74. static DEFINE_MUTEX(acpi_ioapic_lock);
  75. #endif
  76. /* --------------------------------------------------------------------------
  77. Boot-time Configuration
  78. -------------------------------------------------------------------------- */
  79. /*
  80. * The default interrupt routing model is PIC (8259). This gets
  81. * overridden if IOAPICs are enumerated (below).
  82. */
  83. enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
  84. /*
  85. * ISA irqs by default are the first 16 gsis but can be
  86. * any gsi as specified by an interrupt source override.
  87. */
  88. static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {
  89. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
  90. };
  91. /*
  92. * This is just a simple wrapper around early_memremap(),
  93. * with sanity checks for phys == 0 and size == 0.
  94. */
  95. void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
  96. {
  97. if (!phys || !size)
  98. return NULL;
  99. return early_memremap(phys, size);
  100. }
  101. void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
  102. {
  103. if (!map || !size)
  104. return;
  105. early_memunmap(map, size);
  106. }
  107. #ifdef CONFIG_X86_LOCAL_APIC
  108. static int __init acpi_parse_madt(struct acpi_table_header *table)
  109. {
  110. struct acpi_table_madt *madt = NULL;
  111. if (!boot_cpu_has(X86_FEATURE_APIC))
  112. return -EINVAL;
  113. madt = (struct acpi_table_madt *)table;
  114. if (!madt) {
  115. pr_warn("Unable to map MADT\n");
  116. return -ENODEV;
  117. }
  118. if (madt->address) {
  119. acpi_lapic_addr = (u64) madt->address;
  120. pr_debug("Local APIC address 0x%08x\n", madt->address);
  121. }
  122. if (madt->flags & ACPI_MADT_PCAT_COMPAT)
  123. legacy_pic_pcat_compat();
  124. /* ACPI 6.3 and newer support the online capable bit. */
  125. if (acpi_gbl_FADT.header.revision > 6 ||
  126. (acpi_gbl_FADT.header.revision == 6 &&
  127. acpi_gbl_FADT.minor_revision >= 3))
  128. acpi_support_online_capable = true;
  129. default_acpi_madt_oem_check(madt->header.oem_id,
  130. madt->header.oem_table_id);
  131. return 0;
  132. }
  133. static bool __init acpi_is_processor_usable(u32 lapic_flags)
  134. {
  135. if (lapic_flags & ACPI_MADT_ENABLED)
  136. return true;
  137. if (!acpi_support_online_capable ||
  138. (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
  139. return true;
  140. return false;
  141. }
  142. static int __init
  143. acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
  144. {
  145. struct acpi_madt_local_x2apic *processor = NULL;
  146. #ifdef CONFIG_X86_X2APIC
  147. u32 apic_id;
  148. u8 enabled;
  149. #endif
  150. processor = (struct acpi_madt_local_x2apic *)header;
  151. if (BAD_MADT_ENTRY(processor, end))
  152. return -EINVAL;
  153. acpi_table_print_madt_entry(&header->common);
  154. #ifdef CONFIG_X86_X2APIC
  155. apic_id = processor->local_apic_id;
  156. enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
  157. /* Ignore invalid ID */
  158. if (apic_id == 0xffffffff)
  159. return 0;
  160. /* don't register processors that cannot be onlined */
  161. if (!acpi_is_processor_usable(processor->lapic_flags))
  162. return 0;
  163. /*
  164. * According to https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#processor-local-x2apic-structure
  165. * when MADT provides both valid LAPIC and x2APIC entries, the APIC ID
  166. * in x2APIC must be equal or greater than 0xff.
  167. */
  168. if (has_lapic_cpus && apic_id < 0xff)
  169. return 0;
  170. /*
  171. * We need to register disabled CPU as well to permit
  172. * counting disabled CPUs. This allows us to size
  173. * cpus_possible_map more accurately, to permit
  174. * to not preallocating memory for all NR_CPUS
  175. * when we use CPU hotplug.
  176. */
  177. if (!apic_id_valid(apic_id)) {
  178. if (enabled)
  179. pr_warn("x2apic entry ignored\n");
  180. return 0;
  181. }
  182. topology_register_apic(apic_id, processor->uid, enabled);
  183. #else
  184. pr_warn("x2apic entry ignored\n");
  185. #endif
  186. return 0;
  187. }
  188. static int __init
  189. acpi_check_lapic(union acpi_subtable_headers *header, const unsigned long end)
  190. {
  191. struct acpi_madt_local_apic *processor = NULL;
  192. processor = (struct acpi_madt_local_apic *)header;
  193. if (BAD_MADT_ENTRY(processor, end))
  194. return -EINVAL;
  195. /* Ignore invalid ID */
  196. if (processor->id == 0xff)
  197. return 0;
  198. /* Ignore processors that can not be onlined */
  199. if (!acpi_is_processor_usable(processor->lapic_flags))
  200. return 0;
  201. has_lapic_cpus = true;
  202. return 0;
  203. }
  204. static int __init
  205. acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
  206. {
  207. struct acpi_madt_local_apic *processor = NULL;
  208. processor = (struct acpi_madt_local_apic *)header;
  209. if (BAD_MADT_ENTRY(processor, end))
  210. return -EINVAL;
  211. acpi_table_print_madt_entry(&header->common);
  212. /* Ignore invalid ID */
  213. if (processor->id == 0xff)
  214. return 0;
  215. /* don't register processors that can not be onlined */
  216. if (!acpi_is_processor_usable(processor->lapic_flags))
  217. return 0;
  218. /*
  219. * We need to register disabled CPU as well to permit
  220. * counting disabled CPUs. This allows us to size
  221. * cpus_possible_map more accurately, to permit
  222. * to not preallocating memory for all NR_CPUS
  223. * when we use CPU hotplug.
  224. */
  225. topology_register_apic(processor->id, /* APIC ID */
  226. processor->processor_id, /* ACPI ID */
  227. processor->lapic_flags & ACPI_MADT_ENABLED);
  228. return 0;
  229. }
  230. static int __init
  231. acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end)
  232. {
  233. struct acpi_madt_local_sapic *processor = NULL;
  234. processor = (struct acpi_madt_local_sapic *)header;
  235. if (BAD_MADT_ENTRY(processor, end))
  236. return -EINVAL;
  237. acpi_table_print_madt_entry(&header->common);
  238. topology_register_apic((processor->id << 8) | processor->eid,/* APIC ID */
  239. processor->processor_id, /* ACPI ID */
  240. processor->lapic_flags & ACPI_MADT_ENABLED);
  241. return 0;
  242. }
  243. static int __init
  244. acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
  245. const unsigned long end)
  246. {
  247. struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
  248. lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
  249. if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
  250. return -EINVAL;
  251. acpi_table_print_madt_entry(&header->common);
  252. acpi_lapic_addr = lapic_addr_ovr->address;
  253. return 0;
  254. }
  255. static int __init
  256. acpi_parse_x2apic_nmi(union acpi_subtable_headers *header,
  257. const unsigned long end)
  258. {
  259. struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
  260. x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header;
  261. if (BAD_MADT_ENTRY(x2apic_nmi, end))
  262. return -EINVAL;
  263. acpi_table_print_madt_entry(&header->common);
  264. if (x2apic_nmi->lint != 1)
  265. pr_warn("NMI not connected to LINT 1!\n");
  266. return 0;
  267. }
  268. static int __init
  269. acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
  270. {
  271. struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
  272. lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
  273. if (BAD_MADT_ENTRY(lapic_nmi, end))
  274. return -EINVAL;
  275. acpi_table_print_madt_entry(&header->common);
  276. if (lapic_nmi->lint != 1)
  277. pr_warn("NMI not connected to LINT 1!\n");
  278. return 0;
  279. }
  280. #endif /* CONFIG_X86_LOCAL_APIC */
  281. #ifdef CONFIG_X86_IO_APIC
  282. #define MP_ISA_BUS 0
  283. static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
  284. u8 trigger, u32 gsi);
  285. static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
  286. u32 gsi)
  287. {
  288. /*
  289. * Check bus_irq boundary.
  290. */
  291. if (bus_irq >= NR_IRQS_LEGACY) {
  292. pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq);
  293. return;
  294. }
  295. /*
  296. * TBD: This check is for faulty timer entries, where the override
  297. * erroneously sets the trigger to level, resulting in a HUGE
  298. * increase of timer interrupts!
  299. */
  300. if ((bus_irq == 0) && (trigger == 3))
  301. trigger = 1;
  302. if (mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi) < 0)
  303. return;
  304. /*
  305. * Reset default identity mapping if gsi is also an legacy IRQ,
  306. * otherwise there will be more than one entry with the same GSI
  307. * and acpi_isa_irq_to_gsi() may give wrong result.
  308. */
  309. if (gsi < nr_legacy_irqs() && isa_irq_to_gsi[gsi] == gsi)
  310. isa_irq_to_gsi[gsi] = INVALID_ACPI_IRQ;
  311. isa_irq_to_gsi[bus_irq] = gsi;
  312. }
  313. static void mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
  314. int polarity)
  315. {
  316. #ifdef CONFIG_X86_MPPARSE
  317. struct mpc_intsrc mp_irq;
  318. struct pci_dev *pdev;
  319. unsigned char number;
  320. unsigned int devfn;
  321. int ioapic;
  322. u8 pin;
  323. if (!acpi_ioapic)
  324. return;
  325. if (!dev || !dev_is_pci(dev))
  326. return;
  327. pdev = to_pci_dev(dev);
  328. number = pdev->bus->number;
  329. devfn = pdev->devfn;
  330. pin = pdev->pin;
  331. /* print the entry should happen on mptable identically */
  332. mp_irq.type = MP_INTSRC;
  333. mp_irq.irqtype = mp_INT;
  334. mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
  335. (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
  336. mp_irq.srcbus = number;
  337. mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
  338. ioapic = mp_find_ioapic(gsi);
  339. mp_irq.dstapic = mpc_ioapic_id(ioapic);
  340. mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
  341. mp_save_irq(&mp_irq);
  342. #endif
  343. }
  344. static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
  345. u8 trigger, u32 gsi)
  346. {
  347. struct mpc_intsrc mp_irq;
  348. int ioapic, pin;
  349. /* Convert 'gsi' to 'ioapic.pin'(INTIN#) */
  350. ioapic = mp_find_ioapic(gsi);
  351. if (ioapic < 0) {
  352. pr_warn("Failed to find ioapic for gsi : %u\n", gsi);
  353. return ioapic;
  354. }
  355. pin = mp_find_ioapic_pin(ioapic, gsi);
  356. mp_irq.type = MP_INTSRC;
  357. mp_irq.irqtype = mp_INT;
  358. mp_irq.irqflag = (trigger << 2) | polarity;
  359. mp_irq.srcbus = MP_ISA_BUS;
  360. mp_irq.srcbusirq = bus_irq;
  361. mp_irq.dstapic = mpc_ioapic_id(ioapic);
  362. mp_irq.dstirq = pin;
  363. mp_save_irq(&mp_irq);
  364. return 0;
  365. }
  366. static int __init
  367. acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end)
  368. {
  369. struct acpi_madt_io_apic *ioapic = NULL;
  370. struct ioapic_domain_cfg cfg = {
  371. .type = IOAPIC_DOMAIN_DYNAMIC,
  372. .ops = &mp_ioapic_irqdomain_ops,
  373. };
  374. ioapic = (struct acpi_madt_io_apic *)header;
  375. if (BAD_MADT_ENTRY(ioapic, end))
  376. return -EINVAL;
  377. acpi_table_print_madt_entry(&header->common);
  378. /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */
  379. if (ioapic->global_irq_base < nr_legacy_irqs())
  380. cfg.type = IOAPIC_DOMAIN_LEGACY;
  381. mp_register_ioapic(ioapic->id, ioapic->address, ioapic->global_irq_base,
  382. &cfg);
  383. return 0;
  384. }
  385. /*
  386. * Parse Interrupt Source Override for the ACPI SCI
  387. */
  388. static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, u32 gsi)
  389. {
  390. if (trigger == 0) /* compatible SCI trigger is level */
  391. trigger = 3;
  392. if (polarity == 0) /* compatible SCI polarity is low */
  393. polarity = 3;
  394. /* Command-line over-ride via acpi_sci= */
  395. if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
  396. trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
  397. if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
  398. polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
  399. if (bus_irq < NR_IRQS_LEGACY)
  400. mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
  401. else
  402. mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi);
  403. acpi_penalize_sci_irq(bus_irq, trigger, polarity);
  404. /*
  405. * stash over-ride to indicate we've been here
  406. * and for later update of acpi_gbl_FADT
  407. */
  408. acpi_sci_override_gsi = gsi;
  409. return;
  410. }
  411. static int __init
  412. acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
  413. const unsigned long end)
  414. {
  415. struct acpi_madt_interrupt_override *intsrc = NULL;
  416. intsrc = (struct acpi_madt_interrupt_override *)header;
  417. if (BAD_MADT_ENTRY(intsrc, end))
  418. return -EINVAL;
  419. acpi_table_print_madt_entry(&header->common);
  420. if (intsrc->source_irq < NR_IRQS_LEGACY)
  421. acpi_int_src_ovr[intsrc->source_irq] = true;
  422. if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
  423. acpi_sci_ioapic_setup(intsrc->source_irq,
  424. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  425. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
  426. intsrc->global_irq);
  427. return 0;
  428. }
  429. if (intsrc->source_irq == 0) {
  430. if (acpi_skip_timer_override) {
  431. pr_warn("BIOS IRQ0 override ignored.\n");
  432. return 0;
  433. }
  434. if ((intsrc->global_irq == 2) && acpi_fix_pin2_polarity
  435. && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) {
  436. intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK;
  437. pr_warn("BIOS IRQ0 pin2 override: forcing polarity to high active.\n");
  438. }
  439. }
  440. mp_override_legacy_irq(intsrc->source_irq,
  441. intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
  442. (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
  443. intsrc->global_irq);
  444. return 0;
  445. }
  446. static int __init
  447. acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
  448. {
  449. struct acpi_madt_nmi_source *nmi_src = NULL;
  450. nmi_src = (struct acpi_madt_nmi_source *)header;
  451. if (BAD_MADT_ENTRY(nmi_src, end))
  452. return -EINVAL;
  453. acpi_table_print_madt_entry(&header->common);
  454. /* TBD: Support nimsrc entries? */
  455. return 0;
  456. }
  457. #endif /* CONFIG_X86_IO_APIC */
  458. /*
  459. * acpi_pic_sci_set_trigger()
  460. *
  461. * use ELCR to set PIC-mode trigger type for SCI
  462. *
  463. * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
  464. * it may require Edge Trigger -- use "acpi_sci=edge"
  465. *
  466. * Port 0x4d0-4d1 are ELCR1 and ELCR2, the Edge/Level Control Registers
  467. * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
  468. * ELCR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
  469. * ELCR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
  470. */
  471. void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
  472. {
  473. unsigned int mask = 1 << irq;
  474. unsigned int old, new;
  475. /* Real old ELCR mask */
  476. old = inb(PIC_ELCR1) | (inb(PIC_ELCR2) << 8);
  477. /*
  478. * If we use ACPI to set PCI IRQs, then we should clear ELCR
  479. * since we will set it correctly as we enable the PCI irq
  480. * routing.
  481. */
  482. new = acpi_noirq ? old : 0;
  483. /*
  484. * Update SCI information in the ELCR, it isn't in the PCI
  485. * routing tables..
  486. */
  487. switch (trigger) {
  488. case 1: /* Edge - clear */
  489. new &= ~mask;
  490. break;
  491. case 3: /* Level - set */
  492. new |= mask;
  493. break;
  494. }
  495. if (old == new)
  496. return;
  497. pr_warn("setting ELCR to %04x (from %04x)\n", new, old);
  498. outb(new, PIC_ELCR1);
  499. outb(new >> 8, PIC_ELCR2);
  500. }
  501. int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
  502. {
  503. int rc, irq, trigger, polarity;
  504. if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  505. *irqp = gsi;
  506. return 0;
  507. }
  508. rc = acpi_get_override_irq(gsi, &trigger, &polarity);
  509. if (rc)
  510. return rc;
  511. trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
  512. polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
  513. irq = acpi_register_gsi(NULL, gsi, trigger, polarity);
  514. if (irq < 0)
  515. return irq;
  516. *irqp = irq;
  517. return 0;
  518. }
  519. EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
  520. int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
  521. {
  522. if (isa_irq < nr_legacy_irqs() &&
  523. isa_irq_to_gsi[isa_irq] != INVALID_ACPI_IRQ) {
  524. *gsi = isa_irq_to_gsi[isa_irq];
  525. return 0;
  526. }
  527. return -1;
  528. }
  529. static int acpi_register_gsi_pic(struct device *dev, u32 gsi,
  530. int trigger, int polarity)
  531. {
  532. #ifdef CONFIG_PCI
  533. /*
  534. * Make sure all (legacy) PCI IRQs are set as level-triggered.
  535. */
  536. if (trigger == ACPI_LEVEL_SENSITIVE)
  537. elcr_set_level_irq(gsi);
  538. #endif
  539. return gsi;
  540. }
  541. #ifdef CONFIG_X86_LOCAL_APIC
  542. static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
  543. int trigger, int polarity)
  544. {
  545. int irq = gsi;
  546. #ifdef CONFIG_X86_IO_APIC
  547. int node;
  548. struct irq_alloc_info info;
  549. node = dev ? dev_to_node(dev) : NUMA_NO_NODE;
  550. trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1;
  551. polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1;
  552. ioapic_set_alloc_attr(&info, node, trigger, polarity);
  553. mutex_lock(&acpi_ioapic_lock);
  554. irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
  555. /* Don't set up the ACPI SCI because it's already set up */
  556. if (irq >= 0 && enable_update_mptable && gsi != acpi_gbl_FADT.sci_interrupt)
  557. mp_config_acpi_gsi(dev, gsi, trigger, polarity);
  558. mutex_unlock(&acpi_ioapic_lock);
  559. #endif
  560. return irq;
  561. }
  562. static void acpi_unregister_gsi_ioapic(u32 gsi)
  563. {
  564. #ifdef CONFIG_X86_IO_APIC
  565. int irq;
  566. mutex_lock(&acpi_ioapic_lock);
  567. irq = mp_map_gsi_to_irq(gsi, 0, NULL);
  568. if (irq > 0)
  569. mp_unmap_irq(irq);
  570. mutex_unlock(&acpi_ioapic_lock);
  571. #endif
  572. }
  573. #endif
  574. int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
  575. int trigger, int polarity) = acpi_register_gsi_pic;
  576. void (*__acpi_unregister_gsi)(u32 gsi) = NULL;
  577. #ifdef CONFIG_ACPI_SLEEP
  578. int (*acpi_suspend_lowlevel)(void) = x86_acpi_suspend_lowlevel;
  579. #else
  580. int (*acpi_suspend_lowlevel)(void);
  581. #endif
  582. /*
  583. * success: return IRQ number (>=0)
  584. * failure: return < 0
  585. */
  586. int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
  587. {
  588. return __acpi_register_gsi(dev, gsi, trigger, polarity);
  589. }
  590. EXPORT_SYMBOL_GPL(acpi_register_gsi);
  591. void acpi_unregister_gsi(u32 gsi)
  592. {
  593. if (__acpi_unregister_gsi)
  594. __acpi_unregister_gsi(gsi);
  595. }
  596. EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
  597. #ifdef CONFIG_X86_LOCAL_APIC
  598. static void __init acpi_set_irq_model_ioapic(void)
  599. {
  600. acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
  601. __acpi_register_gsi = acpi_register_gsi_ioapic;
  602. __acpi_unregister_gsi = acpi_unregister_gsi_ioapic;
  603. acpi_ioapic = 1;
  604. }
  605. #endif
  606. /*
  607. * ACPI based hotplug support for CPU
  608. */
  609. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  610. #include <acpi/processor.h>
  611. static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
  612. {
  613. #ifdef CONFIG_ACPI_NUMA
  614. int nid;
  615. nid = acpi_get_node(handle);
  616. if (nid != NUMA_NO_NODE) {
  617. set_apicid_to_node(physid, nid);
  618. numa_set_node(cpu, nid);
  619. }
  620. #endif
  621. return 0;
  622. }
  623. int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, int *pcpu)
  624. {
  625. int cpu = topology_hotplug_apic(physid, acpi_id);
  626. if (cpu < 0) {
  627. pr_info("Unable to map lapic to logical cpu number\n");
  628. return cpu;
  629. }
  630. acpi_processor_set_pdc(handle);
  631. acpi_map_cpu2node(handle, cpu, physid);
  632. *pcpu = cpu;
  633. return 0;
  634. }
  635. EXPORT_SYMBOL(acpi_map_cpu);
  636. int acpi_unmap_cpu(int cpu)
  637. {
  638. #ifdef CONFIG_ACPI_NUMA
  639. set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE);
  640. #endif
  641. topology_hotunplug_apic(cpu);
  642. return 0;
  643. }
  644. EXPORT_SYMBOL(acpi_unmap_cpu);
  645. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  646. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
  647. {
  648. int ret = -ENOSYS;
  649. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  650. int ioapic_id;
  651. u64 addr;
  652. struct ioapic_domain_cfg cfg = {
  653. .type = IOAPIC_DOMAIN_DYNAMIC,
  654. .ops = &mp_ioapic_irqdomain_ops,
  655. };
  656. ioapic_id = acpi_get_ioapic_id(handle, gsi_base, &addr);
  657. if (ioapic_id < 0) {
  658. unsigned long long uid;
  659. acpi_status status;
  660. status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
  661. NULL, &uid);
  662. if (ACPI_FAILURE(status)) {
  663. acpi_handle_warn(handle, "failed to get IOAPIC ID.\n");
  664. return -EINVAL;
  665. }
  666. ioapic_id = (int)uid;
  667. }
  668. mutex_lock(&acpi_ioapic_lock);
  669. ret = mp_register_ioapic(ioapic_id, phys_addr, gsi_base, &cfg);
  670. mutex_unlock(&acpi_ioapic_lock);
  671. #endif
  672. return ret;
  673. }
  674. EXPORT_SYMBOL(acpi_register_ioapic);
  675. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
  676. {
  677. int ret = -ENOSYS;
  678. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  679. mutex_lock(&acpi_ioapic_lock);
  680. ret = mp_unregister_ioapic(gsi_base);
  681. mutex_unlock(&acpi_ioapic_lock);
  682. #endif
  683. return ret;
  684. }
  685. EXPORT_SYMBOL(acpi_unregister_ioapic);
  686. /**
  687. * acpi_ioapic_registered - Check whether IOAPIC associated with @gsi_base
  688. * has been registered
  689. * @handle: ACPI handle of the IOAPIC device
  690. * @gsi_base: GSI base associated with the IOAPIC
  691. *
  692. * Assume caller holds some type of lock to serialize acpi_ioapic_registered()
  693. * with acpi_register_ioapic()/acpi_unregister_ioapic().
  694. */
  695. int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base)
  696. {
  697. int ret = 0;
  698. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  699. mutex_lock(&acpi_ioapic_lock);
  700. ret = mp_ioapic_registered(gsi_base);
  701. mutex_unlock(&acpi_ioapic_lock);
  702. #endif
  703. return ret;
  704. }
  705. static int __init acpi_parse_sbf(struct acpi_table_header *table)
  706. {
  707. struct acpi_table_boot *sb = (struct acpi_table_boot *)table;
  708. sbf_port = sb->cmos_index; /* Save CMOS port */
  709. return 0;
  710. }
  711. #ifdef CONFIG_HPET_TIMER
  712. #include <asm/hpet.h>
  713. static struct resource *hpet_res __initdata;
  714. static int __init acpi_parse_hpet(struct acpi_table_header *table)
  715. {
  716. struct acpi_table_hpet *hpet_tbl = (struct acpi_table_hpet *)table;
  717. if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
  718. pr_warn("HPET timers must be located in memory.\n");
  719. return -1;
  720. }
  721. hpet_address = hpet_tbl->address.address;
  722. hpet_blockid = hpet_tbl->sequence;
  723. /*
  724. * Some broken BIOSes advertise HPET at 0x0. We really do not
  725. * want to allocate a resource there.
  726. */
  727. if (!hpet_address) {
  728. pr_warn("HPET id: %#x base: %#lx is invalid\n", hpet_tbl->id, hpet_address);
  729. return 0;
  730. }
  731. #ifdef CONFIG_X86_64
  732. /*
  733. * Some even more broken BIOSes advertise HPET at
  734. * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
  735. * some noise:
  736. */
  737. if (hpet_address == 0xfed0000000000000UL) {
  738. if (!hpet_force_user) {
  739. pr_warn("HPET id: %#x base: 0xfed0000000000000 is bogus, try hpet=force on the kernel command line to fix it up to 0xfed00000.\n",
  740. hpet_tbl->id);
  741. hpet_address = 0;
  742. return 0;
  743. }
  744. pr_warn("HPET id: %#x base: 0xfed0000000000000 fixed up to 0xfed00000.\n",
  745. hpet_tbl->id);
  746. hpet_address >>= 32;
  747. }
  748. #endif
  749. pr_info("HPET id: %#x base: %#lx\n", hpet_tbl->id, hpet_address);
  750. /*
  751. * Allocate and initialize the HPET firmware resource for adding into
  752. * the resource tree during the lateinit timeframe.
  753. */
  754. #define HPET_RESOURCE_NAME_SIZE 9
  755. hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE,
  756. SMP_CACHE_BYTES);
  757. if (!hpet_res)
  758. panic("%s: Failed to allocate %zu bytes\n", __func__,
  759. sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
  760. hpet_res->name = (void *)&hpet_res[1];
  761. hpet_res->flags = IORESOURCE_MEM;
  762. snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
  763. hpet_tbl->sequence);
  764. hpet_res->start = hpet_address;
  765. hpet_res->end = hpet_address + (1 * 1024) - 1;
  766. return 0;
  767. }
  768. /*
  769. * hpet_insert_resource inserts the HPET resources used into the resource
  770. * tree.
  771. */
  772. static __init int hpet_insert_resource(void)
  773. {
  774. if (!hpet_res)
  775. return 1;
  776. return insert_resource(&iomem_resource, hpet_res);
  777. }
  778. late_initcall(hpet_insert_resource);
  779. #else
  780. #define acpi_parse_hpet NULL
  781. #endif
  782. static int __init acpi_parse_fadt(struct acpi_table_header *table)
  783. {
  784. if (!(acpi_gbl_FADT.boot_flags & ACPI_FADT_LEGACY_DEVICES)) {
  785. pr_debug("no legacy devices present\n");
  786. x86_platform.legacy.devices.pnpbios = 0;
  787. }
  788. if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
  789. !(acpi_gbl_FADT.boot_flags & ACPI_FADT_8042) &&
  790. x86_platform.legacy.i8042 != X86_LEGACY_I8042_PLATFORM_ABSENT) {
  791. pr_debug("i8042 controller is absent\n");
  792. x86_platform.legacy.i8042 = X86_LEGACY_I8042_FIRMWARE_ABSENT;
  793. }
  794. if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
  795. pr_debug("not registering RTC platform device\n");
  796. x86_platform.legacy.rtc = 0;
  797. }
  798. if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_VGA) {
  799. pr_debug("probing for VGA not safe\n");
  800. x86_platform.legacy.no_vga = 1;
  801. }
  802. #ifdef CONFIG_X86_PM_TIMER
  803. /* detect the location of the ACPI PM Timer */
  804. if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
  805. /* FADT rev. 2 */
  806. if (acpi_gbl_FADT.xpm_timer_block.space_id !=
  807. ACPI_ADR_SPACE_SYSTEM_IO)
  808. return 0;
  809. pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
  810. /*
  811. * "X" fields are optional extensions to the original V1.0
  812. * fields, so we must selectively expand V1.0 fields if the
  813. * corresponding X field is zero.
  814. */
  815. if (!pmtmr_ioport)
  816. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  817. } else {
  818. /* FADT rev. 1 */
  819. pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
  820. }
  821. if (pmtmr_ioport)
  822. pr_info("PM-Timer IO Port: %#x\n", pmtmr_ioport);
  823. #endif
  824. return 0;
  825. }
  826. #ifdef CONFIG_X86_LOCAL_APIC
  827. /*
  828. * Parse LAPIC entries in MADT
  829. * returns 0 on success, < 0 on error
  830. */
  831. static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
  832. {
  833. int count;
  834. if (!boot_cpu_has(X86_FEATURE_APIC))
  835. return -ENODEV;
  836. /*
  837. * Note that the LAPIC address is obtained from the MADT (32-bit value)
  838. * and (optionally) overridden by a LAPIC_ADDR_OVR entry (64-bit value).
  839. */
  840. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
  841. acpi_parse_lapic_addr_ovr, 0);
  842. if (count < 0) {
  843. pr_err("Error parsing LAPIC address override entry\n");
  844. return count;
  845. }
  846. register_lapic_address(acpi_lapic_addr);
  847. return count;
  848. }
  849. static int __init acpi_parse_madt_lapic_entries(void)
  850. {
  851. int count, x2count = 0;
  852. struct acpi_subtable_proc madt_proc[2];
  853. int ret;
  854. if (!boot_cpu_has(X86_FEATURE_APIC))
  855. return -ENODEV;
  856. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
  857. acpi_parse_sapic, MAX_LOCAL_APIC);
  858. if (!count) {
  859. /* Check if there are valid LAPIC entries */
  860. acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, acpi_check_lapic, MAX_LOCAL_APIC);
  861. /*
  862. * Enumerate the APIC IDs in the order that they appear in the
  863. * MADT, no matter LAPIC entry or x2APIC entry is used.
  864. */
  865. memset(madt_proc, 0, sizeof(madt_proc));
  866. madt_proc[0].id = ACPI_MADT_TYPE_LOCAL_APIC;
  867. madt_proc[0].handler = acpi_parse_lapic;
  868. madt_proc[1].id = ACPI_MADT_TYPE_LOCAL_X2APIC;
  869. madt_proc[1].handler = acpi_parse_x2apic;
  870. ret = acpi_table_parse_entries_array(ACPI_SIG_MADT,
  871. sizeof(struct acpi_table_madt),
  872. madt_proc, ARRAY_SIZE(madt_proc), MAX_LOCAL_APIC);
  873. if (ret < 0) {
  874. pr_err("Error parsing LAPIC/X2APIC entries\n");
  875. return ret;
  876. }
  877. count = madt_proc[0].count;
  878. x2count = madt_proc[1].count;
  879. }
  880. if (!count && !x2count) {
  881. pr_err("No LAPIC entries present\n");
  882. /* TBD: Cleanup to allow fallback to MPS */
  883. return -ENODEV;
  884. } else if (count < 0 || x2count < 0) {
  885. pr_err("Error parsing LAPIC entry\n");
  886. /* TBD: Cleanup to allow fallback to MPS */
  887. return count;
  888. }
  889. x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI,
  890. acpi_parse_x2apic_nmi, 0);
  891. count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI,
  892. acpi_parse_lapic_nmi, 0);
  893. if (count < 0 || x2count < 0) {
  894. pr_err("Error parsing LAPIC NMI entry\n");
  895. /* TBD: Cleanup to allow fallback to MPS */
  896. return count;
  897. }
  898. return 0;
  899. }
  900. #endif /* CONFIG_X86_LOCAL_APIC */
  901. #ifdef CONFIG_X86_IO_APIC
  902. static void __init mp_config_acpi_legacy_irqs(void)
  903. {
  904. int i;
  905. struct mpc_intsrc mp_irq;
  906. #ifdef CONFIG_EISA
  907. /*
  908. * Fabricate the legacy ISA bus (bus #31).
  909. */
  910. mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
  911. #endif
  912. set_bit(MP_ISA_BUS, mp_bus_not_pci);
  913. pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS, nr_legacy_irqs());
  914. /*
  915. * Use the default configuration for the IRQs 0-15. Unless
  916. * overridden by (MADT) interrupt source override entries.
  917. */
  918. for (i = 0; i < nr_legacy_irqs(); i++) {
  919. int ioapic, pin;
  920. unsigned int dstapic;
  921. int idx;
  922. u32 gsi;
  923. /* Locate the gsi that irq i maps to. */
  924. if (acpi_isa_irq_to_gsi(i, &gsi))
  925. continue;
  926. /*
  927. * Locate the IOAPIC that manages the ISA IRQ.
  928. */
  929. ioapic = mp_find_ioapic(gsi);
  930. if (ioapic < 0)
  931. continue;
  932. pin = mp_find_ioapic_pin(ioapic, gsi);
  933. dstapic = mpc_ioapic_id(ioapic);
  934. for (idx = 0; idx < mp_irq_entries; idx++) {
  935. struct mpc_intsrc *irq = mp_irqs + idx;
  936. /* Do we already have a mapping for this ISA IRQ? */
  937. if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
  938. break;
  939. /* Do we already have a mapping for this IOAPIC pin */
  940. if (irq->dstapic == dstapic && irq->dstirq == pin)
  941. break;
  942. }
  943. if (idx != mp_irq_entries) {
  944. pr_debug("ACPI: IRQ%d used by override.\n", i);
  945. continue; /* IRQ already used */
  946. }
  947. mp_irq.type = MP_INTSRC;
  948. mp_irq.irqflag = 0; /* Conforming */
  949. mp_irq.srcbus = MP_ISA_BUS;
  950. mp_irq.dstapic = dstapic;
  951. mp_irq.irqtype = mp_INT;
  952. mp_irq.srcbusirq = i; /* Identity mapped */
  953. mp_irq.dstirq = pin;
  954. mp_save_irq(&mp_irq);
  955. }
  956. }
  957. /*
  958. * Parse IOAPIC related entries in MADT
  959. * returns 0 on success, < 0 on error
  960. */
  961. static int __init acpi_parse_madt_ioapic_entries(void)
  962. {
  963. int count;
  964. /*
  965. * ACPI interpreter is required to complete interrupt setup,
  966. * so if it is off, don't enumerate the io-apics with ACPI.
  967. * If MPS is present, it will handle them,
  968. * otherwise the system will stay in PIC mode
  969. */
  970. if (acpi_disabled || acpi_noirq)
  971. return -ENODEV;
  972. if (!boot_cpu_has(X86_FEATURE_APIC))
  973. return -ENODEV;
  974. /*
  975. * if "noapic" boot option, don't look for IO-APICs
  976. */
  977. if (ioapic_is_disabled) {
  978. pr_info("Skipping IOAPIC probe due to 'noapic' option.\n");
  979. return -ENODEV;
  980. }
  981. count = acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
  982. MAX_IO_APICS);
  983. if (!count) {
  984. pr_err("No IOAPIC entries present\n");
  985. return -ENODEV;
  986. } else if (count < 0) {
  987. pr_err("Error parsing IOAPIC entry\n");
  988. return count;
  989. }
  990. count = acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE,
  991. acpi_parse_int_src_ovr, nr_irqs);
  992. if (count < 0) {
  993. pr_err("Error parsing interrupt source overrides entry\n");
  994. /* TBD: Cleanup to allow fallback to MPS */
  995. return count;
  996. }
  997. /*
  998. * If BIOS did not supply an INT_SRC_OVR for the SCI
  999. * pretend we got one so we can set the SCI flags.
  1000. * But ignore setting up SCI on hardware reduced platforms.
  1001. */
  1002. if (acpi_sci_override_gsi == INVALID_ACPI_IRQ && !acpi_gbl_reduced_hardware)
  1003. acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0,
  1004. acpi_gbl_FADT.sci_interrupt);
  1005. /* Fill in identity legacy mappings where no override */
  1006. mp_config_acpi_legacy_irqs();
  1007. count = acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE,
  1008. acpi_parse_nmi_src, nr_irqs);
  1009. if (count < 0) {
  1010. pr_err("Error parsing NMI SRC entry\n");
  1011. /* TBD: Cleanup to allow fallback to MPS */
  1012. return count;
  1013. }
  1014. return 0;
  1015. }
  1016. #else
  1017. static inline int acpi_parse_madt_ioapic_entries(void)
  1018. {
  1019. return -1;
  1020. }
  1021. #endif /* !CONFIG_X86_IO_APIC */
  1022. static void __init early_acpi_process_madt(void)
  1023. {
  1024. #ifdef CONFIG_X86_LOCAL_APIC
  1025. int error;
  1026. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  1027. /*
  1028. * Parse MADT LAPIC entries
  1029. */
  1030. error = early_acpi_parse_madt_lapic_addr_ovr();
  1031. if (!error) {
  1032. acpi_lapic = 1;
  1033. smp_found_config = 1;
  1034. }
  1035. if (error == -EINVAL) {
  1036. /*
  1037. * Dell Precision Workstation 410, 610 come here.
  1038. */
  1039. pr_err("Invalid BIOS MADT, disabling ACPI\n");
  1040. disable_acpi();
  1041. }
  1042. }
  1043. #endif
  1044. }
  1045. static void __init acpi_process_madt(void)
  1046. {
  1047. #ifdef CONFIG_X86_LOCAL_APIC
  1048. int error;
  1049. if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
  1050. /*
  1051. * Parse MADT LAPIC entries
  1052. */
  1053. error = acpi_parse_madt_lapic_entries();
  1054. if (!error) {
  1055. acpi_lapic = 1;
  1056. /*
  1057. * Parse MADT IO-APIC entries
  1058. */
  1059. mutex_lock(&acpi_ioapic_lock);
  1060. error = acpi_parse_madt_ioapic_entries();
  1061. mutex_unlock(&acpi_ioapic_lock);
  1062. if (!error) {
  1063. acpi_set_irq_model_ioapic();
  1064. smp_found_config = 1;
  1065. }
  1066. #ifdef CONFIG_ACPI_MADT_WAKEUP
  1067. /*
  1068. * Parse MADT MP Wake entry.
  1069. */
  1070. acpi_table_parse_madt(ACPI_MADT_TYPE_MULTIPROC_WAKEUP,
  1071. acpi_parse_mp_wake, 1);
  1072. #endif
  1073. }
  1074. if (error == -EINVAL) {
  1075. /*
  1076. * Dell Precision Workstation 410, 610 come here.
  1077. */
  1078. pr_err("Invalid BIOS MADT, disabling ACPI\n");
  1079. disable_acpi();
  1080. }
  1081. } else {
  1082. /*
  1083. * ACPI found no MADT, and so ACPI wants UP PIC mode.
  1084. * In the event an MPS table was found, forget it.
  1085. * Boot with "acpi=off" to use MPS on such a system.
  1086. */
  1087. if (smp_found_config) {
  1088. pr_warn("No APIC-table, disabling MPS\n");
  1089. smp_found_config = 0;
  1090. }
  1091. }
  1092. /*
  1093. * ACPI supports both logical (e.g. Hyper-Threading) and physical
  1094. * processors, where MPS only supports physical.
  1095. */
  1096. if (acpi_lapic && acpi_ioapic)
  1097. pr_info("Using ACPI (MADT) for SMP configuration information\n");
  1098. else if (acpi_lapic)
  1099. pr_info("Using ACPI for processor (LAPIC) configuration information\n");
  1100. #endif
  1101. return;
  1102. }
  1103. static int __init disable_acpi_irq(const struct dmi_system_id *d)
  1104. {
  1105. if (!acpi_force) {
  1106. pr_notice("%s detected: force use of acpi=noirq\n", d->ident);
  1107. acpi_noirq_set();
  1108. }
  1109. return 0;
  1110. }
  1111. static int __init disable_acpi_pci(const struct dmi_system_id *d)
  1112. {
  1113. if (!acpi_force) {
  1114. pr_notice("%s detected: force use of pci=noacpi\n", d->ident);
  1115. acpi_disable_pci();
  1116. }
  1117. return 0;
  1118. }
  1119. static int __init disable_acpi_xsdt(const struct dmi_system_id *d)
  1120. {
  1121. if (!acpi_force) {
  1122. pr_notice("%s detected: force use of acpi=rsdt\n", d->ident);
  1123. acpi_gbl_do_not_use_xsdt = TRUE;
  1124. } else {
  1125. pr_notice("Warning: DMI blacklist says broken, but acpi XSDT forced\n");
  1126. }
  1127. return 0;
  1128. }
  1129. static int __init dmi_disable_acpi(const struct dmi_system_id *d)
  1130. {
  1131. if (!acpi_force) {
  1132. pr_notice("%s detected: acpi off\n", d->ident);
  1133. disable_acpi();
  1134. } else {
  1135. pr_notice("Warning: DMI blacklist says broken, but acpi forced\n");
  1136. }
  1137. return 0;
  1138. }
  1139. /*
  1140. * Force ignoring BIOS IRQ0 override
  1141. */
  1142. static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
  1143. {
  1144. if (!acpi_skip_timer_override) {
  1145. pr_notice("%s detected: Ignoring BIOS IRQ0 override\n",
  1146. d->ident);
  1147. acpi_skip_timer_override = 1;
  1148. }
  1149. return 0;
  1150. }
  1151. /*
  1152. * ACPI offers an alternative platform interface model that removes
  1153. * ACPI hardware requirements for platforms that do not implement
  1154. * the PC Architecture.
  1155. *
  1156. * We initialize the Hardware-reduced ACPI model here:
  1157. */
  1158. void __init acpi_generic_reduced_hw_init(void)
  1159. {
  1160. /*
  1161. * Override x86_init functions and bypass legacy PIC in
  1162. * hardware reduced ACPI mode.
  1163. */
  1164. x86_init.timers.timer_init = x86_init_noop;
  1165. x86_init.irqs.pre_vector_init = x86_init_noop;
  1166. legacy_pic = &null_legacy_pic;
  1167. }
  1168. static void __init acpi_reduced_hw_init(void)
  1169. {
  1170. if (acpi_gbl_reduced_hardware)
  1171. x86_init.acpi.reduced_hw_early_init();
  1172. }
  1173. /*
  1174. * If your system is blacklisted here, but you find that acpi=force
  1175. * works for you, please contact linux-acpi@vger.kernel.org
  1176. */
  1177. static const struct dmi_system_id acpi_dmi_table[] __initconst = {
  1178. /*
  1179. * Boxes that need ACPI disabled
  1180. */
  1181. {
  1182. .callback = dmi_disable_acpi,
  1183. .ident = "IBM Thinkpad",
  1184. .matches = {
  1185. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1186. DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
  1187. },
  1188. },
  1189. /*
  1190. * Boxes that need ACPI PCI IRQ routing disabled
  1191. */
  1192. {
  1193. .callback = disable_acpi_irq,
  1194. .ident = "ASUS A7V",
  1195. .matches = {
  1196. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
  1197. DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
  1198. /* newer BIOS, Revision 1011, does work */
  1199. DMI_MATCH(DMI_BIOS_VERSION,
  1200. "ASUS A7V ACPI BIOS Revision 1007"),
  1201. },
  1202. },
  1203. {
  1204. /*
  1205. * Latest BIOS for IBM 600E (1.16) has bad pcinum
  1206. * for LPC bridge, which is needed for the PCI
  1207. * interrupt links to work. DSDT fix is in bug 5966.
  1208. * 2645, 2646 model numbers are shared with 600/600E/600X
  1209. */
  1210. .callback = disable_acpi_irq,
  1211. .ident = "IBM Thinkpad 600 Series 2645",
  1212. .matches = {
  1213. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1214. DMI_MATCH(DMI_BOARD_NAME, "2645"),
  1215. },
  1216. },
  1217. {
  1218. .callback = disable_acpi_irq,
  1219. .ident = "IBM Thinkpad 600 Series 2646",
  1220. .matches = {
  1221. DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
  1222. DMI_MATCH(DMI_BOARD_NAME, "2646"),
  1223. },
  1224. },
  1225. /*
  1226. * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
  1227. */
  1228. { /* _BBN 0 bug */
  1229. .callback = disable_acpi_pci,
  1230. .ident = "ASUS PR-DLS",
  1231. .matches = {
  1232. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  1233. DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
  1234. DMI_MATCH(DMI_BIOS_VERSION,
  1235. "ASUS PR-DLS ACPI BIOS Revision 1010"),
  1236. DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
  1237. },
  1238. },
  1239. {
  1240. .callback = disable_acpi_pci,
  1241. .ident = "Acer TravelMate 36x Laptop",
  1242. .matches = {
  1243. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  1244. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  1245. },
  1246. },
  1247. /*
  1248. * Boxes that need ACPI XSDT use disabled due to corrupted tables
  1249. */
  1250. {
  1251. .callback = disable_acpi_xsdt,
  1252. .ident = "Advantech DAC-BJ01",
  1253. .matches = {
  1254. DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
  1255. DMI_MATCH(DMI_PRODUCT_NAME, "Bearlake CRB Board"),
  1256. DMI_MATCH(DMI_BIOS_VERSION, "V1.12"),
  1257. DMI_MATCH(DMI_BIOS_DATE, "02/01/2011"),
  1258. },
  1259. },
  1260. {}
  1261. };
  1262. /* second table for DMI checks that should run after early-quirks */
  1263. static const struct dmi_system_id acpi_dmi_table_late[] __initconst = {
  1264. /*
  1265. * HP laptops which use a DSDT reporting as HP/SB400/10000,
  1266. * which includes some code which overrides all temperature
  1267. * trip points to 16C if the INTIN2 input of the I/O APIC
  1268. * is enabled. This input is incorrectly designated the
  1269. * ISA IRQ 0 via an interrupt source override even though
  1270. * it is wired to the output of the master 8259A and INTIN0
  1271. * is not connected at all. Force ignoring BIOS IRQ0
  1272. * override in that cases.
  1273. */
  1274. {
  1275. .callback = dmi_ignore_irq0_timer_override,
  1276. .ident = "HP nx6115 laptop",
  1277. .matches = {
  1278. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1279. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
  1280. },
  1281. },
  1282. {
  1283. .callback = dmi_ignore_irq0_timer_override,
  1284. .ident = "HP NX6125 laptop",
  1285. .matches = {
  1286. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1287. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
  1288. },
  1289. },
  1290. {
  1291. .callback = dmi_ignore_irq0_timer_override,
  1292. .ident = "HP NX6325 laptop",
  1293. .matches = {
  1294. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1295. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
  1296. },
  1297. },
  1298. {
  1299. .callback = dmi_ignore_irq0_timer_override,
  1300. .ident = "HP 6715b laptop",
  1301. .matches = {
  1302. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1303. DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
  1304. },
  1305. },
  1306. {
  1307. .callback = dmi_ignore_irq0_timer_override,
  1308. .ident = "FUJITSU SIEMENS",
  1309. .matches = {
  1310. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  1311. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
  1312. },
  1313. },
  1314. {}
  1315. };
  1316. /*
  1317. * acpi_boot_table_init() and acpi_boot_init()
  1318. * called from setup_arch(), always.
  1319. * 1. checksums all tables
  1320. * 2. enumerates lapics
  1321. * 3. enumerates io-apics
  1322. *
  1323. * acpi_table_init() is separate to allow reading SRAT without
  1324. * other side effects.
  1325. *
  1326. * side effects of acpi_boot_init:
  1327. * acpi_lapic = 1 if LAPIC found
  1328. * acpi_ioapic = 1 if IOAPIC found
  1329. * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
  1330. * if acpi_blacklisted() acpi_disabled = 1;
  1331. * acpi_irq_model=...
  1332. * ...
  1333. */
  1334. void __init acpi_boot_table_init(void)
  1335. {
  1336. dmi_check_system(acpi_dmi_table);
  1337. /*
  1338. * If acpi_disabled, bail out
  1339. */
  1340. if (acpi_disabled)
  1341. return;
  1342. /*
  1343. * Initialize the ACPI boot-time table parser.
  1344. */
  1345. if (acpi_locate_initial_tables())
  1346. disable_acpi();
  1347. else
  1348. acpi_reserve_initial_tables();
  1349. }
  1350. int __init early_acpi_boot_init(void)
  1351. {
  1352. if (acpi_disabled)
  1353. return 1;
  1354. acpi_table_init_complete();
  1355. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1356. /*
  1357. * blacklist may disable ACPI entirely
  1358. */
  1359. if (acpi_blacklisted()) {
  1360. if (acpi_force) {
  1361. pr_warn("acpi=force override\n");
  1362. } else {
  1363. pr_warn("Disabling ACPI support\n");
  1364. disable_acpi();
  1365. return 1;
  1366. }
  1367. }
  1368. /*
  1369. * Process the Multiple APIC Description Table (MADT), if present
  1370. */
  1371. early_acpi_process_madt();
  1372. /*
  1373. * Hardware-reduced ACPI mode initialization:
  1374. */
  1375. acpi_reduced_hw_init();
  1376. return 0;
  1377. }
  1378. int __init acpi_boot_init(void)
  1379. {
  1380. /* those are executed after early-quirks are executed */
  1381. dmi_check_system(acpi_dmi_table_late);
  1382. /*
  1383. * If acpi_disabled, bail out
  1384. */
  1385. if (acpi_disabled)
  1386. return 1;
  1387. acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  1388. /*
  1389. * set sci_int and PM timer address
  1390. */
  1391. acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
  1392. /*
  1393. * Process the Multiple APIC Description Table (MADT), if present
  1394. */
  1395. acpi_process_madt();
  1396. acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
  1397. if (IS_ENABLED(CONFIG_ACPI_BGRT) && !acpi_nobgrt)
  1398. acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
  1399. if (!acpi_noirq)
  1400. x86_init.pci.init = pci_acpi_init;
  1401. /* Do not enable ACPI SPCR console by default */
  1402. acpi_parse_spcr(earlycon_acpi_spcr_enable, false);
  1403. return 0;
  1404. }
  1405. static int __init parse_acpi(char *arg)
  1406. {
  1407. if (!arg)
  1408. return -EINVAL;
  1409. /* "acpi=off" disables both ACPI table parsing and interpreter */
  1410. if (strcmp(arg, "off") == 0) {
  1411. disable_acpi();
  1412. }
  1413. /* acpi=force to over-ride black-list */
  1414. else if (strcmp(arg, "force") == 0) {
  1415. acpi_force = 1;
  1416. acpi_disabled = 0;
  1417. }
  1418. /* acpi=strict disables out-of-spec workarounds */
  1419. else if (strcmp(arg, "strict") == 0) {
  1420. acpi_strict = 1;
  1421. }
  1422. /* acpi=rsdt use RSDT instead of XSDT */
  1423. else if (strcmp(arg, "rsdt") == 0) {
  1424. acpi_gbl_do_not_use_xsdt = TRUE;
  1425. }
  1426. /* "acpi=noirq" disables ACPI interrupt routing */
  1427. else if (strcmp(arg, "noirq") == 0) {
  1428. acpi_noirq_set();
  1429. }
  1430. /* "acpi=copy_dsdt" copies DSDT */
  1431. else if (strcmp(arg, "copy_dsdt") == 0) {
  1432. acpi_gbl_copy_dsdt_locally = 1;
  1433. }
  1434. /* "acpi=nocmcff" disables FF mode for corrected errors */
  1435. else if (strcmp(arg, "nocmcff") == 0) {
  1436. acpi_disable_cmcff = 1;
  1437. } else {
  1438. /* Core will printk when we return error. */
  1439. return -EINVAL;
  1440. }
  1441. return 0;
  1442. }
  1443. early_param("acpi", parse_acpi);
  1444. static int __init parse_acpi_bgrt(char *arg)
  1445. {
  1446. acpi_nobgrt = true;
  1447. return 0;
  1448. }
  1449. early_param("bgrt_disable", parse_acpi_bgrt);
  1450. /* FIXME: Using pci= for an ACPI parameter is a travesty. */
  1451. static int __init parse_pci(char *arg)
  1452. {
  1453. if (arg && strcmp(arg, "noacpi") == 0)
  1454. acpi_disable_pci();
  1455. return 0;
  1456. }
  1457. early_param("pci", parse_pci);
  1458. int __init acpi_mps_check(void)
  1459. {
  1460. #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
  1461. /* mptable code is not built-in*/
  1462. /*
  1463. * Xen disables ACPI in PV DomU guests but it still emulates APIC and
  1464. * supports SMP. Returning early here ensures that APIC is not disabled
  1465. * unnecessarily and the guest is not limited to a single vCPU.
  1466. */
  1467. if (xen_pv_domain() && !xen_initial_domain())
  1468. return 0;
  1469. if (acpi_disabled || acpi_noirq) {
  1470. pr_warn("MPS support code is not built-in, using acpi=off or acpi=noirq or pci=noacpi may have problem\n");
  1471. return 1;
  1472. }
  1473. #endif
  1474. return 0;
  1475. }
  1476. #ifdef CONFIG_X86_IO_APIC
  1477. static int __init parse_acpi_skip_timer_override(char *arg)
  1478. {
  1479. acpi_skip_timer_override = 1;
  1480. return 0;
  1481. }
  1482. early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
  1483. static int __init parse_acpi_use_timer_override(char *arg)
  1484. {
  1485. acpi_use_timer_override = 1;
  1486. return 0;
  1487. }
  1488. early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
  1489. #endif /* CONFIG_X86_IO_APIC */
  1490. static int __init setup_acpi_sci(char *s)
  1491. {
  1492. if (!s)
  1493. return -EINVAL;
  1494. if (!strcmp(s, "edge"))
  1495. acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
  1496. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1497. else if (!strcmp(s, "level"))
  1498. acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
  1499. (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
  1500. else if (!strcmp(s, "high"))
  1501. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
  1502. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1503. else if (!strcmp(s, "low"))
  1504. acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
  1505. (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
  1506. else
  1507. return -EINVAL;
  1508. return 0;
  1509. }
  1510. early_param("acpi_sci", setup_acpi_sci);
  1511. int __acpi_acquire_global_lock(unsigned int *lock)
  1512. {
  1513. unsigned int old, new, val;
  1514. old = READ_ONCE(*lock);
  1515. do {
  1516. val = (old >> 1) & 0x1;
  1517. new = (old & ~0x3) + 2 + val;
  1518. } while (!try_cmpxchg(lock, &old, new));
  1519. if (val)
  1520. return 0;
  1521. return -1;
  1522. }
  1523. int __acpi_release_global_lock(unsigned int *lock)
  1524. {
  1525. unsigned int old, new;
  1526. old = READ_ONCE(*lock);
  1527. do {
  1528. new = old & ~0x3;
  1529. } while (!try_cmpxchg(lock, &old, new));
  1530. return old & 0x1;
  1531. }
  1532. void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
  1533. {
  1534. e820__range_add(addr, size, E820_TYPE_NVS);
  1535. e820__update_table_print();
  1536. }
  1537. void x86_default_set_root_pointer(u64 addr)
  1538. {
  1539. boot_params.acpi_rsdp_addr = addr;
  1540. }
  1541. u64 x86_default_get_root_pointer(void)
  1542. {
  1543. return boot_params.acpi_rsdp_addr;
  1544. }
  1545. #ifdef CONFIG_XEN_PV
  1546. void __iomem *x86_acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
  1547. {
  1548. return ioremap_cache(phys, size);
  1549. }
  1550. void __iomem * (*acpi_os_ioremap)(acpi_physical_address phys, acpi_size size) =
  1551. x86_acpi_os_ioremap;
  1552. EXPORT_SYMBOL_GPL(acpi_os_ioremap);
  1553. #endif