readcis.h revision 50479
110217Sphk/* 215284Snate * Copyright (c) 1995 Andrew McRae. All rights reserved. 315284Snate * 415284Snate * Redistribution and use in source and binary forms, with or without 515284Snate * modification, are permitted provided that the following conditions 615284Snate * are met: 715284Snate * 1. Redistributions of source code must retain the above copyright 815284Snate * notice, this list of conditions and the following disclaimer. 915284Snate * 2. Redistributions in binary form must reproduce the above copyright 1015284Snate * notice, this list of conditions and the following disclaimer in the 1115284Snate * documentation and/or other materials provided with the distribution. 1215284Snate * 3. The name of the author may not be used to endorse or promote products 1315284Snate * derived from this software without specific prior written permission. 1415284Snate * 1515284Snate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1615284Snate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1715284Snate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1815284Snate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1915284Snate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2015284Snate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2115284Snate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2215284Snate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2315284Snate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2415284Snate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2515284Snate * 2650479Speter * $FreeBSD: head/usr.sbin/pccard/pccardd/readcis.h 50479 1999-08-28 01:35:59Z peter $ 2710217Sphk */ 2815284Snate 2929743Snate#define CIS_MAXSTR 30 3015177Snatestruct tuple { 3110217Sphk struct tuple *next; 3210217Sphk unsigned char code; 3315177Snate int length; 3410217Sphk unsigned char *data; 3515177Snate}; 3610217Sphk 3715177Snatestruct tuple_list { 3810217Sphk struct tuple_list *next; 3910217Sphk struct tuple *tuples; 4015177Snate off_t offs; 4115177Snate int flags; 4215177Snate}; 4310217Sphk 4415177Snatestruct tuple_info { 4515177Snate char *name; 4610217Sphk unsigned char code; 4715177Snate unsigned char length; /* 255 means variable length */ 4815177Snate}; 4915177Snate 5010217Sphk/* 5110217Sphk * Memory device descriptor. 5210217Sphk */ 5315177Snatestruct dev_mem { 5410217Sphk unsigned char valid; 5510217Sphk unsigned char type; 5610217Sphk unsigned char speed; 5710217Sphk unsigned char wps; 5810217Sphk unsigned char addr; 5910217Sphk unsigned char units; 6015177Snate}; 6115177Snate 6210217Sphk/* 6310217Sphk * One I/O structure describing a possible I/O map 6410217Sphk * of the card. 6510217Sphk */ 6615177Snatestruct cis_ioblk { 6710217Sphk struct cis_ioblk *next; 6810217Sphk unsigned int addr; 6910217Sphk unsigned int size; 7015177Snate}; 7115177Snate 7210217Sphk/* 7310217Sphk * A structure storing a memory map for the card. 7410217Sphk */ 7515177Snatestruct cis_memblk { 7610217Sphk struct cis_memblk *next; 7710217Sphk unsigned int address; 7810217Sphk unsigned int length; 7910217Sphk unsigned int host_address; 8015177Snate}; 8115177Snate 8210217Sphk/* 8310217Sphk * One configuration entry for the card. 8410217Sphk */ 8515177Snatestruct cis_config { 8610217Sphk struct cis_config *next; 8710217Sphk unsigned int pwr:1; /* Which values are defined. */ 8810217Sphk unsigned int timing:1; 8910217Sphk unsigned int iospace:1; 9010217Sphk unsigned int irq:1; 9110217Sphk unsigned int memspace:1; 9210217Sphk unsigned int misc_valid:1; 9310217Sphk unsigned char id; 9410217Sphk unsigned char io_blks; 9510217Sphk unsigned char io_addr; 9610217Sphk unsigned char io_bus; 9710217Sphk struct cis_ioblk *io; 9810217Sphk unsigned char irqlevel; 9910217Sphk unsigned char irq_flags; 10010217Sphk unsigned irq_mask; 10110217Sphk unsigned char memwins; 10210217Sphk struct cis_memblk *mem; 10310217Sphk unsigned char misc; 10415177Snate}; 10515177Snate 10610217Sphk/* 10710217Sphk * Structure holding all data retrieved from the 10810217Sphk * CIS block on the card. 10910217Sphk * The default configuration contains interface defaults 11010217Sphk * not listed in each separate configuration. 11110217Sphk */ 11215177Snatestruct cis { 11310217Sphk struct tuple_list *tlist; 11416466Snate char manuf[CIS_MAXSTR]; 11516466Snate char vers[CIS_MAXSTR]; 11616466Snate char add_info1[CIS_MAXSTR]; 11716466Snate char add_info2[CIS_MAXSTR]; 11810217Sphk unsigned char maj_v, min_v; 11910217Sphk unsigned char last_config; 12010217Sphk unsigned char ccrs; 12110217Sphk unsigned long reg_addr; 12210217Sphk struct dev_mem attr_mem; 12310217Sphk struct dev_mem common_mem; 12410217Sphk struct cis_config *def_config; 12510217Sphk struct cis_config *conf; 12615177Snate}; 12710217Sphk 12815177Snatevoid *xmalloc(int); 12915177Snatevoid dumpcis(struct cis *); 13015177Snatevoid freecis(struct cis *); 13116484Snatestruct cis *readcis(int); 13216484Snate 13315177Snatechar *tuple_name(unsigned char); 134