fix some minor problem in PIOCSRESOURCE ioctl.

- If resource which was allocated for pcic was
  requested via this ioctl, bus_alloc_resource
  would be succeeded and that resource was
  returned as free resource.  So check whether
  requested resource was used for pcic or not
  before bus_alloc_resource test.

- merge SYS_RES_IRQ routine into other SYS_RES_*
  routine and clean up.

problem reported by:	Yohei Terada <terada@jiro.c.u-tokyo.ac.jp>
This commit is contained in:
MIHIRA Sanpei Yoshiro 2000-10-01 12:36:14 +00:00
parent de9c893eeb
commit 975ce2575a
2 changed files with 7 additions and 16 deletions

View File

@ -626,7 +626,11 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p)
return EINVAL;
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
for (i = pr->min; i + pr->size <= pr->max; i++) {
case SYS_RES_IRQ:
for (i = pr->min; i + pr->size - 1 <= pr->max; i++) {
/* already allocated to pcic? */
if (bus_get_resource_start(pcicdev, pr->type, 0) == i)
continue;
err = bus_set_resource(pcicdev, pr->type, rid, i, pr->size);
if (!err) {
r = bus_alloc_resource(pcicdev, pr->type, &rid, 0ul, ~0ul, pr->size, 0);
@ -638,19 +642,6 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p)
}
}
break;
case SYS_RES_IRQ:
for (i = pr->min; i <= pr->max; i++) {
err = bus_set_resource(pcicdev, SYS_RES_IRQ, rid, i, 1);
if (!err) {
r = bus_alloc_resource(pcicdev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1, 0);
if (r) {
pr->resource_addr = (u_long)rman_get_start(r);
bus_release_resource(pcicdev, SYS_RES_IRQ, rid, r);
break;
}
}
}
break;
}
break;
}

View File

@ -544,7 +544,7 @@ assign_card_index(struct cis * cis)
for (cio = cp->io; cio; cio = cio->next) {
resource.size = cio->size;
resource.min = cio->addr;
resource.max = resource.min + cio->size;
resource.max = resource.min + cio->size - 1;
if (ioctl(fd, PIOCSRESOURCE, &resource) < 0) {
perror("ioctl (PIOCSRESOURCE)");
exit(1);
@ -697,7 +697,7 @@ assign_io(struct slot *sp)
j = bit_fns(io_avail, IOPORTS, i,
sio->size, sio->size);
res.min = j;
res.max = j + sio->size ;
res.max = j + sio->size - 1;
if (ioctl(fd, PIOCSRESOURCE, &res) < 0) {
perror("ioctl (PIOCSRESOURCE)");
exit(1);