1098ca2bdSWarner Losh /*- 20db7e66cSJonathan Chen * Copyright (c) 2000,2001 Jonathan Chen. 30db7e66cSJonathan Chen * All rights reserved. 4c6793aa8SWarner Losh * 5c6793aa8SWarner Losh * Redistribution and use in source and binary forms, with or without 6c6793aa8SWarner Losh * modification, are permitted provided that the following conditions 7c6793aa8SWarner Losh * are met: 8c6793aa8SWarner Losh * 1. Redistributions of source code must retain the above copyright 92dd5c91eSWarner Losh * notice, this list of conditions and the following disclaimer. 10c6793aa8SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 112dd5c91eSWarner Losh * notice, this list of conditions and the following disclaimer in the 122dd5c91eSWarner Losh * documentation and/or other materials provided with the distribution. 13c6793aa8SWarner Losh * 140db7e66cSJonathan Chen * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 150db7e66cSJonathan Chen * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 160db7e66cSJonathan Chen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 172dd5c91eSWarner Losh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 182dd5c91eSWarner Losh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 190db7e66cSJonathan Chen * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 200db7e66cSJonathan Chen * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 210db7e66cSJonathan Chen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 220db7e66cSJonathan Chen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 230db7e66cSJonathan Chen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 240db7e66cSJonathan Chen * SUCH DAMAGE. 25c6793aa8SWarner Losh * 260db7e66cSJonathan Chen * $FreeBSD$ 27c6793aa8SWarner Losh */ 28c6793aa8SWarner Losh 290db7e66cSJonathan Chen /* 300db7e66cSJonathan Chen * Structure definitions for the Cardbus Bus driver 310db7e66cSJonathan Chen */ 32abca52f4SWarner Losh struct cardbus_devinfo 33abca52f4SWarner Losh { 347ba175acSWarner Losh struct pci_devinfo pci; 3566e390feSWarner Losh uint8_t mprefetchable; /* bit mask of prefetchable BARs */ 3666e390feSWarner Losh uint8_t mbelow1mb; /* bit mask of BARs which require below 1Mb */ 3766e390feSWarner Losh uint8_t ibelow1mb; /* bit mask of BARs which require below 1Mb */ 38abca52f4SWarner Losh #define BARBIT(RID) (1<<(((RID)-PCIR_BARS)/4)) 3966e390feSWarner Losh uint16_t mfrid; /* manufacturer id */ 4066e390feSWarner Losh uint16_t prodid; /* product id */ 41fbe9cff1SWarner Losh u_int funcid; /* function id */ 42fbe9cff1SWarner Losh union { 43fbe9cff1SWarner Losh struct { 4466e390feSWarner Losh uint8_t nid[6]; /* MAC address */ 45fbe9cff1SWarner Losh } lan; 46fbe9cff1SWarner Losh } funce; 4766e390feSWarner Losh uint32_t fepresent; /* bit mask of funce values present */ 48c6793aa8SWarner Losh }; 4947147ce7SWarner Losh 5047147ce7SWarner Losh struct cis_buffer 5147147ce7SWarner Losh { 5247147ce7SWarner Losh size_t len; /* Actual length of the CIS */ 5347147ce7SWarner Losh uint8_t buffer[2040]; /* small enough to be 2k */ 5447147ce7SWarner Losh }; 5547147ce7SWarner Losh 5647147ce7SWarner Losh struct cardbus_softc 5747147ce7SWarner Losh { 5847147ce7SWarner Losh /* XXX need mutex XXX */ 5947147ce7SWarner Losh device_t sc_dev; 6047147ce7SWarner Losh struct cdev *sc_cisdev; 6147147ce7SWarner Losh struct cis_buffer *sc_cis; 6247147ce7SWarner Losh int sc_cis_open; 6347147ce7SWarner Losh }; 6447147ce7SWarner Losh 6547147ce7SWarner Losh struct tuple_callbacks; 6647147ce7SWarner Losh 6747147ce7SWarner Losh typedef int (tuple_cb) (device_t cbdev, device_t child, int id, int len, 6847147ce7SWarner Losh uint8_t *tupledata, uint32_t start, uint32_t *off, 6947147ce7SWarner Losh struct tuple_callbacks *info, void *); 7047147ce7SWarner Losh 7147147ce7SWarner Losh struct tuple_callbacks { 7247147ce7SWarner Losh int id; 7347147ce7SWarner Losh char *name; 7447147ce7SWarner Losh tuple_cb *func; 7547147ce7SWarner Losh }; 7647147ce7SWarner Losh 7747147ce7SWarner Losh int cardbus_device_create(struct cardbus_softc *); 7847147ce7SWarner Losh int cardbus_device_destroy(struct cardbus_softc *); 7947147ce7SWarner Losh int cardbus_parse_cis(device_t cbdev, device_t child, 8047147ce7SWarner Losh struct tuple_callbacks *callbacks, void *); 81