2 Commits

Author SHA1 Message Date
a4acfeceee Starting and testing cmake as a toolchain 2025-12-02 17:22:01 +01:00
2522492835 Couple of small changes
* Commented out the map page function call to handle page not present
* Mapped the ACPI_RECLAIMABLE_MEMORY
* Set VBE to false when VBE is not initialized by the bootloader
2023-10-28 20:42:28 +02:00
6 changed files with 57 additions and 12 deletions

5
CMakeLists.txt Normal file
View File

@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(BarinkOS LANGUAGES C CXX ASM)
add_subdirectory(CoreLib)
add_subdirectory(Kernel)

14
CoreLib/CMakeLists.txt Normal file
View File

@@ -0,0 +1,14 @@
project(CoreLib LANGUAGES CXX)
set(SOURCES
ctype.cpp
Memory.cpp
Path.cpp
Stack.cpp
String.cpp
StringView.cpp
)
add_library(CoreLib STATIC ${SOURCES})
target_include_directories(CoreLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

13
kernel/CMakeLists.txt Normal file
View File

@@ -0,0 +1,13 @@
project(Kernel LANGUAGES C CXX ASM)
set(SOURCES
main.cpp
boot.s
)
add_executable(kernel.elf ${SOURCES})
target_link_libraries(kernel.elf PRIVATE CoreLib)
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/link.ld)
target_link_options(kernel.elf PRIVATE "-T${LINKER_SCRIPT}")

View File

@@ -191,7 +191,7 @@ void irs_handler (registers* regs) {
printf("* Page protection violation!\n");
} else{
printf("* Page not-present!\n");
Immediate_Map(FaultingAddress, FaultingAddress - 0xC0000000);
//Immediate_Map(FaultingAddress, FaultingAddress);
}

View File

@@ -2,6 +2,8 @@
#include <stddef.h>
#include "multiboot.h"
#include "../memory/PhysicalMemoryManager.h"
#include "../memory/VirtualMemoryManager.h"
#include "../acpi/acpi.h"
#define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit)))
#define VADDR_TO_PADDR(vaddr) (vaddr - 0xC0000000)
@@ -10,7 +12,6 @@ BootInfoBlock* BIB;
extern "C" void prekernelSetup ( unsigned long magic, multiboot_info_t* mbi)
{
/*
* Check Multiboot magic number
*/
@@ -21,11 +22,6 @@ extern "C" void prekernelSetup ( unsigned long magic, multiboot_info_t* mbi)
}
mbi = PADDR_TO_VADDR(mbi);
// Setup the physical memory manager immmediatly
// Doing so saves the complications of doing it later when
// paging is enabled
/*
If we got a memory map from our bootloader we
should be parsing it to find out the memory regions available.
@@ -56,6 +52,8 @@ extern "C" void prekernelSetup ( unsigned long magic, multiboot_info_t* mbi)
deallocate_region(mmap->addr, mmap->len);
if(mmap->type == MULTIBOOT_MEMORY_ACPI_RECLAIMABLE)
allocate_region(mmap->addr, mmap->len);
// memory map
Immediate_Map(mmap->addr , mmap->addr);
if(mmap->type == MULTIBOOT_MEMORY_RESERVED)
allocate_region(mmap->addr, mmap->len);
if(mmap->type == MULTIBOOT_MEMORY_NVS)
@@ -99,8 +97,6 @@ extern "C" void prekernelSetup ( unsigned long magic, multiboot_info_t* mbi)
uint32_t i;
BIB->GrubModuleCount = mbi->mods_count;
for(i = 0, mod = (multiboot_module_t *) mbi->mods_addr; i < mbi->mods_count; i++ , mod++){
}
@@ -135,6 +131,6 @@ extern "C" void prekernelSetup ( unsigned long magic, multiboot_info_t* mbi)
// NOTE: Do something with it.. (Store it , process it etc...)
} else{
BIB->EnabledVBE;
BIB->EnabledVBE = false;
}
}

17
toolchain-i686-elf.cmake Normal file
View File

@@ -0,0 +1,17 @@
# toolchain-i686-elf.cmake
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR i686)
# Point to your custom cross tools
set(CMAKE_C_COMPILER /opt/cross/bin/i686-elf-gcc)
set(CMAKE_CXX_COMPILER /opt/cross/bin/i686-elf-g++)
set(CMAKE_ASM_COMPILER /opt/cross/bin/i686-elf-as)
set(CMAKE_AR /opt/cross/bin/i686-elf-ar)
set(CMAKE_RANLIB /opt/cross/bin/i686-elf-ranlib)
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
# Flags for freestanding OS development
set(CMAKE_C_FLAGS "-ffreestanding -Og -ggdb -Wall -Wextra")
set(CMAKE_CXX_FLAGS "-ffreestanding -Og -ggdb -Wall -Wextra")