Events

The concept of events is decribed here.

enum event_t

Types of events supported by U-Boot

Constants

EVT_NONE

This zero value is not used for events.

EVT_TEST

This event is used in unit tests.

EVT_DM_POST_INIT_F

This event is triggered after pre-relocation initialization of the driver model. Its parameter is NULL. A non-zero return code from the event handler let’s the boot process fail.

EVT_DM_POST_INIT_R

This event is triggered after post-relocation initialization of the driver model. Its parameter is NULL. A non-zero return code from the event handler let’s the boot process fail.

EVT_DM_PRE_PROBE

This event is triggered before probing a device. Its parameter is the device to be probed. A non-zero return code from the event handler lets the device not being probed.

EVT_DM_POST_PROBE

This event is triggered after probing a device. Its parameter is the device that was probed. A non-zero return code from the event handler leaves the device in the unprobed state and therefore not usable.

EVT_DM_PRE_REMOVE

This event is triggered after removing a device. Its parameter is the device to be removed. A non-zero return code from the event handler stops the removal of the device before any changes.

EVT_DM_POST_REMOVE

This event is triggered before removing a device. Its parameter is the device that was removed. A non-zero return code stops from the event handler the removal of the device after all removal changes. The previous state is not restored. All children will be gone and the device may not be functional.

EVT_MISC_INIT_F

This event is triggered during the initialization sequence before relocation. Its parameter is NULL. A non-zero return code from the event handler let’s the boot process fail.

EVT_FPGA_LOAD

The FPGA load hook is called after loading an FPGA with a new binary. Its parameter is of type struct event_fpga_load and contains information about the loaded image.

EVT_FT_FIXUP

This event is triggered during device-tree fix up after all other device-tree fixups have been executed. Its parameter is of type struct event_ft_fixup which contains the address of the device-tree to fix up and the list of images to be booted. A non-zero return code from the event handler let’s booting the images fail.

EVT_MAIN_LOOP

This event is triggered immediately before calling main_loop() which is the entry point of the command line. Its parameter is NULL. A non-zero return value causes the boot to fail.

EVT_COUNT

This constants holds the maximum event number + 1 and is used when looping over all event classes.

struct event

an event that can be sent and received

Definition

struct event {
  enum event_t type;
  union event_data data;
};

Members

type

Event type

data

Data for this particular event

struct evspy_info

information about an event spy

Definition

struct evspy_info {
  event_handler_t func;
  enum event_t type;
#if CONFIG_IS_ENABLED(EVENT_DEBUG);
  const char *id;
#endif;
};

Members

func

Function to call when the event is activated (must be first)

type

Event type

id

Event id string

int event_register(const char *id, enum event_t type, event_handler_t func, void *ctx)

register a new spy

Parameters

const char *id

Spy ID

enum event_t type

Event type to subscribe to

event_handler_t func

Function to call when the event is sent

void *ctx

Context to pass to the function return 0 if OK, -ve on error

int event_manual_reloc(void)

Relocate event handler pointers

Parameters

void

no arguments

Description

Relocate event handler pointers for all static event spies. It is called during the generic board init sequence, after relocation.

Return

0 if OK

int event_notify(enum event_t type, void *data, int size)

notify spies about an event

Parameters

enum event_t type

Event type

void *data

Event data to be sent (e.g. union_event_data)

int size

Size of data in bytes return 0 if OK, -ve on error

Description

It is possible to pass in union event_data here but that may not be convenient if the data is elsewhere, or is one of the members of the union. So this uses a void * for data, with a separate size.

int event_notify_null(enum event_t type)

notify spies about an event

Parameters

enum event_t type

Event type return 0 if OK, -ve on error

Description

Data is NULL and the size is 0

int event_uninit(void)

Clean up dynamic events

Parameters

void

no arguments

Description

This removes all dynamic event handlers

int event_init(void)

Set up dynamic events

Parameters

void

no arguments

Description

Init a list of dynamic event handlers, so that these can be added as needed