mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
kernel: use mpaland printf
This commit is contained in:
@@ -9,3 +9,5 @@ pkgs
|
|||||||
sources
|
sources
|
||||||
astral.iso
|
astral.iso
|
||||||
kernel-src/include/limine.h
|
kernel-src/include/limine.h
|
||||||
|
kernel-src/include/printf.h
|
||||||
|
kernel-src/io/printf.c
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ kernel:
|
|||||||
./jinx build astral
|
./jinx build astral
|
||||||
|
|
||||||
clean-kernel:
|
clean-kernel:
|
||||||
find kernel-src -name *.o -delete
|
find builds/astral/ -name *.o -delete
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
make clean-kernel
|
make clean-kernel
|
||||||
|
|||||||
+3
-1
@@ -5,7 +5,9 @@ TARGET=x86-64
|
|||||||
INCDIR=$(shell pwd)/include
|
INCDIR=$(shell pwd)/include
|
||||||
ARCHDIR=$(shell pwd)/arch/$(TARGET)/
|
ARCHDIR=$(shell pwd)/arch/$(TARGET)/
|
||||||
LDFLAGS=-ffreestanding -nostdlib -lgcc -Wl,-T,"$(ARCHDIR)/kernel.ld" -debug
|
LDFLAGS=-ffreestanding -nostdlib -lgcc -Wl,-T,"$(ARCHDIR)/kernel.ld" -debug
|
||||||
CFLAGS=-ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -nostdlib -I "${INCDIR}"
|
# required for mpaland printf so it doesn't compile with floating point support, which results in build failures
|
||||||
|
PRINTFOPTS=-DPRINTF_DISABLE_SUPPORT_FLOAT
|
||||||
|
CFLAGS=-ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -nostdlib -Wall -I "${INCDIR}" $(PRINTFOPTS)
|
||||||
ASFLAGS=-felf64
|
ASFLAGS=-felf64
|
||||||
|
|
||||||
astral: $(OBJS)
|
astral: $(OBJS)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
|
|
||||||
// TODO compile time options for disabling output to port e9h
|
// TODO compile time options for disabling output to port e9h
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <arch/e9.h>
|
#include <arch/e9.h>
|
||||||
|
#include <logging.h>
|
||||||
|
|
||||||
void kernel_entry() {
|
void kernel_entry() {
|
||||||
arch_e9_puts("Hello, world!\n");
|
logging_sethook(arch_e9_putc);
|
||||||
asm("cli");
|
__assert(!"kernel entry end");
|
||||||
asm("hlt");
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _LOGGING_H
|
||||||
|
#define _LOGGING_H
|
||||||
|
|
||||||
|
#include <printf.h>
|
||||||
|
|
||||||
|
void _putchar(char c);
|
||||||
|
void logging_sethook(void (*fun)(char));
|
||||||
|
|
||||||
|
// TODO panic
|
||||||
|
|
||||||
|
#define __assert(x) \
|
||||||
|
if (!(x)){ \
|
||||||
|
printf("%s:%s:%d: %s failed\n", __FILE__, __func__, __LINE__, #x); \
|
||||||
|
for(;;); \
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
static void nohook(char c) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void (*hook)(char) = nohook;
|
||||||
|
|
||||||
|
// hook used by mpaland printf
|
||||||
|
void _putchar(char c) {
|
||||||
|
hook(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void logging_sethook(void (*fun)(char)) {
|
||||||
|
hook = fun;
|
||||||
|
}
|
||||||
@@ -2,7 +2,14 @@ name=astral
|
|||||||
version=0
|
version=0
|
||||||
source_dir="kernel-src"
|
source_dir="kernel-src"
|
||||||
allow_network="yes"
|
allow_network="yes"
|
||||||
|
imagedeps="wget"
|
||||||
|
|
||||||
regenerate() {
|
regenerate() {
|
||||||
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h > include/limine.h
|
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h > include/limine.h
|
||||||
|
pushd /tmp/
|
||||||
|
wget https://github.com/mpaland/printf/archive/refs/tags/v4.0.0.tar.gz
|
||||||
|
tar -xf v4.0.0.tar.gz
|
||||||
|
popd
|
||||||
|
cp /tmp/printf-4.0.0/printf.c io/printf.c
|
||||||
|
cp /tmp/printf-4.0.0/printf.h include/printf.h
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user