From: Ben Gras Date: Sat, 26 Jul 2014 11:54:01 +0000 (+0200) Subject: custom types for RS_INIT, RS_UPDATE, and others X-Git-Tag: v3.3.0~111 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=c727357664b975a98eab538c17aa60495e17f3fe;p=minix.git custom types for RS_INIT, RS_UPDATE, and others --- diff --git a/commands/service/service.c b/commands/service/service.c index e8c965a0b..50c38bd40 100644 --- a/commands/service/service.c +++ b/commands/service/service.c @@ -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; diff --git a/drivers/filter/driver.c b/drivers/filter/driver.c index 2664df76a..e4cf2128f 100644 --- a/drivers/filter/driver.c +++ b/drivers/filter/driver.c @@ -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", diff --git a/include/minix/com.h b/include/minix/com.h index bafc7ab9b..32e4d9df0 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -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 * *===========================================================================*/ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index cddaaf94d..97e6bfeae 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -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; diff --git a/lib/libc/sys-minix/minix_rs.c b/lib/libc/sys-minix/minix_rs.c index c0c0d38b5..71b73603b 100644 --- a/lib/libc/sys-minix/minix_rs.c +++ b/lib/libc/sys-minix/minix_rs.c @@ -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; } diff --git a/lib/libsys/sef_init.c b/lib/libsys/sef_init.c index db1de9031..dae1935ef 100644 --- a/lib/libsys/sef_init.c +++ b/lib/libsys/sef_init.c @@ -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); diff --git a/lib/libsys/sef_liveupdate.c b/lib/libsys/sef_liveupdate.c index 691a6c936..f1834b77f 100644 --- a/lib/libsys/sef_liveupdate.c +++ b/lib/libsys/sef_liveupdate.c @@ -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 diff --git a/servers/rs/main.c b/servers/rs/main.c index adcb8df4d..5c5cd154f 100644 --- a/servers/rs/main.c +++ b/servers/rs/main.c @@ -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. */ diff --git a/servers/rs/manager.c b/servers/rs/manager.c index 689360b6d..0cadf95c0 100644 --- a/servers/rs/manager.c +++ b/servers/rs/manager.c @@ -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); diff --git a/servers/rs/request.c b/servers/rs/request.c index 5345e9c98..c951d9454 100755 --- a/servers/rs/request.c +++ b/servers/rs/request.c @@ -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; } diff --git a/servers/rs/utility.c b/servers/rs/utility.c index 6a40c7a1a..62f3dd14c 100644 --- a/servers/rs/utility.c +++ b/servers/rs/utility.c @@ -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; diff --git a/servers/vm/main.c b/servers/vm/main.c index cc738ab94..73cf0e2c4 100644 --- a/servers/vm/main.c +++ b/servers/vm/main.c @@ -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);