else
memcpy(&nvdata[seq].data, buf + data_ofs, length);
}
+
+void sb_tpm_define_data(struct nvdata_state nvdata[NV_SEQ_COUNT],
+ enum sandbox_nv_space seq, int length)
+{
+ struct nvdata_state *nvd = &nvdata[seq];
+
+ if (length > NV_DATA_SIZE)
+ log_err("Invalid length %x (max %x)\n", length, NV_DATA_SIZE);
+ nvd->length = length;
+ nvd->present = true;
+}
enum sandbox_nv_space seq, const u8 *buf, int data_ofs,
int length);
+/**
+ * sb_tpm_define_data() - Set up non-volatile data
+ *
+ * If @length is too large, an error is logged and nothing is written.
+ *
+ * @nvdata: Current nvdata state
+ * @seq: Sequence number to set up
+ * @length: Length of space in bytes
+ */
+void sb_tpm_define_data(struct nvdata_state nvdata[NV_SEQ_COUNT],
+ enum sandbox_nv_space seq, int length);
+
#endif
memset(recvbuf, '\0', *recv_len);
break;
case TPM_CMD_NV_DEFINE_SPACE:
+ index = get_unaligned_be32(sendbuf + 12);
+ length = get_unaligned_be32(sendbuf + 77);
+ seq = sb_tpm_index_to_seq(index);
+ if (seq < 0)
+ return -EINVAL;
+ printf("tpm: define_space index=%#02x, len=%#02x, seq=%#02x\n",
+ index, length, seq);
+ sb_tpm_define_data(tpm->nvdata, seq, length);
+ *recv_len = 12;
+ memset(recvbuf, '\0', *recv_len);
+ break;
case 0x15: /* pcr read */
case 0x5d: /* force clear */
case 0x6f: /* physical enable */