[SeaBIOS] [PATCH 2/4] tpm: generalize init_timeout()

Philippe Mathieu-Daudé f4bug at amsat.org
Mon Oct 23 18:47:38 CEST 2017


On 10/06/2017 11:33 AM, marcandre.lureau at redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug at amsat.org>

> 
> It seems both TIS & CRB devices share the same timeout. Make
> initialization function generic for now.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> ---
>  src/hw/tpm_drivers.c | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c
> index a137e62..0daaef2 100644
> --- a/src/hw/tpm_drivers.c
> +++ b/src/hw/tpm_drivers.c
> @@ -102,26 +102,31 @@ static TPMVersion tis_get_tpm_version(void)
>      return TPM_VERSION_1_2;
>  }
>  
> -static u32 tis_init(void)
> +static void init_timeout(int driver)
>  {
> -    if (!CONFIG_TCGBIOS)
> -        return 1;
> -
> -    writeb(TIS_REG(0, TIS_REG_INT_ENABLE), 0);
> -
> -    if (tpm_drivers[TIS_DRIVER_IDX].durations == NULL) {
> +    if (tpm_drivers[driver].durations == NULL) {
>          u32 *durations = tpm_default_dur;
>          memcpy(durations, tpm_default_durations,
>                 sizeof(tpm_default_durations));
> -        tpm_drivers[TIS_DRIVER_IDX].durations = durations;
> +        tpm_drivers[driver].durations = durations;
>      }
>  
> -    if (tpm_drivers[TIS_DRIVER_IDX].timeouts == NULL) {
> +    if (tpm_drivers[driver].timeouts == NULL) {
>          u32 *timeouts = tpm_default_to;
>          memcpy(timeouts, tis_default_timeouts,
>                 sizeof(tis_default_timeouts));
> -        tpm_drivers[TIS_DRIVER_IDX].timeouts = timeouts;
> +        tpm_drivers[driver].timeouts = timeouts;
>      }
> +}
> +
> +static u32 tis_init(void)
> +{
> +    if (!CONFIG_TCGBIOS)
> +        return 1;
> +
> +    writeb(TIS_REG(0, TIS_REG_INT_ENABLE), 0);
> +
> +    init_timeout(TIS_DRIVER_IDX);
>  
>      return 1;
>  }
> 



More information about the SeaBIOS mailing list