3 PUBLIC
int identifier
= 0x1234;
4 PUBLIC endpoint_t who_e
;
6 PUBLIC endpoint_t SELF_E
;
10 int (*func
)(message
*);
11 int reply
; /* whether the reply action is passed through */
13 { IPC_SHMGET
, do_shmget
, 0 },
14 { IPC_SHMAT
, do_shmat
, 0 },
15 { IPC_SHMDT
, do_shmdt
, 0 },
16 { IPC_SHMCTL
, do_shmctl
, 0 },
17 { IPC_SEMGET
, do_semget
, 0 },
18 { IPC_SEMCTL
, do_semctl
, 0 },
19 { IPC_SEMOP
, do_semop
, 1 },
22 #define SIZE(a) (sizeof(a)/sizeof(a[0]))
26 /* SEF functions and variables. */
27 FORWARD
_PROTOTYPE( void sef_local_startup
, (void) );
28 FORWARD
_PROTOTYPE( int sef_cb_init_fresh
, (int type
, sef_init_info_t
*info
) );
30 PUBLIC
int main(int argc
, char *argv
[])
34 /* SEF local startup. */
35 env_setargs(argc
, argv
);
42 if ((r
= sef_receive(ANY
, &m
)) != OK
)
43 printf("sef_receive failed %d.\n", r
);
48 printf("IPC: get %d from %d\n", call_type
, who_e
);
50 if (call_type
& NOTIFY_MESSAGE
) {
53 /* PM sends a notify() on shutdown,
54 * checkout if there are still IPC keys,
55 * give warning messages.
57 if (!is_sem_nil() || !is_shm_nil())
58 printf("IPC: exit with un-clean states.\n");
61 /* currently, only semaphore needs such information. */
62 sem_process_vm_notify();
65 printf("IPC: ignoring notify() from %d\n",
72 /* dispatch messages */
73 for (i
= 0; i
< SIZE(ipc_calls
); i
++) {
74 if (ipc_calls
[i
].type
== call_type
) {
77 result
= ipc_calls
[i
].func(&m
);
79 if (ipc_calls
[i
].reply
)
84 if(verbose
&& result
!= OK
)
85 printf("IPC: error for %d: %d\n",
88 if ((r
= sendnb(who_e
, &m
)) != OK
)
89 printf("IPC send error %d.\n", r
);
94 if (i
== SIZE(ipc_calls
)) {
95 /* warn and then ignore */
96 printf("IPC unknown call type: %d from %d.\n",
99 update_refcount_and_destroy();
102 /* no way to get here */
106 /*===========================================================================*
107 * sef_local_startup *
108 *===========================================================================*/
109 PRIVATE
void sef_local_startup()
111 /* Register init callbacks. */
112 sef_setcb_init_fresh(sef_cb_init_fresh
);
113 sef_setcb_init_restart(sef_cb_init_fresh
);
115 /* No live update support for now. */
117 /* Let SEF perform startup. */
121 /*===========================================================================*
122 * sef_cb_init_fresh *
123 *===========================================================================*/
124 PRIVATE
int sef_cb_init_fresh(int type
, sef_init_info_t
*info
)
126 /* Initialize the ipc server. */
128 SELF_E
= getprocnr();
131 printf("IPC: self: %d\n", SELF_E
);