Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

KaiOS overall

architecture

Mingliang ZHOU
KaiOS Technologies, Inc. - Confidential and Proprietary
KaiOS Architecture

KaiOS Technologies, Inc. - Confidential and Proprietary


KaiOS Architecture

KaiOS Technologies, Inc. - Confidential and Proprietary


KaiOS Architecture

KaiOS Technologies, Inc. - Confidential and Proprietary


Gonk overview
Gonk is a simple Linux distribution that includes components from Android (such as
GPS and Camera) and is extended by Mozilla with common open-source projects
such as libusb, bluez, and so forth to integrate with all layers in the Kai OS
architecture. This design makes it easier for OEMs to port software components from
other Android implementations (device drivers, firmware, service-level daemons, etc.)
for deployment on Kai OS smart feature phones.
Gonk is a device porting layer: an adapter between the hardware and Gecko. Gonk is
a relatively simple Linux distribution that can be treated as a Gecko Port paired with
Gecko porting layers — so Gonk is a porting target of Gecko, just like there's a port of
Gecko to OS X, Windows, and Android.

KaiOS Technologies, Inc. - Confidential and Proprietary


Gonk architecture
Each mobile phone model has a specialized combination of Gonk components based
on the system libraries, device drivers, and firmware required to operate the device.
These components are determined by the OEM in collaboration with chipset
manufacturers and ODMs.

KaiOS Technologies, Inc. - Confidential and Proprietary


Gonk architecture
Linux Kernel: Uses libraries from Android (GPS, camera, etc.) and other open source
projects (Linux, libusb, bluez, and so on).
Radio Interface Layer (RIL): Interacts with the modem hardware (telephony) in the phone.
Consists of two components:
– rild daemon: Talks to the modem firmware.
– rilProxy: Proxies messages between rild and the b2g(main) process
mediaserver process: Controls audio and video playback. Gecko communicates with the
media server through an Android RPC mechanism.
netd process: Network daemon that interacts directly with network interfaces (Wi-fi) in the
hardware.
Bluetooth, etc.: Bluetooth and other service-level daemons provide access to hardware
capabilities.
KaiOS Technologies, Inc. - Confidential and Proprietary
Gecko overview
Gecko is the web engine and presentation layer in Kai OS that connects
hardware to HTML by serving as the interface between web content and the
underlying device.
It will provide programmatic access to features in the underlying mobile device
hardware (such as the battery or vibration), along with data that is stored on, or
available to, a device (such as the calendar or contacts). Web content invokes
the accessible Web APIs within HTML5.
Gecko provides an HTML5 parsing and rendering engine, programmatic
access to hardware functionality via secure web APIs, a comprehensive
security framework, update management, and other core services.

KaiOS Technologies, Inc. - Confidential and Proprietary


Gecko architecture

KaiOS Technologies, Inc. - Confidential and Proprietary


Gecko architecture
Security Framework: contains
– Permission Manager: Gateway to accessing functionality in the Web API.
– Access Control List: Matrix of roles and permissions required to access Web API
functionality.
– Credential Validation: Authentication of apps/users.
– Permissions Store: Set of privileges required to access Web API functionality.
b2g process: (Gecko) runs in a highly-privileged system process that has access to
hardware features in the mobile phone. Running apps are child processes of b2g.

KaiOS Technologies, Inc. - Confidential and Proprietary


Gecko architecture
Web API: Set of standard APIs that exposes hardware functionality to web content.
Provides web apps with secure, programmatic access to features in the underlying
mobile device hardware, along with data that is stored on—or available to—a device.
I/O: Interface to the hardware and data store(s).
Software Updates: Obtain and install updates to system software and third-party
apps.
Content Layout & Rendering: Engine that parses, interprets, and executes web
content and, with formatting information, displays the formatted content to the user.

KaiOS Technologies, Inc. - Confidential and Proprietary


kaiOS bootup procedure
This section describes the process by which Kai OS devices
boot, what parts are involved, and where.
As a quick reference, the general system bootup flow goes
from bootloaders in the Kernel space, to init in the native code,
to B2G and then Gecko in the user space, and then finally to the
system app, window manager, then homescreen app inside
Gecko.
This is what all other apps are executed on top of:

KaiOS Technologies, Inc. - Confidential and Proprietary


kaiOS bootup

KaiOS Technologies, Inc. - Confidential and Proprietary


kaiOS bootup procedure
The bootstrapping process
When a KaiOS device is first turned on, execution begins in the primary bootloader. From there, the
process of loading the main operating system proceeds in the typical way; a succession of increasingly
higher-level bootloaders bootstrap the next loader in the chain. At the end of the process, execution is
handed off to the Linux kernel.
There are a few points worth noting about the boot process:
The bootloaders usually display the first splash screen seen by the user during device startup; this is
typically a vendor logo.
The bootloaders implement flashing an image to the device. Different devices use different protocols,
most phones use the fastboot protocol.
By the end of the bootstrapping process, the modem image is usually loaded and running on the
modem processor. How this happens is highly device-specific and may be proprietary.

KaiOS Technologies, Inc. - Confidential and Proprietary


kaiOS bootup procedure
The Linux kernel(s) used by Gonk is very similar to the upstream Linux from which it's derived (based
on the Android Open Source Project). There are a few changes made by the AOSP that have not yet
been upstreamed. In addition, vendors sometimes modify the kernel and upstream those changes on
their own schedule. In general, the Linux kernel is close to stock.
The startup process for Linux is well-documented elsewhere on the Internet, so this article won't cover
that.
The Linux Kernel will bring up devices and run essential processes. It will execute processes defined
in init.rc and the successor init.b2g.rc to boot essential process such as b2g (KaiOS basic process,
containing Gecko) and rild (telephony related process that might proprietary by different chipsets); see
below for more details. At the end of the process, a userspace init process is launched, as it is in most
UNIX-like operating systems.
Once the init process is launched, the Linux kernel handles system calls from userspace, and
interrupts and the like from hardware devices. Many hardware features are exposed to userspace
through sysfs.

KaiOS Technologies, Inc. - Confidential and Proprietary


kaiOS bootup procedure
For example, here's a code snippet that reads the battery state in Gecko:

FILE *capacityFile = fopen("/sys/class/power_supply/battery/capacity", "r");


double capacity = dom::battery::kDefaultLevel * 100;
if (capacityFile) {
fscanf(capacityFile, "%lf", &capacity);
fclose(capacityFile);
}

KaiOS Technologies, Inc. - Confidential and Proprietary


kaiOS bootup procedure
The init process in Gonk handles mounting the required file systems and
spawns system services. After that, it stays around to serve as a process
manager.
This is quite similar to init on other UNIX-like operating systems. It interprets
scripts (that is, the init*.rc files) that consist of commands describing what
should be done to start various services.
One key task the init process handles is starting up the b2g process; this is
the core of the KaiOS operating system.
service b2g /system/bin/b2g.sh
class main
onrestart restart media

KaiOS Technologies, Inc. - Confidential and Proprietary


userspace process architecture
The b2g process is the primary
system process.
It runs with high privileges; It has
access to most hardware devices.
b2g communicates with the modem,
draws to the display framebuffer, and
talks to GPS, cameras, and other
hardware features. Internally, b2g
runs the Gecko layer.

KaiOS Technologies, Inc. - Confidential and Proprietary


userspace process architecture
B2G
The b2g process may, in turn, spawn a number of low-rights content processes.
These processes are where web applications and other web content are loaded.
These processes communicate with the main Gecko server process through
IPDL( Inter-Process Communication Protocol Definition Language), a message-
passing system.

Rild
The rild process is the interface to the modem processor. rild is the daemon that
implements the Radio Interface Layer (RIL). It's a proprietary piece of code that's
implemented by the hardware vendor to talk to their modem hardware. rild makes it
possible for client code to connect to a UNIX-domain socket to which it binds.

KaiOS Technologies, Inc. - Confidential and Proprietary


userspace process architecture
Rild
It's started up by code like this in the init script:
service ril-daemon /system/bin/rild

socket rild stream 660 root radio

Rilproxy
In KaiOS, the rild client is the rilproxy process. This acts as a dumb forwarding proxy
between rild and b2g. Suffice it to say, it is indeed necessary.

Netd

The netd process is used to configure network interfaces.

KaiOS Technologies, Inc. - Confidential and Proprietary


userspace process architecture
Mediaserver
The mediaserver process controls audio and video playback.
Gecko talks to it through an Android Remote Procedure Call (RPC)
mechanism.
Some of the media that Gecko can play (OGG Vorbis audio, OGG Theora
video, and WebM video) are decoded by Gecko and sent directly to the
mediaserver process.
Other media files are decoded by libstagefright, which is capable of accessing
proprietary codecs and hardware encoders.

KaiOS Technologies, Inc. - Confidential and Proprietary


userspace process architecture
Wpa_supplicant
The wpa_supplicant process is the standard UNIX-style daemon that handles
connectivity with WiFi access points.

Dbus-daemon
The dbus-daemon implements D-Bus, a message bus system that KaiOS
uses for Bluetooth communication.

KaiOS Technologies, Inc. - Confidential and Proprietary


THANK
YOU

KaiOS Technologies, Inc. - Confidential and Proprietary Email: Mingliang.Zhou@kaiostech.com

You might also like