https://elinux.org/api.php?action=feedcontributions&user=Palmer+Eldritch&feedformat=atomeLinux.org - User contributions [en]2024-03-28T16:36:07ZUser contributionsMediaWiki 1.31.0https://elinux.org/index.php?title=Android_logger&diff=304046Android logger2013-11-19T22:54:32Z<p>Palmer Eldritch: </p>
<hr />
<div>Here is some information on the Android logger:<br />
<br />
== Overview ==<br />
General system-wide logging is supported by a kernel device driver call 'logger'.<br />
The code for the driver is in 'drivers/staging/android/logger.c' in recent android versions but in 'drivers/misc/logger.c' in older versions and in 'drivers/android/logger.c' in old ones<br />
<br />
The code supports 4 logging buffers, named "main", "events", "radio", and "system" for different<br />
types of events.<br />
<br />
== Driver Features ==<br />
Log reading and writing is done via normal Linux file reads and writes.<br />
<br />
The write path is optimized, so that an open(), write(), close() sequence can occur<br />
very quickly, to avoid logging having too much overhead in the system.<br />
<br />
=== Reading ===<br />
From user-space, a normal 'read' operation is used to read an entry from<br />
the log. Each read() returns one log entry, or blocks waiting for the next entry.<br />
The device can be opened in non-blocking mode.<br />
<br />
At least LOGGER_ENTRY_MAX_LEN (4096) should be used as the amount of data to read from the log on a read<br />
request.<br />
<br />
=== Writing ===<br />
The system performs writes to the log. The driver saves the pid, tgid and timestamp for each log entry.<br />
It appears that the level, tag and message are provided by user-space.<br />
<br />
=== ioctls ===<br />
<br />
The following ioctl's are supported, which pretty much do what you would expect:<br />
* LOGGER_GET_LOG_BUF_SIZE - returns the size of the entire log buffer<br />
* LOGGER_GET_LOG_LEN - returns the amount of data in the log<br />
* LOGGER_GET_NEXT_ENTRY_LEN - returns size of next log entry<br />
* LOGGER_FLUSH_LOG - clears the log of data<br />
<br />
== Device Nodes ==<br />
The driver is activated when a user-space program opens a device node with the appropriate<br />
major and minor number.<br />
<br />
These nodes are located in /dev/log, as shown below:<br />
# ls -l /dev/log<br />
crw-rw--w- 1 0 1007 10, 50 Nov 5 02:00 events<br />
crw-rw--w- 1 0 1007 10, 51 Nov 5 02:00 main<br />
crw-rw--w- 1 0 1007 10, 49 Nov 5 02:00 radio<br />
<br />
/dev/log/system was added in Feb, 2010<br />
<br />
== Android Logging System ==<br />
See [[Android Logging System]] for information about the complete android logging system, including tools which access this driver.<br />
<br />
[[Category:Android]]</div>Palmer Eldritchhttps://elinux.org/index.php?title=Talk:Android_Power_Management&diff=299504Talk:Android Power Management2013-11-10T22:32:12Z<p>Palmer Eldritch: power.c is outdated</p>
<hr />
<div>==power.c==<br />
<br />
No such file in recent kernel versions - see https://groups.google.com/forum/#!topic/android-kernel/FQ39jKMtVp0<br />
<br />
The file is still at https://www.codeaurora.org/cgit/quic/la/kernel/common/tree/drivers/android/power.c?h=android-2.6.25</div>Palmer Eldritchhttps://elinux.org/index.php?title=Talk:Android_Kernel_Features&diff=299246Talk:Android Kernel Features2013-11-09T14:19:02Z<p>Palmer Eldritch: broken link</p>
<hr />
<div>==Broken link==<br />
<br />
www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Porting-Android-to-a-new-device/ is broken nor could I locate it - as it seems interesting could you fix ?</div>Palmer Eldritchhttps://elinux.org/index.php?title=Template_talk:Update&diff=299204Template talk:Update2013-11-08T20:25:43Z<p>Palmer Eldritch: TODO</p>
<hr />
<div>==Needs to include current date==<br />
<br />
Like (November 2013). Have not found a way to do it. Any offer accepted</div>Palmer Eldritchhttps://elinux.org/index.php?title=Template:Update&diff=299120Template:Update2013-11-08T19:44:02Z<p>Palmer Eldritch: Created a template for pages that need update</p>
<hr />
<div><div style="margin:0; margin-top:10px; margin-right:10px; border:1px solid #dfdfdf; padding:0 1em 1em 1em; background-color:#ffffcc; align:right; width:50%;"><br />
<big>'''Needs Update'''</big><br /><br />
This page has not been updated in a long time - needs attention from some expert on the subject<br />
</div></div>Palmer Eldritchhttps://elinux.org/index.php?title=Talk:Android_Kernel_Versions&diff=299054Talk:Android Kernel Versions2013-11-08T17:05:52Z<p>Palmer Eldritch: /* Update needed */</p>
<hr />
<div>== Update needed ==<br />
<br />
Hey shouldn't be this updated ? I would happily do this if I knew how - I asked at SO but no reply yet : http://stackoverflow.com/questions/19413267/android-kernel-repositories-confusion<br />
<br />
; Android git kernel trees<br />
<br />
* ''As of July 2010'' !?!<br />
* http://android.git.kernel.org/ --> broken since for ever. Should be https://android.googlesource.com/ ? What is https://android.googlesource.com/Kernel-Projects/ ?<br />
* Note that the experimental tree is now a bunch of branches in kernel/common (?) - and where is kernel/linux-2.6.git ? Would be worthwhile to include those deletions/moves in the article. Kernel trees (am I right ?) :<br />
:kernel/common Common Android Kernel Tree<br />
:kernel/exynos <br />
:kernel/goldfish <br />
:kernel/lk <br />
:kernel/msm Kernel tree for Qualcomm chipsets<br />
:kernel/omap <br />
:kernel/samsung Kernel tree for Samsung systems on Android.<br />
:kernel/tegra<br />
<br />
; Kernel versions known to run Android<br />
<br />
That's horribly out of date - and would be worthwhile to add links<br />
<br />
I came here for info so can't help much - some Linux boy/girl ?<br />
<br />
== Suggested edit for Android git kernel trees ==<br />
<br />
:As of July 2010, the [http://android.git.kernel.org/ android repository on kernel.org] (the link is dead and left for reference) had the following kernel trees:<br />
:<br />
:; kernel/common.git : This is the kernel tree that matches what is put into official Android products by Google or its partners<br />
:; kernel/experimental.git : some experimental stuff<br />
:; kernel/linux-2.6.git : mirror of Linus' kernel tree. This is a reference for the kernel tree used in Android<br />
:; kernel/lk.git : not a kernel tree, but a bootloader<br />
:; kernel/msm.git : kernel for MSM (Qualcomm chip used in many HTC products)<br />
:; kernel/omap.git : mirror of kernel tree maintained by texas instruments., supporting OMAP chips. usually based on kernel.org latest version, android products w OMAP chip can use this kernel port.<br />
:; kernel/tegra.git : nvidia kernel tree<br />
:<br />
:As of now (November 2013) the [https://android.googlesource.com/ android git repositories] seem to have 7 trees :<br />
:<br />
:; kernel/common.git<br />
:; kernel/exynos --> ???<br />
:; kernel/goldfish --> ???<br />
:; kernel/lk.git : not a kernel tree, but a bootloader (citation ??)<br />
:; kernel/msm.git : kernel for MSM (Qualcomm chip used in many HTC products)<br />
:; kernel/omap.git : mirror of kernel tree maintained by texas instruments., supporting OMAP chips. usually based on kernel.org latest version, android products w OMAP chip can use this kernel port.<br />
:; kernel/tegra.git : nvidia kernel tree</div>Palmer Eldritchhttps://elinux.org/index.php?title=Talk:Android_Kernel_Versions&diff=299048Talk:Android Kernel Versions2013-11-08T16:47:59Z<p>Palmer Eldritch: </p>
<hr />
<div>== Update needed ==<br />
<br />
Hey shouldn't be this updated ? I would happily do this if I knew how - I asked at SO but no reply yet : http://stackoverflow.com/questions/19413267/android-kernel-repositories-confusion<br />
<br />
; Android git kernel trees<br />
<br />
* ''As of July 2010'' !?!<br />
* http://android.git.kernel.org/ --> broken since for ever. Should be https://android.googlesource.com/ ? What is https://android.googlesource.com/Kernel-Projects/ ?<br />
* Note that the experimental tree is now a branch in kernel/common (?) - and where is kernel/linux-2.6.git ?) Would be worthwhile to include those deletions/moves in the article. Kernel trees (am I right ?) :<br />
:kernel/common Common Android Kernel Tree<br />
:kernel/exynos <br />
:kernel/goldfish <br />
:kernel/lk <br />
:kernel/msm Kernel tree for Qualcomm chipsets<br />
:kernel/omap <br />
:kernel/samsung Kernel tree for Samsung systems on Android.<br />
:kernel/tegra<br />
<br />
; Kernel versions known to run Android<br />
<br />
That's horribly out of date - and would be worthwhile to add links<br />
<br />
I came here for info so can't help much - some Linux boy/girl ?<br />
<br />
== Suggested edit for Android git kernel trees ==<br />
<br />
:As of July 2010, the [http://android.git.kernel.org/ android repository on kernel.org] (the link is dead and left for reference) had the following kernel trees:<br />
:<br />
:; kernel/common.git : This is the kernel tree that matches what is put into official Android products by Google or its partners<br />
:; kernel/experimental.git : some experimental stuff<br />
:; kernel/linux-2.6.git : mirror of Linus' kernel tree. This is a reference for the kernel tree used in Android<br />
:; kernel/lk.git : not a kernel tree, but a bootloader<br />
:; kernel/msm.git : kernel for MSM (Qualcomm chip used in many HTC products)<br />
:; kernel/omap.git : mirror of kernel tree maintained by texas instruments., supporting OMAP chips. usually based on kernel.org latest version, android products w OMAP chip can use this kernel port.<br />
:; kernel/tegra.git : nvidia kernel tree<br />
:<br />
:As of now (November 2013) the [https://android.googlesource.com/ android git repositories] seem to have 7 trees :<br />
:<br />
:; kernel/common.git<br />
:; kernel/exynos --> ???<br />
:; kernel/goldfish --> ???<br />
:; kernel/lk.git : not a kernel tree, but a bootloader (citation ??)<br />
:; kernel/msm.git : kernel for MSM (Qualcomm chip used in many HTC products)<br />
:; kernel/omap.git : mirror of kernel tree maintained by texas instruments., supporting OMAP chips. usually based on kernel.org latest version, android products w OMAP chip can use this kernel port.<br />
:; kernel/tegra.git : nvidia kernel tree</div>Palmer Eldritchhttps://elinux.org/index.php?title=Talk:Android_Kernel_Versions&diff=299042Talk:Android Kernel Versions2013-11-08T16:47:32Z<p>Palmer Eldritch: Added discussion for update</p>
<hr />
<div>== Update needed ==<br />
<br />
Hey shouldn't be this updated ? I would happily do this if I knew how - I asked at SO but no reply yet : http://stackoverflow.com/questions/19413267/android-kernel-repositories-confusion<br />
<br />
; Android git kernel trees<br />
<br />
* ''As of July 2010'' !?!<br />
* http://android.git.kernel.org/ --> broken since for ever. Should be https://android.googlesource.com/ ? What is https://android.googlesource.com/Kernel-Projects/ ?<br />
* Note that the experimental tree is now a branch in kernel/common (?) - and where is kernel/linux-2.6.git ?) Would be worthwhile to include those deletions/moves in the article. Kernel trees (am I right ?) :<br />
:kernel/common Common Android Kernel Tree<br />
:kernel/exynos <br />
:kernel/goldfish <br />
:kernel/lk <br />
:kernel/msm Kernel tree for Qualcomm chipsets<br />
:kernel/omap <br />
:kernel/samsung Kernel tree for Samsung systems on Android.<br />
:kernel/tegra<br />
<br />
; Kernel versions known to run Android<br />
<br />
That's horribly out of date - and would be worthwhile to add links<br />
<br />
I came here for info so can't help much - some Linux boy/girl ?<br />
<br />
== Suggested edit for Android git kernel trees ==<br />
<br />
:As of July 2010, the [http://android.git.kernel.org/ android repository on kernel.org] (the link is dead and left for reference) had the following kernel trees:<br />
:<br />
:; kernel/common.git : This is the kernel tree that matches what is put into official Android products by Google or its partners<br />
:; kernel/experimental.git : some experimental stuff<br />
:; kernel/linux-2.6.git : mirror of Linus' kernel tree. This is a reference for the kernel tree used in Android<br />
:; kernel/lk.git : not a kernel tree, but a bootloader<br />
:; kernel/msm.git : kernel for MSM (Qualcomm chip used in many HTC products)<br />
:; kernel/omap.git : mirror of kernel tree maintained by texas instruments., supporting OMAP chips. usually based on kernel.org latest version, android products w OMAP chip can use this kernel port.<br />
:; kernel/tegra.git : nvidia kernel tree<br />
:<br />
:As of now (November 2013) the [https://android.googlesource.com/ android git repositories] seem to have 7 trees :<br />
:<br />
:; kernel/common.git<br />
:; kernel/exynos --> ???<br />
:; kernel/goldfish --> ???<br />
:; kernel/lk.git : not a kernel tree, but a bootloader (citation ??)<br />
:; kernel/msm.git : kernel for MSM (Qualcomm chip used in many HTC products)<br />
:; kernel/omap.git : mirror of kernel tree maintained by texas instruments., supporting OMAP chips. usually based on kernel.org latest version, android products w OMAP chip can use this kernel port.<br />
:; kernel/tegra.git : nvidia kernel tree<br />
:<br />
:[[Category:Android]]</div>Palmer Eldritchhttps://elinux.org/index.php?title=Android_Porting&diff=299036Android Porting2013-11-08T16:15:14Z<p>Palmer Eldritch: /* Android Hardware Abstraction Layer */</p>
<hr />
<div>This page describes various effort to port Android to new boards and new processors<br />
<br />
<br />
== Porting Overview ==<br />
This overview of porting steps was seen on the android-porting list:<br><br />
See http://www.mail-archive.com/android-porting@googlegroups.com/msg06721.html<br />
<br />
This glosses over all the kernel work for a new board, and the android-specific<br />
kernel patches, but has some good discussion about the flash partitioning and file<br />
system bringup process.<br />
<br />
<pre><br />
If the linux kernel is up and running with all drivers in.<br />
(particularly touchscreen and display) it shouldn't be too bad.<br />
<br />
IHMO, the easiest way to get you running is to aggregate the initial<br />
ramfs built into the kernel with the Android build, the root Android<br />
root filesystem (system), and the user data section (mounted as /data<br />
I believe) into one root filesystem.<br />
<br />
You can then take that root filesystem as one tarball.<br />
<br />
Modify the NAND partitioning of the kernel to set aside space for the<br />
whole Android rootfs, and of course rebuild the kernel. (Be sure yaffs<br />
support is in the kernel) Also no need for a ramfs at this point, just<br />
have the kernel look to mtd2 for it's root filesystem, which will be<br />
jffs2<br />
<br />
Create yourself a busybox root filesystem too. Make that into a jffs2<br />
image.<br />
<br />
So your partitioning would look something similar to this (you'll have<br />
to decide on the sizes of course):<br />
mtd0: bootloader<br />
mtd1: kernel<br />
mtd2: rootfs (jffs2)<br />
mtd3: Android rootfs.<br />
<br />
Erase everything on the NAND.<br />
Burn the normal Chumby bootloader to mtd0.<br />
Burn the the new kernel into mtd1.<br />
Burn the jffs2 rootfs image to mtd2.<br />
<br />
Boot the device. Hopefully you get yourself to a prompt.<br />
<br />
Once you have that prompt mount mtd3 to /mnt/android as a yaffs2<br />
partition.<br />
Untar your Android rootfs into /mnt/android.<br />
Chown and chgrp everything under /mnt/android to "root"<br />
chroot to that mount point "chroot /mnt/android /init"<br />
<br />
At this point you should see Android trying to run.<br />
<br />
<br />
I know that's a bit to chomp on, but it's more of an outline of what<br />
you will need to do. Of course it's assuming you have the ability to<br />
erase the whole nand and put down images amongst other assumptions,<br />
but it should help get your mind around a little bit of the<br />
requirements to get Android running on your device.<br />
<br />
Regarding your bootloader question, I'd just stick with the current<br />
one. You'll only need to modify that if/when you go into having<br />
everything compatible with the recovery system. Which is a completely<br />
different discussion.<br />
</pre><br />
<br />
== Porting Tutorials ==<br />
* [http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Porting-Android-to-a-new-device/ Porting Android to a new Device] - excellent and thorough paper on porting Android to the Nokia N810.<br />
** Has a detailed list of kernel changes and annotated diffs.<br />
* http://wiki.kldp.org/wiki.php/AndroidPortingOnRealTarget<br />
* [[Android on OMAP]] - excellent tutorial covering lots of different issues for porting Android to platforms based on the TI OMAP (ARM) processor<br />
* Some cursory notes on a port to a PXA board are at: http://letsgoustc.spaces.live.com/blog/cns!89AD27DFB5E249BA!320.entry<br />
* Adding a new device or changing the configuration of an existing device [[Android Device]]<br />
<br />
== Porting Issues ==<br />
* Matt Porter (Mentor Graphics) gave a presentation on difficulties encountered while they were porting Android to MIPS and PPC processors at [http://www.embeddedlinuxconference.com/elc_europe09/index.html ELC Europe 2009]. His talk was called "Mythbusters: Android" and has lots of good information.<br />
** See [[Media:Mythbusters_Android.pdf|Mythbusters_Android.pdf]]<br />
<br />
* [http://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=docs/porting-guide.html;hb=HEAD Dalvik porting guide]<br />
<br />
* Matthias Brugger presented his personal "war story" on porting Android at ELC Europe 2012. See his [http://www.slideshare.net/MatthiasBrugger/porting-android-40toacustomboard slides] on slideshare.<br />
<br />
=== Android Hardware Abstraction Layer ===<br />
Android talks to standard devices through its hardware abstraction layer, which overlays<br />
the kernel interfaces to devices (e.g. devices nodes, Linux system calls, etc.). To add support<br />
for your own hardware, or, in particular, to add support to Android for some new type of hardware,<br />
you need to understand this abstraction layer.<br />
<br />
Karim Yaghmour has a good blog entry describing the Android HAL layer: http://www.opersys.com/blog/extending-android-hal<br />
<br />
== Porting to New Processors ==<br />
* Mentor Graphics has ported Android to MIPS and PPC<br />
* Power.Org supported the work to port Android to PPC<br />
** Nina Wilner talked about this work, and gave a demo at ELC Europe 2009<br />
** see [[Media:Android_On_Power.pdf|Android_On_Power.pdf]]<br />
<br />
== Virtualization environments ==<br />
There are available some virtualization environments, which allow Android applications (or the whole<br />
system) to run on other Linux-based systems, such as MeeGo or Ubuntu.<br />
<br />
Here is some information about different systems known to exist:<br />
* OpenMobile ACL (Application Compatibility Layer)<br />
** LinuxDevices article: http://www.linuxfordevices.com/c/a/News/OpenMobile-ACL-for-MeeGo/?kc=LNXDEVNL092811<br />
** OpenMobile product page:http://openmobile.co/products.php<br />
* Myriad Alien Dalvik<br />
** LinuxDevices article: http://www.linuxfordevices.com/c/a/News/Myriad-Group-Myriad-Alien-Dalvik/<br />
** Myried Group page: http://www.myriadgroup.com/Device-Manufacturers/Android-solutions/~/media/D42B513FB5114FF2B4CA13A2D8CE313E.ashx<br />
* [FIXTHIS - should add tetsuyuki presentation about running Android on Ubuntu here]<br />
<br />
[[Category:Android]]</div>Palmer Eldritchhttps://elinux.org/index.php?title=Android_Kernel_Features&diff=299030Android Kernel Features2013-11-08T15:07:44Z<p>Palmer Eldritch: english</p>
<hr />
<div>== Kernel features unique to Android ==<br />
In the course of development, Google developers made some changes to the Linux kernel. The amount<br />
of changes is not extremely large, and is on the order of changes that are customarily made to<br />
the Linux kernel by embedded developers (approximately 250 patches, with about 3 meg. of<br />
differences in 25,000 lines). The changes include a variety of large and small additions, ranging<br />
from the wholesale addition of a flash filesystem (YAFFS2), to very small patches to augment Linux<br />
security (paranoid networking patches).<br />
<br />
Various efforts have been made over the past few years to submit these to changes to mainline<br />
(mostly by Google engineers, but also by others), with not much success so far.<br />
<br />
=== Resources ===<br />
A very good overview of the changes is available in a talk by John Stultz at ELC 2011.<br />
(The talk has a somewhat misleading name.)<br />
* [[Media:Elc2011_stultz.pdf|Android OS for Servers]]- John Stultz, ELC 2011<br />
** This talks breaks down the differences between an Android Linux kernel and a stock Linux kernel, and provides information about the features of each.<br />
* http://www.lindusembedded.com/blog/2010/12/07/android-linux-kernel-additions/<br />
** Lindus Embedded (Alex Gonzalez) has a listing of kernel changes based on an Android kernel for the Freescale MX51 SOC, with some good information about each change.<br />
* http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Porting-Android-to-a-new-device/<br />
** Peter McDermott's excellent description of his work to port Android to the Nokia N810.<br />
** Also, see his annotated list of modified and added kernel files, at: http://www.linuxfordevices.com/files/misc/porting-android-to-a-new-device-p3.html<br />
* http://www.slideshare.net/jollen/android-os-porting-introduction<br />
** Jollen Chen's excellent presentation on system-level Android features, including an overview of kernel features unique to Android: ''Note: Parts of the presentation are in Chinese''<br />
<br />
<br />
<br />
=== Temporary including in mainline 'staging' ===<br />
Some changes were temporarily added at the "staging" driver area in the stock kernel, but were removed due to lack of support. See [http://www.kroah.com/log/linux/staging-status-12-2009.html Greg KH blog post on -staging for 2.6.33], where he announces the '''removal''' of various Android drivers from -staging.<br />
<br />
=== Android mainlining project ===<br />
Several groups and individuals are working to get kernel changes from Android mainlined into the Linux kernel.<br />
<br />
Please see [[Android Mainlining Project]] for more information.<br />
<br />
== List of kernel features unique to Android ==<br />
Here is a list of changes/addons that the Android Project made to the linux kernel.<br />
As of September, 2011, these kernel changes are not part of the standard kernel and are only available in the Android kernel trees in the Android Open Source project.<br />
<br />
This list does not include board- or platform-specific support or drivers (commonly called "board support").<br />
<br />
=== Binder ===<br />
Binder is an Android-specific interprocess communication mechanism, and remote method invocation system.<br />
<br />
See [[Android Binder]]<br />
<br />
=== ashmem ===<br />
* ashmem - Android shared memory<br />
** implementation is in <tt>mm/ashmem.c</tt><br />
<br />
According to the Kconfig help "The ashmem subsystem is a new shared memory allocator,<br />
similar to POSIX SHM but with different behavior and sporting a simpler file-based API."<br />
<br />
Apparently it better-supports low memory devices, because it can discard<br />
shared memory units under memory pressure.<br />
<br />
To use this, programs open /dev/ashmem, use mmap() on it, and can perform one<br />
or more of the following ioctls:<br />
<br />
* ASHMEM_SET_NAME<br />
* ASHMEM_GET_NAME<br />
* ASHMEM_SET_SIZE<br />
* ASHMEM_GET_SIZE<br />
* ASHMEM_SET_PROT_MASK<br />
* ASHMEM_GET_PROT_MASK<br />
* ASHMEM_PIN<br />
* ASHMEM_UNPIN<br />
* ASHMEM_GET_PIN_STATUS<br />
* ASHMEM_PURGE_ALL_CACHES<br />
<br />
From a thread on android-platform [http://groups.google.com/group/android-platform/browse_thread/thread/2fa6ba5ef9f81d22/0b91a39d108d02fc source]<br />
<br />
You can create a shared memory segment using:<br />
<pre><br />
fd = ashmem_create_region("my_shm_region", size); <br />
if(fd < 0) <br />
return -1; <br />
data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); <br />
if(data == MAP_FAILED) <br />
goto out; <br />
</pre><br />
<br />
In the second process, instead of opening the region using the same name, for <br />
security reasons the file descriptor is passed to the other process via binder IPC.<br />
<br />
The libcutils interface for ashmem consists of the following calls: (found in system/core/include/cutils/ashmem.h)<br />
<br />
* int ashmem_create_region(const char *name, size_t size);<br />
* int ashmem_set_prot_region(int fd, int prot);<br />
* int ashmem_pin_region(int fd, size_t offset, size_t len);<br />
* int ashmem_unpin_region(int fd, size_t offset, size_t len);<br />
* int ashmem_get_size_region(int fd);<br />
<br />
=== pmem ===<br />
* PMEM - Process memory allocator<br />
** implementation at: <tt>drivers/misc/pmem.c</tt> with include file at: <tt>include/linux/android_pmem.h</tt><br />
** Brian Swetland says:<br />
<pre><br />
The pmem driver is used to manage large (1-16+MB) physically contiguous<br />
regions of memory shared between userspace and kernel drivers (dsp, gpu,<br />
etc). It was written specifically to deal with hardware limitations of<br />
the MSM7201A, but could be used for other chipsets as well. For now,<br />
you're safe to turn it off on x86.<br />
</pre><br />
<br />
David Sparks wrote the following:<br />
[http://groups.google.com/group/android-framework/msg/06bb9d8c294ce6d7 source]<br />
<pre><br />
2. ashmem and pmem are very similar. Both are used for sharing memory <br />
between processes. ashmem uses virtual memory, whereas pmem uses <br />
physically contiguous memory. One big difference is that with ashmem, <br />
you have a ref-counted object that can be shared equally between <br />
processes. For example, if two processes are sharing an ashmem memory <br />
buffer, the buffer reference goes away when both process have removed <br />
all their references by closing all their file descriptors. pmem <br />
doesn't work that way because it needs to maintain a physical to <br />
virtual mapping. This requires the process that allocates a pmem heap <br />
to hold the file descriptor until all the other references are closed. <br />
<br />
3. You have the right idea for using shared memory. The choice between <br />
ashmem and pmem depends on whether you need physically contiguous <br />
buffers. In the case of the G1, we use the hardware 2D engine to do <br />
scaling, rotation, and color conversion, so we use pmem heaps. The <br />
emulator doesn't have a pmem driver and doesn't really need one, so we <br />
use ashmem in the emulator. If you use ashmem on the G1, you lose the <br />
hardware 2D engine capability, so SurfaceFlinger falls back to its <br />
software renderer which does not do color conversion, which is why you <br />
see the monochrome image. <br />
</pre><br />
<br />
=== logger ===<br />
* logger - system logging facility<br />
** This is the kernel support for the 'logcat' command<br />
** The kernel driver for the serial devices for logging are in the source code <tt>drivers/misc/logger.c</tt><br />
** See [[Android logger]] for more information about the kernel code<br />
** See [[Android Logging System]] for an overview of the system it supports<br />
<br />
=== wakelocks ===<br />
* wakelock - used for power management files <tt>kernel/power/wakelock.c</tt><br />
** Holds machine awake on a per-event basis until wakelock is released<br />
** See [[Android Power Management]] for detailed information<br />
<br />
=== oom handling ===<br />
* oom handling modifications<br />
** lowmem notifications<br />
** implementation at: <tt>drivers/misc/lowmemorykiller.c</tt><br />
** also at: <tt>security/lowmem.c</tt><br />
<br />
Informally known as the Viking Killer, the OOM handler simply kills processes as available memory becomes low. The kernel module follows rules for this that are supplied from user space in two ways:<br />
<br />
1. init writes information about memory levels and associated classes:<br />
<br />
* The write value must be consistent with the above properties.<br />
* Note that the driver only supports 6 slots, so we have combined some of the classes into the same memory level; the associated processes of higher classes will still be killed first.<br />
** From /init.rc:<br />
write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15<br />
write /sys/module/lowmemorykiller/parameters/minfree 2048,3072,4096,6144,7168,8192<br />
<br />
2. User space sets the oom_adj of processes to put them in the correct class for their current operation. This redefines the meaning of oom_adj from that used by the standard OOM killer to something that is more aggressive and controlled.<br />
<br />
These oom_adj levels end up being based on the process lifecycle defined here:<br />
http://developer.android.com/guide/topics/fundamentals.html#proclife<br />
<br />
=== Alarm timers ===<br />
This is the kernel implementation to support Android's AlarmManager. It lets user space tell the kernel when it would like to wake up, allowing the kernel to schedule that appropriately and come back (holding a wake lock) when the time has expired regardless of the sleep state of the CPU.<br />
<br />
==== POSIX Alarm Timers ====<br />
Note that POSIX Alarm timers, which implement this functionality (but not identically), was<br />
accepted into mainline Linux in kernel version 3.0.<br />
<br />
See [https://lwn.net/Articles/429925/ Waking Systems from Suspend] and http://lwn.net/Articles/439364/<br />
<br />
=== paranoid network security===<br />
* paranoid network security<br />
** See [[Android_Security#Paranoid_network-ing]]<br />
<br />
=== timed output / timed gpio ===<br />
Generic gpio is a mechanism to allow programs to access and manipulate gpio registers from user space.<br />
<br />
Timed output/gpio is a system to allow chaning a gpio pin and restore it automatically after a specified timeout.<br />
See <tt>drives/misc/timed_output.c</tt> and <tt>drives/misc/timed_gpio.c</tt><br />
This expose a user space interface used by the vibrator code.<br />
<br />
On ADP1, there is a driver at:<br />
<pre><br />
# cd /sys/bus/platform/drivers/timed-gpio<br />
# ls -l<br />
--w------- 1 0 0 4096 Nov 13 02:11 bind<br />
lrwxrwxrwx 1 0 0 0 Nov 13 02:11 timed-gpio -> ../../../../devices/platform/timed-gpio<br />
--w------- 1 0 0 4096 Nov 13 02:11 uevent<br />
--w------- 1 0 0 4096 Nov 13 02:11 unbind<br />
</pre><br />
<br />
Also, there is a device at:<br />
<pre><br />
# cd /sys/devices/platform/timed-gpio<br />
# ls -lR<br />
.:<br />
lrwxrwxrwx 1 0 0 0 Nov 13 01:34 driver -> ../../../bus/platform/drivers/timed-gpio<br />
-r--r--r-- 1 0 0 4096 Nov 13 01:34 modalias<br />
drwxr-xr-x 2 0 0 0 Nov 13 01:34 power<br />
lrwxrwxrwx 1 0 0 0 Nov 13 01:34 subsystem -> ../../../bus/platform<br />
-rw-r--r-- 1 0 0 4096 Nov 13 01:34 uevent<br />
<br />
./power:<br />
-rw-r--r-- 1 0 0 4096 Nov 13 01:34 wakeup<br />
</pre><br />
<br />
=== RAM_CONSOLE ===<br />
This allows saving the kernel printk messages to a buffer in RAM, so that after a kernel panic<br />
they can be viewed in the next kernel invocation, by accessing /proc/last_kmsg.<br />
<br />
[Would be good to get more details on how to set this up and use it here!]<br />
[I guess this is something like pramfs?]<br />
<br />
=== other kernel changes ===<br />
Here is a miscellaneous list of other kernel changes in the mistral Android kernel:<br />
* switch events - drivers/switch/* userspace support for monitoring GPIO via sysfs/uevent used by vold to detect USB<br />
* USB gadget driver for ADB - drivers/usb/gadget/android.c<br />
* yaffs2 flash filesystem<br />
* support in FAT filesystem for FVAT_IOCTL_GET_VOLUME_ID<br />
* and more...<br />
<br />
== Kernel configuration options ==<br />
The file [http://android.git.kernel.org/?p=kernel/common.git;a=blob_plain;f=Documentation/android.txt;hb=HEAD Documentation/android.txt] has a list of required configuration options for a kernel to support<br />
an Android system.<br />
<br />
[[Category:Android]]</div>Palmer Eldritch