kernel: print spurious interrupt message with increasing interval.
[minix.git] / test / safecopy / grantor.c
blob51c700b59511d73cb767e4d4378e259006623cf4
1 #include "inc.h"
3 char buf_buf[BUF_SIZE + CLICK_SIZE];
5 /* SEF functions and variables. */
6 FORWARD _PROTOTYPE( void sef_local_startup, (void) );
8 /*===========================================================================*
9 * main *
10 *===========================================================================*/
11 int main(int argc, char **argv)
13 endpoint_t ep_self, ep_requestor;
14 int fid_send, fid_get;
15 cp_grant_id_t gid;
16 char *buf;
17 int i;
19 /* SEF local startup. */
20 env_setargs(argc, argv);
21 sef_local_startup();
23 /* Prepare work. */
24 buf = (char*) CLICK_CEIL(buf_buf);
25 fid_send = open(FIFO_GRANTOR, O_WRONLY);
26 fid_get = open(FIFO_REQUESTOR, O_RDONLY);
27 if(fid_get < 0 || fid_send < 0) {
28 printf("GRANTOR: can't open fifo files.\n");
29 return 1;
31 buf[0] = BUF_START;
33 /* Get the requestor's endpoint. */
34 read(fid_get, &ep_requestor, sizeof(ep_requestor));
35 dprint("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor);
37 /* Grant. */
38 gid = cpf_grant_direct(ep_requestor, (long)buf, BUF_SIZE,
39 CPF_READ | CPF_WRITE);
40 ep_self = getprocnr();
41 dprint("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid);
42 write(fid_send, &ep_self, sizeof(ep_self));
43 write(fid_send, &gid, sizeof(gid));
45 /* Wait till requestor is done. */
46 FIFO_WAIT(fid_get);
48 return 0;
51 /*===========================================================================*
52 * sef_local_startup *
53 *===========================================================================*/
54 PRIVATE void sef_local_startup()
56 /* Let SEF perform startup. */
57 sef_startup();