[SeaBIOS] [PATCH v2 03/10] tpm: Prepare code for TPM 2 functions

Kevin O'Connor kevin at koconnor.net
Mon Feb 1 22:54:53 CET 2016


On Fri, Jan 22, 2016 at 05:47:13PM -0500, Stefan Berger wrote:
> From: Stefan Berger <stefanb at linux.vnet.ibm.com>
> 
> This patch prepares the tcgbios.c file for extension with TPM 2
> specific code by:
> 
>  o prefixing all TPM 1.2 specific functions with tpm12_
>  o where necessary, introduce switch statements in tpm_ - prefixed functions;
>    here we branch into TPM versions specific code
>  o introduce tpm_ - prefixed functions where necessary; mostly in those
>    cases where tpm12_ functions are too large and where the tpm_ function
>    then only holds the switch statement
>  o leave FIXMEs where we need to write TPM 2 specific code; subsequent patches
>    will replace those FIXMEs
> 
> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
> ---
>  src/tcgbios.c | 311 +++++++++++++++++++++++++++++++++++++---------------------
>  1 file changed, 199 insertions(+), 112 deletions(-)
> 
> diff --git a/src/tcgbios.c b/src/tcgbios.c
> index 799a8bf..7f314b7 100644
> --- a/src/tcgbios.c
> +++ b/src/tcgbios.c
> @@ -171,7 +171,15 @@ tpm_is_working(void)
>  int
>  tpm_can_show_menu(void)
>  {
> -    return tpm_is_working() && TPM_has_physical_presence;
> +    switch (TPM_version) {
> +    case TPM_VERSION_NONE:
> +        return 0;

I find these "case TPM_VERSION_NONE:" clauses to be a little
confusing, both in this patches and the later patches, because I don't
think any of these additional code paths are reachable.  I think it
would be better to just have the branches that are active (ie, v1.2
and v2).

-Kevin



More information about the SeaBIOS mailing list