efi_loader: add EFI_TCG2_PROTOCOL.SubmitCommand
This commit adds the EFI_TCG2_PROTOCOL.SubmitCommand required in the TCG PC Client PFP spec. SubmitCommand enables to send the raw command to the TPM device. To implement this api, tpm2_submit_command() is added into tpm-v2.c. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
		
							parent
							
								
									14cbb330fe
								
							
						
					
					
						commit
						7fc93cae49
					
				| 
						 | 
					@ -641,4 +641,17 @@ u32 tpm2_write_lock(struct udevice *dev, u32 index);
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
u32 tpm2_disable_platform_hierarchy(struct udevice *dev);
 | 
					u32 tpm2_disable_platform_hierarchy(struct udevice *dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * submit user specified data to the TPM and get response
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @dev		TPM device
 | 
				
			||||||
 | 
					 * @sendbuf:	Buffer of the data to send
 | 
				
			||||||
 | 
					 * @recvbuf:	Buffer to save the response to
 | 
				
			||||||
 | 
					 * @recv_size:	Pointer to the size of the response buffer
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @return code of the operation
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf,
 | 
				
			||||||
 | 
								u8 *recvbuf, size_t *recv_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __TPM_V2_H */
 | 
					#endif /* __TPM_V2_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1034,13 +1034,39 @@ out:
 | 
				
			||||||
 * Return:	status code
 | 
					 * Return:	status code
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static efi_status_t EFIAPI
 | 
					static efi_status_t EFIAPI
 | 
				
			||||||
efi_tcg2_submit_command(__maybe_unused struct efi_tcg2_protocol *this,
 | 
					efi_tcg2_submit_command(struct efi_tcg2_protocol *this,
 | 
				
			||||||
			u32 __maybe_unused input_param_block_size,
 | 
								u32 input_param_block_size,
 | 
				
			||||||
			u8 __maybe_unused *input_param_block,
 | 
								u8 *input_param_block,
 | 
				
			||||||
			u32 __maybe_unused output_param_block_size,
 | 
								u32 output_param_block_size,
 | 
				
			||||||
			u8 __maybe_unused *output_param_block)
 | 
								u8 *output_param_block)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return EFI_UNSUPPORTED;
 | 
						struct udevice *dev;
 | 
				
			||||||
 | 
						efi_status_t ret;
 | 
				
			||||||
 | 
						u32 rc;
 | 
				
			||||||
 | 
						size_t resp_buf_size = output_param_block_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						EFI_ENTRY("%p, %u, %p, %u, %p", this, input_param_block_size,
 | 
				
			||||||
 | 
							  input_param_block, output_param_block_size, output_param_block);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!this || !input_param_block || !input_param_block_size) {
 | 
				
			||||||
 | 
							ret = EFI_INVALID_PARAMETER;
 | 
				
			||||||
 | 
							goto out;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = platform_get_tpm2_device(&dev);
 | 
				
			||||||
 | 
						if (ret != EFI_SUCCESS)
 | 
				
			||||||
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						rc = tpm2_submit_command(dev, input_param_block,
 | 
				
			||||||
 | 
									 output_param_block, &resp_buf_size);
 | 
				
			||||||
 | 
						if (rc) {
 | 
				
			||||||
 | 
							ret = (rc == -ENOSPC) ? EFI_OUT_OF_RESOURCES : EFI_DEVICE_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							goto out;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
 | 
						return EFI_EXIT(ret);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -659,3 +659,9 @@ u32 tpm2_disable_platform_hierarchy(struct udevice *dev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf,
 | 
				
			||||||
 | 
								u8 *recvbuf, size_t *recv_size)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return tpm_sendrecv_command(dev, sendbuf, recvbuf, recv_size);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue