This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkmodule.cpp
64 lines (59 loc) · 1.6 KB
/
kmodule.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "types/hashtable.h"
#include "kernel.h"
#include "kmodule.h"
#include "klog.h"
#include "kevent.h"
#include "kconfig.h"
#include "ktask.h"
#include <stdlib.h>
/*Modules*/
#include <kernel/modules/powerctl/module.h>
#include <kernel/modules/soundctl/module.h>
#include <kernel/modules/hid/module.h>
#include <kernel/modules/gui/module.h>
#include <kernel/modules/autostart/module.h>
void boot_pb(double pb){
event_create(khandle->event_mgr,"boot_progress_update", &pb);
}
void _kmodule_register(kmodule_t *module){
kassert(module!=NULL);
kassert(module->name!=NULL);
kmutex_lock();
hashtbl_add(khandle->modules,module->name,(void*)module);
kmutex_unlock();
klog(INFO,"kmodule","Registering module:%s",module->name);
module->init();
}
void kmodule_register(char *name,void (*shared_call)(void *param),void (*init)(void)){
kmodule_t *module=(kmodule_t *)malloc(sizeof(kmodule_t));
module->name=name;
module->shared_call=shared_call;
module->init=init;
_kmodule_register(module);
}
void init_modules(void* xParam){
//Register modules here
#if LOAD_GUI
kmutex_lock();
kmodule_register("gui",NULL,&init_gui_module);
kmutex_unlock();
boot_pb(20.0);
#endif
#if LOAD_POWERCTL
kmodule_register("powerctl",NULL,&init_powerctl);
boot_pb(40.0);
#endif
#if LOAD_SOUNDCTL
kmodule_register("soundctl",NULL,&init_soundctl);
boot_pb(60.0);
#endif
#if LOAD_HIDCTL
kmodule_register("hidctl",NULL,&init_hid);
boot_pb(80.0);
#endif
#if LOAD_AUTOSTART
kmodule_register("autostart",NULL,&do_autostart);
boot_pb(90.0);
#endif
boot_pb(100.0);
}