Vendors have different kernel requirements and feature solutions when adapting their platforms to OpenHarmony.
If their code is directly integrated into the kernel repository or patches are applied, problems such as low build and development efficiency, complex routine maintenance, and poor feature portability will be caused.
To incorporate third-party kernel features into OpenHarmony without or with little interference with the kernel repository, OpenHarmony provides the OpenHarmony Common Kernel (HCK) framework, which provides a complete set of instrumentation, registration, and invoking interfaces to reduce modification to the kernel. The HCK provides instrumentation interfaces applicable to multiple platforms, implementing decoupling of the kernel.
This document describes how to implement the HCK based on the native hook mode.
## Application Scope
You can use the HCK framework when your Linux kernel patches, features, and modules require modification on the native kernel.
## Available APIs
**DECLARE_HCK_LITE_HOOK**: macro used to declare an instrumentation interface. It generates the registration and call interfaces.
**REGISTER_HCK_LITE_HOOK**: macro used to register an instrumentation interface instance. The HCK supports only the registration of a singleton for a singleton, and the registered interfaces cannot be deregistered.
**REGISTER_HCK_LITE_DATA_HOOK**: macro used to register an instrumentation interface instance with parameters. Only a singleton can be registered, and the registered interfaces cannot be deregistered.
**CALL_HCK_LITE_HOOK**: macro used to call an instrumentation interface, which replaces the code that intrudes into the native kernel code.
**Figure 1** HCK interface definition, registration, and invocation

## Usage Guide
### Configuration
Before using the HCK, enable the following settings in the **config** file of your platform in the **kernel_linux_config** repository:
```c
CONFIG_HCK=y
CONFIG_HCK_VENDOR_HOOKS=y
```
### Interface Definition
Define the hook interface in **kernel-x.x/include/linux/hck/lite_hck_xxx.h** by using the following macro:
```c
#include <linux/hck/lite_vendor_hooks.h> // Include HCK header file.
// You can customize data types for passing in parameters in interface registration.
structhck_data{
intstat;
char*name;
};
// Declare the hook interface. The declaration macro contains the EXPORT interface, and you do not need to call EXPORT separately to declare the interface.
Add the interface declaration header file to the new vendor hck module. The file path is **drivers/hck/vendor_hooks.c**.
```c
#define CREATE_LITE_VENDOR_HOOK
#include <linux/hck/lite_hck_sample.h> // Add the interface declaration header file after the macro definition.
```
### Interface Registration
Define the instrumentation function and register the hook functions in the hook module.
```c
// Include the interface declaration header file.
#include <linux/hck/lite_hck_sample.h>
// Implement the interfaces:
boot_config_info0([void*data],...)
{
// Call the input parameters for the registration.
((structhck_data*)data)->stat...;
}
// Register the interface. Generally, register the interface in the init() function of the module. Ensure that the registration is completed before the interface is called.