Skip to content

Commit

Permalink
Kernel: Move all code into the Kernel namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Feb 16, 2020
1 parent d42f0f4 commit a356e48
Show file tree
Hide file tree
Showing 201 changed files with 907 additions and 111 deletions.
4 changes: 2 additions & 2 deletions AK/LogStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ DebugLogStream dbg()
stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: ";
#endif
#if defined(__serenity__) && defined(KERNEL) && !defined(BOOTSTRAPPER)
if (current)
stream << "\033[34;1m[" << *current << "]\033[0m: ";
if (Kernel::current)
stream << "\033[34;1m[" << *Kernel::current << "]\033[0m: ";
else
stream << "\033[36;1m[Kernel]\033[0m: ";
#endif
Expand Down
6 changes: 5 additions & 1 deletion Kernel/ACPI/ACPIDynamicParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <Kernel/ACPI/ACPIDynamicParser.h>
#include <Kernel/ACPI/ACPIParser.h>

namespace Kernel {

void ACPIDynamicParser::initialize(ACPI_RAW::RSDPDescriptor20& rsdp)
{
if (!ACPIStaticParser::is_initialized()) {
Expand Down Expand Up @@ -90,4 +92,6 @@ void ACPIDynamicParser::build_namespace()
{
// FIXME: Implement AML Interpretation to build the ACPI namespace
ASSERT_NOT_REACHED();
}
}

}
4 changes: 4 additions & 0 deletions Kernel/ACPI/ACPIDynamicParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <Kernel/VM/PhysicalPage.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>

namespace Kernel {

class ACPIDynamicParser final : public IRQHandler
, ACPIStaticParser {
public:
Expand All @@ -56,3 +58,5 @@ class ACPIDynamicParser final : public IRQHandler

OwnPtr<Region> m_acpi_namespace;
};

}
6 changes: 5 additions & 1 deletion Kernel/ACPI/ACPIParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <Kernel/ACPI/ACPIParser.h>

namespace Kernel {

static ACPIParser* s_acpi_parser;

ACPIParser& ACPIParser::the()
Expand Down Expand Up @@ -97,4 +99,6 @@ void ACPIParser::disable_aml_interpretation()
bool ACPIParser::is_operable()
{
return false;
}
}

}
4 changes: 4 additions & 0 deletions Kernel/ACPI/ACPIParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <LibBareMetal/Memory/VirtualAddress.h>

namespace Kernel {

class ACPIParser {
public:
static ACPIParser& the();
Expand All @@ -54,3 +56,5 @@ class ACPIParser {
explicit ACPIParser(bool usable);
bool m_operable;
};

}
4 changes: 4 additions & 0 deletions Kernel/ACPI/ACPIStaticParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

//#define ACPI_DEBUG

namespace Kernel {

void ACPIStaticParser::initialize(ACPI_RAW::RSDPDescriptor20& rsdp)
{
if (!ACPIParser::is_initialized()) {
Expand Down Expand Up @@ -413,3 +415,5 @@ ACPI_RAW::SDTHeader* ACPI::FixedACPIData::get_dsdt()
return (ACPI_RAW::SDTHeader*)m_dsdt_ptr;
}
}

}
6 changes: 5 additions & 1 deletion Kernel/ACPI/ACPIStaticParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <ACPI/ACPIParser.h>
#include <AK/OwnPtr.h>

namespace Kernel {

class ACPIStaticParser : ACPIParser {
public:
static void initialize(ACPI_RAW::RSDPDescriptor20& rsdp);
Expand Down Expand Up @@ -65,4 +67,6 @@ class ACPIStaticParser : ACPIParser {

Vector<ACPI_RAW::SDTHeader*> m_aml_tables_ptrs;
bool m_xsdt_supported;
};
};

}
4 changes: 4 additions & 0 deletions Kernel/ACPI/DMIDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/StdLib.h>

namespace Kernel {

static DMIDecoder* s_dmi_decoder;

//#define SMBIOS_DEBUG
Expand Down Expand Up @@ -274,3 +276,5 @@ char* DMIDecoder::get_smbios_string(SMBIOS::TableHeader&, u8)
ASSERT_NOT_REACHED();
return nullptr;
}

}
4 changes: 4 additions & 0 deletions Kernel/ACPI/DMIDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <LibBareMetal/Memory/VirtualAddress.h>

namespace Kernel {

namespace SMBIOS {
struct [[gnu::packed]] LegacyEntryPoint32bit
{
Expand Down Expand Up @@ -1418,3 +1420,5 @@ class DMIDecoder {

SinglyLinkedList<SMBIOS::TableHeader*> m_smbios_tables;
};

}
4 changes: 4 additions & 0 deletions Kernel/ACPI/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <AK/Types.h>
#include <AK/Vector.h>

namespace Kernel {

namespace ACPI_RAW {

struct [[gnu::packed]] RSDPDescriptor
Expand Down Expand Up @@ -309,3 +311,5 @@ class FACS : public SDT {
class MADT : public SDT {
};
}

}
4 changes: 4 additions & 0 deletions Kernel/Arch/i386/APIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#define APIC_REG_LVT_LINT1 0x360
#define APIC_REG_LVT_ERR 0x370

namespace Kernel {

extern "C" void apic_spurious_interrupt_entry();

asm(
Expand Down Expand Up @@ -214,3 +216,5 @@ void enable(u32 cpu)
}

}

}
4 changes: 4 additions & 0 deletions Kernel/Arch/i386/APIC.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@

#include <AK/Types.h>

namespace Kernel {

namespace APIC {

bool init();
void enable(u32 cpu);

}

}
40 changes: 22 additions & 18 deletions Kernel/Arch/i386/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

//#define PAGE_FAULT_DEBUG

namespace Kernel {

struct [[gnu::packed]] DescriptorTablePointer
{
u16 limit;
Expand Down Expand Up @@ -553,24 +555,6 @@ void handle_irq(RegisterState regs)
PIC::eoi(irq);
}

#ifdef DEBUG
void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func)
{
asm volatile("cli");
kprintf("ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func);

// Switch back to the current process's page tables if there are any.
// Otherwise stack walking will be a disaster.
if (current)
MM.enter_process_paging_scope(current->process());

dump_backtrace();
asm volatile("hlt");
for (;;)
;
}
#endif

void sse_init()
{
asm volatile(
Expand Down Expand Up @@ -725,3 +709,23 @@ void write_cr3(u32 cr3)
asm volatile("movl %%eax, %%cr3" ::"a"(cr3)
: "memory");
}

}

#ifdef DEBUG
void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func)
{
asm volatile("cli");
kprintf("ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func);

// Switch back to the current process's page tables if there are any.
// Otherwise stack walking will be a disaster.
if (Kernel::current)
MM.enter_process_paging_scope(Kernel::current->process());

Kernel::dump_backtrace();
asm volatile("hlt");
for (;;)
;
}
#endif
4 changes: 4 additions & 0 deletions Kernel/Arch/i386/CPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#define PAGE_SIZE 4096
#define PAGE_MASK ((uintptr_t)0xfffff000u)

namespace Kernel {

class MemoryManager;
class PageDirectory;
class PageTableEntry;
Expand Down Expand Up @@ -589,3 +591,5 @@ class SmapDisabler {
private:
u32 m_flags;
};

}
4 changes: 4 additions & 0 deletions Kernel/Arch/i386/PIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <Kernel/Arch/i386/PIC.h>
#include <LibBareMetal/IO.h>

namespace Kernel {

// The slave 8259 is connected to the master's IRQ2 line.
// This is really only to enhance clarity.
#define SLAVE_INDEX 2
Expand Down Expand Up @@ -137,3 +139,5 @@ u16 get_irr()
}

}

}
16 changes: 10 additions & 6 deletions Kernel/Arch/i386/PIC.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@

#include <AK/Types.h>

namespace Kernel {

namespace PIC {

void enable(u8 number);
void disable(u8 number);
void eoi(u8 number);
void initialize();
u16 get_isr();
u16 get_irr();
void enable(u8 number);
void disable(u8 number);
void eoi(u8 number);
void initialize();
u16 get_isr();
u16 get_irr();

}

Expand All @@ -50,3 +52,5 @@ class IRQHandlerScope {
private:
u8 m_irq { 0 };
};

}
4 changes: 4 additions & 0 deletions Kernel/Arch/i386/PIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <Kernel/Scheduler.h>
#include <LibBareMetal/IO.h>

namespace Kernel {

#define IRQ_TIMER 0

extern "C" void timer_interrupt_entry();
Expand Down Expand Up @@ -105,3 +107,5 @@ void initialize()
}

}

}
4 changes: 4 additions & 0 deletions Kernel/Arch/i386/PIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <AK/Types.h>

namespace Kernel {

#define TICKS_PER_SECOND 1000
/* Timer related ports */
#define TIMER0_CTL 0x40
Expand Down Expand Up @@ -56,3 +58,5 @@ u32 ticks_this_second();
u32 seconds_since_boot();

}

}
4 changes: 4 additions & 0 deletions Kernel/Devices/BXVGADevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <LibC/errno_numbers.h>
#include <LibC/sys/ioctl_numbers.h>

namespace Kernel {

#define MAX_RESOLUTION_WIDTH 4096
#define MAX_RESOLUTION_HEIGHT 2160

Expand Down Expand Up @@ -182,3 +184,5 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
return -EINVAL;
};
}

}
4 changes: 4 additions & 0 deletions Kernel/Devices/BXVGADevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <Kernel/Devices/BlockDevice.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>

namespace Kernel {

class BXVGADevice final : public BlockDevice {
AK_MAKE_ETERNAL
public:
Expand Down Expand Up @@ -62,3 +64,5 @@ class BXVGADevice final : public BlockDevice {
int m_framebuffer_height { 0 };
int m_y_offset { 0 };
};

}
4 changes: 4 additions & 0 deletions Kernel/Devices/BlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <Kernel/Devices/BlockDevice.h>

namespace Kernel {

BlockDevice::~BlockDevice()
{
}
Expand Down Expand Up @@ -59,3 +61,5 @@ bool BlockDevice::write_raw(u32 offset, unsigned length, const u8* in)
ASSERT(end_block <= 0xffffffff);
return write_blocks(first_block, end_block - first_block, in);
}

}
4 changes: 4 additions & 0 deletions Kernel/Devices/BlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <Kernel/Devices/Device.h>

namespace Kernel {

class BlockDevice : public Device {
public:
virtual ~BlockDevice() override;
Expand Down Expand Up @@ -55,3 +57,5 @@ class BlockDevice : public Device {

size_t m_block_size { 0 };
};

}
Loading

0 comments on commit a356e48

Please sign in to comment.