* same with xv6
[mascara-docs.git] / i386 / ucla / src / lab5 / lib / ipc.c
blobfc5a5bd9c056b7d0275081f547e506da480d2797
1 // User-level IPC library routines
3 #include <inc/lib.h>
5 // Receive a value via IPC and return it.
6 // If 'pg' is nonnull, then any page sent by the sender will be mapped at
7 // that address.
8 // If 'from_env_store' is nonnull, then store the IPC sender's envid in
9 // *from_env_store.
10 // If 'perm_store' is nonnull, then store the IPC sender's page permission
11 // in *perm_store (this is nonzero iff a page was successfully
12 // transferred to 'pg').
13 // If the system call fails, then store 0 in *fromenv and *perm (if
14 // they're nonnull) and return the error.
15 // Otherwise, return the value sent by the sender
17 // Hint:
18 // Use 'thisenv' to discover the value and who sent it.
19 // If 'pg' is null, pass sys_ipc_recv a value that it will understand
20 // as meaning "no page". (Zero is not the right value, since that's
21 // a perfectly valid place to map a page.)
22 int32_t
23 ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
25 // LAB 4: Your code here.
26 panic("ipc_recv not implemented");
27 return 0;
30 // Send 'val' (and 'pg' with 'perm', if 'pg' is nonnull) to 'toenv'.
31 // This function keeps trying until it succeeds.
32 // It should panic() on any error other than -E_IPC_NOT_RECV.
34 // Hint:
35 // Use sys_yield() to be CPU-friendly.
36 // If 'pg' is null, pass sys_ipc_recv a value that it will understand
37 // as meaning "no page". (Zero is not the right value.)
38 void
39 ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
41 // LAB 4: Your code here.
42 panic("ipc_send not implemented");