]> Git Repo - qemu.git/blame - hw/tpm/tpm_ppi.c
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
[qemu.git] / hw / tpm / tpm_ppi.c
CommitLineData
3b97c01e
SB
1/*
2 * tpm_ppi.c - TPM Physical Presence Interface
3 *
4 * Copyright (C) 2018 IBM Corporation
5 *
6 * Authors:
7 * Stefan Berger <[email protected]>
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"
40214766 20#include "hw/acpi/tpm.h"
3b97c01e 21#include "tpm_ppi.h"
ffab1be7
MAL
22#include "trace.h"
23
24void tpm_ppi_reset(TPMPPI *tpmppi)
25{
26 if (tpmppi->buf[0x15a /* movv, docs/specs/tpm.txt */] & 0x1) {
27 GuestPhysBlockList guest_phys_blocks;
28 GuestPhysBlock *block;
29
30 guest_phys_blocks_init(&guest_phys_blocks);
31 guest_phys_blocks_append(&guest_phys_blocks);
32 QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
33 trace_tpm_ppi_memset(block->host_addr,
34 block->target_end - block->target_start);
35 memset(block->host_addr, 0,
36 block->target_end - block->target_start);
37 memory_region_set_dirty(block->mr, 0,
38 block->target_end - block->target_start);
39 }
40 guest_phys_blocks_free(&guest_phys_blocks);
41 }
42}
3b97c01e
SB
43
44void tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
45 hwaddr addr, Object *obj)
46{
71e415c8
MAL
47 tpmppi->buf = qemu_memalign(qemu_real_host_page_size,
48 HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
3b97c01e
SB
49 memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi",
50 TPM_PPI_ADDR_SIZE, tpmppi->buf);
51 vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
52
53 memory_region_add_subregion(m, addr, &tpmppi->ram);
54}
This page took 0.121754 seconds and 4 git commands to generate.