From 1bfc1532365a03f70792c33317974a0684259f1c Mon Sep 17 00:00:00 2001 From: Daniel Oertwig Date: Mon, 5 Oct 2009 00:40:46 +0200 Subject: [PATCH] Changed memory layout. New macro to simplify changing sections. --- inc/types.h | 2 ++ src/linkerscript.ld | 10 ++++------ src/main/main.c | 2 +- src/multitasking/multitasking.c | 8 +++----- src/paging/paging_init.c | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/inc/types.h b/inc/types.h index 61454a9..11b7be6 100644 --- a/inc/types.h +++ b/inc/types.h @@ -3,6 +3,8 @@ #ifndef __KERNEL__TYPES___HEADER____ #define __KERNEL__TYPES___HEADER____ +/* used to simplify changing section */ +#define INTO_SECTION(obj,sec) obj __attribute__ ((section(sec))); obj /* integers */ diff --git a/src/linkerscript.ld b/src/linkerscript.ld index 4a810f4..6669f86 100755 --- a/src/linkerscript.ld +++ b/src/linkerscript.ld @@ -8,9 +8,12 @@ SECTIONS .boot : { *(.boot) + *(.setup) + *(.setup_data) } + __EndOfStartupCode = .; - .text : + .text ALIGN(4096): { *(.text) } @@ -25,11 +28,6 @@ SECTIONS { *(.bss) } - .tasker : - { - *(.tasker) - *(.tasker_data) - } __RealStartOfLinkedMemory = ALIGN(4096); . = 0xFFC00000; __StartOfLinkedMemory = .; diff --git a/src/main/main.c b/src/main/main.c index 51580b3..3d0b935 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -22,7 +22,7 @@ By Daniel Oertwig /* startup routine */ -void c_main (UINT eax, UINT* ebx, UINT esp) +INTO_SECTION(void c_main (UINT eax, UINT* ebx, UINT esp),".setup") { UINT memsize_kbytes = 0; UINT *mmap_add; diff --git a/src/multitasking/multitasking.c b/src/multitasking/multitasking.c index c74a205..4843659 100644 --- a/src/multitasking/multitasking.c +++ b/src/multitasking/multitasking.c @@ -8,11 +8,10 @@ #include "gdt.h" /** Global variables **/ -Task *currentTask; +INTO_SECTION(Task *currentTask,".klinked_data"); const UINT16 mt_KERNELSTACKSIZE = 0x1000; - /** Functions used by the taskmanager **/ Task *CreateTask(UINT eip, UINT cr3) { @@ -49,7 +48,7 @@ Task *CreateTask(UINT eip, UINT cr3) /** Setting up multitasking **/ -void InitMultitasking() +INTO_SECTION(void InitMultitasking(),".setup") { currentTask = (Task*)kalloc(sizeof(Task),0); asm volatile ("mov %%cr3, %0": "=r"(currentTask->cr3)); @@ -60,8 +59,7 @@ void InitMultitasking() /** Code to switch tasks **/ -UINT SwitchTask(struct irq_regs *r) __attribute__ (( section(".klinked"))); -UINT SwitchTask(struct irq_regs *r) +INTO_SECTION(UINT SwitchTask(struct irq_regs *r),".klinked") { currentTask->esp = (UINT)r; currentTask = currentTask->next; diff --git a/src/paging/paging_init.c b/src/paging/paging_init.c index e0b1b36..f533dfe 100644 --- a/src/paging/paging_init.c +++ b/src/paging/paging_init.c @@ -26,7 +26,7 @@ pg_PageTab *linkedDirectory; const UINT KPC_START = 0xFFFFD000; /** Setting up paging **/ -void InitPaging () +INTO_SECTION(void InitPaging (),".setup") { pg_PageTab *kdir; UINT StartOfLinkedMemory = (UINT)&__StartOfLinkedMemory; -- 2.11.4.GIT