Przeglądaj źródła

adapt more parts to cpp

greatbridf 2 lat temu
rodzic
commit
8326c982e1

+ 7 - 7
CMakeLists.txt

@@ -49,16 +49,16 @@ if (NOT DEFINED FDISK_BIN)
 endif()
 endif()
 
 
 set(KERNEL_MAIN_SOURCES src/fs/fat.cpp
 set(KERNEL_MAIN_SOURCES src/fs/fat.cpp
-                        src/kernel_main.c
+                        src/kernel_main.cpp
                         src/kernel/errno.c
                         src/kernel/errno.c
                         src/kernel/interrupt.cpp
                         src/kernel/interrupt.cpp
                         src/kernel/process.cpp
                         src/kernel/process.cpp
                         src/kernel/tty.cpp
                         src/kernel/tty.cpp
-                        src/kernel/stdio.c
+                        src/kernel/stdio.cpp
                         src/kernel/syscall.cpp
                         src/kernel/syscall.cpp
                         src/kernel/mem.cpp
                         src/kernel/mem.cpp
                         src/kernel/vfs.cpp
                         src/kernel/vfs.cpp
-                        src/kernel/vga.c
+                        src/kernel/vga.cpp
                         src/kernel/hw/ata.cpp
                         src/kernel/hw/ata.cpp
                         src/kernel/hw/keyboard.cpp
                         src/kernel/hw/keyboard.cpp
                         src/kernel/hw/serial.cpp
                         src/kernel/hw/serial.cpp
@@ -73,15 +73,15 @@ set(KERNEL_MAIN_SOURCES src/fs/fat.cpp
                         include/kernel/event/event.h
                         include/kernel/event/event.h
                         include/kernel/event/evtqueue.hpp
                         include/kernel/event/evtqueue.hpp
                         include/kernel/errno.h
                         include/kernel/errno.h
-                        include/kernel/tty.h
+                        include/kernel/tty.hpp
                         include/kernel/interrupt.h
                         include/kernel/interrupt.h
                         include/kernel/process.hpp
                         include/kernel/process.hpp
-                        include/kernel/stdio.h
+                        include/kernel/stdio.hpp
                         include/kernel/syscall.hpp
                         include/kernel/syscall.hpp
                         include/kernel/mem.h
                         include/kernel/mem.h
                         include/kernel/mm.hpp
                         include/kernel/mm.hpp
                         include/kernel/vfs.hpp
                         include/kernel/vfs.hpp
-                        include/kernel/vga.h
+                        include/kernel/vga.hpp
                         include/kernel/hw/ata.hpp
                         include/kernel/hw/ata.hpp
                         include/kernel/hw/keyboard.h
                         include/kernel/hw/keyboard.h
                         include/kernel/hw/port.hpp
                         include/kernel/hw/port.hpp
@@ -106,7 +106,7 @@ set(KERNEL_MAIN_SOURCES src/fs/fat.cpp
                         include/types/lock.hpp
                         include/types/lock.hpp
                         include/types/string.hpp
                         include/types/string.hpp
                         include/types/vector.hpp
                         include/types/vector.hpp
-                        include/kernel_main.h
+                        include/kernel_main.hpp
                         )
                         )
 add_library(kernel_main STATIC ${KERNEL_MAIN_SOURCES})
 add_library(kernel_main STATIC ${KERNEL_MAIN_SOURCES})
 
 

+ 0 - 2
include/asm/boot.h

@@ -12,8 +12,6 @@ struct __attribute__((__packed__)) gdt_descriptor {
 
 
 extern struct gdt_descriptor asm_gdt_descriptor;
 extern struct gdt_descriptor asm_gdt_descriptor;
 
 
-extern uint32_t check_a20_on(void);
-
 extern struct mem_size_info asm_mem_size_info;
 extern struct mem_size_info asm_mem_size_info;
 
 
 extern uint8_t asm_e820_mem_map[1024];
 extern uint8_t asm_e820_mem_map[1024];

+ 1 - 1
include/kernel/process.hpp

@@ -405,7 +405,7 @@ public:
     }
     }
 };
 };
 
 
-extern "C" void NORETURN init_scheduler();
+void NORETURN init_scheduler(void);
 void schedule(void);
 void schedule(void);
 
 
 constexpr uint32_t push_stack(uint32_t** stack, uint32_t val)
 constexpr uint32_t push_stack(uint32_t** stack, uint32_t val)

+ 2 - 0
include/kernel/stdio.h → include/kernel/stdio.hpp

@@ -33,6 +33,8 @@ snprintf(
     const char* fmt,
     const char* fmt,
     ...);
     ...);
 
 
+void kmsg(const char* msg);
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }
 #endif
 #endif

+ 0 - 8
include/kernel/tty.h → include/kernel/tty.hpp

@@ -6,10 +6,6 @@
 
 
 #define SERIAL_TTY_BUFFER_SIZE (4096)
 #define SERIAL_TTY_BUFFER_SIZE (4096)
 
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 struct tty;
 struct tty;
 
 
 struct tty_operations {
 struct tty_operations {
@@ -34,7 +30,3 @@ void tty_print(struct tty* p_tty, const char* str);
 
 
 int make_serial_tty(struct tty* p_tty, int id, int buffered);
 int make_serial_tty(struct tty* p_tty, int id, int buffered);
 int make_vga_tty(struct tty* p_tty);
 int make_vga_tty(struct tty* p_tty);
-
-#ifdef __cplusplus
-}
-#endif

+ 0 - 8
include/kernel/vga.h → include/kernel/vga.hpp

@@ -4,10 +4,6 @@
 
 
 #include <types/stdint.h>
 #include <types/stdint.h>
 
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #define VGA_CHAR_COLOR_WHITE (0x0fU)
 #define VGA_CHAR_COLOR_WHITE (0x0fU)
 
 
 struct vga_char {
 struct vga_char {
@@ -22,8 +18,4 @@ struct vga_char {
 void vga_put_char(struct vga_char* c);
 void vga_put_char(struct vga_char* c);
 void vga_print(const char* str, uint8_t color);
 void vga_print(const char* str, uint8_t color);
 
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif // _KERNEL_VGA_H_
 #endif // _KERNEL_VGA_H_

+ 1 - 8
include/kernel_main.h → include/kernel_main.hpp

@@ -6,12 +6,5 @@
 
 
 #define KERNEL_START_ADDR (0x00100000)
 #define KERNEL_START_ADDR (0x00100000)
 
 
-void NORETURN kernel_main(void);
-
-#ifdef __cplusplus
-// in kernel_main.c
-extern "C" struct tss32_t tss;
-#else
-// in kernel_main.c
+// in kernel_main.cpp
 extern struct tss32_t tss;
 extern struct tss32_t tss;
-#endif

+ 1 - 5
include/types/string.hpp

@@ -1,12 +1,10 @@
 #pragma once
 #pragma once
 
 
-#include <kernel/stdio.h>
+#include <kernel/stdio.hpp>
 #include <types/allocator.hpp>
 #include <types/allocator.hpp>
 #include <types/types.h>
 #include <types/types.h>
 #include <types/vector.hpp>
 #include <types/vector.hpp>
 
 
-#ifdef __cplusplus
-
 namespace types {
 namespace types {
 template <template <typename _value_type> class Allocator = kernel_allocator>
 template <template <typename _value_type> class Allocator = kernel_allocator>
 class string : public types::vector<char, Allocator> {
 class string : public types::vector<char, Allocator> {
@@ -114,5 +112,3 @@ public:
     }
     }
 };
 };
 } // namespace types
 } // namespace types
-
-#endif

+ 2 - 3
src/kernel/event/event.cpp

@@ -3,8 +3,7 @@
 #include <kernel/event/evtqueue.hpp>
 #include <kernel/event/evtqueue.hpp>
 #include <kernel/input/input_event.h>
 #include <kernel/input/input_event.h>
 #include <kernel/process.hpp>
 #include <kernel/process.hpp>
-#include <kernel/stdio.h>
-#include <kernel/tty.h>
+#include <kernel/stdio.hpp>
 #include <types/allocator.hpp>
 #include <types/allocator.hpp>
 #include <types/assert.h>
 #include <types/assert.h>
 #include <types/cplusplus.hpp>
 #include <types/cplusplus.hpp>
@@ -40,7 +39,7 @@ void dispatch_event(void)
         for (auto iter = input_event_queue.begin(); iter != input_event_queue.end(); ++iter) {
         for (auto iter = input_event_queue.begin(); iter != input_event_queue.end(); ++iter) {
             const auto& item = *iter;
             const auto& item = *iter;
             snprintf(buf, 1024, "\rinput event: type%x, data%x, code%x\r", item.type, item.data, item.code);
             snprintf(buf, 1024, "\rinput event: type%x, data%x, code%x\r", item.type, item.data, item.code);
-            tty_print(console, buf);
+            kmsg(buf);
             input_event_queue.erase(iter);
             input_event_queue.erase(iter);
         }
         }
     }
     }

+ 3 - 3
src/kernel/hw/ata.cpp

@@ -1,9 +1,8 @@
 #include <asm/port_io.h>
 #include <asm/port_io.h>
 #include <fs/fat.hpp>
 #include <fs/fat.hpp>
 #include <kernel/hw/ata.hpp>
 #include <kernel/hw/ata.hpp>
-#include <kernel/stdio.h>
+#include <kernel/stdio.hpp>
 #include <kernel/syscall.hpp>
 #include <kernel/syscall.hpp>
-#include <kernel/tty.h>
 #include <kernel/vfs.hpp>
 #include <kernel/vfs.hpp>
 #include <types/allocator.hpp>
 #include <types/allocator.hpp>
 #include <types/assert.h>
 #include <types/assert.h>
@@ -180,7 +179,8 @@ struct PACKED mbr {
 
 
 static inline void mbr_part_probe(fs::inode* drive, uint16_t major, uint16_t minor)
 static inline void mbr_part_probe(fs::inode* drive, uint16_t major, uint16_t minor)
 {
 {
-    struct mbr hda_mbr { };
+    struct mbr hda_mbr {
+    };
     auto* dev = fs::vfs_open("/dev");
     auto* dev = fs::vfs_open("/dev");
 
 
     fs::vfs_read(drive, (char*)&hda_mbr, 512, 0, 512);
     fs::vfs_read(drive, (char*)&hda_mbr, 512, 0, 512);

+ 3 - 3
src/kernel/hw/serial.cpp

@@ -1,8 +1,8 @@
-#include <types/status.h>
 #include <asm/port_io.h>
 #include <asm/port_io.h>
 #include <kernel/hw/serial.h>
 #include <kernel/hw/serial.h>
-#include <kernel/stdio.h>
-#include <kernel/tty.h>
+#include <kernel/stdio.hpp>
+#include <kernel/tty.hpp>
+#include <types/status.h>
 
 
 int32_t init_serial_port(port_id_t port)
 int32_t init_serial_port(port_id_t port)
 {
 {

+ 0 - 1
src/kernel/hw/timer.c

@@ -1,5 +1,4 @@
 #include <asm/port_io.h>
 #include <asm/port_io.h>
-#include <kernel/tty.h>
 #include <kernel/hw/timer.h>
 #include <kernel/hw/timer.h>
 
 
 static time_t _current_ticks = 0;
 static time_t _current_ticks = 0;

+ 10 - 11
src/kernel/interrupt.cpp

@@ -8,12 +8,11 @@
 #include <kernel/mem.h>
 #include <kernel/mem.h>
 #include <kernel/mm.hpp>
 #include <kernel/mm.hpp>
 #include <kernel/process.hpp>
 #include <kernel/process.hpp>
-#include <kernel/stdio.h>
+#include <kernel/stdio.hpp>
 #include <kernel/syscall.hpp>
 #include <kernel/syscall.hpp>
-#include <kernel/tty.h>
 #include <kernel/vfs.hpp>
 #include <kernel/vfs.hpp>
-#include <kernel/vga.h>
-#include <kernel_main.h>
+#include <kernel/vga.hpp>
+#include <kernel_main.hpp>
 #include <types/assert.h>
 #include <types/assert.h>
 #include <types/size.h>
 #include <types/size.h>
 #include <types/stdint.h>
 #include <types/stdint.h>
@@ -91,7 +90,7 @@ extern "C" void int6_handler(
 {
 {
     char buf[512];
     char buf[512];
 
 
-    tty_print(console, "\n---- INVALID OPCODE ----\n");
+    kmsg("\n---- INVALID OPCODE ----\n");
 
 
     snprintf(
     snprintf(
         buf, 512,
         buf, 512,
@@ -102,9 +101,9 @@ extern "C" void int6_handler(
         s_regs.edx, s_regs.esp, s_regs.ebp,
         s_regs.edx, s_regs.esp, s_regs.ebp,
         s_regs.esi, s_regs.edi, eip,
         s_regs.esi, s_regs.edi, eip,
         cs, eflags);
         cs, eflags);
-    tty_print(console, buf);
+    kmsg(buf);
 
 
-    tty_print(console, "----   HALTING SYSTEM   ----\n");
+    kmsg("----   HALTING SYSTEM   ----\n");
 
 
     asm_cli();
     asm_cli();
     asm_hlt();
     asm_hlt();
@@ -120,7 +119,7 @@ extern "C" void int13_handler(
 {
 {
     char buf[512];
     char buf[512];
 
 
-    tty_print(console, "\n---- SEGMENTATION FAULT ----\n");
+    kmsg("\n---- SEGMENTATION FAULT ----\n");
 
 
     snprintf(
     snprintf(
         buf, 512,
         buf, 512,
@@ -132,9 +131,9 @@ extern "C" void int13_handler(
         s_regs.edx, s_regs.esp, s_regs.ebp,
         s_regs.edx, s_regs.esp, s_regs.ebp,
         s_regs.esi, s_regs.edi, eip,
         s_regs.esi, s_regs.edi, eip,
         cs, error_code, eflags);
         cs, error_code, eflags);
-    tty_print(console, buf);
+    kmsg(buf);
 
 
-    tty_print(console, "----   HALTING SYSTEM   ----\n");
+    kmsg("----   HALTING SYSTEM   ----\n");
 
 
     asm_cli();
     asm_cli();
     asm_hlt();
     asm_hlt();
@@ -155,7 +154,7 @@ static inline void _int14_panic(void* eip, void* cr2, struct page_fault_error_co
     snprintf(
     snprintf(
         buf, 256,
         buf, 256,
         "\nkilled: segmentation fault (eip: %x, cr2: %x, error_code: %x)\n", eip, cr2, error_code);
         "\nkilled: segmentation fault (eip: %x, cr2: %x, error_code: %x)\n", eip, cr2, error_code);
-    tty_print(console, buf);
+    kmsg(buf);
     assert(false);
     assert(false);
 }
 }
 
 

+ 3 - 3
src/kernel/mem.cpp

@@ -5,10 +5,10 @@
 #include <kernel/mem.h>
 #include <kernel/mem.h>
 #include <kernel/mm.hpp>
 #include <kernel/mm.hpp>
 #include <kernel/process.hpp>
 #include <kernel/process.hpp>
-#include <kernel/stdio.h>
+#include <kernel/stdio.hpp>
 #include <kernel/task.h>
 #include <kernel/task.h>
-#include <kernel/vga.h>
-#include <kernel_main.h>
+#include <kernel/vga.hpp>
+#include <kernel_main.hpp>
 #include <types/allocator.hpp>
 #include <types/allocator.hpp>
 #include <types/assert.h>
 #include <types/assert.h>
 #include <types/bitmap.h>
 #include <types/bitmap.h>

+ 4 - 5
src/kernel/process.cpp

@@ -6,10 +6,9 @@
 #include <kernel/mem.h>
 #include <kernel/mem.h>
 #include <kernel/mm.hpp>
 #include <kernel/mm.hpp>
 #include <kernel/process.hpp>
 #include <kernel/process.hpp>
-#include <kernel/stdio.h>
-#include <kernel/tty.h>
+#include <kernel/stdio.hpp>
 #include <kernel/vfs.hpp>
 #include <kernel/vfs.hpp>
-#include <kernel_main.h>
+#include <kernel_main.hpp>
 #include <types/allocator.hpp>
 #include <types/allocator.hpp>
 #include <types/assert.h>
 #include <types/assert.h>
 #include <types/cplusplus.hpp>
 #include <types/cplusplus.hpp>
@@ -92,7 +91,7 @@ inline void NORETURN _noreturn_crash(void)
 
 
 void kernel_threadd_main(void)
 void kernel_threadd_main(void)
 {
 {
-    tty_print(console, "kernel thread daemon started\n");
+    kmsg("kernel thread daemon started\n");
 
 
     for (;;) {
     for (;;) {
         if (kthreadd_new_thd_func) {
         if (kthreadd_new_thd_func) {
@@ -203,7 +202,7 @@ void k_new_thread(void (*func)(void*), void* data)
     kthreadd_new_thd_data = data;
     kthreadd_new_thd_data = data;
 }
 }
 
 
-void NORETURN init_scheduler()
+void NORETURN init_scheduler(void)
 {
 {
     procs = types::pnew<types::kernel_allocator>(procs);
     procs = types::pnew<types::kernel_allocator>(procs);
     readythds = types::pnew<types::kernel_allocator>(readythds);
     readythds = types::pnew<types::kernel_allocator>(readythds);

+ 16 - 7
src/kernel/stdio.c → src/kernel/stdio.cpp

@@ -1,4 +1,5 @@
-#include <kernel/stdio.h>
+#include <kernel/stdio.hpp>
+#include <kernel/tty.hpp>
 
 
 #include <types/size.h>
 #include <types/size.h>
 #include <types/stdint.h>
 #include <types/stdint.h>
@@ -46,12 +47,12 @@ int64_t do_div_s(int64_t a, int64_t b, uint64_t* remainder)
     return quotient;
     return quotient;
 }
 }
 
 
-int64_t __divdi3(int64_t a, int64_t b)
+extern "C" int64_t __divdi3(int64_t a, int64_t b)
 {
 {
     return do_div_s(a, b, (uint64_t*)0);
     return do_div_s(a, b, (uint64_t*)0);
 }
 }
 
 
-int64_t __moddi3(int64_t a, int64_t b)
+extern "C" int64_t __moddi3(int64_t a, int64_t b)
 {
 {
     uint64_t remainder = 0;
     uint64_t remainder = 0;
     do_div_s(a, b, &remainder);
     do_div_s(a, b, &remainder);
@@ -301,7 +302,7 @@ snprintf(
     ...)
     ...)
 {
 {
     ssize_t n_write = 0;
     ssize_t n_write = 0;
-    void* arg_ptr = ((void*)&buf) + sizeof(char*) + sizeof(size_t) + sizeof(const char*);
+    uint8_t* arg_ptr = ((uint8_t*)&buf) + sizeof(char*) + sizeof(size_t) + sizeof(const char*);
 
 
     for (char c; (c = *fmt) != 0x00; ++fmt) {
     for (char c; (c = *fmt) != 0x00; ++fmt) {
         if (c == '%') {
         if (c == '%') {
@@ -413,9 +414,11 @@ snprintf(
 }
 }
 
 
 #define BYTES_PER_MAX_COPY_UNIT (sizeof(uint32_t) / sizeof(uint8_t))
 #define BYTES_PER_MAX_COPY_UNIT (sizeof(uint32_t) / sizeof(uint8_t))
-void* memcpy(void* dst, const void* src, size_t n)
+void* memcpy(void* _dst, const void* _src, size_t n)
 {
 {
-    void* orig_dst = dst;
+    void* orig_dst = _dst;
+    uint8_t* dst = (uint8_t*)_dst;
+    const uint8_t* src = (const uint8_t*)_src;
     for (size_t i = 0; i < n / BYTES_PER_MAX_COPY_UNIT; ++i) {
     for (size_t i = 0; i < n / BYTES_PER_MAX_COPY_UNIT; ++i) {
         *(uint32_t*)dst = *(uint32_t*)src;
         *(uint32_t*)dst = *(uint32_t*)src;
         dst += BYTES_PER_MAX_COPY_UNIT;
         dst += BYTES_PER_MAX_COPY_UNIT;
@@ -427,8 +430,9 @@ void* memcpy(void* dst, const void* src, size_t n)
     return orig_dst;
     return orig_dst;
 }
 }
 
 
-void* memset(void* dst, int c, size_t n)
+void* memset(void* _dst, int c, size_t n)
 {
 {
+    uint8_t* dst = (uint8_t*)_dst;
     c &= 0xff;
     c &= 0xff;
     int cc = (c + (c << 8) + (c << 16) + (c << 24));
     int cc = (c + (c << 8) + (c << 16) + (c << 24));
     for (size_t i = 0; i < n / BYTES_PER_MAX_COPY_UNIT; ++i) {
     for (size_t i = 0; i < n / BYTES_PER_MAX_COPY_UNIT; ++i) {
@@ -472,3 +476,8 @@ int strcmp(const char* s1, const char* s2)
     }
     }
     return c;
     return c;
 }
 }
+
+void kmsg(const char* msg)
+{
+    tty_print(console, msg);
+}

+ 3 - 3
src/kernel/syscall.cpp

@@ -5,10 +5,10 @@
 #include <kernel/mem.h>
 #include <kernel/mem.h>
 #include <kernel/mm.hpp>
 #include <kernel/mm.hpp>
 #include <kernel/process.hpp>
 #include <kernel/process.hpp>
+#include <kernel/stdio.hpp>
 #include <kernel/syscall.hpp>
 #include <kernel/syscall.hpp>
-#include <kernel/tty.h>
 #include <kernel/vfs.hpp>
 #include <kernel/vfs.hpp>
-#include <kernel_main.h>
+#include <kernel_main.hpp>
 #include <types/allocator.hpp>
 #include <types/allocator.hpp>
 #include <types/assert.h>
 #include <types/assert.h>
 #include <types/elf.hpp>
 #include <types/elf.hpp>
@@ -121,7 +121,7 @@ void _syscall_sleep(interrupt_stack* data)
 
 
 void _syscall_crash(interrupt_stack*)
 void _syscall_crash(interrupt_stack*)
 {
 {
-    tty_print(console, "\nan error occurred while executing command\n");
+    kmsg("\nan error occurred while executing command\n");
     asm_cli();
     asm_cli();
     asm_hlt();
     asm_hlt();
 }
 }

+ 3 - 5
src/kernel/tty.cpp

@@ -1,9 +1,7 @@
-#include <asm/port_io.h>
 #include <kernel/hw/serial.h>
 #include <kernel/hw/serial.h>
-#include <kernel/mem.h>
-#include <kernel/stdio.h>
-#include <kernel/tty.h>
-#include <kernel/vga.h>
+#include <kernel/stdio.hpp>
+#include <kernel/tty.hpp>
+#include <kernel/vga.hpp>
 
 
 static void serial_tty_put_char(struct tty* p_tty, char c)
 static void serial_tty_put_char(struct tty* p_tty, char c)
 {
 {

+ 2 - 2
src/kernel/vfs.cpp

@@ -1,7 +1,7 @@
 #include <kernel/errno.h>
 #include <kernel/errno.h>
 #include <kernel/mem.h>
 #include <kernel/mem.h>
-#include <kernel/stdio.h>
-#include <kernel/tty.h>
+#include <kernel/stdio.hpp>
+#include <kernel/tty.hpp>
 #include <kernel/vfs.hpp>
 #include <kernel/vfs.hpp>
 #include <types/allocator.hpp>
 #include <types/allocator.hpp>
 #include <types/assert.h>
 #include <types/assert.h>

+ 2 - 2
src/kernel/vga.c → src/kernel/vga.cpp

@@ -1,8 +1,8 @@
 #define _KERNEL_VGA_C_
 #define _KERNEL_VGA_C_
 #include <types/stdint.h>
 #include <types/stdint.h>
 
 
-#include <kernel/stdio.h>
-#include <kernel/vga.h>
+#include <kernel/stdio.hpp>
+#include <kernel/vga.hpp>
 
 
 static struct vga_char* p_vga_head = VGA_MEM;
 static struct vga_char* p_vga_head = VGA_MEM;
 
 

+ 10 - 8
src/kernel_main.c → src/kernel_main.cpp

@@ -1,4 +1,4 @@
-#include "kernel_main.h"
+#include "kernel_main.hpp"
 
 
 #include <asm/boot.h>
 #include <asm/boot.h>
 #include <asm/port_io.h>
 #include <asm/port_io.h>
@@ -9,13 +9,15 @@
 #include <kernel/hw/timer.h>
 #include <kernel/hw/timer.h>
 #include <kernel/interrupt.h>
 #include <kernel/interrupt.h>
 #include <kernel/mem.h>
 #include <kernel/mem.h>
-#include <kernel/stdio.h>
+#include <kernel/process.hpp>
+#include <kernel/stdio.hpp>
 #include <kernel/task.h>
 #include <kernel/task.h>
-#include <kernel/tty.h>
-#include <kernel/vga.h>
+#include <kernel/tty.hpp>
+#include <kernel/vga.hpp>
 #include <types/assert.h>
 #include <types/assert.h>
 #include <types/bitmap.h>
 #include <types/bitmap.h>
 #include <types/status.h>
 #include <types/status.h>
+#include <types/stdint.h>
 #include <types/types.h>
 #include <types/types.h>
 
 
 #define KERNEL_MAIN_BUF_SIZE (128)
 #define KERNEL_MAIN_BUF_SIZE (128)
@@ -125,7 +127,7 @@ void init_bss_section(void)
 
 
 int init_console(const char* name)
 int init_console(const char* name)
 {
 {
-    console = ki_malloc(sizeof(struct tty));
+    console = types::_new<types::kernel_ident_allocator, struct tty>();
     if (name[0] == 't' && name[1] == 't' && name[2] == 'y') {
     if (name[0] == 't' && name[1] == 't' && name[2] == 'y') {
         if (name[3] == 'S' || name[3] == 's') {
         if (name[3] == 'S' || name[3] == 's') {
             if (name[4] == '0') {
             if (name[4] == '0') {
@@ -148,9 +150,9 @@ int init_console(const char* name)
 }
 }
 
 
 extern void init_vfs();
 extern void init_vfs();
-extern void NORETURN init_scheduler();
+extern "C" uint32_t check_a20_on(void);
 
 
-void NORETURN kernel_main(void)
+extern "C" void NORETURN kernel_main(void)
 {
 {
     assert(check_a20_on());
     assert(check_a20_on());
 
 
@@ -202,7 +204,7 @@ void NORETURN kernel_main(void)
     init_vfs();
     init_vfs();
 
 
     printkf("switching execution to the scheduler...\n");
     printkf("switching execution to the scheduler...\n");
-    init_scheduler(&tss);
+    init_scheduler();
 }
 }
 
 
 void NORETURN __stack_chk_fail(void)
 void NORETURN __stack_chk_fail(void)

+ 1 - 1
src/types/elf.cpp

@@ -1,5 +1,5 @@
 #include <kernel/errno.h>
 #include <kernel/errno.h>
-#include <kernel/stdio.h>
+#include <kernel/stdio.hpp>
 #include <types/assert.h>
 #include <types/assert.h>
 #include <types/elf.hpp>
 #include <types/elf.hpp>
 #include <types/stdint.h>
 #include <types/stdint.h>