Abstract:
One embodiment of the present invention provides a system that facilitates communicating between device drivers within a computing system. The system first determines a need to invoke a function on a remote device from a local device driver, wherein the local device driver is not able to perform the function on the remote device. Once the need has been determined, the system obtains a unique identifier for a remote device driver capable of performing the function on the remote device, and uses the unique identifier to facilitate invoking the function in the remote device driver from the local device driver.

Description:
BACKGROUND 
     1. Field of the Invention 
     The present invention relates to the process of configuring device drivers in a computer system. More specifically, the present invention relates to a method and an apparatus for communicating between device drivers in a computer system. 
     2. Related Art 
     Although computer systems are often built using standard hardware devices and components, the specific configuration of the devices and components can vary greatly between different computer system implementations. This configuration often affects the way the devices are controlled. When the computer system needs to change the state of a device, the computer system typically calls a driver, which contains all of the necessary information for interacting with the device. However, it can be difficult to control other computer system components outside of the device that affect the state of the device. For example, the clock and the power for a device are often managed through the use of a General Purpose Input Output (GPIO), or through a bit in a configuration register of the parent chip. In order to control these related components, a device driver can be specially configured to control these components. However, this means that device drivers may need to be reconfigured differently for each type of system configuration, which is a time-consuming and error-prone process. 
     Another example of where it is hard to control components associated with a device is interrupts. Interrupts are sometimes not routed to the driver responsible for taking action on the interrupt. For instance, an audio driver may expect to receive an interrupt for the audio hardware, but the interrupt for the headphone jack may come through a GPIO. 
     In yet another example, some hot-swappable devices need to know about the position of a release switch that needs to be released before the device can be physically removed from the computer system. 
     Designing systems to allow devices and drivers to be aware of hardware states outside of their control can be expensive and can require drivers to be modified for each different hardware configuration. Hence, what is needed is a method and an apparatus for configuring drivers to operate with hardware within a computer systems without the problems described above. 
     SUMMARY 
     One embodiment of the present invention provides a system that facilitates communicating between device drivers within a computing system. The system first determines a need to invoke a function on a remote device from a local device driver, wherein the local device driver is not able to perform the function on the remote device. Once the need has been determined, the system obtains a unique identifier for a remote device driver capable of performing the function on the remote device, and uses the unique identifier to facilitate invoking the function in the remote device driver from the local device driver. 
     In a variation on this embodiment, the system stores the unique identifier at the local device driver as a property of the local device driver to facilitate identifying the remote device driver capable of performing the function during subsequent invocations of the function. 
     In a variation on this embodiment, during a computer system boot sequence prior to receiving the request, the system identifies devices within the computer system and builds the device tree, including nodes for the identified devices. The system then assigns each device a unique identifier. The system also locates drivers for the identified devices and loads the drivers into memory. 
     In a further variation on this embodiment, the system scans properties of the drivers to identify platform-functions, wherein platform-functions are functions performed by a driver on a device that are able to be invoked by other drivers. As the platform-functions are located, the system builds a database containing platform-functions to facilitate identifying a driver that is capable of performing a given function on the device. 
     In a further variation on this embodiment, the device tree is saved in Read-Only Memory (ROM) so that during future initializations of the hardware, the device tree can be loaded from ROM, instead of having to identify the devices and construct the device tree. 
     In yet a further variation on this embodiment, platform-functions that are able to be executed on demand by the operating system are registered with the operating system. 
     In yet a further variation on this embodiment, identifying the device tree node involves querying the operating system to identify a device tree node that is associated with code that is capable of performing the function, wherein the operating system looks up the device tree node in the database. 
     In a variation on this embodiment, the system instructs the operating system to perform the function on the remote device. In this embodiment, the steps of obtaining the unique identifier for the remote device driver and invoking the function at the remote device driver are performed by the operating system. 
    
    
     
       BRIEF DESCRIPTION OF THE FIGURES 
         FIG. 1  illustrates a computer system in accordance with an embodiment of the present invention. 
         FIG. 2  presents a flowchart illustrating the process of identifying platform-functions in accordance with an embodiment of the present invention. 
         FIG. 3  presents a flowchart illustrating the process of performing a platform-function in accordance with an embodiment of the present invention. 
     
    
    
     DETAILED DESCRIPTION 
     The following description is presented to enable any person skilled in the art to make and use the invention, and is provided in the context of a particular application and its requirements. Various modifications to the disclosed embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other embodiments and applications without departing from the spirit and scope of the present invention. Thus, the present invention is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein. 
     The data structures and code described in this detailed description are typically stored on a computer readable storage medium, which may be any device or medium that can store code and/or data for use by a computer system. This includes, but is not limited to, magnetic and optical storage devices such as disk drives, magnetic tape, CDs (compact discs) and DVDs (digital versatile discs or digital video discs). However, this does not include computer instruction signals embodied in a transmission medium (with or without a carrier wave upon which the signals are modulated). 
     Computer System 
       FIG. 1  illustrates computer system  100  in accordance with an embodiment of the present invention. Computer system  100  can generally include any type of computer system, including, but not limited to, a computer system based on a microprocessor, a mainframe computer, a digital signal processor, a portable computing device, a personal organizer, a device controller, and a computational engine within an appliance. 
     The operating system for computer system  100  maintains a device tree. This device tree has a root node  102 . Coupled to root node  102  are Peripheral Component Interconnect (PCI) nodes  104 - 108 . Advanced Technology Attachment (ATA) node  110 , which controls disks  114  and  116 , is coupled to PCI node  104  along with Universal Serial Bus (USB) node  112 . In the present example, ATA node  118 , which controls disk  120 , is coupled to USB node  112 . PCI node  106  is coupled to slots  122  which provide expansion possibilities for computer system  100 . PCI node  108  is coupled to General-Purpose Input/Output (GPIO) node  124  which is coupled to power control node  126 , handle (interrupt) node  128 , and LED control node  130 . 
     Each node in the device tree may also contain a driver for performing functions on the device associated with the node as well as for communicating with devices associated with parent and child nodes. For example, ATA node  118  can communicate with disk  120  and USB node  112 , but does not know about PCI node  104 . On the contrary, ATA node  110  can communicate with PCI node  104 , but knows nothing about USB node  112 . 
     In one embodiment of the present invention, disk  114  needs to perform functions at LED control node  130  as well as receive interrupts from handle (interrupt) node  128  and power information from power control node  126 . Presently, because they are isolated from each other on the device tree, drivers must be specifically configured to control all of the nodes. Such programming prohibits the same drivers from being used on similar systems with slightly different device tree structures. 
     One embodiment of the present invention provides a mechanism that allows one device driver to cause a function to be invoked by another device driver. This eliminates the need for a driver to implement a mechanism to control devices that are not of the type for which the driver was written. In addition, information is provided in the device tree nodes that describe the specific method for performing functions on the device. This allows for general-purpose drivers to be written, rather than hand-coding drivers for specific computer system configurations. 
     GPIO devices such as power control node  126 , handle (interrupt) node  128  and LED control node  130  control many functions for other devices or nodes in the device tree. For instance, power control node  126  controls the power for the ATA bus represented by ATA node  110 , LED control node  130  controls the LEDs that indicate the status of disks  114  and  116 , and handle (interrupt) node  128  provides the status of the handle that allows for hot-swapping disks  114  and  116 . Properties in the device tree provide the basis for this new functionality. ATA node  110  contains several properties indicating specific functions, e.g. “enable drive power”, and a unique identifier identifying the device tree node that can perform the function. The GPIO node that performs one of the ATA functions contains a property that identifies the device tree node for which it performs a function, as well as the specific method for performing the function, as well as when to perform the function. Note that the GPIO driver is not written to perform only the one function, but performs different functions depending on the properties of a given node. These functions are referred to as “platform-functions” due to the ability to call the functions from any node. 
     Identifying Platform-Functions 
       FIG. 2  presents a flowchart illustrating the process of identifying platform-functions in accordance with an embodiment of the present invention. During the boot sequence of the computer system, the system identifies devices within the computer system (step  202 ) and builds a device tree for the identified devices (step  204 ). In building the device tree, the system assigns each device a unique identifier to facilitate identification of the device. Note that in one embodiment of the present invention, the system saves the device tree and the unique identifiers in ROM, so that during future boot sequences, the device tree and the unique identifiers for the devices can be retrieved from ROM. 
     Once the devices have been identified, the system locates drivers for the identified devices (step  206 ) and loads the drivers for the identified devices (step  208 ). Upon loading the drivers, the system scans the properties of the drivers for platform-functions, or functions that can be invoked by general-purpose drivers at other nodes (step  210 ). The system also builds a database containing all of the device nodes and their corresponding platform-functions to facilitate future identification of nodes capable of performing specific functions (step  212 ). In one embodiment of the present invention, the OS uses this database to identify particular nodes capable of performing functions upon receiving a query from another driver. 
     Performing Platform-Functions 
       FIG. 3  presents a flowchart illustrating the process of performing a platform-function in accordance with an embodiment of the present invention. The process starts when the system determines a need to perform a function on a remote device (step  302 ). Upon determining the need to perform the function, the system identifies the device tree node associated with the function (step  304 ). This can be accomplished by querying the OS, which in turn looks up the function in a database of platform-functions and returns the unique identifier of the device tree node that can perform the function (step  306 ). Once this information has been retrieved, the unique identifier for the device tree node that is capable of performing the function can be saved as a property in the local driver to prevent additional lookups during subsequent requests for the function. 
     In one embodiment of the present invention, the system invokes the function within the remote device driver from the local device driver by using the unique identifier for the remote device driver (step  308 ). In another embodiment of the present invention, the local device driver instructs the operating system to locate the remote device driver and to invoke the function within the remote driver. 
     The foregoing descriptions of embodiments of the present invention have been presented for purposes of illustration and description only. They are not intended to be exhaustive or to limit the present invention to the forms disclosed. Accordingly, many modifications and variations will be apparent to practitioners skilled in the art. Additionally, the above disclosure is not intended to limit the present invention. The scope of the present invention is defined by the appended claims.