tpm/ppi: Enable submission of optional command parameter for PPI 1.3
This patch enables a user to specify the additional optional command parameter by writing it into the request file: # echo "23 16" > request # cat request 23 16 For backwards compatibility: If only 1 parameter is given then we assume this is the operation request number. # echo "5" > request # cat request 5 Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Tested-by: David Safford <david.safford@ge.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>hifive-unleashed-5.1
parent
8b60c79bcc
commit
50a81b60bf
|
@ -120,9 +120,10 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
|
||||||
u32 req;
|
u32 req;
|
||||||
u64 ret;
|
u64 ret;
|
||||||
int func = TPM_PPI_FN_SUBREQ;
|
int func = TPM_PPI_FN_SUBREQ;
|
||||||
union acpi_object *obj, tmp;
|
union acpi_object *obj, tmp[2];
|
||||||
union acpi_object argv4 = ACPI_INIT_DSM_ARGV4(1, &tmp);
|
union acpi_object argv4 = ACPI_INIT_DSM_ARGV4(2, tmp);
|
||||||
struct tpm_chip *chip = to_tpm_chip(dev);
|
struct tpm_chip *chip = to_tpm_chip(dev);
|
||||||
|
u64 rev = TPM_PPI_REVISION_ID_1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the function to submit TPM operation request to pre-os environment
|
* the function to submit TPM operation request to pre-os environment
|
||||||
|
@ -139,20 +140,29 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
|
||||||
* string/package type. For PPI version 1.0 and 1.1, use buffer type
|
* string/package type. For PPI version 1.0 and 1.1, use buffer type
|
||||||
* for compatibility, and use package type since 1.2 according to spec.
|
* for compatibility, and use package type since 1.2 according to spec.
|
||||||
*/
|
*/
|
||||||
if (strcmp(chip->ppi_version, "1.2") < 0) {
|
if (strcmp(chip->ppi_version, "1.3") == 0) {
|
||||||
|
if (sscanf(buf, "%llu %llu", &tmp[0].integer.value,
|
||||||
|
&tmp[1].integer.value) != 2)
|
||||||
|
goto ppi12;
|
||||||
|
rev = TPM_PPI_REVISION_ID_2;
|
||||||
|
tmp[0].type = ACPI_TYPE_INTEGER;
|
||||||
|
tmp[1].type = ACPI_TYPE_INTEGER;
|
||||||
|
} else if (strcmp(chip->ppi_version, "1.2") < 0) {
|
||||||
if (sscanf(buf, "%d", &req) != 1)
|
if (sscanf(buf, "%d", &req) != 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
argv4.type = ACPI_TYPE_BUFFER;
|
argv4.type = ACPI_TYPE_BUFFER;
|
||||||
argv4.buffer.length = sizeof(req);
|
argv4.buffer.length = sizeof(req);
|
||||||
argv4.buffer.pointer = (u8 *)&req;
|
argv4.buffer.pointer = (u8 *)&req;
|
||||||
} else {
|
} else {
|
||||||
tmp.type = ACPI_TYPE_INTEGER;
|
ppi12:
|
||||||
if (sscanf(buf, "%llu", &tmp.integer.value) != 1)
|
argv4.package.count = 1;
|
||||||
|
tmp[0].type = ACPI_TYPE_INTEGER;
|
||||||
|
if (sscanf(buf, "%llu", &tmp[0].integer.value) != 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = tpm_eval_dsm(chip->acpi_dev_handle, func, ACPI_TYPE_INTEGER,
|
obj = tpm_eval_dsm(chip->acpi_dev_handle, func, ACPI_TYPE_INTEGER,
|
||||||
&argv4, TPM_PPI_REVISION_ID_1);
|
&argv4, rev);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue