Начальный код инициализации
This commit is contained in:
parent
6adf6fad3a
commit
05d4a95ccd
BIN
boot/CYRILL1.F16
BIN
boot/CYRILL1.F16
Binary file not shown.
BIN
boot/CYRILL2.F16
BIN
boot/CYRILL2.F16
Binary file not shown.
BIN
boot/CYRILL3.F16
BIN
boot/CYRILL3.F16
Binary file not shown.
2
build.py
2
build.py
|
@ -11,7 +11,7 @@ WARN_FLAGS = "-Wall -Wextra"
|
|||
STANDART_FLAGS = "-std=gnu11"
|
||||
PROTECT_FLAGS = "-O0 -pipe -ffreestanding -fno-stack-protector -fno-lto -fno-stack-check -fno-PIC -fno-PIE"
|
||||
CHARSET_FLAGS = "-finput-charset=UTF-8 -fexec-charset=cp1251"
|
||||
LIBS_FLAGS = "-Ilimine"
|
||||
LIBS_FLAGS = "-Ilimine -Iinclude"
|
||||
|
||||
|
||||
def find_files(directory, extensions):
|
||||
|
|
|
@ -2,8 +2,8 @@ TIMEOUT=5
|
|||
DEFAULT_ENTRY=0
|
||||
INTERFACE_BRANDING=By Aren Elchinyan
|
||||
|
||||
TERM_FONT=boot:///CYRILL2.F16
|
||||
TERM_FONT_SIZE=8x16
|
||||
#TERM_FONT=boot:///CYRILL2.F16
|
||||
#TERM_FONT_SIZE=8x16
|
||||
|
||||
:MSEOS (KASLR on)
|
||||
PROTOCOL=limine
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
namespace arch {
|
||||
void init();
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
namespace cpu {
|
||||
void init();
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
namespace fb {
|
||||
void init();
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
|
||||
namespace tool {
|
||||
void format(void (*putc)(char c), const char *format_string, va_list args);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#include <limine.h>
|
||||
|
||||
|
||||
|
||||
namespace arch {
|
||||
static volatile struct limine_kernel_address_request kernel_address_request = {
|
||||
.id = LIMINE_KERNEL_ADDRESS_REQUEST,
|
||||
.revision = 0,
|
||||
.response = (struct limine_kernel_address_response *)0
|
||||
};
|
||||
|
||||
struct limine_kernel_address_response *kernel_address_response;
|
||||
|
||||
void init() {
|
||||
kernel_address_response = kernel_address_request.response;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
namespace cpu {
|
||||
static bool x87_support = false;
|
||||
static bool sse_support = false;
|
||||
static bool avx_support = false;
|
||||
|
||||
void init() {
|
||||
x87_support = false;
|
||||
sse_support = false;
|
||||
avx_support = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#include <limine.h>
|
||||
|
||||
|
||||
|
||||
namespace fb {
|
||||
static volatile struct limine_framebuffer_request framebuffer_request = {
|
||||
.id = LIMINE_FRAMEBUFFER_REQUEST,
|
||||
.revision = 0,
|
||||
.response = (struct limine_framebuffer_response *)0
|
||||
};
|
||||
|
||||
struct limine_framebuffer_response *framebuffer_response;
|
||||
struct limine_framebuffer *boot_framebuffer;
|
||||
uint32_t *fb_addr;
|
||||
uint64_t width;
|
||||
uint64_t height;
|
||||
uint64_t pitch;
|
||||
uint16_t bpp;
|
||||
|
||||
void init() {
|
||||
framebuffer_response = framebuffer_request.response;
|
||||
boot_framebuffer = framebuffer_response->framebuffers[0];
|
||||
fb_addr = (uint32_t*)boot_framebuffer->address;
|
||||
width = boot_framebuffer->width;
|
||||
height = boot_framebuffer->height;
|
||||
bpp = boot_framebuffer->bpp;
|
||||
|
||||
for (uint64_t i = 0; i < width * height; i++) {
|
||||
fb_addr[i] = 0x0000FF;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
#include <limine.h>
|
||||
#include <arch.h>
|
||||
#include <cpu.h>
|
||||
#include <fb.h>
|
||||
#include <tool.h>
|
||||
|
||||
|
||||
|
||||
|
@ -6,6 +10,10 @@
|
|||
extern "C" void _start() {
|
||||
asm volatile("cli");
|
||||
|
||||
arch::init();
|
||||
cpu::init();
|
||||
fb::init();
|
||||
|
||||
for (;;) {
|
||||
asm volatile("hlt");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
#include <limine.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace tool {
|
||||
// Функция для форматированного вывода
|
||||
void format(void (*putc)(char c), const char *format_string, va_list args) {
|
||||
while (*format_string != '\0') {
|
||||
if (*format_string == '%') {
|
||||
format_string++;
|
||||
if (*format_string == '\0') {
|
||||
break; // Неожиданный конец строки формата
|
||||
}
|
||||
if (*format_string == '%') {
|
||||
putc('%'); // Вывод одного символа '%'
|
||||
} else if (*format_string == 'd') {
|
||||
int arg = va_arg(args, int);
|
||||
// Преобразование целочисленного аргумента в строку и вывод каждого символа
|
||||
if (arg < 0) {
|
||||
putc('-');
|
||||
arg = -arg;
|
||||
}
|
||||
if (arg == 0) {
|
||||
putc('0');
|
||||
} else {
|
||||
char buffer[10]; // Предполагаем, что максимальное число из 10 цифр
|
||||
int i = 0;
|
||||
|
||||
while (arg > 0) {
|
||||
buffer[i++] = '0' + (arg % 10);
|
||||
arg /= 10;
|
||||
}
|
||||
|
||||
while (i > 0) {
|
||||
putc(buffer[--i]);
|
||||
}
|
||||
}
|
||||
} else if (*format_string == 's') {
|
||||
const char* arg = va_arg(args, const char*);
|
||||
// Вывод каждого символа строки
|
||||
while (*arg != '\0') {
|
||||
putc(*arg);
|
||||
arg++;
|
||||
}
|
||||
} else {
|
||||
// Неподдерживаемый спецификатор формата
|
||||
putc('?');
|
||||
}
|
||||
} else {
|
||||
putc(*format_string);
|
||||
}
|
||||
|
||||
format_string++;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue