1e41f4b71Sopenharmony_ci# bootstrap Module<a name="EN-US_TOPIC_0000001063402356"></a>
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThis module implements automatic service initialization. That is, the initialization function does not need to be explicitly called. Instead, it is declared using the macro definition and is automatically executed when the system is started. Specifically, after the function for starting a service is declared using a macro, it is placed in the predefined  **zInit**  code segment. During system startup, the  **OHOS\_SystemInit**  API is called to traverse the code segment and call the functions in the code segment. Therefore, you need to include the  **zInit**  code segment in the linker script and call the  **OHOS\_SystemInit**  API in the  **main**  function.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciFor details about how to include the  **zInit**  code segment, see the Hi3861 linker script in  **vendor/hisi/hi3861/hi3861/build/link/link.ld.S**.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciFor details about the macros used by the bootstrap module to implement automatic service initialization, see  [API document](https://device.harmonyos.com/en/docs/develop/apiref/init-0000001054598113)  the Startup subsystem.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Available APIs<a name="section1633115419401"></a>
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciThe following table describes the major macros used by the bootstrap module to implement automatic service initialization.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci**Table  1**  Major macros for the bootstrap module
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci<a name="table12281332101910"></a>
16e41f4b71Sopenharmony_ci<table><thead align="left"><tr id="row102914328199"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p229113221917"><a name="p229113221917"></a><a name="p229113221917"></a>Macro Name</p>
17e41f4b71Sopenharmony_ci</th>
18e41f4b71Sopenharmony_ci<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p429132161912"><a name="p429132161912"></a><a name="p429132161912"></a>Description</p>
19e41f4b71Sopenharmony_ci</th>
20e41f4b71Sopenharmony_ci</tr>
21e41f4b71Sopenharmony_ci</thead>
22e41f4b71Sopenharmony_ci<tbody><tr id="row13291532141919"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p14292032181919"><a name="p14292032181919"></a><a name="p14292032181919"></a>SYS_SERVICE_INIT(func)</p>
23e41f4b71Sopenharmony_ci</td>
24e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p10291732181911"><a name="p10291732181911"></a><a name="p10291732181911"></a>Entry for initializing and starting a core system service</p>
25e41f4b71Sopenharmony_ci</td>
26e41f4b71Sopenharmony_ci</tr>
27e41f4b71Sopenharmony_ci<tr id="row1329133214197"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p15291332161915"><a name="p15291332161915"></a><a name="p15291332161915"></a>SYS_FEATURE_INIT(func)</p>
28e41f4b71Sopenharmony_ci</td>
29e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p12292324198"><a name="p12292324198"></a><a name="p12292324198"></a>Entry for initializing and starting a core system feature</p>
30e41f4b71Sopenharmony_ci</td>
31e41f4b71Sopenharmony_ci</tr>
32e41f4b71Sopenharmony_ci<tr id="row1529133231911"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p9291332131915"><a name="p9291332131915"></a><a name="p9291332131915"></a>APP_SERVICE_INIT(func)</p>
33e41f4b71Sopenharmony_ci</td>
34e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1229432181920"><a name="p1229432181920"></a><a name="p1229432181920"></a>Entry for initializing and starting an application-layer service</p>
35e41f4b71Sopenharmony_ci</td>
36e41f4b71Sopenharmony_ci</tr>
37e41f4b71Sopenharmony_ci<tr id="row1229173214194"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12923218193"><a name="p12923218193"></a><a name="p12923218193"></a>APP_FEATURE_INIT(func)</p>
38e41f4b71Sopenharmony_ci</td>
39e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p17291332121913"><a name="p17291332121913"></a><a name="p17291332121913"></a>Entry for initializing and starting an application-layer feature</p>
40e41f4b71Sopenharmony_ci</td>
41e41f4b71Sopenharmony_ci</tr>
42e41f4b71Sopenharmony_ci</tbody>
43e41f4b71Sopenharmony_ci</table>
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci## How to Use<a name="section2055311316228"></a>
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ciThe following is an example of using macros to automatically initialize services.
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci```
50e41f4b71Sopenharmony_civoid SystemServiceInit(void) {
51e41f4b71Sopenharmony_ci    printf("Init System Service\n");
52e41f4b71Sopenharmony_ci}
53e41f4b71Sopenharmony_ciSYS_SERVICE_INIT(SystemServiceInit);
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_civoid SystemFeatureInit(void) {
56e41f4b71Sopenharmony_ci    printf("Init System Feature\n");
57e41f4b71Sopenharmony_ci}
58e41f4b71Sopenharmony_ciSYS_FEATURE_INIT(SystemFeatureInit);
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_civoid AppServiceInit(void) {
61e41f4b71Sopenharmony_ci    printf("Init App Service\n");
62e41f4b71Sopenharmony_ci}
63e41f4b71Sopenharmony_ciAPP_SERVICE_INIT(AppServiceInit);
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_civoid AppFeatureInit(void) {
66e41f4b71Sopenharmony_ci    printf("Init App Feature\n");
67e41f4b71Sopenharmony_ci}
68e41f4b71Sopenharmony_ciAPP_FEATURE_INIT(AppFeatureInit);
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci// Logs are printed in the following sequence:
71e41f4b71Sopenharmony_ci// Init System Service
72e41f4b71Sopenharmony_ci// Init System Feature
73e41f4b71Sopenharmony_ci// Init App Service
74e41f4b71Sopenharmony_ci// Init App Feature
75e41f4b71Sopenharmony_ci```
76e41f4b71Sopenharmony_ci
77