linux/drivers/pcmcia/cistpl.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * cistpl.c -- 16-bit PCMCIA Card Information Structure parser
 *
 * The initial developer of the original code is David A. Hinds
 * <[email protected]>.  Portions created by David A. Hinds
 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
 *
 * (C) 1999		David A. Hinds
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/major.h>
#include <linux/errno.h>
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/pci.h>
#include <linux/ioport.h>
#include <linux/io.h>
#include <linux/security.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>

#include <pcmcia/ss.h>
#include <pcmcia/cisreg.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
#include "cs_internal.h"

static const u_char mantissa[] =;

static const u_int exponent[] =;

/* Convert an extended speed byte to a time in nanoseconds */
#define SPEED_CVT(v)
/* Convert a power byte to a current in 0.1 microamps */
#define POWER_CVT(v)
#define POWER_SCALE(v)

/* Upper limit on reasonable # of tuples */
#define MAX_TUPLES

/* Bits in IRQInfo1 field */
#define IRQ_INFO2_VALID

/* 16-bit CIS? */
static int cis_width;
module_param(cis_width, int, 0444);

void release_cis_mem(struct pcmcia_socket *s)
{}

/*
 * set_cis_map() - map the card memory at "card_offset" into virtual space.
 *
 * If flags & MAP_ATTRIB, map the attribute space, otherwise
 * map the memory space.
 *
 * Must be called with ops_mutex held.
 */
static void __iomem *set_cis_map(struct pcmcia_socket *s,
				unsigned int card_offset, unsigned int flags)
{}


/* Bits in attr field */
#define IS_ATTR
#define IS_INDIRECT

/*
 * pcmcia_read_cis_mem() - low-level function to read CIS memory
 *
 * must be called with ops_mutex held
 */
int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
		 u_int len, void *ptr)
{}


/*
 * pcmcia_write_cis_mem() - low-level function to write CIS memory
 *
 * Probably only useful for writing one-byte registers. Must be called
 * with ops_mutex held.
 */
int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
		   u_int len, void *ptr)
{}


/*
 * read_cis_cache() - read CIS memory or its associated cache
 *
 * This is a wrapper around read_cis_mem, with the same interface,
 * but which caches information, for cards whose CIS may not be
 * readable all the time.
 */
static int read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr,
			size_t len, void *ptr)
{}

static void
remove_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, u_int len)
{}

/**
 * destroy_cis_cache() - destroy the CIS cache
 * @s:		pcmcia_socket for which CIS cache shall be destroyed
 *
 * This destroys the CIS cache but keeps any fake CIS alive. Must be
 * called with ops_mutex held.
 */
void destroy_cis_cache(struct pcmcia_socket *s)
{}

/*
 * verify_cis_cache() - does the CIS match what is in the CIS cache?
 */
int verify_cis_cache(struct pcmcia_socket *s)
{}

/*
 * pcmcia_replace_cis() - use a replacement CIS instead of the card's CIS
 *
 * For really bad cards, we provide a facility for uploading a
 * replacement CIS.
 */
int pcmcia_replace_cis(struct pcmcia_socket *s,
		       const u8 *data, const size_t len)
{}

/* The high-level CIS tuple services */

struct tuple_flags {};

#define LINK_SPACE(f)
#define HAS_LINK(f)
#define MFC_FN(f)
#define SPACE(f)

int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function,
			tuple_t *tuple)
{}

static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
{}

int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function,
			tuple_t *tuple)
{}

int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple)
{}


/* Parsing routines for individual tuples */

static int parse_device(tuple_t *tuple, cistpl_device_t *device)
{}


static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum)
{}


static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link)
{}


static int parse_longlink_mfc(tuple_t *tuple, cistpl_longlink_mfc_t *link)
{}


static int parse_strings(u_char *p, u_char *q, int max,
			 char *s, u_char *ofs, u_char *found)
{}


static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1)
{}


static int parse_altstr(tuple_t *tuple, cistpl_altstr_t *altstr)
{}


static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec)
{}


static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m)
{}


static int parse_funcid(tuple_t *tuple, cistpl_funcid_t *f)
{}


static int parse_funce(tuple_t *tuple, cistpl_funce_t *f)
{}


static int parse_config(tuple_t *tuple, cistpl_config_t *config)
{}

/* The following routines are all used to parse the nightmarish
 * config table entries.
 */

static u_char *parse_power(u_char *p, u_char *q, cistpl_power_t *pwr)
{}


static u_char *parse_timing(u_char *p, u_char *q, cistpl_timing_t *timing)
{}


static u_char *parse_io(u_char *p, u_char *q, cistpl_io_t *io)
{}


static u_char *parse_mem(u_char *p, u_char *q, cistpl_mem_t *mem)
{}


static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq)
{}


static int parse_cftable_entry(tuple_t *tuple,
			       cistpl_cftable_entry_t *entry)
{}


static int parse_device_geo(tuple_t *tuple, cistpl_device_geo_t *geo)
{}


static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2)
{}


static int parse_org(tuple_t *tuple, cistpl_org_t *org)
{}


static int parse_format(tuple_t *tuple, cistpl_format_t *fmt)
{}


int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse)
{}
EXPORT_SYMBOL();


/**
 * pccard_validate_cis() - check whether card has a sensible CIS
 * @s:		the struct pcmcia_socket we are to check
 * @info:	returns the number of tuples in the (valid) CIS, or 0
 *
 * This tries to determine if a card has a sensible CIS.  In @info, it
 * returns the number of tuples in the CIS, or 0 if the CIS looks bad. The
 * checks include making sure several critical tuples are present and
 * valid; seeing if the total number of tuples is reasonable; and
 * looking for tuples that use reserved codes.
 *
 * The function returns 0 on success.
 */
int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
{}


#define to_socket(_dev)

static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf,
				  loff_t off, size_t count)
{}


static ssize_t pccard_show_cis(struct file *filp, struct kobject *kobj,
			       struct bin_attribute *bin_attr,
			       char *buf, loff_t off, size_t count)
{}


static ssize_t pccard_store_cis(struct file *filp, struct kobject *kobj,
				struct bin_attribute *bin_attr,
				char *buf, loff_t off, size_t count)
{}


const struct bin_attribute pccard_cis_attr =;