Skip to content

Commit

Permalink
Переименовал проект в БМПОС
Browse files Browse the repository at this point in the history
  • Loading branch information
0Nera committed Oct 12, 2023
1 parent 8591760 commit fbd3e27
Show file tree
Hide file tree
Showing 18 changed files with 2,239 additions and 222 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.errorSquiggles": "disabled"
}
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# MSEOS: минимальная студенческая обучающая операционная система
# БМПОС: Базовая Модульная Платформа Операционных Систем

[![CI BUILD](https://github.com/0Nera/MSEOS/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/0Nera/MSEOS/actions/workflows/build.yml)
[![Github pages](https://github.com/0Nera/MSEOS/actions/workflows/pages/pages-build-deployment/badge.svg?branch=pages)](https://github.com/0Nera/MSEOS/actions/workflows/pages/pages-build-deployment)
[![CI сборка](https://github.com/0Nera/BMOSP/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/0Nera/MSEOS/actions/workflows/build.yml)
[![Github pages сайт](https://github.com/0Nera/BMOSP/actions/workflows/pages/pages-build-deployment/badge.svg?branch=pages)](https://github.com/0Nera/MSEOS/actions/workflows/pages/pages-build-deployment)

MSEOS - минимальная студенческая обучающая операционная система с открытым исходным кодом для платформы x86_64(BIOS/UEFI). Это отечественная операционная система.
БМПОС - Базовая Модульная Платформа Операционных Систем для платформы x86_64 (BIOS/UEFI). Это отечественное программное обеспечение, созданное при поддержке Синапс ОС на языке программирования C++.

Система:
- [ ] Менеджер памяти
Expand Down Expand Up @@ -41,11 +41,20 @@ MSEOS - минимальная студенческая обучающая оп

- <https://vk.com/mseos> Страница вконтакте
- <https://mseos.ru> Вебсайт
- <https://wiki.synapseos.ru/index.php?title=MSEOS> Страница на вики
- <https://wiki.synapseos.ru/index.php?title=БМПОС> Страница на вики

### Зеркала

- <https://git.synapseos.ru/Aren/MSEOS> - доверенный сервер(главный репозиторий)
- <https://github.com/0Nera/MSEOS> - зеркало
- <https://tvoygit.ru/0Nera/mseos> - зеркало
- <https://hub.mos.ru/synapseos/mseos> - неактивное зеркало
- <https://git.synapseos.ru/Aren/BMOSP> - доверенный сервер(главный репозиторий)
- <https://github.com/0Nera/BMOSP> - зеркало
- <https://tvoygit.ru/0Nera/BMOSP> - зеркало
- <https://hub.mos.ru/synapseos/BMOSP> - неактивное зеркало

### Использованные ресурсы

- https://github.com/limine-bootloader/limine (BSD 2-Clause)
- https://github.com/nothings/stb (MIT, Общественное достояние)
- https://en.wikipedia.org/wiki/CPUID
- https://github.com/klange/toaruos (NCSA)
- https://wiki.osdev.org/Model_Specific_Registers
- https://sandpile.org/x86/msr.htm
61 changes: 49 additions & 12 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,46 @@
from multiprocessing import Pool


CC = "g++"
ARCH_FLAGS = "-m64 -march=x86-64 -mabi=sysv -mno-80387 -mno-red-zone -mcmodel=kernel -MMD -MP"
WARN_FLAGS = "-w -Wall -Wextra"
ARCH_FLAGS = "-m64 -march=x86-64 -mabi=sysv -mno-red-zone -mcmodel=kernel -MMD -MP"
WARN_FLAGS = "-w -Wall -Wextra -nostdlib"
STANDART_FLAGS = "-std=gnu11"
PROTECT_FLAGS = "-O0 -pipe -ffreestanding -fno-stack-protector -fno-lto -fno-stack-check -fno-PIC -fno-PIE"
CHARSET_FLAGS = "-finput-charset=UTF-8 -fexec-charset=cp1251"
LIBS_FLAGS = "-Ilimine -Iinclude"

def version_build():
with open("include/version.h", "r") as file:
lines = file.readlines()

major = 0
minor = 0
build = 0

with open("include/version.h", "w") as file:
for line in lines:
if line.startswith("#define VERSION_BUILD"):
parts = line.split()
build = int(parts[2]) + 1
if build > 255:
build = 0
minor += 1
file.write(f"#define VERSION_MINOR {minor}\n")
file.write(f"#define VERSION_BUILD {build}\n")
elif line.startswith("#define VERSION_MAJOR"):
parts = line.split()
major = int(parts[2])
file.write(line)
elif line.startswith("#define VERSION_MINOR"):
parts = line.split()
minor = int(parts[2])
file.write(line)
else:
file.write(line)

return [major, minor, build]

def sort_strings(strings):
return sorted(strings, key=lambda x: not x.endswith('.s.o'))

def find_files(directory, extensions):
file_list = []
Expand All @@ -24,6 +56,7 @@ def find_files(directory, extensions):


def compile(file: str):
CC = "g++" if file.endswith('cpp') else "gcc"
output_file = file.replace('/', '_')
obj_file = f"bin/{output_file}.o"
cmd = f"{CC} {WARN_FLAGS} {PROTECT_FLAGS} {ARCH_FLAGS} {CHARSET_FLAGS} {LIBS_FLAGS} -c {file} -o {obj_file}"
Expand All @@ -33,7 +66,8 @@ def compile(file: str):


def compile_all():
file_list = find_files("kernel/", [".c", ".cpp", ".s"])
file_list = find_files("kernel/", [".s", ".cpp", ".c"])
file_list += find_files("kernel/*/*", [".s", ".cpp", ".c"])

with Pool() as pool:
results = pool.map(compile, file_list)
Expand All @@ -42,7 +76,7 @@ def compile_all():
print(results)
time.sleep(1)
print(results)
cmd = f"ld -nostdlib -static -m elf_x86_64 -z max-page-size=0x1000 -T configs/linker.ld -o kernel.elf {' '.join(results)}"
cmd = f"ld -nostdlib -static -m elf_x86_64 -z max-page-size=0x1000 -T configs/linker.ld -o kernel.elf {' '.join(sort_strings(results))}"
print(cmd)
os.system(cmd)

Expand Down Expand Up @@ -77,26 +111,29 @@ def create_hdd(IMAGE_NAME):
subprocess.run(["sgdisk", IMAGE_NAME+".hdd", "-n", "1:2048", "-t", "1:ef00"])
subprocess.run(["./limine/limine", "bios-install", IMAGE_NAME+".hdd"])
subprocess.run(["mformat", "-i", IMAGE_NAME+".hdd@@1M"])
subprocess.run(["mmd", "-i", IMAGE_NAME+".hdd@@1M", "::/mod", "::/EFI", "::/EFI/BOOT"])
subprocess.run(["mmd", "-i", IMAGE_NAME+".hdd@@1M", "::/mod", "::/EFI", "::/EFI/BOOT", "::/user"])
subprocess.run(["mcopy", "-i", IMAGE_NAME+".hdd@@1M",
"kernel.elf", "configs/limine.cfg", "limine/limine-bios.sys", "::/"])
subprocess.run(["mcopy", "-i", IMAGE_NAME+".hdd@@1M",
"modules/com/com.elf", "modules/helloworld/helloworld.elf", "::/mod"])
subprocess.run(["mcopy", "-i", IMAGE_NAME+".hdd@@1M",
"limine/BOOTX64.EFI", "limine/BOOTIA32.EFI", "::/EFI/BOOT"])
subprocess.run(["mcopy", "-i", IMAGE_NAME+".hdd@@1M",
"boot.png", "::/"])
subprocess.run(["./limine/limine", "bios-install", IMAGE_NAME+".hdd"])


def create_iso(IMAGE_NAME):
subprocess.run(["rm", "-f", IMAGE_NAME+".iso"])
subprocess.run(["rm", "-rf", "iso_root"])
subprocess.run(["mkdir", "-p", "iso_root"])
subprocess.run(["cp", "-v", "iso_root/"])
subprocess.run(["cp", "-v", "kernel.elf",
subprocess.run(["cp", "-v", "kernel.elf", "boot.png",
"configs/limine.cfg", "limine/limine-bios.sys",
"limine/limine-bios-cd.bin", "limine/limine-uefi-cd.bin",
"iso_root/"])
subprocess.run(["mkdir", "-p", "iso_root/EFI/BOOT"])
subprocess.run(["mkdir", "-p", "iso_root/mod/"])
subprocess.run(["mkdir", "-p", "iso_root/mod"])
subprocess.run(["cp", "-v", "modules/helloworld/helloworld.elf", "iso_root/mod/"])
subprocess.run(["cp", "-v", "modules/com/com.elf", "iso_root/mod/"])
subprocess.run(["cp", "-v", "limine/BOOTX64.EFI", "iso_root/EFI/BOOT/"])
Expand All @@ -107,7 +144,6 @@ def create_iso(IMAGE_NAME):
"-efi-boot-part", "--efi-boot-image", "--protective-msdos-label",
"iso_root", "-o", IMAGE_NAME+".iso"])
subprocess.run(["./limine/limine", "bios-install", IMAGE_NAME+".iso"])
subprocess.run(["rm", "-rf", "iso_root"])

if __name__ == "__main__":
os.system("""find . \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) -print0 | xargs -0 clang-format -i -style=file""")
Expand All @@ -123,7 +159,8 @@ def create_iso(IMAGE_NAME):
check_limine()
check_tools()
compile_all()
create_iso("mseos")
create_hdd("mseos")
create_iso("bmosp")
create_hdd("bmosp")

print("qemu-system-x86_64 -M q35 -m 8G -smp 8 -bios ovmf/OVMF.fd -hda mseos.hdd")
major, minor, build = version_build()
print(f"Не забудьте сохранить изменения! Номер сборки: {major}.{minor}, {build}")
15 changes: 9 additions & 6 deletions configs/limine.cfg
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
GRAPHICS=yes
TIMEOUT=5
DEFAULT_ENTRY=0
INTERFACE_BRANDING=By Aren Elchinyan

BACKGROUND_STYLE=stretched
BACKGROUND_PATH=boot:///boot.png
#TERM_FONT=boot:///CYRILL2.F16
#TERM_FONT_SIZE=8x16

:MSEOS (KASLR on)
:BMOSP (KASLR on)
#RESOLUTION=1280x720
PROTOCOL=limine
KASLR=no
KERNEL_PATH=boot:///kernel.elf

MODULE_PATH=boot:///kernel.elf
MODULE_CMDLINE=boot:///kernel.elf

MODULE_PATH=boot:///mod/helloworld.elf
MODULE_CMDLINE=helloworld

MODULE_PATH=boot:///mod/com.elf
MODULE_CMDLINE=com
MODULE_CMDLINE=com

MODULE_PATH=boot:///boot.png
MODULE_CMDLINE=bootimage
2 changes: 2 additions & 0 deletions deploy_to_sdc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
sudo dd if=mseos.hdd of=/dev/sdc
3 changes: 3 additions & 0 deletions include/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_BUILD 2
36 changes: 22 additions & 14 deletions kernel/arch.cpp → kernel/arch/arch.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
#include <limine.h>

namespace arch {
static volatile struct limine_kernel_address_request kernel_address_request = {
.id = LIMINE_KERNEL_ADDRESS_REQUEST,
.revision = 0,
.response = (struct limine_kernel_address_response *)0
};

struct limine_kernel_address_response *kernel_address_response;

void init( ) {
kernel_address_response = kernel_address_request.response;
}
#include <limine.h>

extern "C" {
void gdt_init( );

void idt_init( );
}

namespace arch {
static volatile struct limine_kernel_address_request kernel_address_request = {
.id = LIMINE_KERNEL_ADDRESS_REQUEST,
.revision = 0,
.response = (struct limine_kernel_address_response *)0
};

struct limine_kernel_address_response *kernel_address_response;

void init( ) {
kernel_address_response = kernel_address_request.response;
gdt_init( );
idt_init( );
}
} // namespace arch
Loading

0 comments on commit fbd3e27

Please sign in to comment.