src/sys/mm/rmem/main.c
/**
 * @brief Handles a write request.
 *
 * @param remote Remote client.
 * @param blknum Number of the target block.
 */
@brief Handles a write request.
@param remote Remote client.
@param blknum Number of the target block.
@brief Handles a write request . @param remote Remote client . @param blknum Number of the target block .
static inline int do_rmem_write(int remote, rpage_t blknum)
{
	int ret = 0;
	rpage_t _blknum;
	rmem_debug("write() nodenum=%d blknum=%x",
		remote,
		blknum
	);
	_blknum = RMEM_BLOCK_NUM(blknum);
	if ((_blknum == RMEM_NULL) || (_blknum >= RMEM_NUM_BLOCKS))
	{
		uprintf("[nanvix][rmem] invalid block number");
		return (-EINVAL);
	}
	if (!bitmap_check_bit(blocks, _blknum))
	{
		uprintf("[nanvix][rmem] bad write block");
		_blknum = 0;
		ret = -EFAULT;
	}
	uassert(kportal_allow(inportal, remote, RMEM_SERVER_PORT_NUM) == 0);
	uassert(
		kportal_read(
			inportal,
			&rmem[_blknum][0],
			RMEM_BLOCK_SIZE
		) == RMEM_BLOCK_SIZE
	);
	return (ret);
}
static inline int do_rmem_write ( int remote , rpage_t blknum ) { int ret = 0 ; rpage_t _blknum ; rmem_debug ( " " , remote , blknum ) ; _blknum = RMEM_BLOCK_NUM ( blknum ) ; if ( ( _blknum == RMEM_NULL ) || ( _blknum >= RMEM_NUM_BLOCKS ) ) { uprintf ( " " ) ; return ( - EINVAL ) ; } if ( ! bitmap_check_bit ( blocks , _blknum ) ) { uprintf ( " " ) ; _blknum = 0 ; ret = - EFAULT ; } uassert ( kportal_allow ( inportal , remote , RMEM_SERVER_PORT_NUM ) == 0 ) ; uassert ( kportal_read ( inportal , & rmem [ _blknum ] [ 0 ] , RMEM_BLOCK_SIZE ) == RMEM_BLOCK_SIZE ) ; return ( ret ) ; }
@brief Handles a write request.
@brief Handles a write request .
/* Invalid block number. */ /*
	 * Bad block number. Drop this read and return
	 * an error. Note that we use the NULL block for this.
	 */