mirror of
https://github.com/0Nera/BMOSP.git
synced 2024-11-22 00:21:22 +03:00
Замена пробелов на таб
This commit is contained in:
parent
4244853b13
commit
11f07cb832
48
.github/workflows/build.yml
vendored
48
.github/workflows/build.yml
vendored
@ -2,37 +2,37 @@ name: CI BUILD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore: [ "pages" ]
|
||||
branches-ignore: [ "pages" ]
|
||||
pull_request:
|
||||
branches-ignore: [ "pages" ]
|
||||
branches-ignore: [ "pages" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
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
|
||||
cd limine && make && cd ..
|
||||
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
|
||||
cd limine && make && cd ..
|
||||
|
||||
- name: build
|
||||
run: |
|
||||
dos2unix *.sh
|
||||
chmod +x build.sh
|
||||
./build.sh
|
||||
- name: build
|
||||
run: |
|
||||
dos2unix *.sh
|
||||
chmod +x build.sh
|
||||
./build.sh
|
||||
|
||||
- name: check root dir
|
||||
run: ls -la
|
||||
- name: check root dir
|
||||
run: ls -la
|
||||
|
||||
- name: check iso_root
|
||||
run: ls -la iso_root
|
||||
- name: check iso_root
|
||||
run: ls -la iso_root
|
||||
|
||||
- name: check bin
|
||||
run: ls -la bin
|
||||
- name: check bin
|
||||
run: ls -la bin
|
118
.github/workflows/release.yml
vendored
118
.github/workflows/release.yml
vendored
@ -2,74 +2,74 @@ name: release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
test_label:
|
||||
required: true
|
||||
type: string
|
||||
inputs:
|
||||
test_label:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
x86_64:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- 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
|
||||
cd limine && make && cd ..
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- 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
|
||||
cd limine && make && cd ..
|
||||
|
||||
- name: build
|
||||
run: |
|
||||
dos2unix *.sh
|
||||
chmod +x build.sh
|
||||
./build.sh
|
||||
- name: build
|
||||
run: |
|
||||
dos2unix *.sh
|
||||
chmod +x build.sh
|
||||
./build.sh
|
||||
|
||||
- name: save
|
||||
run: |
|
||||
mkdir -p ${{ github.workspace }}/rel
|
||||
cp ${{ github.workspace }}/kernel.elf ${{ github.workspace }}/rel/
|
||||
cp ${{ github.workspace }}/bmosp.hdd ${{ github.workspace }}/rel/
|
||||
cp ${{ github.workspace }}/bmosp.iso ${{ github.workspace }}/rel/
|
||||
cp ${{ github.workspace }}/LICENSE ${{ github.workspace }}/rel/
|
||||
- name: save
|
||||
run: |
|
||||
mkdir -p ${{ github.workspace }}/rel
|
||||
cp ${{ github.workspace }}/kernel.elf ${{ github.workspace }}/rel/
|
||||
cp ${{ github.workspace }}/bmosp.hdd ${{ github.workspace }}/rel/
|
||||
cp ${{ github.workspace }}/bmosp.iso ${{ github.workspace }}/rel/
|
||||
cp ${{ github.workspace }}/LICENSE ${{ github.workspace }}/rel/
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bmosp.hdd
|
||||
path: ${{ github.workspace }}/bmosp.hdd
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bmosp.hdd
|
||||
path: ${{ github.workspace }}/bmosp.hdd
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bmosp.iso
|
||||
path: ${{ github.workspace }}/bmosp.iso
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bmosp.iso
|
||||
path: ${{ github.workspace }}/bmosp.iso
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: kernel.elf
|
||||
path: ${{ github.workspace }}/kernel.elf
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: kernel.elf
|
||||
path: ${{ github.workspace }}/kernel.elf
|
||||
|
||||
- name: check
|
||||
run: |
|
||||
echo ${{ github.workspace }}/rel/
|
||||
ls -la ${{ github.workspace }}/rel/
|
||||
|
||||
- name: release
|
||||
uses: softprops/action-gh-release@v0.1.15
|
||||
with:
|
||||
name: ${{ inputs.test_label }}
|
||||
tag_name: autobuild
|
||||
draft: true
|
||||
files: |
|
||||
${{ github.workspace }}/rel/kernel.elf
|
||||
${{ github.workspace }}/rel/bmosp.hdd
|
||||
${{ github.workspace }}/rel/bmosp.iso
|
||||
${{ github.workspace }}/rel/LICENSE
|
||||
- name: check
|
||||
run: |
|
||||
echo ${{ github.workspace }}/rel/
|
||||
ls -la ${{ github.workspace }}/rel/
|
||||
|
||||
- name: release
|
||||
uses: softprops/action-gh-release@v0.1.15
|
||||
with:
|
||||
name: ${{ inputs.test_label }}
|
||||
tag_name: autobuild
|
||||
draft: true
|
||||
files: |
|
||||
${{ github.workspace }}/rel/kernel.elf
|
||||
${{ github.workspace }}/rel/bmosp.hdd
|
||||
${{ github.workspace }}/rel/bmosp.iso
|
||||
${{ github.workspace }}/rel/LICENSE
|
||||
|
||||
body: |
|
||||
${{ inputs.test_label }}
|
||||
body: |
|
||||
${{ inputs.test_label }}
|
||||
|
||||
Использовать на свой страх и риск. Система расчитана на работу в эмулируемой среде Qemu под процессоры x86_64.
|
||||
Мы не несем ответственности за нанесенный ущерб.
|
||||
Использовать на свой страх и риск. Система расчитана на работу в эмулируемой среде Qemu под процессоры x86_64.
|
||||
Мы не несем ответственности за нанесенный ущерб.
|
35
.vscode/settings.json
vendored
35
.vscode/settings.json
vendored
@ -1,19 +1,20 @@
|
||||
{
|
||||
"C_Cpp.errorSquiggles": "disabled",
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"bitset": "cpp",
|
||||
"string_view": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"complex": "cpp",
|
||||
"string": "cpp",
|
||||
"limine.h": "c",
|
||||
"tool.h": "c",
|
||||
"sys.h": "c",
|
||||
"arch.h": "c",
|
||||
"fb.h": "c",
|
||||
"system.h": "c",
|
||||
"mod.h": "c",
|
||||
"modstd.h": "c"
|
||||
}
|
||||
"C_Cpp.errorSquiggles": "disabled",
|
||||
"files.eol": "\n",
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"bitset": "cpp",
|
||||
"string_view": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"complex": "cpp",
|
||||
"string": "cpp",
|
||||
"limine.h": "c",
|
||||
"tool.h": "c",
|
||||
"sys.h": "c",
|
||||
"arch.h": "c",
|
||||
"fb.h": "c",
|
||||
"system.h": "c",
|
||||
"mod.h": "c",
|
||||
"modstd.h": "c"
|
||||
}
|
||||
}
|
6
build.sh
6
build.sh
@ -6,9 +6,9 @@ dos2unix */*.sh
|
||||
chmod +x */build.sh
|
||||
|
||||
for dir in */; do
|
||||
if [ $dir != "bin/" ]; then
|
||||
cd $dir && ./build.sh && cd ..
|
||||
fi
|
||||
if [ $dir != "bin/" ]; then
|
||||
cd $dir && ./build.sh && cd ..
|
||||
fi
|
||||
done
|
||||
|
||||
cd ..
|
||||
|
@ -9,27 +9,27 @@ TERM_WALLPAPER=boot:///boot.jpg
|
||||
#TERM_FONT_SIZE=8x16
|
||||
|
||||
:BMOSP (KASLR off)
|
||||
#RESOLUTION=640x480
|
||||
#RESOLUTION=1024x768
|
||||
RESOLUTION=1280x720
|
||||
PROTOCOL=limine
|
||||
KASLR=no
|
||||
KERNEL_PATH=boot:///kernel.elf
|
||||
#RESOLUTION=640x480
|
||||
#RESOLUTION=1024x768
|
||||
RESOLUTION=1280x720
|
||||
PROTOCOL=limine
|
||||
KASLR=no
|
||||
KERNEL_PATH=boot:///kernel.elf
|
||||
|
||||
MODULE_PATH=boot:///mod/cpubench.ko
|
||||
MODULE_CMDLINE=[MOD]cpubench.ko
|
||||
MODULE_PATH=boot:///mod/cpubench.ko
|
||||
MODULE_CMDLINE=[MOD]cpubench.ko
|
||||
|
||||
MODULE_PATH=boot:///mod/simd.ko
|
||||
MODULE_CMDLINE=[MOD]simd.ko
|
||||
MODULE_PATH=boot:///mod/simd.ko
|
||||
MODULE_CMDLINE=[MOD]simd.ko
|
||||
|
||||
MODULE_PATH=boot:///mod/pci_vendors.txt
|
||||
MODULE_CMDLINE=[PCI][DATA][VENDORS]
|
||||
MODULE_PATH=boot:///mod/pci_vendors.txt
|
||||
MODULE_CMDLINE=[PCI][DATA][VENDORS]
|
||||
|
||||
MODULE_PATH=boot:///mod/pci_data.ko
|
||||
MODULE_CMDLINE=[MOD]pci_data.ko
|
||||
MODULE_PATH=boot:///mod/pci_data.ko
|
||||
MODULE_CMDLINE=[MOD]pci_data.ko
|
||||
|
||||
MODULE_PATH=boot:///mod/pci.ko
|
||||
MODULE_CMDLINE=[MOD]pci.ko
|
||||
MODULE_PATH=boot:///mod/pci.ko
|
||||
MODULE_CMDLINE=[MOD]pci.ko
|
||||
|
||||
MODULE_PATH=boot:///boot.tga
|
||||
MODULE_CMDLINE=[BOOTIMG]
|
||||
MODULE_PATH=boot:///boot.tga
|
||||
MODULE_CMDLINE=[BOOTIMG]
|
@ -9,55 +9,56 @@ ENTRY(_start)
|
||||
/* разрешения MMU */
|
||||
PHDRS
|
||||
{
|
||||
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
|
||||
rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */
|
||||
data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */
|
||||
dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2)) ; /* Динамический PHDR для учёта перерасположений */
|
||||
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
|
||||
rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */
|
||||
data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */
|
||||
dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2)) ; /* Динамический PHDR для учёта перерасположений */
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* Мы хотим быть размещены в верхних 2 ГБ адресного пространства, для оптимизации */
|
||||
/* и потому что это предписывает спецификация Limine. */
|
||||
/* Любой адрес в этом регионе подойдет, но часто выбирают 0xffffffff80000000, так как это */
|
||||
/* начало региона. */
|
||||
. = 0xffffffff80000000;
|
||||
/* Мы хотим быть размещены в верхних 2 ГБ адресного пространства, для оптимизации */
|
||||
/* и потому что это предписывает спецификация Limine. */
|
||||
/* Любой адрес в этом регионе подойдет, но часто выбирают 0xffffffff80000000, так как это */
|
||||
/* начало региона. */
|
||||
. = 0xffffffff80000000;
|
||||
|
||||
.text : {
|
||||
*(.text .text.*)
|
||||
} :text
|
||||
.text : {
|
||||
*(.text .text.*)
|
||||
} :text
|
||||
|
||||
/* Переходим на следующую страницу памяти для .rodata */
|
||||
. += CONSTANT(MAXPAGESIZE);
|
||||
/* Переходим на следующую страницу памяти для .rodata */
|
||||
. += CONSTANT(MAXPAGESIZE);
|
||||
|
||||
.rodata : {
|
||||
*(.rodata .rodata.*)
|
||||
} :rodata
|
||||
.rodata : {
|
||||
*(.rodata .rodata.*)
|
||||
} :rodata
|
||||
|
||||
/* Переходим на следующую страницу памяти для .data */
|
||||
. += CONSTANT(MAXPAGESIZE);
|
||||
/* Переходим на следующую страницу памяти для .data */
|
||||
. += CONSTANT(MAXPAGESIZE);
|
||||
|
||||
.data : {
|
||||
*(.data .data.*)
|
||||
} :data
|
||||
.data : {
|
||||
*(.data .data.*)
|
||||
} :data
|
||||
|
||||
/* Динамический раздел для перерасположений, как в собственном PHDR, так и внутри раздела data */
|
||||
.dynamic : {
|
||||
*(.dynamic)
|
||||
} :data :dynamic
|
||||
/* Динамический раздел для перерасположений, как в собственном PHDR, так и внутри раздела data */
|
||||
.dynamic : {
|
||||
*(.dynamic)
|
||||
} :data :dynamic
|
||||
|
||||
/* Примечание: .bss должен быть последней вещью, отображаемой в раздел data, иначе много */
|
||||
/* ненужных нулей будет записано в бинарный файл. */
|
||||
/* Если вам, например, нужны .init_array и .fini_array, они должны быть размещены */
|
||||
/* выше этого. */
|
||||
.bss : {
|
||||
*(.bss .bss.*)
|
||||
*(COMMON)
|
||||
} :data
|
||||
/* Примечание: .bss должен быть последней вещью, отображаемой в раздел data, иначе много */
|
||||
/* ненужных нулей будет записано в бинарный файл. */
|
||||
/* Если вам, например, нужны .init_array и .fini_array, они должны быть размещены */
|
||||
/* выше этого. */
|
||||
.bss : {
|
||||
*(.bss .bss.*)
|
||||
*(COMMON)
|
||||
} :data
|
||||
|
||||
/* Игнорируем разделы .note.* и .eh_frame, так как они могут вызывать проблемы на некоторых хостах. */
|
||||
/DISCARD/ : {
|
||||
*(.eh_frame)
|
||||
*(.note .note.*)
|
||||
}
|
||||
/* Игнорируем разделы .note.* и .eh_frame, так как они могут вызывать проблемы на некоторых хостах. */
|
||||
/DISCARD/ : {
|
||||
*(.comment)
|
||||
*(.eh_frame)
|
||||
*(.note .note.*)
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
// Название шрифта 6x8 Slim
|
||||
// Автор шрифта Riva
|
||||
// Название шрифта 6x8 Slim
|
||||
// Автор шрифта Riva
|
||||
// Дата и время генерации 06.06.2023 19:38:19
|
||||
// Сгенерировано matrixFont v1.1.0.52
|
||||
// Кодовая страница 1251 (ANSI - кириллица)
|
||||
// Сгенерировано matrixFont v1.1.0.52
|
||||
// Кодовая страница 1251 (ANSI - кириллица)
|
||||
// https://gitlab.com/riva-lab/matrixFont
|
||||
|
||||
#ifndef FONT_6X8_SLIM_H
|
||||
|
@ -1,3 +1,3 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 1
|
||||
#define VERSION_BUILD 759
|
||||
#define VERSION_BUILD 760
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,15 @@
|
||||
.global load_gdt
|
||||
load_gdt:
|
||||
cli
|
||||
lgdt (%rdi)
|
||||
movw $0x30, %ax
|
||||
mov %ax, %ds
|
||||
mov %ax, %es
|
||||
mov %ax, %fs
|
||||
mov %ax, %gs
|
||||
mov %ax, %ss
|
||||
pop %rdi
|
||||
mov $0x28, %rax
|
||||
push %rax
|
||||
push %rdi
|
||||
retfq
|
||||
cli
|
||||
lgdt (%rdi)
|
||||
movw $0x30, %ax
|
||||
mov %ax, %ds
|
||||
mov %ax, %es
|
||||
mov %ax, %fs
|
||||
mov %ax, %gs
|
||||
mov %ax, %ss
|
||||
pop %rdi
|
||||
mov $0x28, %rax
|
||||
push %rax
|
||||
push %rdi
|
||||
retfq
|
||||
|
@ -99,7 +99,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);
|
||||
|
||||
|
@ -6,7 +6,7 @@ CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ CC="gcc"
|
||||
ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -shared -nostdlib "
|
||||
|
||||
if [ -d "../../sdk" ]; then
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
CC="../../sdk/bin/x86_64-elf-gcc"
|
||||
fi
|
||||
|
||||
|
||||
|
284
pbuild.py
284
pbuild.py
@ -9,7 +9,7 @@ __VERSION = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).dec
|
||||
|
||||
output = subprocess.check_output(["git", "status", "-s"]).decode('utf-8').strip()
|
||||
if "^.M" in output:
|
||||
__VERSION = __VERSION
|
||||
__VERSION = __VERSION
|
||||
|
||||
ARCH_FLAGS = "-m64 -march=x86-64 -mabi=sysv -mno-red-zone -mcmodel=kernel -MMD -MP"
|
||||
WARN_FLAGS = "-Wall -Wextra -nostdlib"
|
||||
@ -20,189 +20,189 @@ LIBS_FLAGS = "-Ilimine -Iinclude"
|
||||
FORMAT_CMD = """find . \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) -print0 | xargs -0 clang-format -i -style=file"""
|
||||
|
||||
def version_build():
|
||||
with open("include/version.h", "r") as file:
|
||||
lines = file.readlines()
|
||||
with open("include/version.h", "r") as file:
|
||||
lines = file.readlines()
|
||||
|
||||
major = 0
|
||||
minor = 0
|
||||
build = 0
|
||||
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 > 999:
|
||||
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)
|
||||
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 > 999:
|
||||
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]
|
||||
return [major, minor, build]
|
||||
|
||||
def sort_strings(strings):
|
||||
return sorted(strings, key=lambda x: not x.endswith('.s.o'))
|
||||
return sorted(strings, key=lambda x: not x.endswith('.s.o'))
|
||||
|
||||
def find_files(directory, extensions):
|
||||
file_list = []
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
if any(file.endswith(extension) for extension in extensions):
|
||||
file_list.append(os.path.join(root, file))
|
||||
return file_list
|
||||
file_list = []
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
if any(file.endswith(extension) for extension in extensions):
|
||||
file_list.append(os.path.join(root, file))
|
||||
return file_list
|
||||
|
||||
|
||||
def compile(file: str):
|
||||
CC = "gcc"
|
||||
if os.path.isdir("sdk"):
|
||||
CC = "./sdk/bin/x86_64-elf-gcc"
|
||||
output_file = file.replace('/', '_')
|
||||
obj_file = f"bin/{output_file}.o"
|
||||
cmd = f"{CC} {WARN_FLAGS} {STANDART_FLAGS} {PROTECT_FLAGS} {ARCH_FLAGS} {CHARSET_FLAGS} {LIBS_FLAGS} -c {file} -o {obj_file}"
|
||||
print(cmd)
|
||||
os.system(cmd)
|
||||
return obj_file
|
||||
CC = "gcc"
|
||||
if os.path.isdir("sdk"):
|
||||
CC = "./sdk/bin/x86_64-elf-gcc"
|
||||
output_file = file.replace('/', '_')
|
||||
obj_file = f"bin/{output_file}.o"
|
||||
cmd = f"{CC} {WARN_FLAGS} {STANDART_FLAGS} {PROTECT_FLAGS} {ARCH_FLAGS} {CHARSET_FLAGS} {LIBS_FLAGS} -c {file} -o {obj_file}"
|
||||
print(cmd)
|
||||
os.system(cmd)
|
||||
return obj_file
|
||||
|
||||
|
||||
def compile_all():
|
||||
file_list = find_files("kernel/", [".s", ".cpp", ".c"])
|
||||
file_list += find_files("kernel/*/*", [".s", ".cpp", ".c"])
|
||||
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)
|
||||
with Pool() as pool:
|
||||
results = pool.map(compile, file_list)
|
||||
|
||||
while not all(results):
|
||||
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(sort_strings(results))}"
|
||||
print(cmd)
|
||||
os.system(cmd)
|
||||
while not all(results):
|
||||
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(sort_strings(results))}"
|
||||
print(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
def check_limine():
|
||||
if not os.path.isdir("limine"):
|
||||
subprocess.run(["git", "clone", "https://git.synapseos.ru/Aren/limine.git", "--branch=v5.x-branch-binary", "--depth=1"])
|
||||
else:
|
||||
os.chdir("limine")
|
||||
subprocess.run(["git", "pull"])
|
||||
os.chdir("..")
|
||||
os.chdir("limine")
|
||||
subprocess.run(["make"])
|
||||
os.chdir("..")
|
||||
if not os.path.isdir("limine"):
|
||||
subprocess.run(["git", "clone", "https://git.synapseos.ru/Aren/limine.git", "--branch=v5.x-branch-binary", "--depth=1"])
|
||||
else:
|
||||
os.chdir("limine")
|
||||
subprocess.run(["git", "pull"])
|
||||
os.chdir("..")
|
||||
os.chdir("limine")
|
||||
subprocess.run(["make"])
|
||||
os.chdir("..")
|
||||
|
||||
|
||||
|
||||
def check_os():
|
||||
import platform
|
||||
using_distro = False
|
||||
try:
|
||||
import distro
|
||||
using_distro = True
|
||||
except ImportError:
|
||||
pass
|
||||
if using_distro:
|
||||
linux_distro = distro.like()
|
||||
else:
|
||||
linux_distro = platform.linux_distribution()[0]
|
||||
if linux_distro.lower() in ['debian', 'ubuntu', 'astra']:
|
||||
return 1
|
||||
return 0
|
||||
import platform
|
||||
using_distro = False
|
||||
try:
|
||||
import distro
|
||||
using_distro = True
|
||||
except ImportError:
|
||||
pass
|
||||
if using_distro:
|
||||
linux_distro = distro.like()
|
||||
else:
|
||||
linux_distro = platform.linux_distribution()[0]
|
||||
if linux_distro.lower() in ['debian', 'ubuntu', 'astra']:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def check_tools():
|
||||
required_tools = ["gcc", "g++", "xorriso", "make", "mtools", "curl"]
|
||||
missing_tools = []
|
||||
required_tools = ["gcc", "g++", "xorriso", "make", "mtools", "curl"]
|
||||
missing_tools = []
|
||||
|
||||
for tool in required_tools:
|
||||
if shutil.which(tool) is None:
|
||||
missing_tools.append(tool)
|
||||
for tool in required_tools:
|
||||
if shutil.which(tool) is None:
|
||||
missing_tools.append(tool)
|
||||
|
||||
if len(missing_tools) > 0:
|
||||
if check_os():
|
||||
subprocess.run(["sudo", "apt", "install"] + missing_tools)
|
||||
return
|
||||
subprocess.run(["sudo", "pacman", "-S"] + missing_tools)
|
||||
if len(missing_tools) > 0:
|
||||
if check_os():
|
||||
subprocess.run(["sudo", "apt", "install"] + missing_tools)
|
||||
return
|
||||
subprocess.run(["sudo", "pacman", "-S"] + missing_tools)
|
||||
|
||||
|
||||
def create_hdd(IMAGE_NAME):
|
||||
os.system(f"rm -f {IMAGE_NAME}.hdd".format())
|
||||
os.system(f"dd if=/dev/zero bs=1M count=0 seek=4 of={IMAGE_NAME}.hdd")
|
||||
os.system(f"sgdisk {IMAGE_NAME}.hdd -n 1:2048 -t 1:ef00")
|
||||
os.system(f"./limine/limine bios-install {IMAGE_NAME}.hdd")
|
||||
os.system(f"mformat -i {IMAGE_NAME}.hdd@@1M")
|
||||
os.system(f"mmd -i {IMAGE_NAME}.hdd@@1M ::/mod ::/EFI ::/EFI/BOOT")
|
||||
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M kernel.elf configs/limine.cfg limine/limine-bios.sys ::/")
|
||||
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M modules/bin/* ::/mod")
|
||||
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M limine/BOOTX64.EFI limine/BOOTIA32.EFI ::/EFI/BOOT")
|
||||
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M boot.jpg boot.tga ::/")
|
||||
os.system(f"./limine/limine bios-install {IMAGE_NAME}.hdd")
|
||||
os.system(f"rm -f {IMAGE_NAME}.hdd".format())
|
||||
os.system(f"dd if=/dev/zero bs=1M count=0 seek=4 of={IMAGE_NAME}.hdd")
|
||||
os.system(f"sgdisk {IMAGE_NAME}.hdd -n 1:2048 -t 1:ef00")
|
||||
os.system(f"./limine/limine bios-install {IMAGE_NAME}.hdd")
|
||||
os.system(f"mformat -i {IMAGE_NAME}.hdd@@1M")
|
||||
os.system(f"mmd -i {IMAGE_NAME}.hdd@@1M ::/mod ::/EFI ::/EFI/BOOT")
|
||||
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M kernel.elf configs/limine.cfg limine/limine-bios.sys ::/")
|
||||
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M modules/bin/* ::/mod")
|
||||
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M limine/BOOTX64.EFI limine/BOOTIA32.EFI ::/EFI/BOOT")
|
||||
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M boot.jpg boot.tga ::/")
|
||||
os.system(f"./limine/limine bios-install {IMAGE_NAME}.hdd")
|
||||
|
||||
|
||||
def create_iso(IMAGE_NAME):
|
||||
os.system(f"rm -f {IMAGE_NAME}.iso")
|
||||
os.system(f"rm -rf iso_root")
|
||||
os.system(f"mkdir -p iso_root")
|
||||
os.system(f"cp -v kernel.elf boot.jpg boot.tga configs/limine.cfg limine/limine-bios.sys limine/limine-bios-cd.bin limine/limine-uefi-cd.bin iso_root/")
|
||||
os.system(f"mkdir -p iso_root/EFI/BOOT")
|
||||
shutil.copytree("modules/bin", "iso_root/mod")
|
||||
os.system(f"cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/")
|
||||
os.system(f"cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/")
|
||||
os.system(f"xorriso -as mkisofs -b limine-bios-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-uefi-cd.bin -efi-boot-part --efi-boot-image --protective-msdos-label iso_root -o {IMAGE_NAME}.iso")
|
||||
os.system(f"./limine/limine bios-install {IMAGE_NAME}.iso")
|
||||
os.system(f"rm -f {IMAGE_NAME}.iso")
|
||||
os.system(f"rm -rf iso_root")
|
||||
os.system(f"mkdir -p iso_root")
|
||||
os.system(f"cp -v kernel.elf boot.jpg boot.tga configs/limine.cfg limine/limine-bios.sys limine/limine-bios-cd.bin limine/limine-uefi-cd.bin iso_root/")
|
||||
os.system(f"mkdir -p iso_root/EFI/BOOT")
|
||||
shutil.copytree("modules/bin", "iso_root/mod")
|
||||
os.system(f"cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/")
|
||||
os.system(f"cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/")
|
||||
os.system(f"xorriso -as mkisofs -b limine-bios-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-uefi-cd.bin -efi-boot-part --efi-boot-image --protective-msdos-label iso_root -o {IMAGE_NAME}.iso")
|
||||
os.system(f"./limine/limine bios-install {IMAGE_NAME}.iso")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Форматирование кода")
|
||||
print("Форматирование кода")
|
||||
|
||||
os.chdir("include")
|
||||
os.system(FORMAT_CMD)
|
||||
os.chdir("../kernel/")
|
||||
os.system(FORMAT_CMD)
|
||||
os.chdir("../modlib/")
|
||||
os.system(FORMAT_CMD)
|
||||
os.chdir("../modules/")
|
||||
os.system(FORMAT_CMD)
|
||||
os.chdir("../")
|
||||
os.chdir("include")
|
||||
os.system(FORMAT_CMD)
|
||||
os.chdir("../kernel/")
|
||||
os.system(FORMAT_CMD)
|
||||
os.chdir("../modlib/")
|
||||
os.system(FORMAT_CMD)
|
||||
os.chdir("../modules/")
|
||||
os.system(FORMAT_CMD)
|
||||
os.chdir("../")
|
||||
|
||||
|
||||
print("Очистка папки bin")
|
||||
subprocess.run(["rm", "-rf", "bin"])
|
||||
subprocess.run(["mkdir", "-p", "bin"])
|
||||
print("Очистка папки bin")
|
||||
subprocess.run(["rm", "-rf", "bin"])
|
||||
subprocess.run(["mkdir", "-p", "bin"])
|
||||
|
||||
if not os.path.isdir("ovmf"):
|
||||
print("Установка UEFI")
|
||||
subprocess.run(["mkdir", "-p", "ovmf"])
|
||||
os.chdir("ovmf")
|
||||
subprocess.run(["curl", "-Lo", "OVMF.fd", "https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF.fd"])
|
||||
os.chdir("..")
|
||||
if not os.path.isdir("ovmf"):
|
||||
print("Установка UEFI")
|
||||
subprocess.run(["mkdir", "-p", "ovmf"])
|
||||
os.chdir("ovmf")
|
||||
subprocess.run(["curl", "-Lo", "OVMF.fd", "https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF.fd"])
|
||||
os.chdir("..")
|
||||
|
||||
|
||||
if not os.path.isdir("limine"):
|
||||
print("Установка Limine")
|
||||
check_limine()
|
||||
if not os.path.isdir("limine"):
|
||||
print("Установка Limine")
|
||||
check_limine()
|
||||
|
||||
print("Проверка зависимостей")
|
||||
print("Проверка зависимостей")
|
||||
|
||||
check_tools()
|
||||
|
||||
major, minor, build = version_build()
|
||||
|
||||
print("Сборка модульного ядра")
|
||||
compile_all()
|
||||
check_tools()
|
||||
|
||||
major, minor, build = version_build()
|
||||
|
||||
print("Сборка модульного ядра")
|
||||
compile_all()
|
||||
|
||||
print("Создание ISO образа")
|
||||
create_iso("bmosp")
|
||||
print("Создание ISO образа")
|
||||
create_iso("bmosp")
|
||||
|
||||
print("Создание HDD образа")
|
||||
create_hdd("bmosp")
|
||||
print("Создание HDD образа")
|
||||
create_hdd("bmosp")
|
||||
|
||||
print(f"Не забудьте сохранить изменения! Номер сборки: {major}.{minor}.{build}")
|
||||
print(f"Не забудьте сохранить изменения! Номер сборки: {major}.{minor}.{build}")
|
||||
|
@ -8,9 +8,9 @@ echo "Updating..."
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install build-essential g++ make bison flex texinfo libgmp-dev libmpc-dev libmpfr-dev libisl-dev
|
||||
if [ ! -d "gcc-12.3.0" ]; then
|
||||
echo "Installing gcc..."
|
||||
wget https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.3.0.tar.xz
|
||||
tar -xf gcc-12.3.0.tar.xz
|
||||
echo "Installing gcc..."
|
||||
wget https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.3.0.tar.xz
|
||||
tar -xf gcc-12.3.0.tar.xz
|
||||
fi
|
||||
cd gcc-12.3.0/
|
||||
echo "Configure..."
|
||||
|
@ -1,18 +1,18 @@
|
||||
# Генерируем код для isr_stubs
|
||||
isr_stubs_code = ''
|
||||
for i in range(256):
|
||||
isr_stubs_code += f'\t.quad isr_stub_{i}\n'
|
||||
isr_stubs_code += f'\t.quad isr_stub_{i}\n'
|
||||
|
||||
# Генерируем код для isr_stub
|
||||
isr_stub_code = ''
|
||||
for i in range(256):
|
||||
isr_stub_code += f'stub {i}\n'
|
||||
isr_stub_code += f'stub {i}\n'
|
||||
|
||||
# Сохраняем код в файл
|
||||
with open('output.s', 'w') as file:
|
||||
file.write('.section .text\n')
|
||||
file.write(isr_stub_code)
|
||||
file.write('.global isr_stubs\n')
|
||||
file.write('.section .data\n')
|
||||
file.write('isr_stubs:\n')
|
||||
file.write(isr_stubs_code)
|
||||
file.write('.section .text\n')
|
||||
file.write(isr_stub_code)
|
||||
file.write('.global isr_stubs\n')
|
||||
file.write('.section .data\n')
|
||||
file.write('isr_stubs:\n')
|
||||
file.write(isr_stubs_code)
|
@ -6,8 +6,8 @@ foldername="sdk"
|
||||
|
||||
# Проверяем, существует ли архив
|
||||
if [ ! -f "$filename" ]; then
|
||||
# Скачиваем архив
|
||||
wget "$url"
|
||||
# Скачиваем архив
|
||||
wget "$url"
|
||||
fi
|
||||
|
||||
# Распаковываем содержимое в папку sdk/
|
||||
|
@ -4,7 +4,7 @@ VERSION=`git rev-parse --short HEAD`
|
||||
|
||||
X=$(git status -s | grep -q '^.M')
|
||||
if [ $? -eq 0 ]; then
|
||||
VERSION="$VERSION"
|
||||
VERSION="$VERSION"
|
||||
fi
|
||||
|
||||
echo -n $VERSION
|
Loading…
Reference in New Issue
Block a user