1c2e9c5bbSJustin Hibbits#- 2c2e9c5bbSJustin Hibbits# Copyright (c) 2023 Juniper Networks, Inc. 3c2e9c5bbSJustin Hibbits# All Rights Reserved 4c2e9c5bbSJustin Hibbits# 5c2e9c5bbSJustin Hibbits# Redistribution and use in source and binary forms, with or without 6c2e9c5bbSJustin Hibbits# modification, are permitted provided that the following conditions 7c2e9c5bbSJustin Hibbits# are met: 8c2e9c5bbSJustin Hibbits# 1. Redistributions of source code must retain the above copyright 9c2e9c5bbSJustin Hibbits# notice, this list of conditions and the following disclaimer. 10c2e9c5bbSJustin Hibbits# 2. Redistributions in binary form must reproduce the above copyright 11c2e9c5bbSJustin Hibbits# notice, this list of conditions and the following disclaimer in the 12c2e9c5bbSJustin Hibbits# documentation and/or other materials provided with the distribution. 13c2e9c5bbSJustin Hibbits# 14c2e9c5bbSJustin Hibbits# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15c2e9c5bbSJustin Hibbits# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16c2e9c5bbSJustin Hibbits# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17c2e9c5bbSJustin Hibbits# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18c2e9c5bbSJustin Hibbits# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19c2e9c5bbSJustin Hibbits# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20c2e9c5bbSJustin Hibbits# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21c2e9c5bbSJustin Hibbits# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22c2e9c5bbSJustin Hibbits# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23c2e9c5bbSJustin Hibbits# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24c2e9c5bbSJustin Hibbits# SUCH DAMAGE. 25c2e9c5bbSJustin Hibbits# 26c2e9c5bbSJustin Hibbits# 27c2e9c5bbSJustin Hibbits 28c2e9c5bbSJustin Hibbits#include <sys/bus.h> 29c2e9c5bbSJustin Hibbits#include <dev/tpm/tpm20.h> 30c2e9c5bbSJustin Hibbits 31c2e9c5bbSJustin HibbitsINTERFACE tpm; 32c2e9c5bbSJustin Hibbits 33c2e9c5bbSJustin Hibbits# 34c2e9c5bbSJustin Hibbits# Transfer data to the TPM data buffer 35c2e9c5bbSJustin Hibbits# 36c2e9c5bbSJustin HibbitsMETHOD int transmit { 37c2e9c5bbSJustin Hibbits device_t dev; 38c2e9c5bbSJustin Hibbits size_t length; 39c2e9c5bbSJustin Hibbits}; 40c2e9c5bbSJustin Hibbits 41c2e9c5bbSJustin Hibbits 42c2e9c5bbSJustin HibbitsMETHOD uint64_t read_8 { 43c2e9c5bbSJustin Hibbits device_t dev; 44*bea2bf45SRyan Libby bus_size_t addr; 45c2e9c5bbSJustin Hibbits} 46c2e9c5bbSJustin Hibbits 47c2e9c5bbSJustin Hibbits# 48c2e9c5bbSJustin Hibbits# Read 4 bytes (host endian) from a TPM register 49c2e9c5bbSJustin Hibbits# 50c2e9c5bbSJustin HibbitsMETHOD uint32_t read_4 { 51c2e9c5bbSJustin Hibbits device_t dev; 52*bea2bf45SRyan Libby bus_size_t addr; 53c2e9c5bbSJustin Hibbits}; 54c2e9c5bbSJustin Hibbits 55c2e9c5bbSJustin HibbitsMETHOD uint8_t read_1 { 56c2e9c5bbSJustin Hibbits device_t dev; 57*bea2bf45SRyan Libby bus_size_t addr; 58c2e9c5bbSJustin Hibbits}; 59c2e9c5bbSJustin Hibbits 60c2e9c5bbSJustin HibbitsMETHOD void write_4 { 61c2e9c5bbSJustin Hibbits device_t dev; 62*bea2bf45SRyan Libby bus_size_t addr; 63c2e9c5bbSJustin Hibbits uint32_t value; 64c2e9c5bbSJustin Hibbits}; 65c2e9c5bbSJustin Hibbits 66c2e9c5bbSJustin HibbitsMETHOD void write_1 { 67c2e9c5bbSJustin Hibbits device_t dev; 68*bea2bf45SRyan Libby bus_size_t addr; 69c2e9c5bbSJustin Hibbits uint8_t value; 70c2e9c5bbSJustin Hibbits}; 71c2e9c5bbSJustin Hibbits 72c2e9c5bbSJustin HibbitsMETHOD void write_barrier { 73c2e9c5bbSJustin Hibbits device_t dev; 74*bea2bf45SRyan Libby bus_size_t off; 75c2e9c5bbSJustin Hibbits bus_size_t length; 76c2e9c5bbSJustin Hibbits} 77