From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] mini-os: export allocate_ondemand
Date: Fri, 18 Jul 2008 15:41:52 +0100 [thread overview]
Message-ID: <20080718144152.GV4456@implementation.uk.xensource.com> (raw)
mini-os: export allocate_ondemand
allocate_ondemand can be used to allocate addresse space. Primarily used
for mapping MFNs, it can also be used e.g. to map grant refs.
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
diff -r e80d27b6e206 extras/mini-os/arch/ia64/mm.c
--- a/extras/mini-os/arch/ia64/mm.c Fri Jul 18 14:34:49 2008 +0100
+++ b/extras/mini-os/arch/ia64/mm.c Fri Jul 18 15:42:09 2008 +0100
@@ -130,6 +130,11 @@
max_pfn = max_pfn;
}
+unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
+{
+ return 0;
+}
+
/* Helper function used in gnttab.c. */
void do_map_frames(unsigned long addr,
unsigned long *f, unsigned long n, unsigned long stride,
diff -r e80d27b6e206 extras/mini-os/arch/x86/mm.c
--- a/extras/mini-os/arch/x86/mm.c Fri Jul 18 14:34:49 2008 +0100
+++ b/extras/mini-os/arch/x86/mm.c Fri Jul 18 15:42:09 2008 +0100
@@ -492,9 +492,7 @@
}
}
-void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
- unsigned long increment, unsigned long alignment, domid_t id,
- int may_fail, unsigned long prot)
+unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
{
unsigned long x;
unsigned long y = 0;
@@ -517,13 +515,24 @@
}
if (y != n) {
printk("Failed to find %ld frames!\n", n);
+ return 0;
+ }
+ return demand_map_area_start + x * PAGE_SIZE;
+}
+
+void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
+ unsigned long increment, unsigned long alignment, domid_t id,
+ int may_fail, unsigned long prot)
+{
+ unsigned long addr = allocate_ondemand(n, alignment);
+
+ if (!addr)
return NULL;
- }
/* Found it at x. Map it in. */
- do_map_frames(demand_map_area_start + x * PAGE_SIZE, f, n, stride, increment, id, may_fail, prot);
+ do_map_frames(addr, f, n, stride, increment, id, may_fail, prot);
- return (void *)(unsigned long)(demand_map_area_start + x * PAGE_SIZE);
+ return (void *)addr;
}
static void clear_bootstrap(void)
diff -r e80d27b6e206 extras/mini-os/include/mm.h
--- a/extras/mini-os/include/mm.h Fri Jul 18 14:34:49 2008 +0100
+++ b/extras/mini-os/include/mm.h Fri Jul 18 15:42:09 2008 +0100
@@ -65,6 +65,7 @@
void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
void arch_init_p2m(unsigned long max_pfn_p);
+unsigned long allocate_ondemand(unsigned long n, unsigned long alignment);
/* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages */
void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
unsigned long increment, unsigned long alignment, domid_t id,
reply other threads:[~2008-07-18 14:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080718144152.GV4456@implementation.uk.xensource.com \
--to=samuel.thibault@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.