1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:58:13 +00:00

Meta+Kernel: Make clang-format-10 clean

This commit is contained in:
Ben Wiederhake 2020-09-18 09:49:51 +02:00 committed by Andreas Kling
parent fa62c5595e
commit 64cc3f51d0
61 changed files with 123 additions and 118 deletions

View file

@ -56,7 +56,7 @@ int main(int argc, char** argv, char** env)
auto elf = ELF::Loader::create((const u8*)mapped_file.data(), mapped_file.size()); auto elf = ELF::Loader::create((const u8*)mapped_file.data(), mapped_file.size());
Vector<String> arguments; Vector<String> arguments;
for (auto arg: command) { for (auto arg : command) {
arguments.append(arg); arguments.append(arg);
} }

View file

@ -30,8 +30,8 @@
#include <Kernel/ACPI/Parser.h> #include <Kernel/ACPI/Parser.h>
#include <Kernel/Interrupts/IRQHandler.h> #include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h> #include <Kernel/Lock.h>
#include <Kernel/VM/PhysicalPage.h>
#include <Kernel/PhysicalAddress.h> #include <Kernel/PhysicalAddress.h>
#include <Kernel/VM/PhysicalPage.h>
namespace Kernel { namespace Kernel {
namespace ACPI { namespace ACPI {

View file

@ -30,8 +30,8 @@
#include <Kernel/ACPI/Definitions.h> #include <Kernel/ACPI/Definitions.h>
#include <Kernel/ACPI/Initialize.h> #include <Kernel/ACPI/Initialize.h>
#include <Kernel/FileSystem/File.h> #include <Kernel/FileSystem/File.h>
#include <Kernel/VM/Region.h>
#include <Kernel/PhysicalAddress.h> #include <Kernel/PhysicalAddress.h>
#include <Kernel/VM/Region.h>
#include <Kernel/VirtualAddress.h> #include <Kernel/VirtualAddress.h>
namespace Kernel { namespace Kernel {

View file

@ -338,7 +338,7 @@ struct SC_create_thread_params {
unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE
unsigned int m_reported_guard_page_size = 0; // The lie we tell callers unsigned int m_reported_guard_page_size = 0; // The lie we tell callers
unsigned int m_stack_size = 4 * MiB; // Default PTHREAD_STACK_MIN unsigned int m_stack_size = 4 * MiB; // Default PTHREAD_STACK_MIN
void* m_stack_location; // nullptr means any, o.w. process virtual address void* m_stack_location; // nullptr means any, o.w. process virtual address
}; };
struct SC_realpath_params { struct SC_realpath_params {

View file

@ -415,7 +415,6 @@ void page_fault_handler(TrapFrame* trap)
return; return;
} }
auto current_thread = Thread::current(); auto current_thread = Thread::current();
if (!faulted_in_kernel && !MM.validate_user_stack(current_thread->process(), VirtualAddress(regs.userspace_esp))) { if (!faulted_in_kernel && !MM.validate_user_stack(current_thread->process(), VirtualAddress(regs.userspace_esp))) {
dbg() << "Invalid stack pointer: " << VirtualAddress(regs.userspace_esp); dbg() << "Invalid stack pointer: " << VirtualAddress(regs.userspace_esp);
@ -1278,7 +1277,7 @@ bool Processor::get_context_frame_ptr(Thread& thread, u32& frame_ptr, u32& eip)
// an IPI to that processor, have it walk the stack and wait // an IPI to that processor, have it walk the stack and wait
// until it returns the data back to us // until it returns the data back to us
dbg() << "CPU[" << proc.id() << "] getting stack for " dbg() << "CPU[" << proc.id() << "] getting stack for "
<< thread << " on other CPU# " << thread.cpu() << " not yet implemented!"; << thread << " on other CPU# " << thread.cpu() << " not yet implemented!";
frame_ptr = eip = 0; // TODO frame_ptr = eip = 0; // TODO
return false; return false;
} else { } else {
@ -1730,12 +1729,12 @@ void Processor::smp_enable()
void Processor::smp_cleanup_message(ProcessorMessage& msg) void Processor::smp_cleanup_message(ProcessorMessage& msg)
{ {
switch (msg.type) { switch (msg.type) {
case ProcessorMessage::CallbackWithData: case ProcessorMessage::CallbackWithData:
if (msg.callback_with_data.free) if (msg.callback_with_data.free)
msg.callback_with_data.free(msg.callback_with_data.data); msg.callback_with_data.free(msg.callback_with_data.data);
break; break;
default: default:
break; break;
} }
} }
@ -1745,8 +1744,7 @@ bool Processor::smp_process_pending_messages()
u32 prev_flags; u32 prev_flags;
enter_critical(prev_flags); enter_critical(prev_flags);
if (auto pending_msgs = atomic_exchange(&m_message_queue, nullptr, AK::MemoryOrder::memory_order_acq_rel)) if (auto pending_msgs = atomic_exchange(&m_message_queue, nullptr, AK::MemoryOrder::memory_order_acq_rel)) {
{
// We pulled the stack of pending messages in LIFO order, so we need to reverse the list first // We pulled the stack of pending messages in LIFO order, so we need to reverse the list first
auto reverse_list = auto reverse_list =
[](ProcessorMessageEntry* list) -> ProcessorMessageEntry* [](ProcessorMessageEntry* list) -> ProcessorMessageEntry*
@ -1768,21 +1766,21 @@ bool Processor::smp_process_pending_messages()
for (auto cur_msg = pending_msgs; cur_msg; cur_msg = next_msg) { for (auto cur_msg = pending_msgs; cur_msg; cur_msg = next_msg) {
next_msg = cur_msg->next; next_msg = cur_msg->next;
auto msg = cur_msg->msg; auto msg = cur_msg->msg;
#ifdef SMP_DEBUG #ifdef SMP_DEBUG
dbg() << "SMP[" << id() << "]: Processing message " << VirtualAddress(msg); dbg() << "SMP[" << id() << "]: Processing message " << VirtualAddress(msg);
#endif #endif
switch (msg->type) { switch (msg->type) {
case ProcessorMessage::Callback: case ProcessorMessage::Callback:
msg->callback.handler(); msg->callback.handler();
break; break;
case ProcessorMessage::CallbackWithData: case ProcessorMessage::CallbackWithData:
msg->callback_with_data.handler(msg->callback_with_data.data); msg->callback_with_data.handler(msg->callback_with_data.data);
break; break;
case ProcessorMessage::FlushTlb: case ProcessorMessage::FlushTlb:
flush_tlb_local(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count); flush_tlb_local(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count);
break; break;
} }
bool is_async = msg->async; // Need to cache this value *before* dropping the ref count! bool is_async = msg->async; // Need to cache this value *before* dropping the ref count!
@ -1833,8 +1831,7 @@ void Processor::smp_broadcast_message(ProcessorMessage& msg, bool async)
atomic_store(&msg.refs, count() - 1, AK::MemoryOrder::memory_order_release); atomic_store(&msg.refs, count() - 1, AK::MemoryOrder::memory_order_release);
ASSERT(msg.refs > 0); ASSERT(msg.refs > 0);
for_each( for_each(
[&](Processor& proc) -> IterationDecision [&](Processor& proc) -> IterationDecision {
{
if (&proc != &cur_proc) { if (&proc != &cur_proc) {
if (proc.smp_queue_message(msg)) { if (proc.smp_queue_message(msg)) {
// TODO: only send IPI to that CPU if we queued the first // TODO: only send IPI to that CPU if we queued the first
@ -1890,8 +1887,7 @@ void Processor::smp_broadcast_halt()
// We don't want to use a message, because this could have been triggered // We don't want to use a message, because this could have been triggered
// by being out of memory and we might not be able to get a message // by being out of memory and we might not be able to get a message
for_each( for_each(
[&](Processor& proc) -> IterationDecision [&](Processor& proc) -> IterationDecision {
{
proc.m_halt_requested = true; proc.m_halt_requested = true;
return IterationDecision::Continue; return IterationDecision::Continue;
}); });

View file

@ -26,8 +26,8 @@
#pragma once #pragma once
#include <AK/Types.h>
#include <AK/Assertions.h> #include <AK/Assertions.h>
#include <AK/Types.h>
#include <Kernel/Arch/i386/CPU.h> #include <Kernel/Arch/i386/CPU.h>
extern "C" void interrupt_common_asm_entry(); extern "C" void interrupt_common_asm_entry();
@ -40,6 +40,7 @@ extern "C" void interrupt_common_asm_entry();
" pushw $0\n" \ " pushw $0\n" \
" jmp interrupt_common_asm_entry\n"); " jmp interrupt_common_asm_entry\n");
// clang-format off
asm( asm(
".globl interrupt_common_asm_entry\n" ".globl interrupt_common_asm_entry\n"
"interrupt_common_asm_entry: \n" "interrupt_common_asm_entry: \n"
@ -81,3 +82,4 @@ asm(
" addl $0x4, %esp\n" // skip exception_code, isr_number " addl $0x4, %esp\n" // skip exception_code, isr_number
" iret\n" " iret\n"
); );
// clang-format on

View file

@ -32,8 +32,7 @@ namespace Kernel {
class Processor; class Processor;
class ProcessorInfo class ProcessorInfo {
{
Processor& m_processor; Processor& m_processor;
String m_cpuid; String m_cpuid;
String m_brandstr; String m_brandstr;
@ -46,7 +45,7 @@ class ProcessorInfo
public: public:
ProcessorInfo(Processor& processor); ProcessorInfo(Processor& processor);
const String& cpuid() const { return m_cpuid; } const String& cpuid() const { return m_cpuid; }
const String& brandstr() const { return m_brandstr; } const String& brandstr() const { return m_brandstr; }
const String& features() const { return m_features; } const String& features() const { return m_features; }

View file

@ -38,7 +38,7 @@ void CommandLine::early_initialize(const char* cmd_line)
return; return;
size_t length = strlen(cmd_line); size_t length = strlen(cmd_line);
if (length >= sizeof(s_cmd_line)) if (length >= sizeof(s_cmd_line))
length = sizeof(s_cmd_line) -1; length = sizeof(s_cmd_line) - 1;
memcpy(s_cmd_line, cmd_line, length); memcpy(s_cmd_line, cmd_line, length);
s_cmd_line[length] = '\0'; s_cmd_line[length] = '\0';
} }

View file

@ -27,8 +27,8 @@
#include <AK/Singleton.h> #include <AK/Singleton.h>
#include <Kernel/Console.h> #include <Kernel/Console.h>
#include <Kernel/IO.h> #include <Kernel/IO.h>
#include <Kernel/kstdio.h>
#include <Kernel/SpinLock.h> #include <Kernel/SpinLock.h>
#include <Kernel/kstdio.h>
// Bytes output to 0xE9 end up on the Bochs console. It's very handy. // Bytes output to 0xE9 end up on the Bochs console. It's very handy.
#define CONSOLE_OUT_TO_E9 #define CONSOLE_OUT_TO_E9

View file

@ -29,9 +29,9 @@
#include <AK/CircularQueue.h> #include <AK/CircularQueue.h>
#include <AK/DoublyLinkedList.h> #include <AK/DoublyLinkedList.h>
#include <AK/Types.h> #include <AK/Types.h>
#include <Kernel/API/KeyCode.h>
#include <Kernel/Devices/CharacterDevice.h> #include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/Interrupts/IRQHandler.h> #include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/API/KeyCode.h>
#include <Kernel/Random.h> #include <Kernel/Random.h>
#include <LibKeyboard/CharacterMap.h> #include <LibKeyboard/CharacterMap.h>

View file

@ -26,8 +26,8 @@
#include <Kernel/Arch/i386/CPU.h> #include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Devices/PCSpeaker.h> #include <Kernel/Devices/PCSpeaker.h>
#include <Kernel/Time/PIT.h>
#include <Kernel/IO.h> #include <Kernel/IO.h>
#include <Kernel/Time/PIT.h>
void PCSpeaker::tone_on(int frequency) void PCSpeaker::tone_on(int frequency)
{ {

View file

@ -72,7 +72,7 @@ PS2MouseDevice::~PS2MouseDevice()
void PS2MouseDevice::create() void PS2MouseDevice::create()
{ {
s_the.ensure_instance(); s_the.ensure_instance();
} }
PS2MouseDevice& PS2MouseDevice::the() PS2MouseDevice& PS2MouseDevice::the()

View file

@ -27,9 +27,9 @@
#pragma once #pragma once
#include <AK/CircularQueue.h> #include <AK/CircularQueue.h>
#include <Kernel/API/MousePacket.h>
#include <Kernel/Devices/CharacterDevice.h> #include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/Interrupts/IRQHandler.h> #include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/API/MousePacket.h>
#include <Kernel/Random.h> #include <Kernel/Random.h>
namespace Kernel { namespace Kernel {

View file

@ -28,10 +28,10 @@
#include <AK/Singleton.h> #include <AK/Singleton.h>
#include <AK/StringView.h> #include <AK/StringView.h>
#include <Kernel/Devices/SB16.h> #include <Kernel/Devices/SB16.h>
#include <Kernel/IO.h>
#include <Kernel/Thread.h> #include <Kernel/Thread.h>
#include <Kernel/VM/AnonymousVMObject.h> #include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/MemoryManager.h> #include <Kernel/VM/MemoryManager.h>
#include <Kernel/IO.h>
//#define SB16_DEBUG //#define SB16_DEBUG

View file

@ -28,9 +28,9 @@
#include <Kernel/Devices/CharacterDevice.h> #include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/Interrupts/IRQHandler.h> #include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VM/PhysicalPage.h> #include <Kernel/VM/PhysicalPage.h>
#include <Kernel/WaitQueue.h> #include <Kernel/WaitQueue.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel { namespace Kernel {

View file

@ -28,10 +28,10 @@
#include <AK/OwnPtr.h> #include <AK/OwnPtr.h>
#include <AK/Singleton.h> #include <AK/Singleton.h>
#include <AK/String.h> #include <AK/String.h>
#include <Kernel/API/MousePacket.h>
#include <Kernel/Arch/i386/CPU.h> #include <Kernel/Arch/i386/CPU.h>
#include <Kernel/CommandLine.h> #include <Kernel/CommandLine.h>
#include <Kernel/Devices/VMWareBackdoor.h> #include <Kernel/Devices/VMWareBackdoor.h>
#include <Kernel/API/MousePacket.h>
#include <Kernel/IO.h> #include <Kernel/IO.h>
namespace Kernel { namespace Kernel {
@ -82,8 +82,7 @@ inline void vmware_high_bandwidth_get(VMWareCommand& command)
: "+a"(command.ax), "+b"(command.bx), "+c"(command.cx), "+d"(command.dx), "+S"(command.si), "+D"(command.di)); : "+a"(command.ax), "+b"(command.bx), "+c"(command.cx), "+d"(command.dx), "+S"(command.si), "+D"(command.di));
} }
class VMWareBackdoorDetector class VMWareBackdoorDetector {
{
public: public:
VMWareBackdoorDetector() VMWareBackdoorDetector()
{ {

View file

@ -78,7 +78,7 @@ public:
u8 file_type { 0 }; u8 file_type { 0 };
}; };
virtual void flush_writes() {} virtual void flush_writes() { }
size_t block_size() const { return m_block_size; } size_t block_size() const { return m_block_size; }

View file

@ -37,7 +37,7 @@ struct InodeMetadata;
class InodeIdentifier { class InodeIdentifier {
public: public:
InodeIdentifier() {} InodeIdentifier() { }
InodeIdentifier(u32 fsid, u32 inode) InodeIdentifier(u32 fsid, u32 inode)
: m_fsid(fsid) : m_fsid(fsid)
, m_index(inode) , m_index(inode)

View file

@ -797,10 +797,10 @@ static Optional<KBuffer> procfs$cpuinfo(InodeIdentifier)
Optional<KBuffer> procfs$memstat(InodeIdentifier) Optional<KBuffer> procfs$memstat(InodeIdentifier)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
kmalloc_stats stats; kmalloc_stats stats;
get_kmalloc_stats(stats); get_kmalloc_stats(stats);
KBufferBuilder builder; KBufferBuilder builder;
JsonObjectSerializer<KBufferBuilder> json { builder }; JsonObjectSerializer<KBufferBuilder> json { builder };
json.add("kmalloc_allocated", stats.bytes_allocated); json.add("kmalloc_allocated", stats.bytes_allocated);
@ -1206,7 +1206,7 @@ ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer&
auto* directory_entry = fs().get_directory_entry(identifier()); auto* directory_entry = fs().get_directory_entry(identifier());
Optional<KBuffer>(*read_callback)(InodeIdentifier) = nullptr; Optional<KBuffer> (*read_callback)(InodeIdentifier) = nullptr;
if (directory_entry) if (directory_entry)
read_callback = directory_entry->read_callback; read_callback = directory_entry->read_callback;
else else
@ -1482,7 +1482,7 @@ ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const UserOrKernelB
auto* directory_entry = fs().get_directory_entry(identifier()); auto* directory_entry = fs().get_directory_entry(identifier());
ssize_t(*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t) = nullptr; ssize_t (*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t) = nullptr;
if (directory_entry == nullptr) { if (directory_entry == nullptr) {
if (to_proc_parent_directory(identifier()) == PDI_Root_sys) { if (to_proc_parent_directory(identifier()) == PDI_Root_sys) {

View file

@ -59,7 +59,7 @@ private:
struct ProcFSDirectoryEntry { struct ProcFSDirectoryEntry {
ProcFSDirectoryEntry() { } ProcFSDirectoryEntry() { }
ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, bool a_supervisor_only, Optional<KBuffer>(*read_callback)(InodeIdentifier) = nullptr, ssize_t(*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t) = nullptr, RefPtr<ProcFSInode>&& a_inode = nullptr) ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, bool a_supervisor_only, Optional<KBuffer> (*read_callback)(InodeIdentifier) = nullptr, ssize_t (*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t) = nullptr, RefPtr<ProcFSInode>&& a_inode = nullptr)
: name(a_name) : name(a_name)
, proc_file_type(a_proc_file_type) , proc_file_type(a_proc_file_type)
, supervisor_only(a_supervisor_only) , supervisor_only(a_supervisor_only)
@ -72,8 +72,8 @@ private:
const char* name { nullptr }; const char* name { nullptr };
unsigned proc_file_type { 0 }; unsigned proc_file_type { 0 };
bool supervisor_only { false }; bool supervisor_only { false };
Optional<KBuffer>(*read_callback)(InodeIdentifier); Optional<KBuffer> (*read_callback)(InodeIdentifier);
ssize_t(*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t); ssize_t (*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t);
RefPtr<ProcFSInode> inode; RefPtr<ProcFSInode> inode;
InodeIdentifier identifier(unsigned fsid) const; InodeIdentifier identifier(unsigned fsid) const;
}; };

View file

@ -38,7 +38,7 @@ namespace Kernel {
template<size_t templated_slab_size> template<size_t templated_slab_size>
class SlabAllocator { class SlabAllocator {
public: public:
SlabAllocator() {} SlabAllocator() { }
void init(size_t size) void init(size_t size)
{ {

View file

@ -100,7 +100,7 @@ struct KmallocGlobalHeap {
if (subheap.free_bytes() < allocation_request) { if (subheap.free_bytes() < allocation_request) {
// Looks like we probably need more // Looks like we probably need more
size_t memory_size = PAGE_ROUND_UP(decltype(m_global_heap.m_heap)::calculate_memory_for_bytes(allocation_request)); size_t memory_size = PAGE_ROUND_UP(decltype(m_global_heap.m_heap)::calculate_memory_for_bytes(allocation_request));
// Add some more to the new heap. We're already using it for other // Add some more to the new heap. We're already using it for other
// allocations not including the original allocation_request // allocations not including the original allocation_request
// that triggered heap expansion. If we don't allocate // that triggered heap expansion. If we don't allocate
memory_size += 1 * MiB; memory_size += 1 * MiB;

View file

@ -56,7 +56,7 @@ private:
class ICRReg { class ICRReg {
u32 m_low { 0 }; u32 m_low { 0 };
u32 m_high { 0 }; u32 m_high { 0 };
public: public:
enum DeliveryMode { enum DeliveryMode {
Fixed = 0x0, Fixed = 0x0,
@ -84,13 +84,13 @@ private:
AllIncludingSelf = 0x2, AllIncludingSelf = 0x2,
AllExcludingSelf = 0x3, AllExcludingSelf = 0x3,
}; };
ICRReg(u8 vector, DeliveryMode delivery_mode, DestinationMode destination_mode, Level level, TriggerMode trigger_mode, DestinationShorthand destinationShort, u8 destination = 0) ICRReg(u8 vector, DeliveryMode delivery_mode, DestinationMode destination_mode, Level level, TriggerMode trigger_mode, DestinationShorthand destinationShort, u8 destination = 0)
: m_low(vector | (delivery_mode << 8) | (destination_mode << 11) | (level << 14) | (static_cast<u32>(trigger_mode) << 15) | (destinationShort << 18)), : m_low(vector | (delivery_mode << 8) | (destination_mode << 11) | (level << 14) | (static_cast<u32>(trigger_mode) << 15) | (destinationShort << 18))
m_high((u32)destination << 24) , m_high((u32)destination << 24)
{ {
} }
u32 low() const { return m_low; } u32 low() const { return m_low; }
u32 high() const { return m_high; } u32 high() const { return m_high; }
}; };
@ -98,11 +98,11 @@ private:
OwnPtr<Region> m_apic_base; OwnPtr<Region> m_apic_base;
Vector<OwnPtr<Processor>> m_ap_processor_info; Vector<OwnPtr<Processor>> m_ap_processor_info;
Vector<Thread*> m_ap_idle_threads; Vector<Thread*> m_ap_idle_threads;
AK::Atomic<u8> m_apic_ap_count{0}; AK::Atomic<u8> m_apic_ap_count { 0 };
AK::Atomic<u8> m_apic_ap_continue{0}; AK::Atomic<u8> m_apic_ap_continue { 0 };
u32 m_processor_cnt{0}; u32 m_processor_cnt { 0 };
u32 m_processor_enabled_cnt{0}; u32 m_processor_enabled_cnt { 0 };
static PhysicalAddress get_base(); static PhysicalAddress get_base();
static void set_base(const PhysicalAddress& base); static void set_base(const PhysicalAddress& base);
void write_register(u32 offset, u32 value); void write_register(u32 offset, u32 value);

View file

@ -37,8 +37,8 @@ GenericInterruptHandler& GenericInterruptHandler::from(u8 interrupt_number)
} }
GenericInterruptHandler::GenericInterruptHandler(u8 interrupt_number, bool disable_remap) GenericInterruptHandler::GenericInterruptHandler(u8 interrupt_number, bool disable_remap)
: m_interrupt_number(interrupt_number), : m_interrupt_number(interrupt_number)
m_disable_remap(disable_remap) , m_disable_remap(disable_remap)
{ {
if (m_disable_remap) if (m_disable_remap)
register_generic_interrupt_handler(m_interrupt_number, *this); register_generic_interrupt_handler(m_interrupt_number, *this);

View file

@ -39,7 +39,7 @@ enum class IRQControllerType {
class IRQController : public RefCounted<IRQController> { class IRQController : public RefCounted<IRQController> {
public: public:
virtual ~IRQController() {} virtual ~IRQController() { }
virtual void enable(const GenericInterruptHandler&) = 0; virtual void enable(const GenericInterruptHandler&) = 0;
virtual void disable(const GenericInterruptHandler&) = 0; virtual void disable(const GenericInterruptHandler&) = 0;
@ -57,7 +57,7 @@ public:
virtual IRQControllerType type() const = 0; virtual IRQControllerType type() const = 0;
protected: protected:
IRQController() {} IRQController() { }
virtual void initialize() = 0; virtual void initialize() = 0;
bool m_hard_disabled { false }; bool m_hard_disabled { false };
}; };

View file

@ -37,7 +37,7 @@ class MSIHandler final : public GenericInterruptHandler {
public: public:
virtual ~MSIHandler(); virtual ~MSIHandler();
virtual void handle_interrupt(RegisterState&) override {} virtual void handle_interrupt(RegisterState&) override { }
void enable_irq(); void enable_irq();
void disable_irq(); void disable_irq();

View file

@ -27,9 +27,9 @@
#include <AK/Assertions.h> #include <AK/Assertions.h>
#include <AK/Types.h> #include <AK/Types.h>
#include <Kernel/Arch/i386/CPU.h> #include <Kernel/Arch/i386/CPU.h>
#include <Kernel/IO.h>
#include <Kernel/Interrupts/GenericInterruptHandler.h> #include <Kernel/Interrupts/GenericInterruptHandler.h>
#include <Kernel/Interrupts/PIC.h> #include <Kernel/Interrupts/PIC.h>
#include <Kernel/IO.h>
namespace Kernel { namespace Kernel {

View file

@ -37,7 +37,7 @@ public:
using OutputType = KBuffer; using OutputType = KBuffer;
explicit KBufferBuilder(); explicit KBufferBuilder();
~KBufferBuilder() {} ~KBufferBuilder() { }
void append(const StringView&); void append(const StringView&);
void append(char); void append(char);

View file

@ -35,7 +35,8 @@ enum KSuccessTag {
KSuccess KSuccess
}; };
class [[nodiscard]] KResult { class [[nodiscard]] KResult
{
public: public:
ALWAYS_INLINE explicit KResult(int negative_e) ALWAYS_INLINE explicit KResult(int negative_e)
: m_error(negative_e) : m_error(negative_e)
@ -61,7 +62,8 @@ private:
}; };
template<typename T> template<typename T>
class alignas(T) [[nodiscard]] KResultOr { class alignas(T) [[nodiscard]] KResultOr
{
public: public:
KResultOr(KResult error) KResultOr(KResult error)
: m_error(error) : m_error(error)
@ -69,20 +71,29 @@ public:
{ {
} }
// FIXME: clang-format gets confused about T. Why?
// clang-format off
ALWAYS_INLINE KResultOr(T&& value) ALWAYS_INLINE KResultOr(T&& value)
// clang-format on
{ {
new (&m_storage) T(move(value)); new (&m_storage) T(move(value));
m_have_storage = true; m_have_storage = true;
} }
template<typename U> template<typename U>
// FIXME: clang-format gets confused about U. Why?
// clang-format off
ALWAYS_INLINE KResultOr(U&& value) ALWAYS_INLINE KResultOr(U&& value)
// clang-format on
{ {
new (&m_storage) T(move(value)); new (&m_storage) T(move(value));
m_have_storage = true; m_have_storage = true;
} }
// FIXME: clang-format gets confused about KResultOr. Why?
// clang-format off
KResultOr(KResultOr&& other) KResultOr(KResultOr&& other)
// clang-format on
{ {
m_is_error = other.m_is_error; m_is_error = other.m_is_error;
if (m_is_error) if (m_is_error)

View file

@ -67,7 +67,7 @@ void Lock::lock(Mode mode)
m_lock.store(false, AK::memory_order_release); m_lock.store(false, AK::memory_order_release);
return; return;
} }
} while (current_thread->wait_on(m_queue, m_name, nullptr, &m_lock, m_holder) == Thread::BlockResult::NotBlocked); } while (current_thread->wait_on(m_queue, m_name, nullptr, &m_lock, m_holder) == Thread::BlockResult::NotBlocked);
} else if (Processor::current().in_critical()) { } else if (Processor::current().in_critical()) {
// If we're in a critical section and trying to lock, no context // If we're in a critical section and trying to lock, no context
// switch will happen, so yield. // switch will happen, so yield.

View file

@ -39,8 +39,8 @@ struct ICMPType {
class [[gnu::packed]] ICMPHeader class [[gnu::packed]] ICMPHeader
{ {
public: public:
ICMPHeader() {} ICMPHeader() { }
~ICMPHeader() {} ~ICMPHeader() { }
u8 type() const { return m_type; } u8 type() const { return m_type; }
void set_type(u8 b) { m_type = b; } void set_type(u8 b) { m_type = b; }

View file

@ -352,7 +352,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
} }
if (type() == SOCK_RAW) { if (type() == SOCK_RAW) {
size_t bytes_written = min((size_t) ipv4_packet.payload_size(), buffer_length); size_t bytes_written = min((size_t)ipv4_packet.payload_size(), buffer_length);
if (!buffer.write(ipv4_packet.payload(), bytes_written)) if (!buffer.write(ipv4_packet.payload(), bytes_written))
return KResult(-EFAULT); return KResult(-EFAULT);
return bytes_written; return bytes_written;

View file

@ -125,7 +125,7 @@ int NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Addre
ipv4.set_checksum(ipv4.compute_checksum()); ipv4.set_checksum(ipv4.compute_checksum());
m_packets_out++; m_packets_out++;
m_bytes_out += ethernet_frame_size; m_bytes_out += ethernet_frame_size;
if (!payload.read(ipv4.payload(), payload_size)) if (!payload.read(ipv4.payload(), payload_size))
return -EFAULT; return -EFAULT;
send_raw({ (const u8*)&eth, ethernet_frame_size }); send_raw({ (const u8*)&eth, ethernet_frame_size });

View file

@ -44,8 +44,8 @@ struct TCPFlags {
class [[gnu::packed]] TCPPacket class [[gnu::packed]] TCPPacket
{ {
public: public:
TCPPacket() {} TCPPacket() { }
~TCPPacket() {} ~TCPPacket() { }
size_t header_size() const { return data_offset() * sizeof(u32); } size_t header_size() const { return data_offset() * sizeof(u32); }

View file

@ -33,8 +33,8 @@ namespace Kernel {
class [[gnu::packed]] UDPPacket class [[gnu::packed]] UDPPacket
{ {
public: public:
UDPPacket() {} UDPPacket() { }
~UDPPacket() {} ~UDPPacket() { }
u16 source_port() const { return m_source_port; } u16 source_port() const { return m_source_port; }
void set_source_port(u16 port) { m_source_port = port; } void set_source_port(u16 port) { m_source_port = port; }

View file

@ -24,8 +24,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <Kernel/PCI/IOAccess.h>
#include <Kernel/IO.h> #include <Kernel/IO.h>
#include <Kernel/PCI/IOAccess.h>
namespace Kernel { namespace Kernel {
namespace PCI { namespace PCI {

View file

@ -26,12 +26,12 @@
#include <Kernel/ACPI/Parser.h> #include <Kernel/ACPI/Parser.h>
#include <Kernel/CommandLine.h> #include <Kernel/CommandLine.h>
#include <Kernel/IO.h>
#include <Kernel/Net/E1000NetworkAdapter.h> #include <Kernel/Net/E1000NetworkAdapter.h>
#include <Kernel/Net/RTL8139NetworkAdapter.h> #include <Kernel/Net/RTL8139NetworkAdapter.h>
#include <Kernel/PCI/IOAccess.h> #include <Kernel/PCI/IOAccess.h>
#include <Kernel/PCI/Initializer.h> #include <Kernel/PCI/Initializer.h>
#include <Kernel/PCI/MMIOAccess.h> #include <Kernel/PCI/MMIOAccess.h>
#include <Kernel/IO.h>
namespace Kernel { namespace Kernel {
namespace PCI { namespace PCI {

View file

@ -31,7 +31,7 @@
class PhysicalAddress { class PhysicalAddress {
public: public:
PhysicalAddress() {} PhysicalAddress() { }
explicit PhysicalAddress(FlatPtr address) explicit PhysicalAddress(FlatPtr address)
: m_address(address) : m_address(address)
{ {

View file

@ -26,9 +26,9 @@
#pragma once #pragma once
#include <Kernel/API/Syscall.h>
#include <Kernel/KResult.h> #include <Kernel/KResult.h>
#include <Kernel/Process.h> #include <Kernel/Process.h>
#include <Kernel/API/Syscall.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/i386/regs.h>
namespace Ptrace { namespace Ptrace {

View file

@ -24,10 +24,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <Kernel/API/Syscall.h>
#include <Kernel/Arch/i386/CPU.h> #include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Process.h> #include <Kernel/Process.h>
#include <Kernel/Random.h> #include <Kernel/Random.h>
#include <Kernel/API/Syscall.h>
#include <Kernel/ThreadTracer.h> #include <Kernel/ThreadTracer.h>
#include <Kernel/VM/MemoryManager.h> #include <Kernel/VM/MemoryManager.h>
@ -36,6 +36,7 @@ namespace Kernel {
extern "C" void syscall_handler(TrapFrame*); extern "C" void syscall_handler(TrapFrame*);
extern "C" void syscall_asm_entry(); extern "C" void syscall_asm_entry();
// clang-format off
asm( asm(
".globl syscall_asm_entry\n" ".globl syscall_asm_entry\n"
"syscall_asm_entry:\n" "syscall_asm_entry:\n"
@ -63,6 +64,7 @@ asm(
" call syscall_handler \n" " call syscall_handler \n"
" movl %ebx, 0(%esp) \n" // push pointer to TrapFrame " movl %ebx, 0(%esp) \n" // push pointer to TrapFrame
" jmp common_trap_exit \n"); " jmp common_trap_exit \n");
// clang-format on
namespace Syscall { namespace Syscall {

View file

@ -41,8 +41,8 @@ ssize_t Process::sys$getrandom(Userspace<void*> buffer, size_t buffer_size, [[ma
SmapDisabler disabler; SmapDisabler disabler;
auto data_buffer = UserOrKernelBuffer::for_user_buffer(buffer, buffer_size); auto data_buffer = UserOrKernelBuffer::for_user_buffer(buffer, buffer_size);
if (!data_buffer.has_value()) if (!data_buffer.has_value())
return -EFAULT; return -EFAULT;
ssize_t nwritten = data_buffer.value().write_buffered<1024>(buffer_size, [&](u8* buffer, size_t buffer_bytes) { ssize_t nwritten = data_buffer.value().write_buffered<1024>(buffer_size, [&](u8* buffer, size_t buffer_bytes) {
get_good_random_bytes(buffer, buffer_bytes); get_good_random_bytes(buffer, buffer_bytes);
return (ssize_t)buffer_bytes; return (ssize_t)buffer_bytes;

View file

@ -91,8 +91,7 @@ KResult Process::poke_user_data(Userspace<u32*> address, u32 data)
region->set_shared(false); region->set_shared(false);
} }
const bool was_writable = region->is_writable(); const bool was_writable = region->is_writable();
if (!was_writable) if (!was_writable) {
{
region->set_writable(true); region->set_writable(true);
region->remap(); region->remap();
} }

View file

@ -166,7 +166,7 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params)
if (!copy_from_user(&fds_copy[0], &params.fds[0], params.nfds * sizeof(pollfd))) if (!copy_from_user(&fds_copy[0], &params.fds[0], params.nfds * sizeof(pollfd)))
return -EFAULT; return -EFAULT;
} }
Thread::SelectBlocker::FDVector rfds; Thread::SelectBlocker::FDVector rfds;
Thread::SelectBlocker::FDVector wfds; Thread::SelectBlocker::FDVector wfds;

View file

@ -159,7 +159,7 @@ int Process::sys$join_thread(pid_t tid, Userspace<void**> exit_value)
thread = nullptr; thread = nullptr;
if (exit_value && !copy_to_user(exit_value, &joinee_exit_value)) if (exit_value && !copy_to_user(exit_value, &joinee_exit_value))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }

View file

@ -35,7 +35,7 @@ void FinalizerTask::spawn()
Thread::current()->set_priority(THREAD_PRIORITY_LOW); Thread::current()->set_priority(THREAD_PRIORITY_LOW);
for (;;) { for (;;) {
Thread::current()->wait_on(*g_finalizer_wait_queue, "FinalizerTask"); Thread::current()->wait_on(*g_finalizer_wait_queue, "FinalizerTask");
bool expected = true; bool expected = true;
if (g_finalizer_has_work.compare_exchange_strong(expected, false, AK::MemoryOrder::memory_order_acq_rel)) if (g_finalizer_has_work.compare_exchange_strong(expected, false, AK::MemoryOrder::memory_order_acq_rel))
Thread::finalize_dying_threads(); Thread::finalize_dying_threads();

View file

@ -510,7 +510,6 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
klog() << "signal: dispatch signal " << signal << " to " << *this; klog() << "signal: dispatch signal " << signal << " to " << *this;
#endif #endif
if (m_state == Invalid || !is_initialized()) { if (m_state == Invalid || !is_initialized()) {
// Thread has barely been created, we need to wait until it is // Thread has barely been created, we need to wait until it is
// at least in Runnable state and is_initialized() returns true, // at least in Runnable state and is_initialized() returns true,

View file

@ -25,12 +25,12 @@
*/ */
#include <Kernel/Arch/i386/CPU.h> #include <Kernel/Arch/i386/CPU.h>
#include <Kernel/IO.h>
#include <Kernel/Interrupts/PIC.h> #include <Kernel/Interrupts/PIC.h>
#include <Kernel/Scheduler.h> #include <Kernel/Scheduler.h>
#include <Kernel/Thread.h> #include <Kernel/Thread.h>
#include <Kernel/Time/PIT.h> #include <Kernel/Time/PIT.h>
#include <Kernel/Time/TimeManagement.h> #include <Kernel/Time/TimeManagement.h>
#include <Kernel/IO.h>
#define IRQ_TIMER 0 #define IRQ_TIMER 0
namespace Kernel { namespace Kernel {

View file

@ -26,9 +26,9 @@
#include <Kernel/Arch/i386/CPU.h> #include <Kernel/Arch/i386/CPU.h>
#include <Kernel/CMOS.h> #include <Kernel/CMOS.h>
#include <Kernel/IO.h>
#include <Kernel/Time/RTC.h> #include <Kernel/Time/RTC.h>
#include <Kernel/Time/TimeManagement.h> #include <Kernel/Time/TimeManagement.h>
#include <Kernel/IO.h>
namespace Kernel { namespace Kernel {
#define IRQ_TIMER 8 #define IRQ_TIMER 8

View file

@ -40,8 +40,8 @@ public:
virtual bool is_periodic() const override { return true; } virtual bool is_periodic() const override { return true; }
virtual bool is_periodic_capable() const override { return true; } virtual bool is_periodic_capable() const override { return true; }
virtual void set_periodic() override {} virtual void set_periodic() override { }
virtual void set_non_periodic() override {} virtual void set_non_periodic() override { }
virtual void reset_to_default_ticks_per_second() override; virtual void reset_to_default_ticks_per_second() override;
virtual bool try_to_set_frequency(size_t frequency) override; virtual bool try_to_set_frequency(size_t frequency) override;

View file

@ -73,7 +73,6 @@ void TimeManagement::initialize()
{ {
ASSERT(!s_the.is_initialized()); ASSERT(!s_the.is_initialized());
s_the.ensure_instance(); s_the.ensure_instance();
} }
time_t TimeManagement::seconds_since_boot() const time_t TimeManagement::seconds_since_boot() const
{ {

View file

@ -26,8 +26,8 @@
#pragma once #pragma once
#include <Kernel/VM/VMObject.h>
#include <Kernel/PhysicalAddress.h> #include <Kernel/PhysicalAddress.h>
#include <Kernel/VM/VMObject.h>
namespace Kernel { namespace Kernel {

View file

@ -33,6 +33,7 @@
#include <Kernel/Heap/kmalloc.h> #include <Kernel/Heap/kmalloc.h>
#include <Kernel/Multiboot.h> #include <Kernel/Multiboot.h>
#include <Kernel/Process.h> #include <Kernel/Process.h>
#include <Kernel/StdLib.h>
#include <Kernel/VM/AnonymousVMObject.h> #include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/ContiguousVMObject.h> #include <Kernel/VM/ContiguousVMObject.h>
#include <Kernel/VM/MemoryManager.h> #include <Kernel/VM/MemoryManager.h>
@ -40,7 +41,6 @@
#include <Kernel/VM/PhysicalRegion.h> #include <Kernel/VM/PhysicalRegion.h>
#include <Kernel/VM/PurgeableVMObject.h> #include <Kernel/VM/PurgeableVMObject.h>
#include <Kernel/VM/SharedInodeVMObject.h> #include <Kernel/VM/SharedInodeVMObject.h>
#include <Kernel/StdLib.h>
//#define MM_DEBUG //#define MM_DEBUG
//#define PAGE_FAULT_DEBUG //#define PAGE_FAULT_DEBUG
@ -235,6 +235,7 @@ PageTableEntry* MemoryManager::ensure_pte(PageDirectory& page_directory, Virtual
// we're writing to the correct underlying physical page // we're writing to the correct underlying physical page
pd = quickmap_pd(page_directory, page_directory_table_index); pd = quickmap_pd(page_directory, page_directory_table_index);
ASSERT(&pde == &pd[page_directory_index]); // Sanity check ASSERT(&pde == &pd[page_directory_index]); // Sanity check
ASSERT(!pde.is_present()); // Should have not changed ASSERT(!pde.is_present()); // Should have not changed
} }
#ifdef MM_DEBUG #ifdef MM_DEBUG

View file

@ -89,7 +89,7 @@ public:
static bool is_initialized(); static bool is_initialized();
static void initialize(u32 cpu); static void initialize(u32 cpu);
static inline MemoryManagerData& get_data() static inline MemoryManagerData& get_data()
{ {
return Processor::current().get_mm_data(); return Processor::current().get_mm_data();

View file

@ -67,7 +67,7 @@ public:
private: private:
PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true); PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
~PhysicalPage() {} ~PhysicalPage() { }
void return_to_freelist() const; void return_to_freelist() const;

View file

@ -95,19 +95,19 @@ Optional<unsigned> PhysicalRegion::find_one_free_page()
// We know we don't have any free pages, no need to check the bitmap // We know we don't have any free pages, no need to check the bitmap
// Check if we can draw one from the return queue // Check if we can draw one from the return queue
if (m_recently_returned.size() > 0) { if (m_recently_returned.size() > 0) {
u8 index = get_fast_random<u8>() % m_recently_returned.size(); u8 index = get_fast_random<u8>() % m_recently_returned.size();
ptrdiff_t local_offset = m_recently_returned[index].get() - m_lower.get(); ptrdiff_t local_offset = m_recently_returned[index].get() - m_lower.get();
m_recently_returned.remove(index); m_recently_returned.remove(index);
ASSERT(local_offset >= 0); ASSERT(local_offset >= 0);
ASSERT((FlatPtr)local_offset < (FlatPtr)(m_pages * PAGE_SIZE)); ASSERT((FlatPtr)local_offset < (FlatPtr)(m_pages * PAGE_SIZE));
return local_offset / PAGE_SIZE; return local_offset / PAGE_SIZE;
} }
return {}; return {};
} }
auto free_index = m_bitmap.find_one_anywhere_unset(m_free_hint); auto free_index = m_bitmap.find_one_anywhere_unset(m_free_hint);
if (!free_index.has_value()) if (!free_index.has_value())
return {}; return {};
auto page_index = free_index.value(); auto page_index = free_index.value();
m_bitmap.set(page_index, true); m_bitmap.set(page_index, true);
m_used++; m_used++;

View file

@ -39,7 +39,7 @@ class PhysicalRegion : public RefCounted<PhysicalRegion> {
public: public:
static NonnullRefPtr<PhysicalRegion> create(PhysicalAddress lower, PhysicalAddress upper); static NonnullRefPtr<PhysicalRegion> create(PhysicalAddress lower, PhysicalAddress upper);
~PhysicalRegion() {} ~PhysicalRegion() { }
void expand(PhysicalAddress lower, PhysicalAddress upper); void expand(PhysicalAddress lower, PhysicalAddress upper);
unsigned finalize_capacity(); unsigned finalize_capacity();

View file

@ -85,7 +85,7 @@ int PurgeableVMObject::purge_impl()
if (purged_page_count > 0) { if (purged_page_count > 0) {
for_each_region([&](auto& region) { for_each_region([&](auto& region) {
if (&region.vmobject() == this) if (&region.vmobject() == this)
region.remap(); region.remap();
}); });
} }

View file

@ -37,7 +37,7 @@ class Range {
friend class RangeAllocator; friend class RangeAllocator;
public: public:
Range() {} Range() { }
Range(VirtualAddress base, size_t size) Range(VirtualAddress base, size_t size)
: m_base(base) : m_base(base)
, m_size(size) , m_size(size)

View file

@ -118,7 +118,7 @@ public:
{ {
return (vaddr - m_range.base()).get() / PAGE_SIZE; return (vaddr - m_range.base()).get() / PAGE_SIZE;
} }
VirtualAddress vaddr_from_page_index(size_t page_index) const VirtualAddress vaddr_from_page_index(size_t page_index) const
{ {
return vaddr().offset(page_index * PAGE_SIZE); return vaddr().offset(page_index * PAGE_SIZE);
@ -238,5 +238,4 @@ inline unsigned prot_to_region_access_flags(int prot)
return access; return access;
} }
} }

View file

@ -31,7 +31,7 @@
class VirtualAddress { class VirtualAddress {
public: public:
VirtualAddress() {} VirtualAddress() { }
explicit VirtualAddress(FlatPtr address) explicit VirtualAddress(FlatPtr address)
: m_address(address) : m_address(address)
{ {

View file

@ -31,7 +31,6 @@
namespace Kernel { namespace Kernel {
WaitQueue::WaitQueue() WaitQueue::WaitQueue()
{ {
} }