Skip to content

Commit

Permalink
Kernel: Rename SpinLock => Spinlock
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Aug 22, 2021
1 parent 7d5d26b commit 55adace
Show file tree
Hide file tree
Showing 110 changed files with 491 additions and 491 deletions.
2 changes: 1 addition & 1 deletion Kernel/Arch/x86/common/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ Vector<FlatPtr> Processor::capture_stack_trace(Thread& thread, size_t max_frames
// is a chance a context switch may happen while we're trying
// to get it. It also won't be entirely accurate and merely
// reflect the status at the last context switch.
ScopedSpinLock lock(g_scheduler_lock);
ScopedSpinlock lock(g_scheduler_lock);
if (&thread == Processor::current_thread()) {
VERIFY(thread.state() == Thread::Running);
// Leave the scheduler lock. If we trigger page faults we may
Expand Down
12 changes: 6 additions & 6 deletions Kernel/Bus/PCI/MMIOAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ VirtualAddress MMIOAccess::get_device_configuration_space(Address address)

u8 MMIOAccess::read8_field(Address address, u32 field)
{
ScopedSpinLock lock(m_access_lock);
ScopedSpinlock lock(m_access_lock);
VERIFY(field <= 0xfff);
dbgln_if(PCI_DEBUG, "PCI: MMIO Reading 8-bit field {:#08x} for {}", field, address);
return *((volatile u8*)(get_device_configuration_space(address).get() + (field & 0xfff)));
}

u16 MMIOAccess::read16_field(Address address, u32 field)
{
ScopedSpinLock lock(m_access_lock);
ScopedSpinlock lock(m_access_lock);
VERIFY(field < 0xfff);
dbgln_if(PCI_DEBUG, "PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address);
u16 data = 0;
Expand All @@ -135,7 +135,7 @@ u16 MMIOAccess::read16_field(Address address, u32 field)

u32 MMIOAccess::read32_field(Address address, u32 field)
{
ScopedSpinLock lock(m_access_lock);
ScopedSpinlock lock(m_access_lock);
VERIFY(field <= 0xffc);
dbgln_if(PCI_DEBUG, "PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address);
u32 data = 0;
Expand All @@ -145,21 +145,21 @@ u32 MMIOAccess::read32_field(Address address, u32 field)

void MMIOAccess::write8_field(Address address, u32 field, u8 value)
{
ScopedSpinLock lock(m_access_lock);
ScopedSpinlock lock(m_access_lock);
VERIFY(field <= 0xfff);
dbgln_if(PCI_DEBUG, "PCI: MMIO Writing 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((volatile u8*)(get_device_configuration_space(address).get() + (field & 0xfff))) = value;
}
void MMIOAccess::write16_field(Address address, u32 field, u16 value)
{
ScopedSpinLock lock(m_access_lock);
ScopedSpinlock lock(m_access_lock);
VERIFY(field < 0xfff);
dbgln_if(PCI_DEBUG, "PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
ByteReader::store<u16>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), value);
}
void MMIOAccess::write32_field(Address address, u32 field, u32 value)
{
ScopedSpinLock lock(m_access_lock);
ScopedSpinlock lock(m_access_lock);
VERIFY(field <= 0xffc);
dbgln_if(PCI_DEBUG, "PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
ByteReader::store<u32>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), value);
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Bus/PCI/MMIOAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <AK/Types.h>
#include <Kernel/ACPI/Definitions.h>
#include <Kernel/Bus/PCI/Access.h>
#include <Kernel/Locking/SpinLock.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Memory/AnonymousVMObject.h>
#include <Kernel/Memory/PhysicalRegion.h>
#include <Kernel/Memory/Region.h>
Expand Down Expand Up @@ -44,7 +44,7 @@ class MMIOAccess : public Access {
PhysicalAddress determine_memory_mapped_bus_region(u32 segment, u8 bus) const;
void map_bus_region(u32, u8);
VirtualAddress get_device_configuration_space(Address address);
SpinLock<u8> m_access_lock;
Spinlock<u8> m_access_lock;
u8 m_mapped_bus { 0 };
OwnPtr<Memory::Region> m_mapped_region;

Expand Down
8 changes: 4 additions & 4 deletions Kernel/Bus/USB/SysFSUSB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ KResultOr<size_t> SysFSUSBDeviceInformation::read_bytes(off_t offset, size_t cou

KResult SysFSUSBBusDirectory::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
// Note: if the parent directory is null, it means something bad happened as this should not happen for the USB directory.
VERIFY(m_parent_directory);
callback({ ".", { fsid, component_index() }, 0 });
Expand All @@ -72,7 +72,7 @@ KResult SysFSUSBBusDirectory::traverse_as_directory(unsigned fsid, Function<bool

RefPtr<SysFSComponent> SysFSUSBBusDirectory::lookup(StringView name)
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
for (auto& device_node : m_device_nodes) {
if (device_node.name() == name) {
return device_node;
Expand All @@ -93,15 +93,15 @@ RefPtr<SysFSUSBDeviceInformation> SysFSUSBBusDirectory::device_node_for(USB::Dev

void SysFSUSBBusDirectory::plug(USB::Device& new_device)
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
auto device_node = device_node_for(new_device);
VERIFY(!device_node);
m_device_nodes.append(SysFSUSBDeviceInformation::create(new_device));
}

void SysFSUSBBusDirectory::unplug(USB::Device& deleted_device)
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
auto device_node = device_node_for(deleted_device);
VERIFY(device_node);
device_node->m_list_node.remove();
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Bus/USB/SysFSUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SysFSUSBBusDirectory final : public SysFSDirectory {
RefPtr<SysFSUSBDeviceInformation> device_node_for(USB::Device& device);

IntrusiveList<SysFSUSBDeviceInformation, RefPtr<SysFSUSBDeviceInformation>, &SysFSUSBDeviceInformation::m_list_node> m_device_nodes;
mutable SpinLock<u8> m_lock;
mutable Spinlock<u8> m_lock;
};

}
14 changes: 7 additions & 7 deletions Kernel/Bus/VirtIO/VirtIOConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ void VirtIOConsole::handle_queue_update(u16 queue_index)
dbgln_if(VIRTIO_DEBUG, "VirtIOConsole: Handle queue update {}", queue_index);

if (queue_index == CONTROL_RECEIVEQ) {
ScopedSpinLock ringbuffer_lock(m_control_receive_buffer->lock());
ScopedSpinlock ringbuffer_lock(m_control_receive_buffer->lock());
auto& queue = get_queue(CONTROL_RECEIVEQ);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());
size_t used;
VirtIOQueueChain popped_chain = queue.pop_used_buffer_chain(used);

Expand All @@ -81,9 +81,9 @@ void VirtIOConsole::handle_queue_update(u16 queue_index)
popped_chain = queue.pop_used_buffer_chain(used);
}
} else if (queue_index == CONTROL_TRANSMITQ) {
ScopedSpinLock ringbuffer_lock(m_control_transmit_buffer->lock());
ScopedSpinlock ringbuffer_lock(m_control_transmit_buffer->lock());
auto& queue = get_queue(CONTROL_TRANSMITQ);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());
size_t used;
VirtIOQueueChain popped_chain = queue.pop_used_buffer_chain(used);
auto number_of_messages = 0;
Expand Down Expand Up @@ -112,7 +112,7 @@ void VirtIOConsole::setup_multiport()
m_control_transmit_buffer = make<Memory::RingBuffer>("VirtIOConsole control transmit queue", CONTROL_BUFFER_SIZE);

auto& queue = get_queue(CONTROL_RECEIVEQ);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());
VirtIOQueueChain chain(queue);
auto offset = 0ul;

Expand Down Expand Up @@ -184,7 +184,7 @@ void VirtIOConsole::process_control_message(ControlMessage message)
}
void VirtIOConsole::write_control_message(ControlMessage message)
{
ScopedSpinLock ringbuffer_lock(m_control_transmit_buffer->lock());
ScopedSpinlock ringbuffer_lock(m_control_transmit_buffer->lock());

PhysicalAddress start_of_chunk;
size_t length_of_chunk;
Expand All @@ -197,7 +197,7 @@ void VirtIOConsole::write_control_message(ControlMessage message)
}

auto& queue = get_queue(CONTROL_TRANSMITQ);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());
VirtIOQueueChain chain(queue);

bool did_add_buffer = chain.add_buffer_to_chain(start_of_chunk, length_of_chunk, BufferType::DeviceReadable);
Expand Down
18 changes: 9 additions & 9 deletions Kernel/Bus/VirtIO/VirtIOConsolePort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ VirtIOConsolePort::VirtIOConsolePort(unsigned port, VirtIOConsole& console)
void VirtIOConsolePort::init_receive_buffer()
{
auto& queue = m_console.get_queue(m_receive_queue);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());
VirtIOQueueChain chain(queue);

auto buffer_start = m_receive_buffer->start_of_region();
Expand All @@ -42,11 +42,11 @@ void VirtIOConsolePort::handle_queue_update(Badge<VirtIOConsole>, u16 queue_inde
VERIFY(queue_index == m_transmit_queue || queue_index == m_receive_queue);
if (queue_index == m_receive_queue) {
auto& queue = m_console.get_queue(m_receive_queue);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());
size_t used;
VirtIOQueueChain popped_chain = queue.pop_used_buffer_chain(used);

ScopedSpinLock ringbuffer_lock(m_receive_buffer->lock());
ScopedSpinlock ringbuffer_lock(m_receive_buffer->lock());
auto used_space = m_receive_buffer->reserve_space(used).value();
auto remaining_space = m_receive_buffer->bytes_till_end();

Expand All @@ -65,9 +65,9 @@ void VirtIOConsolePort::handle_queue_update(Badge<VirtIOConsole>, u16 queue_inde

evaluate_block_conditions();
} else {
ScopedSpinLock ringbuffer_lock(m_transmit_buffer->lock());
ScopedSpinlock ringbuffer_lock(m_transmit_buffer->lock());
auto& queue = m_console.get_queue(m_transmit_queue);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());
size_t used;
VirtIOQueueChain popped_chain = queue.pop_used_buffer_chain(used);
do {
Expand All @@ -92,7 +92,7 @@ KResultOr<size_t> VirtIOConsolePort::read(FileDescription& desc, u64, UserOrKern
if (!size)
return 0;

ScopedSpinLock ringbuffer_lock(m_receive_buffer->lock());
ScopedSpinlock ringbuffer_lock(m_receive_buffer->lock());

if (!can_read(desc, size))
return EAGAIN;
Expand All @@ -102,7 +102,7 @@ KResultOr<size_t> VirtIOConsolePort::read(FileDescription& desc, u64, UserOrKern

if (m_receive_buffer_exhausted && m_receive_buffer->used_bytes() == 0) {
auto& queue = m_console.get_queue(m_receive_queue);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());
VirtIOQueueChain new_chain(queue);
new_chain.add_buffer_to_chain(m_receive_buffer->start_of_region(), RINGBUFFER_SIZE, BufferType::DeviceWritable);
m_console.supply_chain_and_notify(m_receive_queue, new_chain);
Expand All @@ -122,9 +122,9 @@ KResultOr<size_t> VirtIOConsolePort::write(FileDescription& desc, u64, const Use
if (!size)
return 0;

ScopedSpinLock ringbuffer_lock(m_transmit_buffer->lock());
ScopedSpinlock ringbuffer_lock(m_transmit_buffer->lock());
auto& queue = m_console.get_queue(m_transmit_queue);
ScopedSpinLock queue_lock(queue.lock());
ScopedSpinlock queue_lock(queue.lock());

if (!can_write(desc, size))
return EAGAIN;
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Bus/VirtIO/VirtIOQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ VirtIOQueue::~VirtIOQueue()

void VirtIOQueue::enable_interrupts()
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
m_driver->flags = 0;
}

void VirtIOQueue::disable_interrupts()
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
m_driver->flags = 1;
}

Expand Down
6 changes: 3 additions & 3 deletions Kernel/Bus/VirtIO/VirtIOQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#pragma once

#include <Kernel/Locking/SpinLock.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Memory/ScatterGatherList.h>

Expand Down Expand Up @@ -47,7 +47,7 @@ class VirtIOQueue {
VirtIOQueueChain pop_used_buffer_chain(size_t& used);
void discard_used_buffers();

SpinLock<u8>& lock() { return m_lock; }
Spinlock<u8>& lock() { return m_lock; }

bool should_notify() const;

Expand Down Expand Up @@ -94,7 +94,7 @@ class VirtIOQueue {
OwnPtr<VirtIOQueueDriver> m_driver { nullptr };
OwnPtr<VirtIOQueueDevice> m_device { nullptr };
OwnPtr<Memory::Region> m_queue_region;
SpinLock<u8> m_lock;
Spinlock<u8> m_lock;

friend class VirtIOQueueChain;
};
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Bus/VirtIO/VirtIORNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void VirtIORNG::handle_queue_update(u16 queue_index)
size_t available_entropy = 0, used;
auto& queue = get_queue(REQUESTQ);
{
ScopedSpinLock lock(queue.lock());
ScopedSpinlock lock(queue.lock());
auto chain = queue.pop_used_buffer_chain(used);
if (chain.is_empty())
return;
Expand All @@ -64,7 +64,7 @@ void VirtIORNG::handle_queue_update(u16 queue_index)
void VirtIORNG::request_entropy_from_host()
{
auto& queue = get_queue(REQUESTQ);
ScopedSpinLock lock(queue.lock());
ScopedSpinlock lock(queue.lock());
VirtIOQueueChain chain(queue);
chain.add_buffer_to_chain(m_entropy_buffer->physical_page(0)->paddr(), PAGE_SIZE, BufferType::DeviceWritable);
supply_chain_and_notify(REQUESTQ, chain);
Expand Down
6 changes: 3 additions & 3 deletions Kernel/ConsoleDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
#include <AK/Singleton.h>
#include <Kernel/ConsoleDevice.h>
#include <Kernel/IO.h>
#include <Kernel/Locking/SpinLock.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Sections.h>
#include <Kernel/kstdio.h>

// Output bytes to kernel debug port 0xE9 (Bochs console). It's very handy.
#define CONSOLE_OUT_TO_BOCHS_DEBUG_PORT

static Singleton<ConsoleDevice> s_the;
static Kernel::SpinLock g_console_lock;
static Kernel::Spinlock g_console_lock;

UNMAP_AFTER_INIT void ConsoleDevice::initialize()
{
Expand Down Expand Up @@ -67,7 +67,7 @@ Kernel::KResultOr<size_t> ConsoleDevice::write(FileDescription&, u64, const Kern

void ConsoleDevice::put_char(char ch)
{
Kernel::ScopedSpinLock lock(g_console_lock);
Kernel::ScopedSpinlock lock(g_console_lock);
#ifdef CONSOLE_OUT_TO_BOCHS_DEBUG_PORT
IO::out8(IO::BOCHS_DEBUG_PORT, ch);
#endif
Expand Down
4 changes: 2 additions & 2 deletions Kernel/CoreDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/KLexicalPath.h>
#include <Kernel/Locking/SpinLock.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Memory/ProcessPagingScope.h>
#include <Kernel/Process.h>
#include <Kernel/RTC.h>
Expand Down Expand Up @@ -321,7 +321,7 @@ ByteBuffer CoreDump::create_notes_segment_data() const

KResult CoreDump::write()
{
ScopedSpinLock lock(m_process->address_space().get_lock());
ScopedSpinlock lock(m_process->address_space().get_lock());
ProcessPagingScope scope(m_process);

ByteBuffer notes_segment = create_notes_segment_data();
Expand Down
10 changes: 5 additions & 5 deletions Kernel/Devices/AsyncDeviceRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AsyncDeviceRequest::AsyncDeviceRequest(Device& device)
AsyncDeviceRequest::~AsyncDeviceRequest()
{
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
VERIFY(is_completed_result(m_result));
VERIFY(m_sub_requests_pending.is_empty());
}
Expand Down Expand Up @@ -63,7 +63,7 @@ auto AsyncDeviceRequest::wait(Time* timeout) -> RequestWaitResult

auto AsyncDeviceRequest::get_request_result() const -> RequestResult
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
return m_result;
}

Expand All @@ -74,7 +74,7 @@ void AsyncDeviceRequest::add_sub_request(NonnullRefPtr<AsyncDeviceRequest> sub_r
VERIFY(sub_request->m_parent_request == nullptr);
sub_request->m_parent_request = this;

ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
VERIFY(!is_completed_result(m_result));
m_sub_requests_pending.append(sub_request);
if (m_result == Started)
Expand All @@ -85,7 +85,7 @@ void AsyncDeviceRequest::sub_request_finished(AsyncDeviceRequest& sub_request)
{
bool all_completed;
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
VERIFY(m_result == Started);

if (m_sub_requests_pending.contains(sub_request)) {
Expand Down Expand Up @@ -131,7 +131,7 @@ void AsyncDeviceRequest::complete(RequestResult result)
VERIFY(result == Success || result == Failure || result == MemoryFault);
ScopedCritical critical;
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
VERIFY(m_result == Started);
m_result = result;
}
Expand Down
Loading

0 comments on commit 55adace

Please sign in to comment.