This commit is contained in:
Adrien Bourmault 2019-03-26 17:50:03 +01:00
parent f67e1baa25
commit 669236cea1
6 changed files with 46 additions and 32 deletions

View File

@ -131,10 +131,14 @@ kal_kern_obj= $(KOBJDIR)/kernel/cpuid.o $(KOBJDIR)/kernel/init.o \
$(KOBJDIR)/kernel/heap.o $(KOBJDIR)/kernel/malloc.o \ $(KOBJDIR)/kernel/heap.o $(KOBJDIR)/kernel/malloc.o \
$(KOBJDIR)/kernel/buf.o $(KOBJDIR)/kernel/sched.o \ $(KOBJDIR)/kernel/buf.o $(KOBJDIR)/kernel/sched.o \
$(KOBJDIR)/kernel/bput.o $(KOBJDIR)/kernel/bprint.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 $(KOBJDIR)/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@ @$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3} @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 $(KOBJDIR)/kernel/init.o: $(KERNELDIR)/kernel/init/init.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@ @$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3} @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} @echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/malloc.o: $(KERNELDIR)/kernel/mm/malloc.c $(KERNELDIR)/include/*/*.h $(KOBJDIR)/kernel/malloc.o: $(KERNELDIR)/kernel/mm/malloc.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@ @$(KCC) $< -o $@
$(KOBJDIR)/kernel/gdt.o: $(KERNELDIR)/kernel/mm/gdt.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3} @echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/buf.o: $(KERNELDIR)/kernel/buf/buf.c $(KERNELDIR)/include/*/*.h $(KOBJDIR)/kernel/buf.o: $(KERNELDIR)/kernel/buf/buf.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@ @$(KCC) $< -o $@

View File

@ -61,6 +61,7 @@
│   │   │   ├── buf.o │   │   │   ├── buf.o
│   │   │   ├── cpuid.o │   │   │   ├── cpuid.o
│   │   │   ├── cursor.o │   │   │   ├── cursor.o
│   │   │   ├── gdt.o
│   │   │   ├── heap.o │   │   │   ├── heap.o
│   │   │   ├── init.o │   │   │   ├── init.o
│   │   │   ├── malloc.o │   │   │   ├── malloc.o
@ -151,10 +152,10 @@
│   ├── ke │   ├── ke
│   │   └── panic.c │   │   └── panic.c
│   ├── mm │   ├── mm
│   │   ├── gdt.c
│   │   ├── heap.c │   │   ├── heap.c
│   │   ├── malloc.c │   │   ├── malloc.c
│   │   ├── map.c │   │   └── map.c
│   │   └── stack.c
│   └── proc │   └── proc
│   ├── Makefile │   ├── Makefile
│   └── sched.c │   └── sched.c
@ -169,4 +170,4 @@
├── qemu.log ├── qemu.log
└── Readme.md └── Readme.md
28 directories, 116 files 28 directories, 117 files

View File

@ -37,6 +37,8 @@
typedef struct MemoryMap_t MemoryMap_t; typedef struct MemoryMap_t MemoryMap_t;
typedef struct MapEntry_t MapEntry_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 // The entry structure of the map
@ -54,7 +56,23 @@ struct MemoryMap_t {
MapEntry_t entry[MAX_ENTRIES]; MapEntry_t entry[MAX_ENTRIES];
} __attribute__((__packed__)); } __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 // Returns the first available memory zone from the start address pointer
//
void *MmGetFirstAvailZone(void *start); void *MmGetFirstAvailZone(void *start);
//
// Initialize the descriptor table
//
void MmInitGdt(void);
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //

View File

@ -28,6 +28,7 @@
// //
static inline void lidt(void* idtAddr, ushort size) static inline void lidt(void* idtAddr, ushort size)
{ {
// The IDTR register structure that will be sent
struct { struct {
ushort length; ushort length;
void* base; void* base;

View File

@ -150,6 +150,12 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic)
//if(rc)KernLog("error\n"); //if(rc)KernLog("error\n");
//KernLog((char*)buf->buf); //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 // We're out
PsFiniSched(); PsFiniSched();
KeCrashSystem(); //yay KeCrashSystem(); //yay

View File

@ -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 <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//