1098ca2bdSWarner Losh /*- 2a7de0b74SWarner Losh * Copyright (c) 2008, M. Warner Losh 30db7e66cSJonathan Chen * Copyright (c) 2000,2001 Jonathan Chen. 40db7e66cSJonathan Chen * All rights reserved. 5c6793aa8SWarner Losh * 6c6793aa8SWarner Losh * Redistribution and use in source and binary forms, with or without 7c6793aa8SWarner Losh * modification, are permitted provided that the following conditions 8c6793aa8SWarner Losh * are met: 9c6793aa8SWarner Losh * 1. Redistributions of source code must retain the above copyright 102dd5c91eSWarner Losh * notice, this list of conditions and the following disclaimer. 11c6793aa8SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 122dd5c91eSWarner Losh * notice, this list of conditions and the following disclaimer in the 132dd5c91eSWarner Losh * documentation and/or other materials provided with the distribution. 14c6793aa8SWarner Losh * 150db7e66cSJonathan Chen * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 160db7e66cSJonathan Chen * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 170db7e66cSJonathan Chen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 182dd5c91eSWarner Losh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 192dd5c91eSWarner Losh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 200db7e66cSJonathan Chen * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 210db7e66cSJonathan Chen * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 220db7e66cSJonathan Chen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 230db7e66cSJonathan Chen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 240db7e66cSJonathan Chen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 250db7e66cSJonathan Chen * SUCH DAMAGE. 26c6793aa8SWarner Losh * 270db7e66cSJonathan Chen * $FreeBSD$ 28c6793aa8SWarner Losh */ 29c6793aa8SWarner Losh 300db7e66cSJonathan Chen /* 310db7e66cSJonathan Chen * Structure definitions for the Cardbus Bus driver 320db7e66cSJonathan Chen */ 33a7de0b74SWarner Losh 34a7de0b74SWarner Losh /* 35a7de0b74SWarner Losh * Static copy of the CIS buffer. Technically, you aren't supposed 36a7de0b74SWarner Losh * to do this. In practice, however, it works well. 37a7de0b74SWarner Losh */ 38a7de0b74SWarner Losh struct cis_buffer 39a7de0b74SWarner Losh { 40a7de0b74SWarner Losh size_t len; /* Actual length of the CIS */ 41a7de0b74SWarner Losh uint8_t buffer[2040]; /* small enough to be 2k */ 42a7de0b74SWarner Losh }; 43a7de0b74SWarner Losh 44a7de0b74SWarner Losh /* 45a7de0b74SWarner Losh * Per child information for the PCI device. Cardbus layers on some 46a7de0b74SWarner Losh * additional data. 47a7de0b74SWarner Losh */ 48abca52f4SWarner Losh struct cardbus_devinfo 49abca52f4SWarner Losh { 507ba175acSWarner Losh struct pci_devinfo pci; 5166e390feSWarner Losh uint8_t mprefetchable; /* bit mask of prefetchable BARs */ 5266e390feSWarner Losh uint8_t mbelow1mb; /* bit mask of BARs which require below 1Mb */ 5366e390feSWarner Losh uint16_t mfrid; /* manufacturer id */ 5466e390feSWarner Losh uint16_t prodid; /* product id */ 55fbe9cff1SWarner Losh u_int funcid; /* function id */ 56fbe9cff1SWarner Losh union { 57fbe9cff1SWarner Losh struct { 5866e390feSWarner Losh uint8_t nid[6]; /* MAC address */ 59fbe9cff1SWarner Losh } lan; 60fbe9cff1SWarner Losh } funce; 6166e390feSWarner Losh uint32_t fepresent; /* bit mask of funce values present */ 62a7de0b74SWarner Losh struct cdev *sc_cisdev; 63a7de0b74SWarner Losh struct cis_buffer sc_cis; 64c6793aa8SWarner Losh }; 6547147ce7SWarner Losh 66a7de0b74SWarner Losh /* 67a7de0b74SWarner Losh * Per cardbus soft info. Not sure why we even keep this around... 68a7de0b74SWarner Losh */ 6947147ce7SWarner Losh struct cardbus_softc 7047147ce7SWarner Losh { 7147147ce7SWarner Losh device_t sc_dev; 7247147ce7SWarner Losh }; 7347147ce7SWarner Losh 74a7de0b74SWarner Losh /* 75a7de0b74SWarner Losh * Per node callback structures. 76a7de0b74SWarner Losh */ 7747147ce7SWarner Losh struct tuple_callbacks; 7847147ce7SWarner Losh typedef int (tuple_cb) (device_t cbdev, device_t child, int id, int len, 7947147ce7SWarner Losh uint8_t *tupledata, uint32_t start, uint32_t *off, 8047147ce7SWarner Losh struct tuple_callbacks *info, void *); 8147147ce7SWarner Losh struct tuple_callbacks { 8247147ce7SWarner Losh int id; 8347147ce7SWarner Losh char *name; 8447147ce7SWarner Losh tuple_cb *func; 8547147ce7SWarner Losh }; 8647147ce7SWarner Losh 87a7de0b74SWarner Losh int cardbus_device_create(struct cardbus_softc *sc, 88a7de0b74SWarner Losh struct cardbus_devinfo *devi, device_t parent, device_t child); 89a7de0b74SWarner Losh int cardbus_device_destroy(struct cardbus_devinfo *devi); 9047147ce7SWarner Losh int cardbus_parse_cis(device_t cbdev, device_t child, 9147147ce7SWarner Losh struct tuple_callbacks *callbacks, void *); 92