Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

IBM AIX device driver development

A tutorial on AIX device driver framework and related APIs

Gautam Raut (gautraut@in.ibm.com), Senior Software Engineer, IBM
Gautam
Gautam Raut works as a Senior Software Engineer for the Andrew File System (AFS) Team at the IBM Software Labs in Pune, India. He works with kernel and user-level debugging of dumps and crashes, as well as reported bugs on the Linux and AIX platforms. He has also worked on various AFS-specific AIX kernel components. Gautam holds M.S. in Computer Science from the University of Pune. He is a Linux enthusiast who spends his spare time exploring the Linux kernel on his Fedora 8 box.

Summary:  This tutorial illustrates the IBM® AIX® device driver framework and related application programming interfaces (APIs). Here, we shall discuss about the device switch structure, API to register device switch methods, major and minor number management, and moving data from kernel to user space.

Date:  28 Mar 2013
Level:  Intermediate PDF:  A4 and Letter (244 KB | 15 pages)Get Adobe® Reader®

Activity:  20933 views
Comments:  

Basics of kernel extension configuration

Components and use of struct cfg_load

Structure for loading a kernel extension:

struct cfg_load
{
   caddr_t path; /* ptr to object module pathname */
   caddr_t libpath; /* ptr to a substitute libpath */
   mid_t   kmid;    /* kernel module id (returned) */
};


Components and use of struct cfg_dd

Structure for calling a device driver's config (module) entry point:

struct cfg_dd
{
  mid_t   kmid;/* Module ID of device driver */
  dev_t   devno; /* Device major/minor number */
  int     cmd; /* Config command code for device driver*/
  caddr_t ddsptr; /* Pointer to device dependent structure*/
  int     ddslen; /* Length of device dependent structure */
};


Sysconfig() system call

Sysconfig() requires three parameters.

int sysconfig(             
   int cmd, /* Command to be executed */
   void *parmp,/* Address of structure containing info for cmd */
   int parmlen /* Length of parmp information */
 );    

Sysconfig() is used to control the lifecycle of a kernel extension. As mentioned in /usr/include/sys/sysconfig.h, the following commands are passed to sysconfig() as cmd parameter.

  • SYS_KLOAD: Loads a kernel extension object file in a kernel memory.
  • SYS_SINGLELOAD: Loads a kernel extension object file only if it is not already loaded.
  • SYS_QUERYLOAD: Determines if a specified kernel object file is loaded.
  • SYS_KULOAD: Unloads a previously loaded kernel object file.
  • SYS_CFGKMOD: Calls the specified module at its module entry point for configuration purposes.

4 of 15 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX, Linux
ArticleID=861832
TutorialTitle= IBM AIX device driver development
publish-date=03282013
author1-email=gautraut@in.ibm.com
author1-email-cc=