Kernel is now in C++ :)

This commit is contained in:
Bananymous 2022-11-12 21:30:26 +02:00
parent e6b4866ab0
commit 61609db228
7 changed files with 19 additions and 4 deletions

View File

@ -7,6 +7,7 @@ export HOST=${HOST:-$(./default-host.sh)}
export AR=${HOST}-ar
export AS=${HOST}-as
export CC=${HOST}-gcc
export CXX=${HOST}-g++
export PREFIX=/usr
export EXEC_PREFIX=$PREFIX
@ -20,9 +21,11 @@ export CPPFLAGS=''
# Configure the cross-compiler to use the desired system root.
export SYSROOT="$(pwd)/sysroot"
export CC="$CC --sysroot=$SYSROOT"
export CXX="$CXX --sysroot=$SYSROOT"
# Work around that the -elf gcc targets doesn't have a system include directory
# because it was configured with --without-headers rather than --with-sysroot.
if echo "$HOST" | grep -Eq -- '-elf($|-)'; then
export CC="$CC -isystem=$INCLUDEDIR"
export CXX="$CXX -isystem=$INCLUDEDIR"
fi

View File

@ -62,6 +62,9 @@ $(ARCHDIR)/crtbegin.o $(ARCHDIR)/crtend.o:
.c.o:
$(CC) -MD -c $< -o $@ -std=gnu11 $(CFLAGS) $(CPPFLAGS)
.cpp.o:
$(CXX) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
.S.o:
$(CC) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)

View File

@ -13,4 +13,4 @@ _init:
_fini:
push %ebp
movl %esp, %ebp
/* gcc will nicely put the contents of crtbegin.o's .fini section here. */
/* gcc will nicely put the contents of crtbegin.o's .fini section here. */

View File

@ -7,4 +7,4 @@
.section .fini
/* gcc will nicely put the contents of crtend.o's .fini section here. */
popl %ebp
ret
ret

View File

@ -29,7 +29,7 @@ void terminal_clear(void)
terminal_putentryat(' ', terminal_color, x, y);
}
void terminal_initialize(void)
void terminal_initialize()
{
terminal_row = 0;
terminal_col = 0;

View File

@ -2,7 +2,15 @@
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
void terminal_initialize(void);
void terminal_putchar(char c);
void terminal_write(const char* data, size_t size);
void terminal_writestring(const char* data);
void terminal_writestring(const char* data);
#ifdef __cplusplus
}
#endif

View File

@ -2,6 +2,7 @@
#include <stdio.h>
extern "C"
void kernel_main()
{
terminal_initialize();