1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2017 The FreeBSD Foundation 5 * All rights reserved. 6 * 7 * This software was developed by Landon Fuller under sponsorship from 8 * the FreeBSD Foundation. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer, 15 * without modification. 16 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 17 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 18 * redistribution must be conditioned upon including a substantially 19 * similar Disclaimer requirement for further binary redistribution. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 24 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 26 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 29 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGES. 32 * 33 * $FreeBSD$ 34 */ 35 36 #ifndef _BHND_EROM_BHND_EROMVAR_H_ 37 #define _BHND_EROM_BHND_EROMVAR_H_ 38 39 #include <sys/param.h> 40 41 #include "bhnd_erom.h" 42 43 /* forward declarations */ 44 struct bhnd_erom_io; 45 struct bhnd_erom_iobus; 46 47 /** @see bhnd_erom_io_map() */ 48 typedef int (bhnd_erom_io_map_t)(struct bhnd_erom_io *eio, 49 bhnd_addr_t addr, bhnd_size_t size); 50 51 /** @see bhnd_erom_io_read() */ 52 typedef uint32_t (bhnd_erom_io_read_t)(struct bhnd_erom_io *eio, 53 bhnd_size_t offset, u_int width); 54 55 /** @see bhnd_erom_io_fini() */ 56 typedef void (bhnd_erom_io_fini_t)(struct bhnd_erom_io *eio); 57 58 /** 59 * Abstract EROM bus I/O support. 60 */ 61 struct bhnd_erom_io { 62 bhnd_erom_io_map_t *map; /**< @see bhnd_erom_io_map() */ 63 bhnd_erom_io_read_t *read; /**< @see bhnd_erom_io_read() */ 64 bhnd_erom_io_fini_t *fini; /**< @see bhnd_erom_io_fini(). May be NULL */ 65 }; 66 67 /** 68 * EROM bus handle/tag I/O instance state. 69 */ 70 struct bhnd_erom_iobus { 71 struct bhnd_erom_io eio; 72 bhnd_addr_t addr; /**< the address of @p bsh */ 73 bhnd_size_t size; /**< the size of @p bsh */ 74 bus_space_tag_t bst; /**< bus space tag */ 75 bus_space_handle_t bsh; /**< bus space handle mapping the full enumeration space */ 76 bool mapped; /**< if a mapping is active */ 77 bus_size_t offset; /**< the current mapped offset within bsh */ 78 bus_size_t limit; /**< the current mapped size relative to offset */ 79 }; 80 81 #endif /* _BHND_EROM_BHND_EROMVAR_H_ */ 82