• Immutable Page
  • Info
  • Attachments

WritingPortableDrivers

Note, This article is originally based on the article, Writing Portable Device Drivers published in Linux Journal Embedded by Greg Kroah-Hartman, and has been added here by the original author. Please feel free to update it like any other page on this site.

Almost all Linux kernel device drivers work on more than just one type of processor. This only happens because device-driver writers adhere to a few important rules. These rules include using the proper variable types, not relying on specific memory page sizes, being aware of endian issues with external data, setting up proper data alignment and accessing device memory locations through the proper interface. Here is a list of these rules:

If you follow these different rules when creating a new Linux kernel device driver, or when modifying an existing one, the resulting code will run successfully on a wide range of processors. These rules are also good to remember when debugging a driver that only works on one platform (remember those endian issues).

The most important resource to remember is to look at existing kernel drivers that are known to work on different platforms. One of Linux's strengths is the open access of its code, which provides a powerful learning tool for aspiring driver authors.

Tell others about this page:

last edited 2005-10-12 09:38:55 by port-212-202-77-43