mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:57:45 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -29,7 +29,7 @@ struct [[gnu::packed]] InodeWatcherEvent {
|
|||
Type type { Type::Invalid };
|
||||
size_t name_length { 0 };
|
||||
// This is a VLA which is written during the read() from the descriptor.
|
||||
const char name[];
|
||||
char const name[];
|
||||
};
|
||||
|
||||
AK_ENUM_BITWISE_OPERATORS(InodeWatcherEvent::Type);
|
||||
|
|
|
@ -125,7 +125,7 @@ enum KeyCode : u8 {
|
|||
Key_Shift
|
||||
= Key_LeftShift,
|
||||
};
|
||||
const int key_code_count = Key_Menu;
|
||||
int const key_code_count = Key_Menu;
|
||||
|
||||
enum KeyModifier {
|
||||
Mod_None = 0x00,
|
||||
|
@ -155,7 +155,7 @@ struct KeyEvent {
|
|||
bool is_press() const { return flags & Is_Press; }
|
||||
};
|
||||
|
||||
inline const char* key_code_to_string(KeyCode key)
|
||||
inline char const* key_code_to_string(KeyCode key)
|
||||
{
|
||||
switch (key) {
|
||||
#define __ENUMERATE_KEY_CODE(name, ui_name) \
|
||||
|
|
|
@ -218,7 +218,7 @@ constexpr StringView to_string(Function function)
|
|||
|
||||
#ifdef __serenity__
|
||||
struct StringArgument {
|
||||
const char* characters;
|
||||
char const* characters;
|
||||
size_t length { 0 };
|
||||
};
|
||||
|
||||
|
@ -262,7 +262,7 @@ struct SC_poll_params {
|
|||
struct pollfd* fds;
|
||||
unsigned nfds;
|
||||
const struct timespec* timeout;
|
||||
const u32* sigmask;
|
||||
u32 const* sigmask;
|
||||
};
|
||||
|
||||
struct SC_clock_nanosleep_params {
|
||||
|
@ -288,7 +288,7 @@ struct SC_getsockopt_params {
|
|||
};
|
||||
|
||||
struct SC_setsockopt_params {
|
||||
const void* value;
|
||||
void const* value;
|
||||
int sockfd;
|
||||
int level;
|
||||
int option;
|
||||
|
@ -319,7 +319,7 @@ struct SC_futex_params {
|
|||
int futex_op;
|
||||
u32 val;
|
||||
union {
|
||||
const timespec* timeout;
|
||||
timespec const* timeout;
|
||||
uintptr_t val2;
|
||||
};
|
||||
u32* userspace_address2;
|
||||
|
@ -327,11 +327,11 @@ struct SC_futex_params {
|
|||
};
|
||||
|
||||
struct SC_setkeymap_params {
|
||||
const u32* map;
|
||||
const u32* shift_map;
|
||||
const u32* alt_map;
|
||||
const u32* altgr_map;
|
||||
const u32* shift_altgr_map;
|
||||
u32 const* map;
|
||||
u32 const* shift_map;
|
||||
u32 const* alt_map;
|
||||
u32 const* altgr_map;
|
||||
u32 const* shift_altgr_map;
|
||||
StringArgument map_name;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ struct VirGL3DResourceSpec {
|
|||
};
|
||||
|
||||
struct VirGLCommandBuffer {
|
||||
const u32* data;
|
||||
u32 const* data;
|
||||
u32 num_elems;
|
||||
};
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ void __asan_handle_no_return(void)
|
|||
{
|
||||
}
|
||||
|
||||
void __asan_before_dynamic_init(const char*);
|
||||
void __asan_before_dynamic_init(const char* /* module_name */)
|
||||
void __asan_before_dynamic_init(char const*);
|
||||
void __asan_before_dynamic_init(char const* /* module_name */)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ struct ProcessorMessage {
|
|||
} flush_tlb;
|
||||
};
|
||||
|
||||
volatile bool async;
|
||||
bool volatile async;
|
||||
|
||||
ProcessorMessageEntry* per_proc_entries;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Prekernel {
|
|||
void drop_to_exception_level_1();
|
||||
void init_prekernel_page_tables();
|
||||
|
||||
[[noreturn]] void panic(const char* msg);
|
||||
[[noreturn]] void panic(char const* msg);
|
||||
|
||||
[[noreturn]] void halt();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Prekernel {
|
||||
|
||||
[[noreturn]] void panic(const char* msg)
|
||||
[[noreturn]] void panic(char const* msg)
|
||||
{
|
||||
auto& uart = Prekernel::UART::the();
|
||||
|
||||
|
|
|
@ -91,8 +91,8 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
const u64* m_start;
|
||||
const u64* m_end;
|
||||
u64 const* m_start;
|
||||
u64 const* m_end;
|
||||
u64* m_current;
|
||||
};
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ static void activate_mmu()
|
|||
|
||||
// Enable MMU in the system control register
|
||||
Aarch64::SCTLR_EL1 sctlr_el1 = Aarch64::SCTLR_EL1::read();
|
||||
sctlr_el1.M = 1; //Enable MMU
|
||||
sctlr_el1.M = 1; // Enable MMU
|
||||
Aarch64::SCTLR_EL1::write(sctlr_el1);
|
||||
|
||||
Aarch64::Asm::flush();
|
||||
|
|
|
@ -17,8 +17,8 @@ namespace Kernel {
|
|||
|
||||
class Thread;
|
||||
|
||||
//FIXME This needs to go behind some sort of platform abstraction
|
||||
// it is used between Thread and Processor.
|
||||
// FIXME This needs to go behind some sort of platform abstraction
|
||||
// it is used between Thread and Processor.
|
||||
struct [[gnu::aligned(16)]] FPUState
|
||||
{
|
||||
u8 buffer[512];
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
void send(u32 c);
|
||||
u32 receive();
|
||||
|
||||
void print_str(const char* s)
|
||||
void print_str(char const* s)
|
||||
{
|
||||
while (*s)
|
||||
send(*s++);
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
void print_hex(u64 n)
|
||||
{
|
||||
char buf[17];
|
||||
static const char* digits = "0123456789ABCDEF";
|
||||
static char const* digits = "0123456789ABCDEF";
|
||||
int i = 0;
|
||||
do {
|
||||
buf[i++] = digits[n % 16];
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
#include <Kernel/Arch/aarch64/UART.h>
|
||||
#include <Kernel/Arch/aarch64/Utils.h>
|
||||
|
||||
void Prekernel::dbgln(const char* text)
|
||||
void Prekernel::dbgln(char const* text)
|
||||
{
|
||||
auto& uart = Prekernel::UART::the();
|
||||
uart.print_str(text);
|
||||
uart.print_str("\r\n");
|
||||
}
|
||||
|
||||
void Prekernel::warnln(const char* text)
|
||||
void Prekernel::warnln(char const* text)
|
||||
{
|
||||
dbgln(text);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
namespace Prekernel {
|
||||
|
||||
// FIXME: to be replaced by real implementation from AK/Format.h
|
||||
void dbgln(const char* text);
|
||||
void warnln(const char* text);
|
||||
void dbgln(char const* text);
|
||||
void warnln(char const* text);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ void dummy();
|
|||
void dummy() { }
|
||||
|
||||
// Assertions.h
|
||||
[[noreturn]] void __assertion_failed(const char*, const char*, unsigned, const char*);
|
||||
[[noreturn]] void __assertion_failed(char const*, char const*, unsigned, char const*);
|
||||
|
||||
[[noreturn]] void __assertion_failed(const char*, const char*, unsigned, const char*)
|
||||
[[noreturn]] void __assertion_failed(char const*, char const*, unsigned, char const*)
|
||||
{
|
||||
for (;;) { }
|
||||
}
|
||||
|
@ -58,20 +58,20 @@ ssize_t safe_strnlen(char const*, unsigned long, void*&) { return 0; }
|
|||
bool safe_memcpy(void*, void const*, unsigned long, void*&);
|
||||
bool safe_memcpy(void*, void const*, unsigned long, void*&) { return false; }
|
||||
|
||||
Optional<bool> safe_atomic_compare_exchange_relaxed(volatile u32*, u32&, u32);
|
||||
Optional<bool> safe_atomic_compare_exchange_relaxed(volatile u32*, u32&, u32) { return {}; }
|
||||
Optional<bool> safe_atomic_compare_exchange_relaxed(u32 volatile*, u32&, u32);
|
||||
Optional<bool> safe_atomic_compare_exchange_relaxed(u32 volatile*, u32&, u32) { return {}; }
|
||||
|
||||
Optional<u32> safe_atomic_load_relaxed(volatile u32*);
|
||||
Optional<u32> safe_atomic_load_relaxed(volatile u32*) { return {}; }
|
||||
Optional<u32> safe_atomic_load_relaxed(u32 volatile*);
|
||||
Optional<u32> safe_atomic_load_relaxed(u32 volatile*) { return {}; }
|
||||
|
||||
Optional<u32> safe_atomic_fetch_add_relaxed(volatile u32*, u32);
|
||||
Optional<u32> safe_atomic_fetch_add_relaxed(volatile u32*, u32) { return {}; }
|
||||
Optional<u32> safe_atomic_fetch_add_relaxed(u32 volatile*, u32);
|
||||
Optional<u32> safe_atomic_fetch_add_relaxed(u32 volatile*, u32) { return {}; }
|
||||
|
||||
Optional<u32> safe_atomic_exchange_relaxed(volatile u32*, u32);
|
||||
Optional<u32> safe_atomic_exchange_relaxed(volatile u32*, u32) { return {}; }
|
||||
Optional<u32> safe_atomic_exchange_relaxed(u32 volatile*, u32);
|
||||
Optional<u32> safe_atomic_exchange_relaxed(u32 volatile*, u32) { return {}; }
|
||||
|
||||
bool safe_atomic_store_relaxed(volatile u32*, u32);
|
||||
bool safe_atomic_store_relaxed(volatile u32*, u32) { return {}; }
|
||||
bool safe_atomic_store_relaxed(u32 volatile*, u32);
|
||||
bool safe_atomic_store_relaxed(u32 volatile*, u32) { return {}; }
|
||||
|
||||
}
|
||||
|
||||
|
@ -79,12 +79,12 @@ extern "C" {
|
|||
|
||||
FlatPtr kernel_mapping_base;
|
||||
|
||||
void kernelputstr(const char*, size_t);
|
||||
void kernelputstr(const char*, size_t) { }
|
||||
void kernelputstr(char const*, size_t);
|
||||
void kernelputstr(char const*, size_t) { }
|
||||
|
||||
void kernelcriticalputstr(const char*, size_t);
|
||||
void kernelcriticalputstr(const char*, size_t) { }
|
||||
void kernelcriticalputstr(char const*, size_t);
|
||||
void kernelcriticalputstr(char const*, size_t) { }
|
||||
|
||||
void kernelearlyputstr(const char*, size_t);
|
||||
void kernelearlyputstr(const char*, size_t) { }
|
||||
void kernelearlyputstr(char const*, size_t);
|
||||
void kernelearlyputstr(char const*, size_t) { }
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ extern "C" const u32 serenity_boot_logo_size;
|
|||
|
||||
static void draw_logo()
|
||||
{
|
||||
Prekernel::BootPPMParser logo_parser(reinterpret_cast<const u8*>(&serenity_boot_logo_start), serenity_boot_logo_size);
|
||||
Prekernel::BootPPMParser logo_parser(reinterpret_cast<u8 const*>(&serenity_boot_logo_start), serenity_boot_logo_size);
|
||||
if (!logo_parser.parse()) {
|
||||
Prekernel::warnln("Invalid boot logo.");
|
||||
return;
|
||||
|
|
|
@ -33,8 +33,8 @@ inline u32 get_iopl_from_eflags(u32 eflags)
|
|||
return (eflags & iopl_mask) >> 12;
|
||||
}
|
||||
|
||||
const DescriptorTablePointer& get_gdtr();
|
||||
const DescriptorTablePointer& get_idtr();
|
||||
DescriptorTablePointer const& get_gdtr();
|
||||
DescriptorTablePointer const& get_idtr();
|
||||
|
||||
void handle_crash(RegisterState const&, char const* description, int signal, bool out_of_memory = false);
|
||||
|
||||
|
@ -48,7 +48,7 @@ constexpr FlatPtr page_base_of(FlatPtr address)
|
|||
return address & PAGE_MASK;
|
||||
}
|
||||
|
||||
inline FlatPtr page_base_of(const void* address)
|
||||
inline FlatPtr page_base_of(void const* address)
|
||||
{
|
||||
return page_base_of((FlatPtr)address);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ constexpr FlatPtr offset_in_page(FlatPtr address)
|
|||
return address & (~PAGE_MASK);
|
||||
}
|
||||
|
||||
inline FlatPtr offset_in_page(const void* address)
|
||||
inline FlatPtr offset_in_page(void const* address)
|
||||
{
|
||||
return offset_in_page((FlatPtr)address);
|
||||
}
|
||||
|
|
|
@ -133,12 +133,12 @@ public:
|
|||
|
||||
bool is_null() const { return m_address == 0; }
|
||||
|
||||
bool operator==(const IOAddress& other) const { return m_address == other.m_address; }
|
||||
bool operator!=(const IOAddress& other) const { return m_address != other.m_address; }
|
||||
bool operator>(const IOAddress& other) const { return m_address > other.m_address; }
|
||||
bool operator>=(const IOAddress& other) const { return m_address >= other.m_address; }
|
||||
bool operator<(const IOAddress& other) const { return m_address < other.m_address; }
|
||||
bool operator<=(const IOAddress& other) const { return m_address <= other.m_address; }
|
||||
bool operator==(IOAddress const& other) const { return m_address == other.m_address; }
|
||||
bool operator!=(IOAddress const& other) const { return m_address != other.m_address; }
|
||||
bool operator>(IOAddress const& other) const { return m_address > other.m_address; }
|
||||
bool operator>=(IOAddress const& other) const { return m_address >= other.m_address; }
|
||||
bool operator<(IOAddress const& other) const { return m_address < other.m_address; }
|
||||
bool operator<=(IOAddress const& other) const { return m_address <= other.m_address; }
|
||||
|
||||
private:
|
||||
u16 m_address { 0 };
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
void clear() { m_raw = 0; }
|
||||
|
||||
u64 raw() const { return m_raw; }
|
||||
void copy_from(Badge<Memory::PageDirectory>, const PageDirectoryEntry& other) { m_raw = other.m_raw; }
|
||||
void copy_from(Badge<Memory::PageDirectory>, PageDirectoryEntry const& other) { m_raw = other.m_raw; }
|
||||
|
||||
enum Flags {
|
||||
Present = 1 << 0,
|
||||
|
|
|
@ -182,7 +182,7 @@ public:
|
|||
|
||||
Descriptor& get_gdt_entry(u16 selector);
|
||||
void flush_gdt();
|
||||
const DescriptorTablePointer& get_gdtr();
|
||||
DescriptorTablePointer const& get_gdtr();
|
||||
|
||||
template<IteratorFunction<Processor&> Callback>
|
||||
static inline IterationDecision for_each(Callback callback)
|
||||
|
|
|
@ -128,7 +128,7 @@ static_assert(AssertSize<RegisterState, REGISTER_STATE_SIZE>());
|
|||
static_assert(AssertSize<RegisterState, REGISTER_STATE_SIZE>());
|
||||
#endif
|
||||
|
||||
inline void copy_kernel_registers_into_ptrace_registers(PtraceRegisters& ptrace_regs, const RegisterState& kernel_regs)
|
||||
inline void copy_kernel_registers_into_ptrace_registers(PtraceRegisters& ptrace_regs, RegisterState const& kernel_regs)
|
||||
{
|
||||
#if ARCH(I386)
|
||||
ptrace_regs.eax = kernel_regs.eax;
|
||||
|
@ -169,7 +169,7 @@ inline void copy_kernel_registers_into_ptrace_registers(PtraceRegisters& ptrace_
|
|||
ptrace_regs.gs = 0;
|
||||
}
|
||||
|
||||
inline void copy_ptrace_registers_into_kernel_registers(RegisterState& kernel_regs, const PtraceRegisters& ptrace_regs)
|
||||
inline void copy_ptrace_registers_into_kernel_registers(RegisterState& kernel_regs, PtraceRegisters const& ptrace_regs)
|
||||
{
|
||||
#if ARCH(I386)
|
||||
kernel_regs.eax = ptrace_regs.eax;
|
||||
|
@ -224,7 +224,7 @@ inline void read_debug_registers_into(DebugRegisterState& state)
|
|||
state.dr7 = read_dr7();
|
||||
}
|
||||
|
||||
inline void write_debug_registers_from(const DebugRegisterState& state)
|
||||
inline void write_debug_registers_from(DebugRegisterState const& state)
|
||||
{
|
||||
write_dr0(state.dr0);
|
||||
write_dr1(state.dr1);
|
||||
|
|
|
@ -14,16 +14,16 @@ namespace Kernel {
|
|||
|
||||
struct RegisterState;
|
||||
|
||||
[[nodiscard]] bool safe_memcpy(void* dest_ptr, const void* src_ptr, size_t n, void*& fault_at) __attribute__((used));
|
||||
[[nodiscard]] ssize_t safe_strnlen(const char* str, size_t max_n, void*& fault_at) __attribute__((used));
|
||||
[[nodiscard]] bool safe_memcpy(void* dest_ptr, void const* src_ptr, size_t n, void*& fault_at) __attribute__((used));
|
||||
[[nodiscard]] ssize_t safe_strnlen(char const* str, size_t max_n, void*& fault_at) __attribute__((used));
|
||||
[[nodiscard]] bool safe_memset(void* dest_ptr, int c, size_t n, void*& fault_at) __attribute__((used));
|
||||
[[nodiscard]] Optional<u32> safe_atomic_fetch_add_relaxed(volatile u32* var, u32 val) __attribute__((used));
|
||||
[[nodiscard]] Optional<u32> safe_atomic_exchange_relaxed(volatile u32* var, u32 val) __attribute__((used));
|
||||
[[nodiscard]] Optional<u32> safe_atomic_load_relaxed(volatile u32* var) __attribute__((used));
|
||||
[[nodiscard]] bool safe_atomic_store_relaxed(volatile u32* var, u32 val) __attribute__((used));
|
||||
[[nodiscard]] Optional<bool> safe_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val) __attribute__((used));
|
||||
[[nodiscard]] Optional<u32> safe_atomic_fetch_add_relaxed(u32 volatile* var, u32 val) __attribute__((used));
|
||||
[[nodiscard]] Optional<u32> safe_atomic_exchange_relaxed(u32 volatile* var, u32 val) __attribute__((used));
|
||||
[[nodiscard]] Optional<u32> safe_atomic_load_relaxed(u32 volatile* var) __attribute__((used));
|
||||
[[nodiscard]] bool safe_atomic_store_relaxed(u32 volatile* var, u32 val) __attribute__((used));
|
||||
[[nodiscard]] Optional<bool> safe_atomic_compare_exchange_relaxed(u32 volatile* var, u32& expected, u32 val) __attribute__((used));
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_and_relaxed(volatile u32* var, u32 val)
|
||||
[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_and_relaxed(u32 volatile* var, u32 val)
|
||||
{
|
||||
auto expected_value = safe_atomic_load_relaxed(var);
|
||||
if (!expected_value.has_value())
|
||||
|
@ -41,7 +41,7 @@ struct RegisterState;
|
|||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_and_not_relaxed(volatile u32* var, u32 val)
|
||||
[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_and_not_relaxed(u32 volatile* var, u32 val)
|
||||
{
|
||||
auto expected_value = safe_atomic_load_relaxed(var);
|
||||
if (!expected_value.has_value())
|
||||
|
@ -59,7 +59,7 @@ struct RegisterState;
|
|||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_or_relaxed(volatile u32* var, u32 val)
|
||||
[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_or_relaxed(u32 volatile* var, u32 val)
|
||||
{
|
||||
auto expected_value = safe_atomic_load_relaxed(var);
|
||||
if (!expected_value.has_value())
|
||||
|
@ -77,7 +77,7 @@ struct RegisterState;
|
|||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_xor_relaxed(volatile u32* var, u32 val)
|
||||
[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_xor_relaxed(u32 volatile* var, u32 val)
|
||||
{
|
||||
auto expected_value = safe_atomic_load_relaxed(var);
|
||||
if (!expected_value.has_value())
|
||||
|
|
|
@ -42,7 +42,7 @@ struct [[gnu::packed]] TSS64 {
|
|||
u32 rsp1h;
|
||||
u32 rsp2l;
|
||||
u32 rsp2h;
|
||||
u64 __2; //probably CR3 and EIP?
|
||||
u64 __2; // probably CR3 and EIP?
|
||||
u32 ist1l;
|
||||
u32 ist1h;
|
||||
u32 ist2l;
|
||||
|
|
|
@ -21,9 +21,9 @@ struct TrapFrame {
|
|||
RegisterState* regs; // must be last
|
||||
|
||||
TrapFrame() = delete;
|
||||
TrapFrame(const TrapFrame&) = delete;
|
||||
TrapFrame(TrapFrame const&) = delete;
|
||||
TrapFrame(TrapFrame&&) = delete;
|
||||
TrapFrame& operator=(const TrapFrame&) = delete;
|
||||
TrapFrame& operator=(TrapFrame const&) = delete;
|
||||
TrapFrame& operator=(TrapFrame&&) = delete;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
using namespace Kernel;
|
||||
|
||||
void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func)
|
||||
void __assertion_failed(char const* msg, char const* file, unsigned line, char const* func)
|
||||
{
|
||||
asm volatile("cli");
|
||||
critical_dmesgln("ASSERTION FAILED: {}", msg);
|
||||
|
|
|
@ -174,7 +174,7 @@ static EntropySource s_entropy_source_interrupts { EntropySource::Static::Interr
|
|||
|
||||
// clang-format on
|
||||
|
||||
static void dump(const RegisterState& regs)
|
||||
static void dump(RegisterState const& regs)
|
||||
{
|
||||
#if ARCH(I386)
|
||||
u16 ss;
|
||||
|
@ -522,7 +522,7 @@ void handle_interrupt(TrapFrame* trap)
|
|||
handler->eoi();
|
||||
}
|
||||
|
||||
const DescriptorTablePointer& get_idtr()
|
||||
DescriptorTablePointer const& get_idtr()
|
||||
{
|
||||
return s_idtr;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ READONLY_AFTER_INIT FPUState Processor::s_clean_fpu_state;
|
|||
|
||||
READONLY_AFTER_INIT static ProcessorContainer s_processors {};
|
||||
READONLY_AFTER_INIT Atomic<u32> Processor::g_total_processors;
|
||||
READONLY_AFTER_INIT static volatile bool s_smp_enabled;
|
||||
READONLY_AFTER_INIT static bool volatile s_smp_enabled;
|
||||
|
||||
static Atomic<ProcessorMessage*> s_message_pool;
|
||||
Atomic<u32> Processor::s_idle_cpu_mask { 0 };
|
||||
|
@ -775,7 +775,7 @@ void Processor::flush_gdt()
|
|||
: "memory");
|
||||
}
|
||||
|
||||
const DescriptorTablePointer& Processor::get_gdtr()
|
||||
DescriptorTablePointer const& Processor::get_gdtr()
|
||||
{
|
||||
return m_gdtr;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ ALWAYS_INLINE bool validate_canonical_address(size_t address)
|
|||
}
|
||||
|
||||
CODE_SECTION(".text.safemem")
|
||||
NEVER_INLINE bool safe_memcpy(void* dest_ptr, const void* src_ptr, size_t n, void*& fault_at)
|
||||
NEVER_INLINE bool safe_memcpy(void* dest_ptr, void const* src_ptr, size_t n, void*& fault_at)
|
||||
{
|
||||
fault_at = nullptr;
|
||||
size_t dest = (size_t)dest_ptr;
|
||||
|
@ -115,7 +115,7 @@ NEVER_INLINE bool safe_memcpy(void* dest_ptr, const void* src_ptr, size_t n, voi
|
|||
}
|
||||
|
||||
CODE_SECTION(".text.safemem")
|
||||
NEVER_INLINE ssize_t safe_strnlen(const char* str, size_t max_n, void*& fault_at)
|
||||
NEVER_INLINE ssize_t safe_strnlen(char const* str, size_t max_n, void*& fault_at)
|
||||
{
|
||||
if (!validate_canonical_address((size_t)str)) {
|
||||
fault_at = const_cast<char*>(str);
|
||||
|
@ -210,7 +210,7 @@ NEVER_INLINE bool safe_memset(void* dest_ptr, int c, size_t n, void*& fault_at)
|
|||
}
|
||||
|
||||
CODE_SECTION(".text.safemem.atomic")
|
||||
NEVER_INLINE Optional<u32> safe_atomic_fetch_add_relaxed(volatile u32* var, u32 val)
|
||||
NEVER_INLINE Optional<u32> safe_atomic_fetch_add_relaxed(u32 volatile* var, u32 val)
|
||||
{
|
||||
u32 result;
|
||||
bool error;
|
||||
|
@ -230,7 +230,7 @@ NEVER_INLINE Optional<u32> safe_atomic_fetch_add_relaxed(volatile u32* var, u32
|
|||
}
|
||||
|
||||
CODE_SECTION(".text.safemem.atomic")
|
||||
NEVER_INLINE Optional<u32> safe_atomic_exchange_relaxed(volatile u32* var, u32 val)
|
||||
NEVER_INLINE Optional<u32> safe_atomic_exchange_relaxed(u32 volatile* var, u32 val)
|
||||
{
|
||||
u32 result;
|
||||
bool error;
|
||||
|
@ -250,7 +250,7 @@ NEVER_INLINE Optional<u32> safe_atomic_exchange_relaxed(volatile u32* var, u32 v
|
|||
}
|
||||
|
||||
CODE_SECTION(".text.safemem.atomic")
|
||||
NEVER_INLINE Optional<u32> safe_atomic_load_relaxed(volatile u32* var)
|
||||
NEVER_INLINE Optional<u32> safe_atomic_load_relaxed(u32 volatile* var)
|
||||
{
|
||||
u32 result;
|
||||
bool error;
|
||||
|
@ -270,7 +270,7 @@ NEVER_INLINE Optional<u32> safe_atomic_load_relaxed(volatile u32* var)
|
|||
}
|
||||
|
||||
CODE_SECTION(".text.safemem.atomic")
|
||||
NEVER_INLINE bool safe_atomic_store_relaxed(volatile u32* var, u32 val)
|
||||
NEVER_INLINE bool safe_atomic_store_relaxed(u32 volatile* var, u32 val)
|
||||
{
|
||||
bool error;
|
||||
asm volatile(
|
||||
|
@ -287,7 +287,7 @@ NEVER_INLINE bool safe_atomic_store_relaxed(volatile u32* var, u32 val)
|
|||
}
|
||||
|
||||
CODE_SECTION(".text.safemem.atomic")
|
||||
NEVER_INLINE Optional<bool> safe_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val)
|
||||
NEVER_INLINE Optional<bool> safe_atomic_compare_exchange_relaxed(u32 volatile* var, u32& expected, u32 val)
|
||||
{
|
||||
// NOTE: accessing expected is NOT protected as it should always point
|
||||
// to a valid location in kernel memory!
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#define __STRINGIFY_HELPER(x) #x
|
||||
#define __STRINGIFY(x) __STRINGIFY_HELPER(x)
|
||||
|
||||
[[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func);
|
||||
[[noreturn]] void __assertion_failed(char const* msg, char const* file, unsigned line, char const* func);
|
||||
#define VERIFY(expr) \
|
||||
do { \
|
||||
if (!static_cast<bool>(expr)) [[unlikely]] \
|
||||
|
|
|
@ -28,7 +28,7 @@ extern "C" PhysicalAddress boot_pdpt;
|
|||
extern "C" PhysicalAddress boot_pd0;
|
||||
extern "C" PhysicalAddress boot_pd_kernel;
|
||||
extern "C" Kernel::PageTableEntry* boot_pd_kernel_pt1023;
|
||||
extern "C" const char* kernel_cmdline;
|
||||
extern "C" char const* kernel_cmdline;
|
||||
extern "C" u32 multiboot_flags;
|
||||
extern "C" multiboot_memory_map_t* multiboot_memory_map;
|
||||
extern "C" size_t multiboot_memory_map_count;
|
||||
|
|
|
@ -26,7 +26,7 @@ u8 MemoryBackedHostBridge::read8_field(BusNumber bus, DeviceNumber device, Funct
|
|||
{
|
||||
VERIFY(Access::the().access_lock().is_locked());
|
||||
VERIFY(field <= 0xfff);
|
||||
return *((volatile u8*)(get_device_configuration_memory_mapped_space(bus, device, function).get() + (field & 0xfff)));
|
||||
return *((u8 volatile*)(get_device_configuration_memory_mapped_space(bus, device, function).get() + (field & 0xfff)));
|
||||
}
|
||||
u16 MemoryBackedHostBridge::read16_field(BusNumber bus, DeviceNumber device, FunctionNumber function, u32 field)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ void MemoryBackedHostBridge::write8_field(BusNumber bus, DeviceNumber device, Fu
|
|||
{
|
||||
VERIFY(Access::the().access_lock().is_locked());
|
||||
VERIFY(field <= 0xfff);
|
||||
*((volatile u8*)(get_device_configuration_memory_mapped_space(bus, device, function).get() + (field & 0xfff))) = value;
|
||||
*((u8 volatile*)(get_device_configuration_memory_mapped_space(bus, device, function).get() + (field & 0xfff))) = value;
|
||||
}
|
||||
void MemoryBackedHostBridge::write16_field(BusNumber bus, DeviceNumber device, FunctionNumber function, u32 field, u16 value)
|
||||
{
|
||||
|
|
|
@ -115,11 +115,11 @@ struct HardwareID {
|
|||
|
||||
bool is_null() const { return !vendor_id && !device_id; }
|
||||
|
||||
bool operator==(const HardwareID& other) const
|
||||
bool operator==(HardwareID const& other) const
|
||||
{
|
||||
return vendor_id == other.vendor_id && device_id == other.device_id;
|
||||
}
|
||||
bool operator!=(const HardwareID& other) const
|
||||
bool operator!=(HardwareID const& other) const
|
||||
{
|
||||
return vendor_id != other.vendor_id || device_id != other.device_id;
|
||||
}
|
||||
|
@ -162,24 +162,24 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
Address(const Address& address) = default;
|
||||
Address(Address const& address) = default;
|
||||
|
||||
bool is_null() const { return !m_bus && !m_device && !m_function; }
|
||||
operator bool() const { return !is_null(); }
|
||||
|
||||
// Disable default implementations that would use surprising integer promotion.
|
||||
bool operator<=(const Address&) const = delete;
|
||||
bool operator>=(const Address&) const = delete;
|
||||
bool operator<(const Address&) const = delete;
|
||||
bool operator>(const Address&) const = delete;
|
||||
bool operator<=(Address const&) const = delete;
|
||||
bool operator>=(Address const&) const = delete;
|
||||
bool operator<(Address const&) const = delete;
|
||||
bool operator>(Address const&) const = delete;
|
||||
|
||||
bool operator==(const Address& other) const
|
||||
bool operator==(Address const& other) const
|
||||
{
|
||||
if (this == &other)
|
||||
return true;
|
||||
return m_domain == other.m_domain && m_bus == other.m_bus && m_device == other.m_device && m_function == other.m_function;
|
||||
}
|
||||
bool operator!=(const Address& other) const
|
||||
bool operator!=(Address const& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ private:
|
|||
|
||||
class Capability {
|
||||
public:
|
||||
Capability(const Address& address, u8 id, u8 ptr)
|
||||
Capability(Address const& address, u8 id, u8 ptr)
|
||||
: m_address(address)
|
||||
, m_id(id)
|
||||
, m_ptr(ptr)
|
||||
|
@ -246,7 +246,7 @@ public:
|
|||
, m_capabilities(capabilities)
|
||||
{
|
||||
if constexpr (PCI_DEBUG) {
|
||||
for (const auto& capability : capabilities)
|
||||
for (auto const& capability : capabilities)
|
||||
dbgln("{} has capability {}", address, capability.id());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
namespace Kernel::PCI {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(const SysFSDirectory& parent_directory, Address address)
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(SysFSDirectory const& parent_directory, Address address)
|
||||
{
|
||||
// FIXME: Handle allocation failure gracefully
|
||||
auto device_name = MUST(KString::formatted("{:04x}:{:02x}:{:02x}.{}", address.domain(), address.bus(), address.device(), address.function()));
|
||||
return adopt_ref(*new (nothrow) PCIDeviceSysFSDirectory(move(device_name), parent_directory, address));
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(NonnullOwnPtr<KString> device_directory_name, const SysFSDirectory& parent_directory, Address address)
|
||||
UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(NonnullOwnPtr<KString> device_directory_name, SysFSDirectory const& parent_directory, Address address)
|
||||
: SysFSDirectory(parent_directory)
|
||||
, m_address(address)
|
||||
, m_device_directory_name(move(device_directory_name))
|
||||
|
@ -92,12 +92,12 @@ StringView PCIDeviceAttributeSysFSComponent::name() const
|
|||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<PCIDeviceAttributeSysFSComponent> PCIDeviceAttributeSysFSComponent::create(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
NonnullRefPtr<PCIDeviceAttributeSysFSComponent> PCIDeviceAttributeSysFSComponent::create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) PCIDeviceAttributeSysFSComponent(device, offset, field_bytes_width));
|
||||
}
|
||||
|
||||
PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
: SysFSComponent()
|
||||
, m_device(device)
|
||||
, m_offset(offset)
|
||||
|
|
|
@ -23,13 +23,13 @@ private:
|
|||
|
||||
class PCIDeviceSysFSDirectory final : public SysFSDirectory {
|
||||
public:
|
||||
static NonnullRefPtr<PCIDeviceSysFSDirectory> create(const SysFSDirectory&, Address);
|
||||
const Address& address() const { return m_address; }
|
||||
static NonnullRefPtr<PCIDeviceSysFSDirectory> create(SysFSDirectory const&, Address);
|
||||
Address const& address() const { return m_address; }
|
||||
|
||||
virtual StringView name() const override { return m_device_directory_name->view(); }
|
||||
|
||||
private:
|
||||
PCIDeviceSysFSDirectory(NonnullOwnPtr<KString> device_directory_name, const SysFSDirectory&, Address);
|
||||
PCIDeviceSysFSDirectory(NonnullOwnPtr<KString> device_directory_name, SysFSDirectory const&, Address);
|
||||
|
||||
Address m_address;
|
||||
|
||||
|
@ -38,7 +38,7 @@ private:
|
|||
|
||||
class PCIDeviceAttributeSysFSComponent : public SysFSComponent {
|
||||
public:
|
||||
static NonnullRefPtr<PCIDeviceAttributeSysFSComponent> create(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
static NonnullRefPtr<PCIDeviceAttributeSysFSComponent> create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
virtual ~PCIDeviceAttributeSysFSComponent() {};
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
protected:
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const;
|
||||
PCIDeviceAttributeSysFSComponent(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
PCIDeviceAttributeSysFSComponent(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
NonnullRefPtr<PCIDeviceSysFSDirectory> m_device;
|
||||
PCI::RegisterOffset m_offset;
|
||||
size_t m_field_bytes_width;
|
||||
|
|
|
@ -476,7 +476,7 @@ ErrorOr<void> UHCIController::spawn_port_process()
|
|||
return {};
|
||||
}
|
||||
|
||||
bool UHCIController::handle_irq(const RegisterState&)
|
||||
bool UHCIController::handle_irq(RegisterState const&)
|
||||
{
|
||||
u32 status = read_usbsts();
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ private:
|
|||
void write_portsc1(u16 value) { m_io_base.offset(0x10).out(value); }
|
||||
void write_portsc2(u16 value) { m_io_base.offset(0x12).out(value); }
|
||||
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(RegisterState const&) override;
|
||||
|
||||
ErrorOr<void> create_structures();
|
||||
void setup_schedule();
|
||||
|
|
|
@ -185,11 +185,11 @@ struct alignas(16) TransferDescriptor final {
|
|||
|
||||
// FIXME: For the love of God, use AK SMART POINTERS PLEASE!!
|
||||
TransferDescriptor* next_td() { return m_next_td; }
|
||||
const TransferDescriptor* next_td() const { return m_next_td; }
|
||||
TransferDescriptor const* next_td() const { return m_next_td; }
|
||||
void set_next_td(TransferDescriptor* td) { m_next_td = td; }
|
||||
|
||||
TransferDescriptor* prev_td() { return m_prev_td; }
|
||||
const TransferDescriptor* prev_td() const { return m_prev_td; }
|
||||
TransferDescriptor const* prev_td() const { return m_prev_td; }
|
||||
void set_previous_td(TransferDescriptor* td) { m_prev_td = td; }
|
||||
|
||||
void insert_next_transfer_descriptor(TransferDescriptor* td)
|
||||
|
@ -274,11 +274,11 @@ struct alignas(16) QueueHead {
|
|||
|
||||
// FIXME: For the love of God, use AK SMART POINTERS PLEASE!!
|
||||
QueueHead* next_qh() { return m_next_qh; }
|
||||
const QueueHead* next_qh() const { return m_next_qh; }
|
||||
QueueHead const* next_qh() const { return m_next_qh; }
|
||||
void set_next_qh(QueueHead* qh) { m_next_qh = qh; }
|
||||
|
||||
QueueHead* prev_qh() { return m_prev_qh; }
|
||||
const QueueHead* prev_qh() const { return m_prev_qh; }
|
||||
QueueHead const* prev_qh() const { return m_prev_qh; }
|
||||
void set_previous_qh(QueueHead* qh)
|
||||
{
|
||||
m_prev_qh = qh;
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
u8 address() const { return m_address; }
|
||||
|
||||
const USBDeviceDescriptor& device_descriptor() const { return m_device_descriptor; }
|
||||
USBDeviceDescriptor const& device_descriptor() const { return m_device_descriptor; }
|
||||
|
||||
USBController& controller() { return *m_controller; }
|
||||
USBController const& controller() const { return *m_controller; }
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
static constexpr u8 ENDPOINT_ATTRIBUTES_ISO_MODE_SYNC_TYPE = 0x0c;
|
||||
static constexpr u8 ENDPOINT_ATTRIBUTES_ISO_MODE_USAGE_TYPE = 0x30;
|
||||
|
||||
const USBEndpointDescriptor& descriptor() const { return m_descriptor; }
|
||||
USBEndpointDescriptor const& descriptor() const { return m_descriptor; }
|
||||
|
||||
bool is_control() const { return (m_descriptor.endpoint_attributes_bitmap & ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_MASK) == ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_CONTROL; }
|
||||
bool is_isochronous() const { return (m_descriptor.endpoint_attributes_bitmap & ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_MASK) == ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_ISOCHRONOUS; }
|
||||
|
|
|
@ -26,7 +26,7 @@ Transfer::Transfer(Pipe& pipe, u16 len, NonnullOwnPtr<Memory::Region> data_buffe
|
|||
|
||||
Transfer::~Transfer() = default;
|
||||
|
||||
void Transfer::set_setup_packet(const USBRequestData& request)
|
||||
void Transfer::set_setup_packet(USBRequestData const& request)
|
||||
{
|
||||
// Kind of a nasty hack... Because the kernel isn't in the business
|
||||
// of handing out physical pointers that we can directly write to,
|
||||
|
|
|
@ -24,13 +24,13 @@ public:
|
|||
Transfer() = delete;
|
||||
~Transfer();
|
||||
|
||||
void set_setup_packet(const USBRequestData& request);
|
||||
void set_setup_packet(USBRequestData const& request);
|
||||
void set_complete() { m_complete = true; }
|
||||
void set_error_occurred() { m_error_occurred = true; }
|
||||
|
||||
// `const` here makes sure we don't blow up by writing to a physical address
|
||||
const USBRequestData& request() const { return m_request; }
|
||||
const Pipe& pipe() const { return m_pipe; }
|
||||
USBRequestData const& request() const { return m_request; }
|
||||
Pipe const& pipe() const { return m_pipe; }
|
||||
Pipe& pipe() { return m_pipe; }
|
||||
VirtualAddress buffer() const { return m_data_buffer->vaddr(); }
|
||||
PhysicalAddress buffer_physical() const { return m_data_buffer->physical_page(0)->paddr(); }
|
||||
|
|
|
@ -92,7 +92,7 @@ void ConsolePort::handle_queue_update(Badge<VirtIO::Console>, u16 queue_index)
|
|||
}
|
||||
}
|
||||
|
||||
bool ConsolePort::can_read(const OpenFileDescription&, u64) const
|
||||
bool ConsolePort::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return m_receive_buffer->used_bytes() > 0;
|
||||
}
|
||||
|
@ -122,12 +122,12 @@ ErrorOr<size_t> ConsolePort::read(OpenFileDescription& desc, u64, UserOrKernelBu
|
|||
return bytes_copied;
|
||||
}
|
||||
|
||||
bool ConsolePort::can_write(const OpenFileDescription&, u64) const
|
||||
bool ConsolePort::can_write(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return m_console.get_queue(m_transmit_queue).has_free_slots() && m_transmit_buffer->has_space();
|
||||
}
|
||||
|
||||
ErrorOr<size_t> ConsolePort::write(OpenFileDescription& desc, u64, const UserOrKernelBuffer& data, size_t size)
|
||||
ErrorOr<size_t> ConsolePort::write(OpenFileDescription& desc, u64, UserOrKernelBuffer const& data, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return 0;
|
||||
|
|
|
@ -40,10 +40,10 @@ private:
|
|||
|
||||
virtual StringView class_name() const override { return "VirtIOConsolePort"sv; }
|
||||
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
|
||||
|
||||
static unsigned next_device_id;
|
||||
|
|
|
@ -179,37 +179,37 @@ void Device::notify_queue(u16 queue_index)
|
|||
config_write16(*m_notify_cfg, get_queue(queue_index).notify_offset() * m_notify_multiplier, queue_index);
|
||||
}
|
||||
|
||||
u8 Device::config_read8(const Configuration& config, u32 offset)
|
||||
u8 Device::config_read8(Configuration const& config, u32 offset)
|
||||
{
|
||||
return mapping_for_bar(config.bar).read<u8>(config.offset + offset);
|
||||
}
|
||||
|
||||
u16 Device::config_read16(const Configuration& config, u32 offset)
|
||||
u16 Device::config_read16(Configuration const& config, u32 offset)
|
||||
{
|
||||
return mapping_for_bar(config.bar).read<u16>(config.offset + offset);
|
||||
}
|
||||
|
||||
u32 Device::config_read32(const Configuration& config, u32 offset)
|
||||
u32 Device::config_read32(Configuration const& config, u32 offset)
|
||||
{
|
||||
return mapping_for_bar(config.bar).read<u32>(config.offset + offset);
|
||||
}
|
||||
|
||||
void Device::config_write8(const Configuration& config, u32 offset, u8 value)
|
||||
void Device::config_write8(Configuration const& config, u32 offset, u8 value)
|
||||
{
|
||||
mapping_for_bar(config.bar).write(config.offset + offset, value);
|
||||
}
|
||||
|
||||
void Device::config_write16(const Configuration& config, u32 offset, u16 value)
|
||||
void Device::config_write16(Configuration const& config, u32 offset, u16 value)
|
||||
{
|
||||
mapping_for_bar(config.bar).write(config.offset + offset, value);
|
||||
}
|
||||
|
||||
void Device::config_write32(const Configuration& config, u32 offset, u32 value)
|
||||
void Device::config_write32(Configuration const& config, u32 offset, u32 value)
|
||||
{
|
||||
mapping_for_bar(config.bar).write(config.offset + offset, value);
|
||||
}
|
||||
|
||||
void Device::config_write64(const Configuration& config, u32 offset, u64 value)
|
||||
void Device::config_write64(Configuration const& config, u32 offset, u64 value)
|
||||
{
|
||||
mapping_for_bar(config.bar).write(config.offset + offset, value);
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ u8 Device::isr_status()
|
|||
return config_read8(*m_isr_cfg, 0);
|
||||
}
|
||||
|
||||
bool Device::handle_irq(const RegisterState&)
|
||||
bool Device::handle_irq(RegisterState const&)
|
||||
{
|
||||
u8 isr_type = isr_status();
|
||||
if ((isr_type & (QUEUE_INTERRUPT | DEVICE_CONFIG_INTERRUPT)) == 0) {
|
||||
|
|
|
@ -119,7 +119,7 @@ protected:
|
|||
}
|
||||
};
|
||||
|
||||
const Configuration* get_config(ConfigurationType cfg_type, u32 index = 0) const
|
||||
Configuration const* get_config(ConfigurationType cfg_type, u32 index = 0) const
|
||||
{
|
||||
for (auto const& cfg : m_configs) {
|
||||
if (cfg.cfg_type != cfg_type)
|
||||
|
@ -148,13 +148,13 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
u8 config_read8(const Configuration&, u32);
|
||||
u16 config_read16(const Configuration&, u32);
|
||||
u32 config_read32(const Configuration&, u32);
|
||||
void config_write8(const Configuration&, u32, u8);
|
||||
void config_write16(const Configuration&, u32, u16);
|
||||
void config_write32(const Configuration&, u32, u32);
|
||||
void config_write64(const Configuration&, u32, u64);
|
||||
u8 config_read8(Configuration const&, u32);
|
||||
u16 config_read16(Configuration const&, u32);
|
||||
u32 config_read32(Configuration const&, u32);
|
||||
void config_write8(Configuration const&, u32, u8);
|
||||
void config_write16(Configuration const&, u32, u16);
|
||||
void config_write32(Configuration const&, u32, u32);
|
||||
void config_write64(Configuration const&, u32, u64);
|
||||
|
||||
auto mapping_for_bar(u8) -> MappedMMIO&;
|
||||
|
||||
|
@ -171,7 +171,7 @@ protected:
|
|||
return m_queues[queue_index];
|
||||
}
|
||||
|
||||
const Queue& get_queue(u16 queue_index) const
|
||||
Queue const& get_queue(u16 queue_index) const
|
||||
{
|
||||
VERIFY(queue_index < m_queue_count);
|
||||
return m_queues[queue_index];
|
||||
|
@ -224,13 +224,13 @@ private:
|
|||
void reset_device();
|
||||
|
||||
u8 isr_status();
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(RegisterState const&) override;
|
||||
|
||||
NonnullOwnPtrVector<Queue> m_queues;
|
||||
Vector<Configuration> m_configs;
|
||||
const Configuration* m_common_cfg { nullptr }; // Cached due to high usage
|
||||
const Configuration* m_notify_cfg { nullptr }; // Cached due to high usage
|
||||
const Configuration* m_isr_cfg { nullptr }; // Cached due to high usage
|
||||
Configuration const* m_common_cfg { nullptr }; // Cached due to high usage
|
||||
Configuration const* m_notify_cfg { nullptr }; // Cached due to high usage
|
||||
Configuration const* m_isr_cfg { nullptr }; // Cached due to high usage
|
||||
|
||||
IOAddress m_io_base;
|
||||
MappedMMIO m_mmio[6];
|
||||
|
|
|
@ -60,8 +60,8 @@ void Queue::disable_interrupts()
|
|||
|
||||
bool Queue::new_data_available() const
|
||||
{
|
||||
const auto index = AK::atomic_load(&m_device->index, AK::MemoryOrder::memory_order_relaxed);
|
||||
const auto used_tail = AK::atomic_load(&m_used_tail, AK::MemoryOrder::memory_order_relaxed);
|
||||
auto const index = AK::atomic_load(&m_device->index, AK::MemoryOrder::memory_order_relaxed);
|
||||
auto const used_tail = AK::atomic_load(&m_used_tail, AK::MemoryOrder::memory_order_relaxed);
|
||||
return index != used_tail;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ void Queue::reclaim_buffer_chain(u16 chain_start_index, u16 chain_end_index, siz
|
|||
|
||||
bool Queue::has_free_slots() const
|
||||
{
|
||||
const auto free_buffers = AK::atomic_load(&m_free_buffers, AK::MemoryOrder::memory_order_relaxed);
|
||||
auto const free_buffers = AK::atomic_load(&m_free_buffers, AK::MemoryOrder::memory_order_relaxed);
|
||||
return free_buffers > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ private:
|
|||
|
||||
void reclaim_buffer_chain(u16 chain_start_index, u16 chain_end_index, size_t length_of_chain);
|
||||
|
||||
PhysicalAddress to_physical(const void* ptr) const
|
||||
PhysicalAddress to_physical(void const* ptr) const
|
||||
{
|
||||
auto offset = FlatPtr(ptr) - m_queue_region->vaddr().get();
|
||||
return m_queue_region->physical_page(0)->paddr().offset(offset);
|
||||
|
|
|
@ -16,7 +16,7 @@ static char s_cmd_line[1024];
|
|||
static constexpr StringView s_embedded_cmd_line = "";
|
||||
static CommandLine* s_the;
|
||||
|
||||
UNMAP_AFTER_INIT void CommandLine::early_initialize(const char* cmd_line)
|
||||
UNMAP_AFTER_INIT void CommandLine::early_initialize(char const* cmd_line)
|
||||
{
|
||||
if (!cmd_line)
|
||||
return;
|
||||
|
@ -32,7 +32,7 @@ bool CommandLine::was_initialized()
|
|||
return s_the != nullptr;
|
||||
}
|
||||
|
||||
const CommandLine& kernel_command_line()
|
||||
CommandLine const& kernel_command_line()
|
||||
{
|
||||
VERIFY(s_the);
|
||||
return *s_the;
|
||||
|
@ -64,7 +64,7 @@ UNMAP_AFTER_INIT NonnullOwnPtr<KString> CommandLine::build_commandline(StringVie
|
|||
return KString::must_create(builder.string_view());
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void CommandLine::add_arguments(const Vector<StringView>& args)
|
||||
UNMAP_AFTER_INIT void CommandLine::add_arguments(Vector<StringView> const& args)
|
||||
{
|
||||
for (auto&& str : args) {
|
||||
if (str == ""sv) {
|
||||
|
@ -86,7 +86,7 @@ UNMAP_AFTER_INIT CommandLine::CommandLine(StringView cmdline_from_bootloader)
|
|||
: m_string(build_commandline(cmdline_from_bootloader))
|
||||
{
|
||||
s_the = this;
|
||||
const auto& args = m_string->view().split_view(' ');
|
||||
auto const& args = m_string->view().split_view(' ');
|
||||
m_params.ensure_capacity(args.size());
|
||||
add_arguments(args);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ UNMAP_AFTER_INIT bool CommandLine::disable_virtio() const
|
|||
|
||||
UNMAP_AFTER_INIT AHCIResetMode CommandLine::ahci_reset_mode() const
|
||||
{
|
||||
const auto ahci_reset_mode = lookup("ahci_reset_mode"sv).value_or("controllers"sv);
|
||||
auto const ahci_reset_mode = lookup("ahci_reset_mode"sv).value_or("controllers"sv);
|
||||
if (ahci_reset_mode == "controllers"sv) {
|
||||
return AHCIResetMode::ControllerOnly;
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ StringView CommandLine::system_mode() const
|
|||
|
||||
PanicMode CommandLine::panic_mode(Validate should_validate) const
|
||||
{
|
||||
const auto panic_mode = lookup("panic"sv).value_or("halt"sv);
|
||||
auto const panic_mode = lookup("panic"sv).value_or("halt"sv);
|
||||
if (panic_mode == "halt"sv) {
|
||||
return PanicMode::Halt;
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ PanicMode CommandLine::panic_mode(Validate should_validate) const
|
|||
|
||||
UNMAP_AFTER_INIT auto CommandLine::are_framebuffer_devices_enabled() const -> FrameBufferDevices
|
||||
{
|
||||
const auto fbdev_value = lookup("fbdev"sv).value_or("on"sv);
|
||||
auto const fbdev_value = lookup("fbdev"sv).value_or("on"sv);
|
||||
if (fbdev_value == "on"sv)
|
||||
return FrameBufferDevices::Enabled;
|
||||
if (fbdev_value == "bootloader"sv)
|
||||
|
@ -311,7 +311,7 @@ NonnullOwnPtrVector<KString> CommandLine::userspace_init_args() const
|
|||
|
||||
UNMAP_AFTER_INIT size_t CommandLine::switch_to_tty() const
|
||||
{
|
||||
const auto default_tty = lookup("switch_to_tty"sv).value_or("1"sv);
|
||||
auto const default_tty = lookup("switch_to_tty"sv).value_or("1"sv);
|
||||
auto switch_tty_number = default_tty.to_uint();
|
||||
if (switch_tty_number.has_value() && switch_tty_number.value() >= 1) {
|
||||
return switch_tty_number.value() - 1;
|
||||
|
|
|
@ -44,7 +44,7 @@ enum class AHCIResetMode {
|
|||
class CommandLine {
|
||||
|
||||
public:
|
||||
static void early_initialize(const char* cmd_line);
|
||||
static void early_initialize(char const* cmd_line);
|
||||
static void initialize();
|
||||
static bool was_initialized();
|
||||
|
||||
|
@ -96,13 +96,13 @@ public:
|
|||
private:
|
||||
CommandLine(StringView);
|
||||
|
||||
void add_arguments(const Vector<StringView>& args);
|
||||
void add_arguments(Vector<StringView> const& args);
|
||||
static NonnullOwnPtr<KString> build_commandline(StringView cmdline_from_bootloader);
|
||||
|
||||
NonnullOwnPtr<KString> m_string;
|
||||
HashMap<StringView, StringView> m_params;
|
||||
};
|
||||
|
||||
const CommandLine& kernel_command_line();
|
||||
CommandLine const& kernel_command_line();
|
||||
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
}
|
||||
|
||||
template<typename... Args>
|
||||
ErrorOr<void> read_from_buffer(const UserOrKernelBuffer& buffer, Args... args)
|
||||
ErrorOr<void> read_from_buffer(UserOrKernelBuffer const& buffer, Args... args)
|
||||
{
|
||||
if (in_target_context(buffer))
|
||||
return buffer.read(forward<Args>(args)...);
|
||||
|
@ -108,7 +108,7 @@ public:
|
|||
}
|
||||
|
||||
template<size_t BUFFER_BYTES, typename... Args>
|
||||
ErrorOr<size_t> read_from_buffer_buffered(const UserOrKernelBuffer& buffer, Args... args)
|
||||
ErrorOr<size_t> read_from_buffer_buffered(UserOrKernelBuffer const& buffer, Args... args)
|
||||
{
|
||||
if (in_target_context(buffer))
|
||||
return buffer.read_buffered<BUFFER_BYTES>(forward<Args>(args)...);
|
||||
|
@ -125,7 +125,7 @@ private:
|
|||
void sub_request_finished(AsyncDeviceRequest&);
|
||||
void request_finished();
|
||||
|
||||
[[nodiscard]] bool in_target_context(const UserOrKernelBuffer& buffer) const
|
||||
[[nodiscard]] bool in_target_context(UserOrKernelBuffer const& buffer) const
|
||||
{
|
||||
if (buffer.is_kernel_buffer())
|
||||
return true;
|
||||
|
|
|
@ -147,7 +147,7 @@ private:
|
|||
explicit AC97(PCI::DeviceIdentifier const&);
|
||||
|
||||
// ^IRQHandler
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(RegisterState const&) override;
|
||||
|
||||
AC97Channel channel(StringView name, NativeAudioBusChannel channel) { return AC97Channel(*this, name, m_io_bus_base.offset(channel)); }
|
||||
ErrorOr<void> initialize();
|
||||
|
|
|
@ -50,7 +50,7 @@ ErrorOr<void> AudioChannel::ioctl(OpenFileDescription&, unsigned request, Usersp
|
|||
}
|
||||
}
|
||||
|
||||
bool AudioChannel::can_read(const OpenFileDescription&, u64) const
|
||||
bool AudioChannel::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
// FIXME: Implement input from device
|
||||
return false;
|
||||
|
|
|
@ -24,10 +24,10 @@ public:
|
|||
virtual ~AudioChannel() override = default;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return true; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
|
||||
|
||||
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned, Userspace<void*>) override;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
AsyncBlockDeviceRequest::AsyncBlockDeviceRequest(Device& block_device, RequestType request_type, u64 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size)
|
||||
AsyncBlockDeviceRequest::AsyncBlockDeviceRequest(Device& block_device, RequestType request_type, u64 block_index, u32 block_count, UserOrKernelBuffer const& buffer, size_t buffer_size)
|
||||
: AsyncDeviceRequest(block_device)
|
||||
, m_block_device(static_cast<BlockDevice&>(block_device))
|
||||
, m_request_type(request_type)
|
||||
|
@ -52,7 +52,7 @@ bool BlockDevice::read_block(u64 index, UserOrKernelBuffer& buffer)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BlockDevice::write_block(u64 index, const UserOrKernelBuffer& buffer)
|
||||
bool BlockDevice::write_block(u64 index, UserOrKernelBuffer const& buffer)
|
||||
{
|
||||
auto write_request_or_error = try_make_request<AsyncBlockDeviceRequest>(AsyncBlockDeviceRequest::Write, index, 1, buffer, m_block_size);
|
||||
if (write_request_or_error.is_error()) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
virtual bool is_seekable() const override { return true; }
|
||||
|
||||
bool read_block(u64 index, UserOrKernelBuffer&);
|
||||
bool write_block(u64 index, const UserOrKernelBuffer&);
|
||||
bool write_block(u64 index, UserOrKernelBuffer const&);
|
||||
|
||||
virtual void start_request(AsyncBlockDeviceRequest&) = 0;
|
||||
|
||||
|
@ -52,14 +52,14 @@ public:
|
|||
Write
|
||||
};
|
||||
AsyncBlockDeviceRequest(Device& block_device, RequestType request_type,
|
||||
u64 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size);
|
||||
u64 block_index, u32 block_count, UserOrKernelBuffer const& buffer, size_t buffer_size);
|
||||
|
||||
RequestType request_type() const { return m_request_type; }
|
||||
u64 block_index() const { return m_block_index; }
|
||||
u32 block_count() const { return m_block_count; }
|
||||
size_t block_size() const { return m_block_device.block_size(); }
|
||||
UserOrKernelBuffer& buffer() { return m_buffer; }
|
||||
const UserOrKernelBuffer& buffer() const { return m_buffer; }
|
||||
UserOrKernelBuffer const& buffer() const { return m_buffer; }
|
||||
size_t buffer_size() const { return m_buffer_size; }
|
||||
|
||||
virtual void start() override;
|
||||
|
|
|
@ -30,7 +30,7 @@ UNMAP_AFTER_INIT ConsoleDevice::ConsoleDevice()
|
|||
|
||||
UNMAP_AFTER_INIT ConsoleDevice::~ConsoleDevice() = default;
|
||||
|
||||
bool ConsoleDevice::can_read(const Kernel::OpenFileDescription&, u64) const
|
||||
bool ConsoleDevice::can_read(Kernel::OpenFileDescription const&, u64) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ ErrorOr<size_t> ConsoleDevice::read(OpenFileDescription&, u64, Kernel::UserOrKer
|
|||
return 0;
|
||||
}
|
||||
|
||||
ErrorOr<size_t> ConsoleDevice::write(OpenFileDescription&, u64, const Kernel::UserOrKernelBuffer& data, size_t size)
|
||||
ErrorOr<size_t> ConsoleDevice::write(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer const& data, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return 0;
|
||||
|
|
|
@ -21,15 +21,15 @@ public:
|
|||
virtual ~ConsoleDevice() override;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual bool can_read(const Kernel::OpenFileDescription&, u64) const override;
|
||||
virtual bool can_write(const Kernel::OpenFileDescription&, u64) const override { return true; }
|
||||
virtual bool can_read(Kernel::OpenFileDescription const&, u64) const override;
|
||||
virtual bool can_write(Kernel::OpenFileDescription const&, u64) const override { return true; }
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const Kernel::UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer const&, size_t) override;
|
||||
virtual StringView class_name() const override { return "Console"sv; }
|
||||
|
||||
void put_char(char);
|
||||
|
||||
const CircularQueue<char, 16384>& logbuffer() const { return m_logbuffer; }
|
||||
CircularQueue<char, 16384> const& logbuffer() const { return m_logbuffer; }
|
||||
|
||||
private:
|
||||
ConsoleDevice();
|
||||
|
|
|
@ -146,12 +146,12 @@ Device::~Device()
|
|||
VERIFY(m_state == State::BeingRemoved);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<KString>> Device::pseudo_path(const OpenFileDescription&) const
|
||||
ErrorOr<NonnullOwnPtr<KString>> Device::pseudo_path(OpenFileDescription const&) const
|
||||
{
|
||||
return KString::formatted("device:{},{}", major(), minor());
|
||||
}
|
||||
|
||||
void Device::process_next_queued_request(Badge<AsyncDeviceRequest>, const AsyncDeviceRequest& completed_request)
|
||||
void Device::process_next_queued_request(Badge<AsyncDeviceRequest>, AsyncDeviceRequest const& completed_request)
|
||||
{
|
||||
SpinlockLocker lock(m_requests_lock);
|
||||
VERIFY(!m_requests.is_empty());
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
MajorNumber major() const { return m_major; }
|
||||
MinorNumber minor() const { return m_minor; }
|
||||
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const override;
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const override;
|
||||
|
||||
UserID uid() const { return m_uid; }
|
||||
GroupID gid() const { return m_gid; }
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
virtual bool is_device() const override { return true; }
|
||||
virtual void will_be_destroyed() override;
|
||||
virtual void after_inserting();
|
||||
void process_next_queued_request(Badge<AsyncDeviceRequest>, const AsyncDeviceRequest&);
|
||||
void process_next_queued_request(Badge<AsyncDeviceRequest>, AsyncDeviceRequest const&);
|
||||
|
||||
template<typename AsyncRequestType, typename... Args>
|
||||
ErrorOr<NonnullRefPtr<AsyncRequestType>> try_make_request(Args&&... args)
|
||||
|
|
|
@ -17,7 +17,7 @@ UNMAP_AFTER_INIT NonnullRefPtr<DeviceControlDevice> DeviceControlDevice::must_cr
|
|||
return device_control_device_or_error.release_value();
|
||||
}
|
||||
|
||||
bool DeviceControlDevice::can_read(const OpenFileDescription&, u64) const
|
||||
bool DeviceControlDevice::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ private:
|
|||
// ^CharacterDevice
|
||||
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override;
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return Error::from_errno(ENOTSUP); }
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return false; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return Error::from_errno(ENOTSUP); }
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return false; }
|
||||
virtual StringView class_name() const override { return "DeviceControlDevice"sv; }
|
||||
};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ UNMAP_AFTER_INIT FullDevice::FullDevice()
|
|||
|
||||
UNMAP_AFTER_INIT FullDevice::~FullDevice() = default;
|
||||
|
||||
bool FullDevice::can_read(const OpenFileDescription&, u64) const
|
||||
bool FullDevice::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ ErrorOr<size_t> FullDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer&
|
|||
return size;
|
||||
}
|
||||
|
||||
ErrorOr<size_t> FullDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size)
|
||||
ErrorOr<size_t> FullDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
|
|
@ -22,9 +22,9 @@ private:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return true; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
|
||||
virtual StringView class_name() const override { return "FullDevice"sv; }
|
||||
};
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
virtual void irq_handle_byte_read(u8 byte) = 0;
|
||||
|
||||
protected:
|
||||
explicit I8042Device(const I8042Controller& ps2_controller)
|
||||
explicit I8042Device(I8042Controller const& ps2_controller)
|
||||
: m_i8042_controller(ps2_controller)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ UNMAP_AFTER_INIT KeyboardDevice::KeyboardDevice()
|
|||
// like USB keyboards, we need to remove this
|
||||
UNMAP_AFTER_INIT KeyboardDevice::~KeyboardDevice() = default;
|
||||
|
||||
bool KeyboardDevice::can_read(const OpenFileDescription&, u64) const
|
||||
bool KeyboardDevice::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return !m_queue.is_empty();
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ public:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; }
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return true; }
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; }
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
|
||||
|
||||
// ^HIDDevice
|
||||
virtual Type instrument_type() const override { return Type::Keyboard; }
|
||||
|
|
|
@ -16,7 +16,7 @@ MouseDevice::MouseDevice()
|
|||
|
||||
MouseDevice::~MouseDevice() = default;
|
||||
|
||||
bool MouseDevice::can_read(const OpenFileDescription&, u64) const
|
||||
bool MouseDevice::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
SpinlockLocker lock(m_queue_lock);
|
||||
return !m_queue.is_empty();
|
||||
|
|
|
@ -24,9 +24,9 @@ public:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; }
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return true; }
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; }
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
|
||||
|
||||
// ^HIDDevice
|
||||
virtual Type instrument_type() const override { return Type::Mouse; }
|
||||
|
|
|
@ -79,14 +79,14 @@ void PS2KeyboardDevice::irq_handle_byte_read(u8 byte)
|
|||
}
|
||||
}
|
||||
|
||||
bool PS2KeyboardDevice::handle_irq(const RegisterState&)
|
||||
bool PS2KeyboardDevice::handle_irq(RegisterState const&)
|
||||
{
|
||||
// The controller will read the data and call irq_handle_byte_read
|
||||
// for the appropriate device
|
||||
return m_i8042_controller->irq_process_input_buffer(HIDDevice::Type::Keyboard);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2KeyboardDevice>> PS2KeyboardDevice::try_to_initialize(const I8042Controller& ps2_controller)
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2KeyboardDevice>> PS2KeyboardDevice::try_to_initialize(I8042Controller const& ps2_controller)
|
||||
{
|
||||
auto keyboard_device = TRY(DeviceManagement::try_create_device<PS2KeyboardDevice>(ps2_controller));
|
||||
|
||||
|
@ -102,7 +102,7 @@ UNMAP_AFTER_INIT ErrorOr<void> PS2KeyboardDevice::initialize()
|
|||
|
||||
// FIXME: UNMAP_AFTER_INIT might not be correct, because in practice PS/2 devices
|
||||
// are hot pluggable.
|
||||
UNMAP_AFTER_INIT PS2KeyboardDevice::PS2KeyboardDevice(const I8042Controller& ps2_controller)
|
||||
UNMAP_AFTER_INIT PS2KeyboardDevice::PS2KeyboardDevice(I8042Controller const& ps2_controller)
|
||||
: IRQHandler(IRQ_KEYBOARD)
|
||||
, KeyboardDevice()
|
||||
, I8042Device(ps2_controller)
|
||||
|
|
|
@ -23,7 +23,7 @@ class PS2KeyboardDevice final : public IRQHandler
|
|||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<PS2KeyboardDevice>> try_to_initialize(const I8042Controller&);
|
||||
static ErrorOr<NonnullRefPtr<PS2KeyboardDevice>> try_to_initialize(I8042Controller const&);
|
||||
virtual ~PS2KeyboardDevice() override;
|
||||
ErrorOr<void> initialize();
|
||||
|
||||
|
@ -37,10 +37,10 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
explicit PS2KeyboardDevice(const I8042Controller&);
|
||||
explicit PS2KeyboardDevice(I8042Controller const&);
|
||||
|
||||
// ^IRQHandler
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(RegisterState const&) override;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual StringView class_name() const override { return "KeyboardDevice"sv; }
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Kernel {
|
|||
#define PS2MOUSE_INTELLIMOUSE_ID 0x03
|
||||
#define PS2MOUSE_INTELLIMOUSE_EXPLORER_ID 0x04
|
||||
|
||||
UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice(const I8042Controller& ps2_controller)
|
||||
UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice(I8042Controller const& ps2_controller)
|
||||
: IRQHandler(IRQ_MOUSE)
|
||||
, MouseDevice()
|
||||
, I8042Device(ps2_controller)
|
||||
|
@ -28,7 +28,7 @@ UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice(const I8042Controller& ps2_contr
|
|||
|
||||
UNMAP_AFTER_INIT PS2MouseDevice::~PS2MouseDevice() = default;
|
||||
|
||||
bool PS2MouseDevice::handle_irq(const RegisterState&)
|
||||
bool PS2MouseDevice::handle_irq(RegisterState const&)
|
||||
{
|
||||
// The controller will read the data and call irq_handle_byte_read
|
||||
// for the appropriate device
|
||||
|
@ -82,7 +82,7 @@ void PS2MouseDevice::irq_handle_byte_read(u8 byte)
|
|||
}
|
||||
}
|
||||
|
||||
MousePacket PS2MouseDevice::parse_data_packet(const RawPacket& raw_packet)
|
||||
MousePacket PS2MouseDevice::parse_data_packet(RawPacket const& raw_packet)
|
||||
{
|
||||
int x = raw_packet.bytes[1];
|
||||
int y = raw_packet.bytes[2];
|
||||
|
@ -175,7 +175,7 @@ ErrorOr<void> PS2MouseDevice::set_sample_rate(u8 rate)
|
|||
return {};
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2MouseDevice>> PS2MouseDevice::try_to_initialize(const I8042Controller& ps2_controller)
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2MouseDevice>> PS2MouseDevice::try_to_initialize(I8042Controller const& ps2_controller)
|
||||
{
|
||||
auto mouse_device = TRY(DeviceManagement::try_create_device<PS2MouseDevice>(ps2_controller));
|
||||
TRY(mouse_device->initialize());
|
||||
|
|
|
@ -20,7 +20,7 @@ class PS2MouseDevice : public IRQHandler
|
|||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<PS2MouseDevice>> try_to_initialize(const I8042Controller&);
|
||||
static ErrorOr<NonnullRefPtr<PS2MouseDevice>> try_to_initialize(I8042Controller const&);
|
||||
ErrorOr<void> initialize();
|
||||
|
||||
virtual ~PS2MouseDevice() override;
|
||||
|
@ -35,10 +35,10 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
explicit PS2MouseDevice(const I8042Controller&);
|
||||
explicit PS2MouseDevice(I8042Controller const&);
|
||||
|
||||
// ^IRQHandler
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(RegisterState const&) override;
|
||||
|
||||
struct RawPacket {
|
||||
union {
|
||||
|
@ -50,7 +50,7 @@ protected:
|
|||
ErrorOr<u8> read_from_device();
|
||||
ErrorOr<u8> send_command(u8 command);
|
||||
ErrorOr<u8> send_command(u8 command, u8 data);
|
||||
MousePacket parse_data_packet(const RawPacket&);
|
||||
MousePacket parse_data_packet(RawPacket const&);
|
||||
ErrorOr<void> set_sample_rate(u8);
|
||||
ErrorOr<u8> get_device_id();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<VMWareMouseDevice>> VMWareMouseDevice::try_to_initialize(const I8042Controller& ps2_controller)
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<VMWareMouseDevice>> VMWareMouseDevice::try_to_initialize(I8042Controller const& ps2_controller)
|
||||
{
|
||||
// FIXME: return the correct error
|
||||
if (!VMWareBackdoor::the())
|
||||
|
@ -51,7 +51,7 @@ void VMWareMouseDevice::irq_handle_byte_read(u8)
|
|||
evaluate_block_conditions();
|
||||
}
|
||||
|
||||
VMWareMouseDevice::VMWareMouseDevice(const I8042Controller& ps2_controller)
|
||||
VMWareMouseDevice::VMWareMouseDevice(I8042Controller const& ps2_controller)
|
||||
: PS2MouseDevice(ps2_controller)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@ namespace Kernel {
|
|||
class VMWareMouseDevice final : public PS2MouseDevice {
|
||||
public:
|
||||
friend class DeviceManagement;
|
||||
static ErrorOr<NonnullRefPtr<VMWareMouseDevice>> try_to_initialize(const I8042Controller&);
|
||||
static ErrorOr<NonnullRefPtr<VMWareMouseDevice>> try_to_initialize(I8042Controller const&);
|
||||
virtual ~VMWareMouseDevice() override;
|
||||
|
||||
// ^I8042Device
|
||||
virtual void irq_handle_byte_read(u8 byte) override;
|
||||
|
||||
private:
|
||||
explicit VMWareMouseDevice(const I8042Controller&);
|
||||
explicit VMWareMouseDevice(I8042Controller const&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -30,11 +30,11 @@ protected:
|
|||
|
||||
virtual StringView class_name() const override { return "KCOVDevice"sv; }
|
||||
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override final { return true; }
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override final { return true; }
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override final { return true; }
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override final { return true; }
|
||||
virtual void start_request(AsyncBlockDeviceRequest& request) override final { request.complete(AsyncDeviceRequest::Failure); }
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; }
|
||||
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef volatile u64 kcov_pc_t;
|
|||
* for the first time. At this point it is in state OPENED. When a thread in
|
||||
* the same process then uses the KCOV_ENABLE ioctl on the block device, the
|
||||
* instance enters state TRACING.
|
||||
*
|
||||
*
|
||||
* A KCOVInstance in state TRACING can return to state OPENED by either the
|
||||
* KCOV_DISABLE ioctl or by killing the thread. A KCOVInstance in state OPENED
|
||||
* can return to state UNUSED only when the process dies. At this point
|
||||
|
|
|
@ -25,11 +25,11 @@ private:
|
|||
MemoryDevice();
|
||||
|
||||
virtual StringView class_name() const override { return "MemoryDevice"sv; }
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override { return true; }
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return false; }
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override { return true; }
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return false; }
|
||||
virtual bool is_seekable() const override { return true; }
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; }
|
||||
|
||||
bool is_allowed_range(PhysicalAddress, Memory::VirtualRange const&) const;
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ UNMAP_AFTER_INIT NullDevice::NullDevice()
|
|||
|
||||
UNMAP_AFTER_INIT NullDevice::~NullDevice() = default;
|
||||
|
||||
bool NullDevice::can_read(const OpenFileDescription&, u64) const
|
||||
bool NullDevice::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ ErrorOr<size_t> NullDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer&,
|
|||
return 0;
|
||||
}
|
||||
|
||||
ErrorOr<size_t> NullDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t buffer_size)
|
||||
ErrorOr<size_t> NullDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t buffer_size)
|
||||
{
|
||||
return buffer_size;
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ private:
|
|||
NullDevice();
|
||||
// ^CharacterDevice
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return true; }
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual StringView class_name() const override { return "NullDevice"sv; }
|
||||
virtual bool is_seekable() const override { return true; }
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ UNMAP_AFTER_INIT RandomDevice::RandomDevice()
|
|||
|
||||
UNMAP_AFTER_INIT RandomDevice::~RandomDevice() = default;
|
||||
|
||||
bool RandomDevice::can_read(const OpenFileDescription&, u64) const
|
||||
bool RandomDevice::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ ErrorOr<size_t> RandomDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer
|
|||
});
|
||||
}
|
||||
|
||||
ErrorOr<size_t> RandomDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size)
|
||||
ErrorOr<size_t> RandomDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t size)
|
||||
{
|
||||
// FIXME: Use input for entropy? I guess that could be a neat feature?
|
||||
return size;
|
||||
|
|
|
@ -22,9 +22,9 @@ private:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return true; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
|
||||
virtual StringView class_name() const override { return "RandomDevice"sv; }
|
||||
};
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ UNMAP_AFTER_INIT SerialDevice::SerialDevice(IOAddress base_addr, unsigned minor)
|
|||
|
||||
UNMAP_AFTER_INIT SerialDevice::~SerialDevice() = default;
|
||||
|
||||
bool SerialDevice::can_read(const OpenFileDescription&, u64) const
|
||||
bool SerialDevice::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return (get_line_status() & DataReady) != 0;
|
||||
}
|
||||
|
@ -75,12 +75,12 @@ ErrorOr<size_t> SerialDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer
|
|||
});
|
||||
}
|
||||
|
||||
bool SerialDevice::can_write(const OpenFileDescription&, u64) const
|
||||
bool SerialDevice::can_write(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return (get_line_status() & EmptyTransmitterHoldingRegister) != 0;
|
||||
}
|
||||
|
||||
ErrorOr<size_t> SerialDevice::write(OpenFileDescription& description, u64, const UserOrKernelBuffer& buffer, size_t size)
|
||||
ErrorOr<size_t> SerialDevice::write(OpenFileDescription& description, u64, UserOrKernelBuffer const& buffer, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return 0;
|
||||
|
|
|
@ -20,10 +20,10 @@ public:
|
|||
virtual ~SerialDevice() override;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
|
||||
void put_char(char);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ UNMAP_AFTER_INIT ZeroDevice::ZeroDevice()
|
|||
|
||||
UNMAP_AFTER_INIT ZeroDevice::~ZeroDevice() = default;
|
||||
|
||||
bool ZeroDevice::can_read(const OpenFileDescription&, u64) const
|
||||
bool ZeroDevice::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ ErrorOr<size_t> ZeroDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer&
|
|||
return size;
|
||||
}
|
||||
|
||||
ErrorOr<size_t> ZeroDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size)
|
||||
ErrorOr<size_t> ZeroDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t size)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ private:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return true; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
|
||||
virtual StringView class_name() const override { return "ZeroDevice"sv; }
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void DoubleBuffer::flip()
|
|||
compute_lockfree_metadata();
|
||||
}
|
||||
|
||||
ErrorOr<size_t> DoubleBuffer::write(const UserOrKernelBuffer& data, size_t size)
|
||||
ErrorOr<size_t> DoubleBuffer::write(UserOrKernelBuffer const& data, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return 0;
|
||||
|
|
|
@ -17,8 +17,8 @@ namespace Kernel {
|
|||
class DoubleBuffer {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<DoubleBuffer>> try_create(size_t capacity = 65536);
|
||||
ErrorOr<size_t> write(const UserOrKernelBuffer&, size_t);
|
||||
ErrorOr<size_t> write(const u8* data, size_t size)
|
||||
ErrorOr<size_t> write(UserOrKernelBuffer const&, size_t);
|
||||
ErrorOr<size_t> write(u8 const* data, size_t size)
|
||||
{
|
||||
return write(UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>(data)), size);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ ErrorOr<Memory::Region*> AnonymousFile::mmap(Process& process, OpenFileDescripti
|
|||
return process.address_space().allocate_region_with_vmobject(range, m_vmobject, offset, {}, prot, shared);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<KString>> AnonymousFile::pseudo_path(const OpenFileDescription&) const
|
||||
ErrorOr<NonnullOwnPtr<KString>> AnonymousFile::pseudo_path(OpenFileDescription const&) const
|
||||
{
|
||||
return KString::try_create(":anonymous-file:"sv);
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ public:
|
|||
|
||||
private:
|
||||
virtual StringView class_name() const override { return "AnonymousFile"sv; }
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const override;
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override { return false; }
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override { return false; }
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override { return false; }
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override { return false; }
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return ENOTSUP; }
|
||||
|
||||
explicit AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject>);
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
return &new_entry;
|
||||
}
|
||||
|
||||
const CacheEntry* entries() const { return (const CacheEntry*)m_entries->data(); }
|
||||
CacheEntry const* entries() const { return (CacheEntry const*)m_entries->data(); }
|
||||
CacheEntry* entries() { return (CacheEntry*)m_entries->data(); }
|
||||
|
||||
template<typename Callback>
|
||||
|
@ -129,7 +129,7 @@ ErrorOr<void> BlockBasedFileSystem::initialize()
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> BlockBasedFileSystem::write_block(BlockIndex index, const UserOrKernelBuffer& data, size_t count, u64 offset, bool allow_cache)
|
||||
ErrorOr<void> BlockBasedFileSystem::write_block(BlockIndex index, UserOrKernelBuffer const& data, size_t count, u64 offset, bool allow_cache)
|
||||
{
|
||||
VERIFY(m_logical_block_size);
|
||||
VERIFY(offset + count <= block_size());
|
||||
|
@ -172,7 +172,7 @@ ErrorOr<void> BlockBasedFileSystem::raw_read(BlockIndex index, UserOrKernelBuffe
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> BlockBasedFileSystem::raw_write(BlockIndex index, const UserOrKernelBuffer& buffer)
|
||||
ErrorOr<void> BlockBasedFileSystem::raw_write(BlockIndex index, UserOrKernelBuffer const& buffer)
|
||||
{
|
||||
auto base_offset = index.value() * m_logical_block_size;
|
||||
auto nwritten = TRY(file_description().write(base_offset, buffer, m_logical_block_size));
|
||||
|
@ -190,7 +190,7 @@ ErrorOr<void> BlockBasedFileSystem::raw_read_blocks(BlockIndex index, size_t cou
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> BlockBasedFileSystem::raw_write_blocks(BlockIndex index, size_t count, const UserOrKernelBuffer& buffer)
|
||||
ErrorOr<void> BlockBasedFileSystem::raw_write_blocks(BlockIndex index, size_t count, UserOrKernelBuffer const& buffer)
|
||||
{
|
||||
auto current = buffer;
|
||||
for (auto block = index.value(); block < (index.value() + count); block++) {
|
||||
|
@ -200,7 +200,7 @@ ErrorOr<void> BlockBasedFileSystem::raw_write_blocks(BlockIndex index, size_t co
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> BlockBasedFileSystem::write_blocks(BlockIndex index, unsigned count, const UserOrKernelBuffer& data, bool allow_cache)
|
||||
ErrorOr<void> BlockBasedFileSystem::write_blocks(BlockIndex index, unsigned count, UserOrKernelBuffer const& data, bool allow_cache)
|
||||
{
|
||||
VERIFY(m_logical_block_size);
|
||||
dbgln_if(BBFS_DEBUG, "BlockBasedFileSystem::write_blocks {}, count={}", index, count);
|
||||
|
|
|
@ -30,13 +30,13 @@ protected:
|
|||
ErrorOr<void> read_blocks(BlockIndex, unsigned count, UserOrKernelBuffer&, bool allow_cache = true) const;
|
||||
|
||||
ErrorOr<void> raw_read(BlockIndex, UserOrKernelBuffer&);
|
||||
ErrorOr<void> raw_write(BlockIndex, const UserOrKernelBuffer&);
|
||||
ErrorOr<void> raw_write(BlockIndex, UserOrKernelBuffer const&);
|
||||
|
||||
ErrorOr<void> raw_read_blocks(BlockIndex index, size_t count, UserOrKernelBuffer&);
|
||||
ErrorOr<void> raw_write_blocks(BlockIndex index, size_t count, const UserOrKernelBuffer&);
|
||||
ErrorOr<void> raw_write_blocks(BlockIndex index, size_t count, UserOrKernelBuffer const&);
|
||||
|
||||
ErrorOr<void> write_block(BlockIndex, const UserOrKernelBuffer&, size_t count, u64 offset = 0, bool allow_cache = true);
|
||||
ErrorOr<void> write_blocks(BlockIndex, unsigned count, const UserOrKernelBuffer&, bool allow_cache = true);
|
||||
ErrorOr<void> write_block(BlockIndex, UserOrKernelBuffer const&, size_t count, u64 offset = 0, bool allow_cache = true);
|
||||
ErrorOr<void> write_blocks(BlockIndex, unsigned count, UserOrKernelBuffer const&, bool allow_cache = true);
|
||||
|
||||
u64 m_logical_block_size { 512 };
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ ErrorOr<size_t> DevPtsFSInode::read_bytes(off_t, size_t, UserOrKernelBuffer&, Op
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<size_t> DevPtsFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*)
|
||||
ErrorOr<size_t> DevPtsFSInode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
|
|
|
@ -71,7 +71,7 @@ ErrorOr<void> DevTmpFSInode::flush_metadata()
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<size_t> DevTmpFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*)
|
||||
ErrorOr<size_t> DevTmpFSInode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ ErrorOr<size_t> DevTmpFSDeviceInode::read_bytes(off_t offset, size_t count, User
|
|||
return result.value();
|
||||
}
|
||||
|
||||
ErrorOr<size_t> DevTmpFSDeviceInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription* description)
|
||||
ErrorOr<size_t> DevTmpFSDeviceInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription* description)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(!!description);
|
||||
|
|
|
@ -53,7 +53,7 @@ protected:
|
|||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual InodeMetadata metadata() const override final;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
|
@ -96,10 +96,10 @@ private:
|
|||
|
||||
// ^Inode
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
|
||||
NonnullOwnPtr<KString> m_name;
|
||||
const bool m_block_device;
|
||||
bool const m_block_device;
|
||||
};
|
||||
|
||||
class DevTmpFSLinkInode final : public DevTmpFSInode {
|
||||
|
@ -117,7 +117,7 @@ protected:
|
|||
|
||||
// ^Inode
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
|
||||
NonnullOwnPtr<KString> m_name;
|
||||
OwnPtr<KString> m_link;
|
||||
|
|
|
@ -69,7 +69,7 @@ ErrorOr<void> Ext2FS::flush_super_block()
|
|||
return raw_write_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer);
|
||||
}
|
||||
|
||||
const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const
|
||||
ext2_group_desc const& Ext2FS::group_descriptor(GroupIndex group_index) const
|
||||
{
|
||||
// FIXME: Should this fail gracefully somehow?
|
||||
VERIFY(group_index <= m_block_group_count);
|
||||
|
@ -164,7 +164,7 @@ bool Ext2FS::find_block_containing_inode(InodeIndex inode, BlockIndex& block_ind
|
|||
Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks) const
|
||||
{
|
||||
BlockListShape shape;
|
||||
const unsigned entries_per_block = EXT2_ADDR_PER_BLOCK(&super_block());
|
||||
unsigned const entries_per_block = EXT2_ADDR_PER_BLOCK(&super_block());
|
||||
unsigned blocks_remaining = blocks;
|
||||
|
||||
shape.direct_blocks = min((unsigned)EXT2_NDIR_BLOCKS, blocks_remaining);
|
||||
|
@ -196,7 +196,7 @@ Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks) const
|
|||
|
||||
ErrorOr<void> Ext2FSInode::write_indirect_block(BlockBasedFileSystem::BlockIndex block, Span<BlockBasedFileSystem::BlockIndex> blocks_indices)
|
||||
{
|
||||
const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
VERIFY(blocks_indices.size() <= entries_per_block);
|
||||
|
||||
auto block_contents = TRY(ByteBuffer::create_uninitialized(fs().block_size()));
|
||||
|
@ -213,10 +213,10 @@ ErrorOr<void> Ext2FSInode::write_indirect_block(BlockBasedFileSystem::BlockIndex
|
|||
|
||||
ErrorOr<void> Ext2FSInode::grow_doubly_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, Span<BlockBasedFileSystem::BlockIndex> blocks_indices, Vector<Ext2FS::BlockIndex>& new_meta_blocks, unsigned& meta_blocks)
|
||||
{
|
||||
const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
const auto entries_per_doubly_indirect_block = entries_per_block * entries_per_block;
|
||||
const auto old_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_block);
|
||||
const auto new_indirect_blocks_length = ceil_div(blocks_indices.size(), entries_per_block);
|
||||
auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
auto const entries_per_doubly_indirect_block = entries_per_block * entries_per_block;
|
||||
auto const old_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_block);
|
||||
auto const new_indirect_blocks_length = ceil_div(blocks_indices.size(), entries_per_block);
|
||||
VERIFY(blocks_indices.size() > 0);
|
||||
VERIFY(blocks_indices.size() > old_blocks_length);
|
||||
VERIFY(blocks_indices.size() <= entries_per_doubly_indirect_block);
|
||||
|
@ -243,7 +243,7 @@ ErrorOr<void> Ext2FSInode::grow_doubly_indirect_block(BlockBasedFileSystem::Bloc
|
|||
|
||||
// Write out the indirect blocks.
|
||||
for (unsigned i = old_blocks_length / entries_per_block; i < new_indirect_blocks_length; i++) {
|
||||
const auto offset_block = i * entries_per_block;
|
||||
auto const offset_block = i * entries_per_block;
|
||||
TRY(write_indirect_block(block_as_pointers[i], blocks_indices.slice(offset_block, min(blocks_indices.size() - offset_block, entries_per_block))));
|
||||
}
|
||||
|
||||
|
@ -253,10 +253,10 @@ ErrorOr<void> Ext2FSInode::grow_doubly_indirect_block(BlockBasedFileSystem::Bloc
|
|||
|
||||
ErrorOr<void> Ext2FSInode::shrink_doubly_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, size_t new_blocks_length, unsigned& meta_blocks)
|
||||
{
|
||||
const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
const auto entries_per_doubly_indirect_block = entries_per_block * entries_per_block;
|
||||
const auto old_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_block);
|
||||
const auto new_indirect_blocks_length = ceil_div(new_blocks_length, entries_per_block);
|
||||
auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
auto const entries_per_doubly_indirect_block = entries_per_block * entries_per_block;
|
||||
auto const old_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_block);
|
||||
auto const new_indirect_blocks_length = ceil_div(new_blocks_length, entries_per_block);
|
||||
VERIFY(old_blocks_length > 0);
|
||||
VERIFY(old_blocks_length >= new_blocks_length);
|
||||
VERIFY(new_blocks_length <= entries_per_doubly_indirect_block);
|
||||
|
@ -285,11 +285,11 @@ ErrorOr<void> Ext2FSInode::shrink_doubly_indirect_block(BlockBasedFileSystem::Bl
|
|||
|
||||
ErrorOr<void> Ext2FSInode::grow_triply_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, Span<BlockBasedFileSystem::BlockIndex> blocks_indices, Vector<Ext2FS::BlockIndex>& new_meta_blocks, unsigned& meta_blocks)
|
||||
{
|
||||
const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
const auto entries_per_doubly_indirect_block = entries_per_block * entries_per_block;
|
||||
const auto entries_per_triply_indirect_block = entries_per_block * entries_per_block;
|
||||
const auto old_doubly_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_doubly_indirect_block);
|
||||
const auto new_doubly_indirect_blocks_length = ceil_div(blocks_indices.size(), entries_per_doubly_indirect_block);
|
||||
auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
auto const entries_per_doubly_indirect_block = entries_per_block * entries_per_block;
|
||||
auto const entries_per_triply_indirect_block = entries_per_block * entries_per_block;
|
||||
auto const old_doubly_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_doubly_indirect_block);
|
||||
auto const new_doubly_indirect_blocks_length = ceil_div(blocks_indices.size(), entries_per_doubly_indirect_block);
|
||||
VERIFY(blocks_indices.size() > 0);
|
||||
VERIFY(blocks_indices.size() > old_blocks_length);
|
||||
VERIFY(blocks_indices.size() <= entries_per_triply_indirect_block);
|
||||
|
@ -316,9 +316,9 @@ ErrorOr<void> Ext2FSInode::grow_triply_indirect_block(BlockBasedFileSystem::Bloc
|
|||
|
||||
// Write out the doubly indirect blocks.
|
||||
for (unsigned i = old_blocks_length / entries_per_doubly_indirect_block; i < new_doubly_indirect_blocks_length; i++) {
|
||||
const auto processed_blocks = i * entries_per_doubly_indirect_block;
|
||||
const auto old_doubly_indirect_blocks_length = min(old_blocks_length > processed_blocks ? old_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block);
|
||||
const auto new_doubly_indirect_blocks_length = min(blocks_indices.size() > processed_blocks ? blocks_indices.size() - processed_blocks : 0, entries_per_doubly_indirect_block);
|
||||
auto const processed_blocks = i * entries_per_doubly_indirect_block;
|
||||
auto const old_doubly_indirect_blocks_length = min(old_blocks_length > processed_blocks ? old_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block);
|
||||
auto const new_doubly_indirect_blocks_length = min(blocks_indices.size() > processed_blocks ? blocks_indices.size() - processed_blocks : 0, entries_per_doubly_indirect_block);
|
||||
TRY(grow_doubly_indirect_block(block_as_pointers[i], old_doubly_indirect_blocks_length, blocks_indices.slice(processed_blocks, new_doubly_indirect_blocks_length), new_meta_blocks, meta_blocks));
|
||||
}
|
||||
|
||||
|
@ -328,11 +328,11 @@ ErrorOr<void> Ext2FSInode::grow_triply_indirect_block(BlockBasedFileSystem::Bloc
|
|||
|
||||
ErrorOr<void> Ext2FSInode::shrink_triply_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, size_t new_blocks_length, unsigned& meta_blocks)
|
||||
{
|
||||
const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
const auto entries_per_doubly_indirect_block = entries_per_block * entries_per_block;
|
||||
const auto entries_per_triply_indirect_block = entries_per_doubly_indirect_block * entries_per_block;
|
||||
const auto old_triply_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_doubly_indirect_block);
|
||||
const auto new_triply_indirect_blocks_length = new_blocks_length / entries_per_doubly_indirect_block;
|
||||
auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block());
|
||||
auto const entries_per_doubly_indirect_block = entries_per_block * entries_per_block;
|
||||
auto const entries_per_triply_indirect_block = entries_per_doubly_indirect_block * entries_per_block;
|
||||
auto const old_triply_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_doubly_indirect_block);
|
||||
auto const new_triply_indirect_blocks_length = new_blocks_length / entries_per_doubly_indirect_block;
|
||||
VERIFY(old_blocks_length > 0);
|
||||
VERIFY(old_blocks_length >= new_blocks_length);
|
||||
VERIFY(new_blocks_length <= entries_per_triply_indirect_block);
|
||||
|
@ -344,9 +344,9 @@ ErrorOr<void> Ext2FSInode::shrink_triply_indirect_block(BlockBasedFileSystem::Bl
|
|||
|
||||
// Shrink the doubly indirect blocks.
|
||||
for (unsigned i = new_triply_indirect_blocks_length; i < old_triply_indirect_blocks_length; i++) {
|
||||
const auto processed_blocks = i * entries_per_doubly_indirect_block;
|
||||
const auto old_doubly_indirect_blocks_length = min(old_blocks_length > processed_blocks ? old_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block);
|
||||
const auto new_doubly_indirect_blocks_length = min(new_blocks_length > processed_blocks ? new_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block);
|
||||
auto const processed_blocks = i * entries_per_doubly_indirect_block;
|
||||
auto const old_doubly_indirect_blocks_length = min(old_blocks_length > processed_blocks ? old_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block);
|
||||
auto const new_doubly_indirect_blocks_length = min(new_blocks_length > processed_blocks ? new_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block);
|
||||
dbgln_if(EXT2_BLOCKLIST_DEBUG, "Ext2FSInode[{}]::shrink_triply_indirect_block(): Shrinking doubly indirect block {} at index {}", identifier(), block_as_pointers[i], i);
|
||||
TRY(shrink_doubly_indirect_block(block_as_pointers[i], old_doubly_indirect_blocks_length, new_doubly_indirect_blocks_length, meta_blocks));
|
||||
}
|
||||
|
@ -373,10 +373,10 @@ ErrorOr<void> Ext2FSInode::flush_block_list()
|
|||
}
|
||||
|
||||
// NOTE: There is a mismatch between i_blocks and blocks.size() since i_blocks includes meta blocks and blocks.size() does not.
|
||||
const auto old_block_count = ceil_div(size(), static_cast<u64>(fs().block_size()));
|
||||
auto const old_block_count = ceil_div(size(), static_cast<u64>(fs().block_size()));
|
||||
|
||||
auto old_shape = fs().compute_block_list_shape(old_block_count);
|
||||
const auto new_shape = fs().compute_block_list_shape(m_block_list.size());
|
||||
auto const new_shape = fs().compute_block_list_shape(m_block_list.size());
|
||||
|
||||
Vector<Ext2FS::BlockIndex> new_meta_blocks;
|
||||
if (new_shape.meta_blocks > old_shape.meta_blocks) {
|
||||
|
@ -813,7 +813,7 @@ ErrorOr<size_t> Ext2FSInode::read_bytes(off_t offset, size_t count, UserOrKernel
|
|||
if (is_symlink() && size() < max_inline_symlink_length) {
|
||||
VERIFY(offset == 0);
|
||||
size_t nread = min((off_t)size() - offset, static_cast<off_t>(count));
|
||||
TRY(buffer.write(((const u8*)m_raw_inode.i_block) + offset, nread));
|
||||
TRY(buffer.write(((u8 const*)m_raw_inode.i_block) + offset, nread));
|
||||
return nread;
|
||||
}
|
||||
|
||||
|
@ -827,7 +827,7 @@ ErrorOr<size_t> Ext2FSInode::read_bytes(off_t offset, size_t count, UserOrKernel
|
|||
|
||||
bool allow_cache = !description || !description->is_direct();
|
||||
|
||||
const int block_size = fs().block_size();
|
||||
int const block_size = fs().block_size();
|
||||
|
||||
BlockBasedFileSystem::BlockIndex first_block_logical_index = offset / block_size;
|
||||
BlockBasedFileSystem::BlockIndex last_block_logical_index = (offset + count) / block_size;
|
||||
|
@ -935,7 +935,7 @@ ErrorOr<void> Ext2FSInode::resize(u64 new_size)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<size_t> Ext2FSInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& data, OpenFileDescription* description)
|
||||
ErrorOr<size_t> Ext2FSInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& data, OpenFileDescription* description)
|
||||
{
|
||||
VERIFY(offset >= 0);
|
||||
|
||||
|
@ -960,7 +960,7 @@ ErrorOr<size_t> Ext2FSInode::write_bytes(off_t offset, size_t count, const UserO
|
|||
|
||||
bool allow_cache = !description || !description->is_direct();
|
||||
|
||||
const auto block_size = fs().block_size();
|
||||
auto const block_size = fs().block_size();
|
||||
auto new_size = max(static_cast<u64>(offset) + count, size());
|
||||
|
||||
TRY(resize(new_size));
|
||||
|
@ -1003,7 +1003,7 @@ ErrorOr<size_t> Ext2FSInode::write_bytes(off_t offset, size_t count, const UserO
|
|||
return nwritten;
|
||||
}
|
||||
|
||||
u8 Ext2FS::internal_file_type_to_directory_entry_type(const DirectoryEntryView& entry) const
|
||||
u8 Ext2FS::internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const
|
||||
{
|
||||
switch (entry.file_type) {
|
||||
case EXT2_FT_REG_FILE:
|
||||
|
@ -1219,7 +1219,7 @@ ErrorOr<void> Ext2FS::write_ext2_inode(InodeIndex inode, ext2_inode const& e2ino
|
|||
unsigned offset;
|
||||
if (!find_block_containing_inode(inode, block_index, offset))
|
||||
return EINVAL;
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>((const u8*)&e2inode));
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>((u8 const*)&e2inode));
|
||||
return write_block(block_index, buffer, inode_size(), offset);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode& child, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
|
@ -69,7 +69,7 @@ private:
|
|||
ErrorOr<Vector<BlockBasedFileSystem::BlockIndex>> compute_block_list_impl_internal(ext2_inode const&, bool include_block_list_blocks) const;
|
||||
|
||||
Ext2FS& fs();
|
||||
const Ext2FS& fs() const;
|
||||
Ext2FS const& fs() const;
|
||||
Ext2FSInode(Ext2FS&, InodeIndex);
|
||||
|
||||
mutable Vector<BlockBasedFileSystem::BlockIndex> m_block_list;
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
virtual bool supports_watchers() const override { return true; }
|
||||
|
||||
virtual u8 internal_file_type_to_directory_entry_type(const DirectoryEntryView& entry) const override;
|
||||
virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override;
|
||||
|
||||
FeaturesReadOnly get_features_readonly() const;
|
||||
|
||||
|
@ -109,10 +109,10 @@ private:
|
|||
|
||||
explicit Ext2FS(OpenFileDescription&);
|
||||
|
||||
const ext2_super_block& super_block() const { return m_super_block; }
|
||||
const ext2_group_desc& group_descriptor(GroupIndex) const;
|
||||
ext2_super_block const& super_block() const { return m_super_block; }
|
||||
ext2_group_desc const& group_descriptor(GroupIndex) const;
|
||||
ext2_group_desc* block_group_descriptors() { return (ext2_group_desc*)m_cached_group_descriptor_table->data(); }
|
||||
const ext2_group_desc* block_group_descriptors() const { return (const ext2_group_desc*)m_cached_group_descriptor_table->data(); }
|
||||
ext2_group_desc const* block_group_descriptors() const { return (ext2_group_desc const*)m_cached_group_descriptor_table->data(); }
|
||||
void flush_block_group_descriptor_table();
|
||||
u64 inodes_per_block() const;
|
||||
u64 inodes_per_group() const;
|
||||
|
@ -188,9 +188,9 @@ inline Ext2FS& Ext2FSInode::fs()
|
|||
return static_cast<Ext2FS&>(Inode::fs());
|
||||
}
|
||||
|
||||
inline const Ext2FS& Ext2FSInode::fs() const
|
||||
inline Ext2FS const& Ext2FSInode::fs() const
|
||||
{
|
||||
return static_cast<const Ext2FS&>(Inode::fs());
|
||||
return static_cast<Ext2FS const&>(Inode::fs());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -97,12 +97,12 @@ void FIFO::detach(Direction direction)
|
|||
evaluate_block_conditions();
|
||||
}
|
||||
|
||||
bool FIFO::can_read(const OpenFileDescription&, u64) const
|
||||
bool FIFO::can_read(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return !m_buffer->is_empty() || !m_writers;
|
||||
}
|
||||
|
||||
bool FIFO::can_write(const OpenFileDescription&, u64) const
|
||||
bool FIFO::can_write(OpenFileDescription const&, u64) const
|
||||
{
|
||||
return m_buffer->space_for_writing() || !m_readers;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ ErrorOr<size_t> FIFO::read(OpenFileDescription& fd, u64, UserOrKernelBuffer& buf
|
|||
return m_buffer->read(buffer, size);
|
||||
}
|
||||
|
||||
ErrorOr<size_t> FIFO::write(OpenFileDescription& fd, u64, const UserOrKernelBuffer& buffer, size_t size)
|
||||
ErrorOr<size_t> FIFO::write(OpenFileDescription& fd, u64, UserOrKernelBuffer const& buffer, size_t size)
|
||||
{
|
||||
if (!m_readers) {
|
||||
Thread::current()->send_signal(SIGPIPE, &Process::current());
|
||||
|
@ -130,7 +130,7 @@ ErrorOr<size_t> FIFO::write(OpenFileDescription& fd, u64, const UserOrKernelBuff
|
|||
return m_buffer->write(buffer, size);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<KString>> FIFO::pseudo_path(const OpenFileDescription&) const
|
||||
ErrorOr<NonnullOwnPtr<KString>> FIFO::pseudo_path(OpenFileDescription const&) const
|
||||
{
|
||||
return KString::formatted("fifo:{}", m_fifo_id);
|
||||
}
|
||||
|
|
|
@ -40,12 +40,12 @@ public:
|
|||
|
||||
private:
|
||||
// ^File
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<struct stat> stat() const override;
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const override;
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const override;
|
||||
virtual StringView class_name() const override { return "FIFO"sv; }
|
||||
virtual bool is_fifo() const override { return true; }
|
||||
|
||||
|
|
|
@ -81,20 +81,20 @@ public:
|
|||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options);
|
||||
virtual ErrorOr<void> close();
|
||||
|
||||
virtual bool can_read(const OpenFileDescription&, u64) const = 0;
|
||||
virtual bool can_write(const OpenFileDescription&, u64) const = 0;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const = 0;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const = 0;
|
||||
|
||||
virtual ErrorOr<void> attach(OpenFileDescription&);
|
||||
virtual void detach(OpenFileDescription&);
|
||||
virtual void did_seek(OpenFileDescription&, off_t) { }
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) = 0;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) = 0;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) = 0;
|
||||
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg);
|
||||
virtual ErrorOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared);
|
||||
virtual ErrorOr<struct stat> stat() const { return EBADF; }
|
||||
|
||||
// Although this might be better described "name" or "description", these terms already have other meanings.
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const = 0;
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const = 0;
|
||||
|
||||
virtual ErrorOr<void> truncate(u64) { return EINVAL; }
|
||||
virtual ErrorOr<void> sync() { return EINVAL; }
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
File& file() { return m_file_description->file(); }
|
||||
OpenFileDescription& file_description() { return *m_file_description; }
|
||||
const File& file() const { return m_file_description->file(); }
|
||||
File const& file() const { return m_file_description->file(); }
|
||||
OpenFileDescription& file_description() const { return *m_file_description; }
|
||||
|
||||
protected:
|
||||
|
|
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