From cbcbf6e7d614ecf94dd7e1b9033f8d599f48662e Mon Sep 17 00:00:00 2001 From: Alexey Gavrilov Date: Thu, 22 Feb 2024 14:18:39 +0700 Subject: Implement support of cpuid instruction + include folder + some updates --- arch/x86/gdt/Gdt.cpp | 17 +++++++++++++++-- arch/x86/gdt/Gdt.h | 5 +++-- arch/x86/gdt/GlobalObj.cpp | 8 -------- arch/x86/gdt/GlobalObj.h | 3 ++- 4 files changed, 20 insertions(+), 13 deletions(-) (limited to 'arch/x86/gdt') diff --git a/arch/x86/gdt/Gdt.cpp b/arch/x86/gdt/Gdt.cpp index 63c70ef..88c7bbd 100755 --- a/arch/x86/gdt/Gdt.cpp +++ b/arch/x86/gdt/Gdt.cpp @@ -57,7 +57,7 @@ uint64 DescSeg32::flatDataUser() MngGdt::MngGdt() { - this->gdt[0] = 0; + gdt[0] = 0; currIdx = 1; isGdtLoaded = 0; }; @@ -82,7 +82,7 @@ bool MngGdt::loadGdt() uint64 pointer = 0; uint16 size = sizeof(uint64) * this->size - 1; - uint16 offset = (uint32)((void *)(&gdt)); + uint32 offset = (uint32)((void *)(&gdt)); pointer |= offset; pointer <<= 16; @@ -98,3 +98,16 @@ bool MngGdt::getIsGdtLoaded() { return isGdtLoaded; }; + +void MngGdt::operator=(const MngGdt& src) +{ + if(this->isGdtLoaded == 1 || src.isGdtLoaded == 1) + { + return; + } + + // Fix it. Write method to copy from ... to ... + for(int i = 0; i < this->size; i++) this->gdt[i] = src.gdt[i]; + this->isGdtLoaded = src.isGdtLoaded; + this->currIdx = src.currIdx; +}; diff --git a/arch/x86/gdt/Gdt.h b/arch/x86/gdt/Gdt.h index e3d48a3..a8d7dc2 100755 --- a/arch/x86/gdt/Gdt.h +++ b/arch/x86/gdt/Gdt.h @@ -1,7 +1,7 @@ #ifndef GDT_H #define GDT_H -#include "../inc/types.h" +#include // Define access options @@ -54,7 +54,7 @@ class DescSeg32 // Segment descriptor static uint64 flatDataKernel(); static uint64 flatCodeUser(); static uint64 flatDataUser(); -} __attribute__((packed)); +}; #ifdef __cplusplus extern "C" { @@ -74,6 +74,7 @@ class MngGdt public: MngGdt(); + void operator=(const MngGdt& src); bool addDescriptor(uint64 desc); // 0 - not set descriptor, 1 - set bool loadGdt(); // 0 - if GDT is not loaded, 1 - loaded bool getIsGdtLoaded(); diff --git a/arch/x86/gdt/GlobalObj.cpp b/arch/x86/gdt/GlobalObj.cpp index 5832c11..fbceeef 100644 --- a/arch/x86/gdt/GlobalObj.cpp +++ b/arch/x86/gdt/GlobalObj.cpp @@ -4,11 +4,3 @@ uint64 MngGdt::gdt[MngGdt::size]; MngGdt mngGdt; - -void mngGdtInit() -{ - if(!mngGdt.getIsGdtLoaded()) - { - mngGdt = MngGdt(); - } -}; diff --git a/arch/x86/gdt/GlobalObj.h b/arch/x86/gdt/GlobalObj.h index 563a2a9..3c62847 100644 --- a/arch/x86/gdt/GlobalObj.h +++ b/arch/x86/gdt/GlobalObj.h @@ -1,6 +1,7 @@ #ifndef GDTGLOBALOBJ_H #define GDTGLOBALOBJ_H -#include "../inc/types.h" + +#include #include "Gdt.h" extern MngGdt mngGdt; -- cgit v1.2.3