Esempio n. 1
0
/** Load the frame that issued the wakeup.
 *
 * The NIC can support only matched_type,  only part of the frame
 * can be available or not at all. Sometimes even the type can be
 * uncertain -- in this case the matched_type contains NIC_WV_NONE.
 *
 * Frame_length can be greater than max_length, but at most max_length
 * bytes will be copied into the frame buffer.
 *
 * Note: Only the type of the filter can be detected, not the concrete
 * filter, because the driver is probably not running when the wakeup
 * is issued.
 *
 * @param[in]  dev_sess
 * @param[out] matched_type Type of the filter that issued wakeup.
 * @param[in]  max_length   Size of the buffer
 * @param[out] frame        Buffer for the frame. Can be NULL.
 * @param[out] frame_length Length of the stored frame. Can be NULL.
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_wol_load_info(async_sess_t *dev_sess, nic_wv_type_t *matched_type,
    size_t max_length, uint8_t *frame, size_t *frame_length)
{
	assert(matched_type);
	
	sysarg_t _matched_type;
	sysarg_t _frame_length;
	
	if (frame == NULL)
		max_length = 0;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	
	int rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_WOL_LOAD_INFO, max_length, &_matched_type, &_frame_length);
	if (rc != EOK) {
		async_exchange_end(exch);
		return rc;
	}
	
	*matched_type = (nic_wv_type_t) _matched_type;
	if (frame_length)
		*frame_length = (size_t) _frame_length;
	
	if ((max_length != 0) && (_frame_length != 0))
		rc = async_data_read_start(exch, frame, max_length);
	
	async_exchange_end(exch);
	return rc;
}
Esempio n. 2
0
/** Retrieve current settings of multicast frames reception.
 *
 * Note: In case of mode != NIC_MULTICAST_LIST the contents of
 * address_list and address_count are undefined.
 *
 * @param[in]  dev_sess
 * @param[out] mode          Current operation mode
 * @param[in]  max_count     Maximal number of addresses that could
 *                           be written into the list buffer.
 * @param[out] address_list  Buffer for the list (array). Can be NULL.
 * @param[out] address_count Number of addresses in the list before
 *                           possible truncation due to the max_count.
 *                           Can be NULL.
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_multicast_get_mode(async_sess_t *dev_sess, nic_multicast_mode_t *mode,
    size_t max_count, nic_address_t *address_list, size_t *address_count)
{
	assert(mode);
	
	sysarg_t _mode;
	
	if (!address_list)
		max_count = 0;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	
	sysarg_t ac;
	int rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_MULTICAST_GET_MODE, max_count, &_mode, &ac);
	if (rc != EOK) {
		async_exchange_end(exch);
		return rc;
	}
	
	*mode = (nic_multicast_mode_t) _mode;
	if (address_count)
		*address_count = (size_t) ac;
	
	if ((max_count) && (ac))
		rc = async_data_read_start(exch, address_list,
		    max_count * sizeof(nic_address_t));
	
	async_exchange_end(exch);
	return rc;
}
Esempio n. 3
0
/**
 * Query audio mixer for item specific info (name and channels count).
 * @param[in] exch IPC exchange connected to the device
 * @param[in] item The control item
 * @param[out] name Control item string identifier.
 * @param[out] channles Number of channels associated with this control item.
 * @return Error code.
 */
int audio_mixer_get_item_info(async_exch_t *exch, unsigned item,
    const char **name, unsigned *levels)
{
	if (!exch)
		return EINVAL;
	sysarg_t name_size, lvls;
	const int ret = async_req_2_2(exch, DEV_IFACE_ID(AUDIO_MIXER_IFACE),
	    IPC_M_AUDIO_MIXER_GET_ITEM_INFO, item, &name_size, &lvls);
	if (ret == EOK && name) {
		char *name_place = calloc(1, name_size);
		if (!name_place) {
			/* Make the other side fail
			 * as it waits for read request */
			async_data_read_start(exch, (void*)-1, 0);
			return ENOMEM;
		}
		const int ret =
		    async_data_read_start(exch, name_place, name_size);
		if (ret != EOK) {
			free(name_place);
			return ret;
		}
		*name = name_place;
	}
	if (ret == EOK && levels)
		*levels = lvls;
	return ret;
}