feat added init function
This commit is contained in:
20
include/myke/util/init.h
Normal file
20
include/myke/util/init.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Created by rick on 13-08-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_INIT_H
|
||||
#define NEW_KERNEL_INIT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <myke/driver.h>
|
||||
|
||||
struct init {
|
||||
const char *name;
|
||||
void (*init)();
|
||||
};
|
||||
|
||||
#define INIT_FUNCTION(order) GENERIC_DRIVER(init, order)
|
||||
|
||||
void init_execute_all();
|
||||
|
||||
#endif //NEW_KERNEL_INIT_H
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/libk/syscall.h>
|
||||
#include <myke/mem/mem.h>
|
||||
#include <myke/util/init.h>
|
||||
#include <myke/tasks/task.h>
|
||||
|
||||
const int version_major = 0,
|
||||
@@ -78,6 +79,9 @@ void att_noreturn att_used kmain(multiboot_info_t *multiboot_info, uint32_t mb_n
|
||||
|
||||
printf("Booted successfully v%d.%d.%d\n", version_major, version_minor, version_patch);
|
||||
|
||||
// initializing modules
|
||||
init_execute_all();
|
||||
|
||||
// initialize tasking
|
||||
task_init();
|
||||
kprint_start_task();
|
||||
|
||||
18
kernel/util/init.c
Normal file
18
kernel/util/init.c
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Created by rick on 13-08-21.
|
||||
//
|
||||
|
||||
#include <myke/util/init.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern struct init __start_init[];
|
||||
extern struct init __stop_init[];
|
||||
#define NUM_DRIVERS ((size_t)(__stop_init - __start_init))
|
||||
#define DRIVER(i) ((__start_init) + (i))
|
||||
|
||||
void init_execute_all() {
|
||||
for (size_t i = 0; i < NUM_DRIVERS; ++i) {
|
||||
printf("init %s\n", DRIVER(i)->name);
|
||||
DRIVER(i)->init();
|
||||
}
|
||||
}
|
||||
13
kernel/vfs/tmpfs.c
Normal file
13
kernel/vfs/tmpfs.c
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Created by rick on 13-08-21.
|
||||
//
|
||||
|
||||
#include <myke/util/init.h>
|
||||
|
||||
void tmpfs_init() {
|
||||
}
|
||||
|
||||
INIT_FUNCTION(100) = {
|
||||
.name = "tmpfs",
|
||||
.init = tmpfs_init,
|
||||
};
|
||||
Reference in New Issue
Block a user