1 /* The kernel call implemented in this file:
4 * The parameters for this kernel call are:
5 * m_lsys_krn_sys_diagctl.code request
6 * and then request-specific arguments in
7 * m_lsys_krn_sys_diagctl.buf
8 * m_lsys_krn_sys_diagctl.len
9 * m_lsys_krn_sys_diagctl.endpt
12 #include "kernel/system.h"
15 /*===========================================================================*
17 *===========================================================================*/
18 int do_diagctl(struct proc
* caller
, message
* m_ptr
)
21 static char mybuf
[DIAG_BUFSIZE
];
24 switch (m_ptr
->m_lsys_krn_sys_diagctl
.code
) {
25 case DIAGCTL_CODE_DIAG
:
26 buf
= m_ptr
->m_lsys_krn_sys_diagctl
.buf
;
27 len
= m_ptr
->m_lsys_krn_sys_diagctl
.len
;
28 if(len
< 1 || len
> DIAG_BUFSIZE
) {
29 printf("do_diagctl: diag for %d: len %d out of range\n",
30 caller
->p_endpoint
, len
);
33 if((s
=data_copy_vmcheck(caller
, caller
->p_endpoint
, buf
, KERNEL
,
34 (vir_bytes
) mybuf
, len
)) != OK
) {
35 printf("do_diagctl: diag for %d: len %d: copy failed: %d\n",
36 caller
->p_endpoint
, len
, s
);
39 for(i
= 0; i
< len
; i
++)
43 case DIAGCTL_CODE_STACKTRACE
:
44 if(!isokendpt(m_ptr
->m_lsys_krn_sys_diagctl
.endpt
, &proc_nr
))
46 proc_stacktrace(proc_addr(proc_nr
));
48 case DIAGCTL_CODE_REGISTER
:
49 if (!(priv(caller
)->s_flags
& SYS_PROC
))
51 priv(caller
)->s_diag_sig
= TRUE
;
52 /* If the message log is not empty, send a first notification
53 * immediately. After bootup the log is basically never empty.
55 if (kmess
.km_size
> 0 && !kinfo
.do_serial_debug
)
56 send_sig(caller
->p_endpoint
, SIGKMESS
);
58 case DIAGCTL_CODE_UNREGISTER
:
59 if (!(priv(caller
)->s_flags
& SYS_PROC
))
61 priv(caller
)->s_diag_sig
= FALSE
;
64 printf("do_diagctl: invalid request %d\n", m_ptr
->m_lsys_krn_sys_diagctl
.code
);