libdriver: allow driver to break out of message loop

This commit is contained in:
David van Moolenbroek 2010-08-01 22:07:46 +00:00
parent da597227ac
commit 20eced94e7
2 changed files with 16 additions and 1 deletions

View file

@ -67,6 +67,7 @@ _PROTOTYPE( void driver_announce, (void) );
_PROTOTYPE( int driver_receive, (endpoint_t src, 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( int driver_mq_queue, (message *m_ptr, int status) );
_PROTOTYPE( void driver_init_buffer, (void) );

View file

@ -65,6 +65,7 @@ int device_caller;
PRIVATE mq_t *queue_head = NULL;
PRIVATE int open_devs[MAX_NR_OPEN_DEVICES];
PRIVATE int next_open_devs_slot = 0;
PRIVATE int driver_running;
/*===========================================================================*
* clear_open_devs *
@ -324,6 +325,17 @@ int *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 *
*===========================================================================*/
@ -336,10 +348,12 @@ int type; /* Driver type (DRIVER_STD or DRIVER_ASYN) */
int r, proc_nr, ipc_status;
message mess;
driver_running = TRUE;
/* Here is the main loop of the disk task. It waits for a message, carries
* it out, and sends a reply.
*/
while (TRUE) {
while (driver_running) {
if ((r=driver_receive_mq(&mess, &ipc_status)) != OK)
panic("driver_receive_mq failed: %d", r);