From aeea74bc5438895f09329ef1a3a006f251ae25ce Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sat, 24 Jun 2017 01:28:08 +0200 Subject: vm/vm_map: implement the vm_map_info shell command --- kern/task.h | 6 ++++++ vm/vm_map.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/kern/task.h b/kern/task.h index cfe694bf..591e8d7e 100644 --- a/kern/task.h +++ b/kern/task.h @@ -68,6 +68,12 @@ task_unref(struct task *task) } } +static inline struct vm_map * +task_get_vm_map(const struct task *task) +{ + return task->map; +} + /* * Initialize the task module. */ diff --git a/vm/vm_map.c b/vm/vm_map.c index f506d3ba..d7c7fa66 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include #include @@ -695,6 +697,39 @@ vm_map_init(struct vm_map *map, struct pmap *pmap, map->pmap = pmap; } +#ifdef X15_SHELL + +static void +vm_map_shell_info(int argc, char **argv) +{ + const struct task *task; + + if (argc < 2) { + goto error; + } else { + task = task_lookup(argv[1]); + + if (task == NULL) { + goto error; + } + + vm_map_info(task_get_vm_map(task)); + } + + return; + +error: + printf("vm_map: info: invalid arguments\n"); +} + +static struct shell_cmd vm_map_shell_cmds[] = { + SHELL_CMD_INITIALIZER("vm_map_info", vm_map_shell_info, + "vm_map_info ", + "print information about a VM map"), +}; + +#endif /* X15_SHELL */ + void __init vm_map_setup(void) { @@ -705,6 +740,7 @@ vm_map_setup(void) KMEM_CACHE_PAGE_ONLY); kmem_cache_init(&vm_map_cache, "vm_map", sizeof(struct vm_map), 0, NULL, 0); + SHELL_REGISTER_CMDS(vm_map_shell_cmds); } int -- cgit v1.2.3