Compare commits

...

5 Commits

6 changed files with 40 additions and 3 deletions

View File

@ -13,7 +13,7 @@ namespace CPU
[[noreturn]] void efficient_halt(); [[noreturn]] void efficient_halt();
void idle_loop(); [[noreturn]] void idle_loop();
void switch_kernel_stack(u64 top); void switch_kernel_stack(u64 top);

View File

@ -430,7 +430,7 @@ namespace CPU
goto loop; // Safeguard: if we ever wake up, start our low-power rest again goto loop; // Safeguard: if we ever wake up, start our low-power rest again
} }
void idle_loop() [[noreturn]] void idle_loop()
{ {
asm volatile("sti"); asm volatile("sti");
loop: loop:

View File

@ -1,3 +1,4 @@
#pragma once
#include <luna/Types.h> #include <luna/Types.h>
struct Registers // Saved CPU registers for x86-64 struct Registers // Saved CPU registers for x86-64

23
luna/include/luna/Stack.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <luna/Types.h>
struct Stack
{
Stack(u64 base, usize bytes);
u64 bottom()
{
return m_base;
}
u64 top();
usize bytes()
{
return m_bytes;
}
private:
u64 m_base;
usize m_bytes;
};

View File

@ -62,11 +62,14 @@ void Bitmap::clear_region(usize start, usize bits, bool value)
expect(initialized(), "Bitmap was never initialized"); expect(initialized(), "Bitmap was never initialized");
expect((start + bits) <= size(), "Bitmap clear out of range"); expect((start + bits) <= size(), "Bitmap clear out of range");
if (!bits) return;
// Set individual bits while not on a byte boundary. // Set individual bits while not on a byte boundary.
while ((start % 8) && bits--) while ((start % 8) && bits)
{ {
set(start, value); set(start, value);
start++; start++;
bits--;
} }
// Clear out the rest in bytes. // Clear out the rest in bytes.

10
luna/src/Stack.cpp Normal file
View File

@ -0,0 +1,10 @@
#include <luna/Stack.h>
Stack::Stack(u64 base, usize bytes) : m_base(base), m_bytes(bytes)
{
}
u64 Stack::top()
{
return (m_base + m_bytes) - sizeof(void*);
}