Linux Device Drivers: Kernel to User Space communication

Inside Kernel space code:

To convert data from User space to Kernel space => copy_from_user
To send data from Kernel space to User space => copy_to_user

To read/write data to IO device below Device Driver(Firmware) => ioread32/iowrite32

The file_operations structure is defined in linux/fs.h, and holds pointers to functions defined by the driver that perform various operations on the device. Each field of the structure corresponds to the address of some function defined by the driver to handle a requested operation.
C99 way of assigning to elements of a structure.  You should use this syntax in case someone wants to port your driver. It will help with compatibility:

    struct file_operations fops = {
       .read = device_read,
       .write = device_write,
       .open = device_open,
       .release = device_release
    };

debugfs is a special filesystem (technically referred as a kernel space-user-space interface) available in Linux kernel since version 2.6.10-rc3. It is a simple to use RAM-based file system specially designed for debugging purposes. debugfs exists as a simple way for kernel developers to make information available to user space.


Inside User space code:

Open device directly from User space and read/write. 
example: open(“/dev/device_name”, O_RDWR);

Shared Memory:

Shared memory in user space => mmap(), munmap()
Shared memory in kernel space => remap_pfn_range()

PCI Device Drivers:

pci_register_driver - register a new pci driver

pci_unregister_driver - unregister a new pci driver

register_netdev - network device drivers

misc_register - char device drivers
register_blkdev - block device drivers 

module_init - driver initialization entry point

module_exit - driver exit entry point

Miscellaneous commands:

lspci –k => lists all pci device drivers
lsmod => lists all Loadable kernel modules(LKM)
modprobe => add/remove a kernel module

ref:

User space memory access from Kernel => http://www.ibm.com/developerworks/library/l-kernel-memory-access/


Linux Kernel to User space communication(copy_from-user, copy_to_user) -  http://www.makelinux.net/ldd3/chp-3-sect-7


Google Research(papers ...) - http://research.google.com/

Kernel to User space communication - http://people.ee.ethz.ch/~arkeller/linux/multi/kernel_user_space_howto-2.html

Use mmap() shared memory instead of copy_to_user => http://www.linuxforums.org/forum/kernel/158548-avoid-memory-copying-between-user-space-kernel-space.html

Debugfs - 
Linux Device Driver Overview - http://inbasudhakar.blogspot.com/2011/08/pci-driver-flow.html

Practical and effective sandboxing for non-root users -  http://people.csail.mit.edu/nickolai/papers/kim-mbox.pdf


packetdrill: Scriptable Network Stack Testing, from Sockets to Packets - http://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/en/us/pubs/archive/41316.pdf


http://linuxforthenew.blogspot.com/2013/01/why-doshould-we-use-copyfromuser-or.html

Android Development Overview

Android is a Linux-based operating system designed primarily for touchscreen mobile devices such as smartphones and tablet computers. Initially developed by Android, Inc., which Google backed financially and later bought in 2005, Android was unveiled in 2007 along with the founding of the Open Handset Alliance: a consortium of hardware, software, and telecommunication companies devoted to advancing open standards for mobile devices. 

Android software development is the process by which new applications are created for the Android operating system. Applications are usually developed in the Java programming language using the Android Software Development Kit, but other development tools are available. 


ref:

Android Wiki - 

Android Source - http://source.android.com/

Android Platform Developer's guide - http://www.kandroid.org/online-pdk/guide/index.html

Intel Android resources - http://software.intel.com/en-us/android

Marakana(NewCircle) resources - https://thenewcircle.com/s/tags/android


Browse Android source code online -

Android Books - https://drive.google.com/folderview?id=0B5BO97vHUkN2ZmV0cE5wMXFabFU&usp=sharing_eid

Android Tools - http://developer.android.com/tools/help/logcat.html

Android Compatibility - https://source.android.com/compatibility/index.html




Downloading and building Android - http://source.android.com/source/building.html

Android SDK ADT bundle - http://developer.android.com/sdk/index.html#download


Android Development Intelpedia Wiki - https://intelpedia.intel.com/SFF_Android_Development



Intel for Android Developers Learning Series Landing Page - http://software.intel.com/en-us/blogs/2012/11/28/intel-for-android-developers-learning-series

Development and Optimization for NDK-based Android Game Application on Platforms based on Intel® Architecture - http://software.intel.com/en-us/articles/development-and-optimization-for-ndk-based-android-game-application-on-platforms-based-on

Installing the Android SDK for Intel® Architecture - http://software.intel.com/en-us/articles/installing-the-android-sdk-for-ia/
Remote Application Debug on Android OS - http://software.intel.com/en-us/articles/application-debug-android/


Intel ships high-powered C++ compiler for native Android apps - http://www.theregister.co.uk/2013/08/28/intel_cpp_compiler_for_android/

Intel compilers for Windows and Linux are available for internal use here - softwareproducts.intel.com/ILC


How to add a native lib to apk - http://stackoverflow.com/questions/4365227/add-a-native-lib-to-an-apkhttp://stackoverflow.com/questions/8295728/how-to-add-a-shared-library-to-my-apk


Where can I browse Android source code on-line - http://stackoverflow.com/questions/449763/where-can-i-browse-android-source-code-on-line


Linux Device Drivers - ttp://lwn.net/Kernel/LDD3/


Porting Unix to Windows - http://msdn.microsoft.com/en-us/library/y23kc048.aspx


Windows to Unix Porting - 

Porting Windows to Unix - http://www.woodtennis.com/win2unix.html

Porting Windows to Unix - http://www.woodtennis.com/win2unix.html


Unix man pages - http://www.unix.com/man-page/All/3/libm/