Example #1
0
void init_epc(int nepc) {
    g_num_epc = nepc;

    //toward making g_num_epc configurable
    //g_epc = memalign(PAGE_SIZE, g_num_epc * sizeof(epc_t));

    g_epc = (epc_t *)mmap((void *)EPC_ADDR, g_num_epc * sizeof(epc_t),
                          PROT_READ|PROT_WRITE,
                          MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
    if(g_epc == MAP_FAILED) {
        perror("EPC ALLOC FAIL");
        exit(EXIT_FAILURE);
    }


    sgx_dbg(kern, "g_epc: %p", (void *)g_epc);


    if (!g_epc)
        err(1, "failed to allocate EPC");

    g_epc_info = malloc(g_num_epc * sizeof(epc_info_t));
    if (!g_epc_info)
        err(1, "failed to allocate EPC map in kernel");

    memset(g_epc, 0, g_num_epc * sizeof(epc_t));
    memset(g_epc_info, 0, g_num_epc * sizeof(epc_info_t));
}
Example #2
0
//TODO : fcode_to_str, tp_trampoline should be implemented
static
const char *fcode_to_str(fcode_t_tp fcode)
{
    switch (fcode) {
        case FUNC_UNSET_TP    : return "UNSET";
        case FUNC_GMTIME   : return "GMTIME";
        case FUNC_DEBUG       : return "DEBUG";
        case FUNC_PRINT_BYTES : return "PRINT_BYTES";
        default:
        {
            sgx_dbg(err, "unknown function code (%d)", fcode);
                assert(false);
        }
    }
}
Example #3
0
static
const char *epc_bitmap_to_str(epc_type_t type)
{
    switch (type) {
        case FREE_PAGE: return "FREE";
        case SECS_PAGE: return "SECS";
        case TCS_PAGE : return "TCS ";
        case REG_PAGE : return "REG ";
        case RESERVED : return "RERV";
        default:
        {
            sgx_dbg(err, "unknown epc page type (%d)", type);
	        assert(false);
        }
    }
}