From 9ea21ea1580fce0c2b591c385b75c4923a5a6eaf Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Fri, 25 Jul 2014 16:35:26 +0200 Subject: [PATCH] Message type for SYS_DIAGCTL. Change-Id: Icdaa84847f8c75f5af6612dda3326f800166e0d7 --- include/minix/com.h | 3 --- include/minix/ipc.h | 11 +++++++++++ kernel/system/do_diagctl.c | 17 ++++++++++------- lib/libsys/sys_diagctl.c | 21 ++++++++++++++++++--- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/include/minix/com.h b/include/minix/com.h index 2f85d774f..56305b8bc 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -414,9 +414,6 @@ #define VMCTL_BOOTINHIBIT_CLEAR 33 /* Codes and field names for SYS_DIAGCTL. */ -#define DIAGCTL_CODE m1_i1 /* DIAGCTL_CODE_* below */ -#define DIAGCTL_ARG1 m1_p1 -#define DIAGCTL_ARG2 m1_i2 #define DIAGCTL_CODE_DIAG 1 /* Print diagnostics. */ #define DIAGCTL_CODE_STACKTRACE 2 /* Print process stack. */ #define DIAGCTL_CODE_REGISTER 3 /* Register for diagnostic signals */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index aa46868e1..abcf538ab 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -131,6 +131,16 @@ typedef struct { } mess_pm_lsys_sigs_signal; _ASSERT_MSG_SIZE(mess_pm_lsys_sigs_signal); +typedef struct { + int code; + vir_bytes buf; + int len; + endpoint_t endpt; + + uint8_t padding[40]; +} mess_lsys_krn_sys_diagctl; +_ASSERT_MSG_SIZE(mess_lsys_krn_sys_diagctl); + typedef struct { off_t offset; void *addr; @@ -1968,6 +1978,7 @@ typedef struct { mess_notify m_notify; mess_sigcalls m_sigcalls; + mess_lsys_krn_sys_diagctl m_lsys_krn_sys_diagctl; mess_lsys_krn_readbios m_lsys_krn_readbios; mess_pm_lsys_sigs_signal m_pm_lsys_sigs_signal; mess_input_tty_event m_input_tty_event; diff --git a/kernel/system/do_diagctl.c b/kernel/system/do_diagctl.c index 788dddba3..5003ab996 100644 --- a/kernel/system/do_diagctl.c +++ b/kernel/system/do_diagctl.c @@ -2,8 +2,11 @@ * m_type: SYS_DIAGCTL * * The parameters for this kernel call are: - * DIAGCTL_CODE request - * and then request-specific arguments in DIAGCTL_ARG1 and DIAGCTL_ARG2. + * m_lsys_krn_sys_diagctl.code request + * and then request-specific arguments in + * m_lsys_krn_sys_diagctl.buf + * m_lsys_krn_sys_diagctl.len + * m_lsys_krn_sys_diagctl.endpt */ #include "kernel/system.h" @@ -18,10 +21,10 @@ int do_diagctl(struct proc * caller, message * m_ptr) static char mybuf[DIAG_BUFSIZE]; int s, i, proc_nr; - switch (m_ptr->DIAGCTL_CODE) { + switch (m_ptr->m_lsys_krn_sys_diagctl.code) { case DIAGCTL_CODE_DIAG: - buf = (vir_bytes) m_ptr->DIAGCTL_ARG1; - len = (vir_bytes) m_ptr->DIAGCTL_ARG2; + buf = m_ptr->m_lsys_krn_sys_diagctl.buf; + len = m_ptr->m_lsys_krn_sys_diagctl.len; if(len < 1 || len > DIAG_BUFSIZE) { printf("do_diagctl: diag for %d: len %d out of range\n", caller->p_endpoint, len); @@ -38,7 +41,7 @@ int do_diagctl(struct proc * caller, message * m_ptr) kputc(END_OF_KMESS); return OK; case DIAGCTL_CODE_STACKTRACE: - if(!isokendpt(m_ptr->DIAGCTL_ARG2, &proc_nr)) + if(!isokendpt(m_ptr->m_lsys_krn_sys_diagctl.endpt, &proc_nr)) return EINVAL; proc_stacktrace(proc_addr(proc_nr)); return OK; @@ -58,7 +61,7 @@ int do_diagctl(struct proc * caller, message * m_ptr) priv(caller)->s_diag_sig = FALSE; return OK; default: - printf("do_diagctl: invalid request %d\n", m_ptr->DIAGCTL_CODE); + printf("do_diagctl: invalid request %d\n", m_ptr->m_lsys_krn_sys_diagctl.code); return(EINVAL); } } diff --git a/lib/libsys/sys_diagctl.c b/lib/libsys/sys_diagctl.c index bf7ca5d8c..cb6b08a21 100644 --- a/lib/libsys/sys_diagctl.c +++ b/lib/libsys/sys_diagctl.c @@ -1,13 +1,28 @@ #include "syslib.h" +#include "sysutil.h" int sys_diagctl(int code, char *arg1, int arg2) { message m; - m.DIAGCTL_CODE = code; - m.DIAGCTL_ARG1 = arg1; - m.DIAGCTL_ARG2 = arg2; + m.m_lsys_krn_sys_diagctl.code = code; + + switch(code) { + case DIAGCTL_CODE_DIAG: + m.m_lsys_krn_sys_diagctl.buf = (vir_bytes)arg1; + m.m_lsys_krn_sys_diagctl.len = arg2; + break; + case DIAGCTL_CODE_STACKTRACE: + m.m_lsys_krn_sys_diagctl.endpt = (endpoint_t)arg2; + break; + case DIAGCTL_CODE_REGISTER: + break; + case DIAGCTL_CODE_UNREGISTER: + break; + default: + panic("Unknown SYS_DIAGCTL request %d\n", code); + } return(_kernel_call(SYS_DIAGCTL, &m)); }