Brief Analysis of Android's changes to the Linux kernel-(below)

Source: Internet
Author: User

2. yaffs2

Unlike PCs (files are stored on hard disks), mobile phones use flash as storage media. HTC G1 uses NAND Flash, which is widely used and has many types (such as SLC and MLC ), the storage density is getting higher and higher (dozens of GB nandflash has been available), and the price is getting lower and lower.

Yaffs2 is a file system dedicated to flash, and yaffs2 is short for "yet another flash file system, 2nd Edition. Yaffs2 provides an efficient nandflash access interface for the Linux kernel. However, nandflash support is not included in the 2.6.25 kernel, So Google added support for nandflash. According to statistics, in order to support yaffs2, Google has modified and added the following 35 files:

1. Add the yaffs configuration in chg: fs/kconfig

2. Add yaffs to chg: fs/makefile

The newly added yaffs2 is as follows:

1. New: fs/yaffs2/kconfig18new: fs/yaffs2/yaffs_mtddif2.h

2. New: fs/yaffs2/makefile19new: fs/yaffs2/yaffs_nand.c

3. New: fs/yaffs2/devextras. h20new: fs/yaffs2/yaffs_nand.h

4. New: fs/yaffs2/moduleconfig. h21new: fs/yaffs2/yaffs_nandemul2k.h

5. New: fs/yaffs2/yaffs_checkptr1_c22new: fs/yaffs2/yaffs_packedtags1.c

6. New: fs/yaffs2/yaffs_checkprtw.h23new: fs/yaffs2/yaffs_packedtags1.h

7. New: fs/yaffs2/yaffs_ecc.c24new: fs/yaffs2/yaffs_packedtags2.c

8. New: fs/yaffs2/yaffs_ecc.h25new: fs/yaffs2/yaffs_packedtags2.h

9. New: fs/yaffs2/yaffs_fs.c26new: fs/yaffs2/yaffs_qsort.c

10. New: fs/yaffs2/yaffs_getblockinfo.h27new: fs/yaffs2/yaffs_qsort.h

11. New: fs/yaffs2/yaffs_guts.c28new: fs/yaffs2/yaffs_tagscompat.c

12. New: fs/yaffs2/yaffs_guts.h29new: fs/yaffs2/yaffs_tagscompat.h

13. New: fs/yaffs2/yaffs_mtdif.c30new: fs/yaffs2/yaffs_tagsvaliditiy.c

14. New: fs/yaffs2/yaffs_mtdif.h31new: fs/yaffs2/yaffs_tagsvalidity.h

15. New: fs/yaffs2/yaffs_mtddif1.c32new: fs/yaffs2/yaffsinterface. h

16. New: fs/yaffs2/yaffs_mtddif1.h33new: fs/yaffs2/yportenv. h

17. New: fs/yaffs2/yaffs_mtddif2.c

3. Bluetooth

Google modified 10 files in the Bluetooth communication protocol stack. These changes fix some significant bugs related to Bluetooth headsets and some functions related to Bluetooth debugging and access control, as shown below.

1. Add hci uart debug to chg: Drivers/Bluetooth/kconfig

2. chg: Drivers/Bluetooth/hci_ii.c if hci uart debug is defined in the Kernel configuration, the bt_dbg () macro is added.

3. Add the L2CAP, hci_core, hci_sock configuration options to chg: net/Bluetooth/kconfig, and common interfaces and voice

4. chg: net/Bluetooth/af_rjth.c. If config_android_paranoid_network is defined, add a security check for the Bluetooth function.

5. chg: net/Bluetooth/hci_event.c fixed the Bluetooth encryption bug and added voice support.

6. chg: net/Bluetooth/RFCOMM/CORE. c bug fixing

7. chg: net/Bluetooth/RFCOMM/sock. c bug fixing

8. Disable the SCO link in chg: net/Bluetooth/sco. C.

9. chg: Include/NET/Bluetooth/hci_core.h disable lmp_esco

10. Add the "out" parameter to rfcomm_dlc in chg: Include/NET/Bluetooth/RFCOMM. h.

4. sched)

The android kernel also modifies the policies related to process scheduling and clock. Only five files have been modified, as shown below:

1. Add normalized_sleeper to chg: kernel/sched. C.

2. chg: kernel/sched_fair.c. Modify the kernel scheduling mode.

3. Change chg: kernel/softirq. C to CPU scheduling.

4. chg: kernel/time/tick-sched.c modified to CPU scheduling

5. chg: Include/Linux/tick. H. If config_no_hz is defined, add tick_nohz _ update _ stopped _ sched_tick ()

5. New Android drivers

Android has added many unique drivers on the basis of Linux, as shown below.

1) IPC binder is an IPC (inter-process communication) mechanism. Its processes can provide services for other processes-calling APIs through standard Linux systems. The concept of IPC binder originated from a company named be. Inc, which was adopted by palm software before Google.

2) low memory killer has a similar function in the kernel, named OOM killer (out of memory killer ). When the memory is insufficient, this policy tries to end a process.

3) ashmem anonymous shared memory. This feature enables the process to share large volumes of memory. For example, the system can use ashmem to save some icons, and multiple applications can access the shared memory to obtain these icons. Ashmem provides the kernel with a way to recycle these used shared memory blocks. If a process tries to access these recycled memory blocks, it will get an incorrect return value, so that it can re-allocate memory blocks and initialize data.

4) for debugging convenience, the RAM console and log device have added a function for Android to allow debugging information to be entered into a memory block. In addition, Android also adds an independent log module so that the user space process can read and write log messages and debug and print information.

5) debugging of Android debug bridge embedded devices is indeed troublesome. To facilitate debugging, Google has designed this debugging tool, which can be referred to as ADB and uses USB as the connection method, ADB can be seen as a set of protocols used to connect Android devices and PCs.

In addition to these main functions, Android also adds functions such as real-time clock, switch, and timed gpio. All these changes and additions are included in the following 28 files.

1. chg: Drivers/kconfig to enter the configuration file

2. Add switch and driver to chg: Drivers/makefile

3. Add binder_ipc, power, power_stat, power _ alarm, logger, ram_console, timed_gpio, and paranoid_network to the configuration in new: Drivers/Android/kconfig.

4. New: Add binder. O, power. O, alarm. O, logger. O, ram_console.o, timed_gpio to drivers/Android/makefile.

5. New: hardware clock and real-time clock management of drivers/Android/alarm. C System

6. New: Drivers/Android/binder. cipc mechanism (binder)

7. New: Drivers/Android/logger. cgoogle log API

8. New: Easy debugging of drivers/Android/ram_console.cram console and Log Device [1]

9. New: Drivers/Android/timed_gpio.cgoogle gpio timing driver

10. New: Drivers/switch/kconfig add configuration options for gpio

11. New: Drivers/switch/makefile introduce gpio driver

12. New: Drivers/switch/switch_class.c

13. New: Drivers/switch/switch_gpio.c

14. chg: Drivers/USB/gadget/kconfig add ADB configuration options

15. chg: configuration options required for ADB compilation by drivers/USB/gadget/makefile

16. New: Drivers/USB/gadget/android_adb.cadb driver

17. Add aids, Inet, and networking to new: Include/Linux/android_aid.h

18. New: Include/Linux/android_alarm.h clock function settings

19. New: Include/Linux/android_timed_gpio.hgpio struct

20. New: Include/Linux/ashmem. handroid shared memory

21. New: Include/Linux/binder. hbinder ipc api Definition

22. New: Include/Linux/logger. hlogger Definition

23. New: Include/Linux/switch. hgpio switch interface

24. Add ashmem. O to chg: mm/makefile

25. New: mm/ashmem. c Memory sharing implementation

26. Add low_memory_killer configuration options to chg: Drivers/MISC/kconfig

27. Add lowmemorykiller. C to chg: Drivers/MISC/makefile.

28. New: Drivers/MISC/lowmemorykiller. C. When the memory is too low, select and end the process

6. Power Supply Management

Power management is very important for mobile devices. It is also the most complex and difficult to develop. Google has added a new power management system, excluding the original APM and DPM. This change mainly involves the following five files:

1. New: Include/Linux/android_power.h defines the power management API

2. New: Drivers/Android/power. C power management API implementation

3. chg: Drivers/input/evdev. C. Modify the android power processing mode.

4. chg: fs/inotify_user.c. Modify the android Power Supply processing method.

5. chg: kernel/power/process. C. Modify the android power processing mode.

7. Miscellaneous

In addition to the above changes, there are also some minor changes, such as new additional debugging functions, keyboard backlight control, TCP network management, and so on. A total of 36 files are involved, as shown below.

1. New: Documentation/Vm/pagemap.txt

2. Add have_latencytop_support and arch_goldfish to chg: ARCH/ARM/kconfig.

3. Add the dump_task_regs method to chg: ARCH/ARM/kernel/process. C.

4. chg: ARCH/ARM/kernel/signal. c solves the problem that the system cannot be restarted.

5. chg: ARCH/ARM/kernel/stacktrace. c improved debugging stack tracking

6. chg: ARCH/ARM/MM/abort-ev6.S

7. Add memory device driver and goldfish tty driver to chg: Drivers/Char/kconfig.

8. chg: Drivers/Char/MEM. C. output the compilation result to/dev/kmem and/dev/mem.

9. chg: Drivers/LEDs/kconfig enable LEDs when the CPU is running, but the screen is disabled.

10, chg: Drivers/LEDs/makefile add compile ledtrig-sleep.o

11. New: Drivers/LEDs/ledtrig-sleep.c sleep (CPU is still running when the screen is off)

12. chg: Drivers/RTC/class. c bug in correcting real-time clock errors

13. Add vfat_ioctl_get_volume_id to fat_dir_ioctl () to chg: fs/fat/Dir. C ()

14. chg: fs/fat/inode. c

15. chg: fs/proc/base. C. Adjust the/proc file when the memory is insufficient.

16. chg: fs/proc/proc_misc.c fixed some errors returned by kpagecount_read and kpageflags_read.

17. chg: fs/proc/task_mmu.c simplify the error check in add_to_pagemap

18. chg: Include/ASM-arm/elf. h add elf_core_copy_task_regs () macro to call dump_task _ regs (...)

19. Add the shmem_set_file (...) function prototype to chg: Include/Linux/mm. h.

20. Add a vfat_ioctl_get_volume_id macro to chg: Include/Linux/msdos_fs.h.

21. chg: kernel/hrtimer. C. Fixed the run_hrtimer_pending error.

22. The default value of panic_timeout added to chg: init/kconfig is 0.

23. chg: kernel/panic. C. Set the default panic_timeout: from Kernel configuration to panic_timeout

24. chg: kernel/power/console. C. Fix virtual console errors

25. chg: kernel/printk. C. Fixed the printk error.

26. chg: mm/filemap. c corrected filemap_fault

27. chg: mm/shmmem. c reconstruction shmem_zero_setup

28. chg: mm/tiny-shmem.c refactoring shmem_zero_setup

29. Add siockilladdr Control for chg: Include/Linux/sockios. h

30. chg: Include/NET/tcp. h Add the tcp_v4_nuke_addr Function

31. chg: net/IPv4/makefile if config_sysfs is set, compile sysfs_net_ipv4

32. chg: net/IPv4/af_inet_c. If config_android_paranoid_network is defined, add a security check.

33. Add siockilladdr to chg: net/IPv4/devinet. C.

34. chg: net/IPv4/sysfs_net_ipv4.c control TCP Window Length

35. Add the tcp_v4_nuke_addr function to chg: net/IPv4/tcp_ipv4.c.

36. chg: net/IPv6/af_inet6.c. If config_android_paranoid_network is defined, add a security check.

These seem simple, but very important. You need to study these files when developing system-level applications and Porting Programs. For the specific modification method and implementation of each file, we need to further view the android kernel source code, which will be explained in detail later.

For ease of debugging, Android adds a function that allows debugging information to be input into a memory block. In addition, an independent Log Module is added to Android, so that processes in the user space can read and write log messages and debug and print information.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.