Lines Matching +full:integer +full:- +full:n
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012-2014 Intel Corporation
10 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
55 return scnprintf(buf, PAGE_SIZE, "%s\n", chip->ppi_version); in tpm_show_ppi_version()
61 ssize_t size = -EINVAL; in tpm_show_ppi_request()
67 if (strcmp(chip->ppi_version, "1.2") < 0) in tpm_show_ppi_request()
70 obj = tpm_eval_dsm(chip->acpi_dev_handle, TPM_PPI_FN_GETREQ, in tpm_show_ppi_request()
73 return -ENXIO; in tpm_show_ppi_request()
81 if (obj->package.count == 3 && in tpm_show_ppi_request()
82 obj->package.elements[0].type == ACPI_TYPE_INTEGER && in tpm_show_ppi_request()
83 obj->package.elements[1].type == ACPI_TYPE_INTEGER && in tpm_show_ppi_request()
84 obj->package.elements[2].type == ACPI_TYPE_INTEGER) { in tpm_show_ppi_request()
85 if (obj->package.elements[0].integer.value) in tpm_show_ppi_request()
86 size = -EFAULT; in tpm_show_ppi_request()
88 req = obj->package.elements[1].integer.value; in tpm_show_ppi_request()
91 "%llu %llu\n", req, in tpm_show_ppi_request()
92 obj->package.elements[2].integer.value); in tpm_show_ppi_request()
95 "%llu\n", req); in tpm_show_ppi_request()
97 } else if (obj->package.count == 2 && in tpm_show_ppi_request()
98 obj->package.elements[0].type == ACPI_TYPE_INTEGER && in tpm_show_ppi_request()
99 obj->package.elements[1].type == ACPI_TYPE_INTEGER) { in tpm_show_ppi_request()
100 if (obj->package.elements[0].integer.value) in tpm_show_ppi_request()
101 size = -EFAULT; in tpm_show_ppi_request()
103 size = scnprintf(buf, PAGE_SIZE, "%llu\n", in tpm_show_ppi_request()
104 obj->package.elements[1].integer.value); in tpm_show_ppi_request()
125 * the function to submit TPM operation request to pre-os environment in tpm_store_ppi_request()
129 if (acpi_check_dsm(chip->acpi_dev_handle, &tpm_ppi_guid, in tpm_store_ppi_request()
135 * accept buffer/string/integer type, but some BIOS accept buffer/ in tpm_store_ppi_request()
139 if (strcmp(chip->ppi_version, "1.3") == 0) { in tpm_store_ppi_request()
140 if (sscanf(buf, "%llu %llu", &tmp[0].integer.value, in tpm_store_ppi_request()
141 &tmp[1].integer.value) != 2) in tpm_store_ppi_request()
146 } else if (strcmp(chip->ppi_version, "1.2") < 0) { in tpm_store_ppi_request()
148 return -EINVAL; in tpm_store_ppi_request()
156 if (sscanf(buf, "%llu", &tmp[0].integer.value) != 1) in tpm_store_ppi_request()
157 return -EINVAL; in tpm_store_ppi_request()
160 obj = tpm_eval_dsm(chip->acpi_dev_handle, func, ACPI_TYPE_INTEGER, in tpm_store_ppi_request()
163 return -ENXIO; in tpm_store_ppi_request()
165 ret = obj->integer.value; in tpm_store_ppi_request()
172 return (ret == 1) ? -EPERM : -EFAULT; in tpm_store_ppi_request()
193 "OS Vendor-specific", in tpm_show_ppi_transition_action()
199 * (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for in tpm_show_ppi_transition_action()
202 if (strcmp(chip->ppi_version, "1.2") < 0) in tpm_show_ppi_transition_action()
204 obj = tpm_eval_dsm(chip->acpi_dev_handle, TPM_PPI_FN_GETACT, in tpm_show_ppi_transition_action()
207 return -ENXIO; in tpm_show_ppi_transition_action()
209 ret = obj->integer.value; in tpm_show_ppi_transition_action()
213 if (ret < ARRAY_SIZE(info) - 1) in tpm_show_ppi_transition_action()
214 status = scnprintf(buf, PAGE_SIZE, "%d: %s\n", ret, info[ret]); in tpm_show_ppi_transition_action()
216 status = scnprintf(buf, PAGE_SIZE, "%d: %s\n", ret, in tpm_show_ppi_transition_action()
217 info[ARRAY_SIZE(info)-1]); in tpm_show_ppi_transition_action()
225 acpi_status status = -EINVAL; in tpm_show_ppi_response()
230 obj = tpm_eval_dsm(chip->acpi_dev_handle, TPM_PPI_FN_GETRSP, in tpm_show_ppi_response()
233 return -ENXIO; in tpm_show_ppi_response()
240 * the second integer is not 0, the response makes sense. in tpm_show_ppi_response()
242 ret_obj = obj->package.elements; in tpm_show_ppi_response()
243 if (obj->package.count < 3 || in tpm_show_ppi_response()
249 if (ret_obj[0].integer.value) { in tpm_show_ppi_response()
250 status = -EFAULT; in tpm_show_ppi_response()
254 req = ret_obj[1].integer.value; in tpm_show_ppi_response()
255 res = ret_obj[2].integer.value; in tpm_show_ppi_response()
258 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req, in tpm_show_ppi_response()
261 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req, in tpm_show_ppi_response()
264 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req, in tpm_show_ppi_response()
267 status = scnprintf(buf, PAGE_SIZE, "%llu %llu: %s\n", in tpm_show_ppi_response()
270 status = scnprintf(buf, PAGE_SIZE, "%llu %llu: %s\n", in tpm_show_ppi_response()
273 status = scnprintf(buf, PAGE_SIZE, "%llu: %s\n", in tpm_show_ppi_response()
301 return -EPERM; in show_ppi_operations()
303 tmp.integer.type = ACPI_TYPE_INTEGER; in show_ppi_operations()
305 tmp.integer.value = i; in show_ppi_operations()
310 return -ENOMEM; in show_ppi_operations()
312 ret = obj->integer.value; in show_ppi_operations()
317 str += scnprintf(str, PAGE_SIZE, "%d %d: %s\n", in show_ppi_operations()
321 return str - buf; in show_ppi_operations()
330 return show_ppi_operations(chip->acpi_dev_handle, buf, 0, in tpm_show_ppi_tcg_operations()
340 return show_ppi_operations(chip->acpi_dev_handle, buf, PPI_VS_REQ_START, in tpm_show_ppi_vs_operations()
370 if (!chip->acpi_dev_handle) in tpm_add_ppi()
373 if (!acpi_check_dsm(chip->acpi_dev_handle, &tpm_ppi_guid, in tpm_add_ppi()
378 obj = acpi_evaluate_dsm_typed(chip->acpi_dev_handle, &tpm_ppi_guid, in tpm_add_ppi()
383 strscpy(chip->ppi_version, obj->string.pointer, in tpm_add_ppi()
384 sizeof(chip->ppi_version)); in tpm_add_ppi()
388 chip->groups[chip->groups_cnt++] = &ppi_attr_grp; in tpm_add_ppi()