]> xenbits.xensource.com Git - people/liuw/rumprun.git/commitdiff
Add bmk_platform_memsize() and replace use of homegrown variants.
authorAntti Kantee <pooka@iki.fi>
Wed, 29 Apr 2015 09:14:27 +0000 (09:14 +0000)
committerAntti Kantee <pooka@iki.fi>
Wed, 29 Apr 2015 09:14:27 +0000 (09:14 +0000)
include/bmk-core/platform.h
platform/baremetal/include/bmk/kernel.h
platform/baremetal/kernel.c
platform/baremetal/rumpuser.c
platform/xen/rumphyper_base.c
platform/xen/xen/include/mini-os/mm.h
platform/xen/xen/mm.c

index 25dc3eca808f2eda1bfd9f19c42843447cdf64b2..3f4cd970558f5f2a5f333cbf5f0279ed795e597c 100644 (file)
@@ -31,6 +31,7 @@
 void *bmk_platform_allocpg2(int);
 void bmk_platform_freepg2(void *, int);
 void bmk_platform_block(bmk_time_t);
+unsigned long bmk_platform_memsize(void);
 
 void bmk_platform_halt(const char *) __attribute__((noreturn));
 
index 0bed2a07656e28eec85bfd741dfa3da6ce945915..ccc3fa6e70a2a44b62103cb0299b88174125ba68 100644 (file)
@@ -33,8 +33,6 @@ void bmk_isr(int);
 int bmk_isr_init(void);
 int bmk_isr_netinit(int (*)(void *), void *, int);
 
-extern unsigned long bmk_membase, bmk_memsize;
-
 #endif /* _LOCORE */
 
 #include <bmk-core/errno.h>
index 2587950502849ad54f52afacb6bf0d603e2ba642..7d86bda4253604634ce3a71dace68508817ca6aa 100644 (file)
@@ -36,8 +36,8 @@
 #include <bmk-core/printf.h>
 #include <bmk-core/queue.h>
 
-unsigned long bmk_membase;
-unsigned long bmk_memsize;
+static unsigned long bmk_membase;
+static unsigned long bmk_memsize;
 
 LIST_HEAD(, stackcache) cacheofstacks = LIST_HEAD_INITIALIZER(cacheofstacks);
 struct stackcache {
@@ -128,6 +128,13 @@ bmk_platform_freepg2(void *mem, int shift)
        bmk_printf("WARNING: freepg2 called! (%p, %d)\n", mem, shift);
 }
 
+unsigned long
+bmk_platform_memsize(void)
+{
+
+       return bmk_memsize;
+}
+
 void
 bmk_platform_block(bmk_time_t until)
 {
index d1114a8bfab06f8b8ee6e68139e25ce396bebdd9..10c11cdf83b66594fbda86c06473321666d35638 100644 (file)
@@ -66,13 +66,13 @@ rumpuser_getparam(const char *name, void *buf, size_t buflen)
 
        /* for memlimit, we have to implement int -> string ... */
        } else if (bmk_strcmp(name, "RUMP_MEMLIMIT") == 0) {
-               unsigned long memsize;
+               unsigned long memsize = bmk_platform_memsize();
                char tmp[64];
                char *res = buf;
                unsigned i, j;
 
-               bmk_assert(bmk_memsize > BMK_MEMRESERVE);
-               memsize = bmk_memsize - BMK_MEMRESERVE;
+               bmk_assert(memsize > BMK_MEMRESERVE);
+               memsize -= BMK_MEMRESERVE;
 
                for (i = 0; memsize > 0; i++) {
                        bmk_assert(i < sizeof(tmp)-1);
index 19d2d45992a4f92fa3f03f15009671f24dd4aa63..36729d44b947118508c8339760f60d3a8a520921 100644 (file)
@@ -60,7 +60,7 @@ rumpuser_getparam(const char *name, void *buf, size_t buflen)
                unsigned i, j;
 
                /* use up to 50% memory for rump kernel */
-               memsize = minios_get_memsize() / 2;
+               memsize = bmk_platform_memsize() / 2;
                if (memsize < (8 * 1024 * 1024)) {
                        minios_printk("rumphyper: warning: low on physical "
                                      "memory (%llu bytes), "
index 2de72c0f8f0781b23542281cd926a46c16f55eb6..ac7a2468a25e24ca01958548c06c9f9ed0e8926c 100644 (file)
@@ -77,6 +77,5 @@ unsigned long minios_alloc_contig_pages(int order, unsigned int addr_bits);
 
 int free_physical_pages(xen_pfn_t *mfns, int n);
 void fini_mm(void);
-uint64_t minios_get_memsize(void);
 
 #endif /* _MINIOS_MM_H_ */
index d9c6aa125a8f73cb825939de4640f90a8e6e5348..ced9a72246a0fae9195cb60834fd5395ce305443 100644 (file)
@@ -41,6 +41,7 @@
 #include <mini-os/types.h>
 #include <mini-os/lib.h>
 
+#include <bmk-core/platform.h>
 #include <bmk-core/string.h>
 
 #ifdef MM_DEBUG
@@ -375,8 +376,8 @@ int free_physical_pages(xen_pfn_t *mfns, int n)
 }
 #endif
 
-static uint64_t memsize = 0;
-uint64_t minios_get_memsize(void)
+static unsigned long memsize = 0;
+unsigned long bmk_platform_memsize(void)
 {
     return memsize;
 }