-# $Id: Makefile,v 1.1 1999/01/22 21:05:10 mj Exp $
+# $Id: Makefile,v 1.2 1999/01/24 21:35:35 mj Exp $
# Makefile for The PCI Library
# (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
include config.mk
-OBJS=access.o generic.o dump.o names.o filter.o buffer.o
+OBJS=access.o generic.o dump.o names.o filter.o
INCL=internal.h pci.h config.h
ifdef HAVE_PM_LINUX_PROC
/*
- * $Id: access.c,v 1.1 1999/01/22 21:05:12 mj Exp $
+ * $Id: access.c,v 1.2 1999/01/24 21:35:35 mj Exp $
*
* The PCI Library -- User Access
*
{
if (pos & (len-1))
d->access->error("Unaligned read: pos=%02x, len=%d", pos, len);
- if (!d->methods->read(d, pos, buf, len))
+ if (pos + len <= d->cache_len)
+ memcpy(buf, d->cache + pos, len);
+ else if (!d->methods->read(d, pos, buf, len))
memset(buf, 0xff, len);
}
{
if (pos & (len-1))
d->access->error("Unaligned write: pos=%02x,len=%d", pos, len);
+ if (pos + len <= d->cache_len)
+ memcpy(d->cache + pos, buf, len);
return d->methods->write(d, pos, buf, len);
}
int
pci_write_block(struct pci_dev *d, int pos, byte *buf, int len)
{
+ if (pos < d->cache_len)
+ {
+ int l = (pos + len >= d->cache_len) ? (d->cache_len - pos) : len;
+ memcpy(d->cache + pos, buf, l);
+ }
return d->methods->write(d, pos, buf, len);
}
d->methods->fill_info(d, flags & ~d->known_fields);
d->known_fields |= flags;
}
+
+void
+pci_setup_cache(struct pci_dev *d, byte *cache, int len)
+{
+ d->cache = cache;
+ d->cache_len = len;
+}
+++ /dev/null
-/*
- * $Id: buffer.c,v 1.1 1999/01/22 21:05:14 mj Exp $
- *
- * The PCI Library -- Buffered Access
- *
- * Copyright (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
- *
- * Can be freely distributed and used under the terms of the GNU GPL.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-
-#include "internal.h"
-
-static int
-buff_read(struct pci_dev *d, int pos, byte *buf, int len)
-{
- memcpy(buf, (byte *)d->aux + pos, len);
- return 1;
-}
-
-static int
-buff_write(struct pci_dev *d, int UNUSED pos, byte * UNUSED buf, int UNUSED len)
-{
- d->access->error("buffer: Writing to configuration space not supported.");
- return 0;
-}
-
-static struct pci_methods pm_buffer = {
- "Buffer",
- NULL, /* config */
- NULL, /* Shall not be called */
- NULL, /* No init nor cleanup */
- NULL,
- NULL, /* No scanning */
- pci_generic_fill_info,
- buff_read,
- buff_write,
- NULL, /* init_dev */
- NULL /* cleanup_dev */
-};
-
-void
-pci_setup_buffer(struct pci_dev *d, byte *buf)
-{
- if (d->methods->cleanup_dev)
- d->methods->cleanup_dev(d);
- d->methods = &pm_buffer;
- d->aux = buf;
-}
/*
- * $Id: pci.h,v 1.1 1999/01/22 21:05:34 mj Exp $
+ * $Id: pci.h,v 1.2 1999/01/24 21:35:36 mj Exp $
*
* The PCI Library
*
/* Fields used internally: */
struct pci_access *access;
struct pci_methods *methods;
+ byte *cache; /* Cached information */
+ int cache_len;
int known_fields; /* Set of info fields that is already known */
int hdrtype; /* Direct methods: header type */
void *aux; /* Auxillary data */
#define PCI_FILL_ROM_BASE 8
#define PCI_FILL_RESCAN 0x10000
-/*
- * Buffered access
- */
-
-void pci_setup_buffer(struct pci_dev *, byte *buf);
+void pci_setup_cache(struct pci_dev *, byte *cache, int len);
/*
* Filters