All: Cleanup all files

Add newline to end of files and remove whitespace from end of lines
This commit is contained in:
2024-01-24 14:43:46 +02:00
parent 3441f63298
commit dfe5a2d665
226 changed files with 466 additions and 460 deletions

View File

@@ -63,7 +63,7 @@ namespace Kernel::GDT
uint8_t flags : 4;
uint8_t base3;
} __attribute__((packed));
struct
{
uint32_t low;
@@ -101,7 +101,7 @@ namespace Kernel::GDT
{
s_tss = new TaskStateSegment();
ASSERT(s_tss);
memset(s_tss, 0x00, sizeof(TaskStateSegment));
s_tss->ss0 = 0x10;
s_tss->esp0 = (uintptr_t)g_boot_stack_top;
@@ -127,7 +127,7 @@ namespace Kernel::GDT
void initialize()
{
constexpr uint32_t descriptor_count = 6;
s_gdt = new SegmentDescriptor[descriptor_count];
s_gdt = new SegmentDescriptor[descriptor_count];
ASSERT(s_gdt);
s_gdtr.address = (uint64_t)s_gdt;
@@ -144,4 +144,4 @@ namespace Kernel::GDT
flush_tss(0x28);
}
}
}

View File

@@ -123,7 +123,7 @@ namespace IDT
}
dprintln("Spurious irq");
return;
return;
found:
if (s_irq_handlers[irq])
s_irq_handlers[irq]();
@@ -174,7 +174,7 @@ found:
"addl $16, %esp;"
"popw %es;"
"popw %ds;"
// NOTE: following instructions are same as in 'popa', except we skip eax
// since it holds the return value of the syscall.
"popl %edi;"
@@ -185,7 +185,7 @@ found:
"popl %edx;"
"popl %ecx;"
"addl $4, %esp;"
"iret;"
);
@@ -267,4 +267,4 @@ found:
flush_idt();
}
}
}

View File

@@ -76,7 +76,7 @@ namespace Kernel
{
if (s_instance == nullptr)
return;
// Here we copy the s_instances paging structs since they are
// global for every process
@@ -84,7 +84,7 @@ namespace Kernel
uint64_t* pdpt = (uint64_t*)kmalloc(sizeof(uint64_t) * 4, 32);
ASSERT(pdpt);
for (uint32_t pdpte = 0; pdpte < 4; pdpte++)
{
if (!(global_pdpt[pdpte] & Flags::Present))

View File

@@ -16,4 +16,4 @@ spinlock_lock_asm:
spinlock_unlock_asm:
movl 4(%esp), %eax
movl $0, (%eax)
ret
ret

View File

@@ -25,4 +25,4 @@ SECTIONS
}
g_kernel_end = .;
}
}

View File

@@ -39,7 +39,7 @@ namespace Kernel::GDT
uint8_t flags : 4;
uint8_t base3;
} __attribute__((packed));
struct
{
uint32_t low;
@@ -81,7 +81,7 @@ namespace Kernel::GDT
{
memset(&s_tss, 0x00, sizeof(TaskStateSegment));
s_tss.iopb = sizeof(TaskStateSegment);
uint64_t base = (uint64_t)&s_tss;
write_entry(s_tss_offset, (uint32_t)base, sizeof(TaskStateSegment), 0x89, 0x0);
@@ -122,4 +122,4 @@ namespace Kernel::GDT
flush_tss();
}
}
}

View File

@@ -121,7 +121,7 @@ namespace Kernel::IDT
uint32_t reserved2 : 16;
};
};
};
static_assert(sizeof(PageFaultError) == 4);
@@ -290,7 +290,7 @@ namespace Kernel::IDT
break;
case ISR::PageFault:
signal = SIGSEGV;
break;
break;
default:
dwarnln("Unhandled exception");
signal = SIGABRT;
@@ -305,7 +305,7 @@ namespace Kernel::IDT
}
ASSERT(Thread::current().state() != Thread::State::Terminated);
done:
return;
}

View File

@@ -138,7 +138,7 @@ namespace Kernel
s_global_pml4e = V2P(allocate_zeroed_page_aligned_page());
m_highest_paging_struct = V2P(allocate_zeroed_page_aligned_page());
uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct);
pml4[511] = s_global_pml4e;
@@ -436,7 +436,7 @@ namespace Kernel
ASSERT(vaddr % PAGE_SIZE == 0);
size_t page_count = range_page_count(vaddr, size);
LockGuard _(m_lock);
for (size_t page = 0; page < page_count; page++)
map_page_at(paddr + page * PAGE_SIZE, vaddr + page * PAGE_SIZE, flags);
@@ -453,7 +453,7 @@ namespace Kernel
uint64_t pdpte = (uc_vaddr >> 30) & 0x1FF;
uint64_t pde = (uc_vaddr >> 21) & 0x1FF;
uint64_t pte = (uc_vaddr >> 12) & 0x1FF;
LockGuard _(m_lock);
uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct);
@@ -533,7 +533,7 @@ namespace Kernel
const uint16_t e_pdpte = (uc_vaddr_end >> 30) & 0x1FF;
const uint16_t e_pde = (uc_vaddr_end >> 21) & 0x1FF;
const uint16_t e_pte = (uc_vaddr_end >> 12) & 0x1FF;
LockGuard _(m_lock);
// Try to find free page that can be mapped without
@@ -714,7 +714,7 @@ namespace Kernel
if (!(pt[pte] & Flags::Used))
continue;
if (start == 0)
{
flags = parse_flags(pt[pte]);

View File

@@ -192,4 +192,4 @@ syscall_asm:
addq $8, %rsp
popaq_no_rax
addq $8, %rsp
iretq
iretq

View File

@@ -35,4 +35,4 @@ SECTIONS
*(.bss)
}
g_kernel_end = .;
}
}

View File

@@ -46,8 +46,8 @@ void __cxa_finalize(void *f)
* TODO:
* Note well, however, that deleting a function from here that contains a __dso_handle
* means that one link to a shared object file has been terminated. In other words,
* We should monitor this list (optional, of course), since it tells us how many links to
* an object file exist at runtime in a particular application. This can be used to tell
* We should monitor this list (optional, of course), since it tells us how many links to
* an object file exist at runtime in a particular application. This can be used to tell
* when a shared object is no longer in use. It is one of many methods, however.
**/
//You may insert a prinf() here to tell you whether or not the function gets called. Testing
@@ -59,7 +59,7 @@ void __cxa_finalize(void *f)
/* ^^^ That if statement is a safeguard...
* To make sure we don't call any entries that have already been called and unset at runtime.
* Those will contain a value of 0, and calling a function with value 0
* will cause undefined behaviour. Remember that linear address 0,
* will cause undefined behaviour. Remember that linear address 0,
* in a non-virtual address space (physical) contains the IVT and BDA.
*
* In a virtual environment, the kernel will receive a page fault, and then probably
@@ -92,7 +92,7 @@ void __cxa_finalize(void *f)
**/
if (__atexit_funcs[i].destructor_func == f)
{
/*
/*
* Note that in the next line, not every destructor function is a class destructor.
* It is perfectly legal to register a non class destructor function as a simple cleanup
* function to be called on program termination, in which case, it would not NEED an
@@ -113,7 +113,7 @@ void __cxa_finalize(void *f)
};
};
namespace __cxxabiv1
namespace __cxxabiv1
{
/* guard variables */
static Kernel::SpinLock s_spin_lock;

View File

@@ -126,7 +126,7 @@ namespace Kernel
SDTHeader* as_header() { return (SDTHeader*)vaddr; }
};
BAN::Vector<MappedPage> m_mapped_headers;
BAN::Vector<MappedPage> m_mapped_headers;
};
}
@@ -135,7 +135,7 @@ namespace BAN::Formatter
{
template<typename F>
void print_argument(F putc, const Kernel::ACPI::SDTHeader& header, const ValueFormat& format)
{
{
putc(header.signature[0]);
putc(header.signature[1]);
putc(header.signature[2]);

View File

@@ -18,4 +18,4 @@ namespace Kernel::API
DirectoryEntry array[];
};
}
}

View File

@@ -55,7 +55,7 @@ namespace Kernel
BAN::Vector<Processor> m_processors;
Kernel::paddr_t m_local_apic_paddr = 0;
Kernel::vaddr_t m_local_apic_vaddr = 0;
BAN::Vector<IOAPIC> m_io_apics;
BAN::Vector<IOAPIC> m_io_apics;
uint8_t m_irq_overrides[0x100] {};
uint8_t m_reserved_gsis[0x100 / 8] {};
};

View File

@@ -7,38 +7,38 @@ namespace CPUID
enum Features : uint32_t
{
ECX_SSE3 = (uint32_t)1 << 0,
ECX_SSE3 = (uint32_t)1 << 0,
ECX_PCLMULQDQ = (uint32_t)1 << 1,
ECX_DTES64 = (uint32_t)1 << 2,
ECX_MONITOR = (uint32_t)1 << 3,
ECX_DS_CPL = (uint32_t)1 << 4,
ECX_VMX = (uint32_t)1 << 5,
ECX_SMX = (uint32_t)1 << 6,
ECX_EST = (uint32_t)1 << 7,
ECX_TM2 = (uint32_t)1 << 8,
ECX_SSSE3 = (uint32_t)1 << 9,
ECX_MONITOR = (uint32_t)1 << 3,
ECX_DS_CPL = (uint32_t)1 << 4,
ECX_VMX = (uint32_t)1 << 5,
ECX_SMX = (uint32_t)1 << 6,
ECX_EST = (uint32_t)1 << 7,
ECX_TM2 = (uint32_t)1 << 8,
ECX_SSSE3 = (uint32_t)1 << 9,
ECX_CNTX_ID = (uint32_t)1 << 10,
ECX_SDBG = (uint32_t)1 << 11,
ECX_FMA = (uint32_t)1 << 12,
ECX_CX16 = (uint32_t)1 << 13,
ECX_XTPR = (uint32_t)1 << 14,
ECX_PDCM = (uint32_t)1 << 15,
ECX_PCID = (uint32_t)1 << 17,
ECX_DCA = (uint32_t)1 << 18,
ECX_SSE4_1 = (uint32_t)1 << 19,
ECX_SSE4_2 = (uint32_t)1 << 20,
ECX_X2APIC = (uint32_t)1 << 21,
ECX_MOVBE = (uint32_t)1 << 22,
ECX_POPCNT = (uint32_t)1 << 23,
ECX_TSC_DEADLINE = (uint32_t)1 << 24,
ECX_AES = (uint32_t)1 << 25,
ECX_XSAVE = (uint32_t)1 << 26,
ECX_OSXSAVE = (uint32_t)1 << 27,
ECX_CX16 = (uint32_t)1 << 13,
ECX_XTPR = (uint32_t)1 << 14,
ECX_PDCM = (uint32_t)1 << 15,
ECX_PCID = (uint32_t)1 << 17,
ECX_DCA = (uint32_t)1 << 18,
ECX_SSE4_1 = (uint32_t)1 << 19,
ECX_SSE4_2 = (uint32_t)1 << 20,
ECX_X2APIC = (uint32_t)1 << 21,
ECX_MOVBE = (uint32_t)1 << 22,
ECX_POPCNT = (uint32_t)1 << 23,
ECX_TSC_DEADLINE = (uint32_t)1 << 24,
ECX_AES = (uint32_t)1 << 25,
ECX_XSAVE = (uint32_t)1 << 26,
ECX_OSXSAVE = (uint32_t)1 << 27,
ECX_AVX = (uint32_t)1 << 28,
ECX_F16C = (uint32_t)1 << 29,
ECX_RDRND = (uint32_t)1 << 30,
ECX_HYPERVISOR = (uint32_t)1 << 31,
EDX_FPU = (uint32_t)1 << 0,
EDX_VME = (uint32_t)1 << 1,
EDX_DE = (uint32_t)1 << 2,
@@ -79,4 +79,4 @@ namespace CPUID
bool is_64_bit();
bool has_nxe();
}
}

View File

@@ -27,4 +27,4 @@ namespace Kernel
size_t m_flags;
};
}
}

View File

@@ -61,4 +61,4 @@ namespace Debug
static void lock();
static void unlock();
};
}
}

View File

@@ -52,4 +52,4 @@ namespace Kernel
}
};
}
}

View File

@@ -50,4 +50,4 @@ namespace Kernel
friend class FramebufferMemoryRegion;
};
}
}

View File

@@ -27,4 +27,4 @@ namespace Kernel
const dev_t m_rdev;
};
}
}

View File

@@ -25,4 +25,4 @@ namespace Kernel
const dev_t m_rdev;
};
}
}

View File

@@ -33,4 +33,4 @@ namespace Kernel
BAN::StringView error_string(ErrorCode);
}
}

View File

@@ -13,7 +13,7 @@ namespace Kernel
public:
static void initialize();
static DevFileSystem& get();
void initialize_device_updater();
void add_device(BAN::RefPtr<Device>);
@@ -39,4 +39,4 @@ namespace Kernel
volatile bool m_should_sync { false };
};
}
}

View File

@@ -259,4 +259,4 @@ namespace Kernel::Ext2
}
}
}

View File

@@ -27,7 +27,7 @@ namespace Kernel
{
m_used = false;
}
size_t size() const { return m_buffer.size(); }
uint8_t* data() { return m_buffer.data(); }
@@ -44,7 +44,7 @@ namespace Kernel
bool& m_used;
};
public:
public:
static BAN::ErrorOr<Ext2FS*> create(BAN::RefPtr<BlockDevice>);
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_inode; }
@@ -120,4 +120,4 @@ namespace Kernel
friend class Ext2Inode;
};
}
}

View File

@@ -35,7 +35,7 @@ namespace Kernel
virtual BAN::ErrorOr<void> create_file_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
virtual BAN::ErrorOr<void> create_directory_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
virtual BAN::ErrorOr<void> unlink_impl(BAN::StringView) override;
virtual BAN::ErrorOr<BAN::String> link_target_impl() override;
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
@@ -81,4 +81,4 @@ namespace Kernel
friend class BAN::RefPtr<Ext2Inode>;
};
}
}

View File

@@ -12,4 +12,4 @@ namespace Kernel
virtual BAN::RefPtr<Inode> root_inode() = 0;
};
}
}

View File

@@ -131,4 +131,4 @@ namespace Kernel
friend class FileBackedRegion;
};
}
}

View File

@@ -50,4 +50,4 @@ namespace Kernel
uint32_t m_writing_count { 1 };
};
}
}

View File

@@ -20,4 +20,4 @@ namespace Kernel
ProcFileSystem();
};
}
}

View File

@@ -47,7 +47,7 @@ namespace Kernel
private:
ProcROInode(Process&, size_t (Process::*)(off_t, BAN::ByteSpan) const, TmpFileSystem&, const TmpInodeInfo&);
private:
Process& m_process;
size_t (Process::*m_callback)(off_t, BAN::ByteSpan) const;

View File

@@ -177,4 +177,4 @@ namespace Kernel
}
}
}
}

View File

@@ -44,4 +44,4 @@ namespace Kernel
BAN::Vector<MountPoint> m_mount_points;
};
}
}

View File

@@ -32,4 +32,4 @@ namespace Kernel
uint32_t m_pitch = 0;
};
}
}

View File

@@ -13,4 +13,4 @@ namespace Kernel::GDT
void initialize();
void set_tss_stack(uintptr_t);
}
}

View File

@@ -10,4 +10,4 @@ namespace Kernel::IDT
void initialize();
[[noreturn]] void force_triple_fault();
}
}

View File

@@ -62,4 +62,4 @@ namespace IO
outb(0x80, 0);
}
}
}

View File

@@ -95,4 +95,4 @@ namespace Kernel::Input
Key key_event_to_key(KeyEvent);
const char* key_to_utf8(Key key, uint16_t modifier);
}
}

View File

@@ -42,7 +42,7 @@ namespace Kernel::Input
MouseButtonEvent button_event;
MouseMoveEvent move_event;
MouseScrollEvent scroll_event;
};
};
};
}
}

View File

@@ -53,4 +53,4 @@ namespace Kernel
bool interrupts_enabled();
}
}

View File

@@ -14,4 +14,4 @@ namespace Kernel
uint64_t ss;
};
}
}

View File

@@ -15,7 +15,7 @@ namespace Kernel
LockGuard(Lock& lock)
: m_lock(lock)
{
m_lock.lock();
m_lock.lock();
}
~LockGuard()
@@ -27,4 +27,4 @@ namespace Kernel
Lock& m_lock;
};
}
}

View File

@@ -46,4 +46,4 @@ namespace MMIO
return *(volatile uint64_t*)addr;
}
}
}

View File

@@ -4,7 +4,7 @@
namespace Kernel
{
class DMARegion
{
public:
@@ -27,4 +27,4 @@ namespace Kernel
const paddr_t m_paddr;
};
}
}

View File

@@ -46,4 +46,4 @@ namespace Kernel
BAN::RefPtr<SharedFileData> m_shared_data;
};
}
}

View File

@@ -9,7 +9,7 @@ namespace Kernel
{
BAN_NON_COPYABLE(MemoryBackedRegion);
BAN_NON_MOVABLE(MemoryBackedRegion);
public:
static BAN::ErrorOr<BAN::UniqPtr<MemoryBackedRegion>> create(PageTable&, size_t size, AddressRange, Type, PageTable::flags_t);
~MemoryBackedRegion();
@@ -29,4 +29,4 @@ namespace Kernel
MemoryBackedRegion(PageTable&, size_t size, Type, PageTable::flags_t);
};
}
}

View File

@@ -48,7 +48,7 @@ namespace Kernel
BAN::ErrorOr<bool> allocate_page_containing(vaddr_t address);
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> clone(PageTable& new_page_table) = 0;
protected:
MemoryRegion(PageTable&, size_t size, Type type, PageTable::flags_t flags);
BAN::ErrorOr<void> initialize(AddressRange);
@@ -64,4 +64,4 @@ namespace Kernel
size_t m_physical_page_count { 0 };
};
}
}

View File

@@ -19,7 +19,7 @@ namespace Kernel
{
public:
using flags_t = uint16_t;
enum Flags : flags_t
enum Flags : flags_t
{
Present = (1 << 0),
ReadWrite = (1 << 1),
@@ -107,7 +107,7 @@ namespace Kernel
uint64_t get_page_data(vaddr_t) const;
void initialize_kernel();
void map_kernel_memory();
void prepare_fast_page();
void prepare_fast_page();
static void invalidate(vaddr_t);
private:

View File

@@ -30,4 +30,4 @@ namespace Kernel
PageTable& m_temp;
};
}
}

View File

@@ -30,7 +30,7 @@ namespace Kernel
private:
unsigned long long* ull_bitmap_ptr() { return (unsigned long long*)m_vaddr; }
const unsigned long long* ull_bitmap_ptr() const { return (const unsigned long long*)m_vaddr; }
paddr_t paddr_for_bit(unsigned long long) const;
unsigned long long bit_for_paddr(paddr_t paddr) const;
@@ -47,4 +47,4 @@ namespace Kernel
size_t m_free_pages { 0 };
};
}
}

View File

@@ -20,4 +20,4 @@ namespace Kernel
using vaddr_t = uintptr_t;
using paddr_t = uintptr_t;
}
}

View File

@@ -48,4 +48,4 @@ namespace Kernel
PageTable::flags_t m_flags { 0 };
};
}
}

View File

@@ -1,6 +1,7 @@
#pragma once
#include <BAN/UniqPtr.h>
#include <kernel/InterruptController.h>
#include <kernel/Networking/NetworkDriver.h>
#include <kernel/PCI.h>
@@ -10,7 +11,7 @@
namespace Kernel
{
class E1000 final : public NetworkDriver
class E1000 final : public NetworkDriver, public Interruptable
{
public:
static bool probe(PCI::Device&);
@@ -23,9 +24,11 @@ namespace Kernel
virtual bool link_up() override { return m_link_up; }
virtual int link_speed() override;
virtual void handle_irq() override { ASSERT_NOT_REACHED(); }
private:
E1000() = default;
BAN::ErrorOr<void> initialize(PCI::Device&);
E1000(PCI::Device& pci_device) : m_pci_device(pci_device) {}
BAN::ErrorOr<void> initialize();
static void interrupt_handler();
@@ -40,11 +43,12 @@ namespace Kernel
void initialize_tx();
void enable_link();
void enable_interrupts();
BAN::ErrorOr<void> enable_interrupts();
void handle_receive();
private:
PCI::Device& m_pci_device;
BAN::UniqPtr<PCI::BarRegion> m_bar_region;
bool m_has_eerprom { false };
uint8_t m_mac_address[6] {};

View File

@@ -17,4 +17,4 @@ namespace Kernel
virtual int link_speed() = 0;
};
}
}

View File

@@ -78,4 +78,4 @@ namespace Kernel
BAN::Array<BAN::RefPtr<OpenFileDescription>, OPEN_MAX> m_open_files;
};
}
}

View File

@@ -130,7 +130,7 @@ namespace Kernel::PCI
public:
static void initialize();
static PCIManager& get();
const BAN::Vector<PCI::Device>& devices() const { return m_devices; }
static uint32_t read_config_dword(uint8_t bus, uint8_t dev, uint8_t func, uint8_t offset);
@@ -153,4 +153,4 @@ namespace Kernel::PCI
BAN::Vector<PCI::Device> m_devices;
};
}
}

View File

@@ -26,4 +26,4 @@ namespace Kernel::detail
__builtin_unreachable();
}
}
}

View File

@@ -225,4 +225,4 @@ namespace Kernel
friend class Thread;
};
}
}

View File

@@ -76,4 +76,4 @@ namespace Kernel
friend class Process;
};
}
}

View File

@@ -10,4 +10,4 @@ namespace Kernel
void unblock();
};
}
}

View File

@@ -43,7 +43,7 @@ namespace Kernel
{
BAN_NON_COPYABLE(RecursivePrioritySpinLock);
BAN_NON_MOVABLE(RecursivePrioritySpinLock);
public:
RecursivePrioritySpinLock() = default;
void lock();

View File

@@ -37,68 +37,68 @@ namespace Kernel
struct FISRegisterH2D
{
uint8_t fis_type; // FIS_TYPE_REGISTER_H2D
uint8_t pm_port : 4; // Port multiplier
uint8_t __reserved0 : 3;
uint8_t c : 1; // 1: Command, 0: Control
uint8_t command;
uint8_t feature_lo; // Feature register, 7:0
uint8_t lba0; // LBA low register, 7:0
uint8_t lba1; // LBA mid register, 15:8
uint8_t lba2; // LBA high register, 23:16
uint8_t device;
uint8_t lba3; // LBA register, 31:24
uint8_t lba4; // LBA register, 39:32
uint8_t lba5; // LBA register, 47:40
uint8_t feature_hi; // Feature register, 15:8
uint8_t count_lo; // Count register, 7:0
uint8_t count_hi; // Count register, 15:8
uint8_t icc; // Isochronous command completion
uint8_t control;
uint8_t __reserved1[4];
} __attribute__((packed));
struct FISRegisterD2H
{
uint8_t fis_type; // FIS_TYPE_REGISTER_D2H
uint8_t pm_port : 4; // Port multiplier
uint8_t __reserved0 : 2;
uint8_t i : 1; // Interrupt bit
uint8_t __reserved1 : 1;
uint8_t status;
uint8_t error;
uint8_t lba0; // LBA low register, 7:0
uint8_t lba1; // LBA mid register, 15:8
uint8_t lba2; // LBA high register, 23:16
uint8_t device;
uint8_t lba3; // LBA register, 31:24
uint8_t lba4; // LBA register, 39:32
uint8_t lba5; // LBA register, 47:40
uint8_t __reserved2;
uint8_t count_lo; // Count register, 7:0
uint8_t count_hi; // Count register, 15:8
uint8_t __reserved3[2];
uint8_t __reserved4[4];
} __attribute__((packed));
struct FISDataBI
{
uint8_t fis_type; // FIS_TYPE_DATA
uint8_t pm_port : 4; // Port multiplier
uint8_t __reserved0 : 4;
uint8_t __reserved1[2];
uint32_t data[0]; // Payload (1 - 2048 dwords)
@@ -122,31 +122,31 @@ namespace Kernel
struct PIOSetupD2H
{
uint8_t fis_type; // FIS_TYPE_PIO_SETUP
uint8_t pm_port : 4; // Port multiplier
uint8_t __reserved0 : 1;
uint8_t d : 1; // Data transfer direction, 1 - device to host
uint8_t i : 1; // Interrupt bit
uint8_t __reserved1 : 1;
uint8_t status;
uint8_t error;
uint8_t lba0; // LBA low register, 7:0
uint8_t lba1; // LBA mid register, 15:8
uint8_t lba2; // LBA high register, 23:16
uint8_t device;
uint8_t lba3; // LBA register, 31:24
uint8_t lba4; // LBA register, 39:32
uint8_t lba5; // LBA register, 47:40
uint8_t __reserved2;
uint8_t count_lo; // Count register, 7:0
uint8_t count_hi; // Count register, 15:8
uint8_t __reserved3;
uint8_t e_status; // New value of status register
uint16_t tc; // Transfer count
uint8_t __reserved4[2];
} __attribute__((packed));
@@ -154,13 +154,13 @@ namespace Kernel
struct DMASetupBI
{
uint8_t fis_type; // FIS_TYPE_DMA_SETUP
uint8_t pm_port : 4; // Port multiplier
uint8_t __reserved0 : 1;
uint8_t d : 1; // Data transfer direction, 1 - device to host
uint8_t i : 1; // Interrupt bit
uint8_t a : 1; // Auto-activate. Specifies if DMA Activate FIS is needed
uint8_t __reserved1[2];
uint64_t dma_buffer_id; // DMA Buffer Identifier. Used to Identify DMA buffer in host memory.
@@ -211,11 +211,11 @@ namespace Kernel
uint32_t em_ctl; // 0x20, Enclosure management control
uint32_t cap2; // 0x24, Host capabilities extended
uint32_t bohc; // 0x28, BIOS/OS handoff control and status
uint8_t __reserved0[0xA0-0x2C];
uint8_t vendor[0x100-0xA0];
HBAPortMemorySpace ports[0]; // 1 - 32 ports
} __attribute__((packed));
@@ -223,17 +223,17 @@ namespace Kernel
{
DMASetupBI dsfis;
uint8_t pad0[4];
PIOSetupD2H psfis;
uint8_t pad1[12];
FISRegisterD2H rfis;
uint8_t pad2[4];
SetDeviceBitsD2H sdbfis;
uint8_t ufis[64];
uint8_t __reserved[0x100-0xA0];
} __attribute__((packed));
@@ -243,20 +243,20 @@ namespace Kernel
uint8_t a : 1; // ATAPI
uint8_t w : 1; // Write, 1: H2D, 0: D2H
uint8_t p : 1; // Prefetchable
uint8_t r : 1; // Reset
uint8_t b : 1; // BIST
uint8_t c : 1; // Clear busy upon R_OK
uint8_t __reserved0 : 1;
uint8_t pmp : 4; // Port multiplier port
uint16_t prdtl; // Physical region descriptor table length in entries
volatile uint32_t prdbc; // Physical region descriptor byte count transferred
uint32_t ctba; // Command table descriptor base address
uint32_t ctbau; // Command table descriptor base address upper 32 bits
uint32_t __reserved1[4];
} __attribute__((packed));

View File

@@ -30,13 +30,13 @@ namespace Kernel
BAN::Optional<uint32_t> find_free_command_slot();
void handle_irq();
BAN::ErrorOr<void> block_until_command_completed(uint32_t command_slot);
private:
BAN::RefPtr<AHCIController> m_controller;
volatile HBAPortMemorySpace* const m_port;
BAN::UniqPtr<DMARegion> m_dma_region;
// Intermediate read/write buffer
// TODO: can we read straight to user buffer?
@@ -45,4 +45,4 @@ namespace Kernel
friend class AHCIController;
};
}
}

View File

@@ -61,4 +61,4 @@ namespace Kernel
friend class ATAController;
};
}
}

View File

@@ -24,4 +24,4 @@ namespace Kernel
PCI::Device& m_pci_device;
};
}
}

View File

@@ -56,4 +56,4 @@
#define ATA_COMMANDSET_LBA48_SUPPORTED (1 << 26)
#define ATA_CAPABILITIES_LBA (1 << 9)
#define ATA_CAPABILITIES_DMA (1 << 8)
#define ATA_CAPABILITIES_DMA (1 << 8)

View File

@@ -39,7 +39,7 @@ namespace Kernel
ATABaseDevice();
BAN::ErrorOr<void> initialize(BAN::Span<const uint16_t> identify_data);
protected:
protected:
uint16_t m_signature;
uint16_t m_capabilities;
uint32_t m_command_set;
@@ -62,7 +62,7 @@ namespace Kernel
private:
ATADevice(BAN::RefPtr<ATABus>, ATABus::DeviceType, bool is_secodary);
virtual BAN::ErrorOr<void> read_sectors_impl(uint64_t, uint64_t, BAN::ByteSpan) override;
virtual BAN::ErrorOr<void> write_sectors_impl(uint64_t, uint64_t, BAN::ConstByteSpan) override;

View File

@@ -40,4 +40,4 @@ namespace Kernel
BAN::Array<uint8_t, PAGE_SIZE> m_sync_cache;
};
}
}

View File

@@ -149,7 +149,7 @@ namespace Kernel::NVMe
uint8_t cns;
uint8_t __reserved1;
uint16_t cntid;
// dword 11
// dword 11
uint16_t cnsid;
uint8_t __reserved2;
uint8_t csi;
@@ -292,4 +292,4 @@ namespace Kernel::NVMe
} __attribute__((packed));
static_assert(sizeof(NamespaceIdentify) == 0x1000);
}
}

View File

@@ -12,4 +12,4 @@ namespace Kernel
virtual BAN::ErrorOr<void> initialize() = 0;
};
}
}

View File

@@ -47,4 +47,4 @@ namespace Kernel
friend class DiskCache;
};
}
}

View File

@@ -40,7 +40,7 @@ namespace Kernel
{
public:
static BAN::ErrorOr<BAN::RefPtr<SerialTTY>> create(Serial);
virtual uint32_t width() const override;
virtual uint32_t height() const override;
@@ -69,4 +69,4 @@ namespace Kernel
const dev_t m_rdev;
};
}
}

View File

@@ -15,7 +15,7 @@ namespace Kernel
{
public:
void set_termios(const termios& termios) { m_termios = termios; }
termios get_termios() const { return m_termios; }
termios get_termios() const { return m_termios; }
virtual void set_font(const Font&) {};
void set_foreground_pgrp(pid_t pgrp) { m_foreground_pgrp = pgrp; }

View File

@@ -58,4 +58,4 @@ namespace TerminalColor
static constexpr TerminalDriver::Color BRIGHT_MAGENTA = 0xFF55FF;
static constexpr TerminalDriver::Color BRIGHT_YELLOW = 0xFFFF55;
static constexpr TerminalDriver::Color BRIGHT_WHITE = 0xFFFFFF;
}
}

View File

@@ -9,4 +9,4 @@ namespace Kernel
bool echo { true };
};
}
}

View File

@@ -17,7 +17,7 @@ namespace Kernel
{
BAN_NON_COPYABLE(Thread);
BAN_NON_MOVABLE(Thread);
public:
using entry_t = void(*)(void*);
@@ -95,7 +95,7 @@ namespace Kernel
private:
Thread(pid_t tid, Process*);
void on_exit();
void validate_stack() const;
private:
@@ -125,4 +125,4 @@ namespace Kernel
friend class Scheduler;
};
}
}

View File

@@ -29,4 +29,4 @@ namespace Kernel
vaddr_t m_mmio_base { 0 };
};
}
}

View File

@@ -24,4 +24,4 @@ namespace Kernel
volatile uint64_t m_system_time { 0 };
};
}
}

View File

@@ -28,7 +28,7 @@ namespace Kernel
virtual uint64_t ms_since_boot() const override;
virtual uint64_t ns_since_boot() const override;
virtual timespec time_since_boot() const override;
void sleep(uint64_t ms) const;
timespec real_time() const;
@@ -44,4 +44,4 @@ namespace Kernel
BAN::UniqPtr<Timer> m_timer;
};
}
}

View File

@@ -171,7 +171,7 @@ namespace Kernel
size_t needed_pages = range_page_count(header_paddr, header_length);
vaddr_t page_vaddr = PageTable::kernel().reserve_free_contiguous_pages(needed_pages, KERNEL_OFFSET);
ASSERT(page_vaddr);
PageTable::kernel().map_range_at(
header_paddr & PAGE_ADDR_MASK,
page_vaddr,
@@ -194,7 +194,7 @@ namespace Kernel
paddr_t header_paddr = (m_entry_size == 4) ?
((uint32_t*)m_header_table_vaddr)[i] :
((uint64_t*)m_header_table_vaddr)[i];
vaddr_t header_vaddr = map_header(header_paddr);
if (header_vaddr == 0)
continue;
@@ -252,4 +252,4 @@ namespace Kernel
return nullptr;
}
}
}

View File

@@ -218,7 +218,7 @@ namespace Kernel
void APIC::eoi(uint8_t)
{
write_to_local_apic(LAPIC_EIO_REG, 0);
write_to_local_apic(LAPIC_EIO_REG, 0);
}
void APIC::enable_irq(uint8_t irq)
@@ -305,7 +305,7 @@ namespace Kernel
for (int irq = 0; irq <= 0xFF; irq++)
{
uint32_t gsi = m_irq_overrides[irq];
IOAPIC* ioapic = nullptr;
for (IOAPIC& io : m_io_apics)
{

View File

@@ -36,7 +36,7 @@ namespace Kernel
const auto& mmap_tag = *reinterpret_cast<const multiboot2_mmap_tag_t*>(tag);
const size_t entry_count = (mmap_tag.size - sizeof(multiboot2_mmap_tag_t)) / mmap_tag.entry_size;
MUST(g_boot_info.memory_map_entries.resize(entry_count));
for (size_t i = 0; i < entry_count; i++)
@@ -105,7 +105,7 @@ namespace Kernel
return true;
if (magic == BANAN_BOOTLOADER_MAGIC)
return true;
return false;
return false;
}
void parse_boot_info(uint32_t magic, uint32_t info)

View File

@@ -55,7 +55,7 @@ namespace Kernel
TRY(result.append(parts[0]));
return result;
}
line.clear();
}

View File

@@ -101,7 +101,7 @@ namespace Debug
if (row >= g_terminal_driver->height())
row = 0;
if (row != row_copy)
{
for (uint32_t i = col; i < g_terminal_driver->width(); i++)
@@ -134,4 +134,4 @@ namespace Debug
s_debug_lock.unlock();
}
}
}

View File

@@ -13,4 +13,4 @@ namespace Kernel
)
{ }
}
}

View File

@@ -97,7 +97,7 @@ namespace Kernel
if ((size_t)offset >= m_width * m_height * (BANAN_FB_BPP / 8))
return 0;
size_t bytes_to_copy = BAN::Math::min<size_t>(m_width * m_height * (BANAN_FB_BPP / 8) - offset, buffer.size());
memcpy(buffer.data(), reinterpret_cast<void*>(m_video_buffer->vaddr() + offset), bytes_to_copy);
@@ -110,7 +110,7 @@ namespace Kernel
return BAN::Error::from_errno(EINVAL);
if ((size_t)offset >= m_width * m_height * (BANAN_FB_BPP / 8))
return 0;
size_t bytes_to_copy = BAN::Math::min<size_t>(m_width * m_height * (BANAN_FB_BPP / 8) - offset, buffer.size());
memcpy(reinterpret_cast<void*>(m_video_buffer->vaddr() + offset), buffer.data(), bytes_to_copy);
@@ -252,7 +252,7 @@ namespace Kernel
vaddr &= PAGE_ADDR_MASK;
if (m_page_table.physical_address_of(vaddr))
return false;
paddr_t paddr = PageTable::kernel().physical_address_of(m_framebuffer->m_video_buffer->vaddr() + (vaddr - m_vaddr));
m_page_table.map_page_at(paddr, vaddr, m_flags);

View File

@@ -12,4 +12,4 @@ namespace Kernel
return BAN::RefPtr<NullDevice>::adopt(result);
}
}
}

View File

@@ -18,4 +18,4 @@ namespace Kernel
return buffer.size();
}
}
}

View File

@@ -34,4 +34,4 @@ namespace Kernel
return s_error_strings[(uint32_t)error];
}
}
}

View File

@@ -135,4 +135,4 @@ namespace Kernel
return next_dev++;
}
}
}

View File

@@ -503,4 +503,4 @@ namespace Kernel
return {};
}
}
}

View File

@@ -807,4 +807,4 @@ needs_new_block:
return BAN::Error::from_errno(ENOENT);
}
}
}

View File

@@ -153,4 +153,4 @@ namespace Kernel
return has_data_impl();
}
}
}

View File

@@ -82,4 +82,4 @@ namespace Kernel
return buffer.size();
}
}
}

View File

@@ -67,7 +67,7 @@ namespace Kernel
PageTable::with_fast_page(inode_location.paddr, [&] {
inode_info = PageTable::fast_page_as_sized<TmpInodeInfo>(inode_location.index);
});
auto inode = TRY(TmpInode::create_from_existing(*this, ino, inode_info));
TRY(m_inode_cache.insert(ino, inode));
return inode;
@@ -85,7 +85,7 @@ namespace Kernel
void TmpFileSystem::remove_from_cache(BAN::RefPtr<TmpInode> inode)
{
LockGuard _(m_lock);
ASSERT(m_inode_cache.contains(inode->ino()));
m_inode_cache.remove(inode->ino());
}

View File

@@ -392,7 +392,7 @@ namespace Kernel
if (result == 0)
return BAN::Error::from_errno(ENOENT);
auto inode = TRY(m_fs.open_inode(result));
return BAN::RefPtr<Inode>(inode);
}
@@ -406,13 +406,13 @@ namespace Kernel
}
auto block_index = this->block_index(data_block_index);
list->entry_count = 0;
// if we reach a non-allocated block, it marks the end
if (!block_index.has_value())
return {};
auto* dirp = list->array;
const size_t byte_count = BAN::Math::min<size_t>(size() - data_block_index * blksize(), blksize());

View File

@@ -198,4 +198,4 @@ namespace Kernel
return file;
}
}
}

View File

@@ -42,7 +42,7 @@ namespace Kernel
BAN::Vector<uint8_t> file_data;
TRY(file_data.resize(inode->size()));
TRY(inode->read(0, file_data.span()));
if (file_data.size() < 4)
@@ -69,7 +69,7 @@ namespace Kernel
uint8_t char_size;
};
const PSF1Header& header = *(const PSF1Header*)font_data.data();
uint32_t glyph_count = header.mode & PSF1_MODE512 ? 512 : 256;
uint32_t glyph_size = header.char_size;
uint32_t glyph_data_size = glyph_size * glyph_count;
@@ -225,7 +225,7 @@ namespace Kernel
else
{
for (uint32_t i = 0; i < header.glyph_count; i++)
TRY(glyph_offsets.insert(i, i * header.glyph_size));
TRY(glyph_offsets.insert(i, i * header.glyph_size));
}
if (invalid_utf)
@@ -254,4 +254,4 @@ namespace Kernel
return m_glyph_data.data() + m_glyph_offsets[codepoint];
}
}
}

View File

@@ -137,7 +137,7 @@ namespace Kernel::Input
{
dprintln("Invalid modifier instruction in keymap '{}'", line);
dprintln(" format: include \"PATH\"");
return BAN::Error::from_errno(EINVAL);
return BAN::Error::from_errno(EINVAL);
}
parts[1] = parts[1].substring(1, parts[1].size() - 2);

View File

@@ -260,7 +260,7 @@ namespace Kernel::Input
// Flush The Output Buffer
while (!read_byte().is_error())
continue;
// Set the Controller Configuration Byte
TRY(send_command(PS2::Command::READ_CONFIG));
uint8_t config = TRY(read_byte());
@@ -340,7 +340,7 @@ namespace Kernel::Input
dwarnln("Could not reserve irq for PS/2 port 2");
m_devices[1].clear();
}
if (!m_devices[0] && !m_devices[1])
return {};

Some files were not shown because too many files have changed in this diff Show More