Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 82a5fa0 | 2013-03-05 14:39:40 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 The Chromium OS Authors. |
Simon Glass | 82a5fa0 | 2013-03-05 14:39:40 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | 5b66888 | 2017-03-28 10:27:17 -0600 | [diff] [blame] | 6 | #ifndef __INITCALL_H |
| 7 | #define __INITCALL_H |
| 8 | |
Simon Glass | 6b42d38 | 2023-08-21 21:16:54 -0600 | [diff] [blame] | 9 | #include <asm/types.h> |
| 10 | #include <event.h> |
| 11 | |
| 12 | _Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits"); |
| 13 | |
| 14 | /** |
| 15 | * init_fnc_t - Init function |
| 16 | * |
| 17 | * Return: 0 if OK -ve on error |
| 18 | */ |
Simon Glass | 82a5fa0 | 2013-03-05 14:39:40 +0000 | [diff] [blame] | 19 | typedef int (*init_fnc_t)(void); |
| 20 | |
Simon Glass | 6b42d38 | 2023-08-21 21:16:54 -0600 | [diff] [blame] | 21 | /* Top bit indicates that the initcall is an event */ |
| 22 | #define INITCALL_IS_EVENT GENMASK(BITS_PER_LONG - 1, 8) |
| 23 | #define INITCALL_EVENT_TYPE GENMASK(7, 0) |
| 24 | |
| 25 | #define INITCALL_EVENT(_type) (void *)((_type) | INITCALL_IS_EVENT) |
| 26 | |
| 27 | /** |
| 28 | * initcall_run_list() - Run through a list of function calls |
| 29 | * |
| 30 | * This calls functions one after the other, stopping at the first error, or |
| 31 | * when NULL is obtained. |
| 32 | * |
| 33 | * @init_sequence: NULL-terminated init sequence to run |
| 34 | * Return: 0 if OK, or -ve error code from the first failure |
| 35 | */ |
Simon Glass | afb5a8a | 2023-08-21 21:16:49 -0600 | [diff] [blame] | 36 | int initcall_run_list(const init_fnc_t init_sequence[]); |
Simon Glass | 5b66888 | 2017-03-28 10:27:17 -0600 | [diff] [blame] | 37 | |
| 38 | #endif |