1# bootstrap Module 2 3 4This 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 through macro definition, 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. 5 6 7For details about how to include the **zInit** code segment, see the Hi3861 linker script in **vendor/hisi/hi3861/hi3861/build/link/link.ld.S**. 8 9 10For details about the macros used by the bootstrap module to implement automatic service initialization, see [API Reference](https://device.harmonyos.com/cn/docs/develop/apiref/init-0000001054598113) of the Startup subsystem. 11 12 13## Available APIs 14 15The following table lists the automatic initialization macros of main services. 16 17 Table 1 Major macros for the bootstrap module 18 19| Name| Description| 20| -------- | -------- | 21| SYS_SERVICE_INIT(func) | Entry for initializing and starting a core system service.| 22| SYS_FEATURE_INIT(func) | Entry for initializing and starting a core system feature.| 23| APP_SERVICE_INIT(func) | Entry for initializing and starting an application-layer service.| 24| APP_FEATURE_INIT(func) | Entry for initializing and starting an application-layer feature.| 25 26 27## Development Example 28 29 The following is an example of using macros to automatically initialize services. 30 31``` 32void SystemServiceInit(void) { 33 printf("Init System Service\n"); 34} 35SYS_SERVICE_INIT(SystemServiceInit); 36 37void SystemFeatureInit(void) { 38 printf("Init System Feature\n"); 39} 40SYS_FEATURE_INIT(SystemFeatureInit); 41 42void AppServiceInit(void) { 43 printf("Init App Service\n"); 44} 45APP_SERVICE_INIT(AppServiceInit); 46 47void AppFeatureInit(void) { 48 printf("Init App Feature\n"); 49} 50APP_FEATURE_INIT(AppFeatureInit); 51 52// Logs are printed in the following sequence: 53// Init System Service 54// Init System Feature 55// Init App Service 56// Init App Feature 57``` 58