ia64/xen-unstable

view xen/arch/powerpc/ofd_fixup_memory.c @ 14239:b75609e1fa81

[POWERPC][XEN] Implement guest_physmap_{add,remove}_page().
- Use p2m array in pfn2mfn() and DOMCTL_getmemlist.
- Remove domain extent list.
- Create and use an m2p array for mfn_to_gmfn().
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Hollis Blanchard <hollisb@us.ibm.com>
date Fri Mar 02 17:07:59 2007 -0600 (2007-03-02)
parents a510c94ceaa3
children
line source
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Copyright IBM Corp. 2006, 2007
17 *
18 * Authors: Jimi Xenidis <jimix@watson.ibm.com>
19 * Ryan Harper <ryanh@us.ibm.com>
20 */
22 #include <xen/config.h>
23 #include <xen/lib.h>
24 #include <xen/sched.h>
25 #include <asm/platform.h>
26 #include <public/xen.h>
27 #include "of-devtree.h"
28 #include "oftree.h"
30 static char memory[] = "memory";
32 struct mem_reg {
33 u64 addr;
34 u64 sz;
35 };
37 static void ofd_memory_clean(void *m)
38 {
39 ofdn_t old;
41 /* Remove all old memory props */
42 do {
43 old = ofd_node_find_by_prop(m, OFD_ROOT, "device_type",
44 memory, sizeof(memory));
45 if (old <= 0)
46 break;
48 ofd_node_prune(m, old);
49 } while (1);
50 }
52 static ofdn_t ofd_memory_node_create(
53 void *m, ofdn_t p, const char *ppath, const char *name,
54 const char *dt, ulong start, ulong size)
55 {
56 struct mem_reg reg;
57 char path[128];
58 ulong l;
59 ofdn_t n;
60 ulong nl = strlen(name) + 1;
61 ulong dtl = strlen(dt) + 1;
63 l = snprintf(path, sizeof (path), "%s/%s@%lx", ppath, name, start);
64 n = ofd_node_add(m, p, path, l + 1);
65 ofd_prop_add(m, n, "name", name, nl);
66 ofd_prop_add(m, n, "device_type", dt, dtl);
68 /* physical addresses usable without regard to OF */
69 reg.addr = start;
70 reg.sz = size;
71 ofd_prop_add(m, n, "reg", &reg, sizeof (reg));
73 printk("Dom0: %s: %016lx, %016lx\n", path, start, size);
75 return n;
76 }
78 static void ofd_memory_rma_node(void *m, struct domain *d)
79 {
80 ulong size = rma_size(d->arch.rma_order);
81 ofdn_t n;
83 n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory, 0, size);
84 BUG_ON(n <= 0);
85 }
87 static void ofd_memory_extent_nodes(void *m, struct domain *d)
88 {
89 ulong start;
90 ulong size;
91 ofdn_t n;
92 ulong cur_pfn = 1UL << d->arch.rma_order;
94 /* if dom0 > 2G, shift ram past IO hole */
95 if ((d->tot_pages << PAGE_SHIFT) > platform_iohole_base()) {
96 /* memory@RMA up to IO hole */
97 start = cur_pfn << PAGE_SHIFT;
98 size = platform_iohole_base() - (cur_pfn << PAGE_SHIFT);
99 n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory,
100 start, size);
102 BUG_ON(n <= 0);
104 /* XXX Our p2m translation currnetly doesn't allow dom0 memory above
105 * the IO hole. */
106 #if 0
107 /* remaining memory shifted up to memory@IOHOLE_END */
108 start = platform_iohole_base()+platform_iohole_size();
109 size = (d->tot_pages << PAGE_SHIFT) - platform_iohole_base();
110 n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory,
111 start, size);
112 #endif
113 } else {
114 /* we fit beneath the IO hole as one chunk */
115 start = cur_pfn << PAGE_SHIFT;
116 size = (d->tot_pages - cur_pfn) << PAGE_SHIFT;
117 n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory,
118 start, size);
119 }
120 BUG_ON(n <= 0);
121 }
123 void ofd_memory_props(void *m, struct domain *d)
124 {
125 ofd_memory_clean(m);
126 ofd_memory_rma_node(m, d);
127 ofd_memory_extent_nodes(m,d);
128 }