disk: Add an option for partitions in SPL
[platform/kernel/u-boot.git] / lib / tpm-utils.h
index bc98d1e..a519e18 100644 (file)
 /* Internal error of TPM command library */
 #define TPM_LIB_ERROR ((u32)~0u)
 
-/**
- * tpm_open() - Request access to locality 0 for the caller
- *
- * After all commands have been completed the caller is supposed to
- * call tpm_close().
- *
- * Returns 0 on success, -ve on failure.
- */
-int tpm_open(struct udevice *dev);
-
-/**
- * tpm_close() - Close the current session
- *
- * Releasing the locked locality. Returns 0 on success, -ve 1 on
- * failure (in case lock removal did not succeed).
- */
-int tpm_close(struct udevice *dev);
+/* To make strings of commands more easily */
+#define __MSB(x) ((x) >> 8)
+#define __LSB(x) ((x) & 0xFF)
+#define tpm_u16(x) __MSB(x), __LSB(x)
+#define tpm_u32(x) tpm_u16((x) >> 16), tpm_u16((x) & 0xFFFF)
 
 /**
  * Pack data into a byte string.  The data types are specified in
@@ -43,7 +31,7 @@ int tpm_close(struct udevice *dev);
  * @param size         size of output string
  * @param format       format string
  * @param ...          data points
- * @return 0 on success, non-0 on error
+ * Return: 0 on success, non-0 on error
  */
 int pack_byte_string(u8 *str, size_t size, const char *format, ...);
 
@@ -58,7 +46,7 @@ int pack_byte_string(u8 *str, size_t size, const char *format, ...);
  * @param size         size of output string
  * @param format       format string
  * @param ...          data points
- * @return 0 on success, non-0 on error
+ * Return: 0 on success, non-0 on error
  */
 int unpack_byte_string(const u8 *str, size_t size, const char *format, ...);
 
@@ -66,7 +54,7 @@ int unpack_byte_string(const u8 *str, size_t size, const char *format, ...);
  * Get TPM command size.
  *
  * @param command      byte string of TPM command
- * @return command size of the TPM command
+ * Return: command size of the TPM command
  */
 u32 tpm_command_size(const void *command);
 
@@ -74,7 +62,7 @@ u32 tpm_command_size(const void *command);
  * Get TPM response return code, which is one of TPM_RESULT values.
  *
  * @param response     byte string of TPM response
- * @return return code of the TPM response
+ * Return: return code of the TPM response
  */
 u32 tpm_return_code(const void *response);
 
@@ -88,8 +76,9 @@ u32 tpm_return_code(const void *response);
  * @param size_ptr     output buffer size (input parameter) and TPM
  *                     response length (output parameter); this parameter
  *                     is a bidirectional
- * @return return code of the TPM response
+ * Return: return code of the TPM response
  */
-u32 tpm_sendrecv_command(const void *command, void *response, size_t *size_ptr);
+u32 tpm_sendrecv_command(struct udevice *dev, const void *command,
+                        void *response, size_t *size_ptr);
 
 #endif /* __TPM_UTILS_H */