msm_pft.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef MSM_PFT_H_
  13. #define MSM_PFT_H_
  14. #include <linux/types.h>
  15. /**
  16. * enum pft_command_opcode - PFT driver command ID
  17. *
  18. * @PFT_CMD_OPCODE_SET_STATE -
  19. * command ID to set PFT driver state
  20. * @PFT_CMD_OPCODE_UPDATE_REG_APP_UID -
  21. * command ID to update the list of registered application
  22. * UID
  23. * @PFT_CMD_OPCODE_PERFORM_IN_PLACE_FILE_ENC -
  24. * command ID to perfrom in-place file encryption
  25. */
  26. enum pft_command_opcode {
  27. PFT_CMD_OPCODE_SET_STATE,
  28. PFT_CMD_OPCODE_UPDATE_REG_APP_UID,
  29. PFT_CMD_OPCODE_PERFORM_IN_PLACE_FILE_ENC,
  30. /* */
  31. PFT_CMD_OPCODE_MAX_COMMAND_INDEX
  32. };
  33. /**
  34. * enum pft_state - PFT driver operational states
  35. *
  36. * @PFT_STATE_DEACTIVATED - driver is deativated.
  37. * @PFT_STATE_DEACTIVATING - driver is in the process of being deativated.
  38. * @PFT_STATE_KEY_REMOVED - driver is active but no encryption key is loaded.
  39. * @PFT_STATE_REMOVING_KEY - driver is active, but the encryption key is being
  40. * removed.
  41. * @PFT_STATE_KEY_LOADED - driver is active, and the encryption key is loaded
  42. * to encryption block, hence registered apps can perform file operations
  43. * on encrypted files.
  44. */
  45. enum pft_state {
  46. PFT_STATE_DEACTIVATED,
  47. PFT_STATE_DEACTIVATING,
  48. PFT_STATE_KEY_REMOVED,
  49. PFT_STATE_REMOVING_KEY,
  50. PFT_STATE_KEY_LOADED,
  51. /* Internal */
  52. PFT_STATE_MAX_INDEX
  53. };
  54. /**
  55. * enum pft_command_response_code - PFT response on the previous
  56. * command
  57. *
  58. * @PFT_CMD_RESP_SUCCESS - The command was properly processed
  59. * without an error.
  60. * @PFT_CMD_RESP_GENERAL_ERROR -
  61. * Indicates an error that cannot be better described by a
  62. * more specific errors below.
  63. * @PFT_CMD_RESP_INVALID_COMMAND - Invalid or unsupported
  64. * command id.
  65. * @PFT_CMD_RESP_INVALID_CMD_PARAMS - Invalid command
  66. * parameters.
  67. * @PFT_CMD_RESP_INVALID_STATE - Invalid state
  68. * @PFT_CMD_RESP_ALREADY_IN_STATE - Used to indicates that
  69. * the new state is equal to the existing one.
  70. * @PFT_CMD_RESP_INPLACE_FILE_IS_OPEN - Used to indicates
  71. * that the file that should be encrypted is already open
  72. * and can be encrypted.
  73. * @PFT_CMD_RESP_ENT_FILES_CLOSING_FAILURE
  74. * Indicates about failure of the PFT to close Enterprise files
  75. * @PFT_CMD_RESP_MAX_INDEX
  76. */
  77. enum pft_command_response_code {
  78. PFT_CMD_RESP_SUCCESS,
  79. PFT_CMD_RESP_GENERAL_ERROR,
  80. PFT_CMD_RESP_INVALID_COMMAND,
  81. PFT_CMD_RESP_INVALID_CMD_PARAMS,
  82. PFT_CMD_RESP_INVALID_STATE,
  83. PFT_CMD_RESP_ALREADY_IN_STATE,
  84. PFT_CMD_RESP_INPLACE_FILE_IS_OPEN,
  85. PFT_CMD_RESP_ENT_FILES_CLOSING_FAILURE,
  86. /* Internal */
  87. PFT_CMD_RESP_MAX_INDEX
  88. };
  89. /**
  90. * struct pft_command_response - response structure
  91. *
  92. * @command_id - see enum pft_command_response_code
  93. * @error_codee - see enum pft_command_response_code
  94. */
  95. struct pft_command_response {
  96. __u32 command_id;
  97. __u32 error_code;
  98. };
  99. /**
  100. * struct pft_command - pft command
  101. *
  102. * @opcode - see enum pft_command_opcode.
  103. * @set_state.state - see enum pft_state.
  104. * @update_app_list.count - number of items in the
  105. * registered applications list.
  106. * @update_app_list.table - registered applications array
  107. * @preform_in_place_file_enc.file_descriptor - file descriptor
  108. * of the opened file to be in-placed encrypted.
  109. */
  110. struct pft_command {
  111. __u32 opcode;
  112. union {
  113. struct {
  114. /* @see pft_state */
  115. __u32 state;
  116. } set_state;
  117. struct {
  118. __u32 items_count; /* number of items */
  119. __u32 table[0]; /* array of UIDs */
  120. } update_app_list;
  121. struct {
  122. __u32 file_descriptor;
  123. } preform_in_place_file_enc;
  124. };
  125. };
  126. #endif /* MSM_PFT_H_ */