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

static os_error_code get_capabilities ( fsl_shw_uco_t user_ctx,
void *  user_mode_pco_request 
) [static]

Handle user-mode Get Capabilities request

Right now, this function can only have a failure if the user has failed to provide a pointer to a location in user space with enough room to hold the fsl_shw_pco_t structure and any associated data. It will treat this failure as an ioctl failure and return an ioctl error code, instead of treating it as an API failure.

user_ctx The kernel version of user's context
user_mode_pco_request Pointer to user-space request
an os_error_code

Definition at line 1305 of file shw_driver.c.

References capabilities_req::capabilities, copy_array(), copy_fsl_code(), FSL_RETURN_OK_S, fsl_shw_pco_t::hash_algorithm_count, fsl_shw_pco_t::hash_algorithms, os_copy_from_user, os_copy_to_user, OS_ERROR_BAD_ADDRESS_S, OS_ERROR_OK_S, capabilities_req::size, fsl_shw_pco_t::sym_algorithm_count, fsl_shw_pco_t::sym_algorithms, fsl_shw_pco_t::sym_mode_count, and fsl_shw_pco_t::sym_modes.

Referenced by fsl_shw_get_capabilities(), and OS_DEV_IOCTL().

      os_error_code code;
      struct capabilities_req req;
      fsl_shw_pco_t local_cap;

      memcpy(&local_cap, &cap, sizeof(cap));
      /* Initialize pointers to out-of-struct arrays */
      local_cap.sym_algorithms = NULL;
      local_cap.sym_modes = NULL;
      local_cap.sym_modes = NULL;

      code = os_copy_from_user(&req, user_mode_pco_request, sizeof(req));
      if (code == OS_ERROR_OK_S) {
            void *endcap;
            void *user_bounds;
#ifdef SHW_DEBUG
            LOG_KDIAG_ARGS("SHE: Received get_cap request: 0x%p/%u/0x%x",
                         req.capabilities, req.size,
            endcap = req.capabilities + 1;      /* point to end of structure */
            user_bounds = (void *)req.capabilities + req.size;    /* end of area */

            /* First verify that request is big enough for the main structure */
            if (endcap >= user_bounds) {
                  endcap = NULL;    /* No! */

            /* Copy any Symmetric Algorithm suppport */
            if (cap.sym_algorithm_count != 0) {
                  local_cap.sym_algorithms = endcap;
                  endcap =
                      copy_array(endcap, user_bounds, cap.sym_algorithms,

            /* Copy any Symmetric Modes suppport */
            if (cap.sym_mode_count != 0) {
                  local_cap.sym_modes = endcap;
                  endcap = copy_array(endcap, user_bounds, cap.sym_modes,

            /* Copy any Hash Algorithm suppport */
            if (cap.hash_algorithm_count != 0) {
                  local_cap.hash_algorithms = endcap;
                  endcap =
                      copy_array(endcap, user_bounds, cap.hash_algorithms,

            /* Now copy up the (possibly modified) main structure */
            if (endcap != NULL) {
                  code =
                      os_copy_to_user(req.capabilities, &local_cap,

            if (endcap == NULL) {
                  code = OS_ERROR_BAD_ADDRESS_S;

            /* And return the FSL SHW code in the request structure. */
            if (code == OS_ERROR_OK_S) {
                  code =

      /* code may already be set to an error.  This is another error case.  */

#ifdef SHW_DEBUG
      LOG_KDIAG_ARGS("SHW: get capabilities returning %d", code);

      return code;

Generated by  Doxygen 1.6.0   Back to index