IPC status code for receive().

IPC changes:
- receive() is changed to take an additional parameter, which is a pointer to
a status code.
- The status code is filled in by the kernel to provide additional information
to the caller. For now, the kernel only fills in the IPC call used by the
sender.

Syslib changes:
- sef_receive() has been split into sef_receive() (with the original semantics)
and sef_receive_status() which exposes the status code to userland.
- Ideally, every sys process should gradually switch to sef_receive_status()
and use is_ipc_notify() as a dependable way to check for notify.
- SEF has been modified to use is_ipc_notify() and demonstrate how to use the
new status code.
This commit is contained in:
Cristiano Giuffrida
2010-03-23 00:09:11 +00:00
parent 45db6482e8
commit bde2109b7c
12 changed files with 91 additions and 47 deletions

View File

@@ -15,9 +15,9 @@ INCS+= minix/a.out.h minix/bitmap.h minix/callnr.h minix/cdrom.h \
minix/crtso.h minix/debug.h minix/devio.h minix/dirent.h \
minix/dir.h minix/dl_eth.h minix/dmap.h minix/driver.h \
minix/drivers.h minix/drvlib.h minix/ds.h minix/endpoint.h \
minix/fslib.h minix/ioctl.h minix/ipc.h minix/keymap.h \
minix/minlib.h minix/mq.h minix/partition.h minix/paths.h \
minix/portio.h minix/profile.h minix/queryparam.h \
minix/fslib.h minix/ioctl.h minix/ipc.h minix/ipcconst.h \
minix/keymap.h minix/minlib.h minix/mq.h minix/partition.h \
minix/paths.h minix/portio.h minix/profile.h minix/queryparam.h \
minix/rs.h minix/safecopies.h minix/sef.h minix/sound.h \
minix/sys_config.h minix/sysinfo.h minix/syslib.h \
minix/sysutil.h minix/tty.h minix/type.h minix/types.h \

View File

@@ -96,7 +96,8 @@
* offset are used for the per-process notification bit maps.
*/
#define NOTIFY_MESSAGE 0x1000
/* FIXME will be is_notify(a) ((a) == NOTIFY_MESSAGE) */
/* FIXME the old is_notify(a) should be replaced by is_ipc_notify(status). */
#define is_ipc_notify(status) (IPC_STATUS_CALL(status) == NOTIFY)
#define is_notify(a) ((unsigned) ((a) - NOTIFY_MESSAGE) < 0x100)
#define NOTIFY_FROM(p_nr) (NOTIFY_MESSAGE | ((p_nr) + NR_TASKS))

View File

@@ -1,6 +1,7 @@
#ifndef _IPC_H
#define _IPC_H
#include <minix/ipcconst.h>
#include <minix/type.h>
/*==========================================================================*
@@ -147,7 +148,7 @@ typedef struct asynmsg
_PROTOTYPE( int echo, (message *m_ptr) );
_PROTOTYPE( int notify, (endpoint_t dest) );
_PROTOTYPE( int sendrec, (endpoint_t src_dest, message *m_ptr) );
_PROTOTYPE( int receive, (endpoint_t src, message *m_ptr) );
_PROTOTYPE( int receive, (endpoint_t src, message *m_ptr, int *status_ptr));
_PROTOTYPE( int send, (endpoint_t dest, message *m_ptr) );
_PROTOTYPE( int sendnb, (endpoint_t dest, message *m_ptr) );
_PROTOTYPE( int senda, (asynmsg_t *table, size_t count) );

20
include/minix/ipcconst.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef _IPC_CONST_H
#define _IPC_CONST_H
/* System call numbers that are passed when trapping to the kernel. */
#define SEND 1 /* blocking send */
#define RECEIVE 2 /* blocking receive */
#define SENDREC 3 /* SEND + RECEIVE */
#define NOTIFY 4 /* asynchronous notify */
#define SENDNB 5 /* nonblocking send */
#define SENDA 16 /* asynchronous send */
/* Macros for IPC status code manipulation. */
#define IPC_STATUS_CALL_SHIFT 0
#define IPC_STATUS_CALL_MASK 0x3F
#define IPC_STATUS_CALL(status) \
(((status) >> IPC_STATUS_CALL_SHIFT) & IPC_STATUS_CALL_MASK)
#define IPC_STATUS_CALL_TO(call) \
(((call) & IPC_STATUS_CALL_MASK) << IPC_STATUS_CALL_SHIFT)
#endif /* IPC_CONST_H */

View File

@@ -7,8 +7,10 @@
/* SEF entry points for system processes. */
_PROTOTYPE( void sef_startup, (void) );
_PROTOTYPE( int sef_receive, (endpoint_t src, message *m_ptr) );
_PROTOTYPE( int sef_receive_status, (endpoint_t src, message *m_ptr,
int *status_ptr) );
_PROTOTYPE( void sef_exit, (int status) );
#define sef_receive(src, m_ptr) sef_receive_status(src, m_ptr, NULL)
/* SEF Debug. */
#include <stdio.h>
@@ -73,7 +75,7 @@ _PROTOTYPE( int sef_cb_init_crash, (int type, sef_init_info_t *info) );
*===========================================================================*/
/* What to intercept. */
#define INTERCEPT_SEF_PING_REQUESTS 1
#define IS_SEF_PING_REQUEST(mp) (is_notify((mp)->m_type) \
#define IS_SEF_PING_REQUEST(mp, status) (is_ipc_notify(status) \
&& (mp)->m_source == RS_PROC_NR)
/* Callback type definitions. */
@@ -108,7 +110,7 @@ _PROTOTYPE( void sef_cb_ping_reply_pong, (endpoint_t source) );
*===========================================================================*/
/* What to intercept. */
#define INTERCEPT_SEF_LU_REQUESTS 1
#define IS_SEF_LU_REQUEST(mp) ((mp)->m_type == RS_LU_PREPARE \
#define IS_SEF_LU_REQUEST(mp, status) ((mp)->m_type == RS_LU_PREPARE \
&& (mp)->m_source == RS_PROC_NR)
/* Callback type definitions. */
@@ -175,9 +177,9 @@ _PROTOTYPE( int sef_cb_lu_state_isvalid_standard, (int state) );
*===========================================================================*/
/* What to intercept. */
#define INTERCEPT_SEF_SIGNAL_REQUESTS 1
#define IS_SEF_SIGNAL_REQUEST(mp) \
#define IS_SEF_SIGNAL_REQUEST(mp, status) \
(((mp)->m_type == SIGS_SIGNAL_RECEIVED && (mp)->m_source < INIT_PROC_NR) \
|| (is_notify((mp)->m_type) && (mp)->m_source == SYSTEM))
|| (is_ipc_notify(status) && (mp)->m_source == SYSTEM))
/* Callback type definitions. */
typedef void(*sef_cb_signal_handler_t)(int signo);