14.3 Newbus API

As the Newbus API is huge, this section makes some effort at documenting it. More information to come in the next revision of this document.

14.3.1 Important locations in the source hierarchy

src/sys/[arch]/[arch] - Kernel code for a specific machine architecture resides in this directory. For example, the i386 architecture, or the SPARC64 architecture.

src/sys/dev/[bus] - device support for a specific [bus] resides in this directory.

src/sys/dev/pci - PCI bus support code resides in this directory.

src/sys/[isa|pci] - PCI/ISA device drivers reside in this directory. The PCI/ISA bus support code used to exist in this directory in FreeBSD version 4.0.

14.3.2 Important structures and type definitions

devclass_t - This is a type definition of a pointer to a struct devclass.

device_method_t - This is same as kobj_method_t (see src/sys/kobj.h).

device_t - This is a type definition of a pointer to a struct device. device_t represents a device in the system. It is a kernel object. See src/sys/sys/bus_private.h for implementation details.

driver_t - This is a type definition which, references struct driver. The driver struct is a class of the device kernel object; it also holds data private to for the driver.

Figure 14-1. driver_t implementation

     struct driver {
            KOBJ_CLASS_FIELDS;
            void    *priv;          /* driver private data */
      };
   

A device_state_t type, which is an enumeration, device_state. It contains the possible states of a Newbus device before and after the autoconfiguration process.

Figure 14-2. Device statesdevice_state_t

     /*
       * src/sys/sys/bus.h
       */
      typedef enum device_state {
        DS_NOTPRESENT,  /* not probed or probe failed */
            DS_ALIVE,       /* probe succeeded */
            DS_ATTACHED,    /* attach method called */
            DS_BUSY         /* device is open */
      } device_state_t;
   

This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.