Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
notify.h
Go to the documentation of this file.
1#ifndef __DEV__NOTIFY_H__
2#define __DEV__NOTIFY_H__
3
4#include "spinlock.h"
5#include "string.h"
6#include <type.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12/* Notifier callback return codes */
13#define NOTIFY_OK 1
14#define NOTIFY_STOP -1
15#define NOTIFY_BAD -2
16
17/* Notifier flags */
18#define NOTIFIER_FLAG_ONCE (1 << 0)
19#define NOTIFIER_FLAG_ATOMIC (1 << 1)
20#define NOTIFIER_FLAG_DISABLED (1 << 2)
21
22#define NOTIFY_HIGHT 1000
23#define NOTIFY_MEDIUM 500
24#define NOTIFY_NORMAL 100
25#define NOTIFY_LOW 50
26
27typedef void (*notify_callback_t)(uint32_t event, void* data, void* context);
28
36
39 size_t size;
40 struct notifier* head;
41};
42
43#define NOTIFY_DEV_HASH_SIZE 64
44#define NOTIFY_DEV_HASH_MASK (NOTIFY_DEV_HASH_SIZE - 1)
45
46
51
60
61/* Lifecycle */
64
65/* Subscription */
66int notify_register(char* name, struct notifier* n);
68
69int wait_until_receive_notify(const char* name, uint64_t timeout);
70
71/* Dispatch */
72int notify_call(char* name, uint32_t event, void* data);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* __DEV__NOTIFY_H__ */
kstring name
Definition dentry.h:5
struct fs_data data
Definition filesystem.h:1
void notify_dev_create(kstring name)
Definition notify.c:41
int notify_call(char *name, uint32_t event, void *data)
Definition notify.c:110
int notify_unregister(kstring name, struct notifier *n)
void(* notify_callback_t)(uint32_t event, void *data, void *context)
Definition notify.h:27
int notify_register(char *name, struct notifier *n)
Definition notify.c:78
int notify_dev_destroy(kstring name)
#define NOTIFY_DEV_HASH_SIZE
Definition notify.h:43
int wait_until_receive_notify(const char *name, uint64_t timeout)
Definition notify.c:140
uint32_t flags
Definition notify.h:33
notify_callback_t callback
Definition notify.h:30
struct notifier * next
Definition notify.h:34
uint32_t priority
Definition notify.h:32
void * context
Definition notify.h:31
spinlock_t lock
Definition notify.h:38
struct notifier * head
Definition notify.h:40
size_t size
Definition notify.h:39
spinlock_t lock
Definition notify.h:48
struct notify_dev * buckets[64]
Definition notify.h:49
kstring name
Definition notify.h:54
atomic_t refcount
Definition notify.h:55
volatile uint64_t event_received
Definition notify.h:58
uint64_t hash
Definition notify.h:53
struct notify_chain chain
Definition notify.h:56
struct notify_dev * next
Definition notify.h:57
unsigned int uint32_t
Definition type.h:19
unsigned long uint64_t
Definition type.h:25