From 9e2efbd73dc9cf2187c7a81b1850bdfd01e0dcfe Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Sat, 26 Jul 2014 13:53:48 +0200 Subject: [PATCH] custom message type for VM_INFO --- include/minix/com.h | 7 +------ include/minix/ipc.h | 11 +++++++++++ lib/libsys/vm_info.c | 24 ++++++++++++------------ servers/vm/utility.c | 18 +++++++++--------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/include/minix/com.h b/include/minix/com.h index 869968888..a134724dd 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -773,13 +773,8 @@ # define VM_NOTIFY_SIG_IPC m1_i2 #define VM_INFO (VM_RQ_BASE+40) -# define VMI_WHAT m2_i1 -# define VMI_EP m2_i2 -# define VMI_COUNT m2_i3 -# define VMI_PTR m2_p1 -# define VMI_NEXT m2_l1 -/* VMI_WHAT values. */ +/* VM_INFO 'what' values. */ #define VMIW_STATS 1 #define VMIW_USAGE 2 #define VMIW_REGION 3 diff --git a/include/minix/ipc.h b/include/minix/ipc.h index bd703b316..a257ce048 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -1741,6 +1741,16 @@ typedef struct { } mess_lsys_vm_query_exit; _ASSERT_MSG_SIZE(mess_lsys_vm_query_exit); +typedef struct { + int what; + endpoint_t ep; + int count; + void *ptr; + vir_bytes next; + uint8_t padding[36]; +} mess_lsys_vm_info; +_ASSERT_MSG_SIZE(mess_lsys_vm_info); + typedef struct { endpoint_t m_source; /* who sent the message */ int m_type; /* what kind of message is it */ @@ -1964,6 +1974,7 @@ typedef struct { mess_lc_vm_getphys m_lc_vm_getphys; mess_lc_vm_shm_unmap m_lc_vm_shm_unmap; mess_lsys_vm_query_exit m_lsys_vm_query_exit; + mess_lsys_vm_info m_lsys_vm_info; mess_vfs_lchardriver_cancel m_vfs_lchardriver_cancel; mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose; diff --git a/lib/libsys/vm_info.c b/lib/libsys/vm_info.c index 591d3b267..81342487e 100644 --- a/lib/libsys/vm_info.c +++ b/lib/libsys/vm_info.c @@ -12,8 +12,8 @@ int vm_info_stats(struct vm_stats_info *vsi) message m; memset(&m, 0, sizeof(m)); - m.VMI_WHAT = VMIW_STATS; - m.VMI_PTR = (void *) vsi; + m.m_lsys_vm_info.what = VMIW_STATS; + m.m_lsys_vm_info.ptr = vsi; return _taskcall(VM_PROC_NR, VM_INFO, &m); } @@ -26,9 +26,9 @@ int vm_info_usage(endpoint_t who, struct vm_usage_info *vui) message m; memset(&m, 0, sizeof(m)); - m.VMI_WHAT = VMIW_USAGE; - m.VMI_EP = who; - m.VMI_PTR = (void *) vui; + m.m_lsys_vm_info.what = VMIW_USAGE; + m.m_lsys_vm_info.ep = who; + m.m_lsys_vm_info.ptr = vui; return _taskcall(VM_PROC_NR, VM_INFO, &m); } @@ -43,16 +43,16 @@ int vm_info_region(endpoint_t who, struct vm_region_info *vri, int result; memset(&m, 0, sizeof(m)); - m.VMI_WHAT = VMIW_REGION; - m.VMI_EP = who; - m.VMI_COUNT = count; - m.VMI_PTR = (void *) vri; - m.VMI_NEXT = *next; + m.m_lsys_vm_info.what = VMIW_REGION; + m.m_lsys_vm_info.ep = who; + m.m_lsys_vm_info.count = count; + m.m_lsys_vm_info.ptr = vri; + m.m_lsys_vm_info.next = *next; if ((result = _taskcall(VM_PROC_NR, VM_INFO, &m)) != OK) return result; - *next = m.VMI_NEXT; - return m.VMI_COUNT; + *next = m.m_lsys_vm_info.next; + return m.m_lsys_vm_info.count; } diff --git a/servers/vm/utility.c b/servers/vm/utility.c index 936391807..17edbe2c1 100644 --- a/servers/vm/utility.c +++ b/servers/vm/utility.c @@ -111,9 +111,9 @@ int do_info(message *m) return EINVAL; vmp = &vmproc[pr]; - ptr = (vir_bytes) m->VMI_PTR; + ptr = (vir_bytes) m->m_lsys_vm_info.ptr; - switch(m->VMI_WHAT) { + switch(m->m_lsys_vm_info.what) { case VMIW_STATS: vsi.vsi_pagesize = VM_PAGE_SIZE; vsi.vsi_total = total_pages; @@ -129,9 +129,9 @@ int do_info(message *m) break; case VMIW_USAGE: - if(m->VMI_EP < 0) + if(m->m_lsys_vm_info.ep < 0) get_usage_info_kernel(&vui); - else if (vm_isokendpt(m->VMI_EP, &pr) != OK) + else if (vm_isokendpt(m->m_lsys_vm_info.ep, &pr) != OK) return EINVAL; else get_usage_info(&vmproc[pr], &vui); @@ -141,16 +141,16 @@ int do_info(message *m) break; case VMIW_REGION: - if (vm_isokendpt(m->VMI_EP, &pr) != OK) + if (vm_isokendpt(m->m_lsys_vm_info.ep, &pr) != OK) return EINVAL; - count = MIN(m->VMI_COUNT, MAX_VRI_COUNT); - next = m->VMI_NEXT; + count = MIN(m->m_lsys_vm_info.count, MAX_VRI_COUNT); + next = m->m_lsys_vm_info.next; count = get_region_info(&vmproc[pr], vri, count, &next); - m->VMI_COUNT = count; - m->VMI_NEXT = next; + m->m_lsys_vm_info.count = count; + m->m_lsys_vm_info.next = next; addr = (vir_bytes) vri; size = sizeof(vri[0]) * count;