libdriver: allow driver to break out of message loop
This commit is contained in:
parent
da597227ac
commit
20eced94e7
2 changed files with 16 additions and 1 deletions
|
@ -67,6 +67,7 @@ _PROTOTYPE( void driver_announce, (void) );
|
||||||
_PROTOTYPE( int driver_receive, (endpoint_t src, message *m_ptr,
|
_PROTOTYPE( int driver_receive, (endpoint_t src, message *m_ptr,
|
||||||
int *status_ptr) );
|
int *status_ptr) );
|
||||||
_PROTOTYPE( int driver_receive_mq, (message *m_ptr, int *status_ptr) );
|
_PROTOTYPE( int driver_receive_mq, (message *m_ptr, int *status_ptr) );
|
||||||
|
_PROTOTYPE( void driver_terminate, (void) );
|
||||||
_PROTOTYPE( void driver_task, (struct driver *dr, int type) );
|
_PROTOTYPE( void driver_task, (struct driver *dr, int type) );
|
||||||
_PROTOTYPE( int driver_mq_queue, (message *m_ptr, int status) );
|
_PROTOTYPE( int driver_mq_queue, (message *m_ptr, int status) );
|
||||||
_PROTOTYPE( void driver_init_buffer, (void) );
|
_PROTOTYPE( void driver_init_buffer, (void) );
|
||||||
|
|
|
@ -65,6 +65,7 @@ int device_caller;
|
||||||
PRIVATE mq_t *queue_head = NULL;
|
PRIVATE mq_t *queue_head = NULL;
|
||||||
PRIVATE int open_devs[MAX_NR_OPEN_DEVICES];
|
PRIVATE int open_devs[MAX_NR_OPEN_DEVICES];
|
||||||
PRIVATE int next_open_devs_slot = 0;
|
PRIVATE int next_open_devs_slot = 0;
|
||||||
|
PRIVATE int driver_running;
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* clear_open_devs *
|
* clear_open_devs *
|
||||||
|
@ -324,6 +325,17 @@ int *status_ptr;
|
||||||
return driver_receive(ANY, m_ptr, status_ptr);
|
return driver_receive(ANY, m_ptr, status_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*===========================================================================*
|
||||||
|
* driver_terminate *
|
||||||
|
*===========================================================================*/
|
||||||
|
PUBLIC void driver_terminate(void)
|
||||||
|
{
|
||||||
|
/* Break out of the main driver loop after finishing the current request.
|
||||||
|
*/
|
||||||
|
|
||||||
|
driver_running = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* driver_task *
|
* driver_task *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
|
@ -336,10 +348,12 @@ int type; /* Driver type (DRIVER_STD or DRIVER_ASYN) */
|
||||||
int r, proc_nr, ipc_status;
|
int r, proc_nr, ipc_status;
|
||||||
message mess;
|
message mess;
|
||||||
|
|
||||||
|
driver_running = TRUE;
|
||||||
|
|
||||||
/* Here is the main loop of the disk task. It waits for a message, carries
|
/* Here is the main loop of the disk task. It waits for a message, carries
|
||||||
* it out, and sends a reply.
|
* it out, and sends a reply.
|
||||||
*/
|
*/
|
||||||
while (TRUE) {
|
while (driver_running) {
|
||||||
if ((r=driver_receive_mq(&mess, &ipc_status)) != OK)
|
if ((r=driver_receive_mq(&mess, &ipc_status)) != OK)
|
||||||
panic("driver_receive_mq failed: %d", r);
|
panic("driver_receive_mq failed: %d", r);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue