summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kern/kernel.c2
-rw-r--r--vm/vm_page.c57
-rw-r--r--vm/vm_page.h2
3 files changed, 47 insertions, 14 deletions
diff --git a/kern/kernel.c b/kern/kernel.c
index 326c70a..9aa5c35 100644
--- a/kern/kernel.c
+++ b/kern/kernel.c
@@ -54,7 +54,7 @@ kernel_main(void)
work_setup();
llsync_setup();
sref_setup();
- vm_page_info();
+ vm_page_log_info();
log_start();
#ifdef X15_RUN_TEST_MODULE
diff --git a/vm/vm_page.c b/vm/vm_page.c
index dd17573..b675319 100644
--- a/vm/vm_page.c
+++ b/vm/vm_page.c
@@ -42,6 +42,7 @@
#include <kern/mutex.h>
#include <kern/panic.h>
#include <kern/param.h>
+#include <kern/shell.h>
#include <kern/thread.h>
#include <machine/cpu.h>
#include <machine/pmap.h>
@@ -634,6 +635,46 @@ vm_page_bootalloc(size_t size)
panic("vm_page: no physical memory available");
}
+static void
+vm_page_info_common(int (*print_fn)(const char *format, ...))
+{
+ struct vm_page_zone *zone;
+ unsigned long pages;
+ unsigned int i;
+
+ for (i = 0; i < vm_page_zones_size; i++) {
+ zone = &vm_page_zones[i];
+ pages = (unsigned long)(zone->pages_end - zone->pages);
+ print_fn("vm_page: %s: pages: %lu (%luM), free: %lu (%luM)\n",
+ vm_page_zone_name(i), pages, pages >> (20 - PAGE_SHIFT),
+ zone->nr_free_pages, zone->nr_free_pages >> (20 - PAGE_SHIFT));
+ }
+}
+
+#ifdef X15_SHELL
+
+static void
+vm_page_info(void)
+{
+ vm_page_info_common(printf);
+}
+
+static void
+vm_page_shell_info(int argc, char **argv)
+{
+ (void)argc;
+ (void)argv;
+ vm_page_info();
+}
+
+static struct shell_cmd vm_page_shell_cmds[] = {
+ SHELL_CMD_INITIALIZER("vm_page_info", vm_page_shell_info,
+ "vm_page_info",
+ "print information about physical memory"),
+};
+
+#endif /* X15_SHELL */
+
void __init
vm_page_setup(void)
{
@@ -694,6 +735,8 @@ vm_page_setup(void)
}
vm_page_is_ready = 1;
+
+ SHELL_REGISTER_CMDS(vm_page_shell_cmds);
}
void __init
@@ -766,17 +809,7 @@ vm_page_zone_name(unsigned int zone_index)
}
void
-vm_page_info(void)
+vm_page_log_info(void)
{
- struct vm_page_zone *zone;
- unsigned long pages;
- unsigned int i;
-
- for (i = 0; i < vm_page_zones_size; i++) {
- zone = &vm_page_zones[i];
- pages = (unsigned long)(zone->pages_end - zone->pages);
- log_info("vm_page: %s: pages: %lu (%luM), free: %lu (%luM)",
- vm_page_zone_name(i), pages, pages >> (20 - PAGE_SHIFT),
- zone->nr_free_pages, zone->nr_free_pages >> (20 - PAGE_SHIFT));
- }
+ vm_page_info_common(log_info);
}
diff --git a/vm/vm_page.h b/vm/vm_page.h
index fa018a0..34ad163 100644
--- a/vm/vm_page.h
+++ b/vm/vm_page.h
@@ -209,6 +209,6 @@ const char * vm_page_zone_name(unsigned int zone_index);
/*
* Display internal information about the module.
*/
-void vm_page_info(void);
+void vm_page_log_info(void);
#endif /* _VM_VM_PAGE_H */