vm: util.S not used currently; leave it out.
[minix.git] / servers / pm / dma.c
blob476006431da694cf1df569c0665e1b61b6193c6a
2 #include "pm.h"
4 #include <minix/com.h>
5 #include <minix/callnr.h>
6 #include <minix/type.h>
7 #include <minix/config.h>
8 #include <minix/vm.h>
9 #include <signal.h>
10 #include <stdlib.h>
11 #include <string.h>
13 #include "mproc.h"
15 /*===========================================================================*
16 * do_adddma *
17 *===========================================================================*/
18 PUBLIC int do_adddma()
20 endpoint_t req_proc_e, target_proc_e;
21 int proc_n, r;
22 phys_bytes base, size;
24 if (mp->mp_effuid != SUPER_USER)
25 return EPERM;
27 req_proc_e= m_in.m_source;
28 target_proc_e= m_in.m2_i1;
29 base= m_in.m2_l1;
30 size= m_in.m2_l2;
32 if((r = vm_adddma(req_proc_e, target_proc_e, base, size)) != OK) {
33 printf("pm:do_adddma: vm_adddma failed (%d)\n", r);
34 return r;
37 /* Find target process */
38 if (pm_isokendpt(target_proc_e, &proc_n) != OK)
40 printf("pm:do_adddma: endpoint %d not found\n", target_proc_e);
41 return EINVAL;
44 return OK;
47 /*===========================================================================*
48 * do_deldma *
49 *===========================================================================*/
50 PUBLIC int do_deldma()
52 endpoint_t req_proc_e, target_proc_e;
53 phys_bytes base, size;
55 if (mp->mp_effuid != SUPER_USER)
56 return EPERM;
58 req_proc_e= m_in.m_source;
59 target_proc_e= m_in.m2_i1;
60 base= m_in.m2_l1;
61 size= m_in.m2_l2;
63 return vm_deldma(req_proc_e, target_proc_e, base, size);
66 /*===========================================================================*
67 * do_getdma *
68 *===========================================================================*/
69 PUBLIC int do_getdma()
71 endpoint_t req_proc_e, proc;
72 int r;
73 phys_bytes base, size;
75 if (mp->mp_effuid != SUPER_USER)
76 return EPERM;
78 req_proc_e= m_in.m_source;
80 if((r=vm_getdma(req_proc_e, &proc, &base, &size)) != OK)
81 return r;
83 printf("pm:do_getdma: setting reply to 0x%lx@0x%lx proc %d\n",
84 size, base, proc);
86 mp->mp_reply.m2_i1= proc;
87 mp->mp_reply.m2_l1= base;
88 mp->mp_reply.m2_l2= size;
90 return OK;