5 #include <minix/config.h>
9 #include <minix/const.h>
10 #include <minix/type.h>
14 #include <minix/syslib.h>
15 #include <minix/sysutil.h>
21 PRIVATE asynmsg_t msgtable
[ASYN_NR
];
22 PRIVATE
int first_slot
= 0, next_slot
= 0;
24 PUBLIC
int asynsend3(dst
, mp
, fl
)
29 int r
, src_ind
, dst_ind
;
32 static int inside
= 0;
35 /* printf() causes asynsend? */
44 for(i
= 0; i
< ASYN_NR
; i
++) {
45 msgtable
[i
].flags
= AMF_EMPTY
;
50 /* Update first_slot */
51 for (; first_slot
< next_slot
; first_slot
++)
53 flags
= msgtable
[first_slot
].flags
;
54 if ((flags
& (AMF_VALID
|AMF_DONE
)) == (AMF_VALID
|AMF_DONE
))
56 if (msgtable
[first_slot
].result
!= OK
)
60 "asynsend: found completed entry %d with error %d\n",
62 msgtable
[first_slot
].result
);
67 if (flags
!= AMF_EMPTY
)
71 if (first_slot
>= next_slot
)
73 /* Reset first_slot and next_slot */
74 next_slot
= first_slot
= 0;
77 if (next_slot
>= ASYN_NR
)
79 /* Tell the kernel to stop processing */
82 panic("asynsend: senda failed: %d", r
);
85 for (src_ind
= first_slot
; src_ind
<next_slot
; src_ind
++)
87 flags
= msgtable
[src_ind
].flags
;
88 if ((flags
& (AMF_VALID
|AMF_DONE
)) ==
91 if (msgtable
[src_ind
].result
!= OK
)
95 "asynsend: found completed entry %d with error %d\n",
97 msgtable
[src_ind
].result
);
102 if (flags
== AMF_EMPTY
)
105 printf("asynsend: copying entry %d to %d\n",
108 if (src_ind
!= dst_ind
)
109 msgtable
[dst_ind
]= msgtable
[src_ind
];
114 if (next_slot
>= ASYN_NR
)
115 panic("asynsend: msgtable full");
119 msgtable
[next_slot
].dst
= dst
;
120 msgtable
[next_slot
].msg
= *mp
;
121 msgtable
[next_slot
].flags
= fl
; /* Has to be last. The kernel
122 * scans this table while we
127 assert(first_slot
< ASYN_NR
);
128 assert(next_slot
>= first_slot
);
129 len
= next_slot
-first_slot
;
130 assert(first_slot
+ len
<= ASYN_NR
);
132 /* Tell the kernel to rescan the table */
133 r
= senda(msgtable
+first_slot
, len
);