/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2017 The FreeBSD Foundation4*5* This software was developed by Landon Fuller under sponsorship from6* the FreeBSD Foundation.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions and the following disclaimer,13* without modification.14* 2. Redistributions in binary form must reproduce at minimum a disclaimer15* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any16* redistribution must be conditioned upon including a substantially17* similar Disclaimer requirement for further binary redistribution.18*19* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS20* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT21* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY22* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL23* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,24* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER27* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF29* THE POSSIBILITY OF SUCH DAMAGES.30*31*/3233#ifndef _BHND_EROM_BHND_EROMVAR_H_34#define _BHND_EROM_BHND_EROMVAR_H_3536#include <sys/param.h>3738#include "bhnd_erom.h"3940/* forward declarations */41struct bhnd_erom_io;42struct bhnd_erom_iobus;4344/** @see bhnd_erom_io_map() */45typedef int (bhnd_erom_io_map_t)(struct bhnd_erom_io *eio,46bhnd_addr_t addr, bhnd_size_t size);4748/** @see bhnd_erom_io_tell() */49typedef int (bhnd_erom_io_tell_t)(struct bhnd_erom_io *eio,50bhnd_addr_t *addr, bhnd_size_t *size);5152/** @see bhnd_erom_io_read() */53typedef uint32_t (bhnd_erom_io_read_t)(struct bhnd_erom_io *eio,54bhnd_size_t offset, u_int width);5556/** @see bhnd_erom_io_fini() */57typedef void (bhnd_erom_io_fini_t)(struct bhnd_erom_io *eio);5859int bhnd_erom_read_chipid(struct bhnd_erom_io *eio,60struct bhnd_chipid *cid);6162/**63* Abstract EROM bus I/O support.64*/65struct bhnd_erom_io {66bhnd_erom_io_map_t *map; /**< @see bhnd_erom_io_map() */67bhnd_erom_io_tell_t *tell; /**< @see bhnd_erom_io_tell() */68bhnd_erom_io_read_t *read; /**< @see bhnd_erom_io_read() */69bhnd_erom_io_fini_t *fini; /**< @see bhnd_erom_io_fini(). May be NULL */70};7172/**73* EROM bus handle/tag I/O instance state.74*/75struct bhnd_erom_iobus {76struct bhnd_erom_io eio;77bhnd_addr_t addr; /**< the address of @p bsh */78bhnd_size_t size; /**< the size of @p bsh */79bus_space_tag_t bst; /**< bus space tag */80bus_space_handle_t bsh; /**< bus space handle mapping the full enumeration space */81bool mapped; /**< if a mapping is active */82bus_size_t offset; /**< the current mapped offset within bsh */83bus_size_t limit; /**< the current mapped size relative to offset */84};8586#endif /* _BHND_EROM_BHND_EROMVAR_H_ */878889