aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/lib
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-04-16 10:05:57 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-04-16 10:05:57 +0100
commit28baa78877ebda840603774d6a1e3e9da9546a6e (patch)
tree7f3e7943f2838769040a19258e95fa79b8c105bf /extras/mini-os/lib
parentf464d312c7b7185b7174434b61d00903949d3a76 (diff)
downloadxen-28baa78877ebda840603774d6a1e3e9da9546a6e.tar.gz
xen-28baa78877ebda840603774d6a1e3e9da9546a6e.tar.bz2
xen-28baa78877ebda840603774d6a1e3e9da9546a6e.zip
stubdom: sparse application's BSS by linking it separately first, put
markers at its beginning and end, and then link with mini-os. That permits to stick a bit more to upstream qemu. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/lib')
-rw-r--r--extras/mini-os/lib/sys.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/extras/mini-os/lib/sys.c b/extras/mini-os/lib/sys.c
index f97991bd00..efa02e5af4 100644
--- a/extras/mini-os/lib/sys.c
+++ b/extras/mini-os/lib/sys.c
@@ -1108,6 +1108,41 @@ int munmap(void *start, size_t length)
return 0;
}
+void sparse(unsigned long data, size_t size)
+{
+ unsigned long newdata;
+ xen_pfn_t *mfns;
+ int i, n;
+
+ newdata = (data + PAGE_SIZE - 1) & PAGE_MASK;
+ if (newdata - data > size)
+ return;
+ size -= newdata - data;
+ data = newdata;
+ n = size / PAGE_SIZE;
+ size = n * PAGE_SIZE;
+
+ mfns = malloc(n * sizeof(*mfns));
+ for (i = 0; i < n; i++) {
+#ifdef LIBC_DEBUG
+ int j;
+ for (j=0; j<PAGE_SIZE; j++)
+ if (((char*)data + i * PAGE_SIZE)[j]) {
+ printk("%lx is not zero!\n", data + i * PAGE_SIZE + j);
+ exit(1);
+ }
+#endif
+ mfns[i] = virtual_to_mfn(data + i * PAGE_SIZE);
+ }
+
+ printk("sparsing %ldMB at %lx\n", size >> 20, data);
+
+ munmap((void *) data, size);
+ free_physical_pages(mfns, n);
+ do_map_zero(data, n);
+}
+
+
/* Not supported by FS yet. */
unsupported_function_crash(link);
unsupported_function(int, readlink, -1);