@@ -1878,48 +1878,61 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
1878
1878
"FACP" , tbl -> len - fadt_start , f -> rev , oem_id , oem_table_id );
1879
1879
}
1880
1880
1881
+ /*
1882
+ * build_tpm2 - Build the TPM2 table as specified in
1883
+ * table 7: TCG Hardware Interface Description Table Format for TPM 2.0
1884
+ * of TCG ACPI Specification, Family “1.2” and “2.0”, Version 1.2, Rev 8
1885
+ */
1881
1886
void build_tpm2 (GArray * table_data , BIOSLinker * linker , GArray * tcpalog )
1882
1887
{
1883
- Acpi20TPM2 * tpm2_ptr = acpi_data_push (table_data , sizeof (AcpiTableHeader ));
1884
- unsigned log_addr_size = sizeof (tpm2_ptr -> log_area_start_address );
1885
- unsigned log_addr_offset =
1886
- (char * )& tpm2_ptr -> log_area_start_address - table_data -> data ;
1887
1888
uint8_t start_method_params [12 ] = {};
1889
+ unsigned log_addr_offset , tpm2_start ;
1890
+ uint64_t control_area_start_address ;
1888
1891
TPMIf * tpmif = tpm_find ();
1892
+ uint32_t start_method ;
1893
+ void * tpm2_ptr ;
1894
+
1895
+ tpm2_start = table_data -> len ;
1896
+ tpm2_ptr = acpi_data_push (table_data , sizeof (AcpiTableHeader ));
1889
1897
1890
- /* platform class */
1898
+ /* Platform Class */
1891
1899
build_append_int_noprefix (table_data , TPM2_ACPI_CLASS_CLIENT , 2 );
1892
- /* reserved */
1900
+ /* Reserved */
1893
1901
build_append_int_noprefix (table_data , 0 , 2 );
1894
1902
if (TPM_IS_TIS_ISA (tpmif ) || TPM_IS_TIS_SYSBUS (tpmif )) {
1895
- /* address of control area */
1896
- build_append_int_noprefix (table_data , 0 , 8 );
1897
- /* start method */
1898
- build_append_int_noprefix (table_data , TPM2_START_METHOD_MMIO , 4 );
1903
+ control_area_start_address = 0 ;
1904
+ start_method = TPM2_START_METHOD_MMIO ;
1899
1905
} else if (TPM_IS_CRB (tpmif )) {
1900
- build_append_int_noprefix ( table_data , TPM_CRB_ADDR_CTRL , 8 ) ;
1901
- build_append_int_noprefix ( table_data , TPM2_START_METHOD_CRB , 4 ) ;
1906
+ control_area_start_address = TPM_CRB_ADDR_CTRL ;
1907
+ start_method = TPM2_START_METHOD_CRB ;
1902
1908
} else {
1903
- g_warn_if_reached ();
1909
+ g_assert_not_reached ();
1904
1910
}
1911
+ /* Address of Control Area */
1912
+ build_append_int_noprefix (table_data , control_area_start_address , 8 );
1913
+ /* Start Method */
1914
+ build_append_int_noprefix (table_data , start_method , 4 );
1905
1915
1906
- /* platform specific parameters */
1907
- g_array_append_vals (table_data , & start_method_params , 12 );
1916
+ /* Platform Specific Parameters */
1917
+ g_array_append_vals (table_data , & start_method_params ,
1918
+ ARRAY_SIZE (start_method_params ));
1908
1919
1909
- /* log area minimum length */
1920
+ /* Log Area Minimum Length */
1910
1921
build_append_int_noprefix (table_data , TPM_LOG_AREA_MINIMUM_SIZE , 4 );
1911
1922
1912
1923
acpi_data_push (tcpalog , TPM_LOG_AREA_MINIMUM_SIZE );
1913
1924
bios_linker_loader_alloc (linker , ACPI_BUILD_TPMLOG_FILE , tcpalog , 1 ,
1914
1925
false);
1915
1926
1916
- /* log area start address to be filled by Guest linker */
1927
+ log_addr_offset = table_data -> len ;
1928
+
1929
+ /* Log Area Start Address to be filled by Guest linker */
1917
1930
build_append_int_noprefix (table_data , 0 , 8 );
1918
1931
bios_linker_loader_add_pointer (linker , ACPI_BUILD_TABLE_FILE ,
1919
- log_addr_offset , log_addr_size ,
1932
+ log_addr_offset , 8 ,
1920
1933
ACPI_BUILD_TPMLOG_FILE , 0 );
1921
1934
build_header (linker , table_data ,
1922
- ( void * ) tpm2_ptr , "TPM2" , sizeof ( * tpm2_ptr ) , 4 , NULL , NULL );
1935
+ tpm2_ptr , "TPM2" , table_data -> len - tpm2_start , 4 , NULL , NULL );
1923
1936
}
1924
1937
1925
1938
/* ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors */
0 commit comments