sibavar.h revision 183371
1/*- 2 * Copyright (c) 2007 Bruce M. Simpson. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: head/sys/dev/siba/sibavar.h 183371 2008-09-26 03:57:23Z imp $ 27 */ 28 29#ifndef _SIBA_SIBAVAR_H_ 30#define _SIBA_SIBAVAR_H_ 31 32#include <sys/rman.h> 33 34struct siba_softc { 35 device_t sc_dev; /* Device ID */ 36 struct resource *sc_mem; /* Memory window on nexus */ 37 38 bus_space_tag_t sc_bt; 39 bus_space_handle_t sc_bh; 40 bus_addr_t sc_maddr; 41 bus_size_t sc_msize; 42 43 uint8_t sc_ncores; 44}; 45 46struct siba_devinfo { 47 struct resource_list sdi_rl; 48 /*devhandle_t sdi_devhandle; XXX*/ 49 /*struct rman sdi_intr_rman;*/ 50 51 /* Accessors are needed for ivars below. */ 52 uint16_t sdi_vid; 53 uint16_t sdi_devid; 54 uint8_t sdi_rev; 55 uint8_t sdi_idx; /* core index on bus */ 56 uint8_t sdi_irq; /* TODO */ 57}; 58 59#define siba_read_2(sc, core, reg) \ 60 bus_space_read_2((sc)->sc_bt, (sc)->sc_bh, \ 61 (core * SIBA_CORE_LEN) + (reg)) 62 63#define siba_read_4(sc, core, reg) \ 64 bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, \ 65 (core * SIBA_CORE_LEN) + (reg)) 66 67#define siba_write_2(sc, core, reg, val) \ 68 bus_space_write_2((sc)->sc_bt, (sc)->sc_bh, \ 69 (core * SIBA_CORE_LEN) + (reg), (val)) 70 71#define siba_write_4(sc, core, reg, val) \ 72 bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, \ 73 (core * SIBA_CORE_LEN) + (reg), (val)) 74 75enum siba_device_ivars { 76 SIBA_IVAR_VENDOR, 77 SIBA_IVAR_DEVICE, 78 SIBA_IVAR_REVID, 79 SIBA_IVAR_CORE_INDEX 80}; 81 82#define SIBA_ACCESSOR(var, ivar, type) \ 83 __BUS_ACCESSOR(siba, var, SIBA, ivar, type) 84 85SIBA_ACCESSOR(vendor, VENDOR, uint16_t) 86SIBA_ACCESSOR(device, DEVICE, uint16_t) 87SIBA_ACCESSOR(revid, REVID, uint8_t) 88SIBA_ACCESSOR(core_index, CORE_INDEX, uint8_t) 89 90#undef SIBA_ACCESSOR 91 92#endif /* _SIBA_SIBAVAR_H_ */ 93