1, goldfish
Android emulator runs the arm926t instruction set by running virtual CPU (arm926t belongs to armv5 architecture). Goldfish, and analog input/output, such as keyboard input and LCD output. This simulator is actually developed on qemu, and the input/output is based on libSDL. Because goldfish is the virtual CPU that the simulator runs, we need to remove it when Android runs on real hardware devices. Therefore, only when we know what specific changes Google has made to goldfish can we delete them correctly. According to statistics, the changes to goldfish by Android kernel mainly involve 44 files, which are summarized as follows.
Description In this book, the changed file is marked with Chg, and the New file is marked with New.
1Chgarch/arm/Makefile add CONFIG _ ARCH _ goldfish.
2 new arch/arm/configs/ goldfish _ defconfig default configuration file
3 new arch/arm/mach- goldfish /kconfig adds kernel configuration file for goldfish CPU.
4 new arch/arm/mach- goldfish /makefile add board-goldfish.o.
5 new arch/arm/mach- goldfish /makefile.boot to start the configuration of goldfish CPU.
6 new arch/arm/mach- goldfish /audio.c audio input/output.
7 new arch/arm/mach- goldfish /board- goldfish.c interrupt request, input/output, etc.
8 new arch/arm/mach- goldfish /pdev _ bus.c device bus
9 new /arm/mach- goldfish /pm.c power management
10 new /arm/mach- goldfish /switch. c switch control
11newarch/arm/mach-goldfish /timer.c to get and set the time.
12chgarch/arm/mm/kconfig adds ARCH _ goldfish to the support list.
13chgdrivers/char/makefile add goldfish _tty.
14 new drivers/char/ goldfish _ tty.ctty driver
15chgdrivers/input/keyboard/kconfig adds a configuration file for goldfish keyboard events.
16chgdrivers/input/keyboard/makefile Add Goldfish _ Event Event.
17 newdrivers/input/keyboard/goldfish _ events.cgoldfish keyboard driver
18chgdrivers/MMC/host/kconfig Add the kernel configuration option Goldfish MMC card.
19chgdrivers/MMC/host/makefile add goldfish MMC card driver.
20 new drivers /MMC/host/ goldfish.c multimedia drivers
21chgdrivers/MTD/devices/kconfig adds kernel configuration options for goldfish's NAND flash memory devices.
22 chgdrivers/MTD/devices/makefile Add Goldfish _nand.
23 new driver /MTD/ equipment/goldfish _ nand.cn and flash drive
24 new drivers/MTD/devices/ goldfish _ NAND _ reg.hnandflash driver
25Chgdrivers/power/Kconfig added the kernel configuration option of goldfish's battery drive.
26Chgdrivers/power/Makefile add goldfish battery.
27 new drivers/power/ goldfish _ battery.c energy and battery state drive
28Chgdrivers/rtc/Kconfig adds kernel configuration options for the rtc (clock) driver of Goldfish.
29Chgdrivers/rtc/Makefile add RTC- goldfish.
30 new drivers/RTC/RTC- goldfish.c real-time clock driver
31chgdrivers/video/kconfig Add the goldfish's framebuffer.
32Chgdrivers/video/Makefile add goldfish framebuffer.
33 newdrivers/video/goldfishfb.cframebuffer driver
34 new include/ASM-arm/arch- goldfish /dma.h
35 new include/ASM-arm/arch- goldfish /entry-macro. S
36 new include/ASM-arm/arch- goldfish /hardware.h
37 new include/ASM-arm/arch- goldfish /io.h
38 new include/ASM-arm/arch- goldfish/irqs.h.
39 new include/ASM-arm/arch- goldfish /memory.h
40 new include/ASM-arm/arch- goldfish /system.h
41newinclude/ASM-arm/arch-goldfish /timer.h
42 new include/ASM-arm/arch- goldfish/Timex.h.
43 new include/ASM-arm/arch- goldfish /uncompress.h
44 new include/ASM-arm/arch- goldfish/vmalloc.h.
2、YAFFS2
Unlike a PC (where files are stored on a hard disk), mobile phones use flash memory as a storage medium. HTC's G 1 uses the popular NANDFLASH at present, and there are many kinds (such as SLC, MLC, etc.). ), and the storage density is getting higher and higher (NANDFLASH with the size of tens of GB has appeared), and the price is getting lower and lower.
YAFFS2 is a special file system used in FLASH. YAFFS2 is the abbreviation of "Another Flash file system, 2nd edition". YAFFS2 provides an efficient interface for Linux kernel to access NANDFLASH. However, the standard 2.6.25 kernel does not contain support for NANDFLASH, so Google added support for NANDFLASH. According to statistics, in order to support YAFFS2, Google * * * changed and added the following 35 files:
1Chgfs/Kconfig add YAFFS configuration.
2Chg fs/Makefile add YAFFS
The following is the new YAFFS2:
1 newfs/yaffs 2/kconfig 18 newfs/yaffs 2/yaffs _ MTD dif 2 . h
2 new fs/yaffs 2/makefile 19 new fs/yaffs 2/yaffs _ NAND . c
3 newfs/yaffs 2/devextras . h20 newfs/yaffs 2/yaffs _ NAND . h
4 new fs/yaffs 2/module config . h 2 1 new fs/yaffs 2/yaffs _ nande mul2k . h
5 new fs/yaffs 2/yaffs _ check ptrw . c22 new fs/yaffs 2/yaffs _ packed 1 . c
6 new fs/yaffs 2/yaffs _ check prtw . h23 new fs/yaffs 2/yaffs _ packed 1 . h
7 new fs/yaffs 2/yaffs _ ECC . c 24 new fs/yaffs 2/yaffs _ packed 2 . c
8 new fs/yaffs 2/yaffs _ ECC . h25 new fs/yaffs 2/yaffs _ packed 2 . h
9 new fs/yaffs 2/yaffs _ fs . c 26 new fs/yaffs 2/yaffs _ qsort . c
10 newfs/yaffs 2/yaffs _ get block info . h27 newfs/yaffs 2/yaffs _ qsort . h
1 1 newfs/yaffs 2/yaffs _ guts . c 28 newfs/yaffs 2/yaffs _ compat . c
12 new fs/yaffs 2/yaffs _ guts . h29 new fs/yaffs 2/yaffs _ compat . h
13 newfs/yaffs 2/yaffs _ mtdif . c 30 newfs/yaffs 2/yaffs _ validity . c
14 newfs/yaffs 2/yaffs _ mtdif . h 3 1 newfs/yaffs 2/yaffs _ validity . h
15 newfs/yaffs 2/yaffs _ mtddif 1 . c32 newfs/yaffs 2/yaffs interface . h
16 newfs/yaffs 2/yaffs _ mtddif 1 . h33 newfs/yaffs 2/yportenv . h
17 new fs/yaffs 2/yaffs _ MTD dif 2 . c
3. Bluetooth
In the Bluetooth communication protocol stack, Google modified 10 files. These changes have fixed some obvious bugs related to Bluetooth headsets and some functions related to Bluetooth debugging and access control, as shown in the following figure.
1chgdriver/bluetooth/kconfig add HCI UART debugging.
2Chgdrivers/bluetooth/hci_II.c If HCI UART Debug is defined in the kernel configuration, add BT_DBG () macro.
3Chgnet/bluetooth/Kconfig adds configuration options L2CAP, HCI_CORE, HCI_SOCK, and general interface and voice.
4chgnet/Bluetooth/AF _ Bluetooth.c If config _ Android _ paranoid _ network is defined, the security check of Bluetooth function is added.
5Chgnet/bluetooth/hci_event.c fixed the encryption Bug of Bluetooth and added voice support.
6 chgnet/bluetooth/rfcomm/core.c to fix the Bug.
7 chg net/ bluetooth /rfcomm/sock.c to fix the bug.
8 chg net/ bluetooth /sco.c disables the sco link.
9 chg include/net/ Bluetooth /HCI _ core.h Disable LMP_ESCO.
10chginclude/net/bluetooth/rfcomm.h add the "out" parameter in rfcomm_dlc.
4, the Scheduler (scheduler)
The Android kernel also modified the policies related to process scheduling and clock. Only five files were changed, as follows:
/kloc-0 1Chgkernel/sched.c add NORMALIZED_SLEEPER.
2Chgkernel/sched_fair.c modifies the kernel scheduling mode.
3 chgkkernel/softirq.c changed to CPU scheduling.
4Chgkernel/time/tick-sched.c changed to CPU scheduling.
5Chginclude/linux/tick.h If CONFIG_NO_HZ is defined, add tick _ no Hz _ update _ stopped _ sched _ tick ().
5. New drivers for 5.Android
Android has added many unique drivers on the basis of Linux, as shown below.
1)IPC binds an IPC (interprocess communication) mechanism. Its process can provide services for other processes and call API through standard Linux system. The concept of IPC Binder originated from a company called Be. Inc, adopted by Palm software before Google.
2) Low-memory black boy actually has a similar function in the kernel, called oom killer. When there is not enough memory, this strategy will try to end a process.
3)Ashmem enjoys the memory anonymously. This function enables the process * * * to enjoy large blocks of memory. For example, the system can use Ashmem to save some icons, and multiple applications can access this shared memory to get these icons. Ashmem provides a way for the kernel to recycle these used memory blocks. If a process tries to access these reclaimed memory blocks, it will get an incorrect return value so that it can allocate memory blocks and initialize data again.
4)RAM console and log device In order to facilitate debugging, Android has added a function, which can input debugging information into a memory block. In addition, an independent log module has been added to Android, which allows processes in user space to read and write log messages and debug print information.
5) Debugging 5) It's really troublesome to debug the embedded devices of the 5)Android bridge. In order to facilitate debugging, Google designed this debugging tool, which can be called ADB for short, and uses USB as the connection mode. ADB can be regarded as a set of protocols to connect Android devices and PCs.
In addition to these main functions, Android also adds real-time clock, switch, timing GPIO and other functions. All these changes and additions are contained in the following 28 files.
1Chgdrivers/Kconfig to enter the configuration file.
2Chgdrivers/Makefile add switches, drivers, etc.
3Newdrivers/android/Kconfig add BINDER_IPC, POWER, POWER_STAT, POWER_ ALARM, LOGGER, RAM_CONSOLE, TIMED_GPIO and PARANOID_NETWORK to the configuration.
4Newdrivers/android/Makefile add binder.o, power.o, alarm.o, logger.o, ram_console.o, timed_gpio.
Hardware clock and real-time clock management of newdrivers/Android/alarm.c system
6 new driver /Android/Binder.cipc mechanism (Binder)
7 newdrivers/Android/logger.c Google's log API.
8 newdrivers/Android/ram _ console.cram console and log device are convenient for debugging [1]
9 GPIO timing driver of newdrivers/Android/timed _ gpio.c Google
10 newdrivers/switch/kconfig adds configuration options for GPIO.
11newdrivers/switch/makefile introduces the GPIO driver.
12 new driver/switch/switch _class.c
13 new driver/switch/switch _gpio.c
14chgdrivers/USB/gadget/kconfig add ADB configuration options.
15 chgdrivers/USB/gadget/makefile configuration options required to compile ADB.
16 newdrivers/USB/gadget/Android _ adb.cadb driver
17newinclude/Linux/Android _ aid.h Add assistive tools, INET and network.
18 newinclude/Linux/Android _ alarm.h clock function setting
19 newinclude/Linux/Android _ timed _ gpio.h gpio structure
20 newinclude/Linux/ashmem.handandroid * * * Enjoy the memory.
21newinclude/Linux/binder.hbinder IPC API definition
22 new include/Linux/logger.h recorder definition
23 newinclude/Linux/switch.h gpioswitch interface
24Chgmm/Makefile add ashmem.o
25Newmm/ashmem.c memory * * * Enjoy implementation.
26Chgdrivers/misc/Kconfig add LOW_MEMORY_KILLER configuration option.
27Chgdrivers/misc/Makefile add lowmemorykiller.c
28 when newdrivers/misc/lowmemorykiller.c is out of memory, select and end the process.
6. Power management
Power management is very important for mobile devices, and it is also the most complex and difficult function to develop. Google added a new power management system, excluding the original apm and dpm. This change mainly involves the following five documents:
1newinclude/Linux/Android _ power.h defines the power management API.
2 implement the new driver /Android/power.c power management API.
3Chgdrivers/input/evdev.c modify the power processing mode of Android.
4Chgfs/inotify_user.c modify the power processing mode of Android.
5 chgkkernel/power/process.c modify the power processing mode of Android.
7, miscellaneous
In addition to the above changes, there are some minor changes, such as adding debugging function, keyboard backlight control, TCP network management and so on. * * * involves 36 files, please refer to Resources for details.
For debugging convenience, Android has added a function, which can input debugging information into the memory block. In addition, Android has added an independent log module, which allows processes in user space to read and write log messages, debug and print information.