summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorAlexey Gavrilov <90127298+rebovas@users.noreply.github.com>2024-03-07 15:18:51 +0700
committerGitHub <noreply@github.com>2024-03-07 15:18:51 +0700
commit05673a8a51a9f00fa367ec2898ffce493e7ecdc9 (patch)
tree4999e8c789a036511a1b6bbaec594b712bb1f64a /arch/x86
parent976575c12b5da66996a3204ec711e4937a3ef240 (diff)
parent244a9154e42a49470bd28e3a95ebe9f4a5fe5ff7 (diff)
Merge pull request #1 from rebovas/init_proc
Mechanism of initialization
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/PrimaryInit.cpp16
-rw-r--r--arch/x86/PrimaryInit.h12
-rwxr-xr-xarch/x86/gdt/Gdt.cpp4
-rwxr-xr-xarch/x86/gdt/Gdt.h2
-rw-r--r--arch/x86/gdt/GlobalObj.cpp6
-rw-r--r--arch/x86/gdt/GlobalObj.h11
-rw-r--r--arch/x86/gdt/SwitchToGdt.s (renamed from arch/x86/gdt/GoToGdtMemSeg.s)4
-rw-r--r--arch/x86/io/GlobalObj.cpp3
-rw-r--r--arch/x86/io/GlobalObj.h8
-rw-r--r--arch/x86/io/VGADisplay.cpp2
-rw-r--r--arch/x86/io/VGADisplay.h8
11 files changed, 44 insertions, 32 deletions
diff --git a/arch/x86/PrimaryInit.cpp b/arch/x86/PrimaryInit.cpp
new file mode 100644
index 0000000..7de690e
--- /dev/null
+++ b/arch/x86/PrimaryInit.cpp
@@ -0,0 +1,16 @@
+#include "PrimaryInit.h"
+
+
+void PrimaryInitialization::processorInitialize()
+{
+ MngGdt mngGdt = MngGdt();
+
+ mngGdt.addDescriptor(DescSeg32::flatCodeKernel());
+ mngGdt.addDescriptor(DescSeg32::flatDataKernel());
+ mngGdt.loadGdt();
+};
+
+void PrimaryInitialization::devicesInitialize()
+{
+ out::display = VGADisplay();
+};
diff --git a/arch/x86/PrimaryInit.h b/arch/x86/PrimaryInit.h
new file mode 100644
index 0000000..8d16549
--- /dev/null
+++ b/arch/x86/PrimaryInit.h
@@ -0,0 +1,12 @@
+#include "gdt/Gdt.h"
+#include "io/VGADisplay.h"
+
+
+#define x86_ARCH
+
+class PrimaryInitialization
+{
+ protected:
+ virtual void processorInitialize();
+ virtual void devicesInitialize();
+};
diff --git a/arch/x86/gdt/Gdt.cpp b/arch/x86/gdt/Gdt.cpp
index 88c7bbd..21941b4 100755
--- a/arch/x86/gdt/Gdt.cpp
+++ b/arch/x86/gdt/Gdt.cpp
@@ -1,6 +1,8 @@
#include "Gdt.h"
+uint64 MngGdt::gdt[MngGdt::size];
+
DescSeg32::DescSeg32(uint32 base, uint32 limit, uint8 access, uint8 flags)
{
this->baseLow = base & 0x0000FFFF;
@@ -88,7 +90,7 @@ bool MngGdt::loadGdt()
pointer <<= 16;
pointer |= size;
- GOTOGDTMEMSEG(pointer);
+ SWITCHTOGDT(pointer);
isGdtLoaded = 1;
return true;
diff --git a/arch/x86/gdt/Gdt.h b/arch/x86/gdt/Gdt.h
index a8d7dc2..6667d93 100755
--- a/arch/x86/gdt/Gdt.h
+++ b/arch/x86/gdt/Gdt.h
@@ -59,7 +59,7 @@ class DescSeg32 // Segment descriptor
#ifdef __cplusplus
extern "C" {
#endif
-extern void GOTOGDTMEMSEG(uint64 pointer);
+extern void SWITCHTOGDT(uint64 pointer);
#ifdef __cplusplus
};
#endif
diff --git a/arch/x86/gdt/GlobalObj.cpp b/arch/x86/gdt/GlobalObj.cpp
deleted file mode 100644
index fbceeef..0000000
--- a/arch/x86/gdt/GlobalObj.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "GlobalObj.h"
-
-
-uint64 MngGdt::gdt[MngGdt::size];
-
-MngGdt mngGdt;
diff --git a/arch/x86/gdt/GlobalObj.h b/arch/x86/gdt/GlobalObj.h
deleted file mode 100644
index 3c62847..0000000
--- a/arch/x86/gdt/GlobalObj.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef GDTGLOBALOBJ_H
-#define GDTGLOBALOBJ_H
-
-#include <types.h>
-#include "Gdt.h"
-
-extern MngGdt mngGdt;
-
-void mngGdtInit();
-
-#endif
diff --git a/arch/x86/gdt/GoToGdtMemSeg.s b/arch/x86/gdt/SwitchToGdt.s
index 2b5dd62..52ebbc7 100644
--- a/arch/x86/gdt/GoToGdtMemSeg.s
+++ b/arch/x86/gdt/SwitchToGdt.s
@@ -1,5 +1,5 @@
-global GOTOGDTMEMSEG
-GOTOGDTMEMSEG:
+global SWITCHTOGDT
+SWITCHTOGDT:
lgdt [esp + 4]
jmp 0x08:.reloadCS
.reloadCS:
diff --git a/arch/x86/io/GlobalObj.cpp b/arch/x86/io/GlobalObj.cpp
deleted file mode 100644
index a1c4f03..0000000
--- a/arch/x86/io/GlobalObj.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "VGADisplay.h"
-
-VGADisplay display;
diff --git a/arch/x86/io/GlobalObj.h b/arch/x86/io/GlobalObj.h
deleted file mode 100644
index 72c6b06..0000000
--- a/arch/x86/io/GlobalObj.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef GLOBALOBJ_H
-#define GLOBALOBJ_H
-
-#include "VGADisplay.h"
-
-extern VGADisplay display;
-
-#endif
diff --git a/arch/x86/io/VGADisplay.cpp b/arch/x86/io/VGADisplay.cpp
index 0cd0bed..ceb4862 100644
--- a/arch/x86/io/VGADisplay.cpp
+++ b/arch/x86/io/VGADisplay.cpp
@@ -1,5 +1,7 @@
#include "VGADisplay.h"
+VGADisplay out::display;
+
VGADisplay::VGADisplay()
{
isBright = isBlink = shift = 0;
diff --git a/arch/x86/io/VGADisplay.h b/arch/x86/io/VGADisplay.h
index db4c4df..326ae95 100644
--- a/arch/x86/io/VGADisplay.h
+++ b/arch/x86/io/VGADisplay.h
@@ -36,4 +36,12 @@ class VGADisplay
void setBlink(bool blinkAttr);
void setBright(bool brigthAttr);
};
+
+// Global variables
+
+namespace out
+{
+ extern VGADisplay display;
+};
+
#endif