}
FbLockEnableResult fastboot_lock_enable() {
- struct blk_desc *fs_dev_desc;
- disk_partition_t fs_partition;
- unsigned char *bdata;
- int mmc_id;
- FbLockEnableResult ret;
-
#ifdef CONFIG_DUAL_BOOTLOADER
/* Always allow unlock device in spl recovery mode. */
if (is_spl_recovery())
return FASTBOOT_UL_ENABLE;
#endif
+#ifdef CONFIG_IMX_TRUSTY_OS
+ int ret;
+ uint8_t oem_device_unlock;
+
+ ret = trusty_read_oem_unlock_device_permission(&oem_device_unlock);
+ if (ret < 0)
+ return FASTBOOT_UL_ERROR;
+ else
+ return oem_device_unlock;
+#else /* CONFIG_IMX_TRUSTY_OS */
+ FbLockEnableResult ret;
+ struct blk_desc *fs_dev_desc;
+ disk_partition_t fs_partition;
+ unsigned char *bdata;
+ int mmc_id;
+
bdata = (unsigned char *)memalign(ALIGN_BYTES, SECTOR_SIZE);
if (bdata == NULL)
return FASTBOOT_UL_ERROR;
fail:
free(bdata);
return ret;
+#endif /* CONFIG_IMX_TRUSTY_OS */
}
#endif
LOCK_BOOT_STATE = (7 << AVB_REQ_SHIFT),
READ_VBMETA_PUBLIC_KEY = (8 << AVB_REQ_SHIFT),
WRITE_VBMETA_PUBLIC_KEY = (9 << AVB_REQ_SHIFT),
+ WRITE_OEM_UNLOCK_DEVICE_PERMISSION = (10 << AVB_REQ_SHIFT),
+ READ_OEM_UNLOCK_DEVICE_PERMISSION = (11 << AVB_REQ_SHIFT),
};
/**
* Returns one of trusty_err.
*/
int trusty_lock_boot_state(void);
+/*
+ * Send request to secure side to read oem device unlock state from RPMB.
+ *
+ * Returns one of trusty_err.
+ */
+int trusty_read_oem_unlock_device_permission(uint8_t *lock_state);
#endif /* TRUSTY_AVB_H_ */
{
return avb_do_tipc(LOCK_BOOT_STATE, NULL, 0, NULL, NULL);
}
+
+int trusty_read_oem_unlock_device_permission(uint8_t *oem_device_unlock)
+{
+ uint32_t resp_size = sizeof(*oem_device_unlock);
+ return avb_do_tipc(READ_OEM_UNLOCK_DEVICE_PERMISSION, NULL, 0, oem_device_unlock,
+ &resp_size);
+}