From 6c36d3dd404e942938ad61bb746453a780ac0d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Tue, 11 Jan 2022 00:38:43 +0100 Subject: [PATCH] Split framebuffer functions into library --- .gitignore | 3 +- Makefile | 18 +- src/kernel/Makefile | 6 +- src/kernel/boot/TEMP-test_scheduler.c | 9 +- src/kernel/drivers/terminal/fbterm.c | 155 +++--------------- src/kernel/drivers/terminal/terminal.c | 4 +- src/kernel/include/terminal.h | 6 +- src/libmittos/Makefile | 46 ++++++ .../graphics}/framebuffer.c | 42 ++--- src/libmittos/graphics/termfont.inc | 98 +++++++++++ .../include/graphics.h} | 12 +- 11 files changed, 223 insertions(+), 176 deletions(-) create mode 100644 src/libmittos/Makefile rename src/{kernel/drivers => libmittos/graphics}/framebuffer.c (61%) create mode 100644 src/libmittos/graphics/termfont.inc rename src/{kernel/include/framebuffer.h => libmittos/include/graphics.h} (62%) diff --git a/.gitignore b/.gitignore index 7c2848f..544078c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ external/ *.d *.o -src/kernel/kernel \ No newline at end of file +src/kernel/kernel +src/libmittos/libmittos.a \ No newline at end of file diff --git a/Makefile b/Makefile index e50dde4..a3099f3 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,13 @@ endif TARGET := x86_64-elf KERNELMAKE := TARGET=${TARGET} $(MAKE) -C src/kernel +LIBMAKE := TARGET=${TARGET} $(MAKE) -C src/libmittos DIST := $(BUILDROOT)/mittos.iso SYSROOT := $(BUILDROOT)/sysroot -SYS_ITEMS := $(SYSROOT)/kernel $(SYSROOT)/usr/lib/libc.a +SYS_ITEMS := $(SYSROOT)/kernel $(SYSROOT)/usr/lib/libc.a $(SYSROOT)/usr/lib/libmittos.a -all: $(SYSROOT)/kernel +all: $(SYSROOT)/kernel $(SYS_ITEMS) dist: $(DIST) @@ -17,19 +18,28 @@ $(DIST): $(SYS_ITEMS) $(BUILDROOT)/toolchain/setup-grub.sh grub-mkrescue -o $@ $(SYSROOT) -$(SYSROOT)/kernel: $(SYSROOT)/usr/lib/libc.a FORCE -ifeq ($(shell make -sqC src/kernel || echo 1), 1) +kernel: $(SYSROOT)/kernel +$(SYSROOT)/kernel: $(SYSROOT)/usr/lib/libc.a $(SYSROOT)/usr/lib/libmittos.a FORCE +ifeq ($(shell make -sqC src/kernel install || echo 1), 1) $(KERNELMAKE) install endif +musllib: $(SYSROOT)/usr/lib/libc.a $(SYSROOT)/usr/lib/libc.a: toolchain/build-musl.sh +libmittos: $(SYSROOT)/usr/lib/libmittos.a +$(SYSROOT)/usr/lib/libmittos.a: FORCE +ifeq ($(shell make -sqC src/libmittos install || echo 1), 1) + $(LIBMAKE) install +endif + .PHONY: all dist sysroot FORCE clean: rm -rf $(DIST) $(KERNELMAKE) clean + $(LIBMAKE) clean distclean: $(MAKE) clean diff --git a/src/kernel/Makefile b/src/kernel/Makefile index 411da08..cababcc 100644 --- a/src/kernel/Makefile +++ b/src/kernel/Makefile @@ -10,9 +10,9 @@ OBJ := $(patsubst %, %.o, $(basename $(basename $(SRC)))) CFLAGS := -Wall -Wextra -pedantic -ffreestanding -mcmodel=large -std=c2x CFLAGS += -ggdb -O0 ASFLAGS += -ggdb -CPPFLAGS += -I include +CPPFLAGS += -nostdinc -I include -I /opt/sysroot/usr/include LDFLAGS := -n -T Link.ld -LDLIBS := -nostdlib -lgcc -L/opt/sysroot/usr/lib -lc +LDLIBS := -nostdlib -lgcc -L/opt/sysroot/usr/lib -lc -lmittos kernel: $(OBJ) $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@ @@ -29,7 +29,7 @@ $(OBJ): CPPFLAGS += $(DEPFLAGS) DESTDIR ?= $(BUILDROOT)/sysroot $(DESTDIR)$(PREFIX)/kernel: kernel - install -D kernel $(DESTDIR)$(PREFIX)/kernel + install -D $< $@ install: $(DESTDIR)$(PREFIX)/kernel diff --git a/src/kernel/boot/TEMP-test_scheduler.c b/src/kernel/boot/TEMP-test_scheduler.c index 63772c7..3a48d42 100644 --- a/src/kernel/boot/TEMP-test_scheduler.c +++ b/src/kernel/boot/TEMP-test_scheduler.c @@ -1,17 +1,14 @@ -#include #include #include +#include extern gfx_context *term_fb; -void drawCharacter(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr_fg, uint32_t clr_bg, char c); - - void thread1() { int a = 0; while(1) { - drawCharacter(term_fb, 0, 0, RGB(255,0,0), RGB(0,0,0), '0'+(a++%10)); + putCharacter(term_fb, 0, 0, RGB(255,255,0), RGB(0,0,0), '0'+(a++%10)); flip(term_fb); sched_yield(); } @@ -21,7 +18,7 @@ void thread2() { int a = 0; while(1) { - drawCharacter(term_fb, 10, 10, RGB(0,0,255), RGB(0,0,0), 'A'+(a++%10)); + putCharacter(term_fb, 10, 10, RGB(0,255,255), RGB(0,0,0), 'A'+(a++%10)); flip(term_fb); sched_yield(); } diff --git a/src/kernel/drivers/terminal/fbterm.c b/src/kernel/drivers/terminal/fbterm.c index 4e0a578..9743705 100644 --- a/src/kernel/drivers/terminal/fbterm.c +++ b/src/kernel/drivers/terminal/fbterm.c @@ -1,130 +1,12 @@ #include #include -#include +#include #include -// Font from https://github.com/atextor/unifont -char font[95][16] = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00}, - {0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x12, 0x7E, 0x24, 0x24, 0x7E, 0x48, 0x48, 0x48, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x08, 0x3E, 0x49, 0x48, 0x38, 0x0E, 0x09, 0x49, 0x3E, 0x08, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x31, 0x4A, 0x4A, 0x34, 0x08, 0x08, 0x16, 0x29, 0x29, 0x46, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x39, 0x45, 0x42, 0x46, 0x39, 0x00, 0x00}, - {0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x00}, - {0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x49, 0x2A, 0x1C, 0x2A, 0x49, 0x08, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x0C, 0x10, 0x20, 0x40, 0x40, 0x7E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x1C, 0x02, 0x02, 0x42, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x04, 0x0C, 0x14, 0x24, 0x44, 0x44, 0x7E, 0x04, 0x04, 0x04, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x02, 0x02, 0x02, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x40, 0x40, 0x7C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x04, 0x38, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x04, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x4A, 0x56, 0x52, 0x52, 0x52, 0x4E, 0x20, 0x1E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x24, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x42, 0x42, 0x42, 0x42, 0x7C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x40, 0x4E, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x42, 0x44, 0x48, 0x50, 0x60, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x66, 0x66, 0x5A, 0x5A, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x42, 0x62, 0x62, 0x52, 0x52, 0x4A, 0x4A, 0x46, 0x46, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x5A, 0x66, 0x3C, 0x03, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x48, 0x44, 0x44, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x30, 0x0C, 0x02, 0x42, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x41, 0x22, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x5A, 0x5A, 0x66, 0x66, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x7E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0E, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x02, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00}, - {0x00, 0x00, 0x18, 0x24, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00}, - {0x00, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x02, 0x3E, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x7E, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x0C, 0x10, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3A, 0x44, 0x44, 0x44, 0x38, 0x20, 0x3C, 0x42, 0x42, 0x3C}, - {0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x48, 0x30}, - {0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5C, 0x40, 0x40}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x02, 0x02}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x30, 0x0C, 0x02, 0x42, 0x3C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x18, 0x18, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x42, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x26, 0x1A, 0x02, 0x02, 0x3C}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7E, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x0C, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x0C, 0x00}, - {0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, - {0x00, 0x00, 0x00, 0x30, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x30, 0x00}, - {0x00, 0x00, 0x00, 0x31, 0x49, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, -}; - +gfx_context kernel_fb; gfx_context *term_fb; static int setup = 0; -void drawCharacter(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr_fg, uint32_t clr_bg, char c) -{ - - char *chr = c ? font[(int)c-0x20]: font[0]; - if(x >= ctx->width || y >= ctx->height) return; - uint64_t loc = \ - y * ctx->pitch + \ - x * ctx->bpp; - uint32_t *fb = incptr(ctx->buffer, loc); - for(int row = 0; row < 16; row++) - { - for(int col = 0; col < 8; col++) - { - fb[col] = ((chr[row]>>(7-col))&0x1) ? clr_fg : clr_bg; - } - fb = incptr(fb, ctx->pitch); - } - -} - static void draw_border(gfx_context *ctx, uint32_t clr) { for(uint64_t x = 0; x < ctx->width; x++) @@ -139,15 +21,6 @@ static void draw_border(gfx_context *ctx, uint32_t clr) } } -void fbterm_init(gfx_context *ctx) -{ - term_fb = framebuffer_make_subcontext(ctx, 20, 20, 8*VGA_COLS+8, 16*VGA_ROWS+8); - draw_border(term_fb, RGB(255, 0, 0)); - flip(term_fb); - term_fb = framebuffer_make_subcontext(ctx, 24, 24, 8*VGA_COLS, 16*VGA_ROWS); - setup = 1; -} - void fbterm_movecursor(unsigned int cursor) { (void) cursor; @@ -161,8 +34,30 @@ void fbterm_flush(struct vga_cell *buffer) { for(int col=0; col < VGA_COLS; col++) { - drawCharacter(term_fb, col*8, row*16, 0xFFFFFF, 0, (char)buffer[i++].c); + putCharacter(term_fb, col*8, row*16, 0xFFFFFF, 0, (char)buffer[i++].c); } } flip(term_fb); +} + +void fbterm_init(struct fbinfo *fbinfo) +{ + kernel_fb.width = fbinfo->framebuffer_width; + kernel_fb.height = fbinfo->framebuffer_height; + kernel_fb.bpp = fbinfo->framebuffer_bpp/8; + kernel_fb.pitch = fbinfo->framebuffer_pitch; + kernel_fb.addr = P2V(fbinfo->framebuffer_addr); + kernel_fb.size = kernel_fb.pitch * (kernel_fb.height); + kernel_fb.buffer = calloc(1, kernel_fb.size); + + for(uintptr_t p = (uintptr_t)kernel_fb.addr; p < ((uintptr_t)kernel_fb.addr + kernel_fb.size); p += PAGE_SIZE) + { + vmm_set_page(kernel_P4, p, V2P(p), PAGE_WRITE | PAGE_PRESENT); + } + + term_fb = framebuffer_make_subcontext(&kernel_fb, 20, 20, 8*VGA_COLS+8, 16*VGA_ROWS+8); + draw_border(term_fb, RGB(255, 0, 0)); + flip(term_fb); + term_fb = framebuffer_make_subcontext(&kernel_fb, 24, 24, 8*VGA_COLS, 16*VGA_ROWS); + setup = 1; } \ No newline at end of file diff --git a/src/kernel/drivers/terminal/terminal.c b/src/kernel/drivers/terminal/terminal.c index cc3f000..66641ff 100644 --- a/src/kernel/drivers/terminal/terminal.c +++ b/src/kernel/drivers/terminal/terminal.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -105,8 +106,7 @@ void terminal_init(){ switch(terminal_type) { case FRAMEBUFFER: - framebuffer_init(fbinfo); - fbterm_init(&kernel_fb); + fbterm_init(fbinfo); break; case EGA_TEXT: vga_init(fbinfo); diff --git a/src/kernel/include/terminal.h b/src/kernel/include/terminal.h index f6ab817..f3672b3 100644 --- a/src/kernel/include/terminal.h +++ b/src/kernel/include/terminal.h @@ -1,5 +1,6 @@ #pragma once -#include +#include +#include #define VGA_COLS 80 #define VGA_ROWS 24 @@ -21,6 +22,7 @@ void vga_movecursor(unsigned int cursor); void vga_flush(struct vga_cell *buffer); // drivers/terminal/fbterm.c -void fbterm_init(gfx_context *ctx); +extern gfx_context kernel_fb; +void fbterm_init(struct fbinfo *fbinfo); void fbterm_movecursor(unsigned int cursor); void fbterm_flush(struct vga_cell *buffer); \ No newline at end of file diff --git a/src/libmittos/Makefile b/src/libmittos/Makefile new file mode 100644 index 0000000..b004f82 --- /dev/null +++ b/src/libmittos/Makefile @@ -0,0 +1,46 @@ +ifeq ($(BUILDROOT),) +$(error BUILDROOT IS NOT SET!) +endif + +CC := ${TARGET}-gcc + +SRC := $(shell find -type f -name '*.[cS]*') +OBJ := $(patsubst %, %.o, $(basename $(basename $(SRC)))) + +HDR := $(shell find -type f -name '*.h') + +CFLAGS := -Wall -Wextra -pedantic -ffreestanding -mcmodel=large -std=c2x +CFLAGS += -ggdb -O0 +ASFLAGS += -ggdb +CPPFLAGS += -nostdinc -I include -I /opt/sysroot/usr/include +LDFLAGS := -nostdlib -r + +libmittos.a: $(OBJ) + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ + +# Automatic dependency tracking +DEP := $(OBJ:.o=.d) +DEPFLAGS = -MT $@ -MMD -MP -MF $*.d +$(OBJ): CPPFLAGS += $(DEPFLAGS) +%.d: ; + +DESTDIR ?= $(BUILDROOT)/sysroot +LIBDIR := $(DESTDIR)/usr/lib +INCDIR := $(DESTDIR)/usr/include/mittos +$(LIBDIR)/libmittos.a: libmittos.a + install -D $< $@ + +$(INCDIR)/%: include/% + mkdir -p $(INCDIR) + install -D $< $@ + +install: install-headers $(LIBDIR)/libmittos.a + +install-headers: $(HDR:./include/%=$(INCDIR)/%) + +clean: + rm -rf $(OBJ) $(DEP) libmittos.a + +.PHONY: install install-headers +# Include automatic dependency rules +include $(DEP) \ No newline at end of file diff --git a/src/kernel/drivers/framebuffer.c b/src/libmittos/graphics/framebuffer.c similarity index 61% rename from src/kernel/drivers/framebuffer.c rename to src/libmittos/graphics/framebuffer.c index 9a28f07..d501978 100644 --- a/src/kernel/drivers/framebuffer.c +++ b/src/libmittos/graphics/framebuffer.c @@ -1,10 +1,11 @@ #include #include #include -#include -#include +#include -gfx_context kernel_fb; +#define incptr(p, n) ((void *)(((uintptr_t)(p)) + (n))) + +#include "termfont.inc" void putpixel(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr) { @@ -16,6 +17,25 @@ void putpixel(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr) *fb = clr; } +void putCharacter(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr_fg, uint32_t clr_bg, char c) +{ + + char *chr = c ? font[(int)c-0x20]: font[0]; + if(x >= ctx->width || y >= ctx->height) return; + uint64_t loc = \ + y * ctx->pitch + \ + x * ctx->bpp; + uint32_t *fb = incptr(ctx->buffer, loc); + for(int row = 0; row < 16; row++) + { + for(int col = 0; col < 8; col++) + { + fb[col] = ((chr[row]>>(7-col))&0x1) ? clr_fg : clr_bg; + } + fb = incptr(fb, ctx->pitch); + } +} + void flip(gfx_context *ctx) { for(uint64_t y = 0; y < ctx->height; y++) @@ -43,20 +63,4 @@ gfx_context *framebuffer_make_subcontext(gfx_context *ctx, uint64_t x, uint64_t out->buffer = calloc(1, out->size); return out; -} - -void framebuffer_init(struct fbinfo *fbinfo) -{ - kernel_fb.width = fbinfo->framebuffer_width; - kernel_fb.height = fbinfo->framebuffer_height; - kernel_fb.bpp = fbinfo->framebuffer_bpp/8; - kernel_fb.pitch = fbinfo->framebuffer_pitch; - kernel_fb.addr = P2V(fbinfo->framebuffer_addr); - kernel_fb.size = kernel_fb.pitch * (kernel_fb.height); - kernel_fb.buffer = calloc(1, kernel_fb.size); - - for(uintptr_t p = (uintptr_t)kernel_fb.addr; p < ((uintptr_t)kernel_fb.addr + kernel_fb.size); p += PAGE_SIZE) - { - vmm_set_page(kernel_P4, p, V2P(p), PAGE_WRITE | PAGE_PRESENT); - } } \ No newline at end of file diff --git a/src/libmittos/graphics/termfont.inc b/src/libmittos/graphics/termfont.inc new file mode 100644 index 0000000..36b35d8 --- /dev/null +++ b/src/libmittos/graphics/termfont.inc @@ -0,0 +1,98 @@ +// Font from https://github.com/atextor/unifont +char font[95][16] = { + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00}, + {0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x12, 0x7E, 0x24, 0x24, 0x7E, 0x48, 0x48, 0x48, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x08, 0x3E, 0x49, 0x48, 0x38, 0x0E, 0x09, 0x49, 0x3E, 0x08, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x31, 0x4A, 0x4A, 0x34, 0x08, 0x08, 0x16, 0x29, 0x29, 0x46, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x39, 0x45, 0x42, 0x46, 0x39, 0x00, 0x00}, + {0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x00}, + {0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x49, 0x2A, 0x1C, 0x2A, 0x49, 0x08, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x0C, 0x10, 0x20, 0x40, 0x40, 0x7E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x1C, 0x02, 0x02, 0x42, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x04, 0x0C, 0x14, 0x24, 0x44, 0x44, 0x7E, 0x04, 0x04, 0x04, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x02, 0x02, 0x02, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x40, 0x40, 0x7C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x04, 0x38, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x04, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x4A, 0x56, 0x52, 0x52, 0x52, 0x4E, 0x20, 0x1E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x24, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x42, 0x42, 0x42, 0x42, 0x7C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x40, 0x4E, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x42, 0x44, 0x48, 0x50, 0x60, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x66, 0x66, 0x5A, 0x5A, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x42, 0x62, 0x62, 0x52, 0x52, 0x4A, 0x4A, 0x46, 0x46, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x5A, 0x66, 0x3C, 0x03, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x48, 0x44, 0x44, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x30, 0x0C, 0x02, 0x42, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x41, 0x22, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x5A, 0x5A, 0x66, 0x66, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x7E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0E, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x02, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00}, + {0x00, 0x00, 0x18, 0x24, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00}, + {0x00, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x02, 0x3E, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x7E, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x0C, 0x10, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3A, 0x44, 0x44, 0x44, 0x38, 0x20, 0x3C, 0x42, 0x42, 0x3C}, + {0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x48, 0x30}, + {0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5C, 0x40, 0x40}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x02, 0x02}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x30, 0x0C, 0x02, 0x42, 0x3C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x18, 0x18, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x42, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x26, 0x1A, 0x02, 0x02, 0x3C}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7E, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x0C, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x0C, 0x00}, + {0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, + {0x00, 0x00, 0x00, 0x30, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x30, 0x00}, + {0x00, 0x00, 0x00, 0x31, 0x49, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +}; \ No newline at end of file diff --git a/src/kernel/include/framebuffer.h b/src/libmittos/include/graphics.h similarity index 62% rename from src/kernel/include/framebuffer.h rename to src/libmittos/include/graphics.h index a8611ea..c6c2c88 100644 --- a/src/kernel/include/framebuffer.h +++ b/src/libmittos/include/graphics.h @@ -1,7 +1,5 @@ #pragma once -#include -#include -#include +#include typedef struct { uint32_t width; @@ -13,13 +11,9 @@ typedef struct { size_t size; } gfx_context; -// drivers/framebuffer.c -extern gfx_context kernel_fb; - #define RGB(r, g, b) (((uint32_t) (r<<16) + (g<<8) + (b))) -// drivers/framebuffer.c void putpixel(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr); +void putCharacter(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr_fg, uint32_t clr_bg, char c); void flip(gfx_context *ctx); -gfx_context *framebuffer_make_subcontext(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_t height); -void framebuffer_init(struct fbinfo *fbinfo); \ No newline at end of file +gfx_context *framebuffer_make_subcontext(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_t height); \ No newline at end of file