mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:28:11 +00:00
Kernel: Move all code into the Kernel namespace
This commit is contained in:
parent
d42f0f4661
commit
a356e48150
201 changed files with 907 additions and 111 deletions
|
@ -101,8 +101,8 @@ DebugLogStream dbg()
|
||||||
stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: ";
|
stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: ";
|
||||||
#endif
|
#endif
|
||||||
#if defined(__serenity__) && defined(KERNEL) && !defined(BOOTSTRAPPER)
|
#if defined(__serenity__) && defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
if (current)
|
if (Kernel::current)
|
||||||
stream << "\033[34;1m[" << *current << "]\033[0m: ";
|
stream << "\033[34;1m[" << *Kernel::current << "]\033[0m: ";
|
||||||
else
|
else
|
||||||
stream << "\033[36;1m[Kernel]\033[0m: ";
|
stream << "\033[36;1m[Kernel]\033[0m: ";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <Kernel/ACPI/ACPIDynamicParser.h>
|
#include <Kernel/ACPI/ACPIDynamicParser.h>
|
||||||
#include <Kernel/ACPI/ACPIParser.h>
|
#include <Kernel/ACPI/ACPIParser.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
void ACPIDynamicParser::initialize(ACPI_RAW::RSDPDescriptor20& rsdp)
|
void ACPIDynamicParser::initialize(ACPI_RAW::RSDPDescriptor20& rsdp)
|
||||||
{
|
{
|
||||||
if (!ACPIStaticParser::is_initialized()) {
|
if (!ACPIStaticParser::is_initialized()) {
|
||||||
|
@ -90,4 +92,6 @@ void ACPIDynamicParser::build_namespace()
|
||||||
{
|
{
|
||||||
// FIXME: Implement AML Interpretation to build the ACPI namespace
|
// FIXME: Implement AML Interpretation to build the ACPI namespace
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <Kernel/VM/PhysicalPage.h>
|
#include <Kernel/VM/PhysicalPage.h>
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class ACPIDynamicParser final : public IRQHandler
|
class ACPIDynamicParser final : public IRQHandler
|
||||||
, ACPIStaticParser {
|
, ACPIStaticParser {
|
||||||
public:
|
public:
|
||||||
|
@ -56,3 +58,5 @@ private:
|
||||||
|
|
||||||
OwnPtr<Region> m_acpi_namespace;
|
OwnPtr<Region> m_acpi_namespace;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <Kernel/ACPI/ACPIParser.h>
|
#include <Kernel/ACPI/ACPIParser.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static ACPIParser* s_acpi_parser;
|
static ACPIParser* s_acpi_parser;
|
||||||
|
|
||||||
ACPIParser& ACPIParser::the()
|
ACPIParser& ACPIParser::the()
|
||||||
|
@ -97,4 +99,6 @@ void ACPIParser::disable_aml_interpretation()
|
||||||
bool ACPIParser::is_operable()
|
bool ACPIParser::is_operable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
#include <LibBareMetal/Memory/VirtualAddress.h>
|
#include <LibBareMetal/Memory/VirtualAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class ACPIParser {
|
class ACPIParser {
|
||||||
public:
|
public:
|
||||||
static ACPIParser& the();
|
static ACPIParser& the();
|
||||||
|
@ -54,3 +56,5 @@ protected:
|
||||||
explicit ACPIParser(bool usable);
|
explicit ACPIParser(bool usable);
|
||||||
bool m_operable;
|
bool m_operable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
//#define ACPI_DEBUG
|
//#define ACPI_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
void ACPIStaticParser::initialize(ACPI_RAW::RSDPDescriptor20& rsdp)
|
void ACPIStaticParser::initialize(ACPI_RAW::RSDPDescriptor20& rsdp)
|
||||||
{
|
{
|
||||||
if (!ACPIParser::is_initialized()) {
|
if (!ACPIParser::is_initialized()) {
|
||||||
|
@ -413,3 +415,5 @@ ACPI_RAW::SDTHeader* ACPI::FixedACPIData::get_dsdt()
|
||||||
return (ACPI_RAW::SDTHeader*)m_dsdt_ptr;
|
return (ACPI_RAW::SDTHeader*)m_dsdt_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <ACPI/ACPIParser.h>
|
#include <ACPI/ACPIParser.h>
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class ACPIStaticParser : ACPIParser {
|
class ACPIStaticParser : ACPIParser {
|
||||||
public:
|
public:
|
||||||
static void initialize(ACPI_RAW::RSDPDescriptor20& rsdp);
|
static void initialize(ACPI_RAW::RSDPDescriptor20& rsdp);
|
||||||
|
@ -65,4 +67,6 @@ private:
|
||||||
|
|
||||||
Vector<ACPI_RAW::SDTHeader*> m_aml_tables_ptrs;
|
Vector<ACPI_RAW::SDTHeader*> m_aml_tables_ptrs;
|
||||||
bool m_xsdt_supported;
|
bool m_xsdt_supported;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
#include <LibBareMetal/StdLib.h>
|
#include <LibBareMetal/StdLib.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static DMIDecoder* s_dmi_decoder;
|
static DMIDecoder* s_dmi_decoder;
|
||||||
|
|
||||||
//#define SMBIOS_DEBUG
|
//#define SMBIOS_DEBUG
|
||||||
|
@ -274,3 +276,5 @@ char* DMIDecoder::get_smbios_string(SMBIOS::TableHeader&, u8)
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
#include <LibBareMetal/Memory/VirtualAddress.h>
|
#include <LibBareMetal/Memory/VirtualAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
namespace SMBIOS {
|
namespace SMBIOS {
|
||||||
struct [[gnu::packed]] LegacyEntryPoint32bit
|
struct [[gnu::packed]] LegacyEntryPoint32bit
|
||||||
{
|
{
|
||||||
|
@ -1418,3 +1420,5 @@ private:
|
||||||
|
|
||||||
SinglyLinkedList<SMBIOS::TableHeader*> m_smbios_tables;
|
SinglyLinkedList<SMBIOS::TableHeader*> m_smbios_tables;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
namespace ACPI_RAW {
|
namespace ACPI_RAW {
|
||||||
|
|
||||||
struct [[gnu::packed]] RSDPDescriptor
|
struct [[gnu::packed]] RSDPDescriptor
|
||||||
|
@ -309,3 +311,5 @@ private:
|
||||||
class MADT : public SDT {
|
class MADT : public SDT {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@
|
||||||
#define APIC_REG_LVT_LINT1 0x360
|
#define APIC_REG_LVT_LINT1 0x360
|
||||||
#define APIC_REG_LVT_ERR 0x370
|
#define APIC_REG_LVT_ERR 0x370
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
extern "C" void apic_spurious_interrupt_entry();
|
extern "C" void apic_spurious_interrupt_entry();
|
||||||
|
|
||||||
asm(
|
asm(
|
||||||
|
@ -214,3 +216,5 @@ void enable(u32 cpu)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,9 +28,13 @@
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
namespace APIC {
|
namespace APIC {
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
void enable(u32 cpu);
|
void enable(u32 cpu);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
//#define PAGE_FAULT_DEBUG
|
//#define PAGE_FAULT_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
struct [[gnu::packed]] DescriptorTablePointer
|
struct [[gnu::packed]] DescriptorTablePointer
|
||||||
{
|
{
|
||||||
u16 limit;
|
u16 limit;
|
||||||
|
@ -553,24 +555,6 @@ void handle_irq(RegisterState regs)
|
||||||
PIC::eoi(irq);
|
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()
|
void sse_init()
|
||||||
{
|
{
|
||||||
asm volatile(
|
asm volatile(
|
||||||
|
@ -725,3 +709,23 @@ void write_cr3(u32 cr3)
|
||||||
asm volatile("movl %%eax, %%cr3" ::"a"(cr3)
|
asm volatile("movl %%eax, %%cr3" ::"a"(cr3)
|
||||||
: "memory");
|
: "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
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#define PAGE_SIZE 4096
|
#define PAGE_SIZE 4096
|
||||||
#define PAGE_MASK ((uintptr_t)0xfffff000u)
|
#define PAGE_MASK ((uintptr_t)0xfffff000u)
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class MemoryManager;
|
class MemoryManager;
|
||||||
class PageDirectory;
|
class PageDirectory;
|
||||||
class PageTableEntry;
|
class PageTableEntry;
|
||||||
|
@ -589,3 +591,5 @@ public:
|
||||||
private:
|
private:
|
||||||
u32 m_flags;
|
u32 m_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/Arch/i386/PIC.h>
|
#include <Kernel/Arch/i386/PIC.h>
|
||||||
#include <LibBareMetal/IO.h>
|
#include <LibBareMetal/IO.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
// The slave 8259 is connected to the master's IRQ2 line.
|
// The slave 8259 is connected to the master's IRQ2 line.
|
||||||
// This is really only to enhance clarity.
|
// This is really only to enhance clarity.
|
||||||
#define SLAVE_INDEX 2
|
#define SLAVE_INDEX 2
|
||||||
|
@ -137,3 +139,5 @@ u16 get_irr()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,14 +28,16 @@
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
namespace PIC {
|
namespace PIC {
|
||||||
|
|
||||||
void enable(u8 number);
|
void enable(u8 number);
|
||||||
void disable(u8 number);
|
void disable(u8 number);
|
||||||
void eoi(u8 number);
|
void eoi(u8 number);
|
||||||
void initialize();
|
void initialize();
|
||||||
u16 get_isr();
|
u16 get_isr();
|
||||||
u16 get_irr();
|
u16 get_irr();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,3 +52,5 @@ public:
|
||||||
private:
|
private:
|
||||||
u8 m_irq { 0 };
|
u8 m_irq { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/Scheduler.h>
|
#include <Kernel/Scheduler.h>
|
||||||
#include <LibBareMetal/IO.h>
|
#include <LibBareMetal/IO.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define IRQ_TIMER 0
|
#define IRQ_TIMER 0
|
||||||
|
|
||||||
extern "C" void timer_interrupt_entry();
|
extern "C" void timer_interrupt_entry();
|
||||||
|
@ -105,3 +107,5 @@ void initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define TICKS_PER_SECOND 1000
|
#define TICKS_PER_SECOND 1000
|
||||||
/* Timer related ports */
|
/* Timer related ports */
|
||||||
#define TIMER0_CTL 0x40
|
#define TIMER0_CTL 0x40
|
||||||
|
@ -56,3 +58,5 @@ u32 ticks_this_second();
|
||||||
u32 seconds_since_boot();
|
u32 seconds_since_boot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
#include <LibC/sys/ioctl_numbers.h>
|
#include <LibC/sys/ioctl_numbers.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define MAX_RESOLUTION_WIDTH 4096
|
#define MAX_RESOLUTION_WIDTH 4096
|
||||||
#define MAX_RESOLUTION_HEIGHT 2160
|
#define MAX_RESOLUTION_HEIGHT 2160
|
||||||
|
|
||||||
|
@ -182,3 +184,5 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <Kernel/Devices/BlockDevice.h>
|
#include <Kernel/Devices/BlockDevice.h>
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class BXVGADevice final : public BlockDevice {
|
class BXVGADevice final : public BlockDevice {
|
||||||
AK_MAKE_ETERNAL
|
AK_MAKE_ETERNAL
|
||||||
public:
|
public:
|
||||||
|
@ -62,3 +64,5 @@ private:
|
||||||
int m_framebuffer_height { 0 };
|
int m_framebuffer_height { 0 };
|
||||||
int m_y_offset { 0 };
|
int m_y_offset { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <Kernel/Devices/BlockDevice.h>
|
#include <Kernel/Devices/BlockDevice.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
BlockDevice::~BlockDevice()
|
BlockDevice::~BlockDevice()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -59,3 +61,5 @@ bool BlockDevice::write_raw(u32 offset, unsigned length, const u8* in)
|
||||||
ASSERT(end_block <= 0xffffffff);
|
ASSERT(end_block <= 0xffffffff);
|
||||||
return write_blocks(first_block, end_block - first_block, in);
|
return write_blocks(first_block, end_block - first_block, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <Kernel/Devices/Device.h>
|
#include <Kernel/Devices/Device.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class BlockDevice : public Device {
|
class BlockDevice : public Device {
|
||||||
public:
|
public:
|
||||||
virtual ~BlockDevice() override;
|
virtual ~BlockDevice() override;
|
||||||
|
@ -55,3 +57,5 @@ private:
|
||||||
|
|
||||||
size_t m_block_size { 0 };
|
size_t m_block_size { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
|
|
||||||
#include <Kernel/Devices/CharacterDevice.h>
|
#include <Kernel/Devices/CharacterDevice.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
CharacterDevice::~CharacterDevice()
|
CharacterDevice::~CharacterDevice()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <Kernel/Devices/Device.h>
|
#include <Kernel/Devices/Device.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class CharacterDevice : public Device {
|
class CharacterDevice : public Device {
|
||||||
public:
|
public:
|
||||||
virtual ~CharacterDevice() override;
|
virtual ~CharacterDevice() override;
|
||||||
|
@ -41,3 +43,5 @@ protected:
|
||||||
private:
|
private:
|
||||||
virtual bool is_character_device() const final { return true; }
|
virtual bool is_character_device() const final { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <Kernel/Devices/DebugLogDevice.h>
|
#include <Kernel/Devices/DebugLogDevice.h>
|
||||||
#include <LibBareMetal/IO.h>
|
#include <LibBareMetal/IO.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static DebugLogDevice* s_the;
|
static DebugLogDevice* s_the;
|
||||||
|
|
||||||
DebugLogDevice& DebugLogDevice::the()
|
DebugLogDevice& DebugLogDevice::the()
|
||||||
|
@ -51,3 +53,5 @@ ssize_t DebugLogDevice::write(FileDescription&, const u8* data, ssize_t data_siz
|
||||||
IO::out8(0xe9, data[i]);
|
IO::out8(0xe9, data[i]);
|
||||||
return data_size;
|
return data_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <Kernel/Devices/CharacterDevice.h>
|
#include <Kernel/Devices/CharacterDevice.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class DebugLogDevice final : public CharacterDevice {
|
class DebugLogDevice final : public CharacterDevice {
|
||||||
public:
|
public:
|
||||||
DebugLogDevice();
|
DebugLogDevice();
|
||||||
|
@ -41,3 +43,5 @@ private:
|
||||||
virtual bool can_read(const FileDescription&) const override { return true; }
|
virtual bool can_read(const FileDescription&) const override { return true; }
|
||||||
virtual const char* class_name() const override { return "DebugLogDevice"; }
|
virtual const char* class_name() const override { return "DebugLogDevice"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <Kernel/FileSystem/InodeMetadata.h>
|
#include <Kernel/FileSystem/InodeMetadata.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static HashMap<u32, Device*>* s_all_devices;
|
static HashMap<u32, Device*>* s_all_devices;
|
||||||
|
|
||||||
HashMap<u32, Device*>& Device::all_devices()
|
HashMap<u32, Device*>& Device::all_devices()
|
||||||
|
@ -78,3 +80,5 @@ String Device::absolute_path(const FileDescription&) const
|
||||||
{
|
{
|
||||||
return absolute_path();
|
return absolute_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
#include <Kernel/FileSystem/File.h>
|
#include <Kernel/FileSystem/File.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class Device : public File {
|
class Device : public File {
|
||||||
public:
|
public:
|
||||||
virtual ~Device() override;
|
virtual ~Device() override;
|
||||||
|
@ -71,3 +73,5 @@ private:
|
||||||
uid_t m_uid { 0 };
|
uid_t m_uid { 0 };
|
||||||
gid_t m_gid { 0 };
|
gid_t m_gid { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
// #define OFFD_DEBUG
|
// #define OFFD_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
NonnullRefPtr<DiskPartition> DiskPartition::create(BlockDevice& device, unsigned block_offset, unsigned block_limit)
|
NonnullRefPtr<DiskPartition> DiskPartition::create(BlockDevice& device, unsigned block_offset, unsigned block_limit)
|
||||||
{
|
{
|
||||||
return adopt(*new DiskPartition(device, block_offset, block_limit));
|
return adopt(*new DiskPartition(device, block_offset, block_limit));
|
||||||
|
@ -67,3 +69,5 @@ const char* DiskPartition::class_name() const
|
||||||
{
|
{
|
||||||
return "DiskPartition";
|
return "DiskPartition";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <Kernel/Devices/BlockDevice.h>
|
#include <Kernel/Devices/BlockDevice.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class DiskPartition final : public BlockDevice {
|
class DiskPartition final : public BlockDevice {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<DiskPartition> create(BlockDevice&, unsigned block_offset, unsigned block_limit);
|
static NonnullRefPtr<DiskPartition> create(BlockDevice&, unsigned block_offset, unsigned block_limit);
|
||||||
|
@ -52,3 +54,5 @@ private:
|
||||||
unsigned m_block_offset;
|
unsigned m_block_offset;
|
||||||
unsigned m_block_limit;
|
unsigned m_block_limit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#define EBR_DEBUG
|
#define EBR_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
EBRPartitionTable::EBRPartitionTable(NonnullRefPtr<BlockDevice> device)
|
EBRPartitionTable::EBRPartitionTable(NonnullRefPtr<BlockDevice> device)
|
||||||
: m_device(move(device))
|
: m_device(move(device))
|
||||||
{
|
{
|
||||||
|
@ -194,3 +196,5 @@ RefPtr<DiskPartition> EBRPartitionTable::partition(unsigned index)
|
||||||
return get_non_extended_partition(index - m_ebr_chained_extensions_count);
|
return get_non_extended_partition(index - m_ebr_chained_extensions_count);
|
||||||
return get_non_extended_partition(index);
|
return get_non_extended_partition(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <Kernel/Devices/DiskPartition.h>
|
#include <Kernel/Devices/DiskPartition.h>
|
||||||
#include <Kernel/Devices/MBRPartitionTable.h>
|
#include <Kernel/Devices/MBRPartitionTable.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
struct [[gnu::packed]] EBRPartitionExtension
|
struct [[gnu::packed]] EBRPartitionExtension
|
||||||
{
|
{
|
||||||
u8 unused_area[446];
|
u8 unused_area[446];
|
||||||
|
@ -65,3 +67,5 @@ private:
|
||||||
u8 m_cached_mbr_header[512];
|
u8 m_cached_mbr_header[512];
|
||||||
u8 m_cached_ebr_header[512];
|
u8 m_cached_ebr_header[512];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
#include <LibBareMetal/IO.h>
|
#include <LibBareMetal/IO.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
// Uncomment me for a LOT of output
|
// Uncomment me for a LOT of output
|
||||||
//#define FLOPPY_DEBUG
|
//#define FLOPPY_DEBUG
|
||||||
|
|
||||||
|
@ -561,3 +563,5 @@ void FloppyDiskDevice::initialize()
|
||||||
kprintf("fdc: fd%d initialised succesfully!\n", is_slave() ? 1 : 0);
|
kprintf("fdc: fd%d initialised succesfully!\n", is_slave() ? 1 : 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -104,6 +104,8 @@
|
||||||
#include <Kernel/VM/PhysicalPage.h>
|
#include <Kernel/VM/PhysicalPage.h>
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
struct FloppyControllerCommand {
|
struct FloppyControllerCommand {
|
||||||
u8 cmd; // Command to send to the controller
|
u8 cmd; // Command to send to the controller
|
||||||
u8 numParams; // Number of parameters to send to the drive
|
u8 numParams; // Number of parameters to send to the drive
|
||||||
|
@ -216,3 +218,5 @@ private:
|
||||||
|
|
||||||
u8 m_controller_version { 0 };
|
u8 m_controller_version { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
FullDevice::FullDevice()
|
FullDevice::FullDevice()
|
||||||
: CharacterDevice(1, 7)
|
: CharacterDevice(1, 7)
|
||||||
{
|
{
|
||||||
|
@ -55,3 +57,5 @@ ssize_t FullDevice::write(FileDescription&, const u8*, ssize_t size)
|
||||||
return 0;
|
return 0;
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "CharacterDevice.h"
|
#include "CharacterDevice.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class FullDevice final : public CharacterDevice {
|
class FullDevice final : public CharacterDevice {
|
||||||
AK_MAKE_ETERNAL
|
AK_MAKE_ETERNAL
|
||||||
public:
|
public:
|
||||||
|
@ -42,3 +44,5 @@ private:
|
||||||
virtual bool can_write(const FileDescription&) const override { return true; }
|
virtual bool can_write(const FileDescription&) const override { return true; }
|
||||||
virtual const char* class_name() const override { return "FullDevice"; }
|
virtual const char* class_name() const override { return "FullDevice"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#define GPT_DEBUG
|
#define GPT_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
GPTPartitionTable::GPTPartitionTable(BlockDevice& device)
|
GPTPartitionTable::GPTPartitionTable(BlockDevice& device)
|
||||||
: m_device(move(device))
|
: m_device(move(device))
|
||||||
{
|
{
|
||||||
|
@ -99,3 +101,5 @@ RefPtr<DiskPartition> GPTPartitionTable::partition(unsigned index)
|
||||||
#endif
|
#endif
|
||||||
return DiskPartition::create(m_device, entry.first_lba[0], entry.last_lba[0]);
|
return DiskPartition::create(m_device, entry.first_lba[0], entry.last_lba[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <Kernel/Devices/DiskPartition.h>
|
#include <Kernel/Devices/DiskPartition.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define GPT_SIGNATURE2 0x54524150
|
#define GPT_SIGNATURE2 0x54524150
|
||||||
#define GPT_SIGNATURE 0x20494645
|
#define GPT_SIGNATURE 0x20494645
|
||||||
#define BytesPerSector 512
|
#define BytesPerSector 512
|
||||||
|
@ -85,3 +87,5 @@ private:
|
||||||
|
|
||||||
u8 m_cached_header[512];
|
u8 m_cached_header[512];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
//#define KEYBOARD_DEBUG
|
//#define KEYBOARD_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define IRQ_KEYBOARD 1
|
#define IRQ_KEYBOARD 1
|
||||||
#define I8042_BUFFER 0x60
|
#define I8042_BUFFER 0x60
|
||||||
#define I8042_STATUS 0x64
|
#define I8042_STATUS 0x64
|
||||||
|
@ -619,3 +621,5 @@ void KeyboardDevice::set_maps(const char* n_map, const char* n_shift_map, const
|
||||||
altgr_map[i] = n_altgr_map[i];
|
altgr_map[i] = n_altgr_map[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <Kernel/Devices/CharacterDevice.h>
|
#include <Kernel/Devices/CharacterDevice.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class KeyboardClient;
|
class KeyboardClient;
|
||||||
|
|
||||||
class KeyboardDevice final : public IRQHandler
|
class KeyboardDevice final : public IRQHandler
|
||||||
|
@ -84,3 +86,5 @@ public:
|
||||||
virtual ~KeyboardClient();
|
virtual ~KeyboardClient();
|
||||||
virtual void on_key_pressed(KeyboardDevice::Event) = 0;
|
virtual void on_key_pressed(KeyboardDevice::Event) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#define MBR_DEBUG
|
#define MBR_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
MBRPartitionTable::MBRPartitionTable(NonnullRefPtr<BlockDevice> device)
|
MBRPartitionTable::MBRPartitionTable(NonnullRefPtr<BlockDevice> device)
|
||||||
: m_device(move(device))
|
: m_device(move(device))
|
||||||
{
|
{
|
||||||
|
@ -107,3 +109,5 @@ RefPtr<DiskPartition> MBRPartitionTable::partition(unsigned index)
|
||||||
|
|
||||||
return DiskPartition::create(m_device, entry.offset, (entry.offset + entry.length));
|
return DiskPartition::create(m_device, entry.offset, (entry.offset + entry.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <Kernel/Devices/DiskPartition.h>
|
#include <Kernel/Devices/DiskPartition.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define MBR_SIGNATURE 0xaa55
|
#define MBR_SIGNATURE 0xaa55
|
||||||
#define MBR_PROTECTIVE 0xEE
|
#define MBR_PROTECTIVE 0xEE
|
||||||
#define EBR_CHS_CONTAINER 0x05
|
#define EBR_CHS_CONTAINER 0x05
|
||||||
|
@ -76,3 +78,5 @@ private:
|
||||||
|
|
||||||
u8 m_cached_header[512];
|
u8 m_cached_header[512];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
#include <LibC/sys/ioctl_numbers.h>
|
#include <LibC/sys/ioctl_numbers.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static MBVGADevice* s_the;
|
static MBVGADevice* s_the;
|
||||||
|
|
||||||
MBVGADevice& MBVGADevice::the()
|
MBVGADevice& MBVGADevice::the()
|
||||||
|
@ -109,3 +111,5 @@ int MBVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <Kernel/Devices/BlockDevice.h>
|
#include <Kernel/Devices/BlockDevice.h>
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class MBVGADevice final : public BlockDevice {
|
class MBVGADevice final : public BlockDevice {
|
||||||
AK_MAKE_ETERNAL
|
AK_MAKE_ETERNAL
|
||||||
public:
|
public:
|
||||||
|
@ -57,3 +59,5 @@ private:
|
||||||
int m_framebuffer_width { 0 };
|
int m_framebuffer_width { 0 };
|
||||||
int m_framebuffer_height { 0 };
|
int m_framebuffer_height { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include "NullDevice.h"
|
#include "NullDevice.h"
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static NullDevice* s_the;
|
static NullDevice* s_the;
|
||||||
|
|
||||||
NullDevice& NullDevice::the()
|
NullDevice& NullDevice::the()
|
||||||
|
@ -59,3 +61,5 @@ ssize_t NullDevice::write(FileDescription&, const u8*, ssize_t buffer_size)
|
||||||
{
|
{
|
||||||
return min(PAGE_SIZE, buffer_size);
|
return min(PAGE_SIZE, buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "CharacterDevice.h"
|
#include "CharacterDevice.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class NullDevice final : public CharacterDevice {
|
class NullDevice final : public CharacterDevice {
|
||||||
AK_MAKE_ETERNAL
|
AK_MAKE_ETERNAL
|
||||||
public:
|
public:
|
||||||
|
@ -44,3 +46,5 @@ private:
|
||||||
virtual bool can_read(const FileDescription&) const override;
|
virtual bool can_read(const FileDescription&) const override;
|
||||||
virtual const char* class_name() const override { return "NullDevice"; }
|
virtual const char* class_name() const override { return "NullDevice"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
#include <LibBareMetal/IO.h>
|
#include <LibBareMetal/IO.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define PATA_PRIMARY_IRQ 14
|
#define PATA_PRIMARY_IRQ 14
|
||||||
#define PATA_SECONDARY_IRQ 15
|
#define PATA_SECONDARY_IRQ 15
|
||||||
|
|
||||||
|
@ -533,3 +535,5 @@ bool PATAChannel::ata_write_sectors(u32 start_sector, u16 count, const u8* inbuf
|
||||||
|
|
||||||
return !m_device_error;
|
return !m_device_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
#include <Kernel/WaitQueue.h>
|
#include <Kernel/WaitQueue.h>
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
struct PhysicalRegionDescriptor {
|
struct PhysicalRegionDescriptor {
|
||||||
PhysicalAddress offset;
|
PhysicalAddress offset;
|
||||||
u16 size { 0 };
|
u16 size { 0 };
|
||||||
|
@ -100,3 +102,5 @@ private:
|
||||||
RefPtr<PATADiskDevice> m_master;
|
RefPtr<PATADiskDevice> m_master;
|
||||||
RefPtr<PATADiskDevice> m_slave;
|
RefPtr<PATADiskDevice> m_slave;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/Devices/PATADiskDevice.h>
|
#include <Kernel/Devices/PATADiskDevice.h>
|
||||||
#include <Kernel/FileSystem/FileDescription.h>
|
#include <Kernel/FileSystem/FileDescription.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(PATAChannel& channel, DriveType type, int major, int minor)
|
NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(PATAChannel& channel, DriveType type, int major, int minor)
|
||||||
{
|
{
|
||||||
return adopt(*new PATADiskDevice(channel, type, major, minor));
|
return adopt(*new PATADiskDevice(channel, type, major, minor));
|
||||||
|
@ -187,3 +189,5 @@ bool PATADiskDevice::is_slave() const
|
||||||
{
|
{
|
||||||
return m_drive_type == DriveType::Slave;
|
return m_drive_type == DriveType::Slave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include <Kernel/IRQHandler.h>
|
#include <Kernel/IRQHandler.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class PATAChannel;
|
class PATAChannel;
|
||||||
|
|
||||||
class PATADiskDevice final : public BlockDevice {
|
class PATADiskDevice final : public BlockDevice {
|
||||||
|
@ -86,3 +88,5 @@ private:
|
||||||
|
|
||||||
PATAChannel& m_channel;
|
PATAChannel& m_channel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <Kernel/Devices/VMWareBackdoor.h>
|
#include <Kernel/Devices/VMWareBackdoor.h>
|
||||||
#include <LibBareMetal/IO.h>
|
#include <LibBareMetal/IO.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define IRQ_MOUSE 12
|
#define IRQ_MOUSE 12
|
||||||
#define I8042_BUFFER 0x60
|
#define I8042_BUFFER 0x60
|
||||||
#define I8042_STATUS 0x64
|
#define I8042_STATUS 0x64
|
||||||
|
@ -383,3 +385,5 @@ ssize_t PS2MouseDevice::write(FileDescription&, const u8*, ssize_t)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <Kernel/IRQHandler.h>
|
#include <Kernel/IRQHandler.h>
|
||||||
#include <Kernel/MousePacket.h>
|
#include <Kernel/MousePacket.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class PS2MouseDevice final : public IRQHandler
|
class PS2MouseDevice final : public IRQHandler
|
||||||
, public CharacterDevice {
|
, public CharacterDevice {
|
||||||
public:
|
public:
|
||||||
|
@ -71,3 +73,5 @@ private:
|
||||||
u8 m_data[4];
|
u8 m_data[4];
|
||||||
bool m_has_wheel { false };
|
bool m_has_wheel { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <Kernel/Devices/RandomDevice.h>
|
#include <Kernel/Devices/RandomDevice.h>
|
||||||
#include <Kernel/Random.h>
|
#include <Kernel/Random.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
RandomDevice::RandomDevice()
|
RandomDevice::RandomDevice()
|
||||||
: CharacterDevice(1, 8)
|
: CharacterDevice(1, 8)
|
||||||
{
|
{
|
||||||
|
@ -52,3 +54,5 @@ ssize_t RandomDevice::write(FileDescription&, const u8*, ssize_t size)
|
||||||
// FIXME: Use input for entropy? I guess that could be a neat feature?
|
// FIXME: Use input for entropy? I guess that could be a neat feature?
|
||||||
return min(PAGE_SIZE, size);
|
return min(PAGE_SIZE, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "CharacterDevice.h"
|
#include "CharacterDevice.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class RandomDevice final : public CharacterDevice {
|
class RandomDevice final : public CharacterDevice {
|
||||||
AK_MAKE_ETERNAL
|
AK_MAKE_ETERNAL
|
||||||
public:
|
public:
|
||||||
|
@ -42,3 +44,5 @@ private:
|
||||||
virtual bool can_write(const FileDescription&) const override { return true; }
|
virtual bool can_write(const FileDescription&) const override { return true; }
|
||||||
virtual const char* class_name() const override { return "RandomDevice"; }
|
virtual const char* class_name() const override { return "RandomDevice"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
//#define SB16_DEBUG
|
//#define SB16_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
enum class SampleFormat : u8 {
|
enum class SampleFormat : u8 {
|
||||||
Signed = 0x10,
|
Signed = 0x10,
|
||||||
Stereo = 0x20,
|
Stereo = 0x20,
|
||||||
|
@ -215,3 +217,5 @@ ssize_t SB16::write(FileDescription&, const u8* data, ssize_t length)
|
||||||
wait_for_irq();
|
wait_for_irq();
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,13 +26,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/CircularQueue.h>
|
|
||||||
#include <Kernel/Devices/CharacterDevice.h>
|
#include <Kernel/Devices/CharacterDevice.h>
|
||||||
#include <Kernel/IRQHandler.h>
|
#include <Kernel/IRQHandler.h>
|
||||||
#include <Kernel/VM/PhysicalPage.h>
|
#include <Kernel/VM/PhysicalPage.h>
|
||||||
#include <Kernel/WaitQueue.h>
|
#include <Kernel/WaitQueue.h>
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class SB16;
|
class SB16;
|
||||||
|
|
||||||
class SB16 final : public IRQHandler
|
class SB16 final : public IRQHandler
|
||||||
|
@ -68,3 +69,5 @@ private:
|
||||||
|
|
||||||
WaitQueue m_irq_queue;
|
WaitQueue m_irq_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <Kernel/Devices/SerialDevice.h>
|
#include <Kernel/Devices/SerialDevice.h>
|
||||||
#include <LibBareMetal/IO.h>
|
#include <LibBareMetal/IO.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
SerialDevice::SerialDevice(int base_addr, unsigned minor)
|
SerialDevice::SerialDevice(int base_addr, unsigned minor)
|
||||||
: CharacterDevice(4, minor)
|
: CharacterDevice(4, minor)
|
||||||
, m_base_addr(base_addr)
|
, m_base_addr(base_addr)
|
||||||
|
@ -134,3 +136,5 @@ char SerialDevice::get_line_status() const
|
||||||
{
|
{
|
||||||
return IO::in8(m_base_addr + 5);
|
return IO::in8(m_base_addr + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <Kernel/Devices/CharacterDevice.h>
|
#include <Kernel/Devices/CharacterDevice.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define SERIAL_COM1_ADDR 0x3F8
|
#define SERIAL_COM1_ADDR 0x3F8
|
||||||
#define SERIAL_COM2_ADDR 0x2F8
|
#define SERIAL_COM2_ADDR 0x2F8
|
||||||
#define SERIAL_COM3_ADDR 0x3E8
|
#define SERIAL_COM3_ADDR 0x3E8
|
||||||
|
@ -144,3 +146,5 @@ private:
|
||||||
bool m_break_enable;
|
bool m_break_enable;
|
||||||
char m_modem_control;
|
char m_modem_control;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/Devices/VMWareBackdoor.h>
|
#include <Kernel/Devices/VMWareBackdoor.h>
|
||||||
#include <LibBareMetal/IO.h>
|
#include <LibBareMetal/IO.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define VMWARE_CMD_GETVERSION 0x0a
|
#define VMWARE_CMD_GETVERSION 0x0a
|
||||||
|
|
||||||
#define VMMOUSE_READ_ID 0x45414552
|
#define VMMOUSE_READ_ID 0x45414552
|
||||||
|
@ -202,3 +204,5 @@ void VMWareBackdoor::send(VMWareCommand& command)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define VMMOUSE_GETVERSION 10
|
#define VMMOUSE_GETVERSION 10
|
||||||
#define VMMOUSE_DATA 39
|
#define VMMOUSE_DATA 39
|
||||||
#define VMMOUSE_STATUS 40
|
#define VMMOUSE_STATUS 40
|
||||||
|
@ -73,3 +75,5 @@ private:
|
||||||
bool m_supported;
|
bool m_supported;
|
||||||
bool m_vmmouse_absolute { false };
|
bool m_vmmouse_absolute { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include "ZeroDevice.h"
|
#include "ZeroDevice.h"
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
ZeroDevice::ZeroDevice()
|
ZeroDevice::ZeroDevice()
|
||||||
: CharacterDevice(1, 5)
|
: CharacterDevice(1, 5)
|
||||||
{
|
{
|
||||||
|
@ -52,3 +54,5 @@ ssize_t ZeroDevice::write(FileDescription&, const u8*, ssize_t size)
|
||||||
{
|
{
|
||||||
return min(PAGE_SIZE, size);
|
return min(PAGE_SIZE, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "CharacterDevice.h"
|
#include "CharacterDevice.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class ZeroDevice final : public CharacterDevice {
|
class ZeroDevice final : public CharacterDevice {
|
||||||
AK_MAKE_ETERNAL
|
AK_MAKE_ETERNAL
|
||||||
public:
|
public:
|
||||||
|
@ -42,3 +44,5 @@ private:
|
||||||
virtual bool can_write(const FileDescription&) const override { return true; }
|
virtual bool can_write(const FileDescription&) const override { return true; }
|
||||||
virtual const char* class_name() const override { return "ZeroDevice"; }
|
virtual const char* class_name() const override { return "ZeroDevice"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <Kernel/DoubleBuffer.h>
|
#include <Kernel/DoubleBuffer.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
inline void DoubleBuffer::compute_lockfree_metadata()
|
inline void DoubleBuffer::compute_lockfree_metadata()
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
|
@ -85,3 +87,5 @@ ssize_t DoubleBuffer::read(u8* data, ssize_t size)
|
||||||
compute_lockfree_metadata();
|
compute_lockfree_metadata();
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/KBuffer.h>
|
#include <Kernel/KBuffer.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class DoubleBuffer {
|
class DoubleBuffer {
|
||||||
public:
|
public:
|
||||||
explicit DoubleBuffer(size_t capacity = 65536);
|
explicit DoubleBuffer(size_t capacity = 65536);
|
||||||
|
@ -62,3 +64,5 @@ private:
|
||||||
bool m_empty { true };
|
bool m_empty { true };
|
||||||
mutable Lock m_lock { "DoubleBuffer" };
|
mutable Lock m_lock { "DoubleBuffer" };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/FileSystem/Inode.h>
|
#include <Kernel/FileSystem/Inode.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static Lockable<InlineLinkedList<Custody>>& all_custodies()
|
static Lockable<InlineLinkedList<Custody>>& all_custodies()
|
||||||
{
|
{
|
||||||
static Lockable<InlineLinkedList<Custody>>* list;
|
static Lockable<InlineLinkedList<Custody>>* list;
|
||||||
|
@ -109,3 +111,5 @@ void Custody::did_rename(Badge<VFS>, const String& name)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class Inode;
|
class Inode;
|
||||||
class VFS;
|
class VFS;
|
||||||
|
|
||||||
|
@ -79,3 +81,5 @@ private:
|
||||||
bool m_mounted_on { false };
|
bool m_mounted_on { false };
|
||||||
int m_mount_flags { 0 };
|
int m_mount_flags { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
#include <Kernel/TTY/SlavePTY.h>
|
#include <Kernel/TTY/SlavePTY.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
NonnullRefPtr<DevPtsFS> DevPtsFS::create()
|
NonnullRefPtr<DevPtsFS> DevPtsFS::create()
|
||||||
{
|
{
|
||||||
return adopt(*new DevPtsFS);
|
return adopt(*new DevPtsFS);
|
||||||
|
@ -206,3 +208,5 @@ KResult DevPtsFSInode::chown(uid_t, gid_t)
|
||||||
{
|
{
|
||||||
return KResult(-EPERM);
|
return KResult(-EPERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/FileSystem/FileSystem.h>
|
#include <Kernel/FileSystem/FileSystem.h>
|
||||||
#include <Kernel/FileSystem/Inode.h>
|
#include <Kernel/FileSystem/Inode.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class SlavePTY;
|
class SlavePTY;
|
||||||
class DevPtsFSInode;
|
class DevPtsFSInode;
|
||||||
|
|
||||||
|
@ -57,6 +59,7 @@ private:
|
||||||
|
|
||||||
class DevPtsFSInode final : public Inode {
|
class DevPtsFSInode final : public Inode {
|
||||||
friend class DevPtsFS;
|
friend class DevPtsFS;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DevPtsFSInode() override;
|
virtual ~DevPtsFSInode() override;
|
||||||
|
|
||||||
|
@ -78,3 +81,5 @@ private:
|
||||||
|
|
||||||
InodeMetadata m_metadata;
|
InodeMetadata m_metadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
//#define DBFS_DEBUG
|
//#define DBFS_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
struct CacheEntry {
|
struct CacheEntry {
|
||||||
time_t timestamp { 0 };
|
time_t timestamp { 0 };
|
||||||
u32 block_index { 0 };
|
u32 block_index { 0 };
|
||||||
|
@ -240,3 +242,5 @@ DiskCache& DiskBackedFS::cache() const
|
||||||
m_cache = make<DiskCache>(const_cast<DiskBackedFS&>(*this));
|
m_cache = make<DiskCache>(const_cast<DiskBackedFS&>(*this));
|
||||||
return *m_cache;
|
return *m_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class DiskCache;
|
class DiskCache;
|
||||||
|
|
||||||
class DiskBackedFS : public FS {
|
class DiskBackedFS : public FS {
|
||||||
|
@ -60,3 +62,5 @@ private:
|
||||||
NonnullRefPtr<BlockDevice> m_device;
|
NonnullRefPtr<BlockDevice> m_device;
|
||||||
mutable OwnPtr<DiskCache> m_cache;
|
mutable OwnPtr<DiskCache> m_cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
//#define EXT2_DEBUG
|
//#define EXT2_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static const size_t max_link_count = 65535;
|
static const size_t max_link_count = 65535;
|
||||||
static const size_t max_block_size = 4096;
|
static const size_t max_block_size = 4096;
|
||||||
static const ssize_t max_inline_symlink_length = 60;
|
static const ssize_t max_inline_symlink_length = 60;
|
||||||
|
@ -573,7 +575,7 @@ InodeMetadata Ext2FSInode::metadata() const
|
||||||
metadata.block_size = fs().block_size();
|
metadata.block_size = fs().block_size();
|
||||||
metadata.block_count = m_raw_inode.i_blocks;
|
metadata.block_count = m_raw_inode.i_blocks;
|
||||||
|
|
||||||
if (::is_character_device(m_raw_inode.i_mode) || ::is_block_device(m_raw_inode.i_mode)) {
|
if (Kernel::is_character_device(m_raw_inode.i_mode) || Kernel::is_block_device(m_raw_inode.i_mode)) {
|
||||||
unsigned dev = m_raw_inode.i_block[0];
|
unsigned dev = m_raw_inode.i_block[0];
|
||||||
if (!dev)
|
if (!dev)
|
||||||
dev = m_raw_inode.i_block[1];
|
dev = m_raw_inode.i_block[1];
|
||||||
|
@ -1646,3 +1648,5 @@ KResult Ext2FS::prepare_to_unmount() const
|
||||||
m_inode_cache.clear();
|
m_inode_cache.clear();
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -27,16 +27,18 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Bitmap.h>
|
#include <AK/Bitmap.h>
|
||||||
#include <Kernel/KBuffer.h>
|
|
||||||
#include <Kernel/FileSystem/DiskBackedFileSystem.h>
|
#include <Kernel/FileSystem/DiskBackedFileSystem.h>
|
||||||
#include <Kernel/FileSystem/Inode.h>
|
#include <Kernel/FileSystem/Inode.h>
|
||||||
#include <Kernel/FileSystem/ext2_fs.h>
|
#include <Kernel/FileSystem/ext2_fs.h>
|
||||||
|
#include <Kernel/KBuffer.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
|
|
||||||
struct ext2_group_desc;
|
struct ext2_group_desc;
|
||||||
struct ext2_inode;
|
struct ext2_inode;
|
||||||
struct ext2_super_block;
|
struct ext2_super_block;
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class Ext2FS;
|
class Ext2FS;
|
||||||
|
|
||||||
class Ext2FSInode final : public Inode {
|
class Ext2FSInode final : public Inode {
|
||||||
|
@ -46,8 +48,8 @@ public:
|
||||||
virtual ~Ext2FSInode() override;
|
virtual ~Ext2FSInode() override;
|
||||||
|
|
||||||
size_t size() const { return m_raw_inode.i_size; }
|
size_t size() const { return m_raw_inode.i_size; }
|
||||||
bool is_symlink() const { return ::is_symlink(m_raw_inode.i_mode); }
|
bool is_symlink() const { return Kernel::is_symlink(m_raw_inode.i_mode); }
|
||||||
bool is_directory() const { return ::is_directory(m_raw_inode.i_mode); }
|
bool is_directory() const { return Kernel::is_directory(m_raw_inode.i_mode); }
|
||||||
|
|
||||||
// ^Inode (RefCounted magic)
|
// ^Inode (RefCounted magic)
|
||||||
virtual void one_ref_left() override;
|
virtual void one_ref_left() override;
|
||||||
|
@ -171,7 +173,8 @@ private:
|
||||||
CachedBitmap(BlockIndex bi, KBuffer&& buf)
|
CachedBitmap(BlockIndex bi, KBuffer&& buf)
|
||||||
: bitmap_block_index(bi)
|
: bitmap_block_index(bi)
|
||||||
, buffer(move(buf))
|
, buffer(move(buf))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
BlockIndex bitmap_block_index { 0 };
|
BlockIndex bitmap_block_index { 0 };
|
||||||
bool dirty { false };
|
bool dirty { false };
|
||||||
KBuffer buffer;
|
KBuffer buffer;
|
||||||
|
@ -192,3 +195,5 @@ inline const Ext2FS& Ext2FSInode::fs() const
|
||||||
{
|
{
|
||||||
return static_cast<const Ext2FS&>(Inode::fs());
|
return static_cast<const Ext2FS&>(Inode::fs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
//#define FIFO_DEBUG
|
//#define FIFO_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
Lockable<HashTable<FIFO*>>& all_fifos()
|
Lockable<HashTable<FIFO*>>& all_fifos()
|
||||||
{
|
{
|
||||||
static Lockable<HashTable<FIFO*>>* s_table;
|
static Lockable<HashTable<FIFO*>>* s_table;
|
||||||
|
@ -143,3 +145,5 @@ String FIFO::absolute_path(const FileDescription&) const
|
||||||
{
|
{
|
||||||
return String::format("fifo:%u", m_fifo_id);
|
return String::format("fifo:%u", m_fifo_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/FileSystem/File.h>
|
#include <Kernel/FileSystem/File.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class FileDescription;
|
class FileDescription;
|
||||||
|
|
||||||
class FIFO final : public File {
|
class FIFO final : public File {
|
||||||
|
@ -70,3 +72,5 @@ private:
|
||||||
|
|
||||||
int m_fifo_id { 0 };
|
int m_fifo_id { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <Kernel/FileSystem/File.h>
|
#include <Kernel/FileSystem/File.h>
|
||||||
#include <Kernel/FileSystem/FileDescription.h>
|
#include <Kernel/FileSystem/FileDescription.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
File::File()
|
File::File()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -56,3 +58,5 @@ KResultOr<Region*> File::mmap(Process&, FileDescription&, VirtualAddress, size_t
|
||||||
{
|
{
|
||||||
return KResult(-ENODEV);
|
return KResult(-ENODEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
#include <LibBareMetal/Memory/VirtualAddress.h>
|
#include <LibBareMetal/Memory/VirtualAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class FileDescription;
|
class FileDescription;
|
||||||
class Process;
|
class Process;
|
||||||
class Region;
|
class Region;
|
||||||
|
@ -102,3 +104,5 @@ public:
|
||||||
protected:
|
protected:
|
||||||
File();
|
File();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
NonnullRefPtr<FileDescription> FileDescription::create(Custody& custody)
|
NonnullRefPtr<FileDescription> FileDescription::create(Custody& custody)
|
||||||
{
|
{
|
||||||
auto description = adopt(*new FileDescription(InodeFile::create(custody.inode())));
|
auto description = adopt(*new FileDescription(InodeFile::create(custody.inode())));
|
||||||
|
@ -170,7 +172,6 @@ ByteBuffer FileDescription::read_entire_file()
|
||||||
return m_inode->read_entire(this);
|
return m_inode->read_entire(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size)
|
ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size)
|
||||||
{
|
{
|
||||||
LOCKER(m_lock);
|
LOCKER(m_lock);
|
||||||
|
@ -340,3 +341,5 @@ KResult FileDescription::chown(uid_t uid, gid_t gid)
|
||||||
LOCKER(m_lock);
|
LOCKER(m_lock);
|
||||||
return m_file->chown(uid, gid);
|
return m_file->chown(uid, gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,22 +28,23 @@
|
||||||
|
|
||||||
#include <AK/Badge.h>
|
#include <AK/Badge.h>
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
#include <AK/CircularQueue.h>
|
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <Kernel/FileSystem/FIFO.h>
|
#include <Kernel/FileSystem/FIFO.h>
|
||||||
#include <Kernel/FileSystem/Inode.h>
|
#include <Kernel/FileSystem/Inode.h>
|
||||||
#include <Kernel/FileSystem/InodeMetadata.h>
|
#include <Kernel/FileSystem/InodeMetadata.h>
|
||||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
#include <Kernel/KBuffer.h>
|
#include <Kernel/KBuffer.h>
|
||||||
#include <Kernel/Net/Socket.h>
|
|
||||||
#include <LibBareMetal/Memory/VirtualAddress.h>
|
#include <LibBareMetal/Memory/VirtualAddress.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
|
class CharacterDevice;
|
||||||
class File;
|
class File;
|
||||||
class TTY;
|
|
||||||
class MasterPTY;
|
class MasterPTY;
|
||||||
class Process;
|
class Process;
|
||||||
class Region;
|
class Region;
|
||||||
class CharacterDevice;
|
class Socket;
|
||||||
|
class TTY;
|
||||||
|
|
||||||
class FileDescription : public RefCounted<FileDescription> {
|
class FileDescription : public RefCounted<FileDescription> {
|
||||||
public:
|
public:
|
||||||
|
@ -161,3 +162,5 @@ private:
|
||||||
|
|
||||||
Lock m_lock { "FileDescription" };
|
Lock m_lock { "FileDescription" };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static u32 s_lastFileSystemID;
|
static u32 s_lastFileSystemID;
|
||||||
static HashMap<u32, FS*>* s_fs_map;
|
static HashMap<u32, FS*>* s_fs_map;
|
||||||
|
|
||||||
|
@ -111,3 +113,5 @@ void FS::set_block_size(int block_size)
|
||||||
return;
|
return;
|
||||||
m_block_size = block_size;
|
m_block_size = block_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static const u32 mepoch = 476763780;
|
static const u32 mepoch = 476763780;
|
||||||
|
|
||||||
class Inode;
|
class Inode;
|
||||||
|
@ -122,11 +124,13 @@ inline bool InodeIdentifier::is_root_inode() const
|
||||||
return (*this) == fs()->root_inode();
|
return (*this) == fs()->root_inode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct Traits<InodeIdentifier> : public GenericTraits<InodeIdentifier> {
|
struct Traits<Kernel::InodeIdentifier> : public GenericTraits<Kernel::InodeIdentifier> {
|
||||||
static unsigned hash(const InodeIdentifier& inode) { return pair_int_hash(inode.fsid(), inode.index()); }
|
static unsigned hash(const Kernel::InodeIdentifier& inode) { return pair_int_hash(inode.fsid(), inode.index()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
#include <Kernel/FileSystem/Custody.h>
|
#include <Kernel/FileSystem/Custody.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
InlineLinkedList<Inode>& all_inodes()
|
InlineLinkedList<Inode>& all_inodes()
|
||||||
{
|
{
|
||||||
static InlineLinkedList<Inode>* list;
|
static InlineLinkedList<Inode>* list;
|
||||||
|
@ -213,3 +215,5 @@ void Inode::set_metadata_dirty(bool metadata_dirty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/String.h>
|
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/InlineLinkedList.h>
|
#include <AK/InlineLinkedList.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/WeakPtr.h>
|
#include <AK/WeakPtr.h>
|
||||||
#include <Kernel/FileSystem/FileSystem.h>
|
#include <Kernel/FileSystem/FileSystem.h>
|
||||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||||
|
@ -37,6 +37,8 @@
|
||||||
#include <Kernel/KResult.h>
|
#include <Kernel/KResult.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class FileDescription;
|
class FileDescription;
|
||||||
class InodeVMObject;
|
class InodeVMObject;
|
||||||
class InodeWatcher;
|
class InodeWatcher;
|
||||||
|
@ -132,3 +134,5 @@ private:
|
||||||
HashTable<InodeWatcher*> m_watchers;
|
HashTable<InodeWatcher*> m_watchers;
|
||||||
bool m_metadata_dirty { false };
|
bool m_metadata_dirty { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
InodeFile::InodeFile(NonnullRefPtr<Inode>&& inode)
|
InodeFile::InodeFile(NonnullRefPtr<Inode>&& inode)
|
||||||
: m_inode(move(inode))
|
: m_inode(move(inode))
|
||||||
{
|
{
|
||||||
|
@ -94,3 +96,5 @@ KResult InodeFile::chmod(mode_t mode)
|
||||||
{
|
{
|
||||||
return VFS::the().chmod(*m_inode, mode);
|
return VFS::the().chmod(*m_inode, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <Kernel/FileSystem/File.h>
|
#include <Kernel/FileSystem/File.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class Inode;
|
class Inode;
|
||||||
|
|
||||||
class InodeFile final : public File {
|
class InodeFile final : public File {
|
||||||
|
@ -64,3 +66,5 @@ private:
|
||||||
explicit InodeFile(NonnullRefPtr<Inode>&&);
|
explicit InodeFile(NonnullRefPtr<Inode>&&);
|
||||||
NonnullRefPtr<Inode> m_inode;
|
NonnullRefPtr<Inode> m_inode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,10 +26,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/String.h>
|
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class FS;
|
class FS;
|
||||||
struct InodeMetadata;
|
struct InodeMetadata;
|
||||||
|
|
||||||
|
@ -75,3 +77,4 @@ inline const LogStream& operator<<(const LogStream& stream, const InodeIdentifie
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <Kernel/KResult.h>
|
#include <Kernel/KResult.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class Process;
|
class Process;
|
||||||
|
|
||||||
inline constexpr u32 encoded_device(unsigned major, unsigned minor)
|
inline constexpr u32 encoded_device(unsigned major, unsigned minor)
|
||||||
|
@ -89,17 +91,17 @@ struct InodeMetadata {
|
||||||
return mode & 0001;
|
return mode & 0001;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_directory() const { return ::is_directory(mode); }
|
bool is_directory() const { return Kernel::is_directory(mode); }
|
||||||
bool is_character_device() const { return ::is_character_device(mode); }
|
bool is_character_device() const { return Kernel::is_character_device(mode); }
|
||||||
bool is_block_device() const { return ::is_block_device(mode); }
|
bool is_block_device() const { return Kernel::is_block_device(mode); }
|
||||||
bool is_device() const { return is_character_device() || is_block_device(); }
|
bool is_device() const { return is_character_device() || is_block_device(); }
|
||||||
bool is_regular_file() const { return ::is_regular_file(mode); }
|
bool is_regular_file() const { return Kernel::is_regular_file(mode); }
|
||||||
bool is_fifo() const { return ::is_fifo(mode); }
|
bool is_fifo() const { return Kernel::is_fifo(mode); }
|
||||||
bool is_symlink() const { return ::is_symlink(mode); }
|
bool is_symlink() const { return Kernel::is_symlink(mode); }
|
||||||
bool is_socket() const { return ::is_socket(mode); }
|
bool is_socket() const { return Kernel::is_socket(mode); }
|
||||||
bool is_sticky() const { return ::is_sticky(mode); }
|
bool is_sticky() const { return Kernel::is_sticky(mode); }
|
||||||
bool is_setuid() const { return ::is_setuid(mode); }
|
bool is_setuid() const { return Kernel::is_setuid(mode); }
|
||||||
bool is_setgid() const { return ::is_setgid(mode); }
|
bool is_setgid() const { return Kernel::is_setgid(mode); }
|
||||||
|
|
||||||
KResult stat(stat& buffer) const
|
KResult stat(stat& buffer) const
|
||||||
{
|
{
|
||||||
|
@ -136,3 +138,5 @@ struct InodeMetadata {
|
||||||
unsigned major_device { 0 };
|
unsigned major_device { 0 };
|
||||||
unsigned minor_device { 0 };
|
unsigned minor_device { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <Kernel/FileSystem/Inode.h>
|
#include <Kernel/FileSystem/Inode.h>
|
||||||
#include <Kernel/FileSystem/InodeWatcher.h>
|
#include <Kernel/FileSystem/InodeWatcher.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
NonnullRefPtr<InodeWatcher> InodeWatcher::create(Inode& inode)
|
NonnullRefPtr<InodeWatcher> InodeWatcher::create(Inode& inode)
|
||||||
{
|
{
|
||||||
return adopt(*new InodeWatcher(inode));
|
return adopt(*new InodeWatcher(inode));
|
||||||
|
@ -84,3 +86,5 @@ void InodeWatcher::notify_inode_event(Badge<Inode>, Event::Type event_type)
|
||||||
{
|
{
|
||||||
m_queue.enqueue({ event_type });
|
m_queue.enqueue({ event_type });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <AK/WeakPtr.h>
|
#include <AK/WeakPtr.h>
|
||||||
#include <Kernel/FileSystem/File.h>
|
#include <Kernel/FileSystem/File.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class Inode;
|
class Inode;
|
||||||
|
|
||||||
class InodeWatcher final : public File {
|
class InodeWatcher final : public File {
|
||||||
|
@ -62,3 +64,5 @@ private:
|
||||||
WeakPtr<Inode> m_inode;
|
WeakPtr<Inode> m_inode;
|
||||||
CircularQueue<Event, 32> m_queue;
|
CircularQueue<Event, 32> m_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@
|
||||||
#include <LibBareMetal/StdLib.h>
|
#include <LibBareMetal/StdLib.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
enum ProcParentDirectory {
|
enum ProcParentDirectory {
|
||||||
PDI_AbstractRoot = 0,
|
PDI_AbstractRoot = 0,
|
||||||
PDI_Root,
|
PDI_Root,
|
||||||
|
@ -1219,7 +1221,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
|
||||||
dbgprintf("ProcFS: traverse_as_directory %u\n", index());
|
dbgprintf("ProcFS: traverse_as_directory %u\n", index());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!::is_directory(identifier()))
|
if (!Kernel::is_directory(identifier()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto pid = to_pid(identifier());
|
auto pid = to_pid(identifier());
|
||||||
|
@ -1622,3 +1624,5 @@ KResult ProcFSInode::chown(uid_t, gid_t)
|
||||||
{
|
{
|
||||||
return KResult(-EPERM);
|
return KResult(-EPERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <Kernel/KBuffer.h>
|
#include <Kernel/KBuffer.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class Process;
|
class Process;
|
||||||
|
|
||||||
class ProcFSInode;
|
class ProcFSInode;
|
||||||
|
@ -147,3 +149,5 @@ private:
|
||||||
|
|
||||||
NonnullRefPtr<FileDescription> m_fd;
|
NonnullRefPtr<FileDescription> m_fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
#include <Kernel/Thread.h>
|
#include <Kernel/Thread.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
NonnullRefPtr<TmpFS> TmpFS::create()
|
NonnullRefPtr<TmpFS> TmpFS::create()
|
||||||
{
|
{
|
||||||
return adopt(*new TmpFS);
|
return adopt(*new TmpFS);
|
||||||
|
@ -397,3 +399,5 @@ void TmpFSInode::one_ref_left()
|
||||||
// Destroy ourselves.
|
// Destroy ourselves.
|
||||||
fs().unregister_inode(identifier());
|
fs().unregister_inode(identifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <Kernel/FileSystem/Inode.h>
|
#include <Kernel/FileSystem/Inode.h>
|
||||||
#include <Kernel/KBuffer.h>
|
#include <Kernel/KBuffer.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class TmpFSInode;
|
class TmpFSInode;
|
||||||
|
|
||||||
class TmpFS final : public FS {
|
class TmpFS final : public FS {
|
||||||
|
@ -106,3 +108,5 @@ private:
|
||||||
};
|
};
|
||||||
HashMap<String, Child> m_children;
|
HashMap<String, Child> m_children;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -32,11 +32,14 @@
|
||||||
#include <Kernel/FileSystem/FileDescription.h>
|
#include <Kernel/FileSystem/FileDescription.h>
|
||||||
#include <Kernel/FileSystem/FileSystem.h>
|
#include <Kernel/FileSystem/FileSystem.h>
|
||||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
|
#include <Kernel/KSyms.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
//#define VFS_DEBUG
|
//#define VFS_DEBUG
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
static VFS* s_the;
|
static VFS* s_the;
|
||||||
static constexpr int symlink_recursion_limit { 5 }; // FIXME: increase?
|
static constexpr int symlink_recursion_limit { 5 }; // FIXME: increase?
|
||||||
|
|
||||||
|
@ -848,3 +851,5 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path(StringView path, Custody& ba
|
||||||
*out_parent = custody->parent();
|
*out_parent = custody->parent();
|
||||||
return custody;
|
return custody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <Kernel/FileSystem/InodeMetadata.h>
|
#include <Kernel/FileSystem/InodeMetadata.h>
|
||||||
#include <Kernel/KResult.h>
|
#include <Kernel/KResult.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define O_RDONLY (1 << 0)
|
#define O_RDONLY (1 << 0)
|
||||||
#define O_WRONLY (1 << 1)
|
#define O_WRONLY (1 << 1)
|
||||||
|
@ -159,3 +160,5 @@ private:
|
||||||
|
|
||||||
RefPtr<Custody> m_root_custody;
|
RefPtr<Custody> m_root_custody;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <Kernel/Heap/kmalloc.h>
|
#include <Kernel/Heap/kmalloc.h>
|
||||||
#include <Kernel/VM/Region.h>
|
#include <Kernel/VM/Region.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
template<size_t templated_slab_size>
|
template<size_t templated_slab_size>
|
||||||
class SlabAllocator {
|
class SlabAllocator {
|
||||||
public:
|
public:
|
||||||
|
@ -160,3 +162,5 @@ void slab_alloc_stats(Function<void(size_t slab_size, size_t allocated, size_t f
|
||||||
callback(allocator.slab_size(), allocator.num_allocated(), allocator.num_free());
|
callback(allocator.slab_size(), allocator.num_allocated(), allocator.num_free());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
#define SLAB_ALLOC_SCRUB_BYTE 0xab
|
#define SLAB_ALLOC_SCRUB_BYTE 0xab
|
||||||
#define SLAB_DEALLOC_SCRUB_BYTE 0xbc
|
#define SLAB_DEALLOC_SCRUB_BYTE 0xbc
|
||||||
|
|
||||||
|
@ -43,3 +45,5 @@ public: \
|
||||||
void operator delete(void* ptr) { slab_dealloc(ptr, sizeof(type)); } \
|
void operator delete(void* ptr) { slab_dealloc(ptr, sizeof(type)); } \
|
||||||
\
|
\
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -112,21 +112,21 @@ void* kmalloc_page_aligned(size_t size)
|
||||||
|
|
||||||
void* kmalloc_impl(size_t size)
|
void* kmalloc_impl(size_t size)
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
Kernel::InterruptDisabler disabler;
|
||||||
++g_kmalloc_call_count;
|
++g_kmalloc_call_count;
|
||||||
|
|
||||||
if (g_dump_kmalloc_stacks && ksyms_ready) {
|
if (g_dump_kmalloc_stacks && Kernel::ksyms_ready) {
|
||||||
dbgprintf("kmalloc(%u)\n", size);
|
dbgprintf("kmalloc(%u)\n", size);
|
||||||
dump_backtrace();
|
Kernel::dump_backtrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need space for the allocation_t structure at the head of the block.
|
// We need space for the allocation_t structure at the head of the block.
|
||||||
size_t real_size = size + sizeof(allocation_t);
|
size_t real_size = size + sizeof(allocation_t);
|
||||||
|
|
||||||
if (sum_free < real_size) {
|
if (sum_free < real_size) {
|
||||||
dump_backtrace();
|
Kernel::dump_backtrace();
|
||||||
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%u\n", current->process().name().characters(), current->pid(), sum_free, real_size);
|
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%u\n", Kernel::current->process().name().characters(), Kernel::current->pid(), sum_free, real_size);
|
||||||
hang();
|
Kernel::hang();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t chunks_needed = real_size / CHUNK_SIZE;
|
size_t chunks_needed = real_size / CHUNK_SIZE;
|
||||||
|
@ -177,9 +177,9 @@ void* kmalloc_impl(size_t size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", current->process().name().characters(), current->pid(), size);
|
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", Kernel::current->process().name().characters(), Kernel::current->pid(), size);
|
||||||
dump_backtrace();
|
Kernel::dump_backtrace();
|
||||||
hang();
|
Kernel::hang();
|
||||||
}
|
}
|
||||||
|
|
||||||
void kfree(void* ptr)
|
void kfree(void* ptr)
|
||||||
|
@ -187,7 +187,7 @@ void kfree(void* ptr)
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InterruptDisabler disabler;
|
Kernel::InterruptDisabler disabler;
|
||||||
++g_kfree_call_count;
|
++g_kfree_call_count;
|
||||||
|
|
||||||
auto* a = (allocation_t*)((((u8*)ptr) - sizeof(allocation_t)));
|
auto* a = (allocation_t*)((((u8*)ptr) - sizeof(allocation_t)));
|
||||||
|
@ -208,7 +208,7 @@ void* krealloc(void* ptr, size_t new_size)
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return kmalloc(new_size);
|
return kmalloc(new_size);
|
||||||
|
|
||||||
InterruptDisabler disabler;
|
Kernel::InterruptDisabler disabler;
|
||||||
|
|
||||||
auto* a = (allocation_t*)((((u8*)ptr) - sizeof(allocation_t)));
|
auto* a = (allocation_t*)((((u8*)ptr) - sizeof(allocation_t)));
|
||||||
size_t old_size = a->nchunk * CHUNK_SIZE;
|
size_t old_size = a->nchunk * CHUNK_SIZE;
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <Kernel/Arch/i386/CPU.h>
|
#include <Kernel/Arch/i386/CPU.h>
|
||||||
#include <Kernel/Arch/i386/PIC.h>
|
#include <Kernel/Arch/i386/PIC.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
IRQHandler::IRQHandler(u8 irq)
|
IRQHandler::IRQHandler(u8 irq)
|
||||||
: m_irq_number(irq)
|
: m_irq_number(irq)
|
||||||
{
|
{
|
||||||
|
@ -48,3 +50,5 @@ void IRQHandler::disable_irq()
|
||||||
{
|
{
|
||||||
PIC::disable(m_irq_number);
|
PIC::disable(m_irq_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class IRQHandler {
|
class IRQHandler {
|
||||||
public:
|
public:
|
||||||
virtual ~IRQHandler();
|
virtual ~IRQHandler();
|
||||||
|
@ -44,3 +46,5 @@ protected:
|
||||||
private:
|
private:
|
||||||
u8 m_irq_number { 0 };
|
u8 m_irq_number { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
#include <Kernel/VM/Region.h>
|
#include <Kernel/VM/Region.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
class KBufferImpl : public RefCounted<KBufferImpl> {
|
class KBufferImpl : public RefCounted<KBufferImpl> {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<KBufferImpl> create_with_size(size_t size, u8 access, const char* name)
|
static NonnullRefPtr<KBufferImpl> create_with_size(size_t size, u8 access, const char* name)
|
||||||
|
@ -118,3 +120,5 @@ inline const LogStream& operator<<(const LogStream& stream, const KBuffer& value
|
||||||
{
|
{
|
||||||
return stream << StringView(value.data(), value.size());
|
return stream << StringView(value.data(), value.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue