Compare commits
2 Commits
e82392e9d9
...
new-toolch
| Author | SHA1 | Date | |
|---|---|---|---|
|
a4acfeceee
|
|||
| 2522492835 |
5
CMakeLists.txt
Normal file
5
CMakeLists.txt
Normal 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
14
CoreLib/CMakeLists.txt
Normal 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
13
kernel/CMakeLists.txt
Normal 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}")
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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,18 +22,13 @@ 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.
|
||||
*/
|
||||
if (CHECK_FLAG(mbi->flags, 6))
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
// Calculate total memory size
|
||||
uint32_t RAM_size = 0;
|
||||
for(
|
||||
@@ -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
17
toolchain-i686-elf.cmake
Normal 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")
|
||||
|
||||
Reference in New Issue
Block a user