Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ set(LIMINE_DIR ${CMAKE_BINARY_DIR}/limine)

file(GLOB_RECURSE KERNEL_SOURCES CONFIGURE_DEPENDS
kernel/*.cpp
include/*.h
include/*.hpp
)

find_program(LLD_LINKER NAMES ld.lld REQUIRED)
Expand Down Expand Up @@ -52,7 +54,9 @@ add_custom_command(
-T ${CMAKE_SOURCE_DIR}/linker.ld
-o ${KERNEL_ELF}
$<TARGET_OBJECTS:avery_objects>
DEPENDS avery_objects ${CMAKE_SOURCE_DIR}/linker.ld
DEPENDS
$<TARGET_OBJECTS:avery_objects>
${CMAKE_SOURCE_DIR}/linker.ld
COMMAND_EXPAND_LISTS
VERBATIM
)
Expand Down
36 changes: 36 additions & 0 deletions include/io/io.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* io.h
* As part of the Avery project
* Created by Max Van den Eynde in 2026
* --------------------------------------
* Description: I/O Mapping and writing functions
* Copyright (c) 2026 Max Van den Eynde
*/

#ifndef AVERY_IO_H
#define AVERY_IO_H
#include "../types.h"

namespace io {
inline void outb(u16 port, u8 value) {
asm volatile(
"outb %0, %1"
:
: "a"(value), "Nd"(port)
);
}

inline u8 inb(u16 port) {
u8 val;

asm volatile(
"inb %1, %0"
: "=a"(val)
: "Nd"(port)
);

return val;
}
}

#endif //AVERY_IO_H
19 changes: 19 additions & 0 deletions include/io/serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* serial.h
* As part of the Avery project
* Created by Max Van den Eynde in 2026
* --------------------------------------
* Description: The serial output for Avery
* Copyright (c) 2026 Max Van den Eynde
*/

#ifndef AVERY_SERIAL_H
#define AVERY_SERIAL_H
#include "../types.h"

namespace io {
void serialWriteChar(char c);
void serialWrite(string input);
}

#endif //AVERY_SERIAL_H
27 changes: 27 additions & 0 deletions include/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* types.h
* As part of the Avery project
* Created by Max Van den Eynde in 2026
* --------------------------------------
* Description: Type definition for the Avery Kernel
* Copyright (c) 2026 Max Van den Eynde
*/

#ifndef AVERY_TYPES_H
#define AVERY_TYPES_H

using u8 = unsigned char;
using u16 = unsigned short;
using u32 = unsigned int;
using u64 = unsigned long long;
using usize = decltype(sizeof(0));

using i8 = char;
using i16 = short;
using i32 = int;
using i64 = long long;

using string = const char*;


#endif //AVERY_TYPES_H
23 changes: 23 additions & 0 deletions kernel/io/serial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* serial.cpp
* As part of the Avery project
* Created by Max Van den Eynde in 2026
* --------------------------------------
* Description: Serial implementation
* Copyright (c) 2026 Max Van den Eynde
*/

#include "types.h"
#include "io/serial.h"
#include "io/io.h"

void io::serialWriteChar(char c) {
outb(0xE9, static_cast<u8>(c));
}

void io::serialWrite(string input) {
while (*input) {
serialWriteChar(*input);
input++;
}
}
4 changes: 4 additions & 0 deletions kernel/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <limine.h>

#include "io/serial.h"

__attribute__((used, section(".limine_requests")))
static volatile uint64_t limine_base_revision[] = LIMINE_BASE_REVISION(6);

Expand All @@ -17,6 +19,8 @@ __attribute__((used, section(".limine_requests_end")))
static volatile uint64_t limine_requests_end_marker[] = LIMINE_REQUESTS_END_MARKER;

extern "C" [[noreturn]] void _start() {
io::serialWrite("Hello, World!");

if (LIMINE_BASE_REVISION_SUPPORTED(limine_base_revision) == false) {
while (true) {
asm("hlt");
Expand Down
Loading