More correctly use vir_bytes.
More correctly use endpoint_t.
*===========================================================================*/
/* These may not be any valid endpoint (see <minix/endpoint.h>). */
-#define ANY 0x7ace /* used to indicate 'any process' */
-#define NONE 0x6ace /* used to indicate 'no process at all' */
-#define SELF 0x8ace /* used to indicate 'own process' */
+#define ANY ((endpoint_t) 0x7ace) /* used to indicate 'any process' */
+#define NONE ((endpoint_t) 0x6ace) /* used to indicate 'no process at all' */
+#define SELF ((endpoint_t) 0x8ace) /* used to indicate 'own process' */
#define _MAX_MAGIC_PROC (SELF) /* used by <minix/endpoint.h>
to determine generation size */
*/
/* Kernel tasks. These all run in the same address space. */
-#define IDLE -4 /* runs when no one else can run */
-#define CLOCK -3 /* alarms and other clock functions */
-#define SYSTEM -2 /* request system functionality */
-#define KERNEL -1 /* pseudo-process for IPC and scheduling */
+#define IDLE ((endpoint_t) -4) /* runs when no one else can run */
+#define CLOCK ((endpoint_t) -3) /* alarms and other clock functions */
+#define SYSTEM ((endpoint_t) -2) /* request system functionality */
+#define KERNEL ((endpoint_t) -1) /* pseudo-process for IPC and scheduling */
#define HARDWARE KERNEL /* for hardware interrupt handlers */
/* Number of tasks. Note that NR_PROCS is defined in <minix/config.h>. */
#define NR_TASKS 4
/* User-space processes, that is, device drivers, servers, and INIT. */
-#define PM_PROC_NR 0 /* process manager */
-#define FS_PROC_NR 1 /* file system */
+#define PM_PROC_NR ((endpoint_t) 0) /* process manager */
+#define FS_PROC_NR ((endpoint_t) 1) /* file system */
#define VFS_PROC_NR FS_PROC_NR /* FS has been renamed to VFS. */
-#define RS_PROC_NR 2 /* reincarnation server */
-#define MEM_PROC_NR 3 /* memory driver (RAM disk, null, etc.) */
-#define LOG_PROC_NR 4 /* log device driver */
-#define TTY_PROC_NR 5 /* terminal (TTY) driver */
-#define DS_PROC_NR 6 /* data store server */
-#define MFS_PROC_NR 7 /* minix root filesystem */
-#define VM_PROC_NR 8 /* memory server */
-#define PFS_PROC_NR 9 /* pipe filesystem */
-#define INIT_PROC_NR 10 /* init -- goes multiuser */
+#define RS_PROC_NR ((endpoint_t) 2) /* reincarnation server */
+#define MEM_PROC_NR ((endpoint_t) 3) /* memory driver (RAM disk, null, etc.) */
+#define LOG_PROC_NR ((endpoint_t) 4) /* log device driver */
+#define TTY_PROC_NR ((endpoint_t) 5) /* terminal (TTY) driver */
+#define DS_PROC_NR ((endpoint_t) 6) /* data store server */
+#define MFS_PROC_NR ((endpoint_t) 7) /* minix root filesystem */
+#define VM_PROC_NR ((endpoint_t) 8) /* memory server */
+#define PFS_PROC_NR ((endpoint_t) 9) /* pipe filesystem */
+#define LAST_SPECIAL_PROC_NR 10 /* An untyped version for
+ computation in macros.*/
+#define INIT_PROC_NR ((endpoint_t) LAST_SPECIAL_PROC_NR) /* init
+ -- goes multiuser */
/* Root system process and root user process. */
#define ROOT_SYS_PROC_NR RS_PROC_NR
#define ROOT_USR_PROC_NR INIT_PROC_NR
/* Number of processes contained in the system image. */
-#define NR_BOOT_PROCS (NR_TASKS + INIT_PROC_NR + 1)
+#define NR_BOOT_PROCS (NR_TASKS + LAST_SPECIAL_PROC_NR + 1)
/*===========================================================================*
* Kernel notification types *
#define VMPTYPE_SUNMAP 4
/* Invalid grant number. */
-#define GRANT_INVALID -1
+#define GRANT_INVALID ((cp_grant_id_t) -1)
#define GRANT_VALID(g) ((g) > GRANT_INVALID)
/* Operations: any combination is ok. */
/* Type definitions. */
typedef struct {
- int rproctab_gid;
+ cp_grant_id_t rproctab_gid;
} sef_init_info_t;
/* Callback type definitions. */
if((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) == _DIO_SAFE) {
/* Map grant address to physical address. */
if(verify_grant(proc_nr_e, caller->p_endpoint,
- (vir_bytes) m_ptr->DIO_VEC_ADDR,
+ (cp_grant_id_t) m_ptr->DIO_VEC_ADDR,
count,
req_dir == _DIO_INPUT ? CPF_WRITE : CPF_READ,
(vir_bytes) m_ptr->DIO_OFFSET,
u32_t phys = 0;
if(seg == MEM_GRANT) {
- return umap_grant(rp, vir_addr, bytes);
+ return umap_grant(rp, (cp_grant_id_t) vir_addr, bytes);
}
if(!(linear = umap_local(rp, seg, vir_addr, bytes))) {
/* Get granter process slot (if valid), and check range of
* grant id.
*/
- if(!isokendpt(granter, &proc_nr) || !GRANT_VALID(grant)) {
+ if(!isokendpt(granter, &proc_nr) ) {
kprintf(
- "grant verify failed: invalid granter or grant\n");
+ "grant verify failed: invalid granter %d\n", (int) granter);
+ return(EINVAL);
+ }
+ if(!GRANT_VALID(grant)) {
+ kprintf(
+ "grant verify failed: invalid grant %d\n", (int) grant);
return(EINVAL);
}
granter_proc = proc_addr(proc_nr);
} else minix_panic("Impossible system call nr. ", m_ptr->m_type);
return safecopy(caller, m_ptr->SCP_FROM_TO, caller->p_endpoint,
- m_ptr->SCP_GID, src_seg, dst_seg, m_ptr->SCP_BYTES,
- m_ptr->SCP_OFFSET, (vir_bytes) m_ptr->SCP_ADDRESS, access);
+ (cp_grant_id_t) m_ptr->SCP_GID, src_seg, dst_seg,
+ m_ptr->SCP_BYTES, m_ptr->SCP_OFFSET,
+ (vir_bytes) m_ptr->SCP_ADDRESS, access);
}
/*===========================================================================*
/* Grantor. */
endpoint_t grantor;
- int gid;
+ cp_grant_id_t gid;
vir_bytes offset;
vir_bytes address_Dseg; /* seg always is D */
/*===========================================================================*
* add_info *
*===========================================================================*/
-static int add_info(endpoint_t grantor, endpoint_t grantee, int gid,
+static int add_info(endpoint_t grantor, endpoint_t grantee, cp_grant_id_t gid,
vir_bytes offset, vir_bytes address_Dseg,
int seg, vir_bytes address, vir_bytes bytes)
{
/*===========================================================================*
* clear_info *
*===========================================================================*/
-static int clear_info(struct map_info_s *p)
+static void clear_info(struct map_info_s *p)
{
p->flag = 0;
-
- return 0;
}
/*===========================================================================*
PUBLIC int do_safemap(struct proc * caller, message * m_ptr)
{
endpoint_t grantor = m_ptr->SMAP_EP;
- cp_grant_id_t gid = m_ptr->SMAP_GID;
+ cp_grant_id_t gid = (cp_grant_id_t) m_ptr->SMAP_GID;
vir_bytes offset = (vir_bytes) m_ptr->SMAP_OFFSET;
int seg = (int) m_ptr->SMAP_SEG;
vir_bytes address = (vir_bytes) m_ptr->SMAP_ADDRESS;
*===========================================================================*/
PUBLIC int do_safeunmap(struct proc * caller, message * m_ptr)
{
- vir_bytes address = m_ptr->SMAP_ADDRESS;
+ vir_bytes address = (vir_bytes) m_ptr->SMAP_ADDRESS;
int seg = (int)m_ptr->SMAP_SEG;
struct map_info_s *p;
int r;
vir_bytes newoffset;
endpoint_t newep;
int new_proc_nr;
+ cp_grant_id_t grant = (cp_grant_id_t) offset;
- if(verify_grant(targetpr->p_endpoint, ANY, offset, count, 0, 0,
+ if(verify_grant(targetpr->p_endpoint, ANY, grant, count, 0, 0,
&newoffset, &newep) != OK) {
- kprintf("SYSTEM: do_umap: verify_grant in %s, grant %d, bytes 0x%lx, failed, caller %s\n", targetpr->p_name, offset, count, caller->p_name);
+ kprintf("SYSTEM: do_umap: verify_grant in %s, grant %d, bytes 0x%lx, failed, caller %s\n",
+ targetpr->p_name, (int) grant, count, caller->p_name);
proc_stacktrace(caller);
return EFAULT;
}
}
/* Copy the memory range. */
- r = sys_safecopyfrom(m_ptr->m_source, m_ptr->DS_VAL, 0,
- (vir_bytes) dsp->u.mem.data, length, D);
+ r = sys_safecopyfrom(m_ptr->m_source, (cp_grant_id_t) m_ptr->DS_VAL,
+ 0, (vir_bytes) dsp->u.mem.data, length, D);
if(r != OK) {
printf("DS: publish: memory map/copy failed from %d: %d\n",
m_ptr->m_source, r);
dsp->u.map.data = (void*) CLICK_CEIL(dsp->u.map.realpointer);
/* Map memory. */
- r = sys_safemap(m_ptr->m_source, m_ptr->DS_VAL, 0,
+ r = sys_safemap(m_ptr->m_source, (cp_grant_id_t) m_ptr->DS_VAL, 0,
(vir_bytes) dsp->u.map.data, length, D, 0);
if(r != OK) {
printf("DS: publish: memory map/copy failed from %d: %d\n",
break;
case DSF_TYPE_MEM:
length = MIN(m_ptr->DS_VAL_LEN, dsp->u.mem.length);
- r = sys_safecopyto(m_ptr->m_source, m_ptr->DS_VAL, 0,
+ r = sys_safecopyto(m_ptr->m_source, (cp_grant_id_t) m_ptr->DS_VAL, 0,
(vir_bytes) dsp->u.mem.data, length, D);
if(r != OK) {
printf("DS: retrieve: copy failed to %d: %d\n",
}
length = MIN(m_ptr->DS_VAL_LEN, dsp->u.map.length);
- r = sys_safecopyto(m_ptr->m_source, m_ptr->DS_VAL, 0,
+ r = sys_safecopyto(m_ptr->m_source,
+ (cp_grant_id_t) m_ptr->DS_VAL, (vir_bytes) 0,
(vir_bytes) data, length, D);
if(r != OK) {
printf("DS: retrieve: copy failed to %d: %d\n",
/* Copy the key name. */
r = sys_safecopyto(m_ptr->m_source,
- (cp_grant_id_t) m_ptr->DS_KEY_GRANT, 0,
+ (cp_grant_id_t) m_ptr->DS_KEY_GRANT, (vir_bytes) 0,
(vir_bytes) dsp->key, strlen(dsp->key) + 1, D);
if(r != OK) {
printf("DS: copy failed from %d: %d\n", m_ptr->m_source, r);
/* Copy the key name. */
r = sys_safecopyto(m_ptr->m_source,
- (cp_grant_id_t) m_ptr->DS_KEY_GRANT, 0,
+ (cp_grant_id_t) m_ptr->DS_KEY_GRANT, (vir_bytes) 0,
(vir_bytes) ds_store[i].key, strlen(ds_store[i].key), D);
if(r != OK) {
printf("DS: check: copy failed from %d: %d\n", m_ptr->m_source, r);