static void alloc_shm(size_t sz, uint32_t algo) { TEEC_Result res; in_shm.buffer = NULL; in_shm.size = sz + offset; res = TEEC_AllocateSharedMemory(&ctx, &in_shm); check_res(res, "TEEC_AllocateSharedMemory"); out_shm.buffer = NULL; out_shm.size = hash_size(algo); res = TEEC_AllocateSharedMemory(&ctx, &out_shm); check_res(res, "TEEC_AllocateSharedMemory"); }
int main() { TEEC_Context context; TEEC_Result ret; TEEC_SharedMemory shared_mem; printf("Starting\n"); ret = TEEC_InitializeContext(NULL, &context); if (ret != TEEC_SUCCESS) printf("Error Connecting to the daemon: 0x%x\n", ret); shared_mem.size = 1024; shared_mem.flags = TEEC_MEM_INPUT | TEEC_MEM_INPUT; ret = TEEC_AllocateSharedMemory(&context, &shared_mem); if (ret != TEEC_SUCCESS) { printf("Error allocating memory: 0x%x\n", ret); printf("Error is %s: %d\n", strerror(errno), errno); } printf("Session entering while loop\n"); (void)fflush(stdout); TEEC_ReleaseSharedMemory(&shared_mem); while (1) { } return 0; }
int verify_start_modem(void *access_mem_start, size_t shared_mem_size, size_t access_private_mem_size, struct access_image_descr *access_image_descr) { int ret = 0; TEEC_Result teec_ret = TEEC_ERROR_GENERIC; TEEC_Context ctx; TEEC_SharedMemory shm; TEEC_ErrorOrigin org; TEEC_Session session; TEEC_Operation operation; TEEC_UUID ta_static_uuid = STATIC_TA_UUID; (void)access_mem_start; (void)shared_mem_size; (void)access_private_mem_size; if (NULL == access_image_descr || NULL == access_image_descr->elf_hdr) { ret = -1; dprintf(ERROR, "NULL pointer error"); goto out; } teec_ret = TEEC_InitializeContext(NULL, &ctx); if (teec_ret != TEEC_SUCCESS) { goto out; } teec_ret = TEEC_OpenSession(&ctx, &session, &ta_static_uuid, TEEC_LOGIN_PUBLIC, NULL, NULL, &org); if (teec_ret != TEEC_SUCCESS) { goto out_finalize; } shm.size = 4; shm.flags = TEEC_MEM_INPUT; teec_ret = TEEC_AllocateSharedMemory(&ctx, &shm); if (teec_ret != TEEC_SUCCESS) { goto out_close; } operation.memRefs[0] = shm; operation.flags = TEEC_MEMREF_0_USED; /* Point to entry. */ *((unsigned int *)shm.buffer) = (uintptr_t)((uint8_t *) access_image_descr->elf_hdr + ELF_ENTRY_OFFSET); teec_ret = TEEC_InvokeCommand(&session, BASS_APP_VERITY_START_MODEM, &operation, &org); if (teec_ret != TEEC_SUCCESS) { goto out_release; } out_release: TEEC_ReleaseSharedMemory(&shm); out_close: TEEC_CloseSession(&session); out_finalize: TEEC_FinalizeContext(&ctx); out: if (teec_ret != TEEC_SUCCESS) { ret = -1; } return ret; }