From 918c4f1b2e3fea6dc419ef6edf9772d8711d95ae Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 18 Mar 2019 17:43:41 +0100 Subject: [PATCH] Memory struct --- Makefile | 11 +++++++---- kaleid/include/kernel/base.h | 9 ++++++++- kaleid/include/kernel/mm.h | 17 +++++++++++++++++ kaleid/kernel/init/init.c | 29 +++++++++-------------------- kaleid/kernel/init/table.c | 2 ++ kaleid/kernel/mm/.placeholder | 0 6 files changed, 43 insertions(+), 25 deletions(-) delete mode 100644 kaleid/kernel/mm/.placeholder diff --git a/Makefile b/Makefile index eddffe6..7b7667c 100644 --- a/Makefile +++ b/Makefile @@ -124,10 +124,10 @@ $(KOBJDIR)/prog.o: $(KERNELDIR)/extras/prog.c @echo ${CL2}[$@] ${CL}Compiled.${CL3} # Kernel objects -kal_kern_obj= $(KOBJDIR)/kernel/cpuid.o $(KOBJDIR)/kernel/init.o \ - $(KOBJDIR)/kernel/table.o $(KOBJDIR)/kernel/cursor.o \ - $(KOBJDIR)/kernel/term.o $(KOBJDIR)/kernel/vga.o \ - $(KOBJDIR)/kernel/panic.o +kal_kern_obj= $(KOBJDIR)/kernel/cpuid.o $(KOBJDIR)/kernel/init.o \ + $(KOBJDIR)/kernel/table.o $(KOBJDIR)/kernel/cursor.o \ + $(KOBJDIR)/kernel/term.o $(KOBJDIR)/kernel/vga.o \ + $(KOBJDIR)/kernel/panic.o $(KOBJDIR)/kernel/map.o \ $(KOBJDIR)/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c @$(KCC) $< -o $@ @@ -150,6 +150,9 @@ $(KOBJDIR)/kernel/vga.o: $(KERNELDIR)/kernel/io/vga.c $(KOBJDIR)/kernel/panic.o: $(KERNELDIR)/kernel/ke/panic.c @$(KCC) $< -o $@ @echo ${CL2}[$@] ${CL}Compiled.${CL3} +$(KOBJDIR)/kernel/map.o: $(KERNELDIR)/kernel/mm/map.c + @$(KCC) $< -o $@ + @echo ${CL2}[$@] ${CL}Compiled.${CL3} ## MISC MAKEFILE ------------------------------------------------------------- # ./ProjectTree: ./.stylehlp_sh diff --git a/kaleid/include/kernel/base.h b/kaleid/include/kernel/base.h index cb5a160..81b9947 100644 --- a/kaleid/include/kernel/base.h +++ b/kaleid/include/kernel/base.h @@ -42,6 +42,7 @@ typedef struct Terminal_t Terminal_t; typedef struct ListHead_t ListHead_t; typedef struct ListNode_t ListNode_t; typedef struct Processor_t Processor_t; +typedef struct MemoryMap_t MemoryMap_t; typedef enum ProcState_t ProcState_t; typedef enum TermColor_t TermColor_t; @@ -96,11 +97,17 @@ struct Processor_t ListHead_t *timeCritProcs; }; +struct MemoryMap_t +{ + void *addr; + int length; +}; + //------------------------------------------// extern int cpuCount; extern Processor_t cpuTable[NCPUS]; - +extern MemoryMap_t memTab; //------------------------------------------// #define DEC_PER_CPU(name, field, type) \ diff --git a/kaleid/include/kernel/mm.h b/kaleid/include/kernel/mm.h index 95971fe..e7fe5ff 100644 --- a/kaleid/include/kernel/mm.h +++ b/kaleid/include/kernel/mm.h @@ -21,3 +21,20 @@ // You should have received a copy of the GNU General Public License // // along with OS/K. If not, see . // //----------------------------------------------------------------------------// + +#include +#include + +#define GetCurMemMap() (memTab) + +// +// Returns a pointer to the first entry of the memory map +// +multiboot_memory_map_t *GetMemoryMap(void); + +// +// Initializes the memory map structure +// +void InitMemoryMap(multiboot_info_t *mbInfo); + +// -------------------------------------------------------------------------- // diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index ef857cf..9cdddf1 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -24,9 +24,7 @@ #include #include #include - - -extern void testf(void); +#include // // Entry point of the Kaleid kernel @@ -39,21 +37,12 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) // Kernel terminals InitTerms(); - // We're out - StartPanic( "We were loaded by : %s\n\n\n" - "We get\n" - " *mbInfo : %p\n" - " mbMagic : %x\n" - " mbBootdrv : %x\n" - " *mbMmap : %p\n" - " `-length : %d\n" - "\nGoodbye World :(", + //Memory mapping + InitMemoryMap(mbInfo); - mbInfo->boot_loader_name, - mbInfo, - mbMagic, - mbInfo->boot_device, - mbInfo->mmap_addr, - mbInfo->mmap_length - ); -} + KernLog("InitMemoryMap : %p, %x\n", GetCurMemMap().addr, GetCurMemMap().length ); + + // We're out + KernLog("Yup, we have magic : %x", mbMagic); + CrashSystem(); //yay +} diff --git a/kaleid/kernel/init/table.c b/kaleid/kernel/init/table.c index 7a51088..5bf80d8 100644 --- a/kaleid/kernel/init/table.c +++ b/kaleid/kernel/init/table.c @@ -27,5 +27,7 @@ int cpuCount = 1; Processor_t cpuTable[NCPUS] = {0}; +MemoryMap_t memTab = {0}; + Terminal_t *stdOut = 0, *stdDbg = 0; diff --git a/kaleid/kernel/mm/.placeholder b/kaleid/kernel/mm/.placeholder deleted file mode 100644 index e69de29..0000000