From: Kees van Reeuwijk Date: Thu, 4 Mar 2010 16:15:26 +0000 (+0000) Subject: Move cp_grant_id_t to a more central header file, and uses it more X-Git-Tag: v3.1.7~255 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=851dc95566ea0e4859a95ac13a010ab1afdd1d40;p=minix.git Move cp_grant_id_t to a more central header file, and uses it more extensively. Fix casts that cast the grand id field of some messages to the wrong type. --- diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index 8c9664c4c..fb26cd917 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -2334,7 +2334,7 @@ message *m; return EINVAL; if (m->REQUEST == DIOCTIMEOUT) { - r= sys_safecopyfrom(m->IO_ENDPT, (vir_bytes) m->IO_GRANT, + r= sys_safecopyfrom(m->IO_ENDPT, (cp_grant_id_t) m->IO_GRANT, 0, (vir_bytes)&timeout, sizeof(timeout), D); if(r != OK) @@ -2363,7 +2363,8 @@ message *m; timeout_ticks = timeout; } - r= sys_safecopyto(m->IO_ENDPT, (vir_bytes) m->IO_GRANT, + r= sys_safecopyto(m->IO_ENDPT, + (cp_grant_id_t) m->IO_GRANT, 0, (vir_bytes)&prev, sizeof(prev), D); if(r != OK) @@ -2375,7 +2376,7 @@ message *m; int count; if (w_prepare(m->DEVICE) == NIL_DEV) return ENXIO; count = w_wn->open_ct; - r= sys_safecopyto(m->IO_ENDPT, (vir_bytes) m->IO_GRANT, + r= sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t) m->IO_GRANT, 0, (vir_bytes)&count, sizeof(count), D); if(r != OK) diff --git a/drivers/bios_wini/bios_wini.c b/drivers/bios_wini/bios_wini.c index fed01fab9..fabf06e80 100644 --- a/drivers/bios_wini/bios_wini.c +++ b/drivers/bios_wini/bios_wini.c @@ -525,7 +525,7 @@ PRIVATE int w_other(struct driver *dr, message *m) int count; if (w_prepare(m->DEVICE) == NIL_DEV) return ENXIO; count = w_wn->open_ct; - r=sys_safecopyto(m->IO_ENDPT, (vir_bytes)m->IO_GRANT, + r=sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t)m->IO_GRANT, 0, (vir_bytes)&count, sizeof(count), D); if(r != OK) diff --git a/drivers/dec21140A/dec21140A.c b/drivers/dec21140A/dec21140A.c index d973e9fe0..e53cd3437 100644 --- a/drivers/dec21140A/dec21140A.c +++ b/drivers/dec21140A/dec21140A.c @@ -481,10 +481,10 @@ PRIVATE void do_vread_s(message * mp, int from_int) client layer */ dep->de_read_iovec.iod_proc_nr = mp->DL_PROC; - de_get_userdata_s(mp->DL_PROC, (vir_bytes) mp->DL_GRANT, 0, + de_get_userdata_s(mp->DL_PROC, (cp_grant_id_t) mp->DL_GRANT, 0, mp->DL_COUNT, dep->de_read_iovec.iod_iovec); dep->de_read_iovec.iod_iovec_s = mp->DL_COUNT; - dep->de_read_iovec.iod_grant = (vir_bytes) mp->DL_GRANT; + dep->de_read_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT; dep->de_read_iovec.iod_iovec_offset = 0; size = de_calc_iov_size(&dep->de_read_iovec); if (size < ETH_MAX_PACK_SIZE) @@ -841,7 +841,7 @@ PRIVATE void do_vwrite_s(message * mp, int from_int){ de_get_userdata_s(mp->DL_PROC, mp->DL_GRANT, 0, mp->DL_COUNT, iovp->iod_iovec); iovp->iod_iovec_s = mp->DL_COUNT; - iovp->iod_grant = (vir_bytes) mp->DL_GRANT; + iovp->iod_grant = (cp_grant_id_t) mp->DL_GRANT; iovp->iod_iovec_offset = 0; totalsize = size = de_calc_iov_size(iovp); if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE) diff --git a/drivers/dpeth/dp.c b/drivers/dpeth/dp.c index 8cf1c6fb8..b6940063f 100644 --- a/drivers/dpeth/dp.c +++ b/drivers/dpeth/dp.c @@ -416,7 +416,7 @@ static void do_vwrite_s(message * mp) get_userdata_s(mp->DL_PROC, mp->DL_GRANT, 0, mp->DL_COUNT, dep->de_write_iovec.iod_iovec); dep->de_write_iovec.iod_iovec_s = mp->DL_COUNT; - dep->de_write_iovec.iod_grant = (vir_bytes) mp->DL_GRANT; + dep->de_write_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT; dep->de_write_iovec.iod_iovec_offset = 0; size = calc_iovec_size(&dep->de_write_iovec); if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE) @@ -454,10 +454,10 @@ static void do_vread_s(message * mp) panic(dep->de_name, "read already in progress", NO_NUM); dep->de_read_iovec.iod_proc_nr = mp->DL_PROC; - get_userdata_s(mp->DL_PROC, (vir_bytes) mp->DL_GRANT, 0, + get_userdata_s(mp->DL_PROC, (cp_grant_id_t) mp->DL_GRANT, 0, mp->DL_COUNT, dep->de_read_iovec.iod_iovec); dep->de_read_iovec.iod_iovec_s = mp->DL_COUNT; - dep->de_read_iovec.iod_grant = (vir_bytes) mp->DL_GRANT; + dep->de_read_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT; dep->de_read_iovec.iod_iovec_offset = 0; size = calc_iovec_size(&dep->de_read_iovec); if (size < ETH_MAX_PACK_SIZE) panic(dep->de_name, SizeErrMsg, size); diff --git a/drivers/lance/lance.c b/drivers/lance/lance.c index 1ca7b41a7..cfffc5fdf 100644 --- a/drivers/lance/lance.c +++ b/drivers/lance/lance.c @@ -1092,7 +1092,7 @@ static void do_vread_s(message *mp) "do_vread_s: sys_safecopyfrom failed: %d\n", r); ec->read_iovec.iod_iovec_s = count; ec->read_iovec.iod_proc_nr = mp->DL_PROC; - ec->read_iovec.iod_grant = (vir_bytes) mp->DL_GRANT; + ec->read_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT; ec->read_iovec.iod_iovec_offset = 0; ec->tmp_iovec = ec->read_iovec; diff --git a/include/minix/safecopies.h b/include/minix/safecopies.h index 477811414..0f237844b 100644 --- a/include/minix/safecopies.h +++ b/include/minix/safecopies.h @@ -6,8 +6,6 @@ #include #include -typedef int32_t cp_grant_id_t; - typedef struct { int cp_flags; /* CPF_* below */ union { diff --git a/include/minix/type.h b/include/minix/type.h index d5a526c3b..f176632d1 100644 --- a/include/minix/type.h +++ b/include/minix/type.h @@ -9,12 +9,16 @@ #include #endif +#include + /* Type definitions. */ typedef unsigned int vir_clicks; /* virtual addr/length in clicks */ typedef unsigned long phys_bytes; /* physical addr/length in bytes */ typedef unsigned int phys_clicks; /* physical addr/length in clicks */ typedef int endpoint_t; /* process identifier */ +typedef int32_t cp_grant_id_t; /* A grant ID. */ + #if (_MINIX_CHIP == _CHIP_INTEL) typedef long unsigned int vir_bytes; /* virtual addresses/lengths in bytes */ #endif @@ -43,7 +47,7 @@ struct far_mem { /* Structure for virtual copying by means of a vector with requests. */ struct vir_addr { - int proc_nr_e; + endpoint_t proc_nr_e; int segment; vir_bytes offset; }; @@ -61,7 +65,7 @@ typedef struct { } iovec_t; typedef struct { - int iov_grant; /* grant ID of an I/O buffer */ + cp_grant_id_t iov_grant; /* grant ID of an I/O buffer */ vir_bytes iov_size; /* sizeof an I/O buffer */ } iovec_s_t;