| 36 | }; |
| 37 | |
| 38 | error_t kernel_init(Module* dts_modules[], DtsDevice dts_devices[]) { |
| 39 | LOG_I(TAG, "init"); |
| 40 | |
| 41 | if (module_construct_add_start(&root_module) != ERROR_NONE) { |
| 42 | LOG_E(TAG, "root module init failed"); |
| 43 | return ERROR_RESOURCE; |
| 44 | } |
| 45 | |
| 46 | Module** dts_module = dts_modules; |
| 47 | while (*dts_module != nullptr) { |
| 48 | if (module_construct_add_start(*dts_module) != ERROR_NONE) { |
| 49 | LOG_E(TAG, "dts module init failed: %s", (*dts_module)->name); |
| 50 | return ERROR_RESOURCE; |
| 51 | } |
| 52 | dts_module++; |
| 53 | } |
| 54 | |
| 55 | DtsDevice* dts_device = dts_devices; |
| 56 | while (dts_device->device != nullptr) { |
| 57 | if (dts_device->status == DTS_DEVICE_STATUS_OKAY) { |
| 58 | if (device_construct_add_start(dts_device->device, dts_device->compatible) != ERROR_NONE) { |
| 59 | LOG_E(TAG, "kernel_init failed to construct+add+start device: %s (%s)", dts_device->device->name, dts_device->compatible); |
| 60 | return ERROR_RESOURCE; |
| 61 | } |
| 62 | } else if (dts_device->status == DTS_DEVICE_STATUS_DISABLED) { |
| 63 | if (device_construct_add(dts_device->device, dts_device->compatible) != ERROR_NONE) { |
| 64 | LOG_E(TAG, "kernel_init failed to construct+add device: %s (%s)", dts_device->device->name, dts_device->compatible); |
| 65 | return ERROR_RESOURCE; |
| 66 | } |
| 67 | } else { |
| 68 | check(false, "DTS status not implemented"); |
| 69 | } |
| 70 | dts_device++; |
| 71 | } |
| 72 | |
| 73 | LOG_I(TAG, "init done"); |
| 74 | return ERROR_NONE; |
| 75 | } |
| 76 | |
| 77 | #ifdef __cplusplus |
| 78 | } |