diff --git a/Makefile b/Makefile index a2145bb..f600141 100644 --- a/Makefile +++ b/Makefile @@ -125,16 +125,20 @@ $(KOBJDIR)/prog.o: $(KERNELDIR)/extras/prog.c $(KERNELDIR)/include/*/*.h # 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 $(KOBJDIR)/kernel/map.o \ - $(KOBJDIR)/kernel/heap.o $(KOBJDIR)/kernel/malloc.o \ - $(KOBJDIR)/kernel/buf.o $(KOBJDIR)/kernel/sched.o \ - $(KOBJDIR)/kernel/bput.o $(KOBJDIR)/kernel/bprint.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/heap.o $(KOBJDIR)/kernel/malloc.o \ + $(KOBJDIR)/kernel/buf.o $(KOBJDIR)/kernel/sched.o \ + $(KOBJDIR)/kernel/bput.o $(KOBJDIR)/kernel/bprint.o \ + $(KOBJDIR)/kernel/gdt.o $(KOBJDIR)/kernel/gdt.o $(KOBJDIR)/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c $(KERNELDIR)/include/*/*.h @$(KCC) $< -o $@ @echo ${CL2}[$@] ${CL}Compiled.${CL3} +$(KOBJDIR)/kernel/idt.o: $(KERNELDIR)/kernel/cpu/idt.c $(KERNELDIR)/include/*/*.h + @$(KCC) $< -o $@ + @echo ${CL2}[$@] ${CL}Compiled.${CL3} $(KOBJDIR)/kernel/init.o: $(KERNELDIR)/kernel/init/init.c $(KERNELDIR)/include/*/*.h @$(KCC) $< -o $@ @echo ${CL2}[$@] ${CL}Compiled.${CL3} @@ -161,6 +165,8 @@ $(KOBJDIR)/kernel/heap.o: $(KERNELDIR)/kernel/mm/heap.c $(KERNELDIR)/include/*/* @echo ${CL2}[$@] ${CL}Compiled.${CL3} $(KOBJDIR)/kernel/malloc.o: $(KERNELDIR)/kernel/mm/malloc.c $(KERNELDIR)/include/*/*.h @$(KCC) $< -o $@ +$(KOBJDIR)/kernel/gdt.o: $(KERNELDIR)/kernel/mm/gdt.c $(KERNELDIR)/include/*/*.h + @$(KCC) $< -o $@ @echo ${CL2}[$@] ${CL}Compiled.${CL3} $(KOBJDIR)/kernel/buf.o: $(KERNELDIR)/kernel/buf/buf.c $(KERNELDIR)/include/*/*.h @$(KCC) $< -o $@ diff --git a/ProjectTree b/ProjectTree index 6d8caf3..7b44cd4 100644 --- a/ProjectTree +++ b/ProjectTree @@ -61,6 +61,7 @@ │   │   │   ├── buf.o │   │   │   ├── cpuid.o │   │   │   ├── cursor.o +│   │   │   ├── gdt.o │   │   │   ├── heap.o │   │   │   ├── init.o │   │   │   ├── malloc.o @@ -151,10 +152,10 @@ │   ├── ke │   │   └── panic.c │   ├── mm +│   │   ├── gdt.c │   │   ├── heap.c │   │   ├── malloc.c -│   │   ├── map.c -│   │   └── stack.c +│   │   └── map.c │   └── proc │   ├── Makefile │   └── sched.c @@ -169,4 +170,4 @@ ├── qemu.log └── Readme.md -28 directories, 116 files +28 directories, 117 files diff --git a/kaleid/include/kernel/mm.h b/kaleid/include/kernel/mm.h index 9fc07e1..e0da6fc 100644 --- a/kaleid/include/kernel/mm.h +++ b/kaleid/include/kernel/mm.h @@ -37,6 +37,8 @@ typedef struct MemoryMap_t MemoryMap_t; typedef struct MapEntry_t MapEntry_t; +typedef struct GdtEntry_t GdtEntry_t; +typedef struct GdtPtr_t GdtPtr_t; // -------------------------------------------------------------------------- // // The entry structure of the map @@ -54,7 +56,23 @@ struct MemoryMap_t { MapEntry_t entry[MAX_ENTRIES]; } __attribute__((__packed__)); +// The gdt +struct GdtEntry_t +{ + ushort lowLimit; // lower 16 bits + ushort lowBase; // lower 16 bits + uchar middleBase; // next 8 bits + uchar access; // determine what ring this segment can be used in + uchar granularity; + uchar highBase; // last 8 bits +} __attribute__((packed)); +struct GdtPtr_t +{ + uchar limit; // upper 16 bits + ushort base; // address of the first entry +} + __attribute__((packed)); // -------------------------------------------------------------------------- // @@ -71,6 +89,11 @@ size_t MmGetAvailZoneSize(void *start); // // Returns the first available memory zone from the start address pointer +// void *MmGetFirstAvailZone(void *start); +// +// Initialize the descriptor table +// +void MmInitGdt(void); // -------------------------------------------------------------------------- // diff --git a/kaleid/kernel/cpu/idt.c b/kaleid/kernel/cpu/idt.c index ae3c860..469796c 100644 --- a/kaleid/kernel/cpu/idt.c +++ b/kaleid/kernel/cpu/idt.c @@ -28,6 +28,7 @@ // static inline void lidt(void* idtAddr, ushort size) { + // The IDTR register structure that will be sent struct { ushort length; void* base; diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 09456e8..1494a13 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -150,6 +150,12 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic) //if(rc)KernLog("error\n"); //KernLog((char*)buf->buf); + uchar *addr = (uchar *)(ullong)(1024*MB - 1); + + KernLog("Test, valeur autour de %p: %hhu\n", addr, *addr); + *addr = 1; + KernLog("Test, valeur autour de %p: %hhu\n", addr, *addr); + // We're out PsFiniSched(); KeCrashSystem(); //yay diff --git a/kaleid/kernel/mm/stack.c b/kaleid/kernel/mm/stack.c deleted file mode 100644 index 2bb1aaf..0000000 --- a/kaleid/kernel/mm/stack.c +++ /dev/null @@ -1,23 +0,0 @@ -//----------------------------------------------------------------------------// -// GNU GPL OS/K // -// // -// Desc: Mapping and checking memory related functions // -// // -// // -// Copyright © 2018-2019 The OS/K Team // -// // -// This file is part of OS/K. // -// // -// OS/K is free software: you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation, either version 3 of the License, or // -// any later version. // -// // -// OS/K is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY//without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with OS/K. If not, see . // -//----------------------------------------------------------------------------//