]> mj.ucw.cz Git - pciutils.git/blob - lib/buffer.c
Added few device IDs.
[pciutils.git] / lib / buffer.c
1 /*
2  *      $Id: buffer.c,v 1.1 1999/01/22 21:05:14 mj Exp $
3  *
4  *      The PCI Library -- Buffered Access
5  *
6  *      Copyright (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
7  *
8  *      Can be freely distributed and used under the terms of the GNU GPL.
9  */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stdarg.h>
14 #include <string.h>
15
16 #include "internal.h"
17
18 static int
19 buff_read(struct pci_dev *d, int pos, byte *buf, int len)
20 {
21   memcpy(buf, (byte *)d->aux + pos, len);
22   return 1;
23 }
24
25 static int
26 buff_write(struct pci_dev *d, int UNUSED pos, byte * UNUSED buf, int UNUSED len)
27 {
28   d->access->error("buffer: Writing to configuration space not supported.");
29   return 0;
30 }
31
32 static struct pci_methods pm_buffer = {
33   "Buffer",
34   NULL,                                 /* config */
35   NULL,                                 /* Shall not be called */
36   NULL,                                 /* No init nor cleanup */
37   NULL,
38   NULL,                                 /* No scanning */
39   pci_generic_fill_info,
40   buff_read,
41   buff_write,
42   NULL,                                 /* init_dev */
43   NULL                                  /* cleanup_dev */
44 };
45
46 void
47 pci_setup_buffer(struct pci_dev *d, byte *buf)
48 {
49   if (d->methods->cleanup_dev)
50     d->methods->cleanup_dev(d);
51   d->methods = &pm_buffer;
52   d->aux = buf;
53 }