mirror of https://github.com/0Nera/BMOSP.git
Merge branch 'master' of https://git.synapseos.ru/Aren/BMOSP
This commit is contained in:
commit
a477da15b5
|
@ -13,10 +13,10 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
- name: install depends
|
||||
run: sudo apt install clang-format python3 git gdisk gcc g++ xorriso make mtools curl dos2unix
|
||||
|
||||
|
||||
- name: install limine
|
||||
run: |
|
||||
git clone https://git.synapseos.ru/Aren/limine.git --branch=v5.x-branch-binary --depth=1
|
||||
|
|
|
@ -6,10 +6,11 @@ ovmf/
|
|||
iso_root/
|
||||
output/
|
||||
sdk/
|
||||
_sdk/
|
||||
*.so
|
||||
*.o
|
||||
*.ko
|
||||
*.elf
|
||||
*.zip
|
||||
*.log
|
||||
*.lck
|
||||
*.zip
|
||||
*.log
|
||||
*.lck
|
||||
|
|
4
build.sh
4
build.sh
|
@ -7,7 +7,9 @@ chmod +x */build.sh
|
|||
|
||||
for dir in */; do
|
||||
if [ $dir != "bin/" ]; then
|
||||
cd $dir && ./build.sh && cd ..
|
||||
cd $dir
|
||||
./build.sh
|
||||
cd ..
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ static inline void pause( ) {
|
|||
void tool_memcpy(void *dest, void *src, uint64_t n);
|
||||
void *tool_memset(void *ptr, uint8_t n, uint64_t size);
|
||||
uint64_t tool_strlen(const char *str);
|
||||
void tool_strcpy(char *dest, char *src);
|
||||
uint64_t tool_starts_with(const char *str, const char *prefix);
|
||||
void tool_format(void (*putc)(char c), const char *format_string, va_list args);
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* debug.c
|
||||
* Функции отладочных сообщений
|
||||
*
|
||||
* Функционал управления выводом отладочных сообщений
|
||||
*
|
||||
*/
|
||||
|
||||
#include <fb.h>
|
||||
#include <mem.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <tool.h>
|
||||
|
||||
typedef struct msg {
|
||||
uint64_t level;
|
||||
char *message;
|
||||
struct msg *next;
|
||||
} msg_t;
|
||||
|
||||
msg_t *log = NULL;
|
||||
msg_t *last_message = NULL;
|
||||
|
||||
uint32_t level_colors[] = {
|
||||
0x0000FF00, // Зеленый
|
||||
0x00FFFF00, // Желтый
|
||||
0x00FF0000, // Красный
|
||||
0x0000FFFF, // Голубой
|
||||
0x000000FF, // Синий
|
||||
0x00FF00FF // Пурпурный
|
||||
};
|
||||
|
||||
// Функция для добавления сообщения в лог
|
||||
void add_message(uint64_t level, char *message) {
|
||||
msg_t *new_msg = (msg_t *)mem_alloc(sizeof(msg_t));
|
||||
|
||||
new_msg->level = level;
|
||||
new_msg->message = mem_alloc(tool_strlen(message) + 1);
|
||||
tool_strcpy(new_msg->message, message);
|
||||
|
||||
new_msg->next = NULL;
|
||||
|
||||
if (log == NULL) {
|
||||
log = new_msg;
|
||||
} else {
|
||||
msg_t *current = log;
|
||||
while (current->next != NULL) { current = current->next; }
|
||||
current->next = new_msg;
|
||||
}
|
||||
last_message = new_msg;
|
||||
}
|
||||
|
||||
// Функция для добавления символа в сообщение
|
||||
void add_char_to_message(char c, msg_t *msg) {
|
||||
uint64_t length = tool_strlen(msg->message);
|
||||
msg->message = mem_realloc(msg->message, length + 1);
|
||||
msg->message[length] = c;
|
||||
msg->message[length + 1] = '\0';
|
||||
}
|
||||
|
||||
void debug_putc(char c) {
|
||||
add_char_to_message(c, last_message);
|
||||
}
|
||||
|
||||
void debug_printf(uint8_t level, char *info, char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
add_message(level, info);
|
||||
tool_format(debug_putc, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// Функция для вывода всего лога
|
||||
void print_log( ) {
|
||||
msg_t *current = log;
|
||||
while (current != NULL) {
|
||||
fb_set_text_color(level_colors[current->level]);
|
||||
fb_printf("Message: %s\n", current->message);
|
||||
fb_set_text_color(0x00D000);
|
||||
current = current->next;
|
||||
}
|
||||
}
|
10
kernel/mod.c
10
kernel/mod.c
|
@ -33,8 +33,12 @@ uint64_t bootpng_size;
|
|||
static void *elf_entry(elf64_header_t *module_bin) {
|
||||
// Приводим заголовок ELF файла к типу elf64_header_t
|
||||
elf64_header_t *elf_header = (elf64_header_t *)module_bin;
|
||||
LOG("(uint64_t)elf_header->e_entry = 0x%x\n",
|
||||
(uint64_t)elf_header->e_entry);
|
||||
LOG("(uint64_t)elf_header->e_entry = 0x%x, type = %u\n",
|
||||
(uint64_t)elf_header->e_entry, elf_header->e_type);
|
||||
if (elf_header->e_type != 2) {
|
||||
fb_printf("\t\tОшибка! Модуль неправильно собран!\n");
|
||||
for (;;) {}
|
||||
}
|
||||
// Возвращаем указатель на точку входа
|
||||
return (void *)((uint64_t)elf_header->e_entry + (uint64_t)module_bin);
|
||||
}
|
||||
|
@ -99,7 +103,7 @@ void mod_init( ) {
|
|||
continue;
|
||||
}
|
||||
|
||||
module_info_t (*module_init)(env_t *env) =
|
||||
module_info_t (*module_init)(env_t * env) =
|
||||
(module_info_t(*)(env_t * env))
|
||||
elf_entry((elf64_header_t *)module_ptr->address);
|
||||
|
||||
|
|
|
@ -32,6 +32,15 @@ uint64_t tool_strlen(const char *str) {
|
|||
return length;
|
||||
}
|
||||
|
||||
void tool_strcpy(char *dest, char *src) {
|
||||
uint64_t i = 0;
|
||||
while (src[i] != '\0') {
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dest[i] = '\0';
|
||||
}
|
||||
|
||||
uint64_t tool_starts_with(const char *str, const char *prefix) {
|
||||
uint64_t str_len = tool_strlen(str);
|
||||
uint64_t prefix_len = tool_strlen(prefix);
|
||||
|
|
|
@ -3,7 +3,7 @@ echo "Название: CPUBENCH"
|
|||
echo "Лицензия: Публичное достояние"
|
||||
|
||||
CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -static -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
|
|
|
@ -3,7 +3,7 @@ echo "Название: Hello world"
|
|||
echo "Лицензия: Публичное достояние"
|
||||
|
||||
CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -static -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
|
|
|
@ -3,7 +3,7 @@ echo "Название: Мелодия из тетриса"
|
|||
echo "Лицензия: Публичное достояние"
|
||||
|
||||
CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -static -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
|
|
|
@ -4,7 +4,7 @@ echo "Лицензия: Публичное достояние"
|
|||
|
||||
|
||||
CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -static -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
|
|
|
@ -3,7 +3,7 @@ echo "Название: SIMD"
|
|||
echo "Лицензия: Публичное достояние"
|
||||
|
||||
CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -static -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
|
|
Loading…
Reference in New Issue