summaryrefslogtreecommitdiff
path: root/Kernel/i386.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-01 16:23:12 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-01 16:23:12 +0100
commitc70afd045e5b91837e77dcc7c54a44ddec39aab7 (patch)
tree09e9db03dc1587c839002bc5e8e2da93bd065357 /Kernel/i386.cpp
parent9da4864a9a123ddc8b2a1d13ee86a727cac7eb67 (diff)
downloadserenity-c70afd045e5b91837e77dcc7c54a44ddec39aab7.zip
Use a freelist for GDT entries.
Tweak the kmalloc space layout a bit. Get the spawn stress test up and running again.
Diffstat (limited to 'Kernel/i386.cpp')
-rw-r--r--Kernel/i386.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp
index 0a778ca9cd..9ebdd95c19 100644
--- a/Kernel/i386.cpp
+++ b/Kernel/i386.cpp
@@ -20,15 +20,20 @@ static Descriptor* s_gdt;
static IRQHandler** s_irqHandler;
+static Vector<word, KmallocEternalAllocator>* s_gdt_freelist;
+
static WORD s_gdtLength;
-WORD allocateGDTEntry()
+word gdt_alloc_entry()
{
- // FIXME: This should not grow indefinitely.
- ASSERT(s_gdtLength < 256);
- WORD newGDTEntry = s_gdtLength * 8;
- s_gdtLength++;
- return newGDTEntry;
+ ASSERT(s_gdt_freelist);
+ ASSERT(!s_gdt_freelist->isEmpty());
+ return s_gdt_freelist->takeLast();
+}
+
+void gdt_free_entry(word entry)
+{
+ s_gdt_freelist->append(entry);
}
extern "C" void handleIRQ();
@@ -310,6 +315,12 @@ void gdt_init()
s_gdt = static_cast<Descriptor*>(kmalloc_eternal(sizeof(Descriptor) * 256));
s_gdtLength = 5;
+ s_gdt_freelist = new Vector<word, KmallocEternalAllocator>();
+ s_gdt_freelist->ensureCapacity(256);
+ for (size_t i = s_gdtLength; i < 256; ++i)
+ s_gdt_freelist->uncheckedAppend(i * 8);
+
+ s_gdtLength = 256;
s_gdtr.address = s_gdt;
s_gdtr.size = (s_gdtLength * 8) - 1;