Libc is now written in C++
This commit is contained in:
@@ -49,25 +49,22 @@ $(ARCHDIR)/crtend.o \
|
||||
$(ARCHDIR)/crtn.o \
|
||||
|
||||
.PHONY: all clean install install-headers install-kernel
|
||||
.SUFFIXES: .o .c .cpp .S
|
||||
.SUFFIXES: .o .cpp .S
|
||||
|
||||
all: banan-os.kernel
|
||||
|
||||
banan-os.kernel: $(OBJS) $(ARCHDIR)/linker.ld
|
||||
$(CC) -T $(ARCHDIR)/linker.ld -o $@ $(CFLAGS) $(LINK_LIST)
|
||||
$(CXX) -T $(ARCHDIR)/linker.ld -o $@ $(CFLAGS) $(CPPFLAGS) $(LINK_LIST)
|
||||
grub-file --is-x86-multiboot banan-os.kernel
|
||||
|
||||
$(ARCHDIR)/crtbegin.o $(ARCHDIR)/crtend.o:
|
||||
OBJ=`$(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=$(@F)` && cp "$$OBJ" $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -MD -c $< -o $@ -std=gnu11 $(CFLAGS) $(CPPFLAGS)
|
||||
OBJ=`$(CXX) $(CFLAGS) $(LDFLAGS) -print-file-name=$(@F)` && cp "$$OBJ" $@
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
|
||||
|
||||
.S.o:
|
||||
$(CC) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
|
||||
$(CXX) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f banan-os.kernel
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
#include "vga.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static const size_t VGA_WIDTH = 80;
|
||||
static const size_t VGA_HEIGHT = 25;
|
||||
static constexpr size_t VGA_WIDTH = 80;
|
||||
static constexpr size_t VGA_HEIGHT = 25;
|
||||
static uint16_t* const VGA_MEMORY = (uint16_t*)0xC03FF000;
|
||||
|
||||
static size_t terminal_row;
|
||||
@@ -21,7 +20,7 @@ void terminal_putentryat(unsigned char c, uint8_t color, size_t x, size_t y)
|
||||
terminal_buffer[index] = vga_entry(c, color);
|
||||
}
|
||||
|
||||
void terminal_clear(void)
|
||||
void terminal_clear()
|
||||
{
|
||||
for (size_t y = 0; y < VGA_HEIGHT; y++)
|
||||
for (size_t x = 0; x < VGA_WIDTH; x++)
|
||||
@@ -1,16 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
__BEGIN_DECLS
|
||||
|
||||
void terminal_initialize(void);
|
||||
void terminal_initialize();
|
||||
void terminal_putchar(char c);
|
||||
void terminal_write(const char* data, size_t size);
|
||||
void terminal_writestring(const char* data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
__END_DECLS
|
||||
@@ -7,6 +7,9 @@
|
||||
extern "C"
|
||||
void kernel_main()
|
||||
{
|
||||
asm volatile("cli");
|
||||
|
||||
|
||||
terminal_initialize();
|
||||
|
||||
printf("Hello from the kernel!\n");
|
||||
|
||||
Reference in New Issue
Block a user