Newer
Older
honey-os / src / kernel / service / events.c
@biosfood biosfood on 10 Dec 2022 613 bytes add kernel events
#include <service.h>
#include <util.h>

ListElement *kernelEvents;

Event *loadInitrdEvent, *crashEvent;

Event *createKernelEvent(char *name) {
    Event *event = malloc(sizeof(Provider));
    event->subscriptions = NULL;
    event->name = name;
    listAdd(&kernelEvents, event);
    return event;
}

void fireEvent(Event *event, uint32_t data1) {
    foreach (event->subscriptions, Provider *, provider,
             { scheduleProvider(provider, data1, 0, 0, 0); })
        ;
}

void installKernelEvents() {
    loadInitrdEvent = createKernelEvent("loadInitrd");
    crashEvent = createKernelEvent("crash");
}