diff --git a/include/minix/com.h b/include/minix/com.h index 160728fef..46242b16e 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -432,14 +432,18 @@ #define IOP_ENDPT m2_l1 /* target endpoint */ /* Field names for _UMAP, _VIRCOPY, _PHYSCOPY. */ -#define CP_SRC_SPACE m5_s1 /* T or D space (stack is also D) */ #define CP_SRC_ENDPT m5_i1 /* process to copy from */ #define CP_SRC_ADDR m5_l1 /* address where data come from */ -#define CP_DST_SPACE m5_s2 /* T or D space (stack is also D) */ #define CP_DST_ENDPT m5_i2 /* process to copy to */ #define CP_DST_ADDR m5_l2 /* address where data go to */ #define CP_NR_BYTES m5_l3 /* number of bytes to copy */ +#define UMAP_SEG m5_s1 + +/* only used for backwards compatability */ +#define CP_SRC_SPACE_OBSOLETE m5_s1 /* T or D space (stack is also D) */ +#define CP_DST_SPACE_OBSOLETE m5_s2 /* T or D space (stack is also D) */ + /* Field names for SYS_VUMAP. */ #define VUMAP_ENDPT m10_i1 /* grant owner, or SELF for local addresses */ #define VUMAP_VADDR m10_l1 /* address of virtual (input) vector */ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 7bd68af2d..90b172934 100644 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -131,19 +131,14 @@ int sys_vtimer(endpoint_t proc_nr, int which, clock_t *newval, clock_t int sys_irqctl(int request, int irq_vec, int policy, int *irq_hook_id); /* Shorthands for sys_vircopy() and sys_physcopy() system calls. */ -#define sys_datacopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \ - sys_vircopy(src_proc, D, src_vir, dst_proc, D, dst_vir, bytes) -#define sys_textcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \ - sys_vircopy(src_proc, T, src_vir, dst_proc, T, dst_vir, bytes) -#define sys_stackcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \ - sys_vircopy(src_proc, S, src_vir, dst_proc, S, dst_vir, bytes) -int sys_vircopy(endpoint_t src_proc, int src_s, vir_bytes src_v, - endpoint_t dst_proc, int dst_seg, vir_bytes dst_vir, phys_bytes bytes); +#define sys_datacopy sys_vircopy +int sys_vircopy(endpoint_t src_proc, vir_bytes src_v, + endpoint_t dst_proc, vir_bytes dst_vir, phys_bytes bytes); #define sys_abscopy(src_phys, dst_phys, bytes) \ - sys_physcopy(NONE, PHYS_SEG, src_phys, NONE, PHYS_SEG, dst_phys, bytes) -int sys_physcopy(endpoint_t src_proc, int src_seg, vir_bytes src_vir, - endpoint_t dst_proc, int dst_seg, vir_bytes dst_vir, phys_bytes bytes); + sys_physcopy(NONE, src_phys, NONE, dst_phys, bytes) +int sys_physcopy(endpoint_t src_proc, vir_bytes src_vir, + endpoint_t dst_proc, vir_bytes dst_vir, phys_bytes bytes); /* Grant-based copy functions. */ diff --git a/kernel/system/do_copy.c b/kernel/system/do_copy.c index 33b7e0c82..2e80c8351 100644 --- a/kernel/system/do_copy.c +++ b/kernel/system/do_copy.c @@ -2,10 +2,8 @@ * m_type: SYS_VIRCOPY, SYS_PHYSCOPY * * The parameters for this kernel call are: - * m5_s1: CP_SRC_SPACE source virtual segment * m5_l1: CP_SRC_ADDR source offset within segment * m5_i1: CP_SRC_ENDPT source process number - * m5_s2: CP_DST_SPACE destination virtual segment * m5_l2: CP_DST_ADDR destination offset within segment * m5_i2: CP_DST_ENDPT destination process number * m5_l3: CP_NR_BYTES number of bytes to copy @@ -28,6 +26,7 @@ int do_copy(struct proc * caller, message * m_ptr) struct vir_addr vir_addr[2]; /* virtual source and destination address */ phys_bytes bytes; /* number of bytes to copy */ int i; + endpoint_t pe; #if 0 if (caller->p_endpoint != PM_PROC_NR && caller->p_endpoint != VFS_PROC_NR && @@ -39,22 +38,20 @@ int do_copy(struct proc * caller, message * m_ptr) { first= 0; printf( -"do_copy: got request from %d (source %d, seg %d, destination %d, seg %d)\n", +"do_copy: got request from %d (source %d, destination %d)\n", caller->p_endpoint, m_ptr->CP_SRC_ENDPT, - m_ptr->CP_SRC_SPACE, - m_ptr->CP_DST_ENDPT, - m_ptr->CP_DST_SPACE); + m_ptr->CP_DST_ENDPT); } } #endif /* Dismember the command message. */ - vir_addr[_SRC_].proc_nr_e = m_ptr->CP_SRC_ENDPT; - vir_addr[_SRC_].segment = m_ptr->CP_SRC_SPACE; + pe = vir_addr[_SRC_].proc_nr_e = m_ptr->CP_SRC_ENDPT; + vir_addr[_SRC_].segment = (pe == NONE ? PHYS_SEG : D); vir_addr[_SRC_].offset = (vir_bytes) m_ptr->CP_SRC_ADDR; - vir_addr[_DST_].proc_nr_e = m_ptr->CP_DST_ENDPT; - vir_addr[_DST_].segment = m_ptr->CP_DST_SPACE; + pe = vir_addr[_DST_].proc_nr_e = m_ptr->CP_DST_ENDPT; + vir_addr[_DST_].segment = (pe == NONE ? PHYS_SEG : D); vir_addr[_DST_].offset = (vir_bytes) m_ptr->CP_DST_ADDR; bytes = (phys_bytes) m_ptr->CP_NR_BYTES; diff --git a/kernel/system/do_umap.c b/kernel/system/do_umap.c index 89378158c..32c1ff3a8 100755 --- a/kernel/system/do_umap.c +++ b/kernel/system/do_umap.c @@ -3,7 +3,7 @@ * * The parameters for this kernel call are: * m5_i1: CP_SRC_PROC_NR (process number) - * m5_s1: CP_SRC_SPACE (segment where address is: T, D, or S) + * m5_s1: UMAP_SEG (segment where address is: T, D, or S) * m5_l1: CP_SRC_ADDR (virtual address) * m5_l2: CP_DST_ADDR (returns physical address) * m5_l3: CP_NR_BYTES (size of datastructure) @@ -24,7 +24,7 @@ *==========================================================================*/ int do_umap(struct proc * caller, message * m_ptr) { - int seg_index = m_ptr->CP_SRC_SPACE & SEGMENT_INDEX; + int seg_index = m_ptr->UMAP_SEG & SEGMENT_INDEX; int endpt = (int) m_ptr->CP_SRC_ENDPT; /* This call is a subset of umap_remote, it allows mapping virtual addresses diff --git a/kernel/system/do_umap_remote.c b/kernel/system/do_umap_remote.c index 5a62d2102..a4ecc64f9 100644 --- a/kernel/system/do_umap_remote.c +++ b/kernel/system/do_umap_remote.c @@ -3,7 +3,7 @@ * * The parameters for this kernel call are: * m5_i1: CP_SRC_PROC_NR (process number) - * m5_s1: CP_SRC_SPACE (segment where address is: T, D, or S) + * m5_s1: UMAP_SEG (segment where address is: T, D, or S) * m5_l1: CP_SRC_ADDR (virtual address) * m5_i2: CP_DST_ENDPT (process number of grantee to check access for) * m5_l2: CP_DST_ADDR (returns physical address) @@ -26,8 +26,8 @@ int do_umap_remote(struct proc * caller, message * m_ptr) { /* Map virtual address to physical, for non-kernel processes. */ - int seg_type = m_ptr->CP_SRC_SPACE & SEGMENT_TYPE; - int seg_index = m_ptr->CP_SRC_SPACE & SEGMENT_INDEX; + int seg_type = m_ptr->UMAP_SEG & SEGMENT_TYPE; + int seg_index = m_ptr->UMAP_SEG & SEGMENT_INDEX; vir_bytes offset = m_ptr->CP_SRC_ADDR; int count = m_ptr->CP_NR_BYTES; int endpt = (int) m_ptr->CP_SRC_ENDPT; diff --git a/lib/libsys/sys_physcopy.c b/lib/libsys/sys_physcopy.c index c678b67de..9c1dab179 100644 --- a/lib/libsys/sys_physcopy.c +++ b/lib/libsys/sys_physcopy.c @@ -1,12 +1,9 @@ #include "syslib.h" -int sys_physcopy(src_proc, src_seg, src_vir, - dst_proc, dst_seg, dst_vir, bytes) +int sys_physcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) endpoint_t src_proc; /* source process */ -int src_seg; /* source memory segment */ vir_bytes src_vir; /* source virtual address */ endpoint_t dst_proc; /* destination process */ -int dst_seg; /* destination memory segment */ vir_bytes dst_vir; /* destination virtual address */ phys_bytes bytes; /* how many bytes */ { @@ -20,11 +17,16 @@ phys_bytes bytes; /* how many bytes */ if (bytes == 0L) return(OK); copy_mess.CP_SRC_ENDPT = src_proc; - copy_mess.CP_SRC_SPACE = src_seg; copy_mess.CP_SRC_ADDR = (long) src_vir; copy_mess.CP_DST_ENDPT = dst_proc; - copy_mess.CP_DST_SPACE = dst_seg; copy_mess.CP_DST_ADDR = (long) dst_vir; copy_mess.CP_NR_BYTES = (long) bytes; + + /* provide backwards compatability arguments to old + * kernels based on process id's; NONE <=> physical + */ + copy_mess.CP_DST_SPACE_OBSOLETE = (dst_proc == NONE ? PHYS_SEG : D); + copy_mess.CP_SRC_SPACE_OBSOLETE = (src_proc == NONE ? PHYS_SEG : D); + return(_kernel_call(SYS_PHYSCOPY, ©_mess)); } diff --git a/lib/libsys/sys_umap.c b/lib/libsys/sys_umap.c index 66b9c9a59..e2e3ce467 100644 --- a/lib/libsys/sys_umap.c +++ b/lib/libsys/sys_umap.c @@ -14,7 +14,7 @@ phys_bytes *phys_addr; /* placeholder for result */ int result; m.CP_SRC_ENDPT = proc_ep; - m.CP_SRC_SPACE = seg; + m.UMAP_SEG = seg; m.CP_SRC_ADDR = vir_addr; m.CP_NR_BYTES = bytes; diff --git a/lib/libsys/sys_umap_remote.c b/lib/libsys/sys_umap_remote.c index dd03c045a..2adda8ec4 100755 --- a/lib/libsys/sys_umap_remote.c +++ b/lib/libsys/sys_umap_remote.c @@ -24,7 +24,7 @@ phys_bytes *phys_addr; /* placeholder for result */ m.CP_SRC_ENDPT = proc_ep; m.CP_DST_ENDPT = grantee; - m.CP_SRC_SPACE = seg; + m.UMAP_SEG = seg; m.CP_SRC_ADDR = vir_addr; m.CP_NR_BYTES = bytes; diff --git a/lib/libsys/sys_vircopy.c b/lib/libsys/sys_vircopy.c index cb9cbb36d..a9e57abb8 100644 --- a/lib/libsys/sys_vircopy.c +++ b/lib/libsys/sys_vircopy.c @@ -1,12 +1,10 @@ #include "syslib.h" -int sys_vircopy(src_proc, src_seg, src_vir, - dst_proc, dst_seg, dst_vir, bytes) +int sys_vircopy(src_proc, src_vir, + dst_proc, dst_vir, bytes) endpoint_t src_proc; /* source process */ -int src_seg; /* source memory segment */ vir_bytes src_vir; /* source virtual address */ endpoint_t dst_proc; /* destination process */ -int dst_seg; /* destination memory segment */ vir_bytes dst_vir; /* destination virtual address */ phys_bytes bytes; /* how many bytes */ { @@ -19,11 +17,14 @@ phys_bytes bytes; /* how many bytes */ if (bytes == 0L) return(OK); copy_mess.CP_SRC_ENDPT = src_proc; - copy_mess.CP_SRC_SPACE = src_seg; copy_mess.CP_SRC_ADDR = (long) src_vir; copy_mess.CP_DST_ENDPT = dst_proc; - copy_mess.CP_DST_SPACE = dst_seg; copy_mess.CP_DST_ADDR = (long) dst_vir; copy_mess.CP_NR_BYTES = (long) bytes; + + /* backwards compatability D segs */ + copy_mess.CP_DST_SPACE_OBSOLETE = D; + copy_mess.CP_SRC_SPACE_OBSOLETE = D; + return(_kernel_call(SYS_VIRCOPY, ©_mess)); } diff --git a/servers/pm/misc.c b/servers/pm/misc.c index c6beef105..705c1088d 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -94,8 +94,8 @@ int do_sysuname() /* Copy an uname string to the user. */ n = strlen(string) + 1; if (n > m_in.sysuname_len) n = m_in.sysuname_len; - r = sys_vircopy(SELF, D, (phys_bytes) string, - mp->mp_endpoint, D, (phys_bytes) m_in.sysuname_value, + r = sys_vircopy(SELF, (phys_bytes) string, + mp->mp_endpoint, (phys_bytes) m_in.sysuname_value, (phys_bytes) n); if (r < 0) return(r); break; @@ -107,8 +107,8 @@ int do_sysuname() if (mp->mp_effuid != 0 || len == 0) return(EPERM); n = len < m_in.sysuname_len ? len : m_in.sysuname_len; if (n <= 0) return(EINVAL); - r = sys_vircopy(mp->mp_endpoint, D, (phys_bytes) m_in.sysuname_value, - SELF, D, (phys_bytes) tmp, (phys_bytes) n); + r = sys_vircopy(mp->mp_endpoint, (phys_bytes) m_in.sysuname_value, + SELF, (phys_bytes) tmp, (phys_bytes) n); if (r < 0) return(r); tmp[n-1] = 0; strcpy(string, tmp); diff --git a/servers/pm/trace.c b/servers/pm/trace.c index 5d19feedd..522a401f0 100644 --- a/servers/pm/trace.c +++ b/servers/pm/trace.c @@ -41,7 +41,7 @@ int do_trace() { register struct mproc *child; struct ptrace_range pr; - int i, r, seg, req; + int i, r, req; message m; req = m_in.request; @@ -190,14 +190,13 @@ int do_trace() if (pr.pr_space != TS_INS && pr.pr_space != TS_DATA) return(EINVAL); if (pr.pr_size == 0 || pr.pr_size > LONG_MAX) return(EINVAL); - seg = (pr.pr_space == TS_INS) ? T : D; if (req == T_GETRANGE) - r = sys_vircopy(child->mp_endpoint, seg, (vir_bytes) pr.pr_addr, - who_e, D, (vir_bytes) pr.pr_ptr, + r = sys_vircopy(child->mp_endpoint, (vir_bytes) pr.pr_addr, + who_e, (vir_bytes) pr.pr_ptr, (phys_bytes) pr.pr_size); else - r = sys_vircopy(who_e, D, (vir_bytes) pr.pr_ptr, - child->mp_endpoint, seg, (vir_bytes) pr.pr_addr, + r = sys_vircopy(who_e, (vir_bytes) pr.pr_ptr, + child->mp_endpoint, (vir_bytes) pr.pr_addr, (phys_bytes) pr.pr_size); if (r != OK) return(r); diff --git a/servers/rs/exec.c b/servers/rs/exec.c index 1a9cbadfa..1c3117c92 100644 --- a/servers/rs/exec.c +++ b/servers/rs/exec.c @@ -202,8 +202,8 @@ size_t seg_bytes /* how much is to be transferred? */ int r; if (off+seg_bytes > execi->hdr_len) return ENOEXEC; - if((r= sys_vircopy(SELF, D, ((vir_bytes)execi->hdr)+off, - execi->proc_e, D, seg_addr, seg_bytes)) != OK) { + if((r= sys_vircopy(SELF, ((vir_bytes)execi->hdr)+off, + execi->proc_e, seg_addr, seg_bytes)) != OK) { printf("RS: exec read_seg: copy 0x%x bytes into %d at 0x%lx failed: %d\n", seg_bytes, execi->proc_e, seg_addr, r); } diff --git a/servers/rs/request.c b/servers/rs/request.c index 54628eac7..3a56e2575 100755 --- a/servers/rs/request.c +++ b/servers/rs/request.c @@ -918,8 +918,8 @@ message *m_ptr; return EINVAL; } - if((r=sys_vircopy(m_ptr->m_source, D, (vir_bytes) m_ptr->RS_NAME, - SELF, D, (vir_bytes) namebuf, len)) != OK) { + if((r=sys_vircopy(m_ptr->m_source, (vir_bytes) m_ptr->RS_NAME, + SELF, (vir_bytes) namebuf, len)) != OK) { printf("RS: name copy failed\n"); return r; diff --git a/servers/vfs/coredump.c b/servers/vfs/coredump.c index 37e24d024..6d484d83d 100644 --- a/servers/vfs/coredump.c +++ b/servers/vfs/coredump.c @@ -304,9 +304,9 @@ static void dump_segments(struct filp *f, Elf_Phdr phdrs[], int phnum) } for (off = 0; off < (off_t) len; off += CLICK_SIZE) { - r = sys_vircopy(fp->fp_endpoint, D, + r = sys_vircopy(fp->fp_endpoint, (vir_bytes) (seg_off + off), - SELF, D, (vir_bytes) buf, + SELF, (vir_bytes) buf, (phys_bytes) CLICK_SIZE); write_buf(f, (char *) buf, (off + CLICK_SIZE <= (off_t) len) ? diff --git a/servers/vfs/dmap.c b/servers/vfs/dmap.c index ed83553e2..347b14de4 100644 --- a/servers/vfs/dmap.c +++ b/servers/vfs/dmap.c @@ -55,7 +55,7 @@ int do_mapdriver() printf("VFS: do_mapdriver: label too long\n"); return(EINVAL); } - r = sys_vircopy(who_e, D, label_vir, SELF, D, (vir_bytes) label, label_len); + r = sys_vircopy(who_e, label_vir, SELF, (vir_bytes) label, label_len); if (r != OK) { printf("VFS: do_mapdriver: sys_vircopy failed: %d\n", r); return(EINVAL); diff --git a/servers/vfs/request.c b/servers/vfs/request.c index c28a75cf8..e39979dea 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -985,7 +985,7 @@ int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf, old_sb.st_ctime = sb.st_ctime; #endif - r = sys_vircopy(SELF, D, (vir_bytes) &old_sb, proc_e, D, buf, + r = sys_vircopy(SELF, (vir_bytes) &old_sb, proc_e, buf, sizeof(struct minix_prev_stat)); return(r); diff --git a/servers/vfs/select.c b/servers/vfs/select.c index c1290fbfc..01d430523 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -123,7 +123,7 @@ int do_select(void) /* Did the process set a timeout value? If so, retrieve it. */ if (vtimeout != 0) { do_timeout = 1; - r = sys_vircopy(who_e, D, (vir_bytes) vtimeout, SELF, D, + r = sys_vircopy(who_e, (vir_bytes) vtimeout, SELF, (vir_bytes) &timeout, sizeof(timeout)); if (r != OK) return(r); } @@ -546,7 +546,7 @@ static int copy_fdsets(struct selectentry *se, int nfds, int direction) src_fds = (direction == FROM_PROC) ? se->vir_readfds : &se->ready_readfds; dst_fds = (direction == FROM_PROC) ? &se->readfds : se->vir_readfds; if (se->vir_readfds) { - r = sys_vircopy(src_e, D, (vir_bytes) src_fds, dst_e, D, + r = sys_vircopy(src_e, (vir_bytes) src_fds, dst_e, (vir_bytes) dst_fds, fd_setsize); if (r != OK) return(r); } @@ -555,7 +555,7 @@ static int copy_fdsets(struct selectentry *se, int nfds, int direction) src_fds = (direction == FROM_PROC) ? se->vir_writefds : &se->ready_writefds; dst_fds = (direction == FROM_PROC) ? &se->writefds : se->vir_writefds; if (se->vir_writefds) { - r = sys_vircopy(src_e, D, (vir_bytes) src_fds, dst_e, D, + r = sys_vircopy(src_e, (vir_bytes) src_fds, dst_e, (vir_bytes) dst_fds, fd_setsize); if (r != OK) return(r); } @@ -564,7 +564,7 @@ static int copy_fdsets(struct selectentry *se, int nfds, int direction) src_fds = (direction == FROM_PROC) ? se->vir_errorfds : &se->ready_errorfds; dst_fds = (direction == FROM_PROC) ? &se->errorfds : se->vir_errorfds; if (se->vir_errorfds) { - r = sys_vircopy(src_e, D, (vir_bytes) src_fds, dst_e, D, + r = sys_vircopy(src_e, (vir_bytes) src_fds, dst_e, (vir_bytes) dst_fds, fd_setsize); if (r != OK) return(r); }