189294a78SLandon J. Fuller /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 36e778a7eSPedro F. Giffuni * 489294a78SLandon J. Fuller * Copyright (c) 2017 The FreeBSD Foundation 589294a78SLandon J. Fuller * 689294a78SLandon J. Fuller * This software was developed by Landon Fuller under sponsorship from 789294a78SLandon J. Fuller * the FreeBSD Foundation. 889294a78SLandon J. Fuller * 989294a78SLandon J. Fuller * Redistribution and use in source and binary forms, with or without 1089294a78SLandon J. Fuller * modification, are permitted provided that the following conditions 1189294a78SLandon J. Fuller * are met: 1289294a78SLandon J. Fuller * 1. Redistributions of source code must retain the above copyright 1389294a78SLandon J. Fuller * notice, this list of conditions and the following disclaimer, 1489294a78SLandon J. Fuller * without modification. 1589294a78SLandon J. Fuller * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1689294a78SLandon J. Fuller * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 1789294a78SLandon J. Fuller * redistribution must be conditioned upon including a substantially 1889294a78SLandon J. Fuller * similar Disclaimer requirement for further binary redistribution. 1989294a78SLandon J. Fuller * 2089294a78SLandon J. Fuller * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2189294a78SLandon J. Fuller * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2289294a78SLandon J. Fuller * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 2389294a78SLandon J. Fuller * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 2489294a78SLandon J. Fuller * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 2589294a78SLandon J. Fuller * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2689294a78SLandon J. Fuller * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2789294a78SLandon J. Fuller * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 2889294a78SLandon J. Fuller * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2989294a78SLandon J. Fuller * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 3089294a78SLandon J. Fuller * THE POSSIBILITY OF SUCH DAMAGES. 3189294a78SLandon J. Fuller * 3289294a78SLandon J. Fuller */ 3389294a78SLandon J. Fuller 3489294a78SLandon J. Fuller #ifndef _BHND_EROM_BHND_EROMVAR_H_ 3589294a78SLandon J. Fuller #define _BHND_EROM_BHND_EROMVAR_H_ 3689294a78SLandon J. Fuller 3789294a78SLandon J. Fuller #include <sys/param.h> 3889294a78SLandon J. Fuller 3989294a78SLandon J. Fuller #include "bhnd_erom.h" 4089294a78SLandon J. Fuller 4189294a78SLandon J. Fuller /* forward declarations */ 4289294a78SLandon J. Fuller struct bhnd_erom_io; 4389294a78SLandon J. Fuller struct bhnd_erom_iobus; 4489294a78SLandon J. Fuller 4589294a78SLandon J. Fuller /** @see bhnd_erom_io_map() */ 4689294a78SLandon J. Fuller typedef int (bhnd_erom_io_map_t)(struct bhnd_erom_io *eio, 4789294a78SLandon J. Fuller bhnd_addr_t addr, bhnd_size_t size); 4889294a78SLandon J. Fuller 49f3524ec8SLandon J. Fuller /** @see bhnd_erom_io_tell() */ 50f3524ec8SLandon J. Fuller typedef int (bhnd_erom_io_tell_t)(struct bhnd_erom_io *eio, 51f3524ec8SLandon J. Fuller bhnd_addr_t *addr, bhnd_size_t *size); 52f3524ec8SLandon J. Fuller 5389294a78SLandon J. Fuller /** @see bhnd_erom_io_read() */ 5489294a78SLandon J. Fuller typedef uint32_t (bhnd_erom_io_read_t)(struct bhnd_erom_io *eio, 5589294a78SLandon J. Fuller bhnd_size_t offset, u_int width); 5689294a78SLandon J. Fuller 5789294a78SLandon J. Fuller /** @see bhnd_erom_io_fini() */ 5889294a78SLandon J. Fuller typedef void (bhnd_erom_io_fini_t)(struct bhnd_erom_io *eio); 5989294a78SLandon J. Fuller 60f3524ec8SLandon J. Fuller int bhnd_erom_read_chipid(struct bhnd_erom_io *eio, 61f3524ec8SLandon J. Fuller struct bhnd_chipid *cid); 62f3524ec8SLandon J. Fuller 6389294a78SLandon J. Fuller /** 6489294a78SLandon J. Fuller * Abstract EROM bus I/O support. 6589294a78SLandon J. Fuller */ 6689294a78SLandon J. Fuller struct bhnd_erom_io { 6789294a78SLandon J. Fuller bhnd_erom_io_map_t *map; /**< @see bhnd_erom_io_map() */ 68f3524ec8SLandon J. Fuller bhnd_erom_io_tell_t *tell; /**< @see bhnd_erom_io_tell() */ 6989294a78SLandon J. Fuller bhnd_erom_io_read_t *read; /**< @see bhnd_erom_io_read() */ 7089294a78SLandon J. Fuller bhnd_erom_io_fini_t *fini; /**< @see bhnd_erom_io_fini(). May be NULL */ 7189294a78SLandon J. Fuller }; 7289294a78SLandon J. Fuller 7389294a78SLandon J. Fuller /** 7489294a78SLandon J. Fuller * EROM bus handle/tag I/O instance state. 7589294a78SLandon J. Fuller */ 7689294a78SLandon J. Fuller struct bhnd_erom_iobus { 7789294a78SLandon J. Fuller struct bhnd_erom_io eio; 7889294a78SLandon J. Fuller bhnd_addr_t addr; /**< the address of @p bsh */ 7989294a78SLandon J. Fuller bhnd_size_t size; /**< the size of @p bsh */ 8089294a78SLandon J. Fuller bus_space_tag_t bst; /**< bus space tag */ 8189294a78SLandon J. Fuller bus_space_handle_t bsh; /**< bus space handle mapping the full enumeration space */ 8289294a78SLandon J. Fuller bool mapped; /**< if a mapping is active */ 8389294a78SLandon J. Fuller bus_size_t offset; /**< the current mapped offset within bsh */ 8489294a78SLandon J. Fuller bus_size_t limit; /**< the current mapped size relative to offset */ 8589294a78SLandon J. Fuller }; 8689294a78SLandon J. Fuller 8789294a78SLandon J. Fuller #endif /* _BHND_EROM_BHND_EROMVAR_H_ */ 88