API

API(Application Programming Interface): Rules that determine how to call which function in the source code

API is a set of usage rules that allows other codes or programs to use certain functions.

Even if you don’t know how a function is implemented internally, you can use that function if you request it in a certain way.

Suppose we create a simple addition function:

function add(a, b) {
	return a + b;
}

Another developer can use it by calling:

add(3, 5)

This is how the function is called.

Here, the add function can be viewed as an API.

In this way, API is a rule for using functions.

ABI

ABI(Application Binary Interface): Rules for matching compiled binary codes with each other

While API is a convention at the source code level, ABI is a convention at the compiled binary level.

For example, which registers the function arguments are placed in, where the return value is stored, how the structure memory is placed, etc.

The ABI must be maintained for the binary to continue to operate without recompiling the source code.

In the Android Kernel

In particular, the reason ABI is important in the Android Kernel is because of the Kernel Module.

The Android GKI structure includes the GKI core kernel managed by Google, and the vendor kernel module provided by the SoC vendor is installed separately.

Here, the vendor module is an already compiled .ko binary, and this module refers to the GKI Kernel internal function or structure. However, if the ABI is broken after a kernel update, there is a possibility that the module will not be loaded or may malfunction at runtime.

Therefore, the binary interface must be maintained even after the kernel update so that the existing vendor module continues to run well. At this time, the binary protocol between the kernel and module is usually called KMI(Kernel Module Interface) in Android.