summaryrefslogtreecommitdiffstats
path: root/arch/x86/gdt
diff options
context:
space:
mode:
authorAlexey Gavrilov <rebovas@yahoo.com>2024-02-22 14:18:39 +0700
committerAlexey Gavrilov <rebovas@yahoo.com>2024-02-22 14:18:39 +0700
commitcbcbf6e7d614ecf94dd7e1b9033f8d599f48662e (patch)
tree59872849d347794cc58c8ad3aa201a14e0db526f /arch/x86/gdt
parentc18781e37e6bfe153e7c0f2bc8b04df0aecf151d (diff)
Implement support of cpuid instruction + include folder + some updates
Diffstat (limited to 'arch/x86/gdt')
-rwxr-xr-xarch/x86/gdt/Gdt.cpp17
-rwxr-xr-xarch/x86/gdt/Gdt.h5
-rw-r--r--arch/x86/gdt/GlobalObj.cpp8
-rw-r--r--arch/x86/gdt/GlobalObj.h3
4 files changed, 20 insertions, 13 deletions
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 <types.h>
// 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 <types.h>
#include "Gdt.h"
extern MngGdt mngGdt;