From 9b856ae4d7ad3dafc5cc6eac9194ff3803965d94 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 20 Jul 2015 16:34:46 +0400 Subject: [PATCH] Switch to cpp --- Readme.md | 4 ++-- kernel/GDT/Makefile | 5 +++++ kernel/GDT/gdt.cpp | 11 ++++++++++ kernel/GDT/gdt.h | 22 ------------------- kernel/GDT/gdt.hpp | 33 +++++++++++++++++++++++++++++ kernel/Makefile | 11 ++++++---- kernel/Types/{types.h => types.hpp} | 0 kernel/{main.c => main.cpp} | 6 ++++-- 8 files changed, 62 insertions(+), 30 deletions(-) create mode 100644 kernel/GDT/Makefile create mode 100644 kernel/GDT/gdt.cpp delete mode 100644 kernel/GDT/gdt.h create mode 100644 kernel/GDT/gdt.hpp rename kernel/Types/{types.h => types.hpp} (100%) rename kernel/{main.c => main.cpp} (51%) diff --git a/Readme.md b/Readme.md index 42bd89b..19fdfd1 100644 --- a/Readme.md +++ b/Readme.md @@ -7,13 +7,13 @@ ##Programmers Zone -> Langages utilisés: nasm, C, AT&T ... +> Langages utilisés: nasm, C++, AT&T ... ##Utilitaires requis pour la compilation > Shell Unix (avec dd, cp etc...)
> Make
-> GCC, ld etc...
+> G++, ld etc...
> Nasm ##Comment utilisé le Noyaux Générer ? diff --git a/kernel/GDT/Makefile b/kernel/GDT/Makefile new file mode 100644 index 0000000..6e1b2c8 --- /dev/null +++ b/kernel/GDT/Makefile @@ -0,0 +1,5 @@ +gdt.o: gdt.cpp + g++ -m32 -c -o gdt.o gdt.cpp + +clean: + rm *.o diff --git a/kernel/GDT/gdt.cpp b/kernel/GDT/gdt.cpp new file mode 100644 index 0000000..5aa8065 --- /dev/null +++ b/kernel/GDT/gdt.cpp @@ -0,0 +1,11 @@ +#include "gdt.hpp" +#include "../Types/types.hpp" + + +void initGdtDesc(u32 base, u32 limit, u8 type, u8 param, gdtDescriptorStruct *descriptor){ + +} + + +void initGdt(){ +} diff --git a/kernel/GDT/gdt.h b/kernel/GDT/gdt.h deleted file mode 100644 index 3df5698..0000000 --- a/kernel/GDT/gdt.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __GDT__ -#define __GDT__ - -#include "../Types/types.h" - -struct gdtPointer{ - u16 size; - u32 segment; -} __attribute__ ((packed)); - -struct gdtDescriptor{ - u16 limit1; - u16 base1; - u8 base2; - u8 type : 4; - u8 param1 : 4; - u8 limit2 : 4; - u8 param2 : 4; - u8 base3; -} __attribute__ ((packed)); - -#endif diff --git a/kernel/GDT/gdt.hpp b/kernel/GDT/gdt.hpp new file mode 100644 index 0000000..4b16886 --- /dev/null +++ b/kernel/GDT/gdt.hpp @@ -0,0 +1,33 @@ +#ifndef __GDT__ +#define __GDT__ + +#include "../Types/types.hpp" + +//Define GDT pointer +struct gdtPointerStruct{ + u16 size; + u32 segment; +} __attribute__ ((packed)); + +//Define GDT descriptor +struct gdtDescriptorStruct{ + u16 limit1; + u16 base1; + u8 base2; + u8 type : 4; + u8 param1 : 4; + u8 limit2 : 4; + u8 param2 : 4; + u8 base3; +} __attribute__ ((packed)); + + +//Typedef : +typedef struct gdtPointerStruct gdtPointerStruct; +typedef struct gdtDescriptorStruct gdtDescriptorStruct; + +//Functions : +void initGdtDesc(u32 base, u32 limit, u8 type, u8 param, gdtDescriptorStruct *descriptor); +void initGdt(); + +#endif diff --git a/kernel/Makefile b/kernel/Makefile index 8b0c1bf..c366b55 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,12 +1,15 @@ -kernel.bin:entry.o main.o +kernel.bin:entry.o main.o GDT/gdt.o ld -m elf_i386 --entry=_start -Ttext=0x100000 -o $@ $^ entry.o:entry.asm nasm -f elf $^ -main.o:main.c - gcc -m32 -c $^ -o $@ +main.o:main.cpp + g++ -Wall -m32 -c $^ -o $@ +GDT/gdt.o: + cd GDT && make clean: + cd ./GDT/ && make clean rm ./*.o - rm kernel.bin + rm ./kernel.bin diff --git a/kernel/Types/types.h b/kernel/Types/types.hpp similarity index 100% rename from kernel/Types/types.h rename to kernel/Types/types.hpp diff --git a/kernel/main.c b/kernel/main.cpp similarity index 51% rename from kernel/main.c rename to kernel/main.cpp index e0e9ebf..af5f048 100644 --- a/kernel/main.c +++ b/kernel/main.cpp @@ -1,8 +1,10 @@ - +#include "GDT/gdt.hpp" //----- PiegOS kernel main ----- -void main(){ +int main(){ while(1); + + return 0; }