3 * \brief Contains helper functions for clients of the interrupt routing service
7 * Copyright (c) 2009, 2010, 2012, ETH Zurich.
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
17 #include <barrelfish/barrelfish.h>
18 #include <barrelfish/nameservice_client.h>
19 #include <skb/skb.h> // read list
20 #include <int_route/int_route_client.h>
21 #include <int_route/int_route_debug.h>
23 #include <if/int_route_service_defs.h>
24 //#include <if/int_route_service_rpcclient_defs.h>
26 static struct int_route_state {
28 struct int_route_rpc_client * client;
29 struct int_route_service_binding * binding;
34 static struct int_route_state * get_int_route_state(void){
35 return &int_route_state_st;
38 static void bind_cb(void *st, errval_t binderr, struct int_route_service_binding *b) {
39 assert(err_is_ok(binderr));
40 get_int_route_state()->binding = b;
43 //errval_t int_route_add_controller(int bus, int dev, int fun,
44 // int_route_service_controller_type_t type) {
45 // struct int_route_service_binding * b = get_int_route_state()->binding;
47 // // int_route_service_pci_address_t addr, int_route_service_controller_type_t type
48 // int_route_service_pci_address_t addr = {.bus = bus, .device = device, .fun = fun}
49 // b->rx_vtbl.add_controller_call(b, addr, type);
53 //errval_t int_route_route(struct capref intin, struct capref dest){
55 // struct int_route_service_binding * b = get_int_route_state()->binding;
57 // return b->tx_vtbl.route_call(b, NULL, intin, dest);
60 errval_t int_route_client_connect(void){
63 struct int_route_state *state = get_int_route_state();
65 /* check if the RPC client already has been initialized */
66 if (state->binding != NULL) {
70 err = nameservice_blocking_lookup("int_route_service", &iref);
71 if (err_is_fail(err)) {
75 state->request_done = false;
76 err = int_route_service_bind(iref, bind_cb, NULL, get_default_waitset(),
77 IDC_BIND_FLAGS_DEFAULT);
78 if (err_is_fail(err)) {
79 return err_push(err, FLOUNDER_ERR_BIND);
82 /* XXX: wait for connection to complete */
83 while (!state->request_done) {
84 messages_wait_and_handle_next();