FreeBSD/sys/mips/rmi/fmn.c
/*
 * Drain out max_messages for the buckets set in the bucket mask. 
 * Use max_messages = 0 to drain out all messages.
 */
Drain out max_messages for the buckets set in the bucket mask.
Use max_messages = 0 to drain out all messages.
Drain out max_messages for the buckets set in the bucket mask . Use max_messages = 0 to drain out all messages .
uint32_t
xlr_msgring_handler(uint8_t bucket_mask, uint32_t max_messages)
{
	int bucket = 0;
	int size = 0, code = 0, rx_stid = 0;
	struct msgrng_msg msg;
	struct tx_stn_handler *he;
	unsigned int status = 0;
	unsigned long mflags;
	uint32_t n_msgs;
	uint32_t msgbuckets;
	n_msgs = 0;
	mflags = msgrng_access_enable();
	for (;;) {
		msgbuckets = (~msgrng_read_status() >> 24) & bucket_mask;
		if (msgbuckets == 0)
			break;
		for (bucket = 0; bucket < 8; bucket++) {
			if ((msgbuckets & (1 << bucket)) == 0) 
				continue;
			status = message_receive(bucket, &size, &code,
			    &rx_stid, &msg);
			if (status != 0)
				continue;
			n_msgs++;
			he = &msgmap[rx_stid];
			if (he->action == NULL) {
				printf("[%s]: No Handler for message from "
				    "stn_id=%d, bucket=%d, size=%d, msg0=%jx\n",
				    __func__, rx_stid, bucket, size,
				    (uintmax_t)msg.msg0);
			} else {
				msgrng_restore(mflags);
				(*he->action)(bucket, size, code, rx_stid,
				    &msg, he->arg);
				mflags = msgrng_access_enable();
			}
			if (max_messages > 0 && n_msgs >= max_messages)
				goto done;
		}
	}
done:
	msgrng_restore(mflags);
	return (n_msgs);
}
uint32_t xlr_msgring_handler ( uint8_t bucket_mask , uint32_t max_messages ) { int bucket = 0 ; int size = 0 , code = 0 , rx_stid = 0 ; struct msgrng_msg msg ; struct tx_stn_handler * he ; unsigned int status = 0 ; unsigned long mflags ; uint32_t n_msgs ; uint32_t msgbuckets ; n_msgs = 0 ; mflags = msgrng_access_enable ( ) ; for ( ; ; ) { msgbuckets = ( ~ msgrng_read_status ( ) >> 24 ) & bucket_mask ; if ( msgbuckets == 0 ) break ; for ( bucket = 0 ; bucket < 8 ; bucket ++ ) { if ( ( msgbuckets & ( 1 << bucket ) ) == 0 ) continue ; status = message_receive ( bucket , & size , & code , & rx_stid , & msg ) ; if ( status != 0 ) continue ; n_msgs ++ ; he = & msgmap [ rx_stid ] ; if ( he -> action == NULL ) { printf ( " " " \n " , __func__ , rx_stid , bucket , size , ( uintmax_t ) msg . msg0 ) ; } else { msgrng_restore ( mflags ) ; ( * he -> action ) ( bucket , size , code , rx_stid , & msg , he -> arg ) ; mflags = msgrng_access_enable ( ) ; } if ( max_messages > 0 && n_msgs >= max_messages ) goto done ; } } done : msgrng_restore ( mflags ) ; return ( n_msgs ) ; }
Drain out max_messages for the buckets set in the bucket mask.
Drain out max_messages for the buckets set in the bucket mask .
/* all buckets empty, break */ /* empty */