From 5d3179d0e2c3915af65dedef0952672220ac4714 Mon Sep 17 00:00:00 2001 From: Alexey Gavrilov Date: Sat, 10 May 2025 16:04:55 +0700 Subject: Kheap section + metadata --- arch/SecondaryInit.cpp | 2 ++ arch/SecondaryInit.h | 2 ++ kernel/boot.s | 15 ++++++++++++--- kernel/linker.ld | 24 ++++++++++++++++++++---- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/arch/SecondaryInit.cpp b/arch/SecondaryInit.cpp index 900f84b..7eba61b 100644 --- a/arch/SecondaryInit.cpp +++ b/arch/SecondaryInit.cpp @@ -3,6 +3,8 @@ void SecondaryInitialization::processorInitialize() { PrimaryInitialization::processorInitialize(); + + Segments(); }; void SecondaryInitialization::devicesInitialize() diff --git a/arch/SecondaryInit.h b/arch/SecondaryInit.h index 795d96a..53ff191 100644 --- a/arch/SecondaryInit.h +++ b/arch/SecondaryInit.h @@ -1,4 +1,6 @@ #include +#include "../kernel/mem/Segments.h" +#include "../kernel/mem/Kheap.h" #if defined(__IAPC) #include "x86/PrimaryInit.h" diff --git a/kernel/boot.s b/kernel/boot.s index 798e7e3..534beb6 100644 --- a/kernel/boot.s +++ b/kernel/boot.s @@ -2,17 +2,19 @@ MBFLAGS equ 0 MAGIC equ 0x1BADB002 CHECKSUM equ -(MAGIC + MBFLAGS) -section .multiboot + section .multiboot align 4 dd MAGIC dd MBFLAGS dd CHECKSUM section .bss +resb 512 align 16 -resb 160 +; align 16 bytes according to the System V ABI standard +; Stack space stack_bottom: -resb 16384 +resb 16384 ; 16KiB stack_top: section .text @@ -25,3 +27,10 @@ _start: .hang: hlt jmp .hang .end: + +section .kheap +kheap_top: +; Kernel heap space +; Change this value together Kheap::size varibale (mem/Kheap.h file) +resb 4096 +kheap_bottom: diff --git a/kernel/linker.ld b/kernel/linker.ld index ae4d98d..abee596 100644 --- a/kernel/linker.ld +++ b/kernel/linker.ld @@ -6,28 +6,44 @@ SECTIONS .multiboot : { + _startMultiboot = .; *(.multiboot) + _endMultiboot = .; } + .text BLOCK(4K) : ALIGN(4K) { + _startText = .; *(.text) - *(.eh_frame) - *(.ctors) + _endText = .; } .rodata BLOCK(4K) : ALIGN(4k) { + _startRodata = .; *(.rodata) + _endRodata = .; } .data BLOCK(4K) : ALIGN(4K) { + _startData = .; *(.data) + _endData = .; } - .bss BLOCK(4K) : ALIGN(4K) + .bss BLOCK(16K) : ALIGN(16K) { - *(COMMON) + _startBss = .; *(.bss) + _endBss = .; } + + .kheap BLOCK(4k) : ALIGN(4k) + { + _startKheap = .; + *(.kheap) + _endKheap = .; + } + } -- cgit v1.2.3