Message type for SYS_DIAGCTL.

Change-Id: Icdaa84847f8c75f5af6612dda3326f800166e0d7
This commit is contained in:
Lionel Sambuc 2014-07-25 16:35:26 +02:00
parent 93b1819dac
commit 9ea21ea158
4 changed files with 39 additions and 13 deletions

View file

@ -414,9 +414,6 @@
#define VMCTL_BOOTINHIBIT_CLEAR 33 #define VMCTL_BOOTINHIBIT_CLEAR 33
/* Codes and field names for SYS_DIAGCTL. */ /* 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_DIAG 1 /* Print diagnostics. */
#define DIAGCTL_CODE_STACKTRACE 2 /* Print process stack. */ #define DIAGCTL_CODE_STACKTRACE 2 /* Print process stack. */
#define DIAGCTL_CODE_REGISTER 3 /* Register for diagnostic signals */ #define DIAGCTL_CODE_REGISTER 3 /* Register for diagnostic signals */

View file

@ -131,6 +131,16 @@ typedef struct {
} mess_pm_lsys_sigs_signal; } mess_pm_lsys_sigs_signal;
_ASSERT_MSG_SIZE(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 { typedef struct {
off_t offset; off_t offset;
void *addr; void *addr;
@ -1968,6 +1978,7 @@ typedef struct {
mess_notify m_notify; mess_notify m_notify;
mess_sigcalls m_sigcalls; mess_sigcalls m_sigcalls;
mess_lsys_krn_sys_diagctl m_lsys_krn_sys_diagctl;
mess_lsys_krn_readbios m_lsys_krn_readbios; mess_lsys_krn_readbios m_lsys_krn_readbios;
mess_pm_lsys_sigs_signal m_pm_lsys_sigs_signal; mess_pm_lsys_sigs_signal m_pm_lsys_sigs_signal;
mess_input_tty_event m_input_tty_event; mess_input_tty_event m_input_tty_event;

View file

@ -2,8 +2,11 @@
* m_type: SYS_DIAGCTL * m_type: SYS_DIAGCTL
* *
* The parameters for this kernel call are: * The parameters for this kernel call are:
* DIAGCTL_CODE request * m_lsys_krn_sys_diagctl.code request
* and then request-specific arguments in DIAGCTL_ARG1 and DIAGCTL_ARG2. * 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" #include "kernel/system.h"
@ -18,10 +21,10 @@ int do_diagctl(struct proc * caller, message * m_ptr)
static char mybuf[DIAG_BUFSIZE]; static char mybuf[DIAG_BUFSIZE];
int s, i, proc_nr; int s, i, proc_nr;
switch (m_ptr->DIAGCTL_CODE) { switch (m_ptr->m_lsys_krn_sys_diagctl.code) {
case DIAGCTL_CODE_DIAG: case DIAGCTL_CODE_DIAG:
buf = (vir_bytes) m_ptr->DIAGCTL_ARG1; buf = m_ptr->m_lsys_krn_sys_diagctl.buf;
len = (vir_bytes) m_ptr->DIAGCTL_ARG2; len = m_ptr->m_lsys_krn_sys_diagctl.len;
if(len < 1 || len > DIAG_BUFSIZE) { if(len < 1 || len > DIAG_BUFSIZE) {
printf("do_diagctl: diag for %d: len %d out of range\n", printf("do_diagctl: diag for %d: len %d out of range\n",
caller->p_endpoint, len); caller->p_endpoint, len);
@ -38,7 +41,7 @@ int do_diagctl(struct proc * caller, message * m_ptr)
kputc(END_OF_KMESS); kputc(END_OF_KMESS);
return OK; return OK;
case DIAGCTL_CODE_STACKTRACE: 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; return EINVAL;
proc_stacktrace(proc_addr(proc_nr)); proc_stacktrace(proc_addr(proc_nr));
return OK; return OK;
@ -58,7 +61,7 @@ int do_diagctl(struct proc * caller, message * m_ptr)
priv(caller)->s_diag_sig = FALSE; priv(caller)->s_diag_sig = FALSE;
return OK; return OK;
default: 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); return(EINVAL);
} }
} }

View file

@ -1,13 +1,28 @@
#include "syslib.h" #include "syslib.h"
#include "sysutil.h"
int sys_diagctl(int code, char *arg1, int arg2) int sys_diagctl(int code, char *arg1, int arg2)
{ {
message m; message m;
m.DIAGCTL_CODE = code; m.m_lsys_krn_sys_diagctl.code = code;
m.DIAGCTL_ARG1 = arg1;
m.DIAGCTL_ARG2 = arg2; 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)); return(_kernel_call(SYS_DIAGCTL, &m));
} }