Add config options to control VESA

This commit is contained in:
Mark
2020-01-02 22:49:50 +02:00
parent 5dc3bf9f34
commit 90353d19e9
8 changed files with 57 additions and 21 deletions
+4
View File
@@ -7,3 +7,7 @@ export AMD64_TRACE_IRQ=1
# Emulation
export QEMU_SMP=4
# export QEMU_MEM=512
export VESA_MODE=0
export VESA_WIDTH=1024
export VESA_HEIGHT=768
export VESA_DEPTH=32
+2 -2
View File
@@ -67,11 +67,11 @@ $(O)/sys/amd64/loader.elf: $(loader_OBJS) $(loader_LINKER) config
$(O)/sys/amd64/loader/%.o: sys/amd64/loader/%.S $(HEADERS) config
@printf " AS\t%s\n" $(@:$(O)/%=%)
@$(CC86) $(loader_CFLAGS) -D__ASM__ -c -o $@ $<
@$(CC86) $(loader_CFLAGS) $(DEFINES) -D__ASM__ -c -o $@ $<
$(O)/sys/amd64/loader/%.o: sys/amd64/loader/%.c $(HEADERS) config
@printf " CC\t%s\n" $(@:$(O)/%=%)
@$(CC86) $(loader_CFLAGS) -c -o $@ $<
@$(CC86) $(loader_CFLAGS) $(DEFINES) -c -o $@ $<
### Initrd building
amd64_mkstage:
+15
View File
@@ -7,6 +7,12 @@ AMD64_KERNEL_STACK?=65536 # Kernel stack size (when bootstrapping + task kstac
QEMU_MEM?=512
QEMU_SMP?=2
VESA_ENABLE?=0
VESA_MODE?=0
VESA_WIDTH?=1024
VESA_HEIGHT?=768
VESA_DEPTH?=32
### From config
ifdef AMD64_TRACE_IRQ
DEFINES+=-DAMD64_TRACE_IRQ
@@ -31,4 +37,13 @@ ifdef ENABLE_RTL8139
OBJS+=$(O)/sys/amd64/hw/pci/rtl8139.o
endif
ifeq ($(VESA_ENABLE),1)
DEFINES+=-DVESA_MODE=$(VESA_MODE) \
-DVESA_WIDTH=$(VESA_WIDTH) \
-DVESA_HEIGHT=$(VESA_HEIGHT) \
-DVESA_DEPTH=$(VESA_DEPTH) \
-DVESA_ENABLE=1
OBJS+=$(O)/sys/amd64/hw/vesa.o
endif
DEFINES+=-DAMD64_KERNEL_STACK=$(AMD64_KERNEL_STACK)
+1 -2
View File
@@ -52,8 +52,7 @@ OBJS+=$(O)/sys/amd64/hw/rs232.o \
$(O)/sys/amd64/sys/binfmt_elf.o \
$(O)/sys/amd64/hw/rtc.o \
$(O)/sys/amd64/hw/pfault_s.o \
$(O)/sys/amd64/hw/pfault.o \
$(O)/sys/amd64/hw/vesa.o
$(O)/sys/amd64/hw/pfault.o
kernel_LINKER=sys/amd64/link.ld
kernel_LDFLAGS=-nostdlib \
+6 -2
View File
@@ -68,10 +68,14 @@ OBJS+=$(O)/sys/debug.o \
$(O)/sys/net/in.o \
$(O)/sys/net/netdev.o \
$(O)/sys/vfs/devfs.o \
$(O)/sys/vfs/pseudo.o \
$(O)/sys/psf.o \
$(O)/sys/vfs/pseudo.o
ifeq ($(VESA_ENABLE),1)
OBJS+=$(O)/sys/psf.o \
$(O)/sys/font/default8x16.o \
$(O)/sys/font/logo.o
endif
DIRS+=$(O)/sys/vfs/ext2 \
$(O)/sys/net \
$(O)/sys/blk
+17 -4
View File
@@ -1,15 +1,20 @@
#include "sys/amd64/hw/con.h"
#include "sys/amd64/hw/vesa.h"
#include "sys/string.h"
#include "sys/types.h"
#include "sys/debug.h"
#include "sys/heap.h"
#include "sys/font/logo.h"
#include "sys/panic.h"
#include "sys/amd64/hw/io.h"
#include "sys/psf.h"
#include "sys/mm.h"
#if defined(VESA_ENABLE)
#include "sys/font/logo.h"
#include "sys/amd64/hw/vesa.h"
#else
#define vesa_available 0
#endif
#define ESC_ESC 1
#define ESC_CSI 2
@@ -53,6 +58,7 @@ static uint16_t attr = ATTR_DEFAULT;
static void setc(uint16_t row, uint16_t col, uint16_t v);
void con_blink(void) {
#if defined(VESA_ENABLE)
if (vesa_available) {
uint32_t fg = rgb_map[(attr >> 8) & 0xF];
uint32_t bg = rgb_map[(attr >> 12) & 0xF];
@@ -64,6 +70,7 @@ void con_blink(void) {
psf_draw(y, x, ' ', fg, bg);
}
}
#endif
}
static void amd64_con_moveto(uint8_t row, uint8_t col) {
@@ -96,11 +103,13 @@ static void amd64_scroll_down(void) {
static void clear(void) {
memsetw(con_buffer, attr, con_width * con_height);
#if defined(VESA_ENABLE)
if (vesa_available) {
for (size_t i = 0; i < vesa_height; ++i) {
memsetl((uint32_t *) (vesa_addr + vesa_pitch * i), rgb_map[(attr >> 12) & 0xF], vesa_width);
}
}
#endif
}
//static void clear_line(uint16_t row) {
@@ -307,6 +316,7 @@ void amd64_con_putc(int c) {
}
void amd64_con_init(void) {
#if defined(VESA_ENABLE)
if (vesa_available) {
psf_init(vesa_addr, vesa_pitch, &char_width, &char_height);
@@ -314,6 +324,9 @@ void amd64_con_init(void) {
con_height = vesa_height / char_height;
con_buffer = (uint16_t *) kmalloc(con_width * con_height * 2);
} else {
#else
{
#endif
con_buffer = (uint16_t *) MM_VIRTUALIZE(CGA_BUFFER_ADDR);
con_width = 80;
con_height = 25;
@@ -322,6 +335,7 @@ void amd64_con_init(void) {
clear();
#if defined(VESA_ENABLE)
if (vesa_available) {
y = FONT_LOGO_HEIGHT / char_height;
char pixel[4];
@@ -337,6 +351,5 @@ void amd64_con_init(void) {
}
}
}
kinfo("Test\n");
#endif
}
+2
View File
@@ -39,7 +39,9 @@ void kernel_main(struct amd64_loader_data *data) {
amd64_idt_init();
amd64_mm_init(data);
amd64_acpi_init();
#if defined(VESA_ENABLE)
amd64_vesa_init(multiboot_info);
#endif
amd64_con_init();
amd64_apic_init();
+10 -11
View File
@@ -1,17 +1,14 @@
.set ALIGN, 1 << 0
.set MEMINFO, 1 << 1
.set VIDEO, 1 << 2
#if defined(VESA_ENABLE)
.set FLAGS, ALIGN | VIDEO | MEMINFO
#else
.set FLAGS, ALIGN | MEMINFO
#endif
.set MAGIC, 0x1BADB002
.set CHECKSUM, -(MAGIC + FLAGS)
.set VIDEO_LFB, 0
.set VIDEO_EGA, 1
.set VIDEO_MODE, VIDEO_LFB
.set VIDEO_WIDTH, 1920
.set VIDEO_HEIGHT, 1080
.set VIDEO_DEPTH, 32
.section .multiboot
.align 4
.long MAGIC
@@ -22,10 +19,12 @@
.long 0 // load_end_addr
.long 0 // bss_end_addr
.long 0 // entry_addr
.long VIDEO_MODE
.long VIDEO_WIDTH
.long VIDEO_HEIGHT
.long VIDEO_DEPTH
#if defined(VESA_ENABLE)
.long VESA_MODE
.long VESA_WIDTH
.long VESA_HEIGHT
.long VESA_DEPTH
#endif
.section .bss
stack_bottom: