diff --git a/sys/dev/tpm/tpm_bus.c b/sys/dev/tpm/tpm_bus.c index f0d3c26c33f1..6e2cc5d81cb6 100644 --- a/sys/dev/tpm/tpm_bus.c +++ b/sys/dev/tpm/tpm_bus.c @@ -1,99 +1,99 @@ /*- * Copyright (c) 2023 Juniper Networks, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include "tpm_if.h" #include "tpm20.h" /* Override accessors */ static uint8_t tpm_read_1(device_t dev, bus_size_t off) { struct tpm_sc *sc = device_get_softc(dev); return (bus_read_1(sc->mem_res, off)); } static uint32_t tpm_read_4(device_t dev, bus_size_t off) { struct tpm_sc *sc = device_get_softc(dev); return (bus_read_4(sc->mem_res, off)); } /* * Only i386 is missing bus_space_read_8. */ #ifndef __i386__ static uint64_t tpm_read_8(device_t dev, bus_size_t off) { struct tpm_sc *sc = device_get_softc(dev); return (bus_read_8(sc->mem_res, off)); } #endif static void tpm_write_1(device_t dev, bus_size_t off, uint8_t val) { struct tpm_sc *sc = device_get_softc(dev); bus_write_1(sc->mem_res, off, val); } static void tpm_write_4(device_t dev, bus_size_t off, uint32_t val) { struct tpm_sc *sc = device_get_softc(dev); bus_write_4(sc->mem_res, off, val); } static void -tpm_write_barrier(device_t dev, bus_addr_t off, bus_size_t length) +tpm_write_barrier(device_t dev, bus_size_t off, bus_size_t length) { struct tpm_sc *sc = device_get_softc(dev); bus_barrier(sc->mem_res, off, length, BUS_SPACE_BARRIER_WRITE); } static device_method_t tpm_bus_methods[] = { DEVMETHOD(tpm_read_1, tpm_read_1), DEVMETHOD(tpm_read_4, tpm_read_4), #ifndef __i386__ DEVMETHOD(tpm_read_8, tpm_read_8), #endif DEVMETHOD(tpm_write_1, tpm_write_1), DEVMETHOD(tpm_write_4, tpm_write_4), DEVMETHOD(tpm_write_barrier, tpm_write_barrier), DEVMETHOD_END }; DEFINE_CLASS_0(tpm_lbc, tpm_bus_driver, tpm_bus_methods, sizeof(struct tpm_sc)); diff --git a/sys/dev/tpm/tpm_if.m b/sys/dev/tpm/tpm_if.m index 2b6afe22f3e8..b0149ba163a6 100644 --- a/sys/dev/tpm/tpm_if.m +++ b/sys/dev/tpm/tpm_if.m @@ -1,76 +1,76 @@ #- # Copyright (c) 2023 Juniper Networks, Inc. # All Rights Reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # #include #include INTERFACE tpm; # # Transfer data to the TPM data buffer # METHOD int transmit { device_t dev; size_t length; }; METHOD uint64_t read_8 { device_t dev; - bus_addr_t addr; + bus_size_t addr; } # # Read 4 bytes (host endian) from a TPM register # METHOD uint32_t read_4 { device_t dev; - bus_addr_t addr; + bus_size_t addr; }; METHOD uint8_t read_1 { device_t dev; - bus_addr_t addr; + bus_size_t addr; }; METHOD void write_4 { device_t dev; - bus_addr_t addr; + bus_size_t addr; uint32_t value; }; METHOD void write_1 { device_t dev; - bus_addr_t addr; + bus_size_t addr; uint8_t value; }; METHOD void write_barrier { device_t dev; - bus_addr_t off; + bus_size_t off; bus_size_t length; }