blob: 208effd8d13e44258a5139a544cbc7d1ffead740 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glassc8a311d2013-03-05 14:39:40 +00002/*
3 * Copyright (c) 2011 The Chromium OS Authors.
Simon Glassc8a311d2013-03-05 14:39:40 +00004 */
5
Simon Glass2d986c02017-03-28 10:27:17 -06006#ifndef __INITCALL_H
7#define __INITCALL_H
8
Simon Glassc9eff0a2023-08-21 21:16:54 -06009#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 Glassc8a311d2013-03-05 14:39:40 +000019typedef int (*init_fnc_t)(void);
20
Simon Glassc9eff0a2023-08-21 21:16:54 -060021/* 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 Glasse7f59de2023-08-21 21:16:49 -060036int initcall_run_list(const init_fnc_t init_sequence[]);
Simon Glass2d986c02017-03-28 10:27:17 -060037
Simon Glassdd802462023-08-21 21:16:55 -060038/**
39 * initcall_manual_reloc() - Do manual relocation on an initcall sequence
40 *
41 * @init_sequence: NULL-terminated init sequence to relocate
42 */
43void initcall_manual_reloc(init_fnc_t init_sequence[]);
44
Simon Glass2d986c02017-03-28 10:27:17 -060045#endif