mdriver_add()

Register the minidriver with the system

Synopsis:

int mdriver_add( char *name,
                 int interrupt,
                 int (*handler)( int state,
                                 void *data ), 
                 paddr32_t data_paddr, 
                 unsigned data_size);

Arguments:

name
An arbitrary character string used for identification purposes.
interrupt
The interrupt that you want to attach the handler to.
handler
A pointer to the handler function for the minidriver. For more information, see Handler function in the Writing a Minidriver chapter.
data_paddr
The physical address of a block of memory that the minidriver can use to store any data. It can be:
  • a predetermined location (e.g., one that you reserved beforehand by passing the -r addr,size[,flag] option to startup)
  • a block that you allocated by calling the alloc_ram() startup function

The virtual address of this block is passed to the handler function as its data argument.

data_size
The size of the block of memory denoted by data_paddr.

Library:

libc

Description:

This function registers the minidriver with the system, as follows:

  • It checks the interrupt number to make sure it's valid, so you must call init_intrinfo() to add the interrupt information to the system page before you can register a minidriver. For more information, see the Customizing Image Startup Programs chapter of Building Embedded Systems.
    Note:
    If the interrupt number isn't valid, mdriver_add() crashes the system.
  • It calls the handler with a state of MDRIVER_INIT and the virtual address that corresponds to the physical address given by data_paddr.
  • It adds an entry of type mdriver_entry to the mdriver section of the system page.

You call mdriver_add() from main() in your board's startup code.

Returns:

The index into the mdriver section of the system page for the newly added minidriver, or -1 if the minidriver wasn't added.

Classification:

QNX Neutrino

Page updated: