2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2008-11-17 01:32:29 +00:00
|
|
|
* Copyright (c) 2005-2008, M. Warner Losh
|
2000-10-18 03:25:13 +00:00
|
|
|
* Copyright (c) 2000,2001 Jonathan Chen.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
2005-01-13 19:12:10 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
2000-10-18 03:25:13 +00:00
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
2005-01-13 19:12:10 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2000-10-18 03:25:13 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
2005-01-13 19:12:10 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
2000-10-18 03:25:13 +00:00
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/*
|
|
|
|
* CIS Handling for the Cardbus Bus
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2001-01-06 18:04:55 +00:00
|
|
|
#include <sys/malloc.h>
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
2003-02-16 00:20:24 +00:00
|
|
|
#include <sys/endian.h>
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-02-27 05:09:14 +00:00
|
|
|
#include <sys/pciio.h>
|
2001-08-27 00:09:42 +00:00
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2003-10-07 03:33:54 +00:00
|
|
|
#include <dev/pccard/pccardvar.h>
|
|
|
|
#include <dev/pccard/pccard_cis.h>
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
#include <dev/cardbus/cardbusreg.h>
|
2001-08-27 00:09:42 +00:00
|
|
|
#include <dev/cardbus/cardbusvar.h>
|
2000-10-18 03:25:13 +00:00
|
|
|
#include <dev/cardbus/cardbus_cis.h>
|
|
|
|
|
2002-03-07 08:10:42 +00:00
|
|
|
extern int cardbus_cis_debug;
|
|
|
|
|
|
|
|
#define DPRINTF(a) if (cardbus_cis_debug) printf a
|
|
|
|
#define DEVPRINTF(x) if (cardbus_cis_debug) device_printf x
|
|
|
|
|
2006-01-03 03:16:53 +00:00
|
|
|
#define CIS_CONFIG_SPACE (struct resource *)~0UL
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_generic(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_linktarget(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_vers_1(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_funcid(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_manfid(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_funce(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_bar(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_unhandled(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
static int decode_tuple_end(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *);
|
2003-02-12 06:11:47 +00:00
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
static int cardbus_read_tuple_conf(device_t cbdev, device_t child,
|
2003-01-27 05:47:01 +00:00
|
|
|
uint32_t start, uint32_t *off, int *tupleid, int *len,
|
|
|
|
uint8_t *tupledata);
|
2001-08-27 00:09:42 +00:00
|
|
|
static int cardbus_read_tuple_mem(device_t cbdev, struct resource *res,
|
2003-01-27 05:47:01 +00:00
|
|
|
uint32_t start, uint32_t *off, int *tupleid, int *len,
|
|
|
|
uint8_t *tupledata);
|
2001-08-26 23:55:34 +00:00
|
|
|
static int cardbus_read_tuple(device_t cbdev, device_t child,
|
2003-01-27 05:47:01 +00:00
|
|
|
struct resource *res, uint32_t start, uint32_t *off,
|
|
|
|
int *tupleid, int *len, uint8_t *tupledata);
|
2001-08-27 00:09:42 +00:00
|
|
|
static void cardbus_read_tuple_finish(device_t cbdev, device_t child,
|
|
|
|
int rid, struct resource *res);
|
|
|
|
static struct resource *cardbus_read_tuple_init(device_t cbdev, device_t child,
|
2003-01-27 05:47:01 +00:00
|
|
|
uint32_t *start, int *rid);
|
2001-08-26 23:55:34 +00:00
|
|
|
static int decode_tuple(device_t cbdev, device_t child, int tupleid,
|
2003-01-27 05:47:01 +00:00
|
|
|
int len, uint8_t *tupledata, uint32_t start,
|
2005-12-29 01:43:47 +00:00
|
|
|
uint32_t *off, struct tuple_callbacks *callbacks,
|
|
|
|
void *);
|
2001-08-26 23:55:34 +00:00
|
|
|
|
|
|
|
#define MAKETUPLE(NAME,FUNC) { CISTPL_ ## NAME, #NAME, decode_tuple_ ## FUNC }
|
|
|
|
|
|
|
|
static char *funcnames[] = {
|
2000-10-18 03:25:13 +00:00
|
|
|
"Multi-Functioned",
|
|
|
|
"Memory",
|
|
|
|
"Serial Port",
|
|
|
|
"Parallel Port",
|
|
|
|
"Fixed Disk",
|
|
|
|
"Video Adaptor",
|
|
|
|
"Network Adaptor",
|
|
|
|
"AIMS",
|
|
|
|
"SCSI",
|
|
|
|
"Security"
|
|
|
|
};
|
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
/*
|
|
|
|
* Handler functions for various CIS tuples
|
|
|
|
*/
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_generic(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
if (cardbus_cis_debug) {
|
|
|
|
if (info)
|
|
|
|
printf("TUPLE: %s [%d]:", info->name, len);
|
|
|
|
else
|
|
|
|
printf("TUPLE: Unknown(0x%02x) [%d]:", id, len);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (i % 0x10 == 0 && len > 0x10)
|
|
|
|
printf("\n 0x%02x:", i);
|
|
|
|
printf(" %02x", tupledata[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_linktarget(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2000-11-29 16:08:01 +00:00
|
|
|
int i;
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
if (cardbus_cis_debug) {
|
|
|
|
printf("TUPLE: %s [%d]:", info->name, len);
|
2000-11-29 16:08:01 +00:00
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (i % 0x10 == 0 && len > 0x10)
|
|
|
|
printf("\n 0x%02x:", i);
|
|
|
|
printf(" %02x", tupledata[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
2000-11-29 16:08:01 +00:00
|
|
|
}
|
2000-11-28 00:08:18 +00:00
|
|
|
if (len != 3 || tupledata[0] != 'C' || tupledata[1] != 'I' ||
|
|
|
|
tupledata[2] != 'S') {
|
2000-10-18 03:25:13 +00:00
|
|
|
printf("Invalid data for CIS Link Target!\n");
|
2001-08-26 23:55:34 +00:00
|
|
|
decode_tuple_generic(cbdev, child, id, len, tupledata,
|
2005-12-29 01:43:47 +00:00
|
|
|
start, off, info, argp);
|
2002-03-07 00:11:42 +00:00
|
|
|
return (EINVAL);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_vers_1(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
|
|
|
int i;
|
2002-11-27 06:56:29 +00:00
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
if (cardbus_cis_debug) {
|
|
|
|
printf("Product version: %d.%d\n", tupledata[0], tupledata[1]);
|
|
|
|
printf("Product name: ");
|
|
|
|
for (i = 2; i < len; i++) {
|
|
|
|
if (tupledata[i] == '\0')
|
|
|
|
printf(" | ");
|
|
|
|
else if (tupledata[i] == 0xff)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
printf("%c", tupledata[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_funcid(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-11-27 06:56:29 +00:00
|
|
|
struct cardbus_devinfo *dinfo = device_get_ivars(child);
|
2016-04-19 23:37:24 +00:00
|
|
|
int numnames = nitems(funcnames);
|
2002-11-27 06:56:29 +00:00
|
|
|
int i;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
if (cardbus_cis_debug) {
|
|
|
|
printf("Functions: ");
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (tupledata[i] < numnames)
|
|
|
|
printf("%s", funcnames[tupledata[i]]);
|
|
|
|
else
|
|
|
|
printf("Unknown(%d)", tupledata[i]);
|
2005-12-29 01:43:47 +00:00
|
|
|
if (i < len - 1)
|
2003-02-12 06:11:47 +00:00
|
|
|
printf(", ");
|
|
|
|
}
|
|
|
|
printf("\n");
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2002-11-27 06:56:29 +00:00
|
|
|
if (len > 0)
|
|
|
|
dinfo->funcid = tupledata[0]; /* use first in list */
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_manfid(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-11-27 06:56:29 +00:00
|
|
|
struct cardbus_devinfo *dinfo = device_get_ivars(child);
|
2000-10-18 03:25:13 +00:00
|
|
|
int i;
|
2002-11-27 06:56:29 +00:00
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
if (cardbus_cis_debug) {
|
|
|
|
printf("Manufacturer ID: ");
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
printf("%02x", tupledata[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2002-11-27 06:56:29 +00:00
|
|
|
|
|
|
|
if (len == 5) {
|
2003-02-12 06:11:47 +00:00
|
|
|
dinfo->mfrid = tupledata[1] | (tupledata[2] << 8);
|
|
|
|
dinfo->prodid = tupledata[3] | (tupledata[4] << 8);
|
2002-11-27 06:56:29 +00:00
|
|
|
}
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_funce(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-11-27 06:56:29 +00:00
|
|
|
struct cardbus_devinfo *dinfo = device_get_ivars(child);
|
|
|
|
int type, i;
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
if (cardbus_cis_debug) {
|
|
|
|
printf("Function Extension: ");
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
printf("%02x", tupledata[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2002-11-27 06:56:29 +00:00
|
|
|
if (len < 2) /* too short */
|
|
|
|
return (0);
|
|
|
|
type = tupledata[0]; /* XXX <32 always? */
|
|
|
|
switch (dinfo->funcid) {
|
2005-02-06 21:03:13 +00:00
|
|
|
case PCCARD_FUNCTION_NETWORK:
|
2002-11-27 06:56:29 +00:00
|
|
|
switch (type) {
|
2005-02-06 21:03:13 +00:00
|
|
|
case PCCARD_TPLFE_TYPE_LAN_NID:
|
2003-02-12 06:11:47 +00:00
|
|
|
if (tupledata[1] > sizeof(dinfo->funce.lan.nid)) {
|
|
|
|
/* ignore, warning? */
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
bcopy(tupledata + 2, dinfo->funce.lan.nid,
|
|
|
|
tupledata[1]);
|
2002-11-27 06:56:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
dinfo->fepresent |= 1<<type;
|
|
|
|
break;
|
|
|
|
}
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_bar(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-11-12 08:23:27 +00:00
|
|
|
struct cardbus_devinfo *dinfo = device_get_ivars(child);
|
|
|
|
int type;
|
2003-02-16 00:20:24 +00:00
|
|
|
uint8_t reg;
|
2006-01-03 03:36:17 +00:00
|
|
|
uint32_t bar;
|
2002-11-12 08:23:27 +00:00
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
if (len != 6) {
|
2003-02-16 00:20:24 +00:00
|
|
|
device_printf(cbdev, "CIS BAR length not 6 (%d)\n", len);
|
2002-03-07 00:11:42 +00:00
|
|
|
return (EINVAL);
|
2002-11-12 08:23:27 +00:00
|
|
|
}
|
2003-02-16 00:20:24 +00:00
|
|
|
|
|
|
|
reg = *tupledata;
|
|
|
|
len = le32toh(*(uint32_t*)(tupledata + 2));
|
2006-01-03 03:16:53 +00:00
|
|
|
if (reg & TPL_BAR_REG_AS)
|
2002-11-12 08:23:27 +00:00
|
|
|
type = SYS_RES_IOPORT;
|
2006-01-03 03:16:53 +00:00
|
|
|
else
|
2002-11-12 08:23:27 +00:00
|
|
|
type = SYS_RES_MEMORY;
|
2003-02-16 00:20:24 +00:00
|
|
|
|
|
|
|
bar = reg & TPL_BAR_REG_ASI_MASK;
|
|
|
|
if (bar == 0) {
|
|
|
|
device_printf(cbdev, "Invalid BAR type 0 in CIS\n");
|
|
|
|
return (EINVAL); /* XXX Return an error? */
|
|
|
|
} else if (bar == 7) {
|
|
|
|
/* XXX Should we try to map in Option ROMs? */
|
2002-11-12 08:23:27 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2003-02-17 23:47:31 +00:00
|
|
|
|
|
|
|
/* Convert from BAR type to BAR offset */
|
2005-10-28 05:30:47 +00:00
|
|
|
bar = PCIR_BAR(bar - 1);
|
2003-02-16 00:20:24 +00:00
|
|
|
|
2002-11-12 08:23:27 +00:00
|
|
|
if (type == SYS_RES_MEMORY) {
|
2003-02-17 23:47:31 +00:00
|
|
|
if (reg & TPL_BAR_REG_PREFETCHABLE)
|
2005-12-30 19:23:32 +00:00
|
|
|
dinfo->mprefetchable |= (1 << PCI_RID2BAR(bar));
|
2004-04-11 19:22:25 +00:00
|
|
|
/*
|
2008-11-15 05:22:06 +00:00
|
|
|
* The PC Card spec says we're only supposed to honor this
|
|
|
|
* hint when the cardbus bridge is a child of pci0 (the main
|
|
|
|
* bus). The PC Card spec seems to indicate that this should
|
|
|
|
* only be done on x86 based machines, which suggests that on
|
2011-06-06 13:21:11 +00:00
|
|
|
* non-x86 machines the addresses can be anywhere. Since the
|
2008-11-15 05:22:06 +00:00
|
|
|
* hardware can do it on non-x86 machines, it should be able
|
|
|
|
* to do it on x86 machines too. Therefore, we can and should
|
|
|
|
* ignore this hint. Furthermore, the PC Card spec recommends
|
|
|
|
* always allocating memory above 1MB, contradicting the other
|
|
|
|
* part of the PC Card spec, it seems. We make note of it,
|
|
|
|
* but otherwise don't use this information.
|
2004-04-11 19:22:25 +00:00
|
|
|
*
|
2008-11-15 05:22:06 +00:00
|
|
|
* Some Realtek cards have this set in their CIS, but fail
|
|
|
|
* to actually work when mapped this way, and experience
|
|
|
|
* has shown ignoring this big to be a wise choice.
|
|
|
|
*
|
|
|
|
* XXX We should cite chapter and verse for standard refs.
|
2004-04-11 19:22:25 +00:00
|
|
|
*/
|
2003-02-17 23:47:31 +00:00
|
|
|
if (reg & TPL_BAR_REG_BELOW1MB)
|
2005-12-30 19:23:32 +00:00
|
|
|
dinfo->mbelow1mb |= (1 << PCI_RID2BAR(bar));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2003-02-16 00:20:24 +00:00
|
|
|
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_unhandled(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2003-02-12 06:11:47 +00:00
|
|
|
/* Make this message suck less XXX */
|
2001-08-26 23:55:34 +00:00
|
|
|
printf("TUPLE: %s [%d] is unhandled! Bailing...", info->name, len);
|
2005-12-29 01:43:47 +00:00
|
|
|
return (EINVAL);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-12 06:11:47 +00:00
|
|
|
static int
|
|
|
|
decode_tuple_end(device_t cbdev, device_t child, int id,
|
|
|
|
int len, uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *info, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2005-02-20 20:36:16 +00:00
|
|
|
if (cardbus_cis_debug)
|
2003-02-12 06:11:47 +00:00
|
|
|
printf("CIS reading done\n");
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
/*
|
|
|
|
* Functions to read the a tuple from the card
|
|
|
|
*/
|
|
|
|
|
2011-06-21 22:45:31 +00:00
|
|
|
/*
|
|
|
|
* Read CIS bytes out of the config space. We have to read it 4 bytes at a
|
|
|
|
* time and do the usual mask and shift to return the bytes. The standard
|
|
|
|
* defines the byte order to be little endian. pci_read_config converts it to
|
|
|
|
* host byte order. This is why we have no endian conversion functions: the
|
|
|
|
* shifts wind up being endian neutral. This is also why we avoid the obvious
|
|
|
|
* memcpy optimization.
|
|
|
|
*/
|
2000-11-28 00:08:18 +00:00
|
|
|
static int
|
2003-01-27 05:47:01 +00:00
|
|
|
cardbus_read_tuple_conf(device_t cbdev, device_t child, uint32_t start,
|
|
|
|
uint32_t *off, int *tupleid, int *len, uint8_t *tupledata)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2000-11-28 00:08:18 +00:00
|
|
|
int i, j;
|
2003-01-27 05:47:01 +00:00
|
|
|
uint32_t e;
|
|
|
|
uint32_t loc;
|
2000-11-29 16:08:01 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
loc = start + *off;
|
2000-11-28 00:52:40 +00:00
|
|
|
|
2011-06-21 22:45:31 +00:00
|
|
|
e = pci_read_config(child, loc & ~0x3, 4);
|
|
|
|
e >>= 8 * (loc & 0x3);
|
2000-11-28 00:08:18 +00:00
|
|
|
*len = 0;
|
2000-11-29 16:08:01 +00:00
|
|
|
for (i = loc, j = -2; j < *len; j++, i++) {
|
2011-06-21 22:45:31 +00:00
|
|
|
if ((i & 0x3) == 0)
|
2000-11-28 00:08:18 +00:00
|
|
|
e = pci_read_config(child, i, 4);
|
|
|
|
if (j == -2)
|
|
|
|
*tupleid = 0xff & e;
|
|
|
|
else if (j == -1)
|
|
|
|
*len = 0xff & e;
|
|
|
|
else
|
|
|
|
tupledata[j] = 0xff & e;
|
|
|
|
e >>= 8;
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2001-08-26 23:55:34 +00:00
|
|
|
*off += *len + 2;
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2011-06-21 22:45:31 +00:00
|
|
|
/*
|
|
|
|
* Read the CIS data out of memroy. We indirect through the bus space
|
|
|
|
* routines to ensure proper byte ordering conversions when necessary.
|
|
|
|
*/
|
2000-10-18 03:25:13 +00:00
|
|
|
static int
|
2003-01-27 05:47:01 +00:00
|
|
|
cardbus_read_tuple_mem(device_t cbdev, struct resource *res, uint32_t start,
|
|
|
|
uint32_t *off, int *tupleid, int *len, uint8_t *tupledata)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2001-08-27 00:09:42 +00:00
|
|
|
int ret;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2009-12-30 20:42:07 +00:00
|
|
|
*tupleid = bus_read_1(res, start + *off);
|
|
|
|
*len = bus_read_1(res, start + *off + 1);
|
|
|
|
bus_read_region_1(res, *off + start + 2, tupledata, *len);
|
2001-08-27 00:09:42 +00:00
|
|
|
ret = 0;
|
|
|
|
*off += *len + 2;
|
2002-03-07 00:11:42 +00:00
|
|
|
return (ret);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-08-27 00:09:42 +00:00
|
|
|
cardbus_read_tuple(device_t cbdev, device_t child, struct resource *res,
|
2003-01-27 05:47:01 +00:00
|
|
|
uint32_t start, uint32_t *off, int *tupleid, int *len,
|
|
|
|
uint8_t *tupledata)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2006-01-03 03:36:17 +00:00
|
|
|
if (res == CIS_CONFIG_SPACE)
|
2002-03-07 00:11:42 +00:00
|
|
|
return (cardbus_read_tuple_conf(cbdev, child, start, off,
|
|
|
|
tupleid, len, tupledata));
|
2006-01-03 03:36:17 +00:00
|
|
|
return (cardbus_read_tuple_mem(cbdev, res, start, off, tupleid, len,
|
|
|
|
tupledata));
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
static void
|
|
|
|
cardbus_read_tuple_finish(device_t cbdev, device_t child, int rid,
|
|
|
|
struct resource *res)
|
|
|
|
{
|
2006-01-03 03:16:53 +00:00
|
|
|
if (res != CIS_CONFIG_SPACE) {
|
2006-01-03 03:36:17 +00:00
|
|
|
bus_release_resource(child, SYS_RES_MEMORY, rid, res);
|
2011-09-12 15:21:52 +00:00
|
|
|
bus_delete_resource(child, SYS_RES_MEMORY, rid);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
static struct resource *
|
2003-01-27 05:47:01 +00:00
|
|
|
cardbus_read_tuple_init(device_t cbdev, device_t child, uint32_t *start,
|
2001-08-27 00:09:42 +00:00
|
|
|
int *rid)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2001-08-27 00:09:42 +00:00
|
|
|
struct resource *res;
|
2005-10-28 05:30:47 +00:00
|
|
|
uint32_t space;
|
2001-08-27 00:09:42 +00:00
|
|
|
|
2005-10-28 05:55:52 +00:00
|
|
|
space = *start & PCIM_CIS_ASI_MASK;
|
2005-10-28 05:30:47 +00:00
|
|
|
switch (space) {
|
2007-05-16 18:42:38 +00:00
|
|
|
case PCIM_CIS_ASI_CONFIG:
|
2009-03-13 05:31:27 +00:00
|
|
|
DEVPRINTF((cbdev, "CIS in PCI config space\n"));
|
2002-11-12 08:23:27 +00:00
|
|
|
/* CIS in PCI config space need no initialization */
|
2006-01-03 03:16:53 +00:00
|
|
|
return (CIS_CONFIG_SPACE);
|
2005-10-28 05:55:52 +00:00
|
|
|
case PCIM_CIS_ASI_BAR0:
|
|
|
|
case PCIM_CIS_ASI_BAR1:
|
|
|
|
case PCIM_CIS_ASI_BAR2:
|
|
|
|
case PCIM_CIS_ASI_BAR3:
|
|
|
|
case PCIM_CIS_ASI_BAR4:
|
|
|
|
case PCIM_CIS_ASI_BAR5:
|
|
|
|
*rid = PCIR_BAR(space - PCIM_CIS_ASI_BAR0);
|
2009-03-13 05:31:27 +00:00
|
|
|
DEVPRINTF((cbdev, "CIS in BAR %#x\n", *rid));
|
2001-08-27 00:09:42 +00:00
|
|
|
break;
|
2005-10-28 05:55:52 +00:00
|
|
|
case PCIM_CIS_ASI_ROM:
|
|
|
|
*rid = PCIR_BIOS;
|
2009-03-13 05:31:27 +00:00
|
|
|
DEVPRINTF((cbdev, "CIS in option rom\n"));
|
2001-08-27 00:09:42 +00:00
|
|
|
break;
|
2000-10-18 03:25:13 +00:00
|
|
|
default:
|
2001-08-26 23:55:34 +00:00
|
|
|
device_printf(cbdev, "Unable to read CIS: Unknown space: %d\n",
|
2005-10-28 05:30:47 +00:00
|
|
|
space);
|
2002-03-07 00:11:42 +00:00
|
|
|
return (NULL);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate the memory space to read CIS */
|
2011-06-06 13:21:11 +00:00
|
|
|
res = bus_alloc_resource_any(child, SYS_RES_MEMORY, rid,
|
2005-12-29 01:43:47 +00:00
|
|
|
rman_make_alignment_flags(4096) | RF_ACTIVE);
|
2001-08-27 00:09:42 +00:00
|
|
|
if (res == NULL) {
|
|
|
|
device_printf(cbdev, "Unable to allocate resource "
|
|
|
|
"to read CIS.\n");
|
2002-03-07 00:11:42 +00:00
|
|
|
return (NULL);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.
On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).
Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.
Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)
Tested PAE and devinfo on virtualbox (live CD)
Special thanks to bz for his testing on ARM.
Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544
2016-03-18 01:28:41 +00:00
|
|
|
DEVPRINTF((cbdev, "CIS Mapped to %#jx\n",
|
|
|
|
rman_get_start(res)));
|
2001-08-27 00:09:42 +00:00
|
|
|
|
|
|
|
/* Flip to the right ROM image if CIS is in ROM */
|
2005-10-28 05:55:52 +00:00
|
|
|
if (space == PCIM_CIS_ASI_ROM) {
|
2003-01-27 05:47:01 +00:00
|
|
|
uint32_t imagesize;
|
|
|
|
uint32_t imagebase = 0;
|
|
|
|
uint32_t pcidata;
|
|
|
|
uint16_t romsig;
|
2001-08-27 00:09:42 +00:00
|
|
|
int romnum = 0;
|
2002-11-12 08:23:27 +00:00
|
|
|
int imagenum;
|
2001-08-27 00:09:42 +00:00
|
|
|
|
2005-10-28 05:55:52 +00:00
|
|
|
imagenum = (*start & PCIM_CIS_ROM_MASK) >> 28;
|
2001-08-27 00:09:42 +00:00
|
|
|
for (romnum = 0;; romnum++) {
|
2009-12-30 20:42:07 +00:00
|
|
|
romsig = bus_read_2(res,
|
2002-11-12 08:23:27 +00:00
|
|
|
imagebase + CARDBUS_EXROM_SIGNATURE);
|
|
|
|
if (romsig != 0xaa55) {
|
2001-08-27 00:09:42 +00:00
|
|
|
device_printf(cbdev, "Bad header in rom %d: "
|
2003-02-12 04:48:15 +00:00
|
|
|
"[%x] %04x\n", romnum, imagebase +
|
2002-11-12 08:23:27 +00:00
|
|
|
CARDBUS_EXROM_SIGNATURE, romsig);
|
2009-12-30 20:49:13 +00:00
|
|
|
cardbus_read_tuple_finish(cbdev, child, *rid,
|
|
|
|
res);
|
2001-08-27 00:09:42 +00:00
|
|
|
*rid = 0;
|
2002-03-07 00:11:42 +00:00
|
|
|
return (NULL);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2002-11-12 08:23:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If this was the Option ROM image that we were
|
|
|
|
* looking for, then we are done.
|
|
|
|
*/
|
|
|
|
if (romnum == imagenum)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Find out where the next Option ROM image is */
|
2009-12-30 20:42:07 +00:00
|
|
|
pcidata = imagebase + bus_read_2(res,
|
2002-11-12 08:23:27 +00:00
|
|
|
imagebase + CARDBUS_EXROM_DATA_PTR);
|
2009-12-30 20:42:07 +00:00
|
|
|
imagesize = bus_read_2(res,
|
2002-11-12 08:23:27 +00:00
|
|
|
pcidata + CARDBUS_EXROM_DATA_IMAGE_LENGTH);
|
2001-08-27 00:09:42 +00:00
|
|
|
|
|
|
|
if (imagesize == 0) {
|
|
|
|
/*
|
|
|
|
* XXX some ROMs seem to have this as zero,
|
|
|
|
* can we assume this means 1 block?
|
|
|
|
*/
|
2002-11-12 08:23:27 +00:00
|
|
|
device_printf(cbdev, "Warning, size of Option "
|
|
|
|
"ROM image %d is 0 bytes, assuming 512 "
|
|
|
|
"bytes.\n", romnum);
|
2001-08-27 00:09:42 +00:00
|
|
|
imagesize = 1;
|
|
|
|
}
|
2002-11-12 08:23:27 +00:00
|
|
|
|
|
|
|
/* Image size is in 512 byte units */
|
2001-08-27 00:09:42 +00:00
|
|
|
imagesize <<= 9;
|
|
|
|
|
2009-12-30 20:42:07 +00:00
|
|
|
if ((bus_read_1(res, pcidata +
|
2002-11-12 09:45:59 +00:00
|
|
|
CARDBUS_EXROM_DATA_INDICATOR) & 0x80) != 0) {
|
2002-11-12 08:23:27 +00:00
|
|
|
device_printf(cbdev, "Cannot find CIS in "
|
|
|
|
"Option ROM\n");
|
2009-12-30 22:34:26 +00:00
|
|
|
cardbus_read_tuple_finish(cbdev, child, *rid,
|
|
|
|
res);
|
2002-11-12 08:23:27 +00:00
|
|
|
*rid = 0;
|
2002-03-07 00:11:42 +00:00
|
|
|
return (NULL);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2002-11-12 08:23:27 +00:00
|
|
|
imagebase += imagesize;
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2005-10-28 05:55:52 +00:00
|
|
|
*start = imagebase + (*start & PCIM_CIS_ADDR_MASK);
|
2001-08-27 00:09:42 +00:00
|
|
|
} else {
|
2005-10-28 05:55:52 +00:00
|
|
|
*start = *start & PCIM_CIS_ADDR_MASK;
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2009-03-13 05:31:27 +00:00
|
|
|
DEVPRINTF((cbdev, "CIS offset is %#x\n", *start));
|
2002-11-12 08:23:27 +00:00
|
|
|
|
2002-03-07 00:11:42 +00:00
|
|
|
return (res);
|
2000-11-28 00:08:18 +00:00
|
|
|
}
|
2000-11-28 00:52:40 +00:00
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
/*
|
|
|
|
* Dispatch the right handler function per tuple
|
|
|
|
*/
|
|
|
|
|
2000-11-28 00:08:18 +00:00
|
|
|
static int
|
2001-08-26 23:55:34 +00:00
|
|
|
decode_tuple(device_t cbdev, device_t child, int tupleid, int len,
|
2003-01-27 05:47:01 +00:00
|
|
|
uint8_t *tupledata, uint32_t start, uint32_t *off,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *callbacks, void *argp)
|
2000-11-28 00:08:18 +00:00
|
|
|
{
|
|
|
|
int i;
|
2001-01-06 18:04:55 +00:00
|
|
|
for (i = 0; callbacks[i].id != CISTPL_GENERIC; i++) {
|
|
|
|
if (tupleid == callbacks[i].id)
|
2002-03-07 00:11:42 +00:00
|
|
|
return (callbacks[i].func(cbdev, child, tupleid, len,
|
2005-12-29 01:43:47 +00:00
|
|
|
tupledata, start, off, &callbacks[i], argp));
|
2000-11-28 00:08:18 +00:00
|
|
|
}
|
2002-03-07 00:11:42 +00:00
|
|
|
return (callbacks[i].func(cbdev, child, tupleid, len,
|
2005-12-29 01:43:47 +00:00
|
|
|
tupledata, start, off, NULL, argp));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2005-12-29 01:43:47 +00:00
|
|
|
int
|
2001-08-26 23:55:34 +00:00
|
|
|
cardbus_parse_cis(device_t cbdev, device_t child,
|
2005-12-29 01:43:47 +00:00
|
|
|
struct tuple_callbacks *callbacks, void *argp)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2003-01-27 05:47:01 +00:00
|
|
|
uint8_t tupledata[MAXTUPLESIZE];
|
2007-06-08 04:03:57 +00:00
|
|
|
int tupleid = CISTPL_NULL;
|
2000-11-28 00:08:18 +00:00
|
|
|
int len;
|
|
|
|
int expect_linktarget;
|
2003-01-27 05:47:01 +00:00
|
|
|
uint32_t start, off;
|
2001-08-27 00:09:42 +00:00
|
|
|
struct resource *res;
|
|
|
|
int rid;
|
2000-11-28 00:52:40 +00:00
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
bzero(tupledata, MAXTUPLESIZE);
|
2000-11-28 00:08:18 +00:00
|
|
|
expect_linktarget = TRUE;
|
2005-10-28 05:55:52 +00:00
|
|
|
if ((start = pci_read_config(child, PCIR_CIS, 4)) == 0) {
|
2009-03-13 05:31:27 +00:00
|
|
|
DEVPRINTF((cbdev, "Warning: CIS pointer is 0: (no CIS)\n"));
|
2011-06-21 22:45:31 +00:00
|
|
|
return (0);
|
2005-02-20 20:36:16 +00:00
|
|
|
}
|
2009-03-13 05:31:27 +00:00
|
|
|
DEVPRINTF((cbdev, "CIS pointer is %#x\n", start));
|
2000-11-29 16:08:01 +00:00
|
|
|
off = 0;
|
2001-08-27 00:09:42 +00:00
|
|
|
res = cardbus_read_tuple_init(cbdev, child, &start, &rid);
|
2005-02-20 20:36:16 +00:00
|
|
|
if (res == NULL) {
|
|
|
|
device_printf(cbdev, "Unable to allocate resources for CIS\n");
|
2002-03-07 00:11:42 +00:00
|
|
|
return (ENXIO);
|
2005-02-20 20:36:16 +00:00
|
|
|
}
|
2003-02-16 00:20:24 +00:00
|
|
|
|
2000-11-28 00:08:18 +00:00
|
|
|
do {
|
2005-12-29 01:43:47 +00:00
|
|
|
if (cardbus_read_tuple(cbdev, child, res, start, &off,
|
|
|
|
&tupleid, &len, tupledata) != 0) {
|
2001-08-27 00:09:42 +00:00
|
|
|
device_printf(cbdev, "Failed to read CIS.\n");
|
|
|
|
cardbus_read_tuple_finish(cbdev, child, rid, res);
|
2002-03-07 00:11:42 +00:00
|
|
|
return (ENXIO);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2000-11-28 00:52:40 +00:00
|
|
|
|
2000-11-28 00:08:18 +00:00
|
|
|
if (expect_linktarget && tupleid != CISTPL_LINKTARGET) {
|
2001-08-26 23:55:34 +00:00
|
|
|
device_printf(cbdev, "Expecting link target, got 0x%x\n",
|
|
|
|
tupleid);
|
2001-08-27 00:09:42 +00:00
|
|
|
cardbus_read_tuple_finish(cbdev, child, rid, res);
|
2002-03-07 00:11:42 +00:00
|
|
|
return (EINVAL);
|
2000-11-28 00:08:18 +00:00
|
|
|
}
|
2001-08-26 23:55:34 +00:00
|
|
|
expect_linktarget = decode_tuple(cbdev, child, tupleid, len,
|
2005-12-29 01:43:47 +00:00
|
|
|
tupledata, start, &off, callbacks, argp);
|
2001-08-27 00:09:42 +00:00
|
|
|
if (expect_linktarget != 0) {
|
2005-02-20 20:36:16 +00:00
|
|
|
device_printf(cbdev, "Parsing failed with %d\n",
|
|
|
|
expect_linktarget);
|
2001-08-27 00:09:42 +00:00
|
|
|
cardbus_read_tuple_finish(cbdev, child, rid, res);
|
2002-03-07 00:11:42 +00:00
|
|
|
return (expect_linktarget);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2000-11-28 00:08:18 +00:00
|
|
|
} while (tupleid != CISTPL_END);
|
2001-08-27 00:09:42 +00:00
|
|
|
cardbus_read_tuple_finish(cbdev, child, rid, res);
|
2002-03-07 00:11:42 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2001-01-06 18:04:55 +00:00
|
|
|
int
|
2001-08-26 23:55:34 +00:00
|
|
|
cardbus_do_cis(device_t cbdev, device_t child)
|
2001-01-06 18:04:55 +00:00
|
|
|
{
|
|
|
|
struct tuple_callbacks init_callbacks[] = {
|
2003-10-07 03:33:54 +00:00
|
|
|
MAKETUPLE(LONGLINK_CB, unhandled),
|
2001-01-06 18:04:55 +00:00
|
|
|
MAKETUPLE(INDIRECT, unhandled),
|
|
|
|
MAKETUPLE(LONGLINK_MFC, unhandled),
|
|
|
|
MAKETUPLE(BAR, bar),
|
|
|
|
MAKETUPLE(LONGLINK_A, unhandled),
|
|
|
|
MAKETUPLE(LONGLINK_C, unhandled),
|
|
|
|
MAKETUPLE(LINKTARGET, linktarget),
|
|
|
|
MAKETUPLE(VERS_1, vers_1),
|
|
|
|
MAKETUPLE(MANFID, manfid),
|
|
|
|
MAKETUPLE(FUNCID, funcid),
|
|
|
|
MAKETUPLE(FUNCE, funce),
|
|
|
|
MAKETUPLE(END, end),
|
|
|
|
MAKETUPLE(GENERIC, generic),
|
|
|
|
};
|
2001-08-27 00:09:42 +00:00
|
|
|
|
2006-06-12 03:28:42 +00:00
|
|
|
return (cardbus_parse_cis(cbdev, child, init_callbacks, NULL));
|
2001-01-06 18:04:55 +00:00
|
|
|
}
|