Example #1
0
void * neon_vfs_fopen_impl (const char * path, const char * mode)
{
    struct neon_handle * handle = handle_init ();

    _DEBUG ("<%p> Trying to open '%s' with neon", (void *) handle, path);

    handle->url = g_strdup (path);

    if (open_handle (handle, 0) != 0)
    {
        _ERROR ("<%p> Could not open URL", (void *) handle);
        handle_free (handle);
        return NULL;
    }

    return handle;
}
Example #2
0
static int __set_new_fd_handle(struct shim_fd_handle ** fdhdl, FDTYPE fd,
                               struct shim_handle * hdl, int flags)
{
    struct shim_fd_handle * new_handle = *fdhdl;

    if (!new_handle) {
        new_handle = malloc(sizeof(struct shim_fd_handle));
        if (!new_handle)
            return -ENOMEM;
        *fdhdl = new_handle;
    }

    new_handle->vfd    = fd;
    new_handle->flags  = flags;
    open_handle(hdl);
    new_handle->handle = hdl;
    return 0;
}
int fpc_init()
{

    ALOGE("INIT FPC TZ APP\n");

    open_handle();

    if (open_handle() < 1) {
        ALOGE("Qseecom Lib Not Open !\n");
        return -1;
    }

    if (device_enable() < 0) {
        ALOGE("Error starting device\n");
        return -1;
    }

    ALOGE("Starting app %s\n", FP_TZAPP_NAME);
    if (mStartApp(&mHandle, FP_TZAPP_PATH, FP_TZAPP_NAME, 1024) < 0) {
        ALOGE("Could not load app : %s\n", FP_TZAPP_NAME);
        return -1;
    }
    ALOGE("TZ App loaded : %s\n", FP_TZAPP_NAME);


    ALOGE("Starting app %s\n", KM_TZAPP_NAME);
    if (mStartApp(&mHdl, KM_TZAPP_PATH, KM_TZAPP_NAME, 1024) < 0) {
        ALOGE("Could not load app : %s\n", KM_TZAPP_NAME);
        return -1;
    }
    ALOGE("TZ App loaded : %s\n", KM_TZAPP_NAME);

    // Start creating one off command to get cert from keymaster
    fpc_send_std_cmd_t *req = (fpc_send_std_cmd_t *) mHdl->ion_sbuffer;
    req->cmd_id = 0x205;
    req->ret_val = 0x02;

    void * send_buf = mHdl->ion_sbuffer;
    void * rec_buf = mHdl->ion_sbuffer + 64;

    if (send_cmd_fn(mHdl, send_buf, 64, rec_buf, 1024-64) < 0) {
        return -1;
    }

    //Send command to keymaster
    fpc_send_std_cmd_t* ret_data = (fpc_send_std_cmd_t*) rec_buf;

    ALOGE("Keymaster Response Code : %u\n", ret_data->ret_val);
    ALOGE("Keymaster Response Length : %u\n", ret_data->length);

    void * data_buff = &ret_data->length + 1;

    if (send_modified_command_to_tz(FPC_SET_INIT_DATA,mHandle,data_buff,ret_data->length) < 0) {
        ALOGE("Error sending data to tz\n");
        return -1;
    }

    if (send_normal_command(FPC_INIT,0,mHandle) != 0) {
        ALOGE("Error sending FPC_INIT to tz\n");
        return -1;
    }

    if (send_normal_command(FPC_GET_INIT_STATE,0,mHandle) != 0) {
        ALOGE("Error sending FPC_GET_INIT_STATE to tz\n");
        return -1;
    }

    if (send_normal_command(FPC_INIT_UNK_1,0,mHandle) != 12) {
        ALOGE("Error sending FPC_INIT_UNK_1 to tz\n");
        return -1;
    }

    if (device_enable() < 0) {
        ALOGE("Error starting device\n");
        return -1;
    }

    if (send_normal_command(FPC_INIT_UNK_2,0,mHandle) != 0) {
        ALOGE("Error sending FPC_INIT_UNK_2 to tz\n");
        return -1;
    }

    int fpc_info = send_normal_command(FPC_INIT_UNK_0,0,mHandle);

    ALOGI("Got device data : %d \n", fpc_info);

    if (device_disable() < 0) {
        ALOGE("Error stopping device\n");
        return -1;
    }

    set_bandwidth_fn(mHandle,true);

    if (send_normal_command(FPC_INIT_NEW_DB,0,mHandle) != 0) {
        ALOGE("Error sending FPC_INIT_NEW_DB to tz\n");
        return -1;
    }

    if (send_normal_command(FPC_SET_FP_STORE,0,mHandle) != 0) {
        ALOGE("Error sending FPC_SET_FP_STORE to tz\n");
        return -1;
    }

    set_bandwidth_fn(mHandle,false);

    return 1;

}