test: Use Flanterm

This commit is contained in:
mintsuki 2023-08-04 07:56:07 -05:00
parent 820d4751d3
commit b8fff872de
4 changed files with 33 additions and 3 deletions

1
test/.gitignore vendored
View File

@ -1,2 +1,3 @@
test.o test.o
test.elf test.elf
flanterm

View File

@ -45,7 +45,8 @@ override INTERNALCFLAGS := \
-mgeneral-regs-only \ -mgeneral-regs-only \
-mno-red-zone \ -mno-red-zone \
-I. \ -I. \
-I.. -I.. \
-D_LIMINE_PROTO
ifneq ($(findstring riscv,$(CC_FOR_TARGET)),) ifneq ($(findstring riscv,$(CC_FOR_TARGET)),)
override INTERNALCFLAGS += -march=rv64imac -mabi=lp64 -mno-relax override INTERNALCFLAGS += -march=rv64imac -mabi=lp64 -mno-relax
@ -74,7 +75,11 @@ else
all: test.elf all: test.elf
endif endif
test.elf: limine.o e9print.o memory.o flanterm:
mkdir -p flanterm
cp -rv ../common/flanterm/* ./flanterm/
test.elf: limine.o e9print.o memory.o flanterm/flanterm.o flanterm/backends/fb.o
$(LD) $^ $(LDFLAGS) $(INTERNALLDFLAGS) -o $@ $(LD) $^ $(LDFLAGS) $(INTERNALLDFLAGS) -o $@
multiboot2.elf: multiboot2_trampoline.o multiboot2.elf: multiboot2_trampoline.o
@ -87,7 +92,7 @@ multiboot.elf: multiboot_trampoline.o
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c e9print.c -o e9print.o $(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c e9print.c -o e9print.o
$(LD) $^ multiboot.o e9print.o $(LDFLAGS) $(INTERNAL_LD_FLAGS_MULTIBOOT1) -m elf_i386 -o $@ $(LD) $^ multiboot.o e9print.o $(LDFLAGS) $(INTERNAL_LD_FLAGS_MULTIBOOT1) -m elf_i386 -o $@
%.o: %.c %.o: %.c flanterm
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(INTERNALCFLAGS) -c $< -o $@
%.o: %.asm %.o: %.asm
@ -97,3 +102,4 @@ clean:
rm -rf test.elf limine.o e9print.o memory.o rm -rf test.elf limine.o e9print.o memory.o
rm -rf multiboot2.o multiboot2.elf multiboot2_trampoline.o rm -rf multiboot2.o multiboot2.elf multiboot2_trampoline.o
rm -rf multiboot.o multiboot_trampoline.o multiboot.elf rm -rf multiboot.o multiboot_trampoline.o multiboot.elf
rm -rf flanterm

View File

@ -2,12 +2,22 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#if defined (_LIMINE_PROTO)
#include <flanterm/flanterm.h>
extern struct flanterm_context *ft_ctx;
#endif
static const char CONVERSION_TABLE[] = "0123456789abcdef"; static const char CONVERSION_TABLE[] = "0123456789abcdef";
void e9_putc(char c) { void e9_putc(char c) {
#if defined (__x86_64__) || defined (__i386__) #if defined (__x86_64__) || defined (__i386__)
__asm__ __volatile__ ("outb %0, %1" :: "a" (c), "Nd" (0xe9) : "memory"); __asm__ __volatile__ ("outb %0, %1" :: "a" (c), "Nd" (0xe9) : "memory");
#endif #endif
#if defined (_LIMINE_PROTO)
if (ft_ctx != NULL) {
flanterm_write(ft_ctx, &c, 1);
}
#endif
} }
void e9_print(const char *msg) { void e9_print(const char *msg) {

View File

@ -2,6 +2,8 @@
#include <stddef.h> #include <stddef.h>
#include <limine.h> #include <limine.h>
#include <e9print.h> #include <e9print.h>
#include <flanterm/flanterm.h>
#include <flanterm/backends/fb.h>
static void limine_main(void); static void limine_main(void);
@ -232,9 +234,20 @@ void ap_entry(struct limine_smp_info *info) {
extern char kernel_start[]; extern char kernel_start[];
struct flanterm_context *ft_ctx = NULL;
void limine_main(void) { void limine_main(void) {
e9_printf("\nWe're alive"); e9_printf("\nWe're alive");
struct limine_framebuffer *fb = framebuffer_request.response->framebuffers[0];
ft_ctx = flanterm_fb_simple_init(
fb->address,
fb->width,
fb->height,
fb->pitch
);
uint64_t kernel_slide = (uint64_t)kernel_start - 0xffffffff80000000; uint64_t kernel_slide = (uint64_t)kernel_start - 0xffffffff80000000;
e9_printf("Kernel slide: %x", kernel_slide); e9_printf("Kernel slide: %x", kernel_slide);