Rice University logo
Top blue bar image
Random notes before using Google Keep

Archive for the ‘General’ Category

Where is app dir?

October 11th, 2014 by mhyun


Adding System Call in Android bionic library

September 25th, 2013 by mhyun

Copied from http://android-harvest.blogspot.com/2012/09/adding-system-call-in-android-bionic.html

Adding System Call in Android bionic library

Finally after long time gap I am in my blog again. This time I will explore adding system call in bionic libc.For simplicity sake let me tell about getpid() system call which is already presentKernel Changes :

1.  kernel/include/linux/syscalls.h
This header file provides syscall function prototype
eg:   asmlinkage long sys_getpid(void);
return type: long
asmlinkage macro tells the compiler to pass all function arguments on the stack.

2. kernel/kernel/timer.c
This source file contains actuall function definition

// Body of getpid() function.

3. kernel/arch/arm/include/asm/unistd.h

The system call need to be given a number in kernel that piece of code is done here
eg: #define __NR_getpid         (__NR_SYSCALL_BASE+ 20)

4. kernel/arch/arm/kernel/calls.S

The declared system call need to be exposed in syscall_table that is done here
eg: CALL(sys_getpid)

This completes Kernel part of exposing syscall getpid()

Bionic Changes:

5. bionic/libc/SYSCALLS.TXT

This is the only place getpid need to exposed in userpace, rest all is taken care automatically by gensyscalls.py python script.
The syntax goes likes this
return_type func_name[:syscall_name][:call_id]([parameter_list])  (#syscall_number|stub)

eg: pid_t getpid()  20

gensyscalls.py script automatically creates getpid.S Stub file and placed in 2 different locations as given below
a. bionic/libc/arch-arm/syscalls.mk
eg: syscall_src += arch-arm/syscalls/getpid.S

b. bionic/libc/arch-arm/syscalls/getpid.S

With both the changes cross-compile kernel and platform binaries so that you can enjoy the syscall interface between userspace and kernel space.

Please do comment if something is missed…

Always brighter side of the world…



Added by me.

In Bionic side,

  • Copy the unistd.h to android/external/kernel-headers/original/asm-arm
  • Run bionic/libc/kernel/tools/update_all.py to update bionic/libc/kernel/arch-arm/asm/unistd.h
  • Run bionic/libc/tools/gensyscalls.py

CPU Governors

September 14th, 2013 by mhyun

The document in Kernel:



Brief compares:




Interactive Governor: https://lkml.org/lkml/2012/2/7/483


Related Paper:





Make the device writable

August 29th, 2013 by mhyun

mount -o remount -rw -t ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/system /system/
The path may be different from device to device

Or, simply type after rooting
adb remount