Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0112e7d
Use IDE Interface to find disks
maxtyson123 Apr 18, 2025
553f30d
Read MBR Partitions from disk
maxtyson123 Apr 19, 2025
13f7d31
MS Dos FS Types
maxtyson123 Apr 20, 2025
8d60520
Virtual File System
maxtyson123 Apr 20, 2025
742ebe2
Fat 32 Theory Code, Untested
maxtyson123 Apr 23, 2025
bbf5c37
First half code and comment clean up
maxtyson123 May 1, 2025
50d1647
First half code and comment clean up
maxtyson123 May 2, 2025
e008275
Fix linux FS
maxtyson123 May 3, 2025
fba4580
Fix directory read recursion
maxtyson123 May 3, 2025
0636fff
Fix File reading
maxtyson123 May 5, 2025
88ac60c
Fix large rebuild on version changes and grub end of file error
maxtyson123 May 6, 2025
8858495
Fix LFN reading
maxtyson123 May 9, 2025
86aec6f
File read/writes
maxtyson123 May 11, 2025
cad14c2
Fix dirnt updates & chain growing for files
maxtyson123 May 22, 2025
719acd0
FAT 32 TODO Clean up
maxtyson123 May 22, 2025
b24b5a5
WIP
maxtyson123 Jun 14, 2025
5ac1dd2
Give up on FAT for now
maxtyson123 Jul 17, 2025
f5d2c2f
Boot from ext2
maxtyson123 Jul 17, 2025
09d302b
Ext2 Directory Parsing
maxtyson123 Jul 20, 2025
92adef5
Ext2 File Reading
maxtyson123 Jul 20, 2025
1e6ddc0
Ext2 File Writing
maxtyson123 Jul 21, 2025
9c9ec65
Ext2 File Expanding
maxtyson123 Jul 24, 2025
a5c0805
String Memory Fixes * Optimisation
maxtyson123 Jul 25, 2025
c19cec7
Buggy Ext2 Dir Adding
maxtyson123 Jul 29, 2025
3e08d71
Buffer Class Implementation
maxtyson123 Aug 1, 2025
7f37946
Creation of Files/Dirs
maxtyson123 Aug 18, 2025
e41d1f5
Undo Deleted Images
maxtyson123 Aug 18, 2025
bdc0665
Delete Files & Directories
maxtyson123 Aug 22, 2025
5596c03
Rename Directories & Files
maxtyson123 Aug 22, 2025
8fb19b8
Fix Crashing
maxtyson123 Aug 25, 2025
81925e2
Fix MaxOS Entry Issues
maxtyson123 Aug 26, 2025
f5d2792
Fix Style Issues
maxtyson123 Aug 26, 2025
56fad28
Process Resource Management
maxtyson123 Aug 26, 2025
d495f72
Resource Syscalls & IPC setup
maxtyson123 Aug 31, 2025
01992ba
Userspace Resources & IPC
maxtyson123 Aug 31, 2025
41d1a75
Userspace Files & Directories
maxtyson123 Sep 1, 2025
5c17ff1
More Path stuff
maxtyson123 Sep 2, 2025
0ed9fa3
Pre merge fixes
maxtyson123 Sep 2, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/max-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- name: Build MaxOS (Release)
run: |
cd toolchain/post_process
cd toolchain/pre_process
./version.sh --force
cd ../../
mkdir -p cmake-build
Expand All @@ -58,7 +58,7 @@ jobs:

generate-docs:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

# Don't generate docs on dev branch
if: github.ref == 'refs/heads/main'
Expand Down
2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 26 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)

# Set the project name and the languages
project(MaxOS C CXX ASM)
PROJECT(MaxOS C CXX ASM)

# Logs the compiler commands
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# don't enable runtime type information
set(CMAKE_SKIP_RPATH TRUE)
SET(CMAKE_SKIP_RPATH TRUE)

# Set the standard to C++20
SET(CMAKE_CXX_STANDARD 20)
Expand All @@ -22,19 +22,37 @@ LINK_DIRECTORIES(${TOOLCHAIN_ROOT_DIR}/${TOOLCHAIN_PLATFORM}/lib/)

# DEBUG / PROD
IF(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
ENDIF()

## Set flags based on build type
# Set flags based on build type
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DTARGET_DEBUG)
ADD_DEFINITIONS(-DTARGET_DEBUG)
ENDIF()

# Function to make a library easier
function(MAKE_LIBRARY LIBNAME)

# TODO: ADD_DEPENDENCIES(${LIBNAME} libc) (& for static)

# Install dynamic library
ADD_LIBRARY(${LIBNAME} SHARED ${LIBRARY_SRCS})
TARGET_INCLUDE_DIRECTORIES(${LIBNAME} PUBLIC include)
INSTALL(TARGETS ${LIBNAME} LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/filesystem/os/lib)

# Install static library
ADD_LIBRARY(${LIBNAME}_static STATIC ${LIBRARY_SRCS})
TARGET_INCLUDE_DIRECTORIES(${LIBNAME}_static PUBLIC include)
INSTALL(TARGETS ${LIBNAME}_static DESTINATION ${CMAKE_SOURCE_DIR}/filesystem/os/lib)

# TODO: Install headers onto fs

endfunction()

# Look to build in these directories
ADD_SUBDIRECTORY(kernel)
#ADD_SUBDIRECTORY(libraries)
ADD_SUBDIRECTORY(libraries)
ADD_SUBDIRECTORY(programs)
#ADD_SUBDIRECTORY(ports)

ADD_CUSTOM_TARGET(image
# Everything needs to be installed (compiled) before we can create the disk image
Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ This is the list of required packages to build the operating system from source.
* libisl-dev
* cmake
* telnet
* rsync

Linux:
```sh
Expand Down Expand Up @@ -194,7 +195,7 @@ No user usage so far (userland will be added in the future)

<!-- ROADMAP -->
## Roadmap

#### Core Kernel
- [x] Bootloader
- [x] GDT
- [x] IDT
Expand All @@ -210,27 +211,30 @@ No user usage so far (userland will be added in the future)
- [x] Paging
- [x] Userspace
- [x] IPC
- [ ] VFS
- [x] VFS
- [x] Loading ELF
- [ ] Multiple Cores Support (SMP & Scheduler)
- [ ] Userland GUI
- [ ] CLI
- [ ] Move drivers to userspace
- [ ] Move VFS to userspace
- [ ] Porting & Dynamically Linking Libc
- [ ] Move networking to userspace (& rewrite, fix)

#### Userland
- [ ] GUI
- [ ] Terminal
- [ ] Connect to Clion with SMB for files and GDB for debugging in userspace
- [ ] DOOM Port
- [ ] Self-hosted os
- [ ] GUI Framework
- [ ] App Framework & System Apps
- [ ] DOOM Port
- [ ] UserSpace Drivers
- [ ] Userspace Networking
- [ ] Connect to Clion with SMB for files and GDB for debugging in userspace
- [ ] Auto Updater & Image Builder (ISO Release)
- [ ] Store
- [ ] Security of some sort
- [ ] User Switching
- [ ] Real Hardware Support
- [ ] Pretty GUI
- [ ] Port NeoVim, Wakatime & Some hot reloader
- [ ] Create port of my 2048
- [ ] Own LibC
- [ ] Compatibility Layer(s)

See the [open issues](https://github.com/maxtyson123/MaxOS/issues) for a full list of proposed features (and known issues).

Expand Down
4 changes: 4 additions & 0 deletions docs/Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ These are my notes relative to various parts of the OS

<!-- TOC end -->

NOTE TO SELF: FUNC AS VARIABLE: auto func_name = [&](uint32_t p) {
// Code
};

<!-- TOC --><a name="hardware-communication"></a>
# Hardware Communication
Here are some notes on how the communication with hardware works, this is used for the keyboard and mouse communication and setting up other devices, e.g. GPU
Expand Down
8 changes: 8 additions & 0 deletions docs/Styles/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BasedOnStyle: LLVM
IndentWidth: 2
ContinuationIndentWidth: 2
BreakConstructorInitializers: AfterColon
ConstructorInitializerIndentWidth: 2
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowShortFunctionsOnASingleLine: None
ColumnLimit: 0
28 changes: 14 additions & 14 deletions docs/Syscalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ This is helpful for updating syscall table (I don't know if that will even happe
| rax | rdi | rsi | rdx | r10 | r8 | r9 |

## Syscall Table (v1)
| Number | Name | Description | Arg0 | Arg1 | Arg2 | Arg3 | Arg4 | Arg5 | Return |
|--------|-----------------------|---------------------------------|----------------------------------------|------------|-------------|------|------|------|------------------------------------------------|
| 0 | close_process | Exit a process | uint64_t pid (= 0 for current process) | int status | | | | | |
| 1 | klog | Log a message to the kernel log | char* msg | | | | | | |
| 2 | created_shared_memory | Create a shared memory region | size_t size | char* name | | | | | void* address (null if failed) |
| 3 | open_shared_memory | Open a shared memory region | char* name | | | | | | void* address (null if failed) |
| 4 | allocate_memory | Allocate memory | size_t size | | | | | | void* address (null if failed) |
| 5 | free_memory | Free memory | void* address | | | | | | |
| 6 | create_ipc_endpoint | Create an IPC endpoint | char* name | | | | | | void* message buffer address (null if failed) |
| 7 | send_ipc_message | Send an IPC message | char* name | void* data | size_t size | | | | |
| 8 | remove_ipc_endpoint | Remove an IPC endpoint | char* name | | | | | | |
| 9 | thread_yield | Yield the current thread | | | | | | | |
| 10 | thread_sleep | Put the current thread to sleep | uint64_t time (ms) | | | | | | |
| 11 | thread_exit | Exit the current thread | | | | | | | |
| Number | Name | Description | Arg0 | Arg1 | Arg2 | Arg3 | Arg4 | Arg5 | Return |
|--------|-----------------|---------------------------------|----------------------------------------|--------------|--------------|--------------|------|------|---------------------------------------|
| 0 | close_process | Exit a process | uint64_t pid (= 0 for current process) | int status | | | | | |
| 1 | klog | Log a message to the kernel log | char* msg | | | | | | |
| 2 | allocate_memory | Allocate memory | size_t size | | | | | | void* address (null if failed) |
| 3 | free_memory | Free memory | void* address | | | | | | |
| 4 | resource_create | Create a resource | ResourceType type | char* name | size_t flags | | | | int success (1 = success, 0 = failed) |
| 5 | resource_open | Open a resource | ResourceType type | char* name | size_t flags | | | | uint64_t handle (0 if failed) |
| 6 | resource_close | Close a resource | uint64_t handle | size_t flags | | | | | |
| 7 | resource_write | Write to a resource | uint64_t handle | void* buffer | size_t size | size_t flags | | | size_t bytes written (0 if failed) |
| 8 | resource_read | Read from a resource | uint64_t handle | void* buffer | size_t size | size_t flags | | | size_t bytes read (0 if failed) |
| 9 | thread_yield | Yield the current thread | | | | | | | |
| 10 | thread_sleep | Put the current thread to sleep | uint64_t time (ms) | | | | | | |
| 11 | thread_exit | Exit the current thread | | | | | | | |
4 changes: 2 additions & 2 deletions filesystem/boot/grub/grub.cfg
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ menuentry "Max OS" {
echo "Loading Kernel..."
multiboot2 /boot/MaxOSk64
echo "Loading Test Elf..."
module2 /boot/test.elf Receiver
module2 /boot/test1.elf Sender
module2 /boot/test.elf File
module2 /boot/test1.elf Folder
boot
}
File renamed without changes.
1 change: 1 addition & 0 deletions filesystem/test/longfilename.extension
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test data to read
Empty file modified filesystem/user/.gitkeep
100644 → 100755
Empty file.
29 changes: 17 additions & 12 deletions kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,30 @@ SET_SOURCE_FILES_PROPERTIES(${ASM_SRCS} PROPERTIES LANGUAGE ASM)
# Find all the cpp and s files in the src directory (recursive)
FILE(GLOB_RECURSE KERNEL_SRCS src/*.cpp src/*.s)

# Create the kernel
ADD_EXECUTABLE(MaxOSk64 ${KERNEL_SRCS})
TARGET_COMPILE_DEFINITIONS(MaxOSk64 PUBLIC MAXOS_KERNEL)

# Update the version before building
SET(VERSION_HEADER "${CMAKE_SOURCE_DIR}/kernel/include/common/version.h")
SET(VERSION_HEADER_TMP "${CMAKE_SOURCE_DIR}/kernel/include/common/version.h.tmp")
SET(POST_PROCESS_SCRIPT "${CMAKE_SOURCE_DIR}/toolchain/pre_process/run.sh")
ADD_CUSTOM_COMMAND(
COMMENT "post_processing kernel"
TARGET MaxOSk64
PRE_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/toolchain/post_process/run.sh
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/kernel/include/common/version.h.tmp ${CMAKE_SOURCE_DIR}/kernel/include/common/version.h
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_SOURCE_DIR}/kernel/include/common/version.h.tmp
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT "${VERSION_HEADER}"
COMMAND "${POST_PROCESS_SCRIPT}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${VERSION_HEADER_TMP}" "${VERSION_HEADER}"
COMMAND ${CMAKE_COMMAND} -E remove "${VERSION_HEADER_TMP}"
DEPENDS ${KERNEL_SRCS}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Regenerating version.h because kernel sources changed"
)
ADD_CUSTOM_TARGET(VersionScript DEPENDS "${VERSION_HEADER}")

# Create the kernel
ADD_EXECUTABLE(MaxOSk64 ${KERNEL_SRCS} ${VERSION_HEADER})
ADD_DEPENDENCIES(MaxOSk64 VersionScript)
TARGET_COMPILE_DEFINITIONS(MaxOSk64 PUBLIC MAXOS_KERNEL)

# Linker
SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/kernel/src/linker.ld)
SET_TARGET_PROPERTIES(MaxOSk64 PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
TARGET_LINK_LIBRARIES(MaxOSk64 gcc)
TARGET_LINK_LIBRARIES(MaxOSk64 PRIVATE gcc syscore_static)
TARGET_LINK_OPTIONS(MaxOSk64 PRIVATE -T ${LINKER_SCRIPT} -nostdlib -n)

# Set the include directories
Expand Down
73 changes: 73 additions & 0 deletions kernel/include/common/buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// Created by 98max on 30/07/2025.
//

#ifndef MAXOS_COMMON_BUFFER_H
#define MAXOS_COMMON_BUFFER_H

#include <stdint.h>
#include <stddef.h>
#include <memory/memoryIO.h>
#include <common/logger.h>

namespace MaxOS{

namespace common{

/**
* @class Buffer
* @brief Wrapper class for a region of bytes in memor in an attempt to add some memory safety. Automatically
* allocates the size specified and frees it once done, adds boundary to I/O.
*/
class Buffer{

private:
uint8_t* m_bytes = nullptr;
size_t m_capacity;
bool m_dont_delete = false;

size_t m_offset = 0;

public:
Buffer(size_t size, bool update_offset = true);
Buffer(void* source, size_t size, bool update_offset = true);
~Buffer();

[[nodiscard]] uint8_t* raw() const;

void clear();
void full(uint8_t byte, size_t offset = 0, size_t amount = 0);

bool update_offset = true;
void set_offset(size_t offset);

[[nodiscard]] size_t capacity() const;
void resize(size_t size);

void write(uint8_t byte);
void write(size_t offset, uint8_t byte);
uint8_t read();
uint8_t read(size_t offset);

void copy_from(const Buffer* buffer);
void copy_from(const Buffer* buffer, size_t length);
void copy_from(const Buffer* buffer, size_t length, size_t offset);
void copy_from(const Buffer* buffer, size_t length, size_t offset, size_t offset_other);
void copy_from(const void* source, size_t length);
void copy_from(const void* source, size_t length, size_t offset);

void copy_to(Buffer* buffer);
void copy_to(Buffer* buffer, size_t length);
void copy_to(Buffer* buffer, size_t length, size_t offset);
void copy_to(Buffer* buffer, size_t length, size_t offset, size_t offset_other);
void copy_to(void* destination, size_t length);
void copy_to(void* destination, size_t length, size_t offset);
};

typedef Buffer buffer_t;

}

}

#endif //MAXOS_COMMON_BUFFER_H
5 changes: 5 additions & 0 deletions kernel/include/common/eventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include <stdint.h>
#include <common/vector.h>



// TODO: - Event doesnt need to be a class should be a struct
// - With moving to micro kernel this should be moved to a external lib as not needed in the kernel

namespace MaxOS{

namespace common{
Expand Down
16 changes: 13 additions & 3 deletions kernel/include/common/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <common/outputStream.h>
#include <common/colour.h>
#include <common/version.h>



Expand Down Expand Up @@ -40,7 +39,7 @@
bool m_log_writers_enabled[m_max_log_writers] = {false, false, false, false, false};

// Progress bar
static const uint8_t s_progress_total = 25;
static inline uint8_t s_progress_total = 100;
uint8_t m_progress_current = 0;

static inline Logger* s_active_logger = nullptr;
Expand All @@ -58,7 +57,6 @@
void set_log_level(LogLevel log_level);

void write_char(char c) final;
void lineFeed() final;
void printf(const char* format, ...);

static void ASSERT(bool condition, const char* message, ...);
Expand All @@ -77,5 +75,17 @@
Logger& operator << (LogLevel log_level);
};

/**
* @brief If the specified condition is not met then the kernel will crash with the specified message.
*
* This macro wraps Logger::ASSERT and supports printf-style formatting with variadic arguments.
*
* @param condition The condition to check.
* @param format The format string (like printf).
* @param ... Additional arguments to format.
*
* @see Logger::ASSERT
*/
#define ASSERT(condition, format, ...) Logger::ASSERT(condition, format, ##__VA_ARGS__)

#endif // MAXOS_COMMON_LOGGER_H
Loading