├── isodir ├── boot │ ├── initrd.tar │ └── grub │ │ └── grub.cfg ├── limine.sys ├── limine-cd.bin ├── limine-cd-efi.bin └── limine.cfg ├── .gitattributes ├── include ├── strings.h ├── int.h ├── pmm.h ├── dt.h ├── versions.h ├── tools.h ├── arch.h ├── modules.h ├── ports.h ├── libk.h ├── com1_log.h └── multiboot2.h ├── src ├── kernel │ ├── libk │ │ └── libk.c │ ├── kernel.c │ └── multiboot2.c └── arch │ └── i686 │ ├── link.ld │ ├── int.c │ ├── ports.c │ ├── arch.c │ ├── boot.s │ ├── dt.c │ └── com1_log.c ├── .gitignore ├── scripts ├── send_admin.py ├── build.sh ├── install.py ├── doxygen │ └── footer.html └── build.py ├── .github └── workflows │ ├── test.yml │ ├── pull.yml │ └── push.yml ├── README.md ├── STYLE.md └── LICENSE /isodir/boot/initrd.tar: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /isodir/boot/grub/grub.cfg: -------------------------------------------------------------------------------- 1 | menuentry "SynapseOS" { 2 | multiboot2 /boot/kernel.elf 3 | } 4 | -------------------------------------------------------------------------------- /isodir/limine.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/SynapseOS-openkernel/main/isodir/limine.sys -------------------------------------------------------------------------------- /isodir/limine-cd.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/SynapseOS-openkernel/main/isodir/limine-cd.bin -------------------------------------------------------------------------------- /isodir/limine-cd-efi.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/SynapseOS-openkernel/main/isodir/limine-cd-efi.bin -------------------------------------------------------------------------------- /isodir/limine.cfg: -------------------------------------------------------------------------------- 1 | TIMEOUT=0 2 | GRAPHICS=YES 3 | TERM_MARGIN_GRADIENT=8 4 | #TERM_WALLPAPER=boot:///bg.bmp 5 | #BACKGROUND_PATH=boot:///bg.bmp 6 | VERBOSE=yes 7 | INTERFACE_RESOLUTION=1024x768 8 | 9 | :SynapseOS multiboot2 10 | #zRESOLUTION=1024x768 11 | PROTOCOL=multiboot2 12 | KERNEL_CMDLINE=Hello World! 13 | KERNEL_PATH=boot:///boot/kernel.elf 14 | #MODULE_STRING=ramdisk 15 | #MODULE_PATH=boot:///ramdisk -------------------------------------------------------------------------------- /include/strings.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strings.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Функции для работы со строками 5 | * @version 0.1.0 6 | * @date 24-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | 15 | 16 | #ifndef _STRINGS_H 17 | #define _STRINGS_H 1 18 | 19 | 20 | /** 21 | * @brief Тип данных для хранения UTF-8 строк 22 | * 23 | */ 24 | typedef int8_t string_utf8_t; 25 | 26 | 27 | #endif // strings.h -------------------------------------------------------------------------------- /include/int.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file int.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Функции обработки прерываний 5 | * @version 0.1.0 6 | * @date 21-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #ifndef _INT_H 14 | #define _INT_H 1 15 | 16 | 17 | /** 18 | * @brief Максимальное количество векторов прерываний (1023 + 1) 19 | * 20 | */ 21 | #define INTERRUPT_MAX_INDEX 1023 22 | 23 | bool int_set_handler(uint16_t index, void *func); 24 | 25 | 26 | #endif // int.h -------------------------------------------------------------------------------- /include/pmm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pmm.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Менеджер физической памяти 5 | * @version 0.1.0 6 | * @date 20-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | 16 | 17 | #ifndef _PMM_H 18 | #define _PMM_H 1 19 | 20 | 21 | #if (defined __i386__ || defined __x86_64__) 22 | 23 | 24 | bool pmm_init(struct multiboot_tag *multiboot_info); 25 | 26 | 27 | #endif 28 | 29 | 30 | #endif // pmm.h -------------------------------------------------------------------------------- /include/dt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dt.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Управление таблицами дескрипторов (idt, gdt) 5 | * @version 0.1.0 6 | * @date 21-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | #ifndef _DT_H 19 | #define _DT_H 1 20 | 21 | 22 | #include 23 | 24 | 25 | #if (defined __i386__ || defined __x86_64__) 26 | 27 | 28 | bool dt_init(); 29 | 30 | 31 | #endif 32 | 33 | 34 | 35 | #endif // dt.h -------------------------------------------------------------------------------- /src/kernel/libk/libk.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file libk.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief 5 | * @version 0.1.0 6 | * @date 19-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | 15 | 16 | /** 17 | * @brief Вычисление длины строки 18 | * 19 | * @param string Строка 20 | * @return uint32_t Длина строки 21 | */ 22 | uint32_t strlen(const char *string) { 23 | uint32_t length = 0; 24 | 25 | while(string[length]) { 26 | length++; 27 | } 28 | 29 | return length; 30 | } -------------------------------------------------------------------------------- /src/arch/i686/link.ld: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | 3 | SECTIONS { 4 | KERNEL_BEGIN = .; 5 | KERNEL_BEGIN_PHYS = . - 0xC0000000; 6 | 7 | 8 | .text BLOCK(128K) : ALIGN(4K) { 9 | text_sect_phys_addr = .; 10 | *(.multiboot) 11 | *(.text) 12 | } 13 | .rodata BLOCK(16K) : ALIGN(4K) { 14 | rodata_sect_phys_addr = .; 15 | *(.rodata) 16 | } 17 | 18 | .data BLOCK(16K) : ALIGN(4K) { 19 | data_sect_phys_addr = .; 20 | *(.data) 21 | } 22 | 23 | .bss BLOCK(16K) : ALIGN(4K) { 24 | bss_sect_phys_addr = .; 25 | *(COMMON) 26 | *(.bss) 27 | KERNEL_END = .; 28 | } 29 | 30 | KERNEL_SIZE = KERNEL_END - KERNEL_BEGIN; 31 | } -------------------------------------------------------------------------------- /include/versions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file versions.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Типы данных и функции для работы с версиями 5 | * @version 0.1.0 6 | * @date 24-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | 15 | 16 | #ifndef _VERSIONS_H 17 | #define _VERSIONS_H 1 18 | 19 | 20 | /** 21 | * @brief Структура для хранения версий 22 | * 23 | */ 24 | typedef struct { 25 | uint16_t major; ///< Версия 26 | uint16_t minor; ///< Подверсия 27 | uint16_t patch; ///< Исправление 28 | } version_t; 29 | 30 | 31 | #endif // string.h -------------------------------------------------------------------------------- /include/tools.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tools.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Дополнительные утилиты для упрощения написания кода 5 | * @version 0.1.0 6 | * @date 18-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #ifndef _TOOLS_H 14 | #define _TOOLS_H 1 15 | 16 | 17 | /** 18 | * @brief Для неиспользуемых переменных 19 | * 20 | */ 21 | #define UNUSED(x) (void)(x) 22 | 23 | 24 | /** 25 | * @brief Логическое ИЛИ 26 | * 27 | */ 28 | #define OR || 29 | 30 | 31 | /** 32 | * @brief Логическое И 33 | * 34 | */ 35 | #define AND && 36 | 37 | 38 | /** 39 | * @brief Инверсия 40 | * 41 | */ 42 | #define NOT(x) !(x) 43 | 44 | 45 | #endif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | /doxygen/ 55 | .vscode/settings.json 56 | *.iso 57 | serial.log 58 | -------------------------------------------------------------------------------- /scripts/send_admin.py: -------------------------------------------------------------------------------- 1 | from email import message 2 | from aiogram import Bot 3 | import sys 4 | import asyncio 5 | 6 | 7 | API_TOKEN = sys.argv[1] 8 | TASK_LIST = [ 9 | "SynapseOS-grub.iso", 10 | "SynapseOS-limine.iso", 11 | "isodir/boot/kernel.elf", 12 | "doxygen/rtf/refman.rtf", 13 | "doxygen.tar.gz" 14 | ] 15 | 16 | 17 | bot = Bot(token=API_TOKEN) 18 | 19 | 20 | async def resp(): 21 | await bot.send_message(838496332, sys.argv[2]) 22 | for i in TASK_LIST: 23 | try: 24 | doc = open(i, 'rb') 25 | await bot.send_document(838496332, doc) 26 | except Exception as E: 27 | await bot.send_message(838496332, str(E)) 28 | 29 | 30 | if __name__ == '__main__': 31 | asyncio.run(resp()) -------------------------------------------------------------------------------- /src/arch/i686/int.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file int.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Функции обработки прерываний 5 | * @version 0.1.0 6 | * @date 21-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | /** 21 | * @brief Изменения функции для вектора прерывания 22 | * 23 | * @param index Номер вектора 24 | * @param func Указатель на функцию 25 | * @return true В случае успеха 26 | * @return false В случае если index вне диапазона от 0 до 1023 27 | */ 28 | bool int_set_handler(uint16_t index, void *func) { 29 | if (index > INTERRUPT_MAX_INDEX) { 30 | com1_log("index %d is more than %d", index, INTERRUPT_MAX_INDEX); 31 | return false; 32 | } 33 | 34 | UNUSED(func); 35 | 36 | return true; 37 | } -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ARCH="i686" 4 | CC="${ARCH}-elf-gcc" 5 | CC_FLAGS="-fno-builtin -fno-stack-protector -ffreestanding -Wall -Wextra -O0 -I include/ -c" 6 | LD_FLAGS="-T src/arch/${ARCH}/link.ld -nostdlib -O0" 7 | 8 | mkdir -p bin/kernel 9 | 10 | declare -a SRC_TARGETS 11 | declare -a BIN_TARGETS 12 | 13 | # *.c 14 | for file in $(find src/ -type f -name "*c") 15 | do 16 | SRC_TARGETS+=($file) 17 | done 18 | 19 | # *.s 20 | for file in $(find src/ -type f -name "*s"); do 21 | SRC_TARGETS+=($file) 22 | done 23 | 24 | for i in ${!SRC_TARGETS[@]}; do 25 | file=$( basename ${SRC_TARGETS[$i]} ) 26 | ${CC} ${CC_FLAGS} ${SRC_TARGETS[$i]} -o bin/kernel/${file}.o 27 | done 28 | 29 | for file in $(find bin/kernel/ -type f -name "*o"); do 30 | BIN_TARGETS+=($file) 31 | done 32 | 33 | ${CC} ${LD_FLAGS} -o isodir/boot/kernel.elf ${BIN_TARGETS[@]} 34 | 35 | xorriso -as mkisofs -b limine-cd.bin \ 36 | -no-emul-boot -boot-load-size 4 -boot-info-table \ 37 | --efi-boot limine-cd-efi.bin \ 38 | -efi-boot-part --efi-boot-image --protective-msdos-label \ 39 | isodir -o SynapseOS-limine.iso 40 | 41 | qemu-system-i386 -cdrom SynapseOS-limine.iso -serial file:serial.log 42 | -------------------------------------------------------------------------------- /scripts/install.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf-8 -*- 3 | from sys import platform 4 | import urllib.request 5 | import os 6 | import zipfile 7 | import shutil 8 | 9 | 10 | ''' Установка зависимостей ''' 11 | def install(): 12 | if platform == "linux" or platform == "linux2": 13 | print("Установка xorriso") 14 | os.system("sudo apt install xorriso") 15 | 16 | print("Установка limine") 17 | os.system("git clone https://github.com/limine-bootloader/limine.git --branch=v4.x-branch-binary --depth=1") 18 | os.system("make -C limine") 19 | elif platform == "darwin": 20 | return -1 21 | elif platform == "win32": 22 | print("Установка xorriso") 23 | urllib.request.urlretrieve("https://github.com/PeyTy/xorriso-exe-for-windows/archive/master.zip", "xorriso.zip") 24 | 25 | with zipfile.ZipFile("xorriso.zip", 'r') as zip_ref: 26 | zip_ref.extractall(".") 27 | get_files = os.listdir("xorriso-exe-for-windows-master") 28 | 29 | print("Установка limine") 30 | os.system("git clone https://github.com/limine-bootloader/limine.git --branch=v4.x-branch-binary --depth=1") 31 | os.system("make -C limine") 32 | 33 | 34 | if __name__ == '__main__': 35 | install() -------------------------------------------------------------------------------- /include/arch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file arch.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Архитектурно-зависимые функции 5 | * @version 0.1.0 6 | * @date 17-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #ifndef _ARCH_H 14 | #define _ARCH_H 1 15 | 16 | 17 | #include 18 | 19 | 20 | #if (defined __i386__ || defined __x86_64__) 21 | 22 | #define halt() asm volatile("hlt") 23 | 24 | #define KERNEL_OFFSET 0xC0000000 25 | 26 | #define V2P(a) ((uintptr_t)(a) & ~KERNEL_OFFSET) 27 | #define P2V(a) ((uintptr_t)(a) | KERNEL_OFFSET) 28 | 29 | 30 | extern uintptr_t KERNEL_BEGIN_PHYS; 31 | extern uintptr_t KERNEL_END_PHYS; 32 | extern uintptr_t KERNEL_START; 33 | extern uintptr_t KERNEL_END; 34 | extern uintptr_t KERNEL_SIZE; 35 | 36 | unsigned int arch_get_kernel_size(); 37 | void arch_cpuid_test(); 38 | 39 | #endif 40 | 41 | 42 | #if defined(__i386__) 43 | 44 | static inline unsigned long long rdtsc() { 45 | unsigned long long int x; 46 | asm volatile (".byte 0x0f, 0x31" : "=A" (x)); 47 | return x; 48 | } 49 | 50 | #elif defined(__x86_64__) 51 | 52 | static inline unsigned long long rdtsc() { 53 | unsigned hi, lo; 54 | asm volatile ("rdtsc" : "=a"(lo), "=d"(hi)); 55 | return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); 56 | } 57 | 58 | #endif 59 | 60 | #endif // arch.h -------------------------------------------------------------------------------- /src/kernel/kernel.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kernel.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Главный файл ядра 5 | * @version 0.1.0 6 | * @date 17-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | /** 23 | * @brief Размер ядра 24 | * 25 | */ 26 | unsigned int kernel_size = 0; 27 | 28 | 29 | /** 30 | * @brief Функция инициализации ядра 31 | * 32 | * @param eax Магическое число 33 | * @param ebx Указатель на данные загрузчика 34 | * @param esp Стек 35 | */ 36 | noreturn void kernel_startup(unsigned int eax, unsigned int ebx, unsigned int esp) { 37 | kernel_size = ((uint32_t) &KERNEL_SIZE) >> 10; 38 | 39 | // Стек пока не используем 40 | UNUSED(esp); 41 | 42 | com1_log("Kernel ready, magic %x", eax); 43 | com1_log("Mbi %x", ebx); 44 | com1_log("kernel size %ukb (with stack)", kernel_size); 45 | 46 | unit_test(eax == MULTIBOOT2_BOOTLOADER_MAGIC, "Check bootloader magic"); 47 | unit_test(ebx & 7, "Unaligned mbi check"); 48 | 49 | unit_test(multiboot2_init(ebx), "Check multiboot2 work"); 50 | 51 | unit_test(dt_init(), "Setup descriptor tables"); 52 | 53 | arch_cpuid_test(); 54 | 55 | // Останавливаем процессор 56 | for (;;) { 57 | halt(); 58 | } 59 | } -------------------------------------------------------------------------------- /scripts/doxygen/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /include/modules.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file modules.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Структуры и функции для модулей 5 | * @version 0.1.0 6 | * @date 24-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | #ifndef _MODULES_H 19 | #define _MODULES_H 1 20 | 21 | 22 | /** 23 | * @brief На начальном этапе у модулей будет 8 разрешений 24 | * 25 | */ 26 | #define MODULE_PERMISSIONS_COUNT 8 27 | 28 | 29 | /** 30 | * @brief Структура для хранения и передачи информации о требуемых модулю разрешениях 31 | * 32 | */ 33 | typedef struct { 34 | uint32_t permissions_count; ///< Количество разрешений 35 | uint32_t permissions[MODULE_PERMISSIONS_COUNT]; ///< Список разрешений 36 | } module_permissions_t; 37 | 38 | 39 | /** 40 | * @brief Структура для хранения ответа модуля 41 | * 42 | */ 43 | typedef struct { 44 | // TODO: перенести из закрытого ядра частично 45 | } module_response_t; 46 | 47 | 48 | /** 49 | * @brief Структура для хранения информации о модуле 50 | * 51 | */ 52 | typedef struct { 53 | string_utf8_t *name; ///< Имя модуля 54 | version_t version; ///< Версия модуля 55 | module_permissions_t permissions; ///< Разрешения модуля 56 | void (*module_post)(uint32_t*, uint32_t*); ///< POST запрос модуля 57 | void *(*module_get)(uint32_t*, uint32_t*); ///< GET запрос модуля 58 | } module_info_t; 59 | 60 | 61 | 62 | 63 | #endif // modules.h -------------------------------------------------------------------------------- /include/ports.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ports.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Прослойка для работы с портами ввода-вывода 5 | * @version 0.1.0 6 | * @date 19-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | 15 | 16 | #ifndef _PORTS_H 17 | #define _PORTS_H 1 18 | 19 | 20 | #if (defined __i386__ || defined __x86_64__) 21 | 22 | #define PORTS_COM1 0x3f8 23 | #define PORTS_COM2 0x2F8 24 | #define PORTS_COM3 0x3E8 25 | #define PORTS_COM4 0x2E8 26 | #define PORTS_COM5 0x5F8 27 | #define PORTS_COM6 0x4F8 28 | #define PORTS_COM7 0x5E8 29 | #define PORTS_COM8 0x4E8 30 | 31 | #define PORTS_PIC1 0x20 32 | #define PORTS_PIC2 0xA0 33 | #define PORTS_ICW1 0x11 34 | #define PORTS_ICW4 0x01 35 | #define PORTS_PIC1 0x20 // Стандартный IO адрес главного PIC 36 | #define PORTS_PIC2 0xA0 // Стандартный IO адрес вторичного PIC 37 | #define PORTS_PIC1_COMMAND PORTS_PIC1 38 | #define PORTS_PIC1_DATA (PORTS_PIC1 + 1) 39 | #define PORTS_PIC2_COMMAND PORTS_PIC2 40 | #define PORTS_PIC2_DATA (PORTS_PIC2 + 1) 41 | 42 | uint8_t ports_inb(uint16_t port); // Чтение 1 байта из порта 43 | uint16_t ports_inw(uint16_t port); // Чтение 2 байт из порта 44 | uint32_t ports_inl(uint16_t port); // Чтение 4 байт из порта 45 | void ports_outb(uint16_t port, uint8_t val); // Отправка 1 байта в порт 46 | void ports_outw(uint16_t port, uint16_t val); // Отправка 2 байта в порт 47 | void ports_outl(uint16_t port, uint32_t val); // Отправка 4 байта в порт 48 | 49 | #endif 50 | 51 | 52 | #endif // ports.h -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: SynapseOS Push 2 | 3 | # Контроль событий при которых будет сборка 4 | on: 5 | # В нашем случае это push в ветку master 6 | push: 7 | tags: 8 | - "v*" 9 | branches: [ "main" ] 10 | #pull_request: 11 | # tags: 12 | # - "v*" 13 | # branches: [ "master" ] 14 | # Позволяет запускать этот рабочий процесс вручную на вкладке Actions 15 | workflow_dispatch: 16 | 17 | # Выполнение рабочего процесса состоит из одного или нескольких заданий, которые могут выполняться последовательно или параллельно 18 | jobs: 19 | build: 20 | # Все будет работать на последней версии Ubuntu 21 | runs-on: ubuntu-latest 22 | 23 | # Шаги представляют собой последовательность задач, которые будут выполняться как часть задания 24 | steps: 25 | - uses: actions/checkout@v3 26 | 27 | # Установка зависимостей 28 | - name: Установка зависимостей 29 | run: | 30 | sudo apt install python3 doxygen 31 | env: 32 | TG_TEXT: ${{ secrets.TEST_TEXT }} 33 | TG_KEY: ${{ secrets.TELEGRAM_TOKEN }} 34 | 35 | # Генерация документации 36 | - name: Генерация документации 37 | run: | 38 | mkdir -p doxygen 39 | doxygen scripts/Doxyfile 40 | tar -cvf doxygen.tar.gz doxygen/ 41 | ls 42 | 43 | # Проверка релиза 44 | - name: Проверка релиза 45 | run: | 46 | pip3 install aiogram 47 | 48 | # Отправка в телеграм 49 | - name: Проверка релиза 50 | run: | 51 | echo $TG_TEXT 52 | python3 scripts/send_admin.py $TG_KEY PUSH 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SynapseOS-openkernel 2 | 3 | Open Source реализация ядра SynapseOS 4 | 5 | Сайт проекта: 6 | Документация: 7 | 8 | ### Безопасность 9 | 10 | Система не передает личные данные пользователей. Даже ради статистики. 11 | 12 | ## На данный момент реализовано 13 | 14 | [X] Гибкая система зависимого от архитектуры кода 15 | [X] Автогенерация и публикация документации 16 | [X] Публикация ISO образов 17 | 18 | ## Сборка и запуск 19 | 20 | Получение ISO образа системы с новым ядром(с закрытым исходным кодом) осуществляется по заявкам - a2.dev@yandex.ru. 21 | 22 | Перед сборкой установите xorriso, i686-elf-gcc, limine(а конкретно limine-deploy) 23 | 24 | Для сборки открытого ядра: 25 | 26 | ```python 27 | python3 scripts/build.py 28 | ``` 29 | 30 | Для установки зависимостей: 31 | 32 | ```python 33 | python3 scripts/install.py 34 | ``` 35 | 36 | ## Минимальные системные требования 37 | 38 | - 5 мегабайт оперативной памяти 39 | - 4 мегабайта видеопамяти 40 | - i686 процессор на x86 архитектуре 41 | 42 | ## Благодарности 43 | 44 | - Геннадий Геннадьевич (наставник) 45 | - 46 | - 47 | 48 | И другие 49 | 50 | ## Отказ от ответственности 51 | 52 | SynapseOS это не дистрибутив linux, это новый проект который не имеет за собой компании или организации которая могла бы дать гарантий. 53 | Ядро SynapseOS имеет открытый исходный код, вы можете сами удостовериться в отсутствии вредоносного ПО изучая файлы этого репозитория. 54 | При использовании материалов вы обязуетесь соблюдать авторские права. 55 | Я не несу ответственности за причиненный ущерб. Используйте на свой страх и риск. 56 | -------------------------------------------------------------------------------- /src/arch/i686/ports.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ports.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Прослойка для работы с портами ввода-вывода 5 | * @version 0.1.0 6 | * @date 19-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | 15 | 16 | /** 17 | * @brief Получение одного байта из порта 18 | * 19 | * @param port Порт 20 | * @return uint8_t Значение из порта 21 | */ 22 | uint8_t ports_inb(uint16_t port) { 23 | uint8_t ret; 24 | asm volatile( "inb %1, %0" : "=a"(ret) : "Nd"(port) ); 25 | return ret; 26 | } 27 | 28 | 29 | /** 30 | * @brief Получение 2 байт(word) из порта 31 | * 32 | * @param port Порт 33 | * @return uint16_t Значение из порта 34 | */ 35 | uint16_t ports_inw(uint16_t port) { 36 | uint16_t ret; 37 | asm volatile( "inw %1, %0" : "=a"(ret) : "Nd"(port) ); 38 | return ret; 39 | } 40 | 41 | 42 | /** 43 | * @brief Получение 4 байт из порта 44 | * 45 | * @param port Порт 46 | * @return uint32_t Значение из порта 47 | */ 48 | uint32_t ports_inl(uint16_t port) { 49 | uint32_t ret; 50 | asm volatile( "inl %1, %0" : "=a"(ret) : "Nd"(port) ); 51 | return ret; 52 | } 53 | 54 | 55 | /** 56 | * @brief Ввод одного байта в порт 57 | * 58 | * @param port Порт 59 | * @param val Входные данные 60 | */ 61 | void ports_outb(uint16_t port, uint8_t val) { 62 | asm volatile( "outb %0, %1" : : "a"(val), "Nd"(port) ); 63 | } 64 | 65 | 66 | /** 67 | * @brief Ввод 2 байт (word) в порт 68 | * 69 | * @param port Порт 70 | * @param val Входные данные 71 | */ 72 | void ports_outw(uint16_t port, uint16_t val) { 73 | asm volatile( "outw %0, %1" : : "a"(val), "Nd"(port) ); 74 | } 75 | 76 | 77 | /** 78 | * @brief Ввод 4 байт в порт 79 | * 80 | * @param port Порт 81 | * @param val Входные данные 82 | */ 83 | void ports_outl(uint16_t port, uint32_t val) { 84 | asm volatile( "outl %0, %1" : : "a"(val), "Nd"(port) ); 85 | } -------------------------------------------------------------------------------- /src/arch/i686/arch.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file arch.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Архитектурно-зависимые функции 5 | * @version 0.1.0 6 | * @date 19-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | 16 | 17 | /** 18 | * @brief Получение размера ядра 19 | * 20 | * @return unsigned int размер ядра 21 | */ 22 | unsigned int arch_get_kernel_size() { 23 | unsigned int temp_size = 0; 24 | 25 | asm volatile ( 26 | "" 27 | : "=d" (temp_size) 28 | ); 29 | 30 | return temp_size; 31 | } 32 | 33 | 34 | /** 35 | * @brief Отладочная функция для тестирования CPUID 36 | * 37 | */ 38 | void arch_cpuid_test() { 39 | for (int i = 0; i < 5; i++) { 40 | char string[11] = {0}; 41 | int pos = 0; 42 | int eax, ebx, edx, ecx; 43 | 44 | asm volatile( 45 | "mov %1, %%eax; " // Ввод 46 | "cpuid;" 47 | "mov %%eax, %0;" // Записываем вывод 48 | : 49 | "=r"(eax), // eax на выход 50 | "=b"(ebx), 51 | "=d"(edx), 52 | "=c"(ecx) 53 | :"r"(i) // eax на вход 54 | ); 55 | 56 | com1_log("cpuid eax %x ebx %x edx %x ecx %x", eax, ebx, edx, ecx); 57 | 58 | 59 | for (int shifted = 0; shifted < 4; shifted++) { 60 | int mask = 0xFF << shifted * 8; 61 | int matched = (ebx & mask) >> shifted * 8; 62 | string[pos] = matched; 63 | pos++; 64 | } 65 | 66 | for (int shifted = 0; shifted < 4; shifted++) { 67 | int mask = 0xFF << shifted * 8; 68 | int matched = (edx & mask) >> shifted * 8; 69 | string[pos] = matched; 70 | pos++; 71 | } 72 | 73 | for (int shifted = 0; shifted < 4; shifted++) { 74 | int mask = 0xFF << shifted * 8; 75 | int matched = (ecx & mask) >> shifted * 8; 76 | string[pos] = matched; 77 | pos++; 78 | } 79 | 80 | com1_log("cpuid decode: [%s] pos = %d", string, pos); 81 | } 82 | } -------------------------------------------------------------------------------- /src/arch/i686/boot.s: -------------------------------------------------------------------------------- 1 | /** 2 | * @file boot.s 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Подзагрузчик ядра 5 | * @version 0.1.0 6 | * @date 18-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | # Использованы материалы 14 | # https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html 15 | 16 | 17 | # 32х битный код 18 | .code32 19 | 20 | 21 | # Размер стека 22 | # 4096 * 16 * 8 = 524288 байт. 23 | # 524288 байт = 512 килобайт 24 | .set STACK_SIZE, 4096 * 16 * 8 25 | 26 | # Multiboot2 теги 27 | .set TAG_END, 0 28 | .set TAG_FRAMEBUFFER, 5 29 | 30 | # Multiboot2 флаги 31 | .set TAG_REQUIRED, 0 32 | .set TAG_OPTIONAL, 1 33 | 34 | # Multiboot2 константы 35 | .set MAGIC, 0xE85250D6 36 | .set ARCH, 0 37 | .set HEADER_LEN, (multiboot_end - multiboot_start) 38 | .set CHECKSUM, -(MAGIC + ARCH + HEADER_LEN) 39 | 40 | .set KERNEL_VIRTUAL_BASE, 0xC0000000 41 | .set KERNEL_PAGE_NUMBER, (KERNEL_VIRTUAL_BASE >> 22) 42 | 43 | # Объявляем мультизагрузочный заголовок, который помечает программу как ядро. 44 | # Это магические значения, которые задокументированы в стандарте мультизагрузки. 45 | # Загрузчик будет искать этот заголовок в первых 8 килобайтах файла ядра, выровненного по 32-битной границе. 46 | # Подпись находится в отдельном разделе, поэтому заголовок можно принудительно разместить в первых 8 килобайтах файла ядра. 47 | .section .multiboot 48 | multiboot_start: 49 | # Магическое число и прочие данные 50 | .align 8 51 | .long MAGIC 52 | .long ARCH 53 | .long HEADER_LEN 54 | .long CHECKSUM 55 | 56 | # Графические флаги 57 | .align 8 58 | .short TAG_FRAMEBUFFER 59 | .short TAG_REQUIRED 60 | .long 20 61 | .long 1024 62 | .long 768 63 | .long 32 64 | 65 | # Конец тега 66 | .align 8 67 | .short TAG_END 68 | .short TAG_REQUIRED 69 | .long 8 70 | multiboot_end: 71 | 72 | .section .text 73 | .global _start 74 | 75 | 76 | # Входная точка 77 | _start: 78 | cli 79 | mov $(_stack + STACK_SIZE), %esp 80 | push $0x0 81 | popf 82 | 83 | finit # Инициализация FPU 84 | 85 | push %esp # Стек 86 | push %ebx # Структура multiboot2 87 | push %eax # Магическое число 88 | 89 | call kernel_startup 90 | 91 | 92 | # Останавливаем процессор 93 | __halt_me: 94 | cli 95 | hlt 96 | jmp __halt_me 97 | 98 | .comm _stack, STACK_SIZE 99 | -------------------------------------------------------------------------------- /.github/workflows/pull.yml: -------------------------------------------------------------------------------- 1 | name: SynapseOS pull 2 | 3 | # Контроль событий при которых будет сборка 4 | on: 5 | # В нашем случае это push в ветку master 6 | pull_request: 7 | tags: 8 | - "v*" 9 | branches: [ "main" ] 10 | 11 | workflow_dispatch: 12 | 13 | # Выполнение рабочего процесса состоит из одного или нескольких заданий, которые могут выполняться последовательно или параллельно 14 | jobs: 15 | build: 16 | # Все будет работать на последней версии Ubuntu 17 | runs-on: ubuntu-latest 18 | 19 | # Шаги представляют собой последовательность задач, которые будут выполняться как часть задания 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | # Установка зависимостей 24 | - name: Установка зависимостей 25 | run: | 26 | sudo apt install python3 build-essential xorriso mtools zip doxygen 27 | wget -nv https://github.com/lordmilko/i686-elf-tools/releases/download/7.1.0/i686-elf-tools-linux.zip 28 | sudo unzip i686-elf-tools-linux.zip -d /usr/local 29 | rm i686-elf-tools-linux.zip 30 | env: 31 | TG_KEY: ${{ secrets.TELEGRAM_TOKEN }} 32 | # Запуск сборки ядра 33 | - name: Сборка ядра 34 | run: python3 scripts/build.py kernel 35 | 36 | # Создание дистрибутива (ISO) 37 | - name: Создание дистрибутива (ISO) 38 | run: | 39 | git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1 40 | make -C limine 41 | xorriso -as mkisofs -b limine-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-cd-efi.bin -efi-boot-part --efi-boot-image --protective-msdos-label isodir -o SynapseOS-limine.iso 42 | 43 | # Генерация документации 44 | - name: Генерация документации 45 | run: | 46 | mkdir -p doxygen 47 | doxygen scripts/Doxyfile 48 | tar -cvf doxygen.tar.gz doxygen/ 49 | ls 50 | 51 | # Проверка релиза 52 | - name: Проверка релиза 53 | run: | 54 | echo " /" 55 | ls 56 | echo " isodir/boot/" 57 | ls isodir/boot/ 58 | pip3 install aiogram 59 | python3 scripts/send_admin.py $TG_KEY PULL 60 | 61 | # Публикация документации 62 | #- name: Commit changes 63 | # uses: EndBug/add-and-commit@v9 64 | # with: 65 | # author_name: Github 66 | # author_email: github@example.com 67 | # message: 'документация: Обновление документации с помощью doxygen [Автосборка]' 68 | # add: 'docs/doxygen/html/*' 69 | 70 | 71 | -------------------------------------------------------------------------------- /include/libk.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file libk.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Стандартная библиотека ядра 5 | * @version 0.1.0 6 | * @date 18-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #ifndef _LIBK_H 14 | #define _LIBK_H 1 15 | 16 | 17 | /** 18 | * @brief Используем встроенный в GCC тип для функций которые не возвращают ничего 19 | * 20 | */ 21 | #define noreturn _Noreturn 22 | 23 | 24 | /** 25 | * @brief Инициализация AP до использования макросами va_arg и va_end. 26 | * 27 | */ 28 | #define va_start(v,l) __builtin_va_start(v,l) 29 | 30 | 31 | /** 32 | * @brief Освобождение памяти va_list 33 | * 34 | */ 35 | #define va_end(v) __builtin_va_end(v) 36 | 37 | 38 | /** 39 | * @brief Парсинг аргументов va_list 40 | * 41 | */ 42 | #define va_arg(v,l) __builtin_va_arg(v,l) 43 | 44 | 45 | /** 46 | * @brief Копирование va_list 47 | * 48 | */ 49 | #define va_copy(d,s) __builtin_va_copy(d,s) 50 | 51 | 52 | /** 53 | * @brief Поиск наибольшего числа 54 | * 55 | */ 56 | #define max(a,b) \ 57 | ({ __typeof__ (a) _a = (a); \ 58 | __typeof__ (b) _b = (b); \ 59 | _a > _b ? _a : _b; }) 60 | 61 | 62 | /** 63 | * @brief Верно 64 | * 65 | */ 66 | #define true 1 67 | 68 | 69 | /** 70 | * @brief Ложь 71 | * 72 | */ 73 | #define false 0 74 | 75 | 76 | /** 77 | * @brief Реализация NULL 78 | * 79 | */ 80 | #define NULL ((void *)0) 81 | 82 | 83 | /** 84 | * @brief Атрибут для упакованных структур 85 | * 86 | */ 87 | #define PACKED __attribute__((packed)) 88 | 89 | 90 | /** 91 | * @brief Число от -128 до 127 (1 байт) 92 | * 93 | */ 94 | typedef char int8_t; 95 | 96 | 97 | /** 98 | * @brief Число от -От -32768 до 32767 (2 байта) 99 | * 100 | */ 101 | typedef short int16_t; 102 | 103 | 104 | /** 105 | * @brief Число от -2147483648 до 2147483647 (4 байта) 106 | * 107 | */ 108 | typedef int int32_t; 109 | 110 | 111 | /** 112 | * @brief Число от 0 до 255 (1 байт) 113 | * 114 | */ 115 | typedef unsigned char uint8_t; 116 | 117 | 118 | /** 119 | * @brief Число от 0 до 65536 (2 байта) 120 | * 121 | */ 122 | typedef unsigned short uint16_t; 123 | 124 | 125 | /** 126 | * @brief Число от 0 до 4294967296 (4 байта) 127 | * 128 | */ 129 | typedef unsigned int uint32_t; 130 | 131 | 132 | 133 | /** 134 | * @brief Специальный тип указателей 135 | * 136 | */ 137 | typedef __UINTPTR_TYPE__ uintptr_t; 138 | 139 | 140 | /** 141 | * @brief Специальный тип для булевых операций 142 | * 143 | */ 144 | typedef _Bool bool; 145 | 146 | 147 | /** 148 | * @brief Список аргументов 149 | * 150 | */ 151 | typedef __builtin_va_list va_list; 152 | 153 | 154 | uint32_t strlen(const char *string); 155 | 156 | bool multiboot2_init(unsigned int addr); 157 | 158 | 159 | #endif // libk.h -------------------------------------------------------------------------------- /include/com1_log.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file com1_log.h 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Функции отладки через COM1 порт 5 | * @version 0.1.0 6 | * @date 19-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | 16 | 17 | #ifndef _COM1_LOG_H 18 | #define _COM1_LOG_H 1 19 | 20 | 21 | #if (defined __i386__ || defined __x86_64__) 22 | 23 | void com1_log_printf(const char *format_string, ...); 24 | 25 | #if DEBUG 26 | #define com1_log(M, ...) \ 27 | com1_log_printf("[DEBUG][" \ 28 | "%s:" \ 29 | "%s:%d]" M "\n", \ 30 | __FILE__, \ 31 | __FUNCTION__, \ 32 | __LINE__, \ 33 | ##__VA_ARGS__ \ 34 | ) 35 | 36 | #define assert(condition) if (condition){ \ 37 | com1_log("ASSERT FAIL"); \ 38 | for(;;) { \ 39 | halt(); \ 40 | } \ 41 | } 42 | 43 | #define unit_test(condition, message) if ((condition) > 0){ \ 44 | com1_log_printf("[TEST PASSED][%s:%s:%d]%s\n", __FILE__, __FUNCTION__, __LINE__, message); \ 45 | } else { \ 46 | com1_log_printf("[TEST FAILED][%s:%s:%d]%s\n", __FILE__, __FUNCTION__, __LINE__, message); \ 47 | } 48 | 49 | #else 50 | 51 | #define com1_log(M, ...) \ 52 | com1_log_printf("[" \ 53 | "%s:%d]" M "\n", \ 54 | __FUNCTION__, \ 55 | __LINE__, \ 56 | ##__VA_ARGS__ \ 57 | ) 58 | #define assert(condition) if (condition){ \ 59 | com1_log("[ASSERT FAIL]"); \ 60 | for(;;) { \ 61 | halt(); \ 62 | } \ 63 | } 64 | 65 | #define unit_test(condition, message) if ((condition) > 0) { \ 66 | com1_log_printf("[PASS][%s]%s\n", __FUNCTION__, message); \ 67 | } else { \ 68 | com1_log_printf("[FAIL][%s]%s\n", __FUNCTION__, message); \ 69 | } 70 | #endif 71 | 72 | 73 | 74 | #endif // i386, x86_64 75 | 76 | 77 | #endif // com1_log.h 78 | 79 | -------------------------------------------------------------------------------- /src/arch/i686/dt.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dt.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Управление таблицами дескрипторов (idt, gdt) 5 | * @version 0.1.0 6 | * @date 21-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | /** 22 | * @brief Ошибка при делении на ноль 23 | * 24 | */ 25 | static noreturn void division_by_zero() { 26 | com1_log("[ERROR]Division by zero"); 27 | 28 | for(;;) { 29 | halt(); 30 | } 31 | } 32 | 33 | 34 | /** 35 | * @brief Неверный код операции 36 | * 37 | */ 38 | static noreturn void invalid_opcode() { 39 | com1_log("[ERROR]Invalid opcode"); 40 | 41 | for(;;) { 42 | halt(); 43 | } 44 | } 45 | 46 | 47 | /** 48 | * @brief Двойная ошибка(при прерывании или обработке ошибки) 49 | * 50 | */ 51 | static noreturn void double_error() { 52 | com1_log("[ERROR]Double error"); 53 | 54 | for(;;) { 55 | halt(); 56 | } 57 | } 58 | 59 | 60 | /** 61 | * @brief Недопустимое исключение TSS 62 | * 63 | */ 64 | static noreturn void invalid_tss() { 65 | com1_log("[ERROR]Invalid tss"); 66 | 67 | for(;;) { 68 | halt(); 69 | } 70 | } 71 | 72 | 73 | /** 74 | * @brief Сегмент недоступен 75 | * 76 | */ 77 | static noreturn void segment_not_available() { 78 | com1_log("[ERROR]Segment not available"); 79 | 80 | for(;;) { 81 | halt(); 82 | } 83 | } 84 | 85 | 86 | /** 87 | * @brief Ошибка стека 88 | * 89 | */ 90 | static noreturn void stack_error() { 91 | com1_log("[ERROR]Stack error"); 92 | 93 | for(;;) { 94 | halt(); 95 | } 96 | } 97 | 98 | 99 | /** 100 | * @brief Общая ошибка защиты 101 | * 102 | */ 103 | static noreturn void general_protection_error() { 104 | com1_log("[ERROR]GPT error"); 105 | 106 | for(;;) { 107 | halt(); 108 | } 109 | } 110 | 111 | 112 | /** 113 | * @brief Ошибка страницы 114 | * 115 | */ 116 | static noreturn void page_fault() { 117 | com1_log("[ERROR]Page fault"); 118 | 119 | for(;;) { 120 | halt(); 121 | } 122 | } 123 | 124 | 125 | /** 126 | * @brief Инициализации глобальной таблицы дескрипторов 127 | * 128 | */ 129 | void gdt_init() { 130 | 131 | } 132 | 133 | 134 | /** 135 | * @brief Инициализация таблицы векторов прерываний 136 | * 137 | */ 138 | void idt_init() { 139 | 140 | } 141 | 142 | 143 | /** 144 | * @brief Инициализация таблиц дескрипторов 145 | * 146 | * @return true В случае успешной настройки 147 | * @return false В случае ошибки 148 | */ 149 | bool dt_init() { 150 | gdt_init(); 151 | idt_init(); 152 | 153 | 154 | // Установка векторов прерываний для ошибок 155 | int_set_handler(0, &division_by_zero); 156 | int_set_handler(6, &invalid_opcode); 157 | int_set_handler(8, &double_error); 158 | int_set_handler(10, &invalid_tss); 159 | int_set_handler(11, &segment_not_available); 160 | int_set_handler(12, &stack_error); 161 | int_set_handler(13, &general_protection_error); 162 | int_set_handler(14, &page_fault); 163 | int_set_handler(36, NULL); 164 | 165 | return true; 166 | } -------------------------------------------------------------------------------- /scripts/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf-8 -*- 3 | import os 4 | import glob 5 | import shutil 6 | 7 | 8 | SRC_TARGETS = [] 9 | BIN_TARGETS = [] 10 | ARCH = "i686" # "x86_64", "arm", "e2k" 11 | CC = f"{ARCH}-elf-gcc" 12 | DEBUG_FLAGS = "" 13 | if 0: 14 | DEBUG_FLAGS = "-ggdb -DDEBUG=1" 15 | CC_FLAGS = f"-fno-builtin -fstack-check=no -fno-stack-protector -ffreestanding {DEBUG_FLAGS} -Wall -Wextra -O0 -I include// -c " 16 | CC_FLAGS = f"-ffreestanding {DEBUG_FLAGS} -Wall -Wextra -O0 -I include// -c " 17 | LD_FLAGS = f"-T src//arch//{ARCH}//link.ld -nostdlib -O0 " 18 | 19 | 20 | ''' Сборка ядра ''' 21 | def build_kernel(): 22 | print("Сборка ядра") 23 | 24 | files = glob.glob("src//kernel//**//*.c", recursive=True) + \ 25 | glob.glob(f"src//arch//{ARCH}//**//*.s", recursive=True) + \ 26 | glob.glob(f"src//arch//{ARCH}//**//*.c", recursive=True) 27 | 28 | for i in range(len(files)): 29 | SRC_TARGETS.append(files[i]) 30 | BIN_TARGETS.append(os.path.join("bin//kernel//", os.path.basename(SRC_TARGETS[i]) + '.o ' )) 31 | print(SRC_TARGETS) 32 | print(BIN_TARGETS) 33 | shutil.rmtree("bin", ignore_errors=True) 34 | 35 | if not os.path.exists("bin//"): 36 | os.mkdir("bin//") 37 | 38 | if not os.path.exists("bin//kernel//"): 39 | os.mkdir("bin//kernel//") 40 | 41 | for i in range(0, len(SRC_TARGETS)): 42 | os.system(f"{CC} {DEBUG_FLAGS} {CC_FLAGS} {SRC_TARGETS[i]} -o {BIN_TARGETS[i]}") 43 | print(f"{CC} {CC_FLAGS} {SRC_TARGETS[i]} -o {BIN_TARGETS[i]}") 44 | 45 | print(f"{CC} {LD_FLAGS} -o isodir//boot//kernel.elf {' '.join(str(x) for x in BIN_TARGETS)}") 46 | os.system(f"{CC} {LD_FLAGS} -o isodir//boot//kernel.elf {' '.join(str(x) for x in BIN_TARGETS)}") 47 | 48 | 49 | ''' Генерация документации ''' 50 | def build_docs(): 51 | print("Генерация документации") 52 | 53 | os.system("doxygen scripts//Doxyfile") 54 | 55 | 56 | ''' Сборка модулей ''' 57 | def build_modules(): 58 | pass 59 | 60 | 61 | ''' Сборка драйверов ''' 62 | def build_drivers(): 63 | pass 64 | 65 | 66 | ''' Сборка программ ''' 67 | def build_programms(): 68 | pass 69 | 70 | 71 | ''' Сборка ISO limine ''' 72 | def build_iso_limine(): 73 | print("Сборка ISO limine") 74 | 75 | os.system("""xorriso -as mkisofs -b limine-cd.bin \ 76 | -no-emul-boot -boot-load-size 4 -boot-info-table \ 77 | --efi-boot limine-cd-efi.bin \ 78 | -efi-boot-part --efi-boot-image --protective-msdos-label \ 79 | isodir -o SynapseOS-limine.iso""") 80 | 81 | os.system("limine-deploy SynapseOS-limine.iso") 82 | 83 | #print(f"Сборка ISO//Limine образа заняла: {(time.time() - start_time):2f} сек.") 84 | 85 | 86 | ''' Сборка ISO grub legasy bios''' 87 | def build_iso_grub_bios(): 88 | os.system("grub-mkrescue -o SynapseOS-grub.iso isodir") 89 | 90 | 91 | ''' Сборка ISO grub EFI''' 92 | def build_iso_grub_efi(): 93 | # TODO 94 | pass 95 | 96 | 97 | if __name__ == '__main__': 98 | build_kernel() 99 | 100 | build_iso_limine() 101 | 102 | build_docs() 103 | 104 | os.system("qemu-system-i386 -cdrom SynapseOS-limine.iso -serial file:serial.log") -------------------------------------------------------------------------------- /.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | name: SynapseOS Push 2 | 3 | # Контроль событий при которых будет сборка 4 | on: 5 | # В нашем случае это push в ветку master 6 | push: 7 | tags: 8 | - "v*" 9 | branches: [ "main" ] 10 | #pull_request: 11 | # tags: 12 | # - "v*" 13 | # branches: [ "master" ] 14 | # Позволяет запускать этот рабочий процесс вручную на вкладке Actions 15 | workflow_dispatch: 16 | 17 | # Выполнение рабочего процесса состоит из одного или нескольких заданий, которые могут выполняться последовательно или параллельно 18 | jobs: 19 | build: 20 | # Все будет работать на последней версии Ubuntu 21 | runs-on: ubuntu-latest 22 | 23 | # Шаги представляют собой последовательность задач, которые будут выполняться как часть задания 24 | steps: 25 | - uses: actions/checkout@v3 26 | 27 | # Установка зависимостей 28 | - name: Установка зависимостей 29 | run: | 30 | sudo apt install python3 build-essential xorriso grub-pc-bin mtools zip doxygen 31 | wget -nv https://github.com/lordmilko/i686-elf-tools/releases/download/7.1.0/i686-elf-tools-linux.zip 32 | sudo unzip i686-elf-tools-linux.zip -d /usr/local 33 | rm i686-elf-tools-linux.zip 34 | env: 35 | TG_TEXT: ${{ secrets.TELEGRAM_TOKEN }} 36 | TG_KEY: ${{ secrets.TELEGRAM_TOKEN }} 37 | 38 | # Запуск сборки ядра 39 | - name: Сборка ядра 40 | run: python3 scripts/build.py kernel 41 | 42 | # Создание дистрибутива (ISO) 43 | - name: Создание дистрибутива (ISO) 44 | run: | 45 | git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1 46 | make -C limine 47 | xorriso -as mkisofs -b limine-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-cd-efi.bin -efi-boot-part --efi-boot-image --protective-msdos-label isodir -o SynapseOS-limine.iso 48 | grub-mkrescue -o SynapseOS-grub.iso isodir 49 | 50 | # Генерация документации 51 | - name: Генерация документации 52 | run: | 53 | mkdir -p doxygen 54 | doxygen scripts/Doxyfile 55 | tar -cvf doxygen.tar.gz doxygen/ 56 | ls 57 | 58 | # Проверка релиза 59 | - name: Проверка релиза 60 | run: | 61 | echo " /" 62 | ls 63 | echo " isodir/boot/" 64 | ls isodir/boot/ 65 | pip3 install aiogram 66 | 67 | # Отправка в телеграм 68 | - name: Проверка релиза 69 | run: python3 scripts/send_admin.py "$TG_KEY" PUSH 70 | # Публикация документации 71 | #- name: Commit changes 72 | # uses: EndBug/add-and-commit@v9 73 | # with: 74 | # author_name: Github 75 | # author_email: github@example.com 76 | # message: 'документация: Обновление документации с помощью doxygen [Автосборка]' 77 | # add: 'docs/doxygen/html/*' 78 | 79 | # Публикация релиза 80 | - name: Публикация релиза 81 | uses: "marvinpinto/action-automatic-releases@latest" 82 | with: 83 | repo_token: "${{ secrets.GIT_TOKEN }}" 84 | automatic_release_tag: "latest-unstable" 85 | prerelease: true 86 | title: "[Автосборка] Нестабильный релиз" 87 | description: "Внимание! Данный релиз собран из последних изменений в ядре! Это не окончательная версия содержит ошибки и не рекомендуется к запуску без проверки на виртуальной машине." 88 | files: | 89 | LICENSE 90 | SynapseOS-grub.iso 91 | SynapseOS-limine.iso 92 | isodir/boot/kernel.elf 93 | doxygen/rtf/refman.rtf 94 | doxygen.tar.gz 95 | -------------------------------------------------------------------------------- /src/arch/i686/com1_log.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file com1_log.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief Функции для работы с com1 портом 5 | * @version 0.1.0 6 | * @date 19-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | static const char CONVERSION_TABLE[] = "0123456789ABCDEF"; 20 | 21 | 22 | /** 23 | * @brief Проверка "занятости" COM1 порта 24 | * 25 | * @return int Количество задач 26 | */ 27 | static int com1_log_is_transmit_empty() { 28 | return ports_inb(PORTS_COM1 + 5) & 0x20; 29 | } 30 | 31 | 32 | /** 33 | * @brief Вывод символа в COM1 порт 34 | * 35 | * @param c Выводимый символ 36 | */ 37 | static void com1_log_putchar(char c) { 38 | while (com1_log_is_transmit_empty() == 0); 39 | ports_outb(PORTS_COM1, c); 40 | } 41 | 42 | 43 | /** 44 | * @brief Вывод строки в COM1 порт 45 | * 46 | * @param string Выводимая строка 47 | */ 48 | static void com1_log_puts(const char string[]) { 49 | for (uint32_t i = 0; i < strlen(string); i++) { 50 | com1_log_putchar(string[i]); 51 | } 52 | } 53 | 54 | 55 | /** 56 | * @brief Вывод шестнадцатеричного числа в COM1 порт 57 | * 58 | * @param num Выводимое число 59 | */ 60 | static void com1_log_printhex(int num) { 61 | int i; 62 | char buf[17]; 63 | 64 | if (!num) { 65 | com1_log_puts("0x0"); 66 | return; 67 | } 68 | 69 | buf[16] = 0; 70 | 71 | for (i = 15; num; i--) { 72 | buf[i] = CONVERSION_TABLE[num % 16]; 73 | num /= 16; 74 | } 75 | 76 | i++; 77 | com1_log_puts("0x"); 78 | com1_log_puts(&buf[i]); 79 | } 80 | 81 | 82 | /** 83 | * @brief Вывод десятичного числа в COM1 порт 84 | * 85 | * @param num Выводимое число 86 | */ 87 | static void com1_log_printdec(int num) { 88 | int i; 89 | char buf[21] = {0}; 90 | 91 | if (!num) { 92 | com1_log_putchar('0'); 93 | return; 94 | } 95 | 96 | for (i = 19; num; i--) { 97 | buf[i] = (num % 10) + 0x30; 98 | num = num / 10; 99 | } 100 | 101 | i++; 102 | com1_log_puts(buf + i); 103 | } 104 | 105 | 106 | /** 107 | * @brief Вывод десятичного числа больше нуля в COM1 порт 108 | * 109 | * @param num Выводимое число 110 | */ 111 | static void com1_log_printudec(unsigned int num) { 112 | int i; 113 | char buf[21] = {0}; 114 | 115 | if (!num) { 116 | com1_log_putchar('0'); 117 | return; 118 | } 119 | 120 | for (i = 19; num; i--) { 121 | buf[i] = (num % 10) + 0x30; 122 | num = num / 10; 123 | } 124 | 125 | i++; 126 | com1_log_puts(buf + i); 127 | } 128 | 129 | 130 | 131 | /** 132 | * @brief Вывод в COM1 порт форматированной строки используя неопределенное количество аргументов 133 | * 134 | * @param format_string Строка форматов 135 | * @param ... Аргументы 136 | */ 137 | void com1_log_printf(const char *format_string, ...) { 138 | va_list args; 139 | 140 | // Ищем первый аргумент 141 | va_start(args, format_string); 142 | 143 | // Обработка и парсинг строки форматов 144 | while (*format_string != '\0') { 145 | if (*format_string == '%') { 146 | format_string++; 147 | if (*format_string == 'x') { 148 | com1_log_printhex(va_arg(args, int)); 149 | } else if (*format_string == 'd') { 150 | com1_log_printdec(va_arg(args, int)); 151 | } else if (*format_string == 'u') { 152 | com1_log_printudec(va_arg(args, unsigned int)); 153 | } else if (*format_string == 's') { 154 | com1_log_puts(va_arg(args, char*)); 155 | } else if (*format_string == 'c') { 156 | com1_log_putchar((char)va_arg(args, char*)[0]); 157 | } 158 | } else { 159 | com1_log_putchar(*format_string); 160 | } 161 | format_string++; 162 | } 163 | 164 | // Освобождаем память 165 | va_end(args); 166 | } -------------------------------------------------------------------------------- /STYLE.md: -------------------------------------------------------------------------------- 1 | # Стиль кода, документации и коммитов 2 | 3 | ## Содержание 4 | 5 | 1. Код 6 | 2. Документация 7 | 3. Коммиты 8 | 9 | ## Код 10 | 11 | ### Комментарии 12 | 13 | Вы можете использовать либо // либо /**/, однако // намного предпочтительнее. 14 | Всегда отделяйте // от тела комментария одним пробелом. 15 | Комментарии должны быть на русском языке. 16 | В начало каждого файла вставляйте шапку (если авторов много, то перечислите через запятую): 17 | 18 | ```C 19 | /** 20 | * @file kernel.c 21 | * @author Арен Елчинян (a2.dev@yandex.com) 22 | * @brief Главный файл ядра 23 | * @version 0.1.0 24 | * @date 17-10-2022 25 | * 26 | * @copyright Арен Елчинян (c) 2022 27 | * 28 | */ 29 | ``` 30 | 31 | Комментарии к объявлению функции должны описывать использование функции (кроме самых очевидных случаев). 32 | Комментарии к определению функции описывают реализацию. 33 | Ко всем глобальным переменным следует писать комментарий о их назначении и (если не очевидно) почему они должны быть глобальными. Например: 34 | 35 | ```C 36 | // Максимальный размер строки для имени пользователя 37 | const uint8_t username_max_name_length = 255; 38 | ``` 39 | 40 | Комментируйте реализацию функции или алгоритма в случае наличия неочевидных, интересных, важных кусков кода. 41 | 42 | Обращайте внимание на пунктуацию, орфографию и грамматику: намного проще читать грамотно написанные комментарии. 43 | 44 | ### Переменные 45 | 46 | Название переменной должно четко описывать назначение. 47 | Названия переменных записываются в нижнем регистре, а слова в названиях отделяются нижним подчеркиванием. 48 | Название глобальных переменных имеет синтаксис: %имя файла%_%имя переменной%. 49 | Объявляйте переменные в начале функции. Если это глобальные переменные, то в начале файла. 50 | По возможности инициализируйте переменные при объявлении. Численные с помощью нуля, указатели — NULL. 51 | Лучше использовать явные размеры: вместо int - int32_t, вместо char - int8_t и тд. 52 | 53 | ```C 54 | // Правильное объявление переменных 55 | 56 | uint32_t hello_size = 14; // Размер строки + 0 в конце 57 | const uint8_t hello_string[] = "Hello, World!"; 58 | void *hello_ptr = NULL; 59 | ``` 60 | 61 | ```C 62 | // Неправильное объявление переменных 63 | 64 | int q; // Не понятно, что за q 65 | long myvar[] = "1234567"; // Тип данных слишком большой 66 | void *trash; // В указателе при инициализации будет мусор 67 | ``` 68 | 69 | ### Циклы 70 | 71 | i, j, k — стандартные названия для итераторов цикла. 72 | Соблюдайте однородность переноса скобок. 73 | Тип данных используемых в цикле for должен быть указан в самом цикле. 74 | 75 | ```C 76 | // Правильный цикл 77 | 78 | uint8_t my_array[256]; // Массив для тестирования циклов 79 | 80 | // Заполняем массив значениями 81 | for (uint8_t i = 0; i < 256; ++i) { 82 | my_array[i] = i; // Записываем в массив по индексу i данные 83 | } 84 | ``` 85 | 86 | ```C 87 | // Неправильный цикл 88 | 89 | bool my_array[256]; // Тип данных не соответствует 90 | 91 | int i; // 1. Неявный размер 2. Объявление вне цикла 92 | 93 | for ( 94 | ; i < 1000; i = i + 1 95 | ) { // Выход за пределы массива, убогая реализация инкремента 96 | my_array[i] = i * 40; // Выход за пределы типа данных 97 | } 98 | ``` 99 | 100 | ## Документация 101 | 102 | Документация должна давать описание каждой функции, константы, глобальной переменной, типа данных, системной функции и тд. 103 | Документирование в комментариях приветствуется, так как используется doxygen. 104 | Документацию желательно хранить в виде markdown. 105 | 106 | ## Коммиты 107 | 108 | Префикс коммитов: 109 | 110 | - фича: Полезное нововведение (инновация) 111 | - исправление: Исправление ошибок, предупреждений, косяков 112 | - дизайн: Исправления и новвоведения связанные с интерфейсом 113 | - рефакторинг: Рефакторинг определенных участков кода 114 | - тестирование: Все что связанно с тестированием 115 | - сборка: Все что связанно с сборкой 116 | - документация: Все что связанно с документированием 117 | - обслуживание: Поддержка кода (разрешены смайлики) 118 | 119 | Примеры: 120 | 121 | ```bash 122 | git commit -m "[фича] Поддержка https протокола" 123 | ``` 124 | 125 | ```bash 126 | git commit -m "[исправление] Устранение предупреждений компилятора" 127 | ``` 128 | 129 | ```bash 130 | git commit -m "[дизайн] Внедрение ttf шрифтов в интерфейс" 131 | ``` 132 | 133 | ```bash 134 | git commit -m "[рефакторинг] Вынос всех ассемблерных вставок в прослойку" 135 | ``` 136 | 137 | ```bash 138 | git commit -m "[тестирование] Добавление тестов для драйвера ACHI" 139 | ``` 140 | 141 | ```bash 142 | git commit -m "[сборка] Добавление загрузчика BOOTBOOT в автосборку" 143 | ``` 144 | 145 | ```bash 146 | git commit -m "[документация] Дополнение документации протокола ARP" 147 | ``` 148 | 149 | ```bash 150 | git commit -m "[обслуживание] Обновление загрузчика limine" 151 | ``` 152 | -------------------------------------------------------------------------------- /src/kernel/multiboot2.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file multiboot2.c 3 | * @author Арен Елчинян (a2.dev@yandex.com) 4 | * @brief 5 | * @version 0.1.0 6 | * @date 20-10-2022 7 | * 8 | * @copyright Арен Елчинян (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | /** 19 | * @brief Получение данных из multiboot2 20 | * 21 | * @param addr Адресс структуры Multiboot2 22 | * @return true В случае успешной инициализации 23 | * @return false В случае ошибки 24 | */ 25 | bool multiboot2_init(unsigned int addr) { 26 | struct multiboot_tag *tag; 27 | unsigned size; 28 | 29 | size = *(unsigned*) addr; 30 | 31 | com1_log ("Announced mbi size %x", size); 32 | 33 | for (tag = (struct multiboot_tag *) (addr + 8); 34 | tag->type != MULTIBOOT_TAG_TYPE_END; 35 | tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag 36 | + ((tag->size + 7) & ~7))) { 37 | com1_log ("Tag %x, Size %x", tag->type, tag->size); 38 | switch (tag->type) { 39 | case MULTIBOOT_TAG_TYPE_CMDLINE: 40 | com1_log ("Command line = %s", 41 | ((struct multiboot_tag_string *) tag)->string); 42 | break; 43 | case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME: 44 | com1_log ("Boot loader name = %s", 45 | ((struct multiboot_tag_string *) tag)->string); 46 | break; 47 | case MULTIBOOT_TAG_TYPE_MODULE: 48 | com1_log ("Module at %x-%x. Command line %s", 49 | ((struct multiboot_tag_module *) tag)->mod_start, 50 | ((struct multiboot_tag_module *) tag)->mod_end, 51 | ((struct multiboot_tag_module *) tag)->cmdline); 52 | break; 53 | case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: 54 | com1_log ("mem_lower = %uKB, mem_upper = %uKB", 55 | ((struct multiboot_tag_basic_meminfo *) tag)->mem_lower, 56 | ((struct multiboot_tag_basic_meminfo *) tag)->mem_upper); 57 | break; 58 | case MULTIBOOT_TAG_TYPE_BOOTDEV: 59 | com1_log ("Boot device %x,%u,%u", 60 | ((struct multiboot_tag_bootdev *) tag)->biosdev, 61 | ((struct multiboot_tag_bootdev *) tag)->slice, 62 | ((struct multiboot_tag_bootdev *) tag)->part); 63 | break; 64 | case MULTIBOOT_TAG_TYPE_MMAP: { 65 | multiboot_memory_map_t *mmap; 66 | 67 | com1_log ("mmap"); 68 | 69 | for (mmap = ((struct multiboot_tag_mmap *) tag)->entries; 70 | (multiboot_uint8_t *) mmap 71 | < (multiboot_uint8_t *) tag + tag->size; 72 | mmap = (multiboot_memory_map_t *) 73 | ((unsigned long) mmap 74 | + ((struct multiboot_tag_mmap *) tag)->entry_size)) 75 | com1_log (" base_addr = %x %x," 76 | " length = %x %x, type = %x", 77 | (unsigned) (mmap->addr >> 32), 78 | (unsigned) (mmap->addr & 0xffffffff), 79 | (unsigned) (mmap->len >> 32), 80 | (unsigned) (mmap->len & 0xffffffff), 81 | (unsigned) mmap->type); 82 | } 83 | break; 84 | case MULTIBOOT_TAG_TYPE_VBE: { 85 | struct multiboot_tag_vbe *tag_vbe = (struct multiboot_tag_vbe *) tag; 86 | com1_log("vbe_mode: %d", tag_vbe->vbe_mode); 87 | com1_log("vbe_interface_seg: %d", tag_vbe->vbe_interface_seg); 88 | com1_log("vbe_interface_off: %d", tag_vbe->vbe_interface_off); 89 | com1_log("vbe_interface_len: %d", tag_vbe->vbe_interface_len); 90 | break; 91 | } 92 | case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: { 93 | multiboot_uint32_t color; 94 | struct multiboot_tag_framebuffer *tagfb = (struct multiboot_tag_framebuffer *) tag; 95 | void *fb = (void *) (unsigned long) tagfb->common.framebuffer_addr; 96 | 97 | switch (tagfb->common.framebuffer_type) { 98 | case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED: { 99 | unsigned best_distance, distance; 100 | struct multiboot_color *palette; 101 | 102 | palette = tagfb->framebuffer_palette; 103 | 104 | color = 0; 105 | best_distance = 4*256*256; 106 | 107 | for (unsigned int i = 0; i < tagfb->framebuffer_palette_num_colors; i++) { 108 | distance = (0xff - palette[i].blue) 109 | * (0xff - palette[i].blue) 110 | + palette[i].red * palette[i].red 111 | + palette[i].green * palette[i].green; 112 | if (distance < best_distance) 113 | { 114 | color = i; 115 | best_distance = distance; 116 | } 117 | } 118 | } 119 | break; 120 | 121 | case MULTIBOOT_FRAMEBUFFER_TYPE_RGB: 122 | color = ((1 << tagfb->framebuffer_blue_mask_size) - 1) 123 | << tagfb->framebuffer_blue_field_position; 124 | break; 125 | 126 | case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT: 127 | color = '\\' | 0x0100; 128 | break; 129 | 130 | default: 131 | color = 0xffffffff; 132 | break; 133 | } 134 | 135 | for (unsigned int i = 0; i < tagfb->common.framebuffer_width && i < tagfb->common.framebuffer_height; i++) { 136 | switch (tagfb->common.framebuffer_bpp) { 137 | case 8: { 138 | multiboot_uint8_t *pixel = fb 139 | + tagfb->common.framebuffer_pitch * i + i; 140 | *pixel = color; 141 | } 142 | break; 143 | case 15: 144 | case 16: { 145 | multiboot_uint16_t *pixel 146 | = fb + tagfb->common.framebuffer_pitch * i + 2 * i; 147 | *pixel = color; 148 | } 149 | break; 150 | case 24: { 151 | multiboot_uint32_t *pixel 152 | = fb + tagfb->common.framebuffer_pitch * i + 3 * i; 153 | *pixel = (color & 0xffffff) | (*pixel & 0xff000000); 154 | } 155 | break; 156 | case 32: { 157 | multiboot_uint32_t *pixel 158 | = fb + tagfb->common.framebuffer_pitch * i + 4 * i; 159 | *pixel = color; 160 | } 161 | break; 162 | } 163 | } 164 | break; 165 | } 166 | } 167 | } 168 | tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag 169 | + ((tag->size + 7) & ~7)); 170 | com1_log ("Total mbi size %x", (unsigned) tag - addr); 171 | 172 | return true; 173 | } -------------------------------------------------------------------------------- /include/multiboot2.h: -------------------------------------------------------------------------------- 1 | /* multiboot2.h - Multiboot 2 header file. */ 2 | /* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY 17 | * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 19 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef MULTIBOOT_HEADER 23 | #define MULTIBOOT_HEADER 1 24 | 25 | /* How many bytes from the start of the file we search for the header. */ 26 | #define MULTIBOOT_SEARCH 32768 27 | #define MULTIBOOT_HEADER_ALIGN 8 28 | 29 | /* The magic field should contain this. */ 30 | #define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 31 | 32 | /* This should be in %eax. */ 33 | #define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 34 | 35 | /* Alignment of multiboot modules. */ 36 | #define MULTIBOOT_MOD_ALIGN 0x00001000 37 | 38 | /* Alignment of the multiboot info structure. */ 39 | #define MULTIBOOT_INFO_ALIGN 0x00000008 40 | 41 | /* Flags set in the ’flags’ member of the multiboot header. */ 42 | 43 | #define MULTIBOOT_TAG_ALIGN 8 44 | #define MULTIBOOT_TAG_TYPE_END 0 45 | #define MULTIBOOT_TAG_TYPE_CMDLINE 1 46 | #define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2 47 | #define MULTIBOOT_TAG_TYPE_MODULE 3 48 | #define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4 49 | #define MULTIBOOT_TAG_TYPE_BOOTDEV 5 50 | #define MULTIBOOT_TAG_TYPE_MMAP 6 51 | #define MULTIBOOT_TAG_TYPE_VBE 7 52 | #define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 53 | #define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9 54 | #define MULTIBOOT_TAG_TYPE_APM 10 55 | #define MULTIBOOT_TAG_TYPE_EFI32 11 56 | #define MULTIBOOT_TAG_TYPE_EFI64 12 57 | #define MULTIBOOT_TAG_TYPE_SMBIOS 13 58 | #define MULTIBOOT_TAG_TYPE_ACPI_OLD 14 59 | #define MULTIBOOT_TAG_TYPE_ACPI_NEW 15 60 | #define MULTIBOOT_TAG_TYPE_NETWORK 16 61 | #define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 62 | #define MULTIBOOT_TAG_TYPE_EFI_BS 18 63 | #define MULTIBOOT_TAG_TYPE_EFI32_IH 19 64 | #define MULTIBOOT_TAG_TYPE_EFI64_IH 20 65 | #define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 66 | 67 | #define MULTIBOOT_HEADER_TAG_END 0 68 | #define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 69 | #define MULTIBOOT_HEADER_TAG_ADDRESS 2 70 | #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3 71 | #define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4 72 | #define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5 73 | #define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 74 | #define MULTIBOOT_HEADER_TAG_EFI_BS 7 75 | #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8 76 | #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 77 | #define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 78 | 79 | #define MULTIBOOT_ARCHITECTURE_I386 0 80 | #define MULTIBOOT_ARCHITECTURE_MIPS32 4 81 | #define MULTIBOOT_HEADER_TAG_OPTIONAL 1 82 | 83 | #define MULTIBOOT_LOAD_PREFERENCE_NONE 0 84 | #define MULTIBOOT_LOAD_PREFERENCE_LOW 1 85 | #define MULTIBOOT_LOAD_PREFERENCE_HIGH 2 86 | 87 | #define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1 88 | #define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 89 | 90 | #ifndef ASM_FILE 91 | 92 | typedef unsigned char multiboot_uint8_t; 93 | typedef unsigned short multiboot_uint16_t; 94 | typedef unsigned int multiboot_uint32_t; 95 | typedef unsigned long long multiboot_uint64_t; 96 | 97 | struct multiboot_header 98 | { 99 | /* Must be MULTIBOOT_MAGIC - see above. */ 100 | multiboot_uint32_t magic; 101 | 102 | /* ISA */ 103 | multiboot_uint32_t architecture; 104 | 105 | /* Total header length. */ 106 | multiboot_uint32_t header_length; 107 | 108 | /* The above fields plus this one must equal 0 mod 2^32. */ 109 | multiboot_uint32_t checksum; 110 | }; 111 | 112 | struct multiboot_header_tag 113 | { 114 | multiboot_uint16_t type; 115 | multiboot_uint16_t flags; 116 | multiboot_uint32_t size; 117 | }; 118 | 119 | struct multiboot_header_tag_information_request 120 | { 121 | multiboot_uint16_t type; 122 | multiboot_uint16_t flags; 123 | multiboot_uint32_t size; 124 | multiboot_uint32_t requests[0]; 125 | }; 126 | 127 | struct multiboot_header_tag_address 128 | { 129 | multiboot_uint16_t type; 130 | multiboot_uint16_t flags; 131 | multiboot_uint32_t size; 132 | multiboot_uint32_t header_addr; 133 | multiboot_uint32_t load_addr; 134 | multiboot_uint32_t load_end_addr; 135 | multiboot_uint32_t bss_end_addr; 136 | }; 137 | 138 | struct multiboot_header_tag_entry_address 139 | { 140 | multiboot_uint16_t type; 141 | multiboot_uint16_t flags; 142 | multiboot_uint32_t size; 143 | multiboot_uint32_t entry_addr; 144 | }; 145 | 146 | struct multiboot_header_tag_console_flags 147 | { 148 | multiboot_uint16_t type; 149 | multiboot_uint16_t flags; 150 | multiboot_uint32_t size; 151 | multiboot_uint32_t console_flags; 152 | }; 153 | 154 | struct multiboot_header_tag_framebuffer 155 | { 156 | multiboot_uint16_t type; 157 | multiboot_uint16_t flags; 158 | multiboot_uint32_t size; 159 | multiboot_uint32_t width; 160 | multiboot_uint32_t height; 161 | multiboot_uint32_t depth; 162 | }; 163 | 164 | struct multiboot_header_tag_module_align 165 | { 166 | multiboot_uint16_t type; 167 | multiboot_uint16_t flags; 168 | multiboot_uint32_t size; 169 | }; 170 | 171 | struct multiboot_header_tag_relocatable 172 | { 173 | multiboot_uint16_t type; 174 | multiboot_uint16_t flags; 175 | multiboot_uint32_t size; 176 | multiboot_uint32_t min_addr; 177 | multiboot_uint32_t max_addr; 178 | multiboot_uint32_t align; 179 | multiboot_uint32_t preference; 180 | }; 181 | 182 | struct multiboot_color 183 | { 184 | multiboot_uint8_t red; 185 | multiboot_uint8_t green; 186 | multiboot_uint8_t blue; 187 | }; 188 | 189 | struct multiboot_mmap_entry 190 | { 191 | multiboot_uint64_t addr; 192 | multiboot_uint64_t len; 193 | #define MULTIBOOT_MEMORY_AVAILABLE 1 194 | #define MULTIBOOT_MEMORY_RESERVED 2 195 | #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 196 | #define MULTIBOOT_MEMORY_NVS 4 197 | #define MULTIBOOT_MEMORY_BADRAM 5 198 | multiboot_uint32_t type; 199 | multiboot_uint32_t zero; 200 | }; 201 | typedef struct multiboot_mmap_entry multiboot_memory_map_t; 202 | 203 | struct multiboot_tag 204 | { 205 | multiboot_uint32_t type; 206 | multiboot_uint32_t size; 207 | }; 208 | 209 | struct multiboot_tag_string 210 | { 211 | multiboot_uint32_t type; 212 | multiboot_uint32_t size; 213 | char string[0]; 214 | }; 215 | 216 | struct multiboot_tag_module 217 | { 218 | multiboot_uint32_t type; 219 | multiboot_uint32_t size; 220 | multiboot_uint32_t mod_start; 221 | multiboot_uint32_t mod_end; 222 | char cmdline[0]; 223 | }; 224 | 225 | struct multiboot_tag_basic_meminfo 226 | { 227 | multiboot_uint32_t type; 228 | multiboot_uint32_t size; 229 | multiboot_uint32_t mem_lower; 230 | multiboot_uint32_t mem_upper; 231 | }; 232 | 233 | struct multiboot_tag_bootdev 234 | { 235 | multiboot_uint32_t type; 236 | multiboot_uint32_t size; 237 | multiboot_uint32_t biosdev; 238 | multiboot_uint32_t slice; 239 | multiboot_uint32_t part; 240 | }; 241 | 242 | struct multiboot_tag_mmap 243 | { 244 | multiboot_uint32_t type; 245 | multiboot_uint32_t size; 246 | multiboot_uint32_t entry_size; 247 | multiboot_uint32_t entry_version; 248 | struct multiboot_mmap_entry entries[0]; 249 | }; 250 | 251 | struct multiboot_vbe_info_block 252 | { 253 | multiboot_uint8_t external_specification[512]; 254 | }; 255 | 256 | struct multiboot_vbe_mode_info_block 257 | { 258 | multiboot_uint8_t external_specification[256]; 259 | }; 260 | 261 | struct multiboot_tag_vbe 262 | { 263 | multiboot_uint32_t type; 264 | multiboot_uint32_t size; 265 | 266 | multiboot_uint16_t vbe_mode; 267 | multiboot_uint16_t vbe_interface_seg; 268 | multiboot_uint16_t vbe_interface_off; 269 | multiboot_uint16_t vbe_interface_len; 270 | 271 | struct multiboot_vbe_info_block vbe_control_info; 272 | struct multiboot_vbe_mode_info_block vbe_mode_info; 273 | }; 274 | 275 | struct multiboot_tag_framebuffer_common 276 | { 277 | multiboot_uint32_t type; 278 | multiboot_uint32_t size; 279 | 280 | multiboot_uint64_t framebuffer_addr; 281 | multiboot_uint32_t framebuffer_pitch; 282 | multiboot_uint32_t framebuffer_width; 283 | multiboot_uint32_t framebuffer_height; 284 | multiboot_uint8_t framebuffer_bpp; 285 | #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 286 | #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 287 | #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 288 | multiboot_uint8_t framebuffer_type; 289 | multiboot_uint16_t reserved; 290 | }; 291 | 292 | struct multiboot_tag_framebuffer 293 | { 294 | struct multiboot_tag_framebuffer_common common; 295 | 296 | union 297 | { 298 | struct 299 | { 300 | multiboot_uint16_t framebuffer_palette_num_colors; 301 | struct multiboot_color framebuffer_palette[0]; 302 | }; 303 | struct 304 | { 305 | multiboot_uint8_t framebuffer_red_field_position; 306 | multiboot_uint8_t framebuffer_red_mask_size; 307 | multiboot_uint8_t framebuffer_green_field_position; 308 | multiboot_uint8_t framebuffer_green_mask_size; 309 | multiboot_uint8_t framebuffer_blue_field_position; 310 | multiboot_uint8_t framebuffer_blue_mask_size; 311 | }; 312 | }; 313 | }; 314 | 315 | struct multiboot_tag_elf_sections 316 | { 317 | multiboot_uint32_t type; 318 | multiboot_uint32_t size; 319 | multiboot_uint32_t num; 320 | multiboot_uint32_t entsize; 321 | multiboot_uint32_t shndx; 322 | char sections[0]; 323 | }; 324 | 325 | struct multiboot_tag_apm 326 | { 327 | multiboot_uint32_t type; 328 | multiboot_uint32_t size; 329 | multiboot_uint16_t version; 330 | multiboot_uint16_t cseg; 331 | multiboot_uint32_t offset; 332 | multiboot_uint16_t cseg_16; 333 | multiboot_uint16_t dseg; 334 | multiboot_uint16_t flags; 335 | multiboot_uint16_t cseg_len; 336 | multiboot_uint16_t cseg_16_len; 337 | multiboot_uint16_t dseg_len; 338 | }; 339 | 340 | struct multiboot_tag_efi32 341 | { 342 | multiboot_uint32_t type; 343 | multiboot_uint32_t size; 344 | multiboot_uint32_t pointer; 345 | }; 346 | 347 | struct multiboot_tag_efi64 348 | { 349 | multiboot_uint32_t type; 350 | multiboot_uint32_t size; 351 | multiboot_uint64_t pointer; 352 | }; 353 | 354 | struct multiboot_tag_smbios 355 | { 356 | multiboot_uint32_t type; 357 | multiboot_uint32_t size; 358 | multiboot_uint8_t major; 359 | multiboot_uint8_t minor; 360 | multiboot_uint8_t reserved[6]; 361 | multiboot_uint8_t tables[0]; 362 | }; 363 | 364 | struct multiboot_tag_old_acpi 365 | { 366 | multiboot_uint32_t type; 367 | multiboot_uint32_t size; 368 | multiboot_uint8_t rsdp[0]; 369 | }; 370 | 371 | struct multiboot_tag_new_acpi 372 | { 373 | multiboot_uint32_t type; 374 | multiboot_uint32_t size; 375 | multiboot_uint8_t rsdp[0]; 376 | }; 377 | 378 | struct multiboot_tag_network 379 | { 380 | multiboot_uint32_t type; 381 | multiboot_uint32_t size; 382 | multiboot_uint8_t dhcpack[0]; 383 | }; 384 | 385 | struct multiboot_tag_efi_mmap 386 | { 387 | multiboot_uint32_t type; 388 | multiboot_uint32_t size; 389 | multiboot_uint32_t descr_size; 390 | multiboot_uint32_t descr_vers; 391 | multiboot_uint8_t efi_mmap[0]; 392 | }; 393 | 394 | struct multiboot_tag_efi32_ih 395 | { 396 | multiboot_uint32_t type; 397 | multiboot_uint32_t size; 398 | multiboot_uint32_t pointer; 399 | }; 400 | 401 | struct multiboot_tag_efi64_ih 402 | { 403 | multiboot_uint32_t type; 404 | multiboot_uint32_t size; 405 | multiboot_uint64_t pointer; 406 | }; 407 | 408 | struct multiboot_tag_load_base_addr 409 | { 410 | multiboot_uint32_t type; 411 | multiboot_uint32_t size; 412 | multiboot_uint32_t load_base_addr; 413 | }; 414 | 415 | #endif /* ! ASM_FILE */ 416 | 417 | #endif /* ! MULTIBOOT_HEADER */ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------