1 #include "inc.h" 2 3 char buf_buf[BUF_SIZE + CLICK_SIZE]; 4 5 /* SEF functions and variables. */ 6 static void sef_local_startup(void); 7 8 /*===========================================================================* 9 * main * 10 *===========================================================================*/ 11 int main(int argc, char **argv) 12 { 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; 18 19 /* SEF local startup. */ 20 env_setargs(argc, argv); 21 sef_local_startup(); 22 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; 30 } 31 buf[0] = BUF_START; 32 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)); 36 37 /* Grant. */ 38 gid = cpf_grant_direct(ep_requestor, (long)buf, BUF_SIZE, 39 CPF_READ | CPF_WRITE); 40 ep_self = sef_self(); 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)); 44 45 /* Wait till requestor is done. */ 46 FIFO_WAIT(fid_get); 47 48 return 0; 49 } 50 51 /*===========================================================================* 52 * sef_local_startup * 53 *===========================================================================*/ 54 static void sef_local_startup() 55 { 56 /* Let SEF perform startup. */ 57 sef_startup(); 58 } 59 60