示例#1
0
void nfc_fsm_init(void * queue)
{
    state = ST_OFF;
    fsm_port_id = port_alloc(queue);
    pending_request = NULL;
    port_set_handler(fsm_port_id, nfc_fsm_message_handler, NULL);
}
int cfw_register_service(T_QUEUE queue, service_t * svc,
        handle_msg_cb_t handle_message, void * data) {
    uint16_t port_id = port_alloc(queue);

    cfw_port_set_handler(port_id, handle_message, data);
    svc->port_id = port_id;
    return _cfw_register_service(svc);
}
void _cfw_init(void * queue)
{
    uint16_t port_id = port_alloc(queue);
    port_set_handler(port_id, (void(*)(struct message*, void *))internal_handle_message, NULL );
    service_mgr_port_id = port_id;
#ifdef SVC_MANAGER_DEBUG
    pr_debug(LOG_MODULE_CFW, "%s queue: %p", __func__, queue);
#endif
}
示例#4
0
cfw_client_t *cfw_client_init(void *queue, handle_msg_cb_t cb, void *cb_data)
{
	_cfw_client_t *client = (_cfw_client_t *)balloc(sizeof(*client), NULL);

	client->handle_msg = cb;
	client->data = cb_data;

	list_init(&client->helper_list);

	client->client_port_id = port_alloc(queue);

	cfw_port_set_handler(client->client_port_id, client_handle_message,
			     client);

	return (cfw_client_t *)client;
}
示例#5
0
文件: xc_minios.c 项目: amodj/Utopia
evtchn_port_or_error_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
{
    evtchn_port_t port;
    int i;

    assert(get_current() == main_thread);
    i = port_alloc(xce_handle);
    if (i == -1)
	return -1;

    printf("xc_evtchn_bind_virq(%d)", virq);
    port = bind_virq(virq, evtchn_handler, (void*)(intptr_t)xce_handle);

    if (port < 0) {
	errno = -port;
	return -1;
    }
    files[xce_handle].evtchn.ports[i].bound = 1;
    files[xce_handle].evtchn.ports[i].port = port;
    unmask_evtchn(port);
    return port;
}
示例#6
0
文件: xc_minios.c 项目: amodj/Utopia
evtchn_port_or_error_t xc_evtchn_bind_unbound_port(int xce_handle, int domid)
{
    int ret, i;
    evtchn_port_t port;

    assert(get_current() == main_thread);
    i = port_alloc(xce_handle);
    if (i == -1)
	return -1;

    printf("xc_evtchn_bind_unbound_port(%d)", domid);
    ret = evtchn_alloc_unbound(domid, evtchn_handler, (void*)(intptr_t)xce_handle, &port);
    printf(" = %d\n", ret);

    if (ret < 0) {
	errno = -ret;
	return -1;
    }
    files[xce_handle].evtchn.ports[i].bound = 1;
    files[xce_handle].evtchn.ports[i].port = port;
    unmask_evtchn(port);
    return port;
}
示例#7
0
文件: xc_minios.c 项目: amodj/Utopia
evtchn_port_or_error_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
    evtchn_port_t remote_port)
{
    evtchn_port_t local_port;
    int ret, i;

    assert(get_current() == main_thread);
    i = port_alloc(xce_handle);
    if (i == -1)
	return -1;

    printf("xc_evtchn_bind_interdomain(%d, %"PRId32")", domid, remote_port);
    ret = evtchn_bind_interdomain(domid, remote_port, evtchn_handler, (void*)(intptr_t)xce_handle, &local_port);
    printf(" = %d\n", ret);

    if (ret < 0) {
	errno = -ret;
	return -1;
    }
    files[xce_handle].evtchn.ports[i].bound = 1;
    files[xce_handle].evtchn.ports[i].port = local_port;
    unmask_evtchn(local_port);
    return local_port;
}
示例#8
0
void ipc_async_init(T_QUEUE queue) {
	ipc_port = port_alloc(queue);
	port_set_handler(ipc_port, handle_ipc_request_port, NULL);
	pr_debug(LOG_MODULE_MAIN, "%s: done port: %d", __func__, ipc_port);
}
示例#9
0
/*
 * Test selecting off a port. Uses a timer to change the value on an output port
 * which is looped back to an input port. The input port is set up to event
 * whenever the value changes.
 */
void port_example()
{
  static const int period = 5000;
  select_disable_trigger_all();

  port p;
  port_alloc(&p, port_1A);
  port q;
  port_alloc(&q, port_1B);

  hwtimer_t t;
  hwtimer_alloc(&t);
  uint32_t time;
  hwtimer_get_time(t, &time);
  time += period;

  int q_value = 0;
  port_out(q, q_value);

  // Setup the resources for eventing
  hwtimer_setup_select(t, time, EVENT_TIMER);
  hwtimer_enable_trigger(t);
  port_setup_select(p, EVENT_PORT_P);
  port_set_trigger_in_equal(p, 0x1);
  port_enable_trigger(p);

  for (int count = 0; count < 10; count++) {
    port_event_result_t choice = select_wait();
    switch (choice) {
      case EVENT_TIMER: {
        // Read the timer to clear the event
        uint32_t dummy;
        hwtimer_get_time(t, &dummy);

        // Set up the next timer event
        time += period;
        hwtimer_change_trigger_time(t, time);

        // Toggle the port value
        q_value = !q_value;
        port_out(q, q_value);

        debug_printf("Timer event, drive %d\n", q_value);
        break;
      }

      case EVENT_PORT_P: {
        // Read the port to clear the event
        uint32_t x;
        port_in(p, &x);
        port_set_trigger_in_not_equal(p, x);

        debug_printf("Port event got %d\n", x);
        break;
      }
    }
  }

  // Release the resources
  hwtimer_free(&t);
  port_free(&q);
  port_free(&p);
}