From fe637878215195ce9500deecdc6cc38f37c07a32 Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Tue, 24 Oct 2023 23:53:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5=D0=B9=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 7 +++++-- .github/workflows/release.yml | 13 ++++++------- README.md | 2 +- build.sh | 1 + configs/limine.cfg | 8 ++++---- include/sys.h | 10 ++++++---- include/version.h | 2 +- kernel/mod.c | 4 +++- modlib/system.h | 6 ++++-- modules/helloworld/main.c | 1 + modules/music/main.c | 1 + 11 files changed, 33 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 03e0dae..ae696c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,14 +15,17 @@ jobs: - uses: actions/checkout@v3 - name: install depends - run: sudo apt install clang-format python3 git gdisk gcc g++ xorriso make mtools curl + run: sudo apt install clang-format python3 git gdisk gcc g++ xorriso make mtools curl dos2unix - name: install limine run: | git clone https://github.com/limine-bootloader/limine.git --branch=v5.x-branch-binary --depth=1 - name: build - run: chmod +x build.sh && ./build.sh + run: | + dos2unix *.sh + chmod +x build.sh + ./build.sh - name: check root dir run: ls -la diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dde0e97..a3102f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,19 +21,18 @@ jobs: git config --global user.email "github@github.com" git config --global user.name "Build bot" - - name: install depends - run: sudo apt install clang-format python3 git gdisk gcc g++ xorriso make mtools curl + run: sudo apt install clang-format python3 git gdisk gcc g++ xorriso make mtools curl dos2unix - name: install limine run: | git clone https://github.com/limine-bootloader/limine.git --branch=v5.x-branch-binary --depth=1 - - name: Build - run: | - ./build.sh - cp kernel.elf x86_64-kernel.elf - cp mseos.hdd x86_64-mseos.hdd + - name: build + run: | + dos2unix *.sh + chmod +x build.sh + ./build.sh - name: Add and commit files uses: EndBug/add-and-commit@v9 diff --git a/README.md b/README.md index b37552d..3a3b579 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ ### Ubuntu 18.04+ ```bash -sudo apt install clang-format python3 git qemu-system-x86 gdisk +sudo apt install clang-format python3 git qemu-system-x86 gdisk dos2unix git clone https://git.synapseos.ru/Aren/BMOSP.git cd BMOSP/ chmod +x build.sh diff --git a/build.sh b/build.sh index 95788e3..a76fa1d 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,6 @@ #!/bin/sh cd modules/ +dos2unix */*.sh cd helloworld/ && chmod +x build.sh && ./build.sh && cd .. cd music/ && chmod +x build.sh && ./build.sh && cd .. cd .. diff --git a/configs/limine.cfg b/configs/limine.cfg index c1402f1..a88e74a 100644 --- a/configs/limine.cfg +++ b/configs/limine.cfg @@ -15,11 +15,11 @@ BACKGROUND_PATH=boot:///boot.tga KASLR=no KERNEL_PATH=boot:///kernel.elf - MODULE_PATH=boot:///mod/music.so - MODULE_CMDLINE=[MOD]music.so + MODULE_PATH=boot:///boot.tga + MODULE_CMDLINE=[BOOTIMG] MODULE_PATH=boot:///mod/hello.so MODULE_CMDLINE=[MOD]hello.so - MODULE_PATH=boot:///boot.tga - MODULE_CMDLINE=[BOOTIMG] \ No newline at end of file + MODULE_PATH=boot:///mod/music.so + MODULE_CMDLINE=[MOD]music.so \ No newline at end of file diff --git a/include/sys.h b/include/sys.h index 79c6f66..fdf0340 100644 --- a/include/sys.h +++ b/include/sys.h @@ -12,10 +12,6 @@ #include -typedef struct { - void (*fb_printf)(char *str, ...); -} env_t; - typedef struct { int reserved; } framebuffer_t; @@ -54,4 +50,10 @@ typedef struct { uint8_t second; } time_t; +typedef struct { + uint64_t offset; + module_info_t *info; + void (*fb_printf)(char *str, ...); +} env_t; + #endif // sys.h \ No newline at end of file diff --git a/include/version.h b/include/version.h index 9a570c4..b5a16ca 100644 --- a/include/version.h +++ b/include/version.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 1 -#define VERSION_BUILD 290 +#define VERSION_BUILD 293 diff --git a/kernel/mod.c b/kernel/mod.c index e0942f7..f71149a 100644 --- a/kernel/mod.c +++ b/kernel/mod.c @@ -63,7 +63,6 @@ static struct limine_module_response *module_response; static uint64_t modules_count = 0; void mod_init( ) { - main_env.fb_printf = &fb_printf; module_response = module_request.response; uint64_t module_count = module_response->module_count; struct limine_file *module_ptr = (struct limine_file *)0; @@ -92,6 +91,9 @@ void mod_init( ) { fb_printf("\t->Точка входа: 0x%x\n", module_init); + main_env.offset = module_ptr->address; + main_env.info = (module_info_t *)0; + main_env.fb_printf = &fb_printf; uint64_t ret = module_init(&main_env); fb_printf("Инициализированно с кодом: %u\n", ret); diff --git a/modlib/system.h b/modlib/system.h index e877ff8..20bdf44 100644 --- a/modlib/system.h +++ b/modlib/system.h @@ -59,8 +59,10 @@ typedef struct { void (*fb_printf)(char *str, ...); } env_t; -void (*fb_printf)(char *str, ...); +extern module_info_t static_info; -static inline void init_env(env_t *loader_env) {} +static inline void init_env(env_t *loader_env) { + loader_env->info = (module_info_t *)&static_info + loader_env->offset; +} #endif // system.h diff --git a/modules/helloworld/main.c b/modules/helloworld/main.c index d047c25..c960734 100644 --- a/modules/helloworld/main.c +++ b/modules/helloworld/main.c @@ -8,5 +8,6 @@ module_info_t static_info = { uint64_t init(env_t *env) { init_env(env); + env->fb_printf("Модуль \"Привет мир!\" инициализирован!\n"); return 0; } diff --git a/modules/music/main.c b/modules/music/main.c index 1d4400a..87cc05a 100644 --- a/modules/music/main.c +++ b/modules/music/main.c @@ -18,6 +18,7 @@ static inline void play_sound(unsigned int frequency) {} int init(env_t *env) { init_env(env); + env->fb_printf("Программа инициализирована!\n"); return 0; // Массив с нотами unsigned int tetris_notes[] = { 0 };