Add i386 support
This commit is contained in:
parent
08a80c7731
commit
20e7a7486a
7
Makefile
7
Makefile
|
|
@ -10,7 +10,12 @@ $(COMPONENTS):
|
||||||
|
|
||||||
disk: $(KERNEL_HDD)
|
disk: $(KERNEL_HDD)
|
||||||
run: $(KERNEL_HDD)
|
run: $(KERNEL_HDD)
|
||||||
qemu-system-x86_64 -m 2G -drive file=$(KERNEL_HDD),format=raw
|
qemu-system-$(ARCH) \
|
||||||
|
-m 16M \
|
||||||
|
-drive file=$(KERNEL_HDD),format=raw \
|
||||||
|
-smp 2 \
|
||||||
|
-enable-kvm \
|
||||||
|
-debugcon stdio
|
||||||
|
|
||||||
ext/limine/limine-install:
|
ext/limine/limine-install:
|
||||||
$(MAKE) -C ext/limine/ limine-install
|
$(MAKE) -C ext/limine/ limine-install
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
TIMEOUT=5
|
TIMEOUT=5
|
||||||
|
E9_OUTPUT=yes
|
||||||
|
|
||||||
:KornOS
|
:KornOS
|
||||||
PROTOCOL=stivale2
|
PROTOCOL=stivale2
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ LD = ld -m elf_$(ARCH)
|
||||||
CFLAGS ?= -O2
|
CFLAGS ?= -O2
|
||||||
CFLAGS := $(CFLAGS) $(ARCH_CFLAGS) \
|
CFLAGS := $(CFLAGS) $(ARCH_CFLAGS) \
|
||||||
-Wall -Wextra -pedantic -Wno-language-extension-token -std=gnu11 -I../ext/limine/stivale -fPIE
|
-Wall -Wextra -pedantic -Wno-language-extension-token -std=gnu11 -I../ext/limine/stivale -fPIE
|
||||||
LDFLAGS := $(LDFLAGS) -T linker.ld
|
LDFLAGS := $(LDFLAGS) -T linker.ld.$(ARCH)
|
||||||
|
|
||||||
|
|
||||||
TARGET := kernel
|
TARGET := kernel
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
ENTRY(stivale2_main)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = 1M + 512K;
|
||||||
|
|
||||||
|
.stivale2hdr ALIGN(4K) :
|
||||||
|
{
|
||||||
|
KEEP(*(.stivalehdr))
|
||||||
|
}
|
||||||
|
|
||||||
|
.text ALIGN(4K) :
|
||||||
|
{
|
||||||
|
KEEP(*(.text*))
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata ALIGN(4K) :
|
||||||
|
{
|
||||||
|
KEEP(*(.rodata*))
|
||||||
|
}
|
||||||
|
|
||||||
|
.data ALIGN(4K) :
|
||||||
|
{
|
||||||
|
KEEP(*(.data*))
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss ALIGN(4K) :
|
||||||
|
{
|
||||||
|
KEEP(*(COMMON))
|
||||||
|
KEEP(*(.bss*))
|
||||||
|
}
|
||||||
|
|
||||||
|
_stack = 1M;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include <stivale2.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "../../main.h"
|
||||||
|
|
||||||
|
void stivale2_main(struct stivale2_struct *info);
|
||||||
|
|
||||||
|
struct stivale2_header_tag_smp smp_request = {
|
||||||
|
.tag = {
|
||||||
|
.identifier = STIVALE2_HEADER_TAG_SMP_ID,
|
||||||
|
.next = 0
|
||||||
|
},
|
||||||
|
.flags = 02
|
||||||
|
};
|
||||||
|
|
||||||
|
__attribute__((section(".stivale2hdr"), used))
|
||||||
|
struct stivale2_header header2 = {
|
||||||
|
.entry_point = 0,
|
||||||
|
.stack = 1024*1024,
|
||||||
|
.flags = 0,
|
||||||
|
.tags = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
void stivale2_main(struct stivale2_struct *info) {
|
||||||
|
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};
|
||||||
|
kmain(3, argv);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
void halt_catch_fire() {
|
||||||
|
asm volatile ("cli");
|
||||||
|
while(1) asm volatile ("hlt");
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "vga.h"
|
||||||
|
|
||||||
|
static const size_t VGA_WIDTH = 80;
|
||||||
|
static const size_t VGA_HEIGHT = 25;
|
||||||
|
|
||||||
|
static volatile size_t terminal_row;
|
||||||
|
static volatile size_t terminal_column;
|
||||||
|
static volatile uint8_t current_color = VGA_WHITE;
|
||||||
|
static uint16_t *terminal_buffer = (uint16_t*)0xb8000;
|
||||||
|
|
||||||
|
void vga_putc(char c) {
|
||||||
|
size_t index = terminal_row*VGA_WIDTH + terminal_column;
|
||||||
|
if(c == '\t') {
|
||||||
|
vga_putc(' ');
|
||||||
|
while(terminal_column % 8 != 0) {
|
||||||
|
vga_putc(' ');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(c != '\n' && c != '\t')
|
||||||
|
terminal_buffer[index] = (uint16_t)c | (uint16_t)(current_color) << 8;
|
||||||
|
|
||||||
|
if (c == '\n' || ++terminal_column == VGA_WIDTH) {
|
||||||
|
terminal_column = 0;
|
||||||
|
if (++terminal_row == VGA_HEIGHT)
|
||||||
|
terminal_row = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vga_puts(char *c) {
|
||||||
|
char cur = *(c++);
|
||||||
|
while(cur != '\0') {
|
||||||
|
vga_putc(cur);
|
||||||
|
cur = *(c++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vga_setcolor(uint8_t new_color) {
|
||||||
|
current_color = new_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vga_write_elsewhere(char *c, size_t y, size_t x) {
|
||||||
|
size_t old_row = terminal_row;
|
||||||
|
size_t old_column = terminal_column;
|
||||||
|
terminal_row = y;
|
||||||
|
terminal_column = x;
|
||||||
|
vga_puts(c);
|
||||||
|
terminal_row=old_row;
|
||||||
|
terminal_column=old_column;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define VGA_BLACK 0
|
||||||
|
#define VGA_BLUE 1
|
||||||
|
#define VGA_GREEN 2
|
||||||
|
#define VGA_CYAN 3
|
||||||
|
#define VGA_RED 4
|
||||||
|
#define VGA_PURPLE 5
|
||||||
|
#define VGA_BROWN 6
|
||||||
|
#define VGA_GRAY 7
|
||||||
|
#define VGA_DARK_GRAY 8
|
||||||
|
#define VGA_LIGHT_BLUE 9
|
||||||
|
#define VGA_LIGH_GREEN 10
|
||||||
|
#define VGA_LIGHT_CYAN 11
|
||||||
|
#define VGA_LIGHT_RED 12
|
||||||
|
#define VGA_LIGHT_PURPLE 13
|
||||||
|
#define VGA_YELLOW 14
|
||||||
|
#define VGA_WHITE 15
|
||||||
|
|
||||||
|
void vga_putc(char c);
|
||||||
|
void vga_puts(char *c);
|
||||||
|
void vga_setcolor(uint8_t color);
|
||||||
|
void vga_write_elsewhere(char *c, size_t y, size_t x);
|
||||||
Loading…
Reference in New Issue