Exemplo n.º 1
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "export failed");
    }

    // construct name
    char namebuf[32];
    size_t len = snprintf(namebuf, sizeof(namebuf), "%s.%d", SERVICE_BASENAME,
                          my_core_id);
    assert(len < sizeof(namebuf));
    namebuf[sizeof(namebuf) - 1] = '\0';

    // register this iref with the name service
    err = nameservice_register(namebuf, iref);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "nameservice_register failed");
    }

#if !defined(USE_KALUGA_DVM) || defined(__arm__) || defined(__scc__) || defined(__k1om__)
    // let the master know we are ready
    err = nsb_register_n(my_core_id, SERVICE_BASENAME);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "nsb_register_n failed");
    }

    // wait for boot to finish
    err = nsb_wait(ALL_SPAWNDS_UP);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "failed ns barrier wait for %s", ALL_SPAWNDS_UP);
    }
    // debug_printf("got \"%s\", continuing\n", ALL_SPAWNDS_UP);
#endif
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
 //this is the bootstrap copy of the domain
     if (strcmp(argv[argc - 1], "SpAwNeD") != 0) {
        bsp_datagatherer = true;
    } else {
        bsp_datagatherer = false;
    }

    core_id = disp_get_core_id();
    skb_client_connect();

#ifdef SPAWN_YOUR_SELF
    if (bsp_datagatherer) {
        spawnmyself();
    }
#endif

//gather different types of data

//run cpuid
    gather_cpuid_data(core_id);

//get the number of running cores and their APIC IDs from the monitor
    if (bsp_datagatherer) {
        gather_nr_running_cores(get_monitor_binding());
    } else {
        nr_cores_done = true;
    }

//adding the numer of cores is the last operation performed by the datagatherer.
//therefore the domain can exit after this. process events as long as the number
//of cores has not yet been added to the SKB.
    struct waitset *ws = get_default_waitset();
    while (!nr_cores_done) {
        errval_t err = event_dispatch(ws);
        if (err_is_fail(err)) {
            DEBUG_ERR(err, "in event_dispatch");
            break;
        }
    }

    skb_add_fact("datagatherer_done.");

    if (bsp_datagatherer) {
        int length = nr_of_running_cores + 1;
        while (length != nr_of_running_cores) {
            skb_execute_query("findall(X, datagatherer_done, L),length(L,Len),write(Len).");
            skb_read_output("%d", &length);
            thread_yield();
        }


        errval_t err = nameservice_register("datagatherer_done", 0);
        if (err_is_fail(err)) {
            DEBUG_ERR(err, "nameservice_register failed");
        }
    }
    return 0;
}
Exemplo n.º 3
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    size_t size = 0;
    char *service_name = NULL;
    char *driver_name = (char *) st;

    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "Exporting basic interface failed.\n");
    }

    // build service name as driver_name.SERVICE_SUFFIX
    size = snprintf(NULL, 0, "%s.%s", driver_name, SERVICE_SUFFIX);
    service_name = (char *) malloc(size + 1);
    if (service_name == NULL) {
        USER_PANIC("Error allocating memory.");
    }
    snprintf(service_name, size + 1, "%s.%s", driver_name, SERVICE_SUFFIX);

    SERIAL_DEBUG("About to register basic interface '%s' at nameservice.\n",
                 service_name);

    // register basic serial driver service at nameservice
    err = nameservice_register(service_name, iref);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "Registering basic interface at "
                       "nameserver failed.");
    }

    free(service_name);
}
Exemplo n.º 4
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    assert(err_is_ok(err));
    char name[256];
    snprintf(name, 256, "replay_slave.%u", disp_get_core_id());
    msg("%s:%s() :: === registering %s\n", __FILE__, __FUNCTION__, name);
    err = nameservice_register(name, iref);
    assert(err_is_ok(err));
}
Exemplo n.º 5
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    struct descq_endpoint_state* q = (struct descq_endpoint_state*) st;

    err = nameservice_register(q->name, iref);
    assert(err_is_ok(err));
    q->exp_done = true;
    // state is only function pointers
    DESCQ_DEBUG("Control interface exported (%s)\n", q->name);
}
Exemplo n.º 6
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "export failed");
    }

    err = nameservice_register(service_name, iref);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "nameservice_register failed");
    }
}
Exemplo n.º 7
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "export failed");
    }

    // register this iref with the name service
    err = nameservice_register("server", iref);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "nameservice_register failed");
    }
}
Exemplo n.º 8
0
static void export_cb(void *st, errval_t err, iref_t iref2)
{
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "export failed");
        abort();
    }

    // register this iref with the name service
    err = nameservice_register("multihop_server", iref2);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "nameservice_register failed");
        abort();
    }
}
Exemplo n.º 9
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "export failed");
    }

    printf("bfscope: exported at iref %"PRIuIREF"\n", iref);

    // register this iref with the name service
    err = nameservice_register("bfscope", iref);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "nameservice_register failed");
    }
}
Exemplo n.º 10
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "export failed");
        abort();
    }

    printf("xcorecapserv: service exported at iref %"PRIuIREF"\n", iref);
    fflush(stdout);
    // register this iref with the name service
    err = nameservice_register(my_service_name, iref);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "nameservice_register failed");
        abort();
    }
}
Exemplo n.º 11
0
errval_t dma_service_init(struct xeon_phi *phi)
{
    errval_t err;

    XDMA_DEBUG("Initializing DMA service\n");

    struct waitset *ws = get_default_waitset();

    err = xeon_phi_dma_export(phi,
                              svc_export_cb,
                              svc_connect_cb,
                              ws,
                              IDC_EXPORT_FLAGS_DEFAULT);
    if (err_is_fail(err)) {
        return err;
    }

    XDMAV_DEBUG("Waiting for export...\n");
    while (svc_state == XPM_SVC_STATE_EXPORTING) {
        messages_wait_and_handle_next();
    }

    if (svc_state == XPM_SVC_STATE_EXPORT_FAIL) {
        return FLOUNDER_ERR_BIND;
    }

    svc_state = XPM_SVC_STATE_NS_REGISTERING;

    char buf[50];
#ifdef __k1om__
    snprintf(buf, 50, "%s.%u", XEON_PHI_DMA_SERVICE_NAME, 0);
#else
    snprintf(buf, 50, "%s.%u", XEON_PHI_DMA_SERVICE_NAME, phi->id);
#endif

    XDMA_DEBUG("Registering iref [%u] with name [%s]\n", dma_iref, buf);
    err = nameservice_register(buf, dma_iref);
    if (err_is_fail(err)) {
        svc_state = XPM_SVC_STATE_NS_REGISTER_FAIL;
        return err;
    }

    svc_state = XPM_SVC_STATE_RUNNING;

    return SYS_ERR_OK;

}
Exemplo n.º 12
0
static void export_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "export failed");
        abort();
    }

    // register this iref with the name service
    char my_service_name[128];
    get_service_name(my_service_name, 128, disp_get_core_id());
    err = nameservice_register(my_service_name, iref);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "nameservice_register failed");
        abort();
    }
    exported = true;
}
Exemplo n.º 13
0
static void export_ether_cb(void *st, errval_t err, iref_t iref)
{
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "service [%s] export failed", exported_queue_name);
        abort();
    }

   // ETHERSRV_DEBUG
    printf("service [%s] exported at iref %"PRIu32"\n", exported_queue_name,
           (uint32_t)iref);

    // register this iref with the name service
    err = nameservice_register(exported_queue_name, iref);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "nameservice_register failed for [%s]",
                exported_queue_name);
        abort();
    }
}
Exemplo n.º 14
0
static void _listening(void *st, errval_t err, iref_t iref)
{
    assert(err_is_ok(err));

    /* printf("%s: listening\n", my_name); */

    /* Register the service with the nameserver */
    char serv[100];
    snprintf(serv, sizeof(serv), "%s%d", my_name, my_core_id);

    err = nameservice_register(serv, iref);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "nameservice_register failed");
        abort();
    }

    /* printf("%s: registered '%s'\n", my_name, serv); */

    assert(!request_done);
    request_done = true;
}
Exemplo n.º 15
0
static void run_server(struct mem_thc_service_binding_t *sv)
{
    mem_service_msg_t msg;
    bool loop = true;
  
    // this is the bitmap of messages we are interested in receiving
    struct mem_service_selector selector = {
        .allocate = 1,
        .available = 1,
        .free = 1,
        .steal = 1,
    };

    while (loop) {
        // receive any message
        sv->recv_any(sv, &msg, selector);

        // dispatch it
        switch(msg.msg) {
        case mem_allocate:
            percore_allocate_handler(sv, msg.args.allocate.in.bits,
                                     msg.args.allocate.in.minbase,
                                     msg.args.allocate.in.maxlimit);
            break;
        case mem_steal:
            percore_steal_handler(sv, msg.args.allocate.in.bits,
                                     msg.args.allocate.in.minbase,
                                     msg.args.allocate.in.maxlimit);
            break;
        case mem_available:
            mem_available_handler(sv);
            break;
        case mem_free_monitor:
            percore_free_handler(sv, msg.args.free.in.mem_cap); 
            break;
        default:
            debug_printf("unexpected message: %d\n", msg.msg);
            loop = false;
            break;
        }
    }
}

errval_t percore_mem_serv(coreid_t core, coreid_t *cores, 
                                 int len_cores, memsize_t ram)
{
    errval_t err;

    struct waitset *ws = get_default_waitset();

    // Init the memory allocator 
    err = initialize_percore_mem_serv(core, cores, len_cores, ram);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "initializing percore mem_serv");
        return err;
    }

    struct mem_thc_export_info e_info;
    struct mem_thc_service_binding_t *sv;
    struct mem_binding *b;
    iref_t iref;

    char service_name[NAME_LEN];
    snprintf(service_name, NAME_LEN, "%s.%d", MEMSERV_DIST, core);
    
    //    err = mem_thc_export(&e_info, service_name, ws,
    err = mem_thc_export(&e_info, NULL, ws,
                         IDC_EXPORT_FLAGS_DEFAULT,
                         &iref);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "exporting percore mem interface");
        return err;
    }

    struct monitor_binding *mb = get_monitor_binding();
    err = mb->tx_vtbl. set_mem_iref_request(mb, NOP_CONT, iref);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "setting monitor's percore mem_serv iref");
        return err;
    }

    // explicitly tell spawnd to use us
    err = set_local_spawnd_memserv(core);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "setting spawnd.%d's local memserv", core);
        return err;
    }

    // register only after spawnd's local memserv has been set
    err = nameservice_register(service_name, iref);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "nameservice_register failed");
        return err;
    }
    // let the master know we are ready
    err = nsb_register_n(core, MEMSERV_DIST);
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "nsb_register_n failed");
    }


    do {
    while (true) {

        mem_thc_accept(&e_info, &b);
        if (err_is_fail(err)) {
            DEBUG_ERR(err, "thc accept failed");
            continue;
        }

        sv = malloc(sizeof(struct mem_thc_service_binding_t));
        if (sv == NULL) {
            DEBUG_ERR(LIB_ERR_MALLOC_FAIL, "allocating thc service binding"); 
            continue;
        }

        err = mem_thc_init_service(sv, b, b);
        if (err_is_fail(err)) {
            DEBUG_ERR(err, "thc init failed");
            continue;
        }

        async run_server(sv);

    }
    } finish;

    // should never reach here
    return SYS_ERR_OK;
}