Linux driver development Miscellany (0x01) - the kernel of some markers such as Acer __init

> The following is an excerpt from the kernel initialization macros optimization, initialization sequence, the init, devexit etc. , only save your notes.

A large number of kernel functions and data structures used to mark different macros have different effects. Such as macros the init, devinit and so on. These macros are defined in include / linux / init.h header file. These macros compiler can optimize the code into the appropriate memory location to reduce the memory footprint and to improve the efficiency of the core.

Here are some commonly used macros:

__init

Initialization code at reboot flag kernel, the kernel after startup is complete is no longer required. This marker is located .init.text code memory area.

__exit

Mark exit code is not valid for non-modular.

__initdata

Initialize data structures used at startup kernel marker, is no longer required after completion of the core promoter. This marker is located .init.data code memory area.

__devinit

Initialization code marking devices used.

__devinitdat to

Marking a data structure of device initialization function.

__devexit

Tag of the device using the removal code.

xxx_initcall

A series of initialization code, in descending priority order.

Features initialization code is: start running in the system, and once running immediately withdraw from memory, not take up memory.

For driver modules, these cases optimization flags are as follows:

  • By module_init () and module_exit () function call to the function you need to use init and exit macros to mark.
  • pci_driver data structure without marking.
  • probe () and remove () function should be used devinit and devexit numerals, and only labeled probe () and remove ()
  • If remove () using devexit mark, then configuration pci_driver use devexit_p (remove) referenced to remove () function.
  • If you are unsure or need to add the macros do not add optimization.

Original: Big Box  Linux driver development Miscellany (0x01) - the kernel of some markers such as Acer __init


Guess you like

Origin www.cnblogs.com/petewell/p/11615213.html