Refactor for C++ components

This commit is contained in:
Curle 2021-07-04 21:47:09 +01:00
parent 48e9b81478
commit 6a39a82b08
Signed by: TheCurle
GPG Key ID: 5942F13718443F79
50 changed files with 450 additions and 215 deletions

3
.gitignore vendored
View File

@ -18,4 +18,5 @@ temp/
tools/x86_64-elf-tools tools/x86_64-elf-tools
!src/global/*.o !src/global/*.o
!src/assets/z*.o

View File

@ -1,9 +1,10 @@
#project config #project config
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_COMPILER x86_64-elf-g++)
set(CMAKE_C_COMPILER x86_64-elf-gcc) set(CMAKE_C_COMPILER x86_64-elf-gcc)
# cheat the compile test # cheat the compile test
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
SET(CMAKE_SYSTEM_NAME Generic) SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_CROSSCOMPILING 1) SET(CMAKE_CROSSCOMPILING 1)
@ -63,4 +64,4 @@ add_executable(kernel)
target_sources(kernel PUBLIC ${src_preamble} PUBLIC ${src_files} PUBLIC ${src_no_sse} PUBLIC ${lib_files} PUBLIC ${src_epilogue}) target_sources(kernel PUBLIC ${src_preamble} PUBLIC ${src_files} PUBLIC ${src_no_sse} PUBLIC ${lib_files} PUBLIC ${src_epilogue})
target_compile_options(kernel PRIVATE -ffreestanding -O0 -Wall -Wextra -Wall -Werror -fPIC -fno-exceptions -fno-omit-frame-pointer -mno-red-zone -fno-stack-protector -ggdb3) target_compile_options(kernel PRIVATE -ffreestanding -O0 -Wall -Wextra -Wall -Werror -fPIC -fno-exceptions -fno-omit-frame-pointer -mno-red-zone -fno-stack-protector -ggdb3)
target_link_options(kernel PRIVATE -T linker.ld -ffreestanding -O2 -nostdlib -nostartfiles -lgcc) target_link_options(kernel PRIVATE -T ${CMAKE_SOURCE_DIR}/linker.ld -ffreestanding -O2 -nostdlib -nostartfiles -lgcc)

View File

@ -5,6 +5,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* This file contains most of the symbols required to start and run the Chroma Editor. * This file contains most of the symbols required to start and run the Chroma Editor.
* *
@ -116,4 +120,8 @@ void GetLine(EditorState* state, size_t line);
void SetLine(EditorState* state, struct EditorLine* line); void SetLine(EditorState* state, struct EditorLine* line);
void AppendLine(EditorState* state, struct EditorLine* line); void AppendLine(EditorState* state, struct EditorLine* line);
void AppendToLine(EditorState* state, struct EditorLine* line, size_t textLength, char* text); void AppendToLine(EditorState* state, struct EditorLine* line, size_t textLength, char* text);
void RemoveLine(EditorState* state, size_t line); void RemoveLine(EditorState* state, size_t line);
#ifdef __cplusplus
}
#endif

View File

@ -1,7 +1,4 @@
#pragma once
#ifndef _BOOTLOADER_H_
#define _BOOTLOADER_H_
/************************ /************************
*** Team Kitty, 2020 *** *** Team Kitty, 2020 ***
*** Chroma *** *** Chroma ***
@ -161,5 +158,3 @@ typedef struct {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif

View File

@ -9,6 +9,10 @@
* It also provides the symbols for the framebuffer and configuration file, which are both equually important. * It also provides the symbols for the framebuffer and configuration file, which are both equually important.
*/ */
#ifdef __cplusplus
extern "C" {
#endif
#define UNUSED(x) (void)x #define UNUSED(x) (void)x
#include <stdint.h> #include <stdint.h>
@ -25,9 +29,6 @@
#include <lainlib/lainlib.h> #include <lainlib/lainlib.h>
#include <lainlib/ethernet/e1000/e1000.h> #include <lainlib/ethernet/e1000/e1000.h>
//Removed cause "wacky copyrighted stuff"
//#include <kernel/system/screen.h>
extern size_t LoadAddr; extern size_t LoadAddr;
extern bootinfo bootldr; extern bootinfo bootldr;
extern unsigned char* environment; extern unsigned char* environment;
@ -82,4 +83,8 @@ int Main();
void Exit(); void Exit();
void SomethingWentWrong(const char* Message); void SomethingWentWrong(const char* Message);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -8,6 +8,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) {
uint16_t LowLimit; uint16_t LowLimit;
uint16_t BaseLow; uint16_t BaseLow;
@ -73,3 +77,6 @@ typedef struct __attribute__((packed)) {
uint16_t IOMap; uint16_t IOMap;
} TSS64; } TSS64;
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -5,6 +5,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct { typedef struct {
char Char; char Char;
char Scancode; char Scancode;
@ -17,4 +21,8 @@ extern KeyboardCallback KeyboardCallbacks[16];
int SetupKBCallback(void (*Handler)(KeyboardData Frame)); int SetupKBCallback(void (*Handler)(KeyboardData Frame));
void UninstallKBCallback(int Index); void UninstallKBCallback(int Index);
#ifdef __cplusplus
}
#endif

View File

@ -1,12 +0,0 @@
#pragma once
/************************
*** Team Kitty, 2020 ***
*** Chroma ***
***********************/
#include <stddef.h>
#include <stdint.h>
uint8_t HeapEnabled = 0;

View File

@ -6,6 +6,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
extern const char* ExceptionStrings[]; extern const char* ExceptionStrings[];
@ -89,3 +93,7 @@ void IRQ12Handler(INTERRUPT_FRAME* Frame);
void IRQ13Handler(INTERRUPT_FRAME* Frame); void IRQ13Handler(INTERRUPT_FRAME* Frame);
void IRQ14Handler(INTERRUPT_FRAME* Frame); void IRQ14Handler(INTERRUPT_FRAME* Frame);
void IRQ15Handler(INTERRUPT_FRAME* Frame); void IRQ15Handler(INTERRUPT_FRAME* Frame);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -1,5 +1,9 @@
#pragma once #pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <kernel/system/descriptors.h> #include <kernel/system/descriptors.h>
/************************ /************************
@ -73,4 +77,8 @@ int SerialPrintf(const char* restrict format, ...);
int Printf(const char* restrict Format, ...); int Printf(const char* restrict Format, ...);
void* memcpy(void* dest, void const* src, size_t len); void* memcpy(void* dest, void const* src, size_t len);
void* memset(void* dst, int src, size_t len); void* memset(void* dst, int src, size_t len);
#ifdef __cplusplus
}
#endif

View File

@ -1,3 +1,9 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <kernel/system/interrupts.h> #include <kernel/system/interrupts.h>
@ -288,4 +294,8 @@ void PageFaultHandler(INTERRUPT_FRAME Frame);
extern void *PREFIX(malloc)(size_t); ///< The standard function. extern void *PREFIX(malloc)(size_t); ///< The standard function.
extern void *PREFIX(realloc)(void *, size_t); ///< The standard function. extern void *PREFIX(realloc)(void *, size_t); ///< The standard function.
extern void *PREFIX(calloc)(size_t, size_t); ///< The standard function. extern void *PREFIX(calloc)(size_t, size_t); ///< The standard function.
extern void PREFIX(free)(void *); ///< The standard function. extern void PREFIX(free)(void *); ///< The standard function.
#ifdef __cplusplus
}
#endif

View File

@ -1,4 +1,9 @@
#pragma once #pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
@ -171,4 +176,8 @@ typedef struct {
extern pci_device_t** pci_root_devices; extern pci_device_t** pci_root_devices;
extern pci_entry_t* pci_map; extern pci_entry_t* pci_map;
#ifdef __cplusplus
}
#endif

View File

@ -14,8 +14,6 @@
#define MAX_PROCESSES 128 #define MAX_PROCESSES 128
#define PROCESS_STACK 65535 #define PROCESS_STACK 65535
static size_t
/** /**
* @brief All the data a process needs. * @brief All the data a process needs.
* *
@ -73,6 +71,7 @@ class Process {
ProcessState State; ProcessState State;
bool User; // Is this process originated in userspace? bool User; // Is this process originated in userspace?
bool System; // Was this process started by the system (ie. not user interaction)
size_t UniquePID; // Globally Unique ID. size_t UniquePID; // Globally Unique ID.
size_t KernelPID; // If in kernel space, the PID. size_t KernelPID; // If in kernel space, the PID.
@ -85,14 +84,14 @@ class Process {
bool ORS = false; bool ORS = false;
bool IsActive = false; bool IsActive = false;
bool IsInterrupted = false; // True if an interrupt was fired while this process is active bool IsInterrupted = false; // True if an interrupt was fired while this process is active
uint8_t Signals[8]; // Interrupt / IRQ / Signal handlers. uint8_t Signals[8]; // Interrupt / IRQ / Signal handlers.
uint8_t Sleeping; // 0 if active, else the process is waiting for something. TODO: remove this, use State? uint8_t Sleeping; // 0 if active, else the process is waiting for something. TODO: remove this, use State?
ProcessMessage* Messages; // A queue of IPC messages. ProcessMessage* Messages; // A queue of IPC messages.
size_t LastMessage; // The index of the current message. size_t LastMessage; // The index of the current message.
uint8_t* ProcessMemory; uint8_t* ProcessMemory;
size_t ProcessMemorySize; size_t ProcessMemorySize;
// TODO: Stack Trace & MFS // TODO: Stack Trace & MFS
@ -101,10 +100,10 @@ class Process {
Process(size_t KPID) : State(PROCESS_AVAILABLE), UniquePID(-1), KernelPID(KPID) { Process(size_t KPID) : State(PROCESS_AVAILABLE), UniquePID(-1), KernelPID(KPID) {
}; };
Process(const char* ProcessName, size_t KPID, size_t UPID, size_t EntryPoint, bool Userspace) Process(const char* ProcessName, size_t KPID, size_t UPID, size_t EntryPoint, bool Userspace)
: UniquePID(UPID), KernelPID(KPID), Entry(EntryPoint), ORS(false), LastMessage(0), User(Userspace), Sleeping(0) { : UniquePID(UPID), KernelPID(KPID), Entry(EntryPoint), ORS(false), LastMessage(0), User(Userspace), Sleeping(0) {
memcpy((void*) ProcessName, Name, strlen(Name) + 1); memcpy((void*) ProcessName, Name, strlen(Name) + 1);
}; };
@ -120,11 +119,40 @@ class Process {
/*************************************************************/ /*************************************************************/
void InitMemory(); void InitMemory();
void InitMessages(); void InitMessages();
void Kill() {
State = ProcessState::PROCESS_REAP;
Sleeping = -1;
};
void Destroy();
void Rename(const char* NewName) {
memcpy(Name, NewName, strlen(Name) > strlen(NewName) ? strlen(Name) : strlen(NewName));
}
size_t* AllocateProcessSpace(size_t Bytes);
size_t FreeProcessSpace(size_t* Address, size_t Bytes);
bool OwnsAddress(size_t* Address, size_t Bytes);
/*************************************************************/ /*************************************************************/
void SetParent(size_t PID) { ParentPID = PID; };
void SetSystem(bool Status) {
System = Status;
if(System && User) {
// TODO: Log error.
}
};
void SetState(ProcessState NewState) { State = NewState; };
void SetActive(bool NewState) { IsActive = NewState; };
void SetCore(size_t CoreID) { Core = CoreID; }; void SetCore(size_t CoreID) { Core = CoreID; };
void IncreaseSleep(size_t Interval) { Sleeping += Interval; }; void IncreaseSleep(size_t Interval) { Sleeping += Interval; };
@ -134,8 +162,15 @@ class Process {
ProcessHeader* GetHeader() { return &Header; }; ProcessHeader* GetHeader() { return &Header; };
const char* GetName() const { return Name; };
size_t GetPID() const { return UniquePID; };
size_t GetKPID() const { return KernelPID; };
size_t GetParent() const { return ParentPID; }; size_t GetParent() const { return ParentPID; };
ProcessState GetState() const { return State; };
bool IsValid() const { return KernelPID != 0; }; bool IsValid() const { return KernelPID != 0; };
bool IsUsed() const { return (State != ProcessState::PROCESS_AVAILABLE && State != ProcessState::PROCESS_CRASH && State != ProcessState::PROCESS_REAP) && IsValid(); }; bool IsUsed() const { return (State != ProcessState::PROCESS_AVAILABLE && State != ProcessState::PROCESS_CRASH && State != ProcessState::PROCESS_REAP) && IsValid(); };
@ -148,10 +183,21 @@ class Process {
bool flag = !(ORS && !IsActive); bool flag = !(ORS && !IsActive);
return State == ProcessState::PROCESS_WAITING && Core == CPU && KernelPID != 0 && flag && !IsSleeping(); return State == ProcessState::PROCESS_WAITING && Core == CPU && KernelPID != 0 && flag && !IsSleeping();
} };
size_t GetCore() const { return Core; }; size_t GetCore() const { return Core; };
bool IsUserspace() { return User; };
bool IsSystem() { return System; };
/*************************************************************/
static Process* FromName(const char* name);
static Process* FromPID(size_t PID);
static Process* Current();
static void SetCurrent(Process* Target);
}; };
@ -166,17 +212,17 @@ class ProcessManagement {
void Wait(); void Wait();
void Initialize(); void Initialize();
void InitialiseCore(int APIC, int ID); void InitialiseCore(int APIC, int ID);
void NotifyAllCores(); void NotifyAllCores();
// TODO: Process* // TODO: Process*
size_t SwitchContext(INTERRUPT_FRAME* CurrentFrame); size_t SwitchContext(INTERRUPT_FRAME* CurrentFrame);
void MapThreadMemory(size_t from, size_t to, size_t length); void MapThreadMemory(size_t from, size_t to, size_t length);
void InitProcess(/*func EntryPoint*/ int argc, char** argv); void InitProcess(/*func EntryPoint*/ int argc, char** argv);
void InitProcessPagetable(bool Userspace); void InitProcessPagetable(bool Userspace);
void InitProcessArch(); void InitProcessArch();
size_t HandleRequest(size_t CPU); size_t HandleRequest(size_t CPU);

View File

@ -1,4 +1,9 @@
#pragma once #pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
@ -12,4 +17,8 @@ typedef struct stackframe {
size_t rip; size_t rip;
} stackframe_t; } stackframe_t;
void StackTrace(size_t cycles); void StackTrace(size_t cycles);
#ifdef __cplusplus
}
#endif

View File

@ -3,6 +3,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
// This file contains all of the bitmap fonts made by me (Curle) and taken from the public domain // This file contains all of the bitmap fonts made by me (Curle) and taken from the public domain
// eg. http://dimensionalrift.homelinux.net/combuster/mos3/?p=viewsource&file=/modules/gfx/font8_8.asm // eg. http://dimensionalrift.homelinux.net/combuster/mos3/?p=viewsource&file=/modules/gfx/font8_8.asm
@ -463,4 +467,8 @@ const unsigned char bitfont_block[32][8] = {
{ 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00}, // U+259D (box top right) { 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00}, // U+259D (box top right)
{ 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F}, // U+259E (boxes top right and bottom left) { 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F}, // U+259E (boxes top right and bottom left)
{ 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF}, // U+259F (boxes right and bottom) { 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF}, // U+259F (boxes right and bottom)
}; };
#ifdef __cplusplus
}
#endif

View File

@ -5,6 +5,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* Drawing routines for screen manipulation. * Drawing routines for screen manipulation.
* This will be pulled out into the Helix library soon. * This will be pulled out into the Helix library soon.
@ -55,4 +59,8 @@ void DrawLineRoundedRect(size_t x, size_t y, size_t width, size_t height, size_t
void DrawFilledCircle(size_t centerX, size_t centerY, size_t radius); void DrawFilledCircle(size_t centerX, size_t centerY, size_t radius);
void DrawLineCircle(size_t centerX, size_t centerY, size_t radius); void DrawLineCircle(size_t centerX, size_t centerY, size_t radius);
void DrawLineCircleCorners(size_t centerX, size_t centerY, size_t radius, char cornerMask); void DrawLineCircleCorners(size_t centerX, size_t centerY, size_t radius, char cornerMask);
#ifdef __cplusplus
}
#endif

View File

@ -33,8 +33,8 @@ extern "C" {
#endif #endif
#define LZG_VERSION "1.0.10" /**< @brief LZG library version string */ #define LZG_VERSION "1.0.10" /**< @brief LZG library version string */
#define LZG_VERNUM 0x0100000a /**< @brief LZG library version number (strictly #define LZG_VERNUM 0x0100000a /**< @brief LZG library version number (strictly */
incremental) */ /* incremental) */
#define LZG_VER_MAJOR 1 /**< @brief LZG library major version */ #define LZG_VER_MAJOR 1 /**< @brief LZG library major version */
#define LZG_VER_MINOR 0 /**< @brief LZG library minor version */ #define LZG_VER_MINOR 0 /**< @brief LZG library minor version */
#define LZG_VER_REVISION 10 /**< @brief LZG library revision */ #define LZG_VER_REVISION 10 /**< @brief LZG library revision */

View File

@ -3,6 +3,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <kernel/system/pci.h> #include <kernel/system/pci.h>
@ -179,3 +183,7 @@ void E1000InterruptFired(INTERRUPT_FRAME* InterruptContext);
uint8_t* E1000GetMAC(e1000_device_t* Device); uint8_t* E1000GetMAC(e1000_device_t* Device);
// Send a packet // Send a packet
int E1000Send(e1000_device_t* Device, const void* Data, uint16_t Length); int E1000Send(e1000_device_t* Device, const void* Data, uint16_t Length);
#ifdef __cplusplus
}
#endif

View File

@ -1,19 +1,20 @@
#pragma once #pragma once
#ifdef __cplusplus
extern "C" {
#endif
/************************ /************************
*** Team Kitty, 2020 *** *** Team Kitty, 2020 ***
*** Chroma *** *** Chroma ***
***********************/ ***********************/
/* Defines all of the temporary library functions. /* Defines all of the temporary library functions.
* All of this must be moved into the Chroma stdlib. * All of this must be moved into the Chroma stdlib.
* They exist here as guidance, and as utility for the kernel itself. * They exist here as guidance, and as utility for the kernel itself.
* If need be, they can also be moved into a trimmed-down "kernel libc" or "libk". * If need be, they can also be moved into a trimmed-down "kernel libc" or "libk".
*/ */
#include <lainlib/vector/vector.h>
#include <lainlib/list/list.h> #include <lainlib/list/list.h>
#include <lainlib/mutex/spinlock.h> #include <lainlib/mutex/spinlock.h>
@ -22,3 +23,7 @@
#include <lainlib/string/str.h> #include <lainlib/string/str.h>
#include <lainlib/compression/lzg.h> #include <lainlib/compression/lzg.h>
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -1,5 +1,9 @@
#include <stdbool.h> #include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct list_entry { typedef struct list_entry {
struct list_entry* Previous; struct list_entry* Previous;
struct list_entry* Next; struct list_entry* Next;
@ -31,4 +35,8 @@ bool ListIsEmpty(list_entry_t* Head);
#define LISTFOREACHENTRY(pos, head, member) \ #define LISTFOREACHENTRY(pos, head, member) \
for(pos = UNSAFE_CAST((head)->next, typeof(*(pos)), member); &pos->member != (head); pos = LISTNEXT(pos, member)) for(pos = UNSAFE_CAST((head)->next, typeof(*(pos)), member); &pos->member != (head); pos = LISTNEXT(pos, member))
#define LASTENTRY 0 #define LASTENTRY 0
#ifdef __cplusplus
}
#endif

View File

@ -5,6 +5,9 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
typedef volatile int spinlock_t; typedef volatile int spinlock_t;
@ -20,3 +23,6 @@ typedef volatile int spinlock_t;
__sync_synchronize(); \ __sync_synchronize(); \
name = 0; name = 0;
#ifdef __cplusplus
}
#endif

View File

@ -7,14 +7,19 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file provides a simple implementation of a ticket-based locking system. /* This file provides a simple implementation of a ticket-based locking system.
* You should probably prefer Spinlock over Ticketlock. * You should probably prefer Spinlock over Ticketlock.
* *
* Create a new lock with NEW_TICKETLOCK(), * Create a new lock with NEW_TICKETLOCK(),
* lock a resource with TicketLock(). * lock a resource with TicketLock().
* *
* Use TicketUnlock() to free the resource after you are done. * Use TicketUnlock() to free the resource after you are done.
* *
*/ */
typedef struct { typedef struct {
@ -30,3 +35,6 @@ bool TicketAttemptLock(ticketlock_t* Lock);
void TicketUnlock(ticketlock_t* Lock); void TicketUnlock(ticketlock_t* Lock);
#ifdef __cplusplus
}
#endif

View File

@ -1,10 +1,19 @@
#pragma once #pragma once
#include <stddef.h>
/************************ /************************
*** Team Kitty, 2021 *** *** Team Kitty, 2021 ***
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
size_t strlen(const char* String); size_t strlen(const char* String);
bool strcmp(char* a, const char* b); bool strcmp(char* a, const char* b);
#ifdef __cplusplus
}
#endif

View File

@ -1,30 +0,0 @@
/************************
*** Team Kitty, 2020 ***
*** Chroma ***
***********************/
#pragma once
#include<stddef.h>
#include<stdint.h>
#include <lainlib/mutex/spinlock.h>
struct vector_t {
void** items;
size_t n;
spinlock_t vector_lock;
};
int VectorRemoveItem(struct vector_t* vec, void* item);
int VectorRemove(struct vector_t* vec, size_t index);
void* VectorGet(struct vector_t* vec, size_t index);
int VectorInsert(struct vector_t* vec, void* item, size_t index);
int VectorAppend(struct vector_t* vec, void* item);
int VectorDestroy(struct vector_t* vec);

View File

@ -1,5 +1,3 @@
memstart = 0x14400;
mmio = 0xfffffffff8000000; mmio = 0xfffffffff8000000;
fb = 0xfffffffffc000000; fb = 0xfffffffffc000000;
@ -16,7 +14,7 @@ SECTIONS
environment = .; . += 4096; environment = .; . += 4096;
.text : { .text : {
_kernel_text_start = .; _kernel_text_start = .;
KEEP(*(.text.boot)) *(.text .text.*) KEEP(*(.text.boot)) *(.text .text.*)
_kernel_rodata_start = .; _kernel_rodata_start = .;

7
src/editor/EditorDraw.c Normal file
View File

@ -0,0 +1,7 @@
#include <kernel/chroma.h>
#include <editor/main.h>
/************************
*** Team Kitty, 2021 ***
*** Chroma ***
***********************/

View File

@ -21,10 +21,10 @@ void StartEditor(int callbackID) {
layout.ScreenWidth = PrintInfo.screenWidth; layout.ScreenWidth = PrintInfo.screenWidth;
layout.HeaderHeight = layout.ScreenHeight / 100 * 3; layout.HeaderHeight = layout.ScreenHeight / 100 * 3;
layout.TextBoxHeight = (layout.ScreenHeight - layout.HeaderHeight) / 100 * 95; layout.TextBoxHeight = ((layout.ScreenHeight - layout.HeaderHeight) / 100) * 95;
layout.TextBoxY = ((layout.ScreenHeight + layout.HeaderHeight) - layout.TextBoxHeight) / 2; layout.TextBoxY = ((layout.ScreenHeight + layout.HeaderHeight) - layout.TextBoxHeight) / 2;
layout.TextBoxWidth = layout.ScreenWidth / 100 * 95; layout.TextBoxWidth = (layout.ScreenWidth / 100) * 95;
layout.TextBoxX = (layout.ScreenWidth - layout.TextBoxWidth) / 2; layout.TextBoxX = (layout.ScreenWidth - layout.TextBoxWidth) / 2;
SetForegroundColor(0x000084); SetForegroundColor(0x000084);

7
src/editor/EditorWrite.c Normal file
View File

@ -0,0 +1,7 @@
#include <kernel/chroma.h>
#include <editor/main.h>
/************************
*** Team Kitty, 2021 ***
*** Chroma ***
***********************/

View File

@ -8,6 +8,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file is the entry point to the system. /* This file is the entry point to the system.
* It dictates the order of operations of everything the kernel actually does. * It dictates the order of operations of everything the kernel actually does.
* If a function isn't fired here, directly or indirectly, it is not run. * If a function isn't fired here, directly or indirectly, it is not run.
@ -150,4 +154,8 @@ void SomethingWentWrong(const char* Message) {
void Exit(int ExitCode) { void Exit(int ExitCode) {
SerialPrintf("Kernel stopped with code %x\r\n", ExitCode); SerialPrintf("Kernel stopped with code %x\r\n", ExitCode);
} }
#ifdef __cplusplus
}
#endif

View File

@ -27,6 +27,10 @@
#include <lainlib/lainlib.h> #include <lainlib/lainlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/*-- PRIVATE -----------------------------------------------------------------*/ /*-- PRIVATE -----------------------------------------------------------------*/
/* Internal definitions */ /* Internal definitions */
@ -188,3 +192,7 @@ lzg_uint32_t LZG_Decode(const unsigned char *in, lzg_uint32_t insize,
else else
return decodedSize; return decodedSize;
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,27 +1,32 @@
/*************************
*** Team Kitty, 2021 ***
*** Lainlib ***
************************/
#include <lainlib/ethernet/e1000/e1000.h> #include <lainlib/ethernet/e1000/e1000.h>
#include <kernel/chroma.h> #include <kernel/chroma.h>
#include <kernel/system/memory.h> #include <kernel/system/memory.h>
#include <kernel/system/interrupts.h> #include <kernel/system/interrupts.h>
/*************************
*** Team Kitty, 2021 ***
*** Lainlib ***
************************/
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* This file handles all the logic for interfacing with the E1000 networking device. * This file handles all the logic for interfacing with the E1000 networking device.
* This card is labelled either the Intel I217, or Intel Gigabit 82577LM. * This card is labelled either the Intel I217, or Intel Gigabit 82577LM.
* These cards are identical, and this driver will work identically for both of them. * These cards are identical, and this driver will work identically for both of them.
* *
* To use this driver, allocate an e1000_device struct and pass it to the E1000Init() function, * To use this driver, allocate an e1000_device struct and pass it to the E1000Init() function,
* along with its' PCI device header. * along with its' PCI device header.
* *
* TODO: usage information * TODO: usage information
*/ */
/** /**
* Write data to the device's command registers. * Write data to the device's command registers.
* If we use BAR type 0, we use MMIO, otherwise ports. * If we use BAR type 0, we use MMIO, otherwise ports.
* *
* @param Device The device to which we write the data. * @param Device The device to which we write the data.
* @param Address The address to write the data at. For MMIO, the offset from base. * @param Address The address to write the data at. For MMIO, the offset from base.
* @param Data The data to write into the register. * @param Data The data to write into the register.
@ -349,4 +354,8 @@ int E1000Send(e1000_device_t* Device, const void* Data, uint16_t Length) {
while(!(Device->TransmitPackets[temp]->Status & 0xFF)); while(!(Device->TransmitPackets[temp]->Status & 0xFF));
return 0; return 0;
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,9 +1,13 @@
#include <stdint.h>
/************************ /************************
*** Team Kitty, 2021 *** *** Team Kitty, 2021 ***
*** Chroma *** *** Lainlib ***
***********************/ ***********************/
#include <stdint.h> #ifdef __cplusplus
extern "C" {
#endif
struct mac_address { struct mac_address {
uint8_t MAC[6]; uint8_t MAC[6];
@ -20,4 +24,8 @@ struct ethernet_packet {
mac_address Source; mac_address Source;
uint16_t Type; uint16_t Type;
uint8_t Payload[]; uint8_t Payload[];
}; };
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,9 @@
#include <lainlib/list/list.h> #include <lainlib/list/list.h>
#ifdef __cplusplus
extern "C" {
#endif
void ListAdd(list_entry_t* Head, list_entry_t* New) { void ListAdd(list_entry_t* Head, list_entry_t* New) {
New->Next = Head->Next; New->Next = Head->Next;
New->Previous = Head; New->Previous = Head;
@ -24,4 +28,8 @@ void ListRemove(list_entry_t* Entry) {
bool ListIsEmpty(list_entry_t* Head) { bool ListIsEmpty(list_entry_t* Head) {
return Head->Next == Head; return Head->Next == Head;
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,6 +1,10 @@
#include <kernel/chroma.h> #include <kernel/chroma.h>
#include <lainlib/lainlib.h> #include <lainlib/lainlib.h>
#ifdef __cplusplus
extern "C" {
#endif
void TicketLock(ticketlock_t* Lock) { void TicketLock(ticketlock_t* Lock) {
size_t Ticket = atomic_fetch_add_explicit(&Lock->NextTicket, 1, memory_order_relaxed); size_t Ticket = atomic_fetch_add_explicit(&Lock->NextTicket, 1, memory_order_relaxed);
@ -18,4 +22,8 @@ bool TicketAttemptLock(ticketlock_t* Lock) {
void TicketUnlock(ticketlock_t* Lock) { void TicketUnlock(ticketlock_t* Lock) {
size_t NextTicket = atomic_load_explicit(&Lock->NowServing, memory_order_relaxed) + 1; size_t NextTicket = atomic_load_explicit(&Lock->NowServing, memory_order_relaxed) + 1;
atomic_store_explicit(&Lock->NowServing, NextTicket, memory_order_release); atomic_store_explicit(&Lock->NowServing, NextTicket, memory_order_release);
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,11 +1,16 @@
/************************
*** Team Kitty, 2021 ***
*** Chroma ***
***********************/
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
/************************
*** Team Kitty, 2021 ***
*** Lainlib ***
***********************/
#ifdef __cplusplus
extern "C" {
#endif
size_t strlen(const char* String) { size_t strlen(const char* String) {
size_t Len = 0; size_t Len = 0;
while(String[Len] != '\0') { while(String[Len] != '\0') {
@ -22,4 +27,8 @@ bool strcmp(char* a, const char* b) {
aI++; aI++;
bI++; bI++;
} }
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,68 +0,0 @@
#include <templib/templib.h>
/************************
*** Team Kitty, 2020 ***
*** Chroma ***
***********************/
/* This file provides a Chroma implementation of std::vector, a C++ standard library class.
* It has a lot of work left to be done, but it's usable for its intended function (Graphics)
*/
int VectorRemoveItem(struct vector_t* vec, void* item) {
//TODO
return -1;
}
int VectorRemove(struct vector_t* vec, size_t index) {
if (!vec) return 0;
//TODO: Vector spinlock
// AcqSpinlock(&vec->lock);
if((index + 1) > vec->n) return 0;
vec->items[index] = NULL;
for (int i = 0; i < vec->n; i++) {
vec->items[i] = vec->items[i + 1];
}
//TODO: vector reallocate
// realloc(vec->items, vec->n - 1);
vec->n--;
// ReleaseSpinlock(&vec->lock);
return 1;
}
void* VectorGet(struct vector_t* vec, size_t index) {
if(!vec) return 0;
//TODO: Vector spinlock
// AcqSpinlock(&vec->lock);
if((index + 1) > vec->n) return NULL;
// ReleaseSpinlock(&vec->lock);
return vec->items[index];
}
int VectorInsert(struct vector_t* vec, void* item, size_t index) {
}
int VectorAppend(struct vector_t* vec, void* item) {
}
int VectorDestroy(struct vector_t* vec) {
}

View File

@ -6,6 +6,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This class provides functions for setting up and preparing the CPU for the things the kernel will do. /* This class provides functions for setting up and preparing the CPU for the things the kernel will do.
* Mainly, it allows you to: * Mainly, it allows you to:
* *
@ -265,5 +269,6 @@ void SetupIDT() {
} }
#ifdef __cplusplus
}
#endif

View File

@ -4,9 +4,13 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* /*
* This file provides utility functions for parsing ELF headers. * This file provides utility functions for parsing ELF headers.
* This exists so that the kernel can find itself for remapping, * This exists so that the kernel can find itself for remapping,
* but I may end up using ELF as the kernel's executable format. * but I may end up using ELF as the kernel's executable format.
* Writing an ELF loader is on the to-do list, after all. * Writing an ELF loader is on the to-do list, after all.
! This needs to be cleaned up. ! This needs to be cleaned up.
@ -17,10 +21,10 @@ extern size_t KernelLocation;
int ParseKernelHeader(size_t InitrdPtr) { int ParseKernelHeader(size_t InitrdPtr) {
int flag = 0; int flag = 0;
SerialPrintf("[ boot] Searching for kernel... Constants start at 0x%p / 0x%p\r\n", ((size_t) (&_kernel_text_start) - KernelAddr) + InitrdPtr, (size_t) (&_kernel_text_start)); SerialPrintf("[ boot] Searching for kernel... Constants start at 0x%p / 0x%p\r\n", ((size_t) (&_kernel_text_start) - KernelAddr) + InitrdPtr, (size_t) (&_kernel_text_start));
// We stop at the constants in the kernel, otherwise we'll read the constant ELF64MAGIC which is stored inside the kernel... // We stop at the constants in the kernel, otherwise we'll read the constant ELF64MAGIC which is stored inside the kernel...
size_t headerLoc = 0; size_t headerLoc = 0;
for(size_t i = InitrdPtr; i < ((size_t) (&_kernel_text_start) - KernelAddr) + InitrdPtr; i++) { for(size_t i = InitrdPtr; i < ((size_t) (&_kernel_text_start) - KernelAddr) + InitrdPtr; i++) {
if(*((volatile uint32_t*)(i)) == ELF64MAGIC) { if(*((volatile uint32_t*)(i)) == ELF64MAGIC) {
@ -54,21 +58,21 @@ int ParseKernelHeader(size_t InitrdPtr) {
uint16_t ExecutableType = (uint16_t) *((volatile uint8_t*)(headerLoc + ELFTYPE_OFF)); uint16_t ExecutableType = (uint16_t) *((volatile uint8_t*)(headerLoc + ELFTYPE_OFF));
uint16_t MachineType = (uint16_t) *((volatile uint8_t*)(headerLoc + ELFMACHINE_OFF)); uint16_t MachineType = (uint16_t) *((volatile uint8_t*)(headerLoc + ELFMACHINE_OFF));
SerialPrintf( SerialPrintf(
"[ boot] ELF header at 0x%p.\r\n\tConsidering ELF with:\r\n\tBitness %d: %d\r\n\tEntry point 0x%p\r\n\tFile type %s : 0x%x\r\n\tArchitecture %s : 0x%x\r\n", "[ boot] ELF header at 0x%p.\r\n\tConsidering ELF with:\r\n\tBitness %d: %d\r\n\tEntry point 0x%p\r\n\tFile type %s : 0x%x\r\n\tArchitecture %s : 0x%x\r\n",
headerLoc, headerLoc,
HeaderClass == 2 ? 64 : 32, HeaderClass == 2 ? 64 : 32,
HeaderClass, HeaderClass,
EntryPoint, EntryPoint,
ExecutableType == FIXENDIAN16(0x0200) ? "EXECUTABLE" : "OTHER", ExecutableType == FIXENDIAN16(0x0200) ? "EXECUTABLE" : "OTHER",
FIXENDIAN16(ExecutableType), FIXENDIAN16(ExecutableType),
MachineType == FIXENDIAN16(0x3E00) ? "AMD64" : "OTHER", MachineType == FIXENDIAN16(0x3E00) ? "AMD64" : "OTHER",
FIXENDIAN16(MachineType)); FIXENDIAN16(MachineType));
if(EntryPoint == (size_t) (&_kernel_text_start)) { if(EntryPoint == (size_t) (&_kernel_text_start)) {
SerialPrintf("[ boot] Header at 0x%p matches kernel header.\r\n", headerLoc); SerialPrintf("[ boot] Header at 0x%p matches kernel header.\r\n", headerLoc);
flag = 1; flag = 1;
@ -89,3 +93,6 @@ int ParseKernelHeader(size_t InitrdPtr) {
} }
#ifdef __cplusplus
}
#endif

View File

@ -6,6 +6,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file contains (mostly unused) implementations of a full PS/2 keyboard driver. /* This file contains (mostly unused) implementations of a full PS/2 keyboard driver.
* *
* It provides provisions for full 2-way communication, as well as auxiliary key commands. * It provides provisions for full 2-way communication, as well as auxiliary key commands.
@ -147,4 +151,8 @@ void WaitFor8042() {
while(full) { while(full) {
full = ReadPort(0x64, 1) & 1; full = ReadPort(0x64, 1) & 1;
} }
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,8 +1,17 @@
#include <kernel/chroma.h>
#include <kernel/video/draw.h>
#include <kernel/system/interrupts.h>
#include <stdbool.h>
/************************ /************************
*** Team Kitty, 2020 *** *** Team Kitty, 2020 ***
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file contains all of the ISR and IRQ /* This file contains all of the ISR and IRQ
* (Interrupt Service Request) functions. * (Interrupt Service Request) functions.
* *
@ -32,11 +41,6 @@
* these having a size_t input as an error code. * these having a size_t input as an error code.
*/ */
#include <kernel/chroma.h>
#include <kernel/video/draw.h>
#include <kernel/system/interrupts.h>
#include <stdbool.h>
const char* ExceptionStrings[] = { const char* ExceptionStrings[] = {
"Division by Zero", "Division by Zero",
"Debug", "Debug",
@ -457,4 +461,8 @@ __attribute__((interrupt)) void IRQ14Handler(INTERRUPT_FRAME* Frame) {
} }
__attribute__((interrupt)) void IRQ15Handler(INTERRUPT_FRAME* Frame) { __attribute__((interrupt)) void IRQ15Handler(INTERRUPT_FRAME* Frame) {
IRQ_Common(Frame, 15); IRQ_Common(Frame, 15);
} }
#ifdef __cplusplus
}
#endif

View File

@ -4,12 +4,14 @@
#include <kernel/system/memory.h> #include <kernel/system/memory.h>
#include <kernel/system/io.h> #include <kernel/system/io.h>
/************************ /************************
*** Team Kitty, 2020 *** *** Team Kitty, 2020 ***
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/************************************************ /************************************************
* C O N S T A N T S A N D M A C R O S * C O N S T A N T S A N D M A C R O S
@ -66,12 +68,12 @@ alloc_decl int Alloc_FindLastOne_64(size_t size) {
int high = (int)(size >> 32); int high = (int)(size >> 32);
int bits = 0; int bits = 0;
if(high) if(high)
bits = 32 + Alloc_FindLastOne(high); bits = 32 + Alloc_FindLastOne(high);
else else
bits = Alloc_FindLastOne((int)size & 0xFFFFFFFF); bits = Alloc_FindLastOne((int)size & 0xFFFFFFFF);
return bits; return bits;
} }
@ -795,4 +797,8 @@ void* AllocatorRealloc(allocator_t Allocator, void* Address, size_t NewSize) {
} }
return Pointer; return Pointer;
} }
#ifdef __cplusplus
}
#endif

View File

@ -3,6 +3,10 @@
/** Durand's Amazing Super Duper Memory functions. */ /** Durand's Amazing Super Duper Memory functions. */
#ifdef __cplusplus
extern "C" {
#endif
#define VERSION "1.1" #define VERSION "1.1"
#define ALIGNMENT 16ul//4ul ///< This is the byte alignment that memory must be allocated on. IMPORTANT for GTK and other stuff. #define ALIGNMENT 16ul//4ul ///< This is the byte alignment that memory must be allocated on. IMPORTANT for GTK and other stuff.
@ -858,3 +862,6 @@ void* PREFIX(realloc)(void *p, size_t size)
return ptr; return ptr;
} }
#ifdef __cplusplus
}
#endif

View File

@ -5,6 +5,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
#define PAGE_TABLES_GET_PDPT(address) \ #define PAGE_TABLES_GET_PDPT(address) \
(address & ((size_t) 0x1FF << 39)) >> 39 (address & ((size_t) 0x1FF << 39)) >> 39
#define PAGE_TABLES_GET_PDP(address) \ #define PAGE_TABLES_GET_PDP(address) \
@ -328,3 +332,7 @@ size_t* CreateNewPageTable(address_space_t* AddressSpace) {
return NewPML4; return NewPML4;
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,4 @@
#include <kernel/chroma.h> #include <kernel/chroma.h>
#include <kernel/system/heap.h>
#include <lainlib/lainlib.h> #include <lainlib/lainlib.h>
/************************ /************************
@ -7,6 +6,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file contains functions for physical memory management. /* This file contains functions for physical memory management.
* *
* This is also called blocking, or block memory allocation. * This is also called blocking, or block memory allocation.
@ -341,4 +344,6 @@ void* memset(void* dst, int src, size_t len) {
return dst; return dst;
} }
#ifdef __cplusplus
}
#endif

View File

@ -4,15 +4,19 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
/* #ifdef __cplusplus
extern "C" {
#endif
/*
* This file aims to implement stack unwinding * This file aims to implement stack unwinding
* to trace faulty functions. * to trace faulty functions.
* *
* I was in the middle of debugging a jump to null * I was in the middle of debugging a jump to null
* when i started creating this, so there will be a * when i started creating this, so there will be a
* lot of functionality here left over from that * lot of functionality here left over from that
* initial goal, probably... * initial goal, probably...
* *
* //TODO: Rework this to allow unwinding function parameters on call. * //TODO: Rework this to allow unwinding function parameters on call.
*/ */
@ -26,4 +30,8 @@ void StackTrace(size_t cycles) {
stack = stack->rbp; stack = stack->rbp;
} }
SerialPrintf("[Trace] Stack trace over.\r\n"); SerialPrintf("[Trace] Stack trace over.\r\n");
} }
#ifdef __cplusplus
}
#endif

View File

@ -5,11 +5,15 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file contains functions for accessing the PCI bus, /* This file contains functions for accessing the PCI bus,
* and devices contained wherein. * and devices contained wherein.
* *
* It allows you to query the bus, as well as communicate with individual devices. * It allows you to query the bus, as well as communicate with individual devices.
* *
*/ */
pci_device_t** pci_root_devices = NULL; pci_device_t** pci_root_devices = NULL;
@ -520,4 +524,8 @@ const char* PCIGetClassName(uint8_t DeviceClass) {
} }
return "Invalid device!"; return "Invalid device!";
} }
#ifdef __cplusplus
}
#endif

View File

@ -5,11 +5,15 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file serves to allow us to communicate with the computer through raw I/O. /* This file serves to allow us to communicate with the computer through raw I/O.
* It provides interfaces for Ports and commonly used Registers (Control Registers, Model-Specific Registers, GDT, IDT..) * It provides interfaces for Ports and commonly used Registers (Control Registers, Model-Specific Registers, GDT, IDT..)
* *
* Additionally, there are wrapper functions for MMIO accesses. * Additionally, there are wrapper functions for MMIO accesses.
* *
*/ */
uint32_t ReadPort(uint16_t Port, int Length) { uint32_t ReadPort(uint16_t Port, int Length) {
@ -255,3 +259,6 @@ void WriteTSR(uint16_t TSRData) {
} }
#ifdef __cplusplus
}
#endif

View File

@ -4,6 +4,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file provides functions related to the Serial port. /* This file provides functions related to the Serial port.
* Through this file, you send and receive text and extra debugging information if available. * Through this file, you send and receive text and extra debugging information if available.
*/ */
@ -45,4 +49,8 @@ void WriteSerialString(const char* str, size_t len) {
for(size_t i = 0; i < len; i++) { for(size_t i = 0; i < len; i++) {
WriteSerialChar(str[i]); WriteSerialChar(str[i]);
} }
} }
#ifdef __cplusplus
}
#endif

View File

@ -7,6 +7,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* This file contains all of the draw-to-screen routines. * This file contains all of the draw-to-screen routines.
* It (currently; 23/08/20) handles the keyboard input test routine, * It (currently; 23/08/20) handles the keyboard input test routine,
@ -470,3 +474,6 @@ void DrawFilledCircle(size_t centerX, size_t centerY, size_t radius) {
DrawFilledCircleInternal(centerX, centerY, radius, 3, 0); DrawFilledCircleInternal(centerX, centerY, radius, 3, 0);
} }
#ifdef __cplusplus
}
#endif

View File

@ -5,6 +5,10 @@
*** Chroma *** *** Chroma ***
***********************/ ***********************/
#ifdef __cplusplus
extern "C" {
#endif
/* This file contains all of the String / Print related functions /* This file contains all of the String / Print related functions
* that are required by the core of the kernel. * that are required by the core of the kernel.
* *
@ -191,3 +195,7 @@ int Printf(const char* restrict Format, ...) {
va_end(Parameters); va_end(Parameters);
return CharsWritten; return CharsWritten;
} }
#ifdef __cplusplus
}
#endif