sha1 unused now.
[minix.git] / servers / vm / asynsend.c
blob19e04194b2fa280850e84af20b0650c7568584fa
2 #define _SYSTEM 1
4 #include <minix/callnr.h>
5 #include <minix/com.h>
6 #include <minix/config.h>
7 #include <minix/const.h>
8 #include <minix/ds.h>
9 #include <minix/endpoint.h>
10 #include <minix/keymap.h>
11 #include <minix/minlib.h>
12 #include <minix/type.h>
13 #include <minix/ipc.h>
14 #include <minix/sysutil.h>
15 #include <minix/syslib.h>
17 #include <errno.h>
18 #include <string.h>
19 #include <env.h>
20 #include <stdio.h>
21 #include <stdlib.h>
23 #include "proto.h"
24 #include "util.h"
26 #define SENDSLOTS _NR_PROCS
28 PRIVATE asynmsg_t msgtable[SENDSLOTS];
29 PRIVATE size_t msgtable_n= SENDSLOTS;
31 PUBLIC int asynsend(dst, mp)
32 endpoint_t dst;
33 message *mp;
35 int i;
36 unsigned flags;
38 /* Find slot in table */
39 for (i= 0; i<msgtable_n; i++)
41 flags= msgtable[i].flags;
42 if ((flags & (AMF_VALID|AMF_DONE)) == (AMF_VALID|AMF_DONE))
44 if (msgtable[i].result != OK)
46 printf(
47 "VM: asynsend: found completed entry %d with error %d\n",
48 i, msgtable[i].result);
50 break;
52 if (flags == AMF_EMPTY)
53 break;
55 if (i >= msgtable_n)
56 vm_panic("asynsend: should resize table", i);
57 msgtable[i].dst= dst;
58 msgtable[i].msg= *mp;
59 msgtable[i].flags= AMF_VALID; /* Has to be last. The kernel
60 * scans this table while we are
61 * sleeping.
64 /* Tell the kernel to rescan the table */
65 return senda(msgtable, msgtable_n);