MOS Source Code
Loading...
Searching...
No Matches
power.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#include "mos/misc/power.h"
4
5#include "mos/mm/slab.h"
8#include "mos/syslog/printk.h"
9
11#include <mos_stdlib.h>
12
19
23
32
33[[noreturn]] void power_shutdown(void)
34{
35 pr_info("system shutdown initiated");
37 {
38 e->callback(e->data);
39 list_remove(e);
40 kfree(e);
41 }
42
43 pr_info("Bye!");
45}
bool callback(pb_istream_t *stream, uint8_t *buf, size_t count)
MOSAPI void linked_list_init(list_node_t *head_node)
Initialise a circular double linked list.
Definition list.c:15
#define LIST_HEAD_INIT(container)
Definition list.h:38
MOSAPI void list_node_append(list_node_t *head, list_node_t *item)
Definition list.c:68
#define list_foreach(t, v, h)
Iterate over a list.
Definition list.h:83
#define list_node(element)
Get the ‘list_node’ of a list element. This is exactly the reverse of ‘list_entry’ above.
Definition list.h:68
list_node_t list_head
A linked list head.
Definition list.h:23
#define list_remove(element)
Definition list.h:74
#define NULL
Definition pb_syshdr.h:46
static slab_t * power_callback_cache
Definition power.c:21
static list_head pm_notifiers
Definition power.c:20
void power_shutdown(void)
Shutdown the system.
Definition power.c:33
void power_register_shutdown_callback(power_callback_t callback, void *data)
Register a callback to be called when the system is about to shut down.
Definition power.c:24
void(* power_callback_t)(void *data)
Definition power.h:6
#define pr_info(fmt,...)
Definition printk.h:35
void platform_shutdown()
#define SLAB_AUTOINIT(name, var, type)
Definition power.c:14
as_linked_list
Definition power.c:15
power_callback_t callback
Definition power.c:16
void * data
Definition power.c:17
Definition slab.h:45