diff options
author | 2009-11-05 20:30:47 +0000 | |
---|---|---|
committer | 2009-11-05 20:30:47 +0000 | |
commit | 11d87e37afca9502415543699d2e87059b249f83 (patch) | |
tree | b156faad0ad41aa1f0c55279f5a2fee09ec8764a | |
parent | Provide assembly version of sqrtl(3). (diff) | |
download | wireguard-openbsd-11d87e37afca9502415543699d2e87059b249f83.tar.xz wireguard-openbsd-11d87e37afca9502415543699d2e87059b249f83.zip |
Add a new PCIOCGETROMLEN ioctl, to give users of PCIOGETROM a chance to
allocate a buffer of the right size.
ok oga@
-rw-r--r-- | sys/dev/pci/pci.c | 13 | ||||
-rw-r--r-- | sys/sys/pciio.h | 3 |
2 files changed, 13 insertions, 3 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index f5a869d820d..a0eae5a59cd 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.67 2009/07/26 13:21:18 kettenis Exp $ */ +/* $OpenBSD: pci.c,v 1.68 2009/11/05 20:30:47 kettenis Exp $ */ /* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */ /* @@ -800,6 +800,7 @@ pciioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (!(flag & FWRITE)) return EPERM; break; + case PCIOCGETROMLEN: case PCIOCGETROM: break; default: @@ -857,6 +858,7 @@ pciioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) } break; + case PCIOCGETROMLEN: case PCIOCGETROM: { pcireg_t addr, mask, bhlc; @@ -865,6 +867,8 @@ pciioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) char buf[256]; int s; + rom = (struct pci_rom *)data; + bhlc = pci_conf_read(pc, tag, PCI_BHLC_REG); if (PCI_HDRTYPE_TYPE(bhlc) != 0) return (ENODEV); @@ -888,7 +892,12 @@ pciioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) PCI_ROM_SIZE(mask) % sizeof(buf)) != 0) return (ENODEV); - rom = (struct pci_rom *)data; + /* If we're just after the size, skip reading the ROM. */ + if (cmd == PCIOCGETROMLEN) { + error = 0; + goto fail; + } + if (rom->pr_romlen < PCI_ROM_SIZE(mask)) { error = ENOMEM; goto fail; diff --git a/sys/sys/pciio.h b/sys/sys/pciio.h index 045e8fcc382..c00bb14405d 100644 --- a/sys/sys/pciio.h +++ b/sys/sys/pciio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pciio.h,v 1.4 2009/07/26 13:21:18 kettenis Exp $ */ +/* $OpenBSD: pciio.h,v 1.5 2009/11/05 20:30:47 kettenis Exp $ */ /*- * Copyright (c) 1997, Stefan Esser <se@FreeBSD.ORG> @@ -57,6 +57,7 @@ struct pci_rom { #define PCIOCREAD _IOWR('p', 2, struct pci_io) #define PCIOCWRITE _IOWR('p', 3, struct pci_io) +#define PCIOCGETROMLEN _IOWR('p', 4, struct pci_rom) #define PCIOCGETROM _IOWR('p', 5, struct pci_rom) #endif /* !_SYS_PCIIO_H_ */ |