cca24d06d8
kernel (sys task). The main reason is that these would have to become cpu local variables on SMP. Once the system task is not a task but a genuine part of the kernel there is even less reason to have these extra variables as proc_ptr will already contain all neccessary information. In addition converting who_e to the process pointer and back again all the time will be avoided. Although proc_ptr will contain all important information, accessing it as a cpu local variable will be fairly expensive, hence the value would be assigned to some on stack local variable. Therefore it is better to add the 'caller' argument to the syscall handlers to pass the value on stack anyway. It also clearly denotes on who's behalf is the syscall being executed. This patch also ANSIfies the syscall function headers. Last but not least, it also fixes a potential bug in virtual_copy_f() in case the check is disabled. So far the function in case of a failure could possible reuse an old who_p in case this function had not been called from the system task. virtual_copy_f() takes the caller as a parameter too. In case the checking is disabled, the caller must be NULL and non NULL if it is enabled as we must be able to suspend the caller.
51 lines
1.5 KiB
C
51 lines
1.5 KiB
C
/* The kernel call implemented in this file:
|
|
* m_type: SYS_ABORT
|
|
*
|
|
* The parameters for this kernel call are:
|
|
* m1_i1: ABRT_HOW (how to abort, possibly fetch monitor params)
|
|
* m1_i2: ABRT_MON_ENDPT (proc nr to get monitor params from)
|
|
* m1_i3: ABRT_MON_LEN (length of monitor params)
|
|
* m1_p1: ABRT_MON_ADDR (virtual address of params)
|
|
*/
|
|
|
|
#include "../system.h"
|
|
#include <unistd.h>
|
|
|
|
#if USE_ABORT
|
|
|
|
/*===========================================================================*
|
|
* do_abort *
|
|
*===========================================================================*/
|
|
PUBLIC int do_abort(struct proc * caller, message * m_ptr)
|
|
{
|
|
/* Handle sys_abort. MINIX is unable to continue. This can originate e.g.
|
|
* in the PM (normal abort or panic) or TTY (after CTRL-ALT-DEL).
|
|
*/
|
|
int how = m_ptr->ABRT_HOW;
|
|
|
|
/* See if the monitor is to run the specified instructions. */
|
|
if (how == RBT_MONITOR) {
|
|
int p;
|
|
static char paramsbuffer[512];
|
|
int len;
|
|
len = MIN(m_ptr->ABRT_MON_LEN, sizeof(paramsbuffer)-1);
|
|
|
|
if((p=data_copy(m_ptr->ABRT_MON_ENDPT,
|
|
(vir_bytes) m_ptr->ABRT_MON_ADDR,
|
|
SYSTEM, (vir_bytes) paramsbuffer, len)) != OK) {
|
|
return p;
|
|
}
|
|
paramsbuffer[len] = '\0';
|
|
|
|
/* Parameters seem ok, copy them and prepare shutting down. */
|
|
if((p = arch_set_params(paramsbuffer, len+1)) != OK)
|
|
return p;
|
|
}
|
|
|
|
/* Now prepare to shutdown MINIX. */
|
|
prepare_shutdown(how);
|
|
return(OK); /* pro-forma (really EDISASTER) */
|
|
}
|
|
|
|
#endif /* USE_ABORT */
|
|
|