1 /* System Information Service.
2 * This service handles the various debugging dumps, such as the process
3 * table, so that these no longer directly touch kernel memory. Instead, the
4 * system task is asked to copy some table in local memory.
7 * Apr 29, 2004 by Jorrit N. Herder
11 #include <minix/endpoint.h>
13 /* Allocate space for the global variables. */
14 static message m_in
; /* the input message itself */
15 static message m_out
; /* the output message used for reply */
16 static endpoint_t who_e
; /* caller's proc number */
17 static int callnr
; /* system call number */
19 /* Declare some local functions. */
20 static void get_work(void);
21 static void reply(int whom
, int result
);
23 /* SEF functions and variables. */
24 static void sef_local_startup(void);
25 static int sef_cb_init_fresh(int type
, sef_init_info_t
*info
);
26 static void sef_cb_signal_handler(int signo
);
28 /*===========================================================================*
30 *===========================================================================*/
31 int main(int argc
, char **argv
)
33 /* This is the main routine of this service. The main loop consists of
34 * three major activities: getting new work, processing the work, and
35 * sending the reply. The loop never terminates, unless a panic occurs.
39 /* SEF local startup. */
40 env_setargs(argc
, argv
);
43 /* Main loop - get work and do it, forever. */
45 /* Wait for incoming message, sets 'callnr' and 'who'. */
48 if (is_notify(callnr
)) {
49 switch (_ENDPOINT_P(who_e
)) {
51 result
= do_fkey_pressed(&m_in
);
54 /* FIXME: error message. */
60 printf("IS: warning, got illegal request %d from %d\n",
61 callnr
, m_in
.m_source
);
65 /* Finally send reply message, unless disabled. */
66 if (result
!= EDONTREPLY
) {
70 return(OK
); /* shouldn't come here */
73 /*===========================================================================*
75 *===========================================================================*/
76 static void sef_local_startup()
78 /* Register init callbacks. */
79 sef_setcb_init_fresh(sef_cb_init_fresh
);
80 sef_setcb_init_lu(sef_cb_init_fresh
);
81 sef_setcb_init_restart(sef_cb_init_fresh
);
83 /* Register live update callbacks. */
84 sef_setcb_lu_prepare(sef_cb_lu_prepare_always_ready
);
85 sef_setcb_lu_state_isvalid(sef_cb_lu_state_isvalid_standard
);
87 /* Register signal callbacks. */
88 sef_setcb_signal_handler(sef_cb_signal_handler
);
90 /* Let SEF perform startup. */
94 /*===========================================================================*
96 *===========================================================================*/
97 static int sef_cb_init_fresh(int UNUSED(type
), sef_init_info_t
*UNUSED(info
))
99 /* Initialize the information server. */
101 /* Set key mappings. */
102 map_unmap_fkeys(TRUE
/*map*/);
107 /*===========================================================================*
108 * sef_cb_signal_handler *
109 *===========================================================================*/
110 static void sef_cb_signal_handler(int signo
)
112 /* Only check for termination signal, ignore anything else. */
113 if (signo
!= SIGTERM
) return;
115 /* Shutting down. Unset key mappings, and quit. */
116 map_unmap_fkeys(FALSE
/*map*/);
121 /*===========================================================================*
123 *===========================================================================*/
124 static void get_work()
127 status
= sef_receive(ANY
, &m_in
); /* this blocks until message arrives */
129 panic("sef_receive failed!: %d", status
);
130 who_e
= m_in
.m_source
; /* message arrived! set sender */
131 callnr
= m_in
.m_type
; /* set function call number */
134 /*===========================================================================*
136 *===========================================================================*/
137 static void reply(who
, result
)
138 int who
; /* destination */
139 int result
; /* report result to replyee */
142 m_out
.m_type
= result
; /* build reply message */
143 send_status
= ipc_send(who
, &m_out
); /* send the message */
144 if (OK
!= send_status
)
145 panic("unable to send reply!: %d", send_status
);