mirror of
https://xff.cz/git/u-boot/
synced 2025-11-01 19:05:51 +01:00
event: Add basic support for events
Add a way to create and dispatch events without needing to allocate memory. Also add a way to 'spy' on events, thus allowing 'hooks' to be created. Use a linker list for static events, which we can use to replace functions like arch_cpu_init_f(). Allow an EVENT_DEBUG option which makes it easier to see what is going on at runtime, but uses more code space. Dynamic events allow the creation of a spy at runtime. This is not always necessary, but can be enabled with EVENT_DYNAMIC if needed. A 'test' event is the only option for now. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
35
include/event_internal.h
Normal file
35
include/event_internal.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Internal definitions for events
|
||||
*
|
||||
* Copyright 2021 Google LLC
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#ifndef __event_internal_h
|
||||
#define __event_internal_h
|
||||
|
||||
#include <event.h>
|
||||
#include <linux/list.h>
|
||||
|
||||
/**
|
||||
* struct event_spy - a spy that watches for an event of a particular type
|
||||
*
|
||||
* @id: Spy ID
|
||||
* @type: Event type to subscribe to
|
||||
* @func: Function to call when the event is sent
|
||||
* @ctx: Context to pass to the function
|
||||
*/
|
||||
struct event_spy {
|
||||
struct list_head sibling_node;
|
||||
const char *id;
|
||||
enum event_t type;
|
||||
event_handler_t func;
|
||||
void *ctx;
|
||||
};
|
||||
|
||||
struct event_state {
|
||||
struct list_head spy_head;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user