Esempio n. 1
0
errval_t get_core_info(coreid_t core_id, archid_t* apic_id, enum cpu_type* cpu_type)
{
#if  defined(__k1om__)
    size_t step = 4;
    assert(step == 1 || step == 2 || step == 4);

    *apic_id = (core_id * step);
    if (*apic_id == my_arch_id) {
        *apic_id += step;
    }
    *cpu_type = CPU_K1OM;
    return SYS_ERR_OK;
#else
    char* record = NULL;
    errval_t err = oct_get(&record, "hw.processor.%"PRIuCOREID"", core_id);
    if (err_is_fail(err)) {
        goto out;
    }

    uint64_t apic, enabled, type;
    err = oct_read(record, "_ { apic_id: %d, enabled: %d, type: %d}",
                   &apic, &enabled, &type);
    assert (enabled);
    if (err_is_fail(err)) {
        goto out;
    }

    *apic_id = (archid_t) apic;
    *cpu_type = (enum cpu_type) type;
out:
    free(record);
    return err;
#endif
}
Esempio n. 2
0
errval_t oct_sem_trywait(uint32_t id)
{
    errval_t err = SYS_ERR_OK;

    char* result = NULL;

    err = oct_get(&result, "r'sem\\.%d\\.[0-9]+' { sem: %d }", id, id);
    if (err_is_ok(err)) {
        err = oct_del(result);
    }
    else if (err_no(err) == OCT_ERR_NO_RECORD) {
        // Return with no record error to caller
    }

    free(result);
    return err;

}
Esempio n. 3
0
static uint32_t get_next_id(void)
{
    uint64_t id = 0;
    char* lock_record = NULL;
    char* record = NULL;

    // Find a valid ID for our next semaphore

    // This lock makes sure that we don't
    // have concurrent access to sem.ids
    errval_t err = oct_lock("sem.lock", &lock_record);
    assert(err_is_ok(err));

    err = oct_get(&record, "sem.ids { current_id: _ }");
    if (err_is_ok(err)) {
        err = oct_read(record, "_ { current_id: %d }", &id);
        assert(err_is_ok(err));
    }
    else if (err_no(err) == OCT_ERR_NO_RECORD) {
        err = oct_set("sem.ids { current_id: 0 }");
        assert(err_is_ok(err));
    }
    else {
        assert(!"Should not happen.");
    }

    id += 1;

    err = oct_set("sem.ids { current_id: %lu }", id);
    assert(err_is_ok(err));

    err = oct_unlock(lock_record);
    free(lock_record);
    free(record);
    assert(err_is_ok(err));

    return id;
}