~peter-pearse/ubuntu/natty/pciutils/prop001

« back to all changes in this revision

Viewing changes to lib/obsd-device.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2008-04-29 16:23:38 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080429162338-v20040rx66khbl7v
Tags: 1:3.0.0-3
libpci-dev conflicts with pciutils-dev. Closes: #478290

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
static void
20
20
obsd_config(struct pci_access *a)
21
21
{
22
 
  a->method_params[PCI_ACCESS_OBSD_DEVICE] = PCI_PATH_OBSD_DEVICE;
 
22
  pci_define_param(a, "obsd.path", PCI_PATH_OBSD_DEVICE, "Path to the OpenBSD PCI device");
23
23
}
24
24
 
25
25
static int
26
26
obsd_detect(struct pci_access *a)
27
27
{
28
 
  char *name = a->method_params[PCI_ACCESS_OBSD_DEVICE];
 
28
  char *name = pci_get_param(a, "obsd.path");
29
29
 
30
30
  if (access(name, R_OK))
31
31
    {
39
39
static void
40
40
obsd_init(struct pci_access *a)
41
41
{
42
 
  char *name = a->method_params[PCI_ACCESS_OBSD_DEVICE];
 
42
  char *name = pci_get_param(a, "obsd.path");
43
43
 
44
44
  a->fd = open(name, O_RDWR, 0);
45
45
  if (a->fd < 0)
46
 
    {
47
 
      a->error("obsd_init: %s open failed", name);
48
 
    }
 
46
    a->error("obsd_init: %s open failed", name);
49
47
}
50
48
 
51
49
static void
65
63
  } u;
66
64
 
67
65
  if (!(len == 1 || len == 2 || len == 4))
68
 
    {
69
 
      return pci_generic_block_read(d, pos, buf, len);
70
 
    }
 
66
    return pci_generic_block_read(d, pos, buf, len);
71
67
 
72
68
  if (pos >= 256)
73
69
    return 0;
80
76
  pi.pi_width = 4;
81
77
 
82
78
  if (ioctl(d->access->fd, PCIOCREAD, &pi) < 0) {
83
 
          if (errno == ENXIO) {
 
79
          if (errno == ENXIO)
84
80
                  pi.pi_data = 0xffffffff;
85
 
          } else {
 
81
          else
86
82
                  d->access->error("obsd_read: ioctl(PCIOCREAD) failed");
87
 
          }
88
83
  }
89
84
  u.u32 = pi.pi_data;
90
85
 
109
104
  struct pci_io pi;
110
105
 
111
106
  if (!(len == 1 || len == 2 || len == 4))
112
 
    {
113
 
      return pci_generic_block_write(d, pos, buf, len);
114
 
    }
 
107
    return pci_generic_block_write(d, pos, buf, len);
115
108
 
116
109
  if (pos >= 256)
117
110
    return 0;
137
130
    }
138
131
 
139
132
  if (ioctl(d->access->fd, PCIOCWRITE, &pi) < 0)
140
 
    {
141
 
      d->access->error("obsd_write: ioctl(PCIOCWRITE) failed");
142
 
    }
 
133
    d->access->error("obsd_write: ioctl(PCIOCWRITE) failed");
143
134
 
144
135
  return 1;
145
136
}
146
137
 
147
138
struct pci_methods pm_obsd_device = {
148
 
  "OpenBSD-device",
 
139
  "obsd-device",
 
140
  "/dev/pci on OpenBSD",
149
141
  obsd_config,
150
142
  obsd_detect,
151
143
  obsd_init,