2013年7月19日 星期五

system call for arm platform (1)

android的external/kernel-headers/original目錄
from:
https://github.com/billwangwl/android_linux_stuff/blob/master/android_bionic_kernel-headers-original_explanation_zh_CN.html

external folder中linux kernel header的作用

在Linux中,有一个external/kernel-headers/original,这个文件夹中有很多linux的头文件,与kernel/include/linux有很多重复的文件。

 1、Android external folder

  External refers to external open source libraries. That means libraries that the Android platform depend upon but that are not primarily developed and maintained by the Android open source project. Typical examples are webkit for the browser, FreeType for fonts, SqlLite for databases and so on. As more features are added to Android, more of these libraries are included in external.

 external folder是外部的open source lib,这些lib是android依赖的,但是主要的开发和维护又不是android来做

 http://stackoverflow.com/questions/10477565/android-external-folder-functionality

  2,external/kernel-headers/original 

 (external/kernel-headers/original/README.TXT)

 这个文件夹里的头文件是Bionic来用生成一个干净的user-land(user space)头文件。基于GPL2+。  

3、Bionic

 Bionic libc是BSD standard C library发展而来,最早是Google为Android开发。作用主要有三个: 

a) BSD license: 通过BSD license,Android程序就和GPL分隔开来。

b) Bionic比GNU C Library要小的多。

c) Bionic的速度更快。

 Bionic也缺少很多完整的libc的特性,比如宽字符和C++的异常处理。一些函数也没有实现。 

(http://discuz-android.blogspot.com/2008/10/google-android-native-libc-bionic.html) 

HAL层,以及除了kernel以外的任意用到的C头文件,都是bionic中的。

 ./core/pathmap.mk,pathmap_INCL := libc:bionic/libc/include (http://www.linuxidc.com/Linux/2011-03/33672.htm ) 

Android编译环境所用的交叉编译工具链是prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin /arm-eabi-gcc,-I和-L参数指定了所用的C库头文件和动态库文件路径分别是bionic/libc/include和out /target/product/generic/obj/lib

 (http://www.360doc.com/content/09/0624/17/36491_4018938.shtml )

 kernel中用的头文件在kernel/include中。user space用的头文件在bionic下。

 4,Bionic kernel header 

 (bionic/libc/kernel/README.TXT)

 Bionic有一套干净的Linux头文件,这些头文件是通过bionic/libc/kernel/tools解析一份原始的,没有修改过的linux头文件生成的,这份头文件就在external/kernel-headers/original。

干净的头文件只包括类型和宏定义,不过处于效率的考虑,不会生成一些静态内联函数。 

这些生成的头文件可以用于编译C++,C,也能够按照ANSI模式编译(linux kernel中用到了大量GNU扩展)。

生成头文件的过程是:

 *external/kernel-headers/original 包含通常linux kernel source tree中的include目录。这里仅仅只应该包含android依赖的kernel头文件。

 *bionic/libc/kernel/common 包含平台无关的头文件。 

from:

 http://blog.csdn.net/muge0913/article/details/7518568

 About sys_ni_syscall in Kernel System Call Table

不是所有的系统调用都有实际内容,如sys_ni_syscll在kernel/sys_ni.c中定义:
asmlinkage long sys_ni_syscall(void)
{
    return -ENOSYS;
}

你会发现在sys_call_table中sys_ni_syscall占据了很多内容,其实它代表着已被淘汰的系统调用。其实只要是被内核淘汰的系统调用都会被sys_ni_systcall代替。之所以这样是为了老的程序在新的内核上运行时不至于出现大的问题。如不应调用这个系统调用却调用了那个系统调用了。

from:

http://bbs.csdn.net/topics/350141651

cond_syscall

#ifndef cond_syscall  
     #define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
#endif

告诉编译器,当在符号表中没有x时,就用sys_ni_syscall这个符号来代替。这样的话,一些在特殊系统中没有定义出的系统调用的函数,就被默认为是sys_ni_syscall了。

2013年7月9日 星期二

ubuntu super user

因為android下envsetup.sh中的mm指令權限不足無法編譯,
而直接下"sudo mm"又無法正確識別為mm指令,
只好成為root帳號來下指令。
要成為root要打指令"su  -",
可是在ubuntu下,一般操作都以sudo指令代替直接以root帳號執行指令,
因此不知道root密碼為何,無法進入root 帳號,
可以用"sudo passwd"修改root密碼再行登入。

2013年7月2日 星期二

oprofile

  • Oprofile 包含在 Linux 2.5 和更高版本的内核中
編譯kernel:
General setup
            Kernel Performance Events And Counters     --->
                          -> Kernel performance events and counters   # CONFIG_PERF_EVENTS
            -> Profiling support  [*]                             # CONFIG_PROFILING
            -> OProfile system profiling  <*>            # CONFIG_OPROFILE
Kernel Features
            -> Enable hardware performance counter support for perf events [*]
            # CONFIG_HW_PERF_EVENTS

在menuconfig模式中,可以用"shift + ?"查詢.config與make menuconfig所設定的對應關係,也可以用"/"查詢.config的選項名稱。

opcontrol  --setup

oprofiled  --session-dir=/data/oprofile  --vmlinux=/vmlinux   \

--kernel-range=c00xxxxx,c0xxxxxx  --events=CPU_CYCLES:255:0:10000:1:1:1   \

--separate-lib=1  --separate-kernel=1


opcontrol  --setup  --vmlinux=/vmlinux  -kernel-range=c00xxxxx,c0xxxxxx    \

--event=CPU_CYCLES:10000:1:1:1

opcontrol --timer


2013年6月25日 星期二

可以動且對開發有幫助的apk

百度一鍵Root.apk:
取得該死的root權限。
Root Explorer.apk:
在圖形介面重新得到"ls"的權利。
AndroidTerm.apk:
可以用。至少比看起來能動的好多了。




2013年6月13日 星期四

ADB: error: insufficient permissions for device

$ sudo adb shell
insufficient permissions for device

$ sudo adb devices
List of devices attached:
??????????????                      no permission


之前有用adb連接user版的android與eng版的android系統,導致這個問題。

解決方法:

$ adb kill-server
$ adb start

link supervision timeout

http://blog.csdn.net/evilcode/article/details/5717527

2013年5月30日 星期四

關於bluetooth active connection

How many ACTIVE bluetooth connections can the iPhone 4 support at one time?

       Am wondering just how many ACTIVE connections my iPhone 4 can support at one time?  I've got my iPhone paired via bluetooth to my car radio...alllowing to answer calls handsfree, as well as listen to my music through the radio.  I'm thinking about purchasing the iPhone radar detector, made by Cobra, which will also utilize a live bluetooth connection.  Is iPhone limited to only one live connection at a time, or can I have more?


Pretty sure bluetooth protocol itself is limited to one active connection by design.  So not a limitation of iPhone but the protocol.