git: 6cf4e30252fe - main - bus: Document special ranges of IVARs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Feb 2026 20:46:18 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=6cf4e30252fe48b230b9d76cac20576d5b3d2ffa
commit 6cf4e30252fe48b230b9d76cac20576d5b3d2ffa
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-02-17 20:45:13 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-02-17 20:45:13 +0000
bus: Document special ranges of IVARs
Some IVAR indices are special in that they have global meaning across
multiple buses where as other IVARs are always private to the local bus.
Try to document this a bit and add constants for the various ranges to
avoid future conflicts.
This is a no-op, but IVAR indices are now generally defined as enums
as that makes it easier to define them in terms of ranges.
Reviewed by: imp, royger, andrew
Differential Revision: https://reviews.freebsd.org/D54159
---
sys/arm/arm/gic_common.h | 10 ++++++----
sys/arm64/arm64/gic_v3_var.h | 10 ++++++----
sys/dev/acpica/acpivar.h | 12 +++++++-----
sys/dev/atkbdc/atkbdcreg.h | 2 +-
sys/dev/bhnd/bhnd.h | 2 +-
sys/dev/fdc/fdcvar.h | 2 +-
sys/dev/gpio/gpiobusvar.h | 2 +-
sys/dev/hid/hidbus.h | 2 +-
sys/dev/iicbus/iicbus.h | 2 +-
sys/dev/mii/miivar.h | 2 +-
sys/dev/mmc/mmcbrvar.h | 2 +-
sys/dev/mmc/mmcvar.h | 2 +-
sys/dev/nvdimm/nvdimm_var.h | 2 +-
sys/dev/ow/ow.h | 2 +-
sys/dev/pccard/pccardvar.h | 2 +-
sys/dev/pci/pcivar.h | 4 ++--
sys/dev/ppbus/ppbconf.h | 12 ++++++++----
sys/dev/puc/puc_bus.h | 6 ++++--
sys/dev/pwm/pwmbus.h | 2 +-
sys/dev/quicc/quicc_bus.h | 8 +++++---
sys/dev/scc/scc_bus.h | 14 ++++++++------
sys/dev/sdio/sdiob.h | 2 +-
sys/dev/smbus/smbconf.h | 2 +-
sys/dev/sound/pci/hda/hdac.h | 2 +-
sys/dev/spibus/spibusvar.h | 2 +-
sys/dev/superio/superio.h | 2 +-
sys/dev/virtio/virtio.h | 16 +++++++++-------
sys/isa/isavar.h | 2 +-
sys/powerpc/ps3/ps3bus.h | 2 +-
sys/powerpc/psim/iobusvar.h | 2 +-
sys/sys/bus.h | 16 ++++++++++++++++
sys/sys/cpu.h | 10 ++++++----
sys/x86/include/legacyvar.h | 2 +-
sys/xen/xenbus/xenbusvar.h | 2 +-
34 files changed, 100 insertions(+), 64 deletions(-)
diff --git a/sys/arm/arm/gic_common.h b/sys/arm/arm/gic_common.h
index c2d1b1340b9b..d2f422ab6536 100644
--- a/sys/arm/arm/gic_common.h
+++ b/sys/arm/arm/gic_common.h
@@ -35,10 +35,12 @@ struct arm_gic_range {
uint64_t size;
};
-#define GIC_IVAR_HW_REV 500
-#define GIC_IVAR_BUS 501
-#define GIC_IVAR_VGIC 502
-#define GIC_IVAR_SUPPORT_LPIS 503
+enum {
+ GIC_IVAR_HW_REV = BUS_IVARS_GIC,
+ GIC_IVAR_BUS,
+ GIC_IVAR_VGIC,
+ GIC_IVAR_SUPPORT_LPIS
+};
/* GIC_IVAR_BUS values */
#define GIC_BUS_UNKNOWN 0
diff --git a/sys/arm64/arm64/gic_v3_var.h b/sys/arm64/arm64/gic_v3_var.h
index a490b69b7417..58523bb42cd6 100644
--- a/sys/arm64/arm64/gic_v3_var.h
+++ b/sys/arm64/arm64/gic_v3_var.h
@@ -109,10 +109,12 @@ struct gic_v3_devinfo {
MALLOC_DECLARE(M_GIC_V3);
/* ivars */
-#define GICV3_IVAR_NIRQS 1000
-/* 1001 was GICV3_IVAR_REDIST_VADDR */
-#define GICV3_IVAR_REDIST 1002
-#define GICV3_IVAR_FLAGS 1003
+enum {
+ GICV3_IVAR_NIRQS = BUS_IVARS_GICV3,
+ _GICV3_IVAR_REDIST_VADDR, /* unused */
+ GICV3_IVAR_REDIST,
+ GICV3_IVAR_FLAGS,
+};
__BUS_ACCESSOR(gicv3, nirqs, GICV3, NIRQS, u_int);
__BUS_ACCESSOR(gicv3, redist, GICV3, REDIST, void *);
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index d585fc8f2e23..34f4204a812c 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -277,11 +277,13 @@ extern int acpi_override_isa_irq_polarity;
* interface compatibility with ISA drivers which can also
* attach to ACPI.
*/
-#define ACPI_IVAR_HANDLE 0x100
-#define ACPI_IVAR_UNUSED 0x101 /* Unused/reserved. */
-#define ACPI_IVAR_PRIVATE 0x102
-#define ACPI_IVAR_FLAGS 0x103
-#define ACPI_IVAR_DOMAIN 0x104
+enum {
+ ACPI_IVAR_HANDLE = BUS_IVARS_ACPI,
+ ACPI_IVAR_UNUSED, /* Unused/reserved. */
+ ACPI_IVAR_PRIVATE,
+ ACPI_IVAR_FLAGS,
+ ACPI_IVAR_DOMAIN
+};
/*
* ad_domain NUMA domain special value.
diff --git a/sys/dev/atkbdc/atkbdcreg.h b/sys/dev/atkbdc/atkbdcreg.h
index dc2194dc69c2..a731d33b8de2 100644
--- a/sys/dev/atkbdc/atkbdcreg.h
+++ b/sys/dev/atkbdc/atkbdcreg.h
@@ -215,7 +215,7 @@ typedef struct atkbdc_softc {
} atkbdc_softc_t;
enum kbdc_device_ivar {
- KBDC_IVAR_VENDORID,
+ KBDC_IVAR_VENDORID = BUS_IVARS_PRIVATE,
KBDC_IVAR_SERIAL,
KBDC_IVAR_LOGICALID,
KBDC_IVAR_COMPATID,
diff --git a/sys/dev/bhnd/bhnd.h b/sys/dev/bhnd/bhnd.h
index 1a29b922d491..3d855e23c7e1 100644
--- a/sys/dev/bhnd/bhnd.h
+++ b/sys/dev/bhnd/bhnd.h
@@ -60,7 +60,7 @@
* bhnd child instance variables
*/
enum bhnd_device_vars {
- BHND_IVAR_VENDOR, /**< Designer's JEP-106 manufacturer ID. */
+ BHND_IVAR_VENDOR = BUS_IVARS_PRIVATE, /**< Designer's JEP-106 manufacturer ID. */
BHND_IVAR_DEVICE, /**< Part number */
BHND_IVAR_HWREV, /**< Core revision */
BHND_IVAR_DEVICE_CLASS, /**< Core class (@sa bhnd_devclass_t) */
diff --git a/sys/dev/fdc/fdcvar.h b/sys/dev/fdc/fdcvar.h
index 881f6f9f898d..8b7081e0a6cc 100644
--- a/sys/dev/fdc/fdcvar.h
+++ b/sys/dev/fdc/fdcvar.h
@@ -69,7 +69,7 @@ struct fdc_data {
};
enum fdc_device_ivars {
- FDC_IVAR_FDUNIT,
+ FDC_IVAR_FDUNIT = BUS_IVARS_PRIVATE,
FDC_IVAR_FDTYPE,
};
diff --git a/sys/dev/gpio/gpiobusvar.h b/sys/dev/gpio/gpiobusvar.h
index 22a10ad2abc2..3d93e3d291b9 100644
--- a/sys/dev/gpio/gpiobusvar.h
+++ b/sys/dev/gpio/gpiobusvar.h
@@ -109,7 +109,7 @@ struct gpiobus_ivar
};
enum gpiobus_ivars {
- GPIOBUS_IVAR_NPINS = 10500,
+ GPIOBUS_IVAR_NPINS = BUS_IVARS_GPIOBUS,
GPIOBUS_IVAR_PINS,
};
diff --git a/sys/dev/hid/hidbus.h b/sys/dev/hid/hidbus.h
index 3de4a6291511..50b680c41065 100644
--- a/sys/dev/hid/hidbus.h
+++ b/sys/dev/hid/hidbus.h
@@ -27,7 +27,7 @@
#define _HID_HIDBUS_H_
enum {
- HIDBUS_IVAR_USAGE,
+ HIDBUS_IVAR_USAGE = BUS_IVARS_PRIVATE,
HIDBUS_IVAR_INDEX,
HIDBUS_IVAR_FLAGS,
#define HIDBUS_FLAG_AUTOCHILD (0<<1) /* Child is autodiscovered */
diff --git a/sys/dev/iicbus/iicbus.h b/sys/dev/iicbus/iicbus.h
index 74503d3e54ec..a72b004fcc7f 100644
--- a/sys/dev/iicbus/iicbus.h
+++ b/sys/dev/iicbus/iicbus.h
@@ -57,7 +57,7 @@ struct iicbus_ivar
/* Value of 0x100 is reserved for ACPI_IVAR_HANDLE used by acpi_iicbus */
enum {
- IICBUS_IVAR_ADDR /* Address or base address */
+ IICBUS_IVAR_ADDR = BUS_IVARS_PRIVATE /* Address or base address */
};
#define IICBUS_ACCESSOR(A, B, T) \
diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h
index 5b0782775359..ef82d9f66a5d 100644
--- a/sys/dev/mii/miivar.h
+++ b/sys/dev/mii/miivar.h
@@ -250,7 +250,7 @@ struct mii_phydesc {
(*(p)->mii_funcs->pf_reset)(p)
enum miibus_device_ivars {
- MIIBUS_IVAR_FLAGS
+ MIIBUS_IVAR_FLAGS = BUS_IVARS_PRIVATE
};
/*
diff --git a/sys/dev/mmc/mmcbrvar.h b/sys/dev/mmc/mmcbrvar.h
index c47966793098..06d38553c201 100644
--- a/sys/dev/mmc/mmcbrvar.h
+++ b/sys/dev/mmc/mmcbrvar.h
@@ -60,7 +60,7 @@
#include "mmcbr_if.h"
enum mmcbr_device_ivars {
- MMCBR_IVAR_BUS_TYPE,
+ MMCBR_IVAR_BUS_TYPE = BUS_IVARS_PRIVATE,
MMCBR_IVAR_BUS_MODE,
MMCBR_IVAR_BUS_WIDTH,
MMCBR_IVAR_CHIP_SELECT,
diff --git a/sys/dev/mmc/mmcvar.h b/sys/dev/mmc/mmcvar.h
index 268b298bce58..a335e098d2ad 100644
--- a/sys/dev/mmc/mmcvar.h
+++ b/sys/dev/mmc/mmcvar.h
@@ -56,7 +56,7 @@
#define DEV_MMC_MMCVAR_H
enum mmc_device_ivars {
- MMC_IVAR_SPEC_VERS,
+ MMC_IVAR_SPEC_VERS = BUS_IVARS_PRIVATE,
MMC_IVAR_DSR_IMP,
MMC_IVAR_MEDIA_SIZE,
MMC_IVAR_RCA,
diff --git a/sys/dev/nvdimm/nvdimm_var.h b/sys/dev/nvdimm/nvdimm_var.h
index ad931e8fbb23..6b7c8afe42b3 100644
--- a/sys/dev/nvdimm/nvdimm_var.h
+++ b/sys/dev/nvdimm/nvdimm_var.h
@@ -79,7 +79,7 @@ _Static_assert(sizeof(struct nvdimm_label) == 256, "Incorrect layout");
typedef uint32_t nfit_handle_t;
enum nvdimm_acpi_ivar {
- NVDIMM_ROOT_IVAR_ACPI_HANDLE,
+ NVDIMM_ROOT_IVAR_ACPI_HANDLE = BUS_IVARS_PRIVATE,
NVDIMM_ROOT_IVAR_DEVICE_HANDLE,
NVDIMM_ROOT_IVAR_MAX,
};
diff --git a/sys/dev/ow/ow.h b/sys/dev/ow/ow.h
index b4d97f957504..6d38111d925c 100644
--- a/sys/dev/ow/ow.h
+++ b/sys/dev/ow/ow.h
@@ -27,7 +27,7 @@
#define DEV_OW_OW_H 1
enum ow_device_ivars {
- OW_IVAR_FAMILY,
+ OW_IVAR_FAMILY = BUS_IVARS_PRIVATE,
OW_IVAR_ROMID
};
diff --git a/sys/dev/pccard/pccardvar.h b/sys/dev/pccard/pccardvar.h
index 546d69939699..c6a03b242f35 100644
--- a/sys/dev/pccard/pccardvar.h
+++ b/sys/dev/pccard/pccardvar.h
@@ -191,7 +191,7 @@ int pccard_select_cfe(device_t dev, int entry);
/* ivar interface */
enum {
- PCCARD_IVAR_ETHADDR, /* read ethernet address from CIS tupple */
+ PCCARD_IVAR_ETHADDR = BUS_IVARS_PRIVATE, /* read ethernet address from CIS tupple */
PCCARD_IVAR_VENDOR,
PCCARD_IVAR_PRODUCT,
PCCARD_IVAR_PRODEXT,
diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h
index 4abb5e977346..696e1c688c68 100644
--- a/sys/dev/pci/pcivar.h
+++ b/sys/dev/pci/pcivar.h
@@ -340,7 +340,7 @@ struct pci_devinfo {
#include "pci_if.h"
enum pci_device_ivars {
- PCI_IVAR_SUBVENDOR,
+ PCI_IVAR_SUBVENDOR = BUS_IVARS_PRIVATE,
PCI_IVAR_SUBDEVICE,
PCI_IVAR_VENDOR,
PCI_IVAR_DEVICE,
@@ -414,7 +414,7 @@ pci_write_config(device_t dev, int reg, uint32_t val, int width)
/*typedef enum pci_device_ivars pcib_device_ivars;*/
enum pcib_device_ivars {
- PCIB_IVAR_DOMAIN,
+ PCIB_IVAR_DOMAIN = BUS_IVARS_PRIVATE,
PCIB_IVAR_BUS
};
diff --git a/sys/dev/ppbus/ppbconf.h b/sys/dev/ppbus/ppbconf.h
index 66f45634ea6d..673006bff4c6 100644
--- a/sys/dev/ppbus/ppbconf.h
+++ b/sys/dev/ppbus/ppbconf.h
@@ -178,7 +178,9 @@ struct ppb_context {
/*
* List of IVARS available to ppb device drivers
*/
-#define PPBUS_IVAR_MODE 0
+enum {
+ PPBUS_IVAR_MODE = BUS_IVARS_PRIVATE
+};
/* other fields are reserved to the ppbus internals */
@@ -208,9 +210,11 @@ struct ppb_device {
#define EPP_1_7 0x1
/* Parallel Port Chipset IVARS */ /* elsewhere XXX */
-#define PPC_IVAR_EPP_PROTO 0
-#define PPC_IVAR_LOCK 1
-#define PPC_IVAR_INTR_HANDLER 2
+enum {
+ PPC_IVAR_EPP_PROTO = BUS_IVARS_PRIVATE,
+ PPC_IVAR_LOCK,
+ PPC_IVAR_INTR_HANDLER
+};
/*
* Maximum size of the PnP info string
diff --git a/sys/dev/puc/puc_bus.h b/sys/dev/puc/puc_bus.h
index 75c39a0f22fc..09fbe2dc42ab 100644
--- a/sys/dev/puc/puc_bus.h
+++ b/sys/dev/puc/puc_bus.h
@@ -32,8 +32,10 @@
#include <sys/serial.h>
#include <serdev_if.h>
-#define PUC_IVAR_CLOCK 0
-#define PUC_IVAR_TYPE 1
+enum {
+ PUC_IVAR_CLOCK = BUS_IVARS_PRIVATE,
+ PUC_IVAR_TYPE
+};
/* Port types. */
#define PUC_TYPE_SERIAL 1
diff --git a/sys/dev/pwm/pwmbus.h b/sys/dev/pwm/pwmbus.h
index 59aacc7beee4..172d8939bcf5 100644
--- a/sys/dev/pwm/pwmbus.h
+++ b/sys/dev/pwm/pwmbus.h
@@ -38,7 +38,7 @@ struct pwmbus_ivars {
};
enum {
- PWMBUS_IVAR_CHANNEL, /* Channel used by child dev */
+ PWMBUS_IVAR_CHANNEL = BUS_IVARS_PRIVATE, /* Channel used by child dev */
};
#define PWMBUS_ACCESSOR(A, B, T) \
diff --git a/sys/dev/quicc/quicc_bus.h b/sys/dev/quicc/quicc_bus.h
index 01d8952dddbb..385c24b93f01 100644
--- a/sys/dev/quicc/quicc_bus.h
+++ b/sys/dev/quicc/quicc_bus.h
@@ -29,9 +29,11 @@
#ifndef _DEV_QUICC_BUS_H_
#define _DEV_QUICC_BUS_H_
-#define QUICC_IVAR_CLOCK 1 /* The CPM clock. */
-#define QUICC_IVAR_BRGCLK 2 /* The BRG clock affected by SCCR. */
-#define QUICC_IVAR_DEVTYPE 3
+enum {
+ QUICC_IVAR_CLOCK = BUS_IVARS_PRIVATE + 1, /* The CPM clock. */
+ QUICC_IVAR_BRGCLK, /* The BRG clock affected by SCCR. */
+ QUICC_IVAR_DEVTYPE
+};
/* Device types. */
#define QUICC_DEVTYPE_SCC 1
diff --git a/sys/dev/scc/scc_bus.h b/sys/dev/scc/scc_bus.h
index 96169d7403d8..3b86dabf1046 100644
--- a/sys/dev/scc/scc_bus.h
+++ b/sys/dev/scc/scc_bus.h
@@ -32,12 +32,14 @@
#include <sys/serial.h>
#include <serdev_if.h>
-#define SCC_IVAR_CHANNEL 0
-#define SCC_IVAR_CLASS 1
-#define SCC_IVAR_CLOCK 2
-#define SCC_IVAR_MODE 3
-#define SCC_IVAR_REGSHFT 4
-#define SCC_IVAR_HWMTX 5
+enum {
+ SCC_IVAR_CHANNEL = BUS_IVARS_PRIVATE,
+ SCC_IVAR_CLASS,
+ SCC_IVAR_CLOCK,
+ SCC_IVAR_MODE,
+ SCC_IVAR_REGSHFT,
+ SCC_IVAR_HWMTX
+};
/* Hardware class -- the SCC type. */
#define SCC_CLASS_UNUSED 0
diff --git a/sys/dev/sdio/sdiob.h b/sys/dev/sdio/sdiob.h
index 316a23b86103..f356cca42588 100644
--- a/sys/dev/sdio/sdiob.h
+++ b/sys/dev/sdio/sdiob.h
@@ -64,7 +64,7 @@
#ifdef _SYS_BUS_H_
/* Ivars for sdiob. */
enum sdiob_dev_enum {
- SDIOB_IVAR_SUPPORT_MULTIBLK,
+ SDIOB_IVAR_SUPPORT_MULTIBLK = BUS_IVARS_PRIVATE,
SDIOB_IVAR_FUNCTION,
SDIOB_IVAR_FUNCNUM,
SDIOB_IVAR_CLASS,
diff --git a/sys/dev/smbus/smbconf.h b/sys/dev/smbus/smbconf.h
index a6c320594064..6d2d03f11def 100644
--- a/sys/dev/smbus/smbconf.h
+++ b/sys/dev/smbus/smbconf.h
@@ -75,7 +75,7 @@
* ivars codes
*/
enum smbus_ivars {
- SMBUS_IVAR_ADDR, /* slave address of the device */
+ SMBUS_IVAR_ADDR = BUS_IVARS_PRIVATE, /* slave address of the device */
};
int smbus_request_bus(device_t, device_t, int);
diff --git a/sys/dev/sound/pci/hda/hdac.h b/sys/dev/sound/pci/hda/hdac.h
index bc0ae651a3b6..27d592242578 100644
--- a/sys/dev/sound/pci/hda/hdac.h
+++ b/sys/dev/sound/pci/hda/hdac.h
@@ -982,7 +982,7 @@ typedef int nid_t;
****************************************************************************/
enum hdac_device_ivars {
- HDA_IVAR_CODEC_ID,
+ HDA_IVAR_CODEC_ID = BUS_IVARS_PRIVATE,
HDA_IVAR_NODE_ID,
HDA_IVAR_VENDOR_ID,
HDA_IVAR_DEVICE_ID,
diff --git a/sys/dev/spibus/spibusvar.h b/sys/dev/spibus/spibusvar.h
index 25cd380173ad..82100f767bda 100644
--- a/sys/dev/spibus/spibusvar.h
+++ b/sys/dev/spibus/spibusvar.h
@@ -48,7 +48,7 @@ struct spibus_ivar
#define SPIBUS_CS_HIGH (1U << 31)
enum {
- SPIBUS_IVAR_CS, /* chip select that we're on */
+ SPIBUS_IVAR_CS = BUS_IVARS_PRIVATE, /* chip select that we're on */
SPIBUS_IVAR_MODE, /* SPI mode (0-3) */
SPIBUS_IVAR_CLOCK, /* maximum clock freq for device */
SPIBUS_IVAR_CS_DELAY, /* delay in microseconds after toggling chip select */
diff --git a/sys/dev/superio/superio.h b/sys/dev/superio/superio.h
index c19ffbb43fe2..82530b14429b 100644
--- a/sys/dev/superio/superio.h
+++ b/sys/dev/superio/superio.h
@@ -60,7 +60,7 @@ device_t superio_find_dev(device_t superio, superio_dev_type_t type,
int ldn);
enum superio_ivars {
- SUPERIO_IVAR_LDN = 10600,
+ SUPERIO_IVAR_LDN = BUS_IVARS_SUPERIO,
SUPERIO_IVAR_TYPE,
SUPERIO_IVAR_IOBASE,
SUPERIO_IVAR_IOBASE2,
diff --git a/sys/dev/virtio/virtio.h b/sys/dev/virtio/virtio.h
index 855dafd63033..6266dc29b94c 100644
--- a/sys/dev/virtio/virtio.h
+++ b/sys/dev/virtio/virtio.h
@@ -53,13 +53,15 @@ struct vq_alloc_info;
/*
* VirtIO instance variables indices.
*/
-#define VIRTIO_IVAR_DEVTYPE 1
-#define VIRTIO_IVAR_FEATURE_DESC 2
-#define VIRTIO_IVAR_VENDOR 3
-#define VIRTIO_IVAR_DEVICE 4
-#define VIRTIO_IVAR_SUBVENDOR 5
-#define VIRTIO_IVAR_SUBDEVICE 6
-#define VIRTIO_IVAR_MODERN 7
+enum {
+ VIRTIO_IVAR_DEVTYPE = BUS_IVARS_PRIVATE + 1,
+ VIRTIO_IVAR_FEATURE_DESC,
+ VIRTIO_IVAR_VENDOR,
+ VIRTIO_IVAR_DEVICE,
+ VIRTIO_IVAR_SUBVENDOR,
+ VIRTIO_IVAR_SUBDEVICE,
+ VIRTIO_IVAR_MODERN
+};
struct virtio_feature_desc {
uint64_t vfd_val;
diff --git a/sys/isa/isavar.h b/sys/isa/isavar.h
index 2d4f643d531d..f0b880de2930 100644
--- a/sys/isa/isavar.h
+++ b/sys/isa/isavar.h
@@ -103,7 +103,7 @@ struct isa_pnp_id {
};
enum isa_device_ivars {
- ISA_IVAR_PORT,
+ ISA_IVAR_PORT = BUS_IVARS_PRIVATE,
ISA_IVAR_PORT_0 = ISA_IVAR_PORT,
ISA_IVAR_PORT_1,
ISA_IVAR_PORTSIZE,
diff --git a/sys/powerpc/ps3/ps3bus.h b/sys/powerpc/ps3/ps3bus.h
index 386e54065b35..36433202f193 100644
--- a/sys/powerpc/ps3/ps3bus.h
+++ b/sys/powerpc/ps3/ps3bus.h
@@ -29,7 +29,7 @@
#define _POWERPC_PS3_PS3BUS_H
enum {
- PS3BUS_IVAR_BUS,
+ PS3BUS_IVAR_BUS = BUS_IVARS_PRIVATE,
PS3BUS_IVAR_DEVICE,
PS3BUS_IVAR_BUSTYPE,
PS3BUS_IVAR_DEVTYPE,
diff --git a/sys/powerpc/psim/iobusvar.h b/sys/powerpc/psim/iobusvar.h
index e95478c6f411..d732eacfaf34 100644
--- a/sys/powerpc/psim/iobusvar.h
+++ b/sys/powerpc/psim/iobusvar.h
@@ -35,7 +35,7 @@
*/
enum iobus_ivars {
- IOBUS_IVAR_NODE,
+ IOBUS_IVAR_NODE = BUS_IVARS_PRIVATE,
IOBUS_IVAR_NAME,
IOBUS_IVAR_NREGS,
IOBUS_IVAR_REGS,
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 10f596654150..5bf8df4ca0b0 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -297,6 +297,22 @@ enum intr_polarity {
INTR_POLARITY_LOW = 2
};
+/**
+ * Bus drivers may maintain a set of bus-specific instance variables
+ * for each child device. The BUS_READ_IVAR/BUS_WRITE_IVAR API can be
+ * used to access these variables using an index value. Some index
+ * values are private to a single bus and should be defined in the
+ * private range. Other index values are shared by multiple busses
+ * and must have the same meaning in all bus drivers.
+ */
+
+#define BUS_IVARS_PRIVATE 0x0 /* private variables */
+#define BUS_IVARS_ACPI 0x100
+#define BUS_IVARS_GIC 500
+#define BUS_IVARS_GICV3 1000
+#define BUS_IVARS_GPIOBUS 10500
+#define BUS_IVARS_SUPERIO 10600
+
/**
* CPU sets supported by bus_get_cpus(). Note that not all sets may be
* supported for a given device. If a request is not supported by a
diff --git a/sys/sys/cpu.h b/sys/sys/cpu.h
index 5bb55679a05b..24c7ec6aacfe 100644
--- a/sys/sys/cpu.h
+++ b/sys/sys/cpu.h
@@ -35,10 +35,12 @@
* CPU device support.
*/
-#define CPU_IVAR_PCPU 1
-#define CPU_IVAR_NOMINAL_MHZ 2
-#define CPU_IVAR_CPUID_SIZE 3
-#define CPU_IVAR_CPUID 4
+enum {
+ CPU_IVAR_PCPU = BUS_IVARS_PRIVATE + 1,
+ CPU_IVAR_NOMINAL_MHZ,
+ CPU_IVAR_CPUID_SIZE,
+ CPU_IVAR_CPUID
+};
static __inline struct pcpu *
cpu_get_pcpu(device_t dev)
diff --git a/sys/x86/include/legacyvar.h b/sys/x86/include/legacyvar.h
index 8a7618781b00..442d1eca1063 100644
--- a/sys/x86/include/legacyvar.h
+++ b/sys/x86/include/legacyvar.h
@@ -30,7 +30,7 @@
#define _X86_LEGACYVAR_H_
enum legacy_device_ivars {
- LEGACY_IVAR_PCIDOMAIN,
+ LEGACY_IVAR_PCIDOMAIN = BUS_IVARS_PRIVATE,
LEGACY_IVAR_PCIBUS,
LEGACY_IVAR_PCISLOT,
LEGACY_IVAR_PCIFUNC
diff --git a/sys/xen/xenbus/xenbusvar.h b/sys/xen/xenbus/xenbusvar.h
index 0f4168f17e6a..83638ed6302f 100644
--- a/sys/xen/xenbus/xenbusvar.h
+++ b/sys/xen/xenbus/xenbusvar.h
@@ -55,7 +55,7 @@ enum {
/**
* Path of this device node.
*/
- XENBUS_IVAR_NODE,
+ XENBUS_IVAR_NODE = BUS_IVARS_PRIVATE,
/**
* The device type (e.g. vif, vbd).