custom types for RS_INIT, RS_UPDATE, and others

This commit is contained in:
Ben Gras 2014-07-26 13:54:01 +02:00 committed by Lionel Sambuc
parent 9961d3d3e5
commit c727357664
12 changed files with 72 additions and 61 deletions

View file

@ -419,8 +419,8 @@ int main(int argc, char **argv)
memset(&m, 0, sizeof(m));
switch(request) {
case RS_UPDATE:
m.RS_LU_STATE = req_lu_state;
m.RS_LU_PREPARE_MAXTIME = req_lu_maxtime;
m.m_rs_update.state = req_lu_state;
m.m_rs_update.prepare_maxtime = req_lu_maxtime;
/* fall through */
case RS_UP:
case RS_EDIT:
@ -462,14 +462,14 @@ int main(int argc, char **argv)
assert(config.rs_start.rss_priority < NR_SCHED_QUEUES);
assert(config.rs_start.rss_quantum > 0);
m.RS_CMD_ADDR = (char *) &config.rs_start;
m.m_rs_req.addr = (char *) &config.rs_start;
break;
case RS_DOWN:
case RS_REFRESH:
case RS_RESTART:
case RS_CLONE:
m.RS_CMD_ADDR = req_label;
m.RS_CMD_LEN = strlen(req_label);
m.m_rs_req.addr = req_label;
m.m_rs_req.len = strlen(req_label);
break;
case RS_SHUTDOWN:
break;

View file

@ -427,8 +427,8 @@ static void restart_driver(int which, int tell_rs)
if (tell_rs) {
/* Tell RS to refresh or restart the driver */
msg.m_type = RS_REFRESH;
msg.RS_CMD_ADDR = driver[which].label;
msg.RS_CMD_LEN = strlen(driver[which].label);
msg.m_rs_req.addr = driver[which].label;
msg.m_rs_req.len = strlen(driver[which].label);
#if DEBUG
printf("Filter: asking RS to refresh %s..\n",

View file

@ -487,25 +487,6 @@
#define RS_INIT (RS_RQ_BASE + 20) /* service init message */
#define RS_LU_PREPARE (RS_RQ_BASE + 21) /* prepare to update message */
# define RS_CMD_ADDR m1_p1 /* command string */
# define RS_CMD_LEN m1_i1 /* length of command */
# define RS_PERIOD m1_i2 /* heartbeat period */
# define RS_DEV_MAJOR m1_i3 /* major device number */
# define RS_ENDPOINT m1_i1 /* endpoint number in reply */
# define RS_NAME m1_p1 /* name */
# define RS_NAME_LEN m1_i1 /* namelen */
# define RS_INIT_RESULT m7_i1 /* init result */
# define RS_INIT_TYPE m7_i2 /* init type */
# define RS_INIT_RPROCTAB_GID m7_i3 /* init rproc table gid */
# define RS_INIT_OLD_ENDPOINT m7_i4 /* init old endpoint */
# define RS_LU_RESULT m1_i1 /* live update result */
# define RS_LU_STATE m1_i2 /* state required to update */
# define RS_LU_PREPARE_MAXTIME m1_i3 /* the max time to prepare */
/*===========================================================================*
* Messages for the Data Store Server *
*===========================================================================*/

View file

@ -1880,6 +1880,33 @@ typedef struct {
} mess_lsys_kern_vsafecopy;
_ASSERT_MSG_SIZE(mess_lsys_kern_vsafecopy);
typedef struct {
int result;
int type;
cp_grant_id_t rproctab_gid;
endpoint_t old_endpoint;
uint8_t padding[40];
} mess_rs_init;
_ASSERT_MSG_SIZE(mess_rs_init);
typedef struct {
int result;
int state;
int prepare_maxtime;
uint8_t padding[44];
} mess_rs_update;
_ASSERT_MSG_SIZE(mess_rs_update);
typedef struct {
int len;
int name_len;
endpoint_t endpoint;
void *addr;
const char *name;
uint8_t padding[36];
} mess_rs_req;
_ASSERT_MSG_SIZE(mess_rs_req);
typedef struct {
endpoint_t m_source; /* who sent the message */
int m_type; /* what kind of message is it */
@ -2120,6 +2147,9 @@ typedef struct {
mess_lsys_vm_unmap_phys m_lsys_vm_unmap_phys;
mess_lsys_kern_safecopy m_lsys_kern_safecopy;
mess_lsys_kern_vsafecopy m_lsys_kern_vsafecopy;
mess_rs_init m_rs_init;
mess_rs_update m_rs_update;
mess_rs_req m_rs_req;
mess_vfs_lchardriver_cancel m_vfs_lchardriver_cancel;
mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose;

View file

@ -28,11 +28,11 @@ int minix_rs_lookup(const char *name, endpoint_t *value)
len_key = strlen(name)+1;
memset(&m, 0, sizeof(m));
m.RS_NAME = (char *) __UNCONST(name);
m.RS_NAME_LEN = len_key;
m.m_rs_req.name = name;
m.m_rs_req.name_len = len_key;
if (_syscall(RS_PROC_NR, RS_LOOKUP, &m) != -1) {
*value = m.RS_ENDPOINT;
*value = m.m_rs_req.endpoint;
return OK;
}

View file

@ -66,7 +66,7 @@ static int process_init(int type, sef_init_info_t *info)
memset(&m, 0, sizeof(m));
m.m_source = sef_self_endpoint;
m.m_type = RS_INIT;
m.RS_INIT_RESULT = result;
m.m_rs_init.result = result;
r = sef_cbs.sef_cb_init_response(&m);
return r;
@ -111,10 +111,10 @@ int do_sef_init_request(message *m_ptr)
sef_init_info_t info;
/* Get init parameters from message. */
type = m_ptr->RS_INIT_TYPE;
info.rproctab_gid = m_ptr->RS_INIT_RPROCTAB_GID;
type = m_ptr->m_rs_init.type;
info.rproctab_gid = m_ptr->m_rs_init.rproctab_gid;
info.endpoint = sef_self_endpoint;
info.old_endpoint = m_ptr->RS_INIT_OLD_ENDPOINT;
info.old_endpoint = m_ptr->m_rs_init.old_endpoint;
/* Peform initialization. */
r = process_init(type, &info);

View file

@ -87,7 +87,7 @@ int do_sef_lu_request(message *m_ptr)
sef_lu_debug_cycle = 0;
old_state = sef_lu_state;
state = m_ptr->RS_LU_STATE;
state = m_ptr->m_rs_update.state;
/* Deal with prepare cancel requests first. */
is_valid_state = (state == SEF_LU_STATE_NULL);
@ -151,8 +151,8 @@ static void sef_lu_ready(int result)
*/
m.m_source = sef_self_endpoint;
m.m_type = RS_LU_PREPARE;
m.RS_LU_STATE = sef_lu_state;
m.RS_LU_RESULT = result;
m.m_rs_update.state = sef_lu_state;
m.m_rs_update.result = result;
r = sef_cbs.sef_cb_lu_response(&m);
#if SEF_LU_DEBUG

View file

@ -646,7 +646,7 @@ endpoint_t endpoint;
if(m.m_type != RS_INIT) {
panic("unexpected reply from service: %d", m.m_source);
}
result = m.RS_INIT_RESULT;
result = m.m_rs_init.result;
rp = rproc_ptr[_ENDPOINT_P(m.m_source)];
/* Check result. */

View file

@ -257,7 +257,7 @@ void update_period(message *m_ptr)
/* Prepare cancel request. */
m.m_type = RS_LU_PREPARE;
m.RS_LU_STATE = SEF_LU_STATE_NULL;
m.m_rs_update.state = SEF_LU_STATE_NULL;
if(rpub->endpoint == RS_PROC_NR) {
/* RS can process the request directly. */
do_sef_lu_request(&m);

View file

@ -35,7 +35,7 @@ message *m_ptr; /* request message pointer */
rpub = rp->r_pub;
/* Copy the request structure. */
r = copy_rs_start(m_ptr->m_source, m_ptr->RS_CMD_ADDR, &rs_start);
r = copy_rs_start(m_ptr->m_source, m_ptr->m_rs_req.addr, &rs_start);
if (r != OK) {
return r;
}
@ -93,8 +93,8 @@ int do_down(message *m_ptr)
char label[RS_MAX_LABEL_LEN];
/* Copy label. */
s = copy_label(m_ptr->m_source, m_ptr->RS_CMD_ADDR,
m_ptr->RS_CMD_LEN, label, sizeof(label));
s = copy_label(m_ptr->m_source, m_ptr->m_rs_req.addr,
m_ptr->m_rs_req.len, label, sizeof(label));
if(s != OK) {
return s;
}
@ -143,8 +143,8 @@ int do_restart(message *m_ptr)
char script[MAX_SCRIPT_LEN];
/* Copy label. */
s = copy_label(m_ptr->m_source, m_ptr->RS_CMD_ADDR,
m_ptr->RS_CMD_LEN, label, sizeof(label));
s = copy_label(m_ptr->m_source, m_ptr->m_rs_req.addr,
m_ptr->m_rs_req.len, label, sizeof(label));
if(s != OK) {
return s;
}
@ -191,8 +191,8 @@ int do_clone(message *m_ptr)
char label[RS_MAX_LABEL_LEN];
/* Copy label. */
s = copy_label(m_ptr->m_source, m_ptr->RS_CMD_ADDR,
m_ptr->RS_CMD_LEN, label, sizeof(label));
s = copy_label(m_ptr->m_source, m_ptr->m_rs_req.addr,
m_ptr->m_rs_req.len, label, sizeof(label));
if(s != OK) {
return s;
}
@ -237,7 +237,7 @@ int do_edit(message *m_ptr)
char label[RS_MAX_LABEL_LEN];
/* Copy the request structure. */
r = copy_rs_start(m_ptr->m_source, m_ptr->RS_CMD_ADDR, &rs_start);
r = copy_rs_start(m_ptr->m_source, m_ptr->m_rs_req.addr, &rs_start);
if (r != OK) {
return r;
}
@ -327,8 +327,8 @@ int do_refresh(message *m_ptr)
char label[RS_MAX_LABEL_LEN];
/* Copy label. */
s = copy_label(m_ptr->m_source, m_ptr->RS_CMD_ADDR,
m_ptr->RS_CMD_LEN, label, sizeof(label));
s = copy_label(m_ptr->m_source, m_ptr->m_rs_req.addr,
m_ptr->m_rs_req.len, label, sizeof(label));
if(s != OK) {
return s;
}
@ -398,7 +398,7 @@ int do_init_ready(message *m_ptr)
is_rs = (m_ptr->m_source == RS_PROC_NR);
who_p = _ENDPOINT_P(m_ptr->m_source);
result = m_ptr->RS_INIT_RESULT;
result = m_ptr->m_rs_init.result;
/* Check for RS failing initialization first. */
if(is_rs && result != OK) {
@ -490,7 +490,7 @@ int do_update(message *m_ptr)
int prepare_maxtime;
/* Copy the request structure. */
s = copy_rs_start(m_ptr->m_source, m_ptr->RS_CMD_ADDR, &rs_start);
s = copy_rs_start(m_ptr->m_source, m_ptr->m_rs_req.addr, &rs_start);
if (s != OK) {
return s;
}
@ -522,13 +522,13 @@ int do_update(message *m_ptr)
return s;
/* Retrieve live update state. */
lu_state = m_ptr->RS_LU_STATE;
lu_state = m_ptr->m_rs_update.state;
if(lu_state == SEF_LU_STATE_NULL) {
return(EINVAL);
}
/* Retrieve prepare max time. */
prepare_maxtime = m_ptr->RS_LU_PREPARE_MAXTIME;
prepare_maxtime = m_ptr->m_rs_update.prepare_maxtime;
if(prepare_maxtime) {
if(prepare_maxtime < 0 || prepare_maxtime > RS_MAX_PREPARE_MAXTIME) {
return(EINVAL);
@ -658,7 +658,7 @@ int do_upd_ready(message *m_ptr)
who_p = _ENDPOINT_P(m_ptr->m_source);
rp = rproc_ptr[who_p];
result = m_ptr->RS_LU_RESULT;
result = m_ptr->m_rs_update.result;
is_rs = (m_ptr->m_source == RS_PROC_NR);
/* Make sure the originating service was requested to prepare for update. */
@ -906,14 +906,14 @@ message *m_ptr;
struct rproc *rrp;
struct rprocpub *rrpub;
len = m_ptr->RS_NAME_LEN;
len = m_ptr->m_rs_req.name_len;
if(len < 2 || len >= sizeof(namebuf)) {
printf("RS: len too weird (%d)\n", len);
return EINVAL;
}
if((r=sys_datacopy(m_ptr->m_source, (vir_bytes) m_ptr->RS_NAME,
if((r=sys_datacopy(m_ptr->m_source, (vir_bytes) m_ptr->m_rs_req.name,
SELF, (vir_bytes) namebuf, len)) != OK) {
printf("RS: name copy failed\n");
return r;
@ -927,7 +927,7 @@ message *m_ptr;
return ESRCH;
}
rrpub = rrp->r_pub;
m_ptr->RS_ENDPOINT = rrpub->endpoint;
m_ptr->m_rs_req.endpoint = rrpub->endpoint;
return OK;
}

View file

@ -43,9 +43,9 @@ int type; /* type of initialization */
/* Send initialization message. */
m.m_type = RS_INIT;
m.RS_INIT_TYPE = type;
m.RS_INIT_RPROCTAB_GID = rinit.rproctab_gid;
m.RS_INIT_OLD_ENDPOINT = old_endpoint;
m.m_rs_init.type = type;
m.m_rs_init.rproctab_gid = rinit.rproctab_gid;
m.m_rs_init.old_endpoint = old_endpoint;
r = asynsend(rpub->endpoint, &m);
return r;

View file

@ -177,7 +177,7 @@ static int do_rs_init(message *m)
static struct rprocpub rprocpub[NR_BOOT_PROCS];
/* Map all the services in the boot image. */
if((s = sys_safecopyfrom(RS_PROC_NR, m->RS_INIT_RPROCTAB_GID, 0,
if((s = sys_safecopyfrom(RS_PROC_NR, m->m_rs_init.rproctab_gid, 0,
(vir_bytes) rprocpub, sizeof(rprocpub))) != OK) {
panic("vm: sys_safecopyfrom (rs) failed: %d", s);
}
@ -191,7 +191,7 @@ static int do_rs_init(message *m)
}
/* RS expects this response that it then again wants to reply to: */
m->RS_INIT_RESULT = OK;
m->m_rs_init.result = OK;
ipc_sendrec(RS_PROC_NR, m);
return(SUSPEND);