Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

fsl_shw_return_t fsl_shw_deregister_user ( fsl_shw_uco_t user_ctx  ) 

Destroy the association between the the user and the provider of the API.

Parameters:
user_ctx The user context which is no longer needed.
Returns:
A return code of type fsl_shw_return_t.

Definition at line 1595 of file shw_driver.c.

References FSL_RETURN_ERROR_S, FSL_RETURN_OK_S, fsl_shw_spo_t::kernel_base, OS_ERROR_OK_S, os_free_memory, os_lock_save_context, os_unlock_restore_context, sah_deregister(), scc_release_partition(), shw_queue_lock, SHW_REMOVE_USER(), unmap_user_memory(), and fsl_shw_spo_t::user_base.

{
      shw_queue_entry_t *finished_request;
      fsl_shw_return_t ret = FSL_RETURN_OK_S;

      /* Clean up what we find in result pool. */
      do {
            os_lock_context_t lock_context;
            os_lock_save_context(shw_queue_lock, lock_context);
            finished_request = user_ctx->result_pool.head;

            if (finished_request != NULL) {
                  SHW_QUEUE_REMOVE_ENTRY(&user_ctx->result_pool,
                                     finished_request);
                  os_unlock_restore_context(shw_queue_lock, lock_context);
                  os_free_memory(finished_request);
            } else {
                  os_unlock_restore_context(shw_queue_lock, lock_context);
            }
      } while (finished_request != NULL);

#ifdef FSL_HAVE_SCC2
      {
            fsl_shw_spo_t *partition;
            struct mm_struct *mm = current->mm;

            while ((user_ctx->partition != NULL)
                   && (ret == FSL_RETURN_OK_S)) {

                  partition = user_ctx->partition;

#ifdef SHW_DEBUG
                  LOG_KDIAG_ARGS
                      ("Found an abandoned secure partition at %p, releasing",
                       partition);
#endif

                  /* It appears that current->mm is not valid if this is called from a
                   * close routine (perhaps only if the program raised an exception that
                   * caused it to close?)  If that is the case, then still free the
                   * partition, but do not remove it from the memory space (dangerous?)
                   */

                  if (mm == NULL) {
#ifdef SHW_DEBUG
                        LOG_KDIAG
                            ("Warning: no mm structure found, not unmapping "
                             "partition from user memory\n");
#endif
                  } else {
                        /* Unmap the memory region (see sys_munmap in mmap.c) */
                        /* Note that this assumes a single memory partition */
                        unmap_user_memory(partition->user_base, 8192);
                  }

                  /* If the memory was successfully released */
                  if (ret == OS_ERROR_OK_S) {
                        /* release the partition */
                        scc_release_partition(partition->kernel_base);

                        /* and remove it from the users context */
                        deregister_user_partition(user_ctx,
                                            partition->user_base);

                        ret = FSL_RETURN_OK_S;
                  } else {
                        ret = FSL_RETURN_ERROR_S;

                        goto out;
                  }
            }
      }
      out:
#endif                        /* FSL_HAVE_SCC2 */

      SHW_REMOVE_USER(user_ctx);

      return ret;
}


Generated by  Doxygen 1.6.0   Back to index