Изменение логики загрузки модулей

This commit is contained in:
Aren Elchinyan 2023-10-15 18:45:09 +03:00
parent c2aef230fc
commit c8347f0d5f
5 changed files with 55 additions and 36 deletions

44
include/sys.h Normal file
View File

@ -0,0 +1,44 @@
#include <stdint.h>
typedef struct {
void (*fb_printf)(char *str, ...);
} env_t;
typedef struct {
int reserved;
} framebuffer_t;
typedef struct {
int reserved;
} sys_info_t;
typedef struct {
char *name;
void *addr;
} module_func_t;
typedef struct {
char *name;
char *message;
int err_code;
uint64_t func_count;
module_func_t *func[];
} module_info_t;
typedef struct {
int reserved;
} func_t;
typedef struct {
uint8_t a[4];
uint8_t b[4];
uint8_t c[4];
uint8_t d[4];
} uid_t;
typedef struct {
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t second;
} time_t;

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 1 #define VERSION_MINOR 1
#define VERSION_BUILD 40 #define VERSION_BUILD 61

View File

@ -48,6 +48,8 @@ void init( ) {
bpp = boot_framebuffer->bpp; bpp = boot_framebuffer->bpp;
for (uint64_t i = 0; i < width * height; i++) { fb_addr[i] = background; } for (uint64_t i = 0; i < width * height; i++) { fb_addr[i] = background; }
fb::printf("0x%x %ux%u\n", fb_addr, width, height);
} }
static inline void print_bits(size_t x, size_t y, uint8_t num) { static inline void print_bits(size_t x, size_t y, uint8_t num) {

View File

@ -1,6 +1,7 @@
#include <fb.h> #include <fb.h>
#include <limine.h> #include <limine.h>
#include <mod.h> #include <mod.h>
#include <sys.h>
// Структуры соответствующие ELF заголовкам // Структуры соответствующие ELF заголовкам
typedef struct { typedef struct {
@ -86,15 +87,16 @@ void init( ) {
module_ptr->mbr_disk_id, module_ptr->tftp_ip, module_ptr->mbr_disk_id, module_ptr->tftp_ip,
module_ptr->tftp_port); module_ptr->tftp_port);
long long (*module_init)(env_t * env) = (long long (*)(env_t * env)) module_info_t *(*module_init)(env_t * env) =
(module_info_t * (*)(env_t * env))
elf_entry(module_ptr->address, module_ptr->size); elf_entry(module_ptr->address, module_ptr->size);
fb::printf("\t->Точка входа: 0x%x\n", module_init); fb::printf("\t->Точка входа: 0x%x\n", module_init);
int ret = module_init(&main_env); module_info_t *ret = module_init(&main_env);
fb::printf("Инициализированно с кодом: %x\n", ret); fb::printf("Инициализированно с кодом: %u\n", ret->err_code);
fb::printf("Сообщение из модуля: %s\n\n", (char *)ret); fb::printf("Сообщение из модуля: %s\n\n", ret->message);
} }
} }
} // namespace mod } // namespace mod

View File

@ -1,34 +1,5 @@
#include <stdint.h> #include <stdint.h>
#include <sys.h>
typedef struct {
int reserved;
} framebuffer_t;
typedef struct {
int reserved;
} sys_info_t;
typedef struct {
int reserved;
} module_info_t;
typedef struct {
int reserved;
} func_t;
typedef struct {
uint8_t a[4];
uint8_t b[4];
uint8_t c[4];
uint8_t d[4];
} uid_t;
typedef struct {
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t second;
} time_t;
namespace sys { namespace sys {
void init( ) {} void init( ) {}