2023-10-21 21:23:51 +03:00
|
|
|
|
/**
|
|
|
|
|
* sys.c
|
|
|
|
|
* Файл с функциями управления системой
|
|
|
|
|
*
|
|
|
|
|
* Этот файл содержит имплементацию функций для управления системой
|
|
|
|
|
*/
|
|
|
|
|
|
2023-11-07 22:34:26 +03:00
|
|
|
|
#include <fb.h>
|
2024-01-13 00:00:11 +03:00
|
|
|
|
#include <log.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-12-16 00:13:37 +03:00
|
|
|
|
extern uint32_t *fb_addr;
|
|
|
|
|
extern uint32_t text_color;
|
|
|
|
|
extern uint32_t background;
|
|
|
|
|
extern uint64_t width;
|
|
|
|
|
extern uint64_t height;
|
|
|
|
|
extern uint64_t pitch;
|
|
|
|
|
extern uint16_t bpp;
|
2023-10-31 19:06:56 +03:00
|
|
|
|
|
2023-10-21 20:27:23 +03:00
|
|
|
|
void sys_init( ) {}
|
|
|
|
|
|
2023-12-16 00:13:37 +03:00
|
|
|
|
static framebuffer_t sys_alloc_framebuffer( ) {
|
|
|
|
|
return (framebuffer_t){
|
|
|
|
|
.address = fb_addr, .width = width, .height = height, .pitch = pitch, .bpp = bpp, .reserved = 0
|
|
|
|
|
};
|
2023-10-21 20:27:23 +03:00
|
|
|
|
}
|
|
|
|
|
|
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-18 14:50:37 +03:00
|
|
|
|
env_t *sys_install(env_t *module) {
|
2024-03-03 14:43:11 +03:00
|
|
|
|
module->log_printf = &log_printf;
|
2023-11-18 14:50:37 +03:00
|
|
|
|
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;
|
2024-01-21 19:25:04 +03:00
|
|
|
|
module->mod_list_get = &mod_list_get;
|
2024-09-17 10:05:22 +03:00
|
|
|
|
module->new_thread = &task_new_thread;
|
2024-01-27 22:03:33 +03:00
|
|
|
|
module->delete_thread = &task_del_current;
|
2024-01-22 21:46:36 +03:00
|
|
|
|
module->get_time = &rtc_get_time;
|
2024-09-17 10:05:22 +03:00
|
|
|
|
module->set_int = &idt_set_int;
|
|
|
|
|
module->mod_update_info = &mod_update_info;
|
2024-09-16 21:42:47 +03:00
|
|
|
|
module->ret = NULL;
|
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) {}
|