Cut PM out of the adddma/deldma/getdma call path

This commit is contained in:
David van Moolenbroek 2012-01-13 00:23:04 +01:00
parent 8cb7ba7951
commit 2c685f34e0
30 changed files with 36 additions and 398 deletions

View file

@ -101,16 +101,6 @@
#define GETPROCNR 104 /* to PM */
#define ISSETUGID 106 /* to PM: ask if process is tainted */
#define GETEPINFO_O 107 /* to PM: get pid/uid/gid of an endpoint */
#define ADDDMA 108 /* to PM: inform PM about a region of memory
* that is used for bus-master DMA
*/
#define DELDMA 109 /* to PM: inform PM that a region of memory
* that is no longer used for bus-master DMA
*/
#define GETDMA 110 /* to PM: ask PM for a region of memory
* that should not be used for bus-master DMA
* any longer
*/
#define SRV_KILL 111 /* to PM: special kill call for RS */
#define GCOV_FLUSH 112 /* flush gcov data from server to gcov files */

View file

@ -929,7 +929,6 @@
* bus-master DMA
*/
#define VM_ADDDMA (VM_RQ_BASE+12)
# define VMAD_REQ m2_i2
# define VMAD_EP m2_i1
# define VMAD_START m2_l1
# define VMAD_SIZE m2_l2
@ -938,7 +937,6 @@
* used for bus-master DMA
*/
#define VM_DELDMA (VM_RQ_BASE+13)
# define VMDD_REQ m2_i2
# define VMDD_EP m2_i1
# define VMDD_START m2_l1
# define VMDD_SIZE m2_l2
@ -947,7 +945,6 @@
* be used for bus-master DMA any longer
*/
#define VM_GETDMA (VM_RQ_BASE+14)
# define VMGD_REQ m2_i2
# define VMGD_PROCP m2_i1
# define VMGD_BASEP m2_l1
# define VMGD_SIZEP m2_l2

View file

@ -13,12 +13,12 @@ _PROTOTYPE( int vm_exec_newmem, (endpoint_t ep, struct exec_newmem *args,
int args_bytes, char **ret_stack_top, int *ret_flags));
_PROTOTYPE( int vm_push_sig, (endpoint_t ep, vir_bytes *old_sp));
_PROTOTYPE( int vm_willexit, (endpoint_t ep));
_PROTOTYPE( int vm_adddma, (endpoint_t req_e, endpoint_t proc_e,
phys_bytes start, phys_bytes size) );
_PROTOTYPE( int vm_deldma, (endpoint_t req_e, endpoint_t proc_e,
phys_bytes start, phys_bytes size) );
_PROTOTYPE( int vm_getdma, (endpoint_t req_e, endpoint_t *procp,
phys_bytes *basep, phys_bytes *sizep) );
_PROTOTYPE( int vm_adddma, (endpoint_t proc_e, phys_bytes start,
phys_bytes size));
_PROTOTYPE( int vm_deldma, (endpoint_t proc_e, phys_bytes start,
phys_bytes size));
_PROTOTYPE( int vm_getdma, (endpoint_t *procp, phys_bytes *basep,
phys_bytes *sizep));
_PROTOTYPE( void *vm_map_phys, (endpoint_t who, void *physaddr, size_t len));
_PROTOTYPE( int vm_unmap_phys, (endpoint_t who, void *vaddr, size_t len));

View file

@ -168,13 +168,13 @@ PRIVATE void sef_cb_signal_handler(int signo)
for (;;)
{
r= getdma(&proc_e, &base, &size);
r= vm_getdma(&proc_e, &base, &size);
if (r == -1)
{
if (errno != -EAGAIN)
{
printf(
"amddev: getdma failed: %d\n",
"amddev: vm_getdma failed: %d\n",
errno);
}
break;
@ -184,10 +184,10 @@ PRIVATE void sef_cb_signal_handler(int signo)
"amddev: deleting 0x%lx@0x%lx for proc %d\n",
size, base, proc_e);
del_range(base, size);
r= deldma(proc_e, base, size);
r= vm_deldma(proc_e, base, size);
if (r == -1)
{
printf("amddev: deldma failed: %d\n",
printf("amddev: vm_deldma failed: %d\n",
errno);
break;
}
@ -411,13 +411,12 @@ static int do_add4pci(const message *m)
return r;
}
r= adddma(proc, start, size);
r= vm_adddma(proc, start, size);
if (r != 0)
{
r= -errno;
printf(
"amddev`do_add4pci: adddma failed for 0x%x@0x%lx, proc %d: %d\n",
size, start, proc, r);
printf("amddev`do_add4pci: vm_adddma failed for 0x%x@0x%lx, "
"proc %d: %d\n", size, start, proc, r);
return r;
}

View file

@ -60,9 +60,6 @@ service pm
EXEC_NEWMEM # 03
PUSH_SIG # 04
WILLEXIT # 05
ADDDMA # 12
DELDMA # 13
GETDMA # 14
NOTIFY_SIG # 39
;
io NONE; # No I/O range allowed
@ -470,6 +467,11 @@ service amddev
system
UMAP_REMOTE # 17
;
vm
ADDDMA # 12
DELDMA # 13
GETDMA # 14
;
uid 0;
};

View file

@ -190,13 +190,6 @@ _PROTOTYPE( int getpprocnr, (void) );
_PROTOTYPE( int _pm_findproc, (char *proc_name, int *proc_nr) );
_PROTOTYPE( int mapdriver, (char *label, int major, int style,
int flags) );
_PROTOTYPE(int adddma, (endpoint_t proc_e,
phys_bytes start, phys_bytes size) );
_PROTOTYPE(int deldma, (endpoint_t proc_e,
phys_bytes start, phys_bytes size) );
_PROTOTYPE(int getdma, (endpoint_t *procp, phys_bytes *basep,
phys_bytes *sizep) );
_PROTOTYPE( pid_t getnpid, (endpoint_t proc_ep) );
_PROTOTYPE( uid_t getnuid, (endpoint_t proc_ep) );
_PROTOTYPE( gid_t getngid, (endpoint_t proc_ep) );

View file

@ -6,12 +6,9 @@ CPPFLAGS.fsversion.c+=-I${.CURDIR}/../../servers
SRCS+= \
__pm_findproc.c \
_adddma.c \
_brk.c \
_cprofile.c \
_deldma.c \
_getdents.c \
_getdma.c \
_getnpid.c \
_getnucred.c \
_getnuid.c \
@ -30,7 +27,6 @@ SRCS+= \
_sprofile.c \
_svrctl.c \
_sysuname.c \
_vm_dmacalls.c \
_vm_memctl.c \
_vm_set_priv.c \
_vm_update.c \

View file

@ -1,21 +0,0 @@
/* adddma.c
*/
#include <lib.h>
#define adddma _adddma
#include <unistd.h>
#include <stdarg.h>
int adddma(proc_e, start, size)
endpoint_t proc_e;
phys_bytes start;
phys_bytes size;
{
message m;
m.m2_i1= proc_e;
m.m2_l1= start;
m.m2_l2= size;
return _syscall(PM_PROC_NR, ADDDMA, &m);
}

View file

@ -1,21 +0,0 @@
/* deldma.c
*/
#include <lib.h>
#define deldma _deldma
#include <unistd.h>
#include <stdarg.h>
int deldma(proc_e, start, size)
endpoint_t proc_e;
phys_bytes start;
phys_bytes size;
{
message m;
m.m2_i1= proc_e;
m.m2_l1= start;
m.m2_l2= size;
return _syscall(PM_PROC_NR, DELDMA, &m);
}

View file

@ -1,25 +0,0 @@
/* getdma.c
*/
#include <lib.h>
#define getdma _getdma
#include <unistd.h>
#include <stdarg.h>
int getdma(procp, basep, sizep)
endpoint_t *procp;
phys_bytes *basep;
phys_bytes *sizep;
{
int r;
message m;
r= _syscall(PM_PROC_NR, GETDMA, &m);
if (r == 0)
{
*procp= m.m2_i1;
*basep= m.m2_l1;
*sizep= m.m2_l2;
}
return r;
}

View file

@ -1,62 +0,0 @@
#include <lib.h>
#define vm_adddma _vm_adddma
#define vm_deldma _vm_deldma
#define vm_getdma _vm_getdma
#include <minix/vm.h>
#include <unistd.h>
#include <stdarg.h>
int vm_adddma(req_proc_e, proc_e, start, size)
endpoint_t req_proc_e;
endpoint_t proc_e;
phys_bytes start;
phys_bytes size;
{
message m;
m.VMAD_REQ= req_proc_e;
m.VMAD_EP= proc_e;
m.VMAD_START= start;
m.VMAD_SIZE= size;
return _syscall(VM_PROC_NR, VM_ADDDMA, &m);
}
int vm_deldma(req_proc_e, proc_e, start, size)
endpoint_t req_proc_e;
endpoint_t proc_e;
phys_bytes start;
phys_bytes size;
{
message m;
m.VMDD_REQ= proc_e;
m.VMDD_EP= proc_e;
m.VMDD_START= start;
m.VMDD_SIZE= size;
return _syscall(VM_PROC_NR, VM_DELDMA, &m);
}
int vm_getdma(req_proc_e, procp, basep, sizep)
endpoint_t req_proc_e;
endpoint_t *procp;
phys_bytes *basep;
phys_bytes *sizep;
{
int r;
message m;
m.VMGD_REQ = req_proc_e;
r= _syscall(VM_PROC_NR, VM_GETDMA, &m);
if (r == 0)
{
*procp= m.VMGD_PROCP;
*basep= m.VMGD_BASEP;
*sizep= m.VMGD_SIZEP;
}
return r;
}

View file

@ -5,7 +5,6 @@ SRCS+= \
_exit.S \
_pm_findproc.S \
access.S \
adddma.S \
alarm.S \
brk.S \
cfgetispeed.S \
@ -20,7 +19,6 @@ SRCS+= \
closedir.S \
cprofile.S \
creat.S \
deldma.S \
dup.S \
dup2.S \
execl.S \
@ -39,7 +37,6 @@ SRCS+= \
fstatvfs.S \
getcwd.S \
getdents.S \
getdma.S \
getegid.S \
geteuid.S \
getgid.S \
@ -134,7 +131,6 @@ SRCS+= \
uname.S \
unlink.S \
utime.S \
vm_dmacalls.S \
wait.S \
waitpid.S \
write.S

View file

@ -1,6 +0,0 @@
#include <machine/asm.h>
IMPORT(_adddma)
ENTRY(adddma)
jmp _C_LABEL(_adddma)

View file

@ -1,6 +0,0 @@
#include <machine/asm.h>
IMPORT(_deldma)
ENTRY(deldma)
jmp _C_LABEL(_deldma)

View file

@ -1,6 +0,0 @@
#include <machine/asm.h>
IMPORT(_getdma)
ENTRY(getdma)
jmp _C_LABEL(_getdma)

View file

@ -1,14 +0,0 @@
#include <machine/asm.h>
IMPORT(_vm_adddma)
ENTRY(vm_adddma)
jmp _C_LABEL(_vm_adddma)
IMPORT(_vm_deldma)
ENTRY(vm_deldma)
jmp _C_LABEL(_vm_deldma)
IMPORT(_vm_getdma)
ENTRY(vm_getdma)
jmp _C_LABEL(_vm_getdma)

View file

@ -116,6 +116,7 @@ SRCS= \
timing.c \
tsc_util.c \
vm_brk.c \
vm_dmacalls.c \
vm_exec_newmem.c \
vm_exit.c \
vm_fork.c \

View file

@ -4,15 +4,13 @@
#include <unistd.h>
#include <stdarg.h>
int vm_adddma(req_proc_e, proc_e, start, size)
endpoint_t req_proc_e;
int vm_adddma(proc_e, start, size)
endpoint_t proc_e;
phys_bytes start;
phys_bytes size;
{
message m;
m.VMAD_REQ= req_proc_e;
m.VMAD_EP= proc_e;
m.VMAD_START= start;
m.VMAD_SIZE= size;
@ -20,15 +18,13 @@ phys_bytes size;
return _syscall(VM_PROC_NR, VM_ADDDMA, &m);
}
int vm_deldma(req_proc_e, proc_e, start, size)
endpoint_t req_proc_e;
int vm_deldma(proc_e, start, size)
endpoint_t proc_e;
phys_bytes start;
phys_bytes size;
{
message m;
m.VMDD_REQ= proc_e;
m.VMDD_EP= proc_e;
m.VMDD_START= start;
m.VMDD_SIZE= size;
@ -36,8 +32,7 @@ phys_bytes size;
return _syscall(VM_PROC_NR, VM_DELDMA, &m);
}
int vm_getdma(req_proc_e, procp, basep, sizep)
endpoint_t req_proc_e;
int vm_getdma(procp, basep, sizep)
endpoint_t *procp;
phys_bytes *basep;
phys_bytes *sizep;
@ -45,8 +40,6 @@ phys_bytes *sizep;
int r;
message m;
m.VMGD_REQ = req_proc_e;
r= _syscall(VM_PROC_NR, VM_GETDMA, &m);
if (r == 0)
{

View file

@ -26,10 +26,8 @@ SRCS+= servxcheck.c
SRCS+= paramvalue.c
# Minix servers/drivers syscall.
SRCS+= adddma.c getdma.c deldma.c getngid.c getnpid.c \
getnprocnr.c getnucred.c getnuid.c getprocnr.c \
mapdriver.c vm_dmacalls.c vm_memctl.c \
vm_set_priv.c vm_query_exit.c vm_update.c
SRCS+= getngid.c getnpid.c getnprocnr.c getnucred.c getnuid.c getprocnr.c \
mapdriver.c vm_memctl.c vm_set_priv.c vm_query_exit.c vm_update.c
INCS+= tools.h

View file

@ -1,20 +0,0 @@
/* adddma.c
*/
#include <lib.h>
#include <unistd.h>
#include <stdarg.h>
int adddma(proc_e, start, size)
endpoint_t proc_e;
phys_bytes start;
phys_bytes size;
{
message m;
m.m2_i1= proc_e;
m.m2_l1= start;
m.m2_l2= size;
return _syscall(PM_PROC_NR, ADDDMA, &m);
}

View file

@ -1,20 +0,0 @@
/* deldma.c
*/
#include <lib.h>
#include <unistd.h>
#include <stdarg.h>
int deldma(proc_e, start, size)
endpoint_t proc_e;
phys_bytes start;
phys_bytes size;
{
message m;
m.m2_i1= proc_e;
m.m2_l1= start;
m.m2_l2= size;
return _syscall(PM_PROC_NR, DELDMA, &m);
}

View file

@ -1,24 +0,0 @@
/* getdma.c
*/
#include <lib.h>
#include <unistd.h>
#include <stdarg.h>
int getdma(procp, basep, sizep)
endpoint_t *procp;
phys_bytes *basep;
phys_bytes *sizep;
{
int r;
message m;
r= _syscall(PM_PROC_NR, GETDMA, &m);
if (r == 0)
{
*procp= m.m2_i1;
*basep= m.m2_l1;
*sizep= m.m2_l2;
}
return r;
}

View file

@ -315,9 +315,6 @@ int getnprocnr(pid_t pid);
int getpprocnr(void);
int _pm_findproc(char *proc_name, int *proc_nr);
int mapdriver(char *label, int major, int style, int flags);
int adddma(endpoint_t proc_e, phys_bytes start, phys_bytes size);
int deldma(endpoint_t proc_e, phys_bytes start, phys_bytes size);
int getdma(endpoint_t *procp, phys_bytes *basep, phys_bytes *sizep);
pid_t getnpid(endpoint_t proc_ep);
uid_t getnuid(endpoint_t proc_ep);
gid_t getngid(endpoint_t proc_ep);

View file

@ -123,9 +123,9 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
no_sys, /* 105 = unused */
no_sys, /* 106 = unused */
no_sys, /* 107 = (getepinfo) */
no_sys, /* 108 = (adddma) */
no_sys, /* 109 = (deldma) */
no_sys, /* 110 = (getdma) */
no_sys, /* 108 = unused */
no_sys, /* 109 = unused */
no_sys, /* 110 = unused */
no_sys, /* 111 = (srv_kill) */
do_gcov_flush, /* 112 = gcov_flush */
no_sys, /* 113 = (getsid) */

View file

@ -4,7 +4,7 @@
PROG= pm
SRCS= main.c forkexit.c break.c exec.c time.c alarm.c \
signal.c utility.c table.c getset.c misc.c \
profile.c dma.c schedule.c
profile.c schedule.c
.if ${USE_MCONTEXT} != "no"
SRCS+= mcontext.c

View file

@ -1,92 +0,0 @@
#include "pm.h"
#include <minix/com.h>
#include <minix/callnr.h>
#include <minix/type.h>
#include <minix/config.h>
#include <minix/vm.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include "mproc.h"
/*===========================================================================*
* do_adddma *
*===========================================================================*/
PUBLIC int do_adddma()
{
endpoint_t req_proc_e, target_proc_e;
int proc_n, r;
phys_bytes base, size;
if (mp->mp_effuid != SUPER_USER)
return EPERM;
req_proc_e= m_in.m_source;
target_proc_e= m_in.m2_i1;
base= m_in.m2_l1;
size= m_in.m2_l2;
if((r = vm_adddma(req_proc_e, target_proc_e, base, size)) != OK) {
printf("pm:do_adddma: vm_adddma failed (%d)\n", r);
return r;
}
/* Find target process */
if (pm_isokendpt(target_proc_e, &proc_n) != OK)
{
printf("pm:do_adddma: endpoint %d not found\n", target_proc_e);
return EINVAL;
}
return OK;
}
/*===========================================================================*
* do_deldma *
*===========================================================================*/
PUBLIC int do_deldma()
{
endpoint_t req_proc_e, target_proc_e;
phys_bytes base, size;
if (mp->mp_effuid != SUPER_USER)
return EPERM;
req_proc_e= m_in.m_source;
target_proc_e= m_in.m2_i1;
base= m_in.m2_l1;
size= m_in.m2_l2;
return vm_deldma(req_proc_e, target_proc_e, base, size);
}
/*===========================================================================*
* do_getdma *
*===========================================================================*/
PUBLIC int do_getdma()
{
endpoint_t req_proc_e, proc;
int r;
phys_bytes base, size;
if (mp->mp_effuid != SUPER_USER)
return EPERM;
req_proc_e= m_in.m_source;
if((r=vm_getdma(req_proc_e, &proc, &base, &size)) != OK)
return r;
printf("pm:do_getdma: setting reply to 0x%lx@0x%lx proc %d\n",
size, base, proc);
mp->mp_reply.m2_i1= proc;
mp->mp_reply.m2_l1= base;
mp->mp_reply.m2_l2= size;
return OK;
}

View file

@ -16,11 +16,6 @@ _PROTOTYPE( void check_vtimer, (int proc_nr, int sig) );
/* break.c */
_PROTOTYPE( int do_brk, (void) );
/* dma.c */
_PROTOTYPE( int do_adddma, (void) );
_PROTOTYPE( int do_deldma, (void) );
_PROTOTYPE( int do_getdma, (void) );
/* exec.c */
_PROTOTYPE( int do_exec, (void) );
_PROTOTYPE( int do_exec_newmem, (void) );

View file

@ -119,9 +119,9 @@ _PROTOTYPE (int (*call_vec[]), (void) ) = {
no_sys, /* 105 = unused */
do_get, /* 106 = issetugid */
do_getepinfo_o, /* 107 = getepinfo XXX: old implementation*/
do_adddma, /* 108 = adddma */
do_deldma, /* 109 = deldma */
do_getdma, /* 110 = getdma */
no_sys, /* 108 = unused */
no_sys, /* 109 = unused */
no_sys, /* 110 = unused */
do_srv_kill, /* 111 = srv_kill */
no_sys, /* 112 = gcov_flush */
do_get, /* 113 = getsid */

View file

@ -123,9 +123,9 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
no_sys, /* 105 = unused */
no_sys, /* 106 = unused */
no_sys, /* 107 = (getepinfo) */
no_sys, /* 108 = (adddma) */
no_sys, /* 109 = (deldma) */
no_sys, /* 110 = (getdma) */
no_sys, /* 108 = unused */
no_sys, /* 109 = unused */
no_sys, /* 110 = unused */
no_sys, /* 111 = (srv_kill) */
do_gcov_flush, /* 112 = gcov_flush */
no_sys, /* 113 = (getsid) */

View file

@ -622,12 +622,11 @@ PRIVATE struct dmatab
*===========================================================================*/
PUBLIC int do_adddma(message *msg)
{
endpoint_t req_proc_e, target_proc_e;
endpoint_t target_proc_e;
int i, proc_n;
phys_bytes base, size;
struct vmproc *vmp;
req_proc_e= msg->VMAD_REQ;
target_proc_e= msg->VMAD_EP;
base= msg->VMAD_START;
size= msg->VMAD_SIZE;
@ -675,11 +674,10 @@ PUBLIC int do_adddma(message *msg)
*===========================================================================*/
PUBLIC int do_deldma(message *msg)
{
endpoint_t req_proc_e, target_proc_e;
endpoint_t target_proc_e;
int i, j;
phys_bytes base, size;
req_proc_e= msg->VMDD_REQ;
target_proc_e= msg->VMDD_EP;
base= msg->VMDD_START;
size= msg->VMDD_SIZE;