예제 #1
0
파일: vbd.c 프로젝트: jvesely/helenos
int vbd_label_delete(vbd_t *vbd, service_id_t sid)
{
	async_exch_t *exch;
	int retval;

	exch = async_exchange_begin(vbd->sess);
	retval = async_req_1_0(exch, VBD_LABEL_DELETE, sid);
	async_exchange_end(exch);

	if (retval != EOK)
		return EIO;

	return EOK;
}
예제 #2
0
파일: vbd.c 프로젝트: jvesely/helenos
int vbd_part_delete(vbd_t *vbd, vbd_part_id_t part)
{
	async_exch_t *exch;
	int retval;

	exch = async_exchange_begin(vbd->sess);
	retval = async_req_1_0(exch, VBD_PART_DELETE, part);
	async_exchange_end(exch);

	if (retval != EOK)
		return EIO;

	return EOK;
}
예제 #3
0
/** Instruct loader to execute the program.
 *
 * Note that this function blocks until the loader actually replies
 * so you cannot expect this function to return if you are debugging
 * the task and its thread is stopped.
 *
 * After using this function, no further operations can be performed
 * on the loader structure and it is deallocated.
 *
 * @param ldr Loader connection structure.
 *
 * @return Zero on success or negative error code.
 *
 */
int loader_run(loader_t *ldr)
{
	async_exch_t *exch = async_exchange_begin(ldr->sess);
	int rc = async_req_0_0(exch, LOADER_RUN);
	async_exchange_end(exch);
	
	if (rc != EOK)
		return rc;
	
	async_hangup(ldr->sess);
	free(ldr);
	
	return EOK;
}
예제 #4
0
파일: led_dev.c 프로젝트: jvesely/helenos
int led_dev_color_set(async_sess_t *sess, pixel_t pixel)
{
	async_exch_t *exch = async_exchange_begin(sess);
	
	aid_t req = async_send_2(exch, DEV_IFACE_ID(LED_DEV_IFACE),
	    LED_DEV_COLOR_SET, (sysarg_t) pixel, NULL);
	
	async_exchange_end(exch);
	
	sysarg_t rc;
	async_wait_for(req, &rc);
	
	return (int) rc;
}
예제 #5
0
sequence_handle_t fb_sequence_create(async_sess_t *sess)
{
    async_exch_t *exch = async_exchange_begin(sess);

    sysarg_t ret;
    int rc = async_req_0_1(exch, FB_SEQUENCE_CREATE, &ret);

    async_exchange_end(exch);

    if (rc != EOK)
        return 0;

    return (sequence_handle_t) ret;
}
예제 #6
0
/** Default handler for IPC methods not handled by DDF.
 *
 * @param fun Device function handling the call.
 * @param icallid Call id.
 * @param icall Call data.
 */
void default_connection_handler(ddf_fun_t *fun,
                                ipc_callid_t icallid, ipc_call_t *icall)
{
    const sysarg_t method = IPC_GET_IMETHOD(*icall);
    xt_kbd_t *kbd = ddf_dev_data_get(ddf_fun_get_dev(fun));

    switch (method) {
    case KBDEV_SET_IND: {
        /* XT keyboards do not support setting mods,
         * assume AT keyboard with Scan Code Set 1 */
        const unsigned mods = IPC_GET_ARG1(*icall);
        const uint8_t status = 0 |
                               ((mods & KM_CAPS_LOCK) ? LI_CAPS : 0) |
                               ((mods & KM_NUM_LOCK) ? LI_NUM : 0) |
                               ((mods & KM_SCROLL_LOCK) ? LI_SCROLL : 0);
        uint8_t cmds[] = { KBD_CMD_SET_LEDS, status };
        async_exch_t *exch = async_exchange_begin(kbd->parent_sess);
        const ssize_t size = chardev_write(exch, cmds, sizeof(cmds));
        async_exchange_end(exch);
        async_answer_0(icallid, size < 0 ? size : EOK);
        break;
    }
    /* This might be ugly but async_callback_receive_start makes no
     * difference for incorrect call and malloc failure. */
    case IPC_M_CONNECT_TO_ME: {
        async_sess_t *sess =
            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
        /* Probably ENOMEM error, try again. */
        if (sess == NULL) {
            ddf_msg(LVL_WARN,
                    "Failed creating callback session");
            async_answer_0(icallid, EAGAIN);
            break;
        }
        if (kbd->client_sess == NULL) {
            kbd->client_sess = sess;
            ddf_msg(LVL_DEBUG, "Set client session");
            async_answer_0(icallid, EOK);
        } else {
            ddf_msg(LVL_ERROR, "Client session already set");
            async_answer_0(icallid, ELIMIT);
        }
        break;
    }
    default:
        ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
        async_answer_0(icallid, EINVAL);
        break;
    }
}
예제 #7
0
파일: vbd.c 프로젝트: jvesely/helenos
int vbd_label_create(vbd_t *vbd, service_id_t sid, label_type_t ltype)
{
	async_exch_t *exch;
	int retval;

	exch = async_exchange_begin(vbd->sess);
	retval = async_req_2_0(exch, VBD_LABEL_CREATE, sid, ltype);
	async_exchange_end(exch);

	if (retval != EOK)
		return EIO;

	return EOK;
}
예제 #8
0
/** Query the current interrupt/poll mode of the NIC
 *
 * @param[in]  dev_sess
 * @param[out] mode     Current poll mode
 * @param[out] period   Period used in periodic polling.
 *                      Can be NULL.
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_poll_get_mode(async_sess_t *dev_sess, nic_poll_mode_t *mode,
    struct timeval *period)
{
	assert(mode);
	
	sysarg_t _mode;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	
	int rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_POLL_GET_MODE, period != NULL, &_mode);
	if (rc != EOK) {
		async_exchange_end(exch);
		return rc;
	}
	
	*mode = (nic_poll_mode_t) _mode;
	
	if (period != NULL)
		rc = async_data_read_start(exch, period, sizeof(struct timeval));
	
	async_exchange_end(exch);
	return rc;
}
예제 #9
0
int bd_get_num_blocks(bd_t *bd, aoff64_t *rnb)
{
	sysarg_t nb_l;
	sysarg_t nb_h;
	async_exch_t *exch = async_exchange_begin(bd->sess);

	int rc = async_req_0_2(exch, BD_GET_NUM_BLOCKS, &nb_l, &nb_h);
	async_exchange_end(exch);

	if (rc != EOK)
		return rc;

	*rnb = (aoff64_t) MERGE_LOUP32(nb_l, nb_h);
	return EOK;
}
예제 #10
0
/** Determine if defective (erroneous) packets are received.
 *
 * @param[in]  dev_sess
 * @param[out] mode     Bitmask specifying allowed errors
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_defective_get_mode(async_sess_t *dev_sess, uint32_t *mode)
{
	assert(mode);
	
	sysarg_t _mode;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_DEFECTIVE_GET_MODE, &_mode);
	async_exchange_end(exch);
	
	*mode = (uint32_t) _mode;
	
	return rc;
}
예제 #11
0
/** Get number of virtues that can be enabled yet.
 *
 * Count: < 0 => Virtue of this type can be never used
 *        = 0 => No more virtues can be enabled
 *        > 0 => #count virtues can be enabled yet
 *
 * @param[in]  dev_sess
 * @param[in]  type     Virtue type
 * @param[out] count    Number of virtues
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_wol_virtue_get_caps(async_sess_t *dev_sess, nic_wv_type_t type,
    int *count)
{
	assert(count);
	
	sysarg_t _count;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	int rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_WOL_VIRTUE_GET_CAPS, (sysarg_t) type, &_count);
	async_exchange_end(exch);
	
	*count = (int) _count;
	return rc;
}
예제 #12
0
/** Request status of the cable (plugged/unplugged)
 *
 * @param[in]  dev_sess
 * @param[out] cable_state Current cable state
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_get_cable_state(async_sess_t *dev_sess, nic_cable_state_t *cable_state)
{
	assert(cable_state);
	
	sysarg_t _cable_state;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_GET_CABLE_STATE, &_cable_state);
	async_exchange_end(exch);
	
	*cable_state = (nic_cable_state_t) _cable_state;
	
	return rc;
}
예제 #13
0
/** Mouse pointer has moved. */
void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy, int dz)
{
	async_exch_t *exch = async_exchange_begin(client_sess);
	if (dx || dy)
		async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
	if (dz) {
		// TODO: Implement proper wheel support
		keycode_t code = dz > 0 ? KC_UP : KC_DOWN;
		for (int i = 0; i < 3; ++i) {
			async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0);
		}
		async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0);
	}
	async_exchange_end(exch);
}
예제 #14
0
int inet_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local)
{
	sysarg_t local_addr;
	async_exch_t *exch = async_exchange_begin(inet_sess);

	int rc = async_req_2_1(exch, INET_GET_SRCADDR, remote->ipv4,
	    tos, &local_addr);
	async_exchange_end(exch);

	if (rc != EOK)
		return rc;

	local->ipv4 = local_addr;
	return EOK;
}
예제 #15
0
/** Determine if broadcast packets are received.
 *
 * @param[in]  dev_sess
 * @param[out] mode     Current operation mode
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_broadcast_get_mode(async_sess_t *dev_sess, nic_broadcast_mode_t *mode)
{
	assert(mode);
	
	sysarg_t _mode;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_BROADCAST_GET_MODE, &_mode);
	async_exchange_end(exch);
	
	*mode = (nic_broadcast_mode_t) _mode;
	
	return rc;
}
예제 #16
0
파일: udp.c 프로젝트: jvesely/helenos
/** Destroy UDP association.
 *
 * Destroy UDP association. The caller should destroy all associations
 * he created before destroying the UDP client and before terminating.
 *
 * @param assoc UDP association
 */
void udp_assoc_destroy(udp_assoc_t *assoc)
{
	async_exch_t *exch;

	if (assoc == NULL)
		return;

	list_remove(&assoc->ludp);

	exch = async_exchange_begin(assoc->udp->sess);
	sysarg_t rc = async_req_1_0(exch, UDP_ASSOC_DESTROY, assoc->id);
	async_exchange_end(exch);

	free(assoc);
	(void) rc;
}
예제 #17
0
vp_handle_t fb_vp_create(async_sess_t *sess, sysarg_t x, sysarg_t y,
                         sysarg_t width, sysarg_t height)
{
    async_exch_t *exch = async_exchange_begin(sess);

    vp_handle_t handle;
    int ret = async_req_4_1(exch, FB_VP_CREATE, x, y, width, height,
                            &handle);

    async_exchange_end(exch);

    if (ret != EOK)
        return 0;

    return handle;
}
예제 #18
0
static int inet_callback_create(void)
{
	async_exch_t *exch = async_exchange_begin(inet_sess);
	
	ipc_call_t answer;
	aid_t req = async_send_0(exch, INET_CALLBACK_CREATE, &answer);
	int rc = async_connect_to_me(exch, 0, 0, 0, inet_cb_conn, NULL);
	async_exchange_end(exch);
	
	if (rc != EOK)
		return rc;
	
	sysarg_t retval;
	async_wait_for(req, &retval);
	
	return retval;
}
예제 #19
0
/** Set command-line arguments for the program.
 *
 * Sets the vector of command-line arguments to be passed to the loaded
 * program. By convention, the very first argument is typically the same as
 * the command used to execute the program.
 *
 * @param ldr  Loader connection structure.
 * @param argv NULL-terminated array of pointers to arguments.
 *
 * @return Zero on success or negative error code.
 *
 */
int loader_set_args(loader_t *ldr, const char *const argv[])
{
	/*
	 * Serialize the arguments into a single array. First
	 * compute size of the buffer needed.
	 */
	const char *const *ap = argv;
	size_t buffer_size = 0;
	while (*ap != NULL) {
		buffer_size += str_size(*ap) + 1;
		ap++;
	}
	
	char *arg_buf = malloc(buffer_size);
	if (arg_buf == NULL)
		return ENOMEM;
	
	/* Now fill the buffer with null-terminated argument strings */
	ap = argv;
	char *dp = arg_buf;
	
	while (*ap != NULL) {
		str_cpy(dp, buffer_size - (dp - arg_buf), *ap);
		dp += str_size(*ap) + 1;
		ap++;
	}
	
	/* Send serialized arguments to the loader */
	async_exch_t *exch = async_exchange_begin(ldr->sess);
	
	ipc_call_t answer;
	aid_t req = async_send_0(exch, LOADER_SET_ARGS, &answer);
	sysarg_t rc = async_data_write_start(exch, (void *) arg_buf,
	    buffer_size);
	
	async_exchange_end(exch);
	free(arg_buf);
	
	if (rc != EOK) {
		async_forget(req);
		return (int) rc;
	}
	
	async_wait_for(req, &rc);
	return (int) rc;
}
예제 #20
0
static int chardev_port_init(kbd_dev_t *kdev)
{
	service_id_t service_id;
	async_exch_t *exch;
	unsigned int i;
	int rc;
	
	kbd_dev = kdev;
	
	for (i = 0; i < num_devs; i++) {
		rc = loc_service_get_id(in_devs[i], &service_id, 0);
		if (rc == EOK)
			break;
	}
	
	if (i >= num_devs) {
		printf("%s: Could not find any suitable input device\n", NAME);
		return -1;
	}
	
	dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
	    IPC_FLAG_BLOCKING);
	if (dev_sess == NULL) {
		printf("%s: Failed connecting to device\n", NAME);
		return ENOENT;
	}
	
	exch = async_exchange_begin(dev_sess);
	if (exch == NULL) {
		printf("%s: Failed starting exchange with device\n", NAME);
		async_hangup(dev_sess);
		return ENOMEM;
	}
	
	/* NB: The callback connection is slotted for removal */
	rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
	async_exchange_end(exch);
	
	if (rc != 0) {
		printf("%s: Failed to create callback from device\n", NAME);
		async_hangup(dev_sess);
		return -1;
	}
	
	return 0;
}
예제 #21
0
/** Read the current battery status from the device
 *
 * @param sess     Session of the device
 * @param status   Current status of the battery
 *
 * @return         EOK on success or a negative error code
 */
int
battery_status_get(async_sess_t *sess, battery_status_t *batt_status)
{
	sysarg_t status;

	async_exch_t *exch = async_exchange_begin(sess);

	int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
	    BATTERY_STATUS_GET, &status);

	async_exchange_end(exch);

	if (rc == EOK)
		*batt_status = (battery_status_t) status;

	return rc;
}
예제 #22
0
/** Read the current battery charge level from the device
 *
 * @param sess     Session of the device
 * @param level    Battery charge level (0 - 100)
 *
 * @return         EOK on success or a negative error code
 */
int
battery_charge_level_get(async_sess_t *sess, int *level)
{
	sysarg_t charge_level;

	async_exch_t *exch = async_exchange_begin(sess);

	int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
	    BATTERY_CHARGE_LEVEL_GET, &charge_level);

	async_exchange_end(exch);

	if (rc == EOK)
		*level = (int) charge_level;

	return rc;
}
예제 #23
0
static async_exch_t *vp_exchange_begin(async_sess_t *sess, vp_handle_t vp)
{
    vp_handle_t cur_vp = (vp_handle_t) async_remote_state_acquire(sess);
    async_exch_t *exch = async_exchange_begin(sess);

    if (cur_vp != vp) {
        int ret = async_req_1_0(exch, FB_VP_FOCUS, vp);
        if (ret != EOK) {
            async_exchange_end(exch);
            return NULL;
        }

        async_remote_state_update(sess, (void *) vp);
    }

    return exch;
}
예제 #24
0
int ahci_get_block_size(async_sess_t *sess, size_t *blocks_size)
{
	async_exch_t *exch = async_exchange_begin(sess);
	if (!exch)
		return EINVAL;
	
	sysarg_t bs;
	int rc = async_req_1_1(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
	    IPC_M_AHCI_GET_BLOCK_SIZE, &bs);
	
	async_exchange_end(exch);
	
	if (rc == EOK)
		*blocks_size = (size_t) bs;
	
	return rc;
}
예제 #25
0
/** Probe supported options and current setting of offload computations
 *
 * @param[in]  dev_sess
 * @param[out] supported Supported offload options
 * @param[out] active    Currently active offload options
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_offload_probe(async_sess_t *dev_sess, uint32_t *supported,
    uint32_t *active)
{
	assert(supported);
	assert(active);
	
	sysarg_t _supported;
	sysarg_t _active;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	int rc = async_req_1_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_OFFLOAD_PROBE, &_supported, &_active);
	async_exchange_end(exch);
	
	*supported = (uint32_t) _supported;
	*active = (uint32_t) _active;
	return rc;
}
예제 #26
0
/** Set the address of the device (e.g. MAC on Ethernet)
 *
 * @param[in] dev_sess
 * @param[in] address  Pointer to the address
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_set_address(async_sess_t *dev_sess, const nic_address_t *address)
{
	assert(address);
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_SET_ADDRESS, NULL);
	int rc = async_data_write_start(exch, address, sizeof(nic_address_t));
	async_exchange_end(exch);
	
	sysarg_t res;
	async_wait_for(aid, &res);
	
	if (rc != EOK)
		return rc;
	
	return (int) res;
}
예제 #27
0
파일: protocol.c 프로젝트: jvesely/helenos
/**
 * Destroy an existing connection between a source and a sink.
 * @param sess Valid audio session.
 * @param source Source name, valid string.
 * @param sink Sink name, valid string.
 * @return Error code.
 */
int hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source,
    const char *sink)
{
	assert(sess);
	async_exch_t *exch = async_exchange_begin(sess);
	if (!exch)
		return ENOMEM;
	ipc_call_t call;
	aid_t id = async_send_0(exch, IPC_M_HOUND_DISCONNECT, &call);
	int ret = id ? EOK : EPARTY;
	if (ret == EOK)
		ret = async_data_write_start(exch, source, str_size(source));
	if (ret == EOK)
		ret = async_data_write_start(exch, sink, str_size(sink));
	async_wait_for(id, (sysarg_t*)&ret);
	async_exchange_end(exch);
	return ENOTSUP;
}
예제 #28
0
/** Get ID of the new task.
 *
 * Retrieves the ID of the new task from the loader.
 *
 * @param ldr     Loader connection structure.
 * @param task_id Points to a variable where the ID should be stored.
 *
 * @return Zero on success or negative error code.
 *
 */
int loader_get_task_id(loader_t *ldr, task_id_t *task_id)
{
	/* Get task ID. */
	async_exch_t *exch = async_exchange_begin(ldr->sess);
	
	ipc_call_t answer;
	aid_t req = async_send_0(exch, LOADER_GET_TASKID, &answer);
	sysarg_t rc = async_data_read_start(exch, task_id, sizeof(task_id_t));
	
	async_exchange_end(exch);
	
	if (rc != EOK) {
		async_forget(req);
		return (int) rc;
	}
	
	async_wait_for(req, &rc);
	return (int) rc;
}
예제 #29
0
imagemap_handle_t fb_imagemap_create(async_sess_t *sess, imgmap_t *imgmap)
{
    async_exch_t *exch = async_exchange_begin(sess);

    ipc_call_t answer;
    aid_t req = async_send_0(exch, FB_IMAGEMAP_CREATE, &answer);
    int rc = async_share_out_start(exch, imgmap, AS_AREA_READ
                                   | AS_AREA_WRITE | AS_AREA_CACHEABLE);

    async_exchange_end(exch);

    sysarg_t ret;
    async_wait_for(req, &ret);

    if ((rc != EOK) || (ret != EOK))
        return 0;

    return (imagemap_handle_t) IPC_GET_ARG1(answer);
}
예제 #30
0
/** Send frame from NIC
 *
 * @param[in] dev_sess
 * @param[in] data     Frame data
 * @param[in] size     Frame size in bytes
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_send_frame(async_sess_t *dev_sess, void *data, size_t size)
{
	async_exch_t *exch = async_exchange_begin(dev_sess);
	
	ipc_call_t answer;
	aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_SEND_MESSAGE, &answer);
	sysarg_t retval = async_data_write_start(exch, data, size);
	
	async_exchange_end(exch);
	
	if (retval != EOK) {
		async_forget(req);
		return retval;
	}

	async_wait_for(req, &retval);
	return retval;
}