1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:07:36 +00:00

Kernel: Move all code into the Kernel namespace

This commit is contained in:
Andreas Kling 2020-02-16 01:27:42 +01:00
parent d42f0f4661
commit a356e48150
201 changed files with 907 additions and 111 deletions

View file

@ -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
@ -182,3 +184,5 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
return -EINVAL;
};
}
}

View file

@ -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:
@ -62,3 +64,5 @@ private:
int m_framebuffer_height { 0 };
int m_y_offset { 0 };
};
}

View file

@ -26,6 +26,8 @@
#include <Kernel/Devices/BlockDevice.h>
namespace Kernel {
BlockDevice::~BlockDevice()
{
}
@ -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);
}
}

View file

@ -28,6 +28,8 @@
#include <Kernel/Devices/Device.h>
namespace Kernel {
class BlockDevice : public Device {
public:
virtual ~BlockDevice() override;
@ -55,3 +57,5 @@ private:
size_t m_block_size { 0 };
};
}

View file

@ -26,6 +26,10 @@
#include <Kernel/Devices/CharacterDevice.h>
namespace Kernel {
CharacterDevice::~CharacterDevice()
{
}
}

View file

@ -28,6 +28,8 @@
#include <Kernel/Devices/Device.h>
namespace Kernel {
class CharacterDevice : public Device {
public:
virtual ~CharacterDevice() override;
@ -41,3 +43,5 @@ protected:
private:
virtual bool is_character_device() const final { return true; }
};
}

View file

@ -27,6 +27,8 @@
#include <Kernel/Devices/DebugLogDevice.h>
#include <LibBareMetal/IO.h>
namespace Kernel {
static DebugLogDevice* s_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]);
return data_size;
}
}

View file

@ -26,6 +26,8 @@
#include <Kernel/Devices/CharacterDevice.h>
namespace Kernel {
class DebugLogDevice final : public CharacterDevice {
public:
DebugLogDevice();
@ -41,3 +43,5 @@ private:
virtual bool can_read(const FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "DebugLogDevice"; }
};
}

View file

@ -28,6 +28,8 @@
#include <Kernel/FileSystem/InodeMetadata.h>
#include <LibC/errno_numbers.h>
namespace Kernel {
static HashMap<u32, Device*>* s_all_devices;
HashMap<u32, Device*>& Device::all_devices()
@ -78,3 +80,5 @@ String Device::absolute_path(const FileDescription&) const
{
return absolute_path();
}
}

View file

@ -39,6 +39,8 @@
#include <Kernel/FileSystem/File.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {
class Device : public File {
public:
virtual ~Device() override;
@ -71,3 +73,5 @@ private:
uid_t m_uid { 0 };
gid_t m_gid { 0 };
};
}

View file

@ -28,6 +28,8 @@
// #define OFFD_DEBUG
namespace Kernel {
NonnullRefPtr<DiskPartition> DiskPartition::create(BlockDevice& device, unsigned block_offset, unsigned block_limit)
{
return adopt(*new DiskPartition(device, block_offset, block_limit));
@ -67,3 +69,5 @@ const char* DiskPartition::class_name() const
{
return "DiskPartition";
}
}

View file

@ -29,6 +29,8 @@
#include <AK/RefPtr.h>
#include <Kernel/Devices/BlockDevice.h>
namespace Kernel {
class DiskPartition final : public BlockDevice {
public:
static NonnullRefPtr<DiskPartition> create(BlockDevice&, unsigned block_offset, unsigned block_limit);
@ -52,3 +54,5 @@ private:
unsigned m_block_offset;
unsigned m_block_limit;
};
}

View file

@ -29,6 +29,8 @@
#define EBR_DEBUG
namespace Kernel {
EBRPartitionTable::EBRPartitionTable(NonnullRefPtr<BlockDevice> 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);
}
}

View file

@ -31,6 +31,8 @@
#include <Kernel/Devices/DiskPartition.h>
#include <Kernel/Devices/MBRPartitionTable.h>
namespace Kernel {
struct [[gnu::packed]] EBRPartitionExtension
{
u8 unused_area[446];
@ -65,3 +67,5 @@ private:
u8 m_cached_mbr_header[512];
u8 m_cached_ebr_header[512];
};
}

View file

@ -31,6 +31,8 @@
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/IO.h>
namespace Kernel {
// Uncomment me for a LOT of output
//#define FLOPPY_DEBUG
@ -561,3 +563,5 @@ void FloppyDiskDevice::initialize()
kprintf("fdc: fd%d initialised succesfully!\n", is_slave() ? 1 : 0);
#endif
}
}

View file

@ -104,6 +104,8 @@
#include <Kernel/VM/PhysicalPage.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
namespace Kernel {
struct FloppyControllerCommand {
u8 cmd; // Command to send to the controller
u8 numParams; // Number of parameters to send to the drive
@ -216,3 +218,5 @@ private:
u8 m_controller_version { 0 };
};
}

View file

@ -28,6 +28,8 @@
#include <AK/StdLibExtras.h>
#include <LibC/errno_numbers.h>
namespace Kernel {
FullDevice::FullDevice()
: CharacterDevice(1, 7)
{
@ -55,3 +57,5 @@ ssize_t FullDevice::write(FileDescription&, const u8*, ssize_t size)
return 0;
return -ENOSPC;
}
}

View file

@ -28,6 +28,8 @@
#include "CharacterDevice.h"
namespace Kernel {
class FullDevice final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
@ -42,3 +44,5 @@ private:
virtual bool can_write(const FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "FullDevice"; }
};
}

View file

@ -29,6 +29,8 @@
#define GPT_DEBUG
namespace Kernel {
GPTPartitionTable::GPTPartitionTable(BlockDevice& device)
: m_device(move(device))
{
@ -99,3 +101,5 @@ RefPtr<DiskPartition> GPTPartitionTable::partition(unsigned index)
#endif
return DiskPartition::create(m_device, entry.first_lba[0], entry.last_lba[0]);
}
}

View file

@ -31,6 +31,8 @@
#include <AK/Vector.h>
#include <Kernel/Devices/DiskPartition.h>
namespace Kernel {
#define GPT_SIGNATURE2 0x54524150
#define GPT_SIGNATURE 0x20494645
#define BytesPerSector 512
@ -85,3 +87,5 @@ private:
u8 m_cached_header[512];
};
}

View file

@ -34,6 +34,8 @@
//#define KEYBOARD_DEBUG
namespace Kernel {
#define IRQ_KEYBOARD 1
#define I8042_BUFFER 0x60
#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];
}
}
}

View file

@ -33,6 +33,8 @@
#include <AK/Types.h>
#include <Kernel/Devices/CharacterDevice.h>
namespace Kernel {
class KeyboardClient;
class KeyboardDevice final : public IRQHandler
@ -84,3 +86,5 @@ public:
virtual ~KeyboardClient();
virtual void on_key_pressed(KeyboardDevice::Event) = 0;
};
}

View file

@ -29,6 +29,8 @@
#define MBR_DEBUG
namespace Kernel {
MBRPartitionTable::MBRPartitionTable(NonnullRefPtr<BlockDevice> 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));
}
}

View file

@ -30,6 +30,8 @@
#include <AK/Vector.h>
#include <Kernel/Devices/DiskPartition.h>
namespace Kernel {
#define MBR_SIGNATURE 0xaa55
#define MBR_PROTECTIVE 0xEE
#define EBR_CHS_CONTAINER 0x05
@ -76,3 +78,5 @@ private:
u8 m_cached_header[512];
};
}

View file

@ -31,6 +31,8 @@
#include <LibC/errno_numbers.h>
#include <LibC/sys/ioctl_numbers.h>
namespace Kernel {
static MBVGADevice* s_the;
MBVGADevice& MBVGADevice::the()
@ -109,3 +111,5 @@ int MBVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
return -EINVAL;
};
}
}

View file

@ -31,6 +31,8 @@
#include <Kernel/Devices/BlockDevice.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
namespace Kernel {
class MBVGADevice final : public BlockDevice {
AK_MAKE_ETERNAL
public:
@ -57,3 +59,5 @@ private:
int m_framebuffer_width { 0 };
int m_framebuffer_height { 0 };
};
}

View file

@ -27,6 +27,8 @@
#include "NullDevice.h"
#include <AK/StdLibExtras.h>
namespace Kernel {
static NullDevice* s_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);
}
}

View file

@ -28,6 +28,8 @@
#include "CharacterDevice.h"
namespace Kernel {
class NullDevice final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
@ -44,3 +46,5 @@ private:
virtual bool can_read(const FileDescription&) const override;
virtual const char* class_name() const override { return "NullDevice"; }
};
}

View file

@ -32,6 +32,8 @@
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/IO.h>
namespace Kernel {
#define PATA_PRIMARY_IRQ 14
#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;
}
}

View file

@ -45,6 +45,8 @@
#include <Kernel/WaitQueue.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
namespace Kernel {
struct PhysicalRegionDescriptor {
PhysicalAddress offset;
u16 size { 0 };
@ -100,3 +102,5 @@ private:
RefPtr<PATADiskDevice> m_master;
RefPtr<PATADiskDevice> m_slave;
};
}

View file

@ -30,6 +30,8 @@
#include <Kernel/Devices/PATADiskDevice.h>
#include <Kernel/FileSystem/FileDescription.h>
namespace Kernel {
NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(PATAChannel& channel, DriveType type, int major, int minor)
{
return adopt(*new PATADiskDevice(channel, type, major, minor));
@ -187,3 +189,5 @@ bool PATADiskDevice::is_slave() const
{
return m_drive_type == DriveType::Slave;
}
}

View file

@ -34,6 +34,8 @@
#include <Kernel/IRQHandler.h>
#include <Kernel/Lock.h>
namespace Kernel {
class PATAChannel;
class PATADiskDevice final : public BlockDevice {
@ -86,3 +88,5 @@ private:
PATAChannel& m_channel;
};
}

View file

@ -28,6 +28,8 @@
#include <Kernel/Devices/VMWareBackdoor.h>
#include <LibBareMetal/IO.h>
namespace Kernel {
#define IRQ_MOUSE 12
#define I8042_BUFFER 0x60
#define I8042_STATUS 0x64
@ -383,3 +385,5 @@ ssize_t PS2MouseDevice::write(FileDescription&, const u8*, ssize_t)
{
return 0;
}
}

View file

@ -31,6 +31,8 @@
#include <Kernel/IRQHandler.h>
#include <Kernel/MousePacket.h>
namespace Kernel {
class PS2MouseDevice final : public IRQHandler
, public CharacterDevice {
public:
@ -71,3 +73,5 @@ private:
u8 m_data[4];
bool m_has_wheel { false };
};
}

View file

@ -27,6 +27,8 @@
#include <Kernel/Devices/RandomDevice.h>
#include <Kernel/Random.h>
namespace Kernel {
RandomDevice::RandomDevice()
: 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?
return min(PAGE_SIZE, size);
}
}

View file

@ -28,6 +28,8 @@
#include "CharacterDevice.h"
namespace Kernel {
class RandomDevice final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
@ -42,3 +44,5 @@ private:
virtual bool can_write(const FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "RandomDevice"; }
};
}

View file

@ -32,6 +32,8 @@
//#define SB16_DEBUG
namespace Kernel {
enum class SampleFormat : u8 {
Signed = 0x10,
Stereo = 0x20,
@ -215,3 +217,5 @@ ssize_t SB16::write(FileDescription&, const u8* data, ssize_t length)
wait_for_irq();
return length;
}
}

View file

@ -26,13 +26,14 @@
#pragma once
#include <AK/CircularQueue.h>
#include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/IRQHandler.h>
#include <Kernel/VM/PhysicalPage.h>
#include <Kernel/WaitQueue.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
namespace Kernel {
class SB16;
class SB16 final : public IRQHandler
@ -68,3 +69,5 @@ private:
WaitQueue m_irq_queue;
};
}

View file

@ -27,6 +27,8 @@
#include <Kernel/Devices/SerialDevice.h>
#include <LibBareMetal/IO.h>
namespace Kernel {
SerialDevice::SerialDevice(int base_addr, unsigned minor)
: CharacterDevice(4, minor)
, m_base_addr(base_addr)
@ -134,3 +136,5 @@ char SerialDevice::get_line_status() const
{
return IO::in8(m_base_addr + 5);
}
}

View file

@ -26,6 +26,8 @@
#include <Kernel/Devices/CharacterDevice.h>
namespace Kernel {
#define SERIAL_COM1_ADDR 0x3F8
#define SERIAL_COM2_ADDR 0x2F8
#define SERIAL_COM3_ADDR 0x3E8
@ -144,3 +146,5 @@ private:
bool m_break_enable;
char m_modem_control;
};
}

View file

@ -30,6 +30,8 @@
#include <Kernel/Devices/VMWareBackdoor.h>
#include <LibBareMetal/IO.h>
namespace Kernel {
#define VMWARE_CMD_GETVERSION 0x0a
#define VMMOUSE_READ_ID 0x45414552
@ -202,3 +204,5 @@ void VMWareBackdoor::send(VMWareCommand& command)
#endif
}
}
}

View file

@ -28,6 +28,8 @@
#include <AK/Types.h>
namespace Kernel {
#define VMMOUSE_GETVERSION 10
#define VMMOUSE_DATA 39
#define VMMOUSE_STATUS 40
@ -73,3 +75,5 @@ private:
bool m_supported;
bool m_vmmouse_absolute { false };
};
}

View file

@ -27,6 +27,8 @@
#include "ZeroDevice.h"
#include <AK/StdLibExtras.h>
namespace Kernel {
ZeroDevice::ZeroDevice()
: CharacterDevice(1, 5)
{
@ -52,3 +54,5 @@ ssize_t ZeroDevice::write(FileDescription&, const u8*, ssize_t size)
{
return min(PAGE_SIZE, size);
}
}

View file

@ -28,6 +28,8 @@
#include "CharacterDevice.h"
namespace Kernel {
class ZeroDevice final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
@ -42,3 +44,5 @@ private:
virtual bool can_write(const FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "ZeroDevice"; }
};
}