Posts

Device Power State

Device Power State I will be describing about only Native Power management here, where we  will set the  PM configuration hardware registers through PCI configuration space.  Well there are other kinds of PM like runtime PM, Native PM using firmware like ACPI..etc What is Device Power State ? In general, power management is a feature allowing one to save energy by putting devices into states in which they draw less power (low-power states) at the price of reduced functionality or performance. PCI devices may be put into low-power states in two ways, by using the device capabilities introduced by the PCI Bus Power Management Interface Specification, or with the help of platform firmware, such as an ACPI BIOS. In the first approach, that is referred to as the native PCI power management (native PCI PM) in what follows, the device power state is changed as a result of writing a specific value into one of its standard configuration registers. The second approach requires the platform firm

Chapter2 - Building and Running: The Hello World Module

 The Hello World Module The hello world is a very simple kernel module.  We will try to explore the same in this blog. I am assuming on your distribution (Debian, Ubuntu, Fedora, CentOS..etc) you have installed all the dependency packages, Kernel Source, and header files of the running kernel.  The sample hello.c kernel module can    #include <linux/module.h> #include <linux/init.h> MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("NARESH BHAT"); static int __init hello_init(void) {      printk(KERN_ALERT "Hello World!\n");      return 0; } static void __exit hello_exit(void) {      printk(KERN_ALERT "Good Bye, Cruel World!\n"); } module_init(hello_init); module_exit(hello_exit); When a module is loaded hello_init will be called and after unloading the kernel hello_exit function will be called by running kernel.  These are defined by module_init and module_exit kernel macros. Hence the module compiled version should match the running

Advanced C TIPS and TECHNIQUES

Image
  C TIPS and TECHNIQUES Data Presentation How will you represent -ve and +ve numbers in binary format ? Can you represent 0-127 +ve numbers and -1 to -128 -ve numbers ? 01111111 this is 127 the MSB is 0 in +ve series …… …….. 0000001  this is  1  0000000  this is  0 11111111  this is -1  the MSB is 1 in -ve series …. …... 1000000  this is -128 Using 2’s complement notation we can positive or negative values to each bit pattern. What are C’s basic data types can you explain ? C's basic data types are char, int, float, and double. Each size is machine dependent, but typical machines use 8 bits for a char, 32 bits for a float, and 64 bits for a double. The size of an int reflects the word size of the machine and is typically 16 or 32 bits. What are qualifiers for basic data types ? C provides long, short, and unsigned qualifiers for integer data types. A long is usually twice the size of an int on 16-bit machines, but long's and int's are ofte