commit 2e836746827f1e98534fe1edc4ecb5e8a0aa5d5d Author: Kyle Evans Date: Fri Apr 22 23:05:08 2022 -0500 mbox: convert to extres-style Abstract away mapping fdt data to an mbox, and add bits for registration and parsing fdt mboxes/#mbox-cells. diff --git a/sys/arm/broadcom/bcm2835/bcm2835_firmware.c b/sys/arm/broadcom/bcm2835/bcm2835_firmware.c index 5137511619fc..fb12238118ad 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_firmware.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_firmware.c @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -50,7 +52,7 @@ __FBSDID("$FreeBSD$"); struct bcm2835_firmware_softc { struct simplebus_softc sc; - phandle_t sc_mbox; + mbox_t sc_mbox; }; static struct ofw_compat_data compat_data[] = { @@ -80,18 +82,17 @@ bcm2835_firmware_attach(device_t dev) struct sysctl_ctx_list *ctx; struct sysctl_oid *tree_node; struct sysctl_oid_list *tree; - phandle_t node, mbox; + phandle_t node; int rv; sc = device_get_softc(dev); node = ofw_bus_get_node(dev); - rv = OF_getencprop(node, "mboxes", &mbox, sizeof(mbox)); + rv = mbox_get_by_ofw_idx(dev, node, 0, &sc->sc_mbox); if (rv <= 0) { device_printf(dev, "can't read mboxes property\n"); return (ENXIO); } - sc->sc_mbox = mbox; OF_device_register_xref(OF_xref_from_node(node), dev); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c index cd1420e8d344..5d3336a02221 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -203,6 +205,7 @@ bcm_mbox_attach(device_t dev) (void)mbox_read_4(sc, REG_READ); mbox_write_4(sc, REG_CONFIG, CONFIG_DATA_IRQ); + mbox_register_ofw_provider(dev); return (0); } diff --git a/sys/arm/broadcom/bcm2835/files.bcm283x b/sys/arm/broadcom/bcm2835/files.bcm283x index 0af397566c17..2dde0cb04242 100644 --- a/sys/arm/broadcom/bcm2835/files.bcm283x +++ b/sys/arm/broadcom/bcm2835/files.bcm283x @@ -22,8 +22,6 @@ arm/broadcom/bcm2835/bcm2838_pci.c optional pci arm/broadcom/bcm2835/bcm2838_xhci.c optional xhci arm/broadcom/bcm2835/bcm283x_dwc_fdt.c optional dwcotg fdt -dev/mbox/mbox_if.m standard - arm/broadcom/bcm2835/bcm2835_audio.c optional sound vchiq \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" diff --git a/sys/conf/files b/sys/conf/files index 9fc66b755db5..2e4786da8d55 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2403,6 +2403,8 @@ lio_23xx_nic.bin.fw optional lio \ dev/malo/if_malo.c optional malo dev/malo/if_malohal.c optional malo dev/malo/if_malo_pci.c optional malo pci +dev/mbox/mbox_if.m optional mbox fdt +dev/mbox/mbox.c optional mbox fdt dev/md/md.c optional md dev/mdio/mdio_if.m optional miiproxy | mdio dev/mdio/mdio.c optional miiproxy | mdio diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index eeae93d385b7..ddd64df70c51 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -269,8 +269,6 @@ dev/ipmi/ipmi_acpi.c optional ipmi acpi dev/ipmi/ipmi_kcs.c optional ipmi dev/ipmi/ipmi_smic.c optional ipmi -dev/mbox/mbox_if.m optional soc_brcm_bcm2837 - dev/mmc/host/dwmmc.c optional dwmmc fdt dev/mmc/host/dwmmc_altera.c optional dwmmc dwmmc_altera fdt dev/mmc/host/dwmmc_hisi.c optional dwmmc dwmmc_hisi fdt diff --git a/sys/dev/mbox/mbox.c b/sys/dev/mbox/mbox.c new file mode 100644 index 000000000000..70a3bdf77d3b --- /dev/null +++ b/sys/dev/mbox/mbox.c @@ -0,0 +1,189 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2016 Michal Meloun + * All rights reserved. + * + * Copyright (c) 2022 Kyle Evans + * + * 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. + * + * $FreeBSD$ + */ + +#include "opt_platform.h" +#include +#include +#include +#include +#include +#include +#include + +#ifdef FDT +#include +#include +#endif + +#include + +#include "mbox_if.h" + +MALLOC_DEFINE(M_MBOX, "mbox", "Mailbox Interface"); + +struct mbox { + device_t consumer_dev; /* consumer device */ + device_t provider_dev; /* provider device */ + intptr_t mbox_id; /* mbox id */ +}; + +int +mbox_get_by_id(device_t consumer_dev, device_t provider_dev, intptr_t id, + mbox_t *mb_out) +{ + mbox_t mb; + + /* Create handle */ + mb = malloc(sizeof(struct mbox), M_MBOX, + M_WAITOK | M_ZERO); + mb->consumer_dev = consumer_dev; + mb->provider_dev = provider_dev; + mb->mbox_id = id; + *mb_out = mb; + return (0); +} + +void +mbox_release(mbox_t mb) +{ + + free(mb, M_MBOX); +} + +int +mbox_read(mbox_t mb, uint32_t *data) +{ + + return (MBOX_READ(mb->provider_dev, mb->mbox_id, data)); +} + +int +mbox_write(mbox_t mb, uint32_t data) +{ + + return (MBOX_WRITE(mb->provider_dev, mb->mbox_id, data)); +} + +#ifdef FDT +int +mbox_default_ofw_map(device_t provider_dev, phandle_t xref, int ncells, + pcell_t *cells, intptr_t *id) +{ + if (ncells == 0) + *id = 1; + else if (ncells == 1) + *id = cells[0]; + else + return (ERANGE); + + return (0); +} + +int +mbox_get_by_ofw_idx(device_t consumer_dev, phandle_t cnode, int idx, + mbox_t *mb) +{ + phandle_t xnode; + pcell_t *cells; + device_t mboxdev; + int ncells, rv; + intptr_t id; + + if (cnode <= 0) + cnode = ofw_bus_get_node(consumer_dev); + if (cnode <= 0) { + device_printf(consumer_dev, + "%s called on not ofw based device\n", __func__); + return (ENXIO); + } + + rv = ofw_bus_parse_xref_list_alloc(cnode, "mboxes", + "#mbox-cells", + idx, &xnode, &ncells, &cells); + if (rv != 0) + return (rv); + + /* Tranlate provider to device */ + mboxdev = OF_device_from_xref(xnode); + if (mboxdev == NULL) { + OF_prop_free(cells); + return (ENODEV); + } + /* Map power domain to number */ + rv = MBOX_MAP(mboxdev, xnode, ncells, cells, &id); + OF_prop_free(cells); + if (rv != 0) + return (rv); + + return (mbox_get_by_id(consumer_dev, mboxdev, id, mb)); +} + +int +mbox_get_by_ofw_name(device_t consumer_dev, phandle_t cnode, char *name, + mbox_t *mb) +{ + int rv, idx; + + if (cnode <= 0) + cnode = ofw_bus_get_node(consumer_dev); + if (cnode <= 0) { + device_printf(consumer_dev, + "%s called on not ofw based device\n", __func__); + return (ENXIO); + } + rv = ofw_bus_find_string_index(cnode, "mbox-names", name, &idx); + if (rv != 0) + return (rv); + return (mbox_get_by_ofw_idx(consumer_dev, cnode, idx, mb)); +} + +void +mbox_register_ofw_provider(device_t provider_dev) +{ + phandle_t xref, node; + + node = ofw_bus_get_node(provider_dev); + if (node <= 0) + panic("%s called on not ofw based device.\n", __func__); + + xref = OF_xref_from_node(node); + OF_device_register_xref(xref, provider_dev); +} + +void +mbox_unregister_ofw_provider(device_t provider_dev) +{ + phandle_t xref; + + xref = OF_xref_from_device(provider_dev); + OF_device_register_xref(xref, NULL); +} +#endif diff --git a/sys/dev/mbox/mbox.h b/sys/dev/mbox/mbox.h new file mode 100644 index 000000000000..17f66d0aa06c --- /dev/null +++ b/sys/dev/mbox/mbox.h @@ -0,0 +1,70 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2016 Michal Meloun + * All rights reserved. + * + * Copyright (c) 2022 Kyle Evans + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef DEV_MBOX_MBOX_H +#define DEV_MBOX_MBOX_H + +#include "opt_platform.h" +#include +#ifdef FDT +#include +#endif + +#include "mbox_if.h" + +typedef struct mbox *mbox_t; + +/* + * Provider interface + */ +#ifdef FDT +void mbox_register_ofw_provider(device_t provider_dev); +void mbox_unregister_ofw_provider(device_t provider_dev); +#endif + +/* + * Consumer interface + */ +int mbox_get_by_id(device_t consumer_dev, device_t provider_dev, + intptr_t id, mbox_t *mb); +void mbox_release(mbox_t mb); + +int mbox_read(mbox_t mb, uint32_t *data); +int mbox_write(mbox_t mb, uint32_t data); + +#ifdef FDT +int mbox_get_by_ofw_name(device_t consumer_dev, phandle_t node, char *name, + mbox_t *mb); +int mbox_get_by_ofw_idx(device_t consumer_dev, phandle_t node, int idx, + mbox_t *mb); +#endif + +#endif /* DEV_MBOX_MBOX_H */ diff --git a/sys/dev/mbox/mbox_if.m b/sys/dev/mbox/mbox_if.m index ad29a7d73e2a..5a92505fa756 100644 --- a/sys/dev/mbox/mbox_if.m +++ b/sys/dev/mbox/mbox_if.m @@ -31,8 +31,32 @@ # system wide mailbox. # +#ifdef FDT +#include +#include +#endif + INTERFACE mbox; +#ifdef FDT +HEADER { + int mbox_default_ofw_map(device_t , phandle_t, int, pcell_t *, + intptr_t *); +}; + +# +# map fdt property cells to mbox id +# Returns 0 on success or a standard errno value. +# +METHOD int map { + device_t provider_dev; + phandle_t xref; + int ncells; + pcell_t *cells; + intptr_t *id; +} DEFAULT mbox_default_ofw_map; +#endif + METHOD int read { device_t dev; int channel; commit c552ef0829fae5584e295a0179de02245d3bde02 Author: Kyle Evans Date: Fri Apr 22 23:07:34 2022 -0500 mbox: extend interface with a "setup_channel" method This effectively establishes a conduit from the mbox driver back into the consumer, sort of 'interrupt-lite'. It assumes that the mbox driver has, e.g., an rx interrupt and will fire off the callback when the rx interrupt comes in. diff --git a/sys/dev/mbox/mbox.c b/sys/dev/mbox/mbox.c index 70a3bdf77d3b..b8c0fc27e101 100644 --- a/sys/dev/mbox/mbox.c +++ b/sys/dev/mbox/mbox.c @@ -78,6 +78,13 @@ mbox_release(mbox_t mb) free(mb, M_MBOX); } +int +mbox_setup_channel(mbox_t mb, mbox_rx_fn *rx_fn, void *data) +{ + + return (MBOX_SETUP_CHANNEL(mb->provider_dev, mb->mbox_id, rx_fn, data)); +} + int mbox_read(mbox_t mb, uint32_t *data) { diff --git a/sys/dev/mbox/mbox.h b/sys/dev/mbox/mbox.h index 17f66d0aa06c..04bd7b93cc37 100644 --- a/sys/dev/mbox/mbox.h +++ b/sys/dev/mbox/mbox.h @@ -57,6 +57,7 @@ int mbox_get_by_id(device_t consumer_dev, device_t provider_dev, intptr_t id, mbox_t *mb); void mbox_release(mbox_t mb); +int mbox_setup_channel(mbox_t mb, mbox_rx_fn *rx_fn, void *data); int mbox_read(mbox_t mb, uint32_t *data); int mbox_write(mbox_t mb, uint32_t data); diff --git a/sys/dev/mbox/mbox_if.m b/sys/dev/mbox/mbox_if.m index 5a92505fa756..e0e3d106afbd 100644 --- a/sys/dev/mbox/mbox_if.m +++ b/sys/dev/mbox/mbox_if.m @@ -38,6 +38,19 @@ INTERFACE mbox; +HEADER { + typedef void (*mbox_rx_fn)(void *data, int channel); +}; + +CODE { + static int + null_setup_channel(device_t dev, int channel, mbox_rx_fn *rx_fn, + void *rx_data) + { + return (ENXIO); + } +}; + #ifdef FDT HEADER { int mbox_default_ofw_map(device_t , phandle_t, int, pcell_t *, @@ -57,6 +70,13 @@ METHOD int map { } DEFAULT mbox_default_ofw_map; #endif +METHOD int setup_channel { + device_t dev; + int channel; + mbox_rx_fn *rx_fn; + void *rx_data; +} DEFAULT null_setup_channel; + METHOD int read { device_t dev; int channel; commit e4f1df6e54a4fc30fa782cb4a03d640aefb415c6 Author: Kyle Evans Date: Fri Apr 22 23:46:52 2022 -0500 mbox: take opaque data for read/write The upcoming Apple mbox driver will write more than a single uint32_t. Alter the interface to take arbitrary data, and have the current implementations + consumers pass in a uint32_t. diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c index 5d3336a02221..ff5ca3c69d2f 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c @@ -214,12 +214,16 @@ bcm_mbox_attach(device_t dev) * Mailbox API */ static int -bcm_mbox_write(device_t dev, int chan, uint32_t data) +bcm_mbox_write(device_t dev, int chan, const void *data, size_t datasz) { int limit = 1000; struct bcm_mbox_softc *sc = device_get_softc(dev); - dprintf("bcm_mbox_write: chan %d, data %08x\n", chan, data); + if (datasz != sizeof(uint32_t)) + return (EINVAL); + + dprintf("bcm_mbox_write: chan %d, data %08x\n", chan, + *(const uint32_t *)data); MBOX_LOCK(sc); sc->have_message[chan] = 0; while ((mbox_read_4(sc, REG_STATUS) & STATUS_FULL) && --limit) @@ -229,19 +233,21 @@ bcm_mbox_write(device_t dev, int chan, uint32_t data) MBOX_UNLOCK(sc); return (EAGAIN); } - mbox_write_4(sc, REG_WRITE, MBOX_MSG(chan, data)); + mbox_write_4(sc, REG_WRITE, MBOX_MSG(chan, *(const uint32_t *)data)); MBOX_UNLOCK(sc); return (0); } static int -bcm_mbox_read(device_t dev, int chan, uint32_t *data) +bcm_mbox_read(device_t dev, int chan, void *data, size_t datasz) { struct bcm_mbox_softc *sc = device_get_softc(dev); int err, read_chan; dprintf("bcm_mbox_read: chan %d\n", chan); + if (datasz != sizeof(uint32_t)) + return (EINVAL); err = 0; MBOX_LOCK(sc); @@ -269,12 +275,13 @@ bcm_mbox_read(device_t dev, int chan, uint32_t *data) * get data from intr handler, the same channel is never coming * because of holding sc lock. */ - *data = MBOX_DATA(sc->msg[chan]); + *(uint32_t *)data = MBOX_DATA(sc->msg[chan]); sc->msg[chan] = 0; sc->have_message[chan] = 0; out: MBOX_UNLOCK(sc); - dprintf("bcm_mbox_read: chan %d, data %08x\n", chan, *data); + dprintf("bcm_mbox_read: chan %d, data %08x\n", chan, + *(uint32_t *)data); return (err); } @@ -427,8 +434,9 @@ bcm2835_mbox_property(void *msg, size_t msg_size) bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREWRITE); - MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)msg_phys); - MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, ®); + reg = (uint32_t)msg_phys; + MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, ®, sizeof(reg)); + MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, ®, sizeof(reg)); bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREREAD); diff --git a/sys/arm/ti/ti_mbox.c b/sys/arm/ti/ti_mbox.c index 9a14bb6d38d4..4874ba02295a 100644 --- a/sys/arm/ti/ti_mbox.c +++ b/sys/arm/ti/ti_mbox.c @@ -67,8 +67,9 @@ static device_probe_t ti_mbox_probe; static device_attach_t ti_mbox_attach; static device_detach_t ti_mbox_detach; static void ti_mbox_intr(void *); -static int ti_mbox_read(device_t, int, uint32_t *); -static int ti_mbox_write(device_t, int, uint32_t); +static int ti_mbox_read(device_t, int, void *, size_t); +static int ti_mbox_write(device_t, int, const void *, + size_t); struct ti_mbox_softc { struct mtx sc_mtx; @@ -227,25 +228,29 @@ ti_mbox_intr(void *arg) } static int -ti_mbox_read(device_t dev, int chan, uint32_t *data) +ti_mbox_read(device_t dev, int chan, void *data, size_t datasz) { struct ti_mbox_softc *sc; if (chan < 0 || chan > 7) return (EINVAL); + if (datasz != sizeof(uint32_t)) + return (EINVAL); sc = device_get_softc(dev); - - return (ti_mbox_reg_read(sc, TI_MBOX_MESSAGE(chan))); + *(uint32_t *)data = ti_mbox_reg_read(sc, TI_MBOX_MESSAGE(chan)); + return (0); } static int -ti_mbox_write(device_t dev, int chan, uint32_t data) +ti_mbox_write(device_t dev, int chan, const void *data, size_t datasz) { int limit = 500; struct ti_mbox_softc *sc; if (chan < 0 || chan > 7) return (EINVAL); + if (datasz != sizeof(uint32_t)) + return (EINVAL); sc = device_get_softc(dev); TI_MBOX_LOCK(sc); /* XXX implement interrupt method */ @@ -258,7 +263,7 @@ ti_mbox_write(device_t dev, int chan, uint32_t data) TI_MBOX_UNLOCK(sc); return (EAGAIN); } - ti_mbox_reg_write(sc, TI_MBOX_MESSAGE(chan), data); + ti_mbox_reg_write(sc, TI_MBOX_MESSAGE(chan), *(const uint32_t *)data); return (0); } diff --git a/sys/contrib/vchiq/interface/compat/vchi_bsd.c b/sys/contrib/vchiq/interface/compat/vchi_bsd.c index f831880f5e13..e1b72f8339f8 100644 --- a/sys/contrib/vchiq/interface/compat/vchi_bsd.c +++ b/sys/contrib/vchiq/interface/compat/vchi_bsd.c @@ -527,5 +527,5 @@ bcm_mbox_write(int channel, uint32_t data) mbox = devclass_get_device(devclass_find("mbox"), 0); if (mbox) - MBOX_WRITE(mbox, channel, data); + MBOX_WRITE(mbox, channel, &data, sizeof(data)); } diff --git a/sys/dev/mbox/mbox.c b/sys/dev/mbox/mbox.c index b8c0fc27e101..7ed2bc9e3ab5 100644 --- a/sys/dev/mbox/mbox.c +++ b/sys/dev/mbox/mbox.c @@ -86,17 +86,17 @@ mbox_setup_channel(mbox_t mb, mbox_rx_fn *rx_fn, void *data) } int -mbox_read(mbox_t mb, uint32_t *data) +mbox_read(mbox_t mb, void *data, size_t datasz) { - return (MBOX_READ(mb->provider_dev, mb->mbox_id, data)); + return (MBOX_READ(mb->provider_dev, mb->mbox_id, data, datasz)); } int -mbox_write(mbox_t mb, uint32_t data) +mbox_write(mbox_t mb, const void *data, size_t datasz) { - return (MBOX_WRITE(mb->provider_dev, mb->mbox_id, data)); + return (MBOX_WRITE(mb->provider_dev, mb->mbox_id, data, datasz)); } #ifdef FDT diff --git a/sys/dev/mbox/mbox.h b/sys/dev/mbox/mbox.h index 04bd7b93cc37..e0c5856caa68 100644 --- a/sys/dev/mbox/mbox.h +++ b/sys/dev/mbox/mbox.h @@ -58,8 +58,8 @@ int mbox_get_by_id(device_t consumer_dev, device_t provider_dev, void mbox_release(mbox_t mb); int mbox_setup_channel(mbox_t mb, mbox_rx_fn *rx_fn, void *data); -int mbox_read(mbox_t mb, uint32_t *data); -int mbox_write(mbox_t mb, uint32_t data); +int mbox_read(mbox_t mb, void *data, size_t datasz); +int mbox_write(mbox_t mb, const void *data, size_t datasz); #ifdef FDT int mbox_get_by_ofw_name(device_t consumer_dev, phandle_t node, char *name, diff --git a/sys/dev/mbox/mbox_if.m b/sys/dev/mbox/mbox_if.m index e0e3d106afbd..1445d6fc8259 100644 --- a/sys/dev/mbox/mbox_if.m +++ b/sys/dev/mbox/mbox_if.m @@ -80,11 +80,13 @@ METHOD int setup_channel { METHOD int read { device_t dev; int channel; - uint32_t *data; + void *data; + size_t datasz; }; METHOD int write { device_t dev; int channel; - uint32_t data; + const void *data; + size_t datasz; };