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

Update android.jar – custom jar

October 23rd, 2013 by mhyun

cp ~/android_gns/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes/* . -R

zip -r android.jar .



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

SYSCALL_DEFINE0(getpid)
{
// 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…
-chandu

 

=======================

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


Old, but still necessary and working docs from IBM

September 23rd, 2013 by mhyun

http://www.ibm.com/developerworks/library/?sort_by=&show_abstract=true&show_all=&search_flag=&contentarea_by=All+Zones&search_by=kernel+api&product_by=-1&topic_by=-1&industry_by=-1&type_by=All+Types&ibm-search=Search



CPU Governors

September 14th, 2013 by mhyun

The document in Kernel:

https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt

 

Brief compares:

http://wiki.rootzwiki.com/CPU_Governors

http://forum.xda-developers.com/showthread.php?t=1736168

 

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

 

Related Paper:

http://dl.acm.org/ft_gateway.cfm?id=2448665&ftid=1352015&dwn=1&CFID=357950533&CFTOKEN=77085944

 

 

 



Microsoft cuts touchscreen lag to 1ms, makes other panels look silly

September 11th, 2013 by mhyun

http://www.engadget.com/2012/03/10/microsoft-cuts-touchscreen-lag-to-1ms/

1ms is my goal



Latency Numbers Every Programmer Should Know (Berkely)

August 29th, 2013 by mhyun

Latency Numbers Every Programmer Should Know (Berkely)



Processing Binaries

August 29th, 2013 by mhyun

EEL



Processing Bytecodes

August 29th, 2013 by mhyun

apktool to extract bytecodes
dex2jar to convert Dalvik bytecodes toJava bytecodes
BCEL to modify Java bytecodes



Inject touch events

August 29th, 2013 by mhyun

#!/usr/bin/env python

import os

os.system(‘adb shell sendevent /dev/input/event1 3 57 100’)
os.system(‘adb shell sendevent /dev/input/event1 3 48 15’)
os.system(‘adb shell sendevent /dev/input/event1 3 58a 191’)
os.system(‘adb shell sendevent /dev/input/event1 3 53 347’)
os.system(‘adb shell sendevent /dev/input/event1 3 54 482’)
os.system(‘adb shell sendevent /dev/input/event1 0 0 0’)
os.system(‘adb shell sendevent /dev/input/event1 3 57 0’)
os.system(‘adb shell sendevent /dev/input/event1 0 0 0’)

event1 can be changed. Run getevent



Change loglevel

August 29th, 2013 by mhyun

echo 3 > /proc/sys/kernel/printk
The number, 3, can be changed.