mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:17:45 +00:00
Kernel: Make self-contained locking smart pointers their own classes
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
This commit is contained in:
parent
e475263113
commit
11eee67b85
360 changed files with 1703 additions and 1672 deletions
|
@ -20,9 +20,9 @@ static constexpr u16 pcm_fixed_sample_rate = 48000;
|
|||
static constexpr u16 pcm_sample_rate_minimum = 8000;
|
||||
static constexpr u16 pcm_sample_rate_maximum = 48000;
|
||||
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<AC97>> AC97::try_create(PCI::DeviceIdentifier const& pci_device_identifier)
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<AC97>> AC97::try_create(PCI::DeviceIdentifier const& pci_device_identifier)
|
||||
{
|
||||
auto ac97 = adopt_nonnull_ref_or_enomem(new (nothrow) AC97(pci_device_identifier));
|
||||
auto ac97 = adopt_nonnull_lock_ref_or_enomem(new (nothrow) AC97(pci_device_identifier));
|
||||
if (!ac97.is_error())
|
||||
TRY(ac97.value()->initialize());
|
||||
return ac97;
|
||||
|
@ -166,7 +166,7 @@ void AC97::set_pcm_output_volume(u8 left_channel, u8 right_channel, Muted mute)
|
|||
m_io_mixer_base.offset(NativeAudioMixerRegister::SetPCMOutputVolume).out(volume_value);
|
||||
}
|
||||
|
||||
RefPtr<AudioChannel> AC97::audio_channel(u32 index) const
|
||||
LockRefPtr<AudioChannel> AC97::audio_channel(u32 index) const
|
||||
{
|
||||
if (index == 0)
|
||||
return m_audio_channel;
|
||||
|
|
|
@ -26,7 +26,7 @@ class AC97 final
|
|||
, public IRQHandler {
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<AC97>> try_create(PCI::DeviceIdentifier const&);
|
||||
static ErrorOr<NonnullLockRefPtr<AC97>> try_create(PCI::DeviceIdentifier const&);
|
||||
|
||||
virtual ~AC97() override;
|
||||
|
||||
|
@ -161,7 +161,7 @@ private:
|
|||
ErrorOr<void> write_single_buffer(UserOrKernelBuffer const&, size_t, size_t);
|
||||
|
||||
// ^AudioController
|
||||
virtual RefPtr<AudioChannel> audio_channel(u32 index) const override;
|
||||
virtual LockRefPtr<AudioChannel> audio_channel(u32 index) const override;
|
||||
virtual ErrorOr<size_t> write(size_t channel_index, UserOrKernelBuffer const& data, size_t length) override;
|
||||
virtual void detect_hardware_audio_channels(Badge<AudioManagement>) override;
|
||||
virtual ErrorOr<void> set_pcm_output_sample_rate(size_t channel_index, u32 samples_per_second_rate) override;
|
||||
|
@ -180,7 +180,7 @@ private:
|
|||
AC97Channel m_pcm_out_channel;
|
||||
u32 m_sample_rate { 0 };
|
||||
bool m_variable_rate_pcm_supported { false };
|
||||
RefPtr<AudioChannel> m_audio_channel;
|
||||
LockRefPtr<AudioChannel> m_audio_channel;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<AudioChannel> AudioChannel::must_create(AudioController const& controller, size_t channel_index)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<AudioChannel> AudioChannel::must_create(AudioController const& controller, size_t channel_index)
|
||||
{
|
||||
auto audio_device_or_error = DeviceManagement::try_create_device<AudioChannel>(controller, channel_index);
|
||||
// FIXME: Find a way to propagate errors
|
||||
|
|
|
@ -20,7 +20,7 @@ class AudioChannel final
|
|||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<AudioChannel> must_create(AudioController const&, size_t channel_index);
|
||||
static NonnullLockRefPtr<AudioChannel> must_create(AudioController const&, size_t channel_index);
|
||||
virtual ~AudioChannel() override = default;
|
||||
|
||||
// ^CharacterDevice
|
||||
|
@ -37,7 +37,7 @@ private:
|
|||
// ^CharacterDevice
|
||||
virtual StringView class_name() const override { return "AudioChannel"sv; }
|
||||
|
||||
WeakPtr<AudioController> m_controller;
|
||||
LockWeakPtr<AudioController> m_controller;
|
||||
const size_t m_channel_index;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Bus/PCI/Access.h>
|
||||
#include <Kernel/Bus/PCI/Device.h>
|
||||
#include <Kernel/Devices/Audio/Channel.h>
|
||||
#include <Kernel/Devices/Device.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Library/LockWeakable.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
#include <Kernel/Memory/PhysicalPage.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
@ -24,13 +24,13 @@ namespace Kernel {
|
|||
class AudioManagement;
|
||||
class AudioController
|
||||
: public AtomicRefCounted<AudioController>
|
||||
, public Weakable<AudioController> {
|
||||
, public LockWeakable<AudioController> {
|
||||
friend class AudioManagement;
|
||||
|
||||
public:
|
||||
virtual ~AudioController() = default;
|
||||
|
||||
virtual RefPtr<AudioChannel> audio_channel(u32 index) const = 0;
|
||||
virtual LockRefPtr<AudioChannel> audio_channel(u32 index) const = 0;
|
||||
virtual ErrorOr<size_t> write(size_t channel_index, UserOrKernelBuffer const& data, size_t length) = 0;
|
||||
|
||||
virtual void detect_hardware_audio_channels(Badge<AudioManagement>) = 0;
|
||||
|
@ -40,6 +40,6 @@ public:
|
|||
virtual ErrorOr<u32> get_pcm_output_sample_rate(size_t channel_index) = 0;
|
||||
|
||||
private:
|
||||
IntrusiveListNode<AudioController, RefPtr<AudioController>> m_node;
|
||||
IntrusiveListNode<AudioController, LockRefPtr<AudioController>> m_node;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include <AK/Error.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Devices/Audio/Controller.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue