2023-10-21 21:23:51 +03:00
|
|
|
|
/**
|
|
|
|
|
* sys.c
|
|
|
|
|
* Файл с функциями управления системой
|
|
|
|
|
*
|
|
|
|
|
* Этот файл содержит имплементацию функций для управления системой
|
|
|
|
|
*/
|
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
#include <fb.h>
|
2023-11-26 13:12:57 +03:00
|
|
|
|
#include <mem.h>
|
2023-11-07 22:34:26 +03:00
|
|
|
|
#include <mod.h>
|
2023-10-21 20:27:23 +03:00
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <sys.h>
|
|
|
|
|
|
2023-10-31 19:06:56 +03:00
|
|
|
|
module_info_t *current_module;
|
|
|
|
|
|
2023-10-21 20:27:23 +03:00
|
|
|
|
void sys_init( ) {}
|
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static framebuffer_t *sys_alloc_framebuffer( ) {
|
2023-10-21 20:27:23 +03:00
|
|
|
|
return (framebuffer_t *)0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static void sys_free_framebuffer(framebuffer_t *frame) {
|
2023-10-31 19:06:56 +03:00
|
|
|
|
frame->reserved = 0;
|
|
|
|
|
}
|
2023-10-21 20:27:23 +03:00
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static void sys_exit(int code) {
|
2023-10-31 19:06:56 +03:00
|
|
|
|
current_module->err_code = code;
|
|
|
|
|
}
|
2023-10-21 20:27:23 +03:00
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static int sys_get_error( ) {
|
2023-10-31 19:06:56 +03:00
|
|
|
|
return current_module->err_code;
|
2023-10-21 20:27:23 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static sys_info_t *sys_get_info( ) {
|
2023-10-31 19:06:56 +03:00
|
|
|
|
return &(sys_info_t){ .reserved = 0 };
|
|
|
|
|
}
|
2023-10-21 20:27:23 +03:00
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static module_info_t *sys_get_module(char *module_id) {
|
|
|
|
|
return (module_info_t *)mod_find(module_id);
|
2023-10-31 19:06:56 +03:00
|
|
|
|
}
|
2023-10-21 20:27:23 +03:00
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static uint64_t sys_new_thread(uint64_t func) {
|
2023-10-31 19:06:56 +03:00
|
|
|
|
return func;
|
|
|
|
|
}
|
2023-10-21 20:27:23 +03:00
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static int sys_delete_thread(uint64_t thread_id) {
|
2023-10-31 19:06:56 +03:00
|
|
|
|
return thread_id;
|
2023-10-21 20:27:23 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
static time_t sys_get_time( ) {
|
2023-10-31 19:06:56 +03:00
|
|
|
|
return (time_t){ .year = 2023, .month = 10, .day = 31, .second = 1 };
|
|
|
|
|
}
|
2023-10-21 20:27:23 +03:00
|
|
|
|
|
2023-11-18 14:50:37 +03:00
|
|
|
|
env_t *sys_install(env_t *module) {
|
|
|
|
|
module->fb_printf = &fb_printf;
|
|
|
|
|
module->alloc_framebuffer = &sys_alloc_framebuffer;
|
|
|
|
|
module->free_framebuffer = &sys_free_framebuffer;
|
2023-11-26 13:12:57 +03:00
|
|
|
|
module->alloc = &mem_alloc;
|
|
|
|
|
module->free = &mem_free;
|
2023-11-18 14:50:37 +03:00
|
|
|
|
module->exit = &sys_exit;
|
|
|
|
|
module->get_error = &sys_get_error;
|
|
|
|
|
module->get_info = &sys_get_info;
|
|
|
|
|
module->get_module = &sys_get_module;
|
|
|
|
|
module->new_thread = &sys_new_thread;
|
|
|
|
|
module->delete_thread = &sys_delete_thread;
|
|
|
|
|
module->get_time = &sys_get_time;
|
2023-11-07 22:34:26 +03:00
|
|
|
|
|
|
|
|
|
return module;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-31 19:06:56 +03:00
|
|
|
|
// void sys_set_alarm(time_t time, func_t func) {}
|