diff --git a/docs/develop/kernel/device_manager_introduction.html b/docs/develop/kernel/device_manager_introduction.html index 6fa69c2878..4af29626ee 100644 --- a/docs/develop/kernel/device_manager_introduction.html +++ b/docs/develop/kernel/device_manager_introduction.html @@ -11,7 +11,7 @@ device driver architecture introduced with BeOS.

although most of its details are already specificed.

-

1. The Basics

+

1. The Basics

The device manager functionality builds upon device_node objects. Every driver in the system publishes one or more of such nodes, building a @@ -36,7 +36,7 @@ and registers a child node for each device on the bus.

userland applications. All drivers and devices are kernel modules.

-

2. Exploring the Device Tree

+

2. Exploring the Device Tree

So how does it all work? When building the initial device tree, the system only explores a minimum of device drivers only, resulting in a tree that basically @@ -55,10 +55,15 @@ device manager will then completely explore all device nodes of that type.

are in a matching module directory. In the above example of a disk driver, this would be either in "busses/scsi", "busses/ide", "drivers/disk", ...

-TODO: untyped/generic busses are not yet supported! +

For untyped or generic busses, it will use the context information gained +from the devfs query directly, and will search for drivers in that sub directory +only. The only exception to this rule are the devfs directories "disk", "ports", +and "bus", which will also allow to search matching drivers in "busses". While +this is relatively limited, it is a good way to cut down the number of drivers +to be loaded.

-

3. Writing a Driver

+

3. Writing a Driver

The device manager assumes the following API from a driver module:

+

To ensure that a module exports this API, it must end its module name with "driver_v1" to denote the version of the API it supports. Note that suspend() and resume() are currently never called, as Haiku has @@ -100,6 +106,7 @@ no power management implemented yet.

If your driver can give the device it is attached to a nice name that can be presented to the user, it should add the B_DEVICE_PRETTY_NAME attribute to the device node. +

The B_DEVICE_UNIQUE_ID should be used in case the device has a unique ID that can be used to identify it, and also differentiate it from other devices of the same model and vendor. This information will be added to the file system @@ -107,14 +114,20 @@ attributes of all devices published by your driver, so that user applications can identify, say, a USB printer no matter what USB slot it is attached to, and assign it additional data, like paper configuration, or recognize it as the default printer.

+

If your driver implements an API that is used by a support or bus module, you will usually use the B_DEVICE_FIXED_CHILD attribute to specify exactly which child device node you will be talking to. If you support several child nodes, you may want to have a closer look at the section explaining how to write a bus driver.

+

In addition to the child nodes a driver registers itself, a driver can either +have dynamic children or fixed children, never both. Also, fixed children are +registered before register_child_devices() is called, while dynamic +children are registered afterwards.

-

4. Publishing a Device

+ +

4. Publishing a Device

To publish a device entry in the device file system under /dev, all your driver has to do is to call the @@ -166,7 +179,7 @@ the device manager delivers for this.

-

5. Writing a Bus Driver

+

5. Writing a Bus Driver

A bus driver is a driver that represents a bus where one or more arbitrary devices can be attached to.

@@ -211,10 +224,27 @@ here, which causes the driver only to be searched when the system asks for it.

5.2. Writing a Simple Bus Driver

-TODO: support for these drivers is still missing! +

A bus can be simple in a number of ways:

+
    +
  1. It may not know how many or if any devices are attached to it
  2. +
  3. It cannot retrieve any type information about the devices it has, but + knows all devices that are attached to it
  4. +
+ +

An example of the latter would be the Zorro bus of the Amiga - it only has +information about the vendor and device ID, but no type information. It should +be implemented like an intelligent bus, though, with the type information simply +omitted.

+ +

Therefore, this section is about the former case, that is, a simple bus like +the ISA bus. Since it doesn't know anything about its children, it does not +publish any child nodes, instead, it will just specify the +B_FIND_MULTIPLE_CHILDREN and B_FIND_CHILD_ON_DEMAND flags for its device node. +Since there are no additional informations about this bus, the device manager +will assume a simple bus, and will try to find drivers on demand only.

-

6. Open Issues

+

6. Open Issues

While most of the new device manager is fledged out, there are some areas that could use improvements or are problematic under certain requirements. Also, some @@ -245,5 +275,39 @@ of the parent node this device node wants to talk to.

6.5. Unregistering Nodes

+

6.6. Support for generic drivers is missing

+ +

This should probably be done by simply adding a simple bus driver named +"generic" that generic drivers need to ask for.

+ +

6.7. Mappings, And Other Optimizations

+ +

Due to the way the device tree is built, the device manager could remember +which driver served a given device node. That way, it wouldn't need to search +for a driver anymore, but could just pick it up. Practically, the device manager +should cache the type (and/or vendor/device) information of a node, and assign +one or more drivers (via module name) to this information. It should also +remember negative outcome, that is if there is no driver supporting the +hardware.

+ +

This way, only the first boot would require an actual search for drivers, as +subsequent boots would reuse the type-driver assignments. If a new driver is +installed, the cached assignments would need to be updated immediately. If a +driver has been installed outside of the running system, the device manager +might want to create a hash per module directory to see if anything changed to +flush the cache. Alternatively or additionally, the boot loader could have a +menu causing the cache to be ignored.

+ +

It would be nice to find a way for generic and simple busses to reduce the +amount of searching necessary for them. One way would be to remember which +driver supports which bus - but this information is currently only accessible +derived from what the driver does, and is therefore not reliable or complete. +A separately exported information would be necessary for this.

+ +

Also, when looking for a generic or simple bus driver, actual directories +could be omitted; currently, driver search is always recursive, as that's how +the module mechanism is working. Eventually, we might want to extend the +open_module_list_etc() call a bit more to accomplish that.

+