ia64/xen-unstable

view xen/arch/x86/x86_64/acpi_mmcfg.c @ 19697:42fe00c6f8b4

Enable pci mmcfg and ATS for x86_64

This patch enables PCI MMCONFIG in xen and turns on hooks for ATS.

Signed-off-by: Allen Kay <allen.m.kay@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 02 11:49:34 2009 +0100 (2009-06-02)
parents
children
line source
1 /*
2 * acpi_mmconfig.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 * copied from Linux
26 */
28 #include <xen/config.h>
29 #include <xen/errno.h>
30 #include <xen/init.h>
31 #include <xen/acpi.h>
32 #include <xen/irq.h>
33 #include <xen/dmi.h>
34 #include <asm/fixmap.h>
35 #include <asm/page.h>
36 #include <asm/apic.h>
37 #include <asm/io_apic.h>
38 #include <asm/apic.h>
39 #include <asm/io.h>
40 #include <asm/mpspec.h>
41 #include <asm/processor.h>
42 #include <mach_apic.h>
43 #include <mach_mpparse.h>
45 #include "mmconfig.h"
47 /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
48 struct acpi_mcfg_allocation *pci_mmcfg_config;
49 int pci_mmcfg_config_num;
51 static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
53 int acpi_parse_mcfg(struct acpi_table_header *header)
54 {
55 struct acpi_table_mcfg *mcfg;
56 unsigned long i;
57 int config_size;
59 if (!header)
60 return -EINVAL;
62 mcfg = (struct acpi_table_mcfg *)header;
64 /* how many config structures do we have */
65 pci_mmcfg_config_num = 0;
66 i = header->length - sizeof(struct acpi_table_mcfg);
67 while (i >= sizeof(struct acpi_mcfg_allocation)) {
68 ++pci_mmcfg_config_num;
69 i -= sizeof(struct acpi_mcfg_allocation);
70 };
71 if (pci_mmcfg_config_num == 0) {
72 printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
73 return -ENODEV;
74 }
76 config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
77 pci_mmcfg_config = xmalloc_bytes(config_size);
78 if (!pci_mmcfg_config) {
79 printk(KERN_WARNING PREFIX
80 "No memory for MCFG config tables\n");
81 return -ENOMEM;
82 }
84 memcpy(pci_mmcfg_config, &mcfg[1], config_size);
86 for (i = 0; i < pci_mmcfg_config_num; ++i) {
87 if ((pci_mmcfg_config[i].address > 0xFFFFFFFF) &&
88 !acpi_mcfg_64bit_base_addr) {
89 printk(KERN_ERR PREFIX
90 "MMCONFIG not in low 4GB of memory\n");
91 xfree(pci_mmcfg_config);
92 pci_mmcfg_config_num = 0;
93 return -ENODEV;
94 }
95 }
97 return 0;
98 }