xref: /openbmc/qemu/hw/tpm/tpm_ppi.c (revision 0fe246690315335a40a132f05cb6fdc7bfb9adca)
1 /*
2  * tpm_ppi.c - TPM Physical Presence Interface
3  *
4  * Copyright (C) 2018 IBM Corporation
5  *
6  * Authors:
7  *  Stefan Berger <stefanb@us.ibm.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2 or later.
10  * See the COPYING file in the top-level directory.
11  *
12  */
13 
14 #include "qemu/osdep.h"
15 
16 #include "qapi/error.h"
17 #include "cpu.h"
18 #include "sysemu/memory_mapping.h"
19 #include "migration/vmstate.h"
20 #include "tpm_ppi.h"
21 
22 void tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
23                   hwaddr addr, Object *obj)
24 {
25     tpmppi->buf = g_malloc0(HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
26     memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi",
27                                       TPM_PPI_ADDR_SIZE, tpmppi->buf);
28     vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
29 
30     memory_region_add_subregion(m, addr, &tpmppi->ram);
31 }
32