Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


Of particular interest are the three pointers to otherresourcestructures. These enable a tree-like hierar-
chy to be established in which the pointers are often arranged as you will see below.


Figure 6-20 illustrates how theparent,child,andsiblingpointers are arranged in a tree structure that is
reminiscent of the process network discussed in Chapter 2.


Sibling
Parent
Child

Figure 6-20: Resource management in a tree structure.

The rules for linking theparent,child,andsiblingelements are simple.


❑ Each child hasjust oneparent.
❑ A parent can have any number of children.
❑ All children with the same parent are linked on the list of siblings.

The following must be noted when the datastructure is represented in memory.


❑ Even though there may be a pointer from each child to the parent, there is always only a single
pointer from the parent to the first child. All other children can be reconstructed from the sibling
list.
❑ The pointer to the parent may also beNULL, in which case there is no higher-level element.

How can this hierarchical structure be used for device drivers? Let us look at the example of a system bus
to which a network card is attached. The card supportstwooutputs, each of which is assigned a specific
memory area for data input and output. The bus itself also has a I/O memory area, sections of which are
used by the network card.


This scheme fits perfectly into the tree hierarchy. The bus memory area that theoretically occupies the
(fictitious) range between 0 and 1,000 acts as the rootelement (the uppermost parent element). The net-
work card lays claim to the memory area between 100 and 199 and is a child of the root element (the bus
itself). The child elements of the network card represent the individual network outputs to which the I/O

Free download pdf