Skip to content

Commit

Permalink
Загрузка модулей исправлена
Browse files Browse the repository at this point in the history
  • Loading branch information
0Nera committed Oct 24, 2023
1 parent 6ae0e82 commit fe63787
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 22 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ jobs:
git config --global user.email "[email protected]"
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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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 ..
Expand Down
8 changes: 4 additions & 4 deletions configs/limine.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
MODULE_PATH=boot:///mod/music.so
MODULE_CMDLINE=[MOD]music.so
10 changes: 6 additions & 4 deletions include/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

#include <stdint.h>

typedef struct {
void (*fb_printf)(char *str, ...);
} env_t;

typedef struct {
int reserved;
} framebuffer_t;
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion include/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_BUILD 290
#define VERSION_BUILD 293
4 changes: 3 additions & 1 deletion kernel/mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions modlib/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions modules/helloworld/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ module_info_t static_info = {

uint64_t init(env_t *env) {
init_env(env);
env->fb_printf("Модуль \"Привет мир!\" инициализирован!\n");
return 0;
}
1 change: 1 addition & 0 deletions modules/music/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit fe63787

Please sign in to comment.