ia64/xen-unstable

view xen/arch/ia64/xen/dom_fw_domu.c @ 19848:5839491bbf20

[IA64] replace MAX_VCPUS with d->max_vcpus where necessary.

don't use MAX_VCPUS, and use vcpu::max_vcpus.
The changeset of 2f9e1348aa98 introduced max_vcpus to allow more vcpus
per guest. This patch is ia64 counter part.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 11:26:05 2009 +0900 (2009-06-29)
parents 615ee2933137
children
line source
1 /******************************************************************************
2 *
3 * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp>
4 * VA Linux Systems Japan K.K.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21 /*
22 * Xen domain firmware emulation support
23 * Copyright (C) 2004 Hewlett-Packard Co.
24 * Dan Magenheimer (dan.magenheimer@hp.com)
25 */
27 #ifdef __XEN__
28 #include <xen/sched.h>
29 #include <asm/dom_fw_utils.h>
30 #include <linux/sort.h>
31 #define xen_ia64_dom_fw_map(d, mpaddr) domain_mpa_to_imva((d), (mpaddr))
32 #define xen_ia64_dom_fw_unmap(d, vaddr) do { } while (0)
33 #else
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <assert.h>
37 #include <errno.h>
38 #include <inttypes.h>
40 #include <xen/xen.h>
42 #include "xg_private.h"
43 #include "xc_dom.h"
44 #include "ia64/xc_dom_ia64_util.h"
45 #endif
47 #include <asm/dom_fw.h>
48 #include <asm/dom_fw_domu.h>
50 void efi_systable_init_domu(struct fw_tables *tables)
51 {
52 int i = 1;
54 printk(XENLOG_GUEST XENLOG_INFO "DomainU EFI build up:");
56 tables->efi_tables[i].guid = ACPI_20_TABLE_GUID;
57 tables->efi_tables[i].table = FW_ACPI_BASE_PADDR;
58 printk(" ACPI 2.0=0x%lx", tables->efi_tables[i].table);
59 i++;
60 printk("\n");
61 BUG_ON(i > NUM_EFI_SYS_TABLES);
62 }
64 int
65 complete_domu_memmap(domain_t * d,
66 struct fw_tables *tables,
67 unsigned long maxmem,
68 unsigned long memmap_info_pfn,
69 unsigned long memmap_info_num_pages)
70 {
71 efi_memory_desc_t *md;
72 int create_memmap = 0;
73 xen_ia64_memmap_info_t *memmap_info;
74 unsigned long memmap_info_size;
75 unsigned long paddr_start;
76 unsigned long paddr_end;
77 void *p;
78 void *memmap_start;
79 void *memmap_end;
81 if (memmap_info_pfn == 0 || memmap_info_num_pages == 0) {
82 /* old domain builder which doesn't setup
83 * memory map. create it for compatibility */
84 memmap_info_pfn = (maxmem >> PAGE_SHIFT) - 1;
85 memmap_info_num_pages = 1;
86 create_memmap = 1;
87 }
89 memmap_info_size = memmap_info_num_pages << PAGE_SHIFT;
90 paddr_start = memmap_info_pfn << PAGE_SHIFT;
91 /* 3 = start info page, xenstore page and console page */
92 paddr_end = paddr_start + memmap_info_size + 3 * PAGE_SIZE;
93 memmap_info = xen_ia64_dom_fw_map(d, paddr_start);
95 if (memmap_info->efi_memmap_size == 0) {
96 create_memmap = 1;
97 } else if (memmap_info->efi_memdesc_size != sizeof(md[0]) ||
98 memmap_info->efi_memdesc_version !=
99 EFI_MEMORY_DESCRIPTOR_VERSION) {
100 printk(XENLOG_WARNING
101 "%s: Warning: unknown memory map "
102 "memmap size %" PRIu64 " "
103 "memdesc size %" PRIu64 " "
104 "version %" PRIu32 "\n",
105 __func__,
106 memmap_info->efi_memmap_size,
107 memmap_info->efi_memdesc_size,
108 memmap_info->efi_memdesc_version);
109 create_memmap = 1;
110 } else if (memmap_info_size < memmap_info->efi_memmap_size) {
111 printk(XENLOG_WARNING
112 "%s: Warning: too short memmap info size %" PRIu64 "\n",
113 __func__, memmap_info_size);
114 xen_ia64_dom_fw_unmap(d, memmap_info);
115 return -EINVAL;
116 } else if (memmap_info->efi_memmap_size >
117 PAGE_SIZE - sizeof(*memmap_info)) {
118 /*
119 * curently memmap spanning more than single page isn't
120 * supported.
121 */
122 printk(XENLOG_WARNING
123 "%s: Warning: too large efi_memmap_size %" PRIu64 "\n",
124 __func__, memmap_info->efi_memmap_size);
125 xen_ia64_dom_fw_unmap(d, memmap_info);
126 return -ENOSYS;
127 }
129 if (create_memmap) {
130 /*
131 * old domain builder which doesn't setup
132 * memory map. create it for compatibility
133 */
134 memmap_info->efi_memdesc_size = sizeof(md[0]);
135 memmap_info->efi_memdesc_version =
136 EFI_MEMORY_DESCRIPTOR_VERSION;
137 memmap_info->efi_memmap_size = 1 * sizeof(md[0]);
139 md = (efi_memory_desc_t *) & memmap_info->memdesc;
140 md->type = EFI_CONVENTIONAL_MEMORY;
141 md->pad = 0;
142 md->phys_addr = 0;
143 md->virt_addr = 0;
144 md->num_pages = maxmem >> EFI_PAGE_SHIFT;
145 md->attribute = EFI_MEMORY_WB;
146 }
148 memmap_start = &memmap_info->memdesc;
149 memmap_end = memmap_start + memmap_info->efi_memmap_size;
151 /* XXX Currently the table must be in a single page. */
152 if ((unsigned long)memmap_end > (unsigned long)memmap_info + PAGE_SIZE) {
153 xen_ia64_dom_fw_unmap(d, memmap_info);
154 return -EINVAL;
155 }
157 /* sort it bofore use
158 * XXX: this is created by user space domain builder so that
159 * we should check its integrity */
160 sort(&memmap_info->memdesc,
161 memmap_info->efi_memmap_size / memmap_info->efi_memdesc_size,
162 memmap_info->efi_memdesc_size, efi_mdt_cmp, NULL);
164 for (p = memmap_start; p < memmap_end;
165 p += memmap_info->efi_memdesc_size) {
166 unsigned long start;
167 unsigned long end;
169 md = p;
170 start = md->phys_addr;
171 end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
173 if (start < tables->fw_end_paddr)
174 start = tables->fw_end_paddr;
175 if (end <= start)
176 continue;
178 /* exclude [paddr_start, paddr_end) */
179 if (paddr_end <= start || end <= paddr_start) {
180 xen_ia64_efi_make_md(&tables->
181 efi_memmap[tables->num_mds],
182 EFI_CONVENTIONAL_MEMORY,
183 EFI_MEMORY_WB, start, end);
184 tables->num_mds++;
185 } else if (paddr_start <= start && paddr_end < end) {
186 xen_ia64_efi_make_md(&tables->
187 efi_memmap[tables->num_mds],
188 EFI_CONVENTIONAL_MEMORY,
189 EFI_MEMORY_WB, paddr_end, end);
190 tables->num_mds++;
191 } else if (start < paddr_start && end <= paddr_end) {
192 xen_ia64_efi_make_md(&tables->
193 efi_memmap[tables->num_mds],
194 EFI_CONVENTIONAL_MEMORY,
195 EFI_MEMORY_WB, start, paddr_start);
196 tables->num_mds++;
197 } else {
198 xen_ia64_efi_make_md(&tables->
199 efi_memmap[tables->num_mds],
200 EFI_CONVENTIONAL_MEMORY,
201 EFI_MEMORY_WB, start, paddr_start);
202 tables->num_mds++;
203 xen_ia64_efi_make_md(&tables->
204 efi_memmap[tables->num_mds],
205 EFI_CONVENTIONAL_MEMORY,
206 EFI_MEMORY_WB, paddr_end, end);
207 tables->num_mds++;
208 }
209 }
211 /* memmap info page. */
212 xen_ia64_efi_make_md(&tables->efi_memmap[tables->num_mds],
213 EFI_RUNTIME_SERVICES_DATA, EFI_MEMORY_WB,
214 paddr_start, paddr_end);
215 tables->num_mds++;
217 /* Create an entry for IO ports. */
218 xen_ia64_efi_make_md(&tables->efi_memmap[tables->num_mds],
219 EFI_MEMORY_MAPPED_IO_PORT_SPACE, EFI_MEMORY_UC,
220 IO_PORTS_PADDR, IO_PORTS_PADDR + IO_PORTS_SIZE);
221 tables->num_mds++;
223 sort(tables->efi_memmap, tables->num_mds, sizeof(efi_memory_desc_t),
224 efi_mdt_cmp, NULL);
226 xen_ia64_dom_fw_unmap(d, memmap_info);
227 return tables->num_mds;
228 }
230 /*
231 * Local variables:
232 * mode: C
233 * c-set-style: "linux"
234 * c-basic-offset: 8
235 * tab-width: 8
236 * indent-tabs-mode: t
237 * End:
238 */