summaryrefslogtreecommitdiffstats
path: root/arch/x86/idt
diff options
context:
space:
mode:
authorAlexey Gavrilov <rebovas@yahoo.com>2024-05-24 14:07:47 +0700
committerAlexey Gavrilov <rebovas@yahoo.com>2024-05-24 14:07:47 +0700
commit5fbf41e967ed8e413ecf1e6abb72e8d285169df4 (patch)
tree48e25b199ae3459e12c7202f7b18a37cd087bf9b /arch/x86/idt
parent0a50b1758fd3da118408fd724825d0a50a9ecf17 (diff)
Pic + Tuple + refactor PrimaryInitialization class
Diffstat (limited to 'arch/x86/idt')
-rw-r--r--arch/x86/idt/Idt.cpp36
-rw-r--r--arch/x86/idt/Idt.h14
2 files changed, 44 insertions, 6 deletions
diff --git a/arch/x86/idt/Idt.cpp b/arch/x86/idt/Idt.cpp
index cd263fb..e24cbfe 100644
--- a/arch/x86/idt/Idt.cpp
+++ b/arch/x86/idt/Idt.cpp
@@ -30,7 +30,7 @@ DescInterrupt32::DescInterrupt32(uint32 offset, uint16 selector, uint8 attr)
}
};
-uint64 DescInterrupt32::getDescriptor()
+uint64 DescInterrupt32::getDescriptor() const
{
uint64 desc = 0;
@@ -42,6 +42,11 @@ uint64 DescInterrupt32::getDescriptor()
return desc;
};
+uint32 DescInterrupt32::getOffset() const
+{
+ return offsetLow | offsetHight << 16;
+};
+
DescInterrupt32 DescInterrupt32::InterruptKernelLong(uint32 offset, uint16 selector)
{
return DescInterrupt32(
@@ -86,6 +91,7 @@ MngIdt::MngIdt()
currIdx = NULL;
idtLoaded = false;
isInitialize = true;
+ irqInterruptStart = firstSystemIntNumber;
}
};
@@ -97,10 +103,24 @@ bool MngIdt::canDescriptorWrite(uint8 idx)
bool MngIdt::addDescriptor(DescInterrupt32 desc)
{
- if(!canDescriptorWrite(currIdx) or isIntReserved(currIdx)) return false;
+ uint64 descqw = desc.getDescriptor();
+
+ if(!canDescriptorWrite(currIdx) or isIntReserved(currIdx)
+ or desc.getOffset() == NULL) return false;
+
+ idt[currIdx] = descqw;
+
+ uint8 attributes = descqw >> 40;
+
+ if((attributes & RING_DRIVERSH or
+ attributes & RING_DRIVERSL) and
+ (irqInterruptStart == firstSystemIntNumber))
+ {
+ irqInterruptStart = (uint8)(descqw >> 16);
+ }
- idt[currIdx] = desc.getDescriptor();
while(isIntReserved(++currIdx));
+
return true;
};
@@ -168,3 +188,13 @@ void DescInterrupt32::setDpl(uint8 dpl)
{
attributes = (dpl & 0x03) << 5;
};
+
+bool MngIdt::isInterruptSet(uint8 numberInterrupt)
+{
+ return idt[numberInterrupt];
+};
+
+uint8 MngIdt::getIrqInterruptStart()
+{
+ return irqInterruptStart;
+};
diff --git a/arch/x86/idt/Idt.h b/arch/x86/idt/Idt.h
index 7370526..3054fd5 100644
--- a/arch/x86/idt/Idt.h
+++ b/arch/x86/idt/Idt.h
@@ -35,8 +35,9 @@ class DescInterrupt32
void setOffset(uint32 offset);
void setGateType(uint8 gateType);
void setDpl(uint8 dpl);
- uint64 getDescriptor();
- static DescInterrupt32 InterruptKernelLong(uint32 offset,
+ uint64 getDescriptor() const;
+ uint32 getOffset() const;
+ static DescInterrupt32 InterruptKernelLong(uint32 offset,
uint16 selector);
static DescInterrupt32 TrapKernelLong(uint32 offset,
uint16 selector);
@@ -47,7 +48,7 @@ class MngIdt
{
private:
const static uint8 reservedIntSize = 12;
- constexpr static uint8 reservedInts[reservedIntSize] =
+ constexpr static uint8 reservedInts[reservedIntSize] =
{
9, 15, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
};
@@ -58,7 +59,12 @@ class MngIdt
static bool isInitialize;
static bool idtLoaded;
uint8 currIdx;
+ // Start number of interrupts that service IRQ
+ // Accpet this number as first interrupt descriptor
+ // with dpl = 2 or 3 (drivers)
+ uint8 irqInterruptStart;
public:
+ const static uint8 firstSystemIntNumber = 0x20;
MngIdt();
MngIdt(const MngIdt &) = delete;
bool addDescriptor(DescInterrupt32 desc);
@@ -66,6 +72,8 @@ class MngIdt
bool canDescriptorWrite(uint8 idx);
bool loadIdt();
static MngIdt &getInstance();
+ uint8 getIrqInterruptStart();
+ bool isInterruptSet(uint8 numberInterrupt);
};
extern MngIdt mngIdt;