mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03: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
Notes:
sideshowbarker
2024-07-17 08:07:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/11eee67b85
29
AK/Forward.h
29
AK/Forward.h
@ -55,7 +55,7 @@ struct Array;
|
||||
template<typename Container, typename ValueType>
|
||||
class SimpleIterator;
|
||||
|
||||
using ReadonlyBytes = Span<const u8>;
|
||||
using ReadonlyBytes = Span<u8 const>;
|
||||
using Bytes = Span<u8>;
|
||||
|
||||
template<typename T, AK::MemoryOrder DefaultMemoryOrder>
|
||||
@ -107,24 +107,30 @@ template<typename T>
|
||||
class NonnullOwnPtr;
|
||||
|
||||
template<typename T, size_t inline_capacity = 0>
|
||||
class NonnullRefPtrVector;
|
||||
class NonnullOwnPtrVector;
|
||||
|
||||
template<typename T, size_t inline_capacity = 0>
|
||||
class NonnullOwnPtrVector;
|
||||
class NonnullRefPtrVector;
|
||||
|
||||
template<typename T>
|
||||
class Optional;
|
||||
|
||||
#ifdef KERNEL
|
||||
template<typename T>
|
||||
struct RefPtrTraits;
|
||||
class NonnullLockRefPtr;
|
||||
|
||||
template<typename T, size_t inline_capacity = 0>
|
||||
class NonnullLockRefPtrVector;
|
||||
|
||||
template<typename T>
|
||||
struct LockRefPtrTraits;
|
||||
|
||||
template<typename T, typename PtrTraits = LockRefPtrTraits<T>>
|
||||
class LockRefPtr;
|
||||
#endif
|
||||
|
||||
template<typename T, typename PtrTraits = RefPtrTraits<T>>
|
||||
class RefPtr;
|
||||
#else
|
||||
template<typename T>
|
||||
class RefPtr;
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
class OwnPtr;
|
||||
@ -192,3 +198,10 @@ using AK::Utf32View;
|
||||
using AK::Utf8CodePointIterator;
|
||||
using AK::Utf8View;
|
||||
using AK::Vector;
|
||||
|
||||
#ifdef KERNEL
|
||||
using AK::LockRefPtr;
|
||||
using AK::LockRefPtrTraits;
|
||||
using AK::NonnullLockRefPtr;
|
||||
using AK::NonnullLockRefPtrVector;
|
||||
#endif
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
|
||||
#ifdef KERNEL
|
||||
# include <Kernel/Library/LockRefPtr.h>
|
||||
#endif
|
||||
namespace AK::Detail {
|
||||
|
||||
template<typename T, typename Container>
|
||||
@ -20,6 +23,13 @@ struct SubstituteIntrusiveContainerType<T, NonnullRefPtr<T>> {
|
||||
using Type = RefPtr<T>;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
template<typename T>
|
||||
struct SubstituteIntrusiveContainerType<T, NonnullLockRefPtr<T>> {
|
||||
using Type = LockRefPtr<T>;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename Container, bool _IsRaw>
|
||||
struct SelfReferenceIfNeeded {
|
||||
Container reference = nullptr;
|
||||
|
@ -13,6 +13,10 @@
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
#ifdef KERNEL
|
||||
# include <Kernel/Library/LockRefPtr.h>
|
||||
#endif
|
||||
|
||||
namespace AK::Detail {
|
||||
|
||||
template<typename T, typename Container = RawPtr<T>>
|
||||
@ -56,7 +60,7 @@ public:
|
||||
void prepend(T& n);
|
||||
void insert_before(T&, T&);
|
||||
void remove(T& n);
|
||||
[[nodiscard]] bool contains(const T&) const;
|
||||
[[nodiscard]] bool contains(T const&) const;
|
||||
[[nodiscard]] Container first() const;
|
||||
[[nodiscard]] Container last() const;
|
||||
|
||||
@ -71,7 +75,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
const T& operator*() const { return *m_value; }
|
||||
T const& operator*() const { return *m_value; }
|
||||
auto operator->() const { return m_value; }
|
||||
T& operator*() { return *m_value; }
|
||||
auto operator->() { return m_value; }
|
||||
@ -99,7 +103,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
const T& operator*() const { return *m_value; }
|
||||
T const& operator*() const { return *m_value; }
|
||||
auto operator->() const { return m_value; }
|
||||
T& operator*() { return *m_value; }
|
||||
auto operator->() { return m_value; }
|
||||
@ -122,12 +126,12 @@ public:
|
||||
class ConstIterator {
|
||||
public:
|
||||
ConstIterator() = default;
|
||||
ConstIterator(const T* value)
|
||||
ConstIterator(T const* value)
|
||||
: m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
const T& operator*() const { return *m_value; }
|
||||
T const& operator*() const { return *m_value; }
|
||||
auto operator->() const { return m_value; }
|
||||
bool operator==(ConstIterator const& other) const { return other.m_value == m_value; }
|
||||
bool operator!=(ConstIterator const& other) const { return !(*this == other); }
|
||||
@ -138,7 +142,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const T* m_value { nullptr };
|
||||
T const* m_value { nullptr };
|
||||
};
|
||||
|
||||
ConstIterator begin() const;
|
||||
@ -147,8 +151,8 @@ public:
|
||||
private:
|
||||
static T* next(T* current);
|
||||
static T* prev(T* current);
|
||||
static const T* next(const T* current);
|
||||
static const T* prev(const T* current);
|
||||
static T const* next(T const* current);
|
||||
static T const* prev(T const* current);
|
||||
static T* node_to_value(SubstitutedIntrusiveListNode<T, Container>& node);
|
||||
IntrusiveListStorage<T, Container> m_storage;
|
||||
};
|
||||
@ -284,7 +288,7 @@ inline void IntrusiveList<T, Container, member>::remove(T& n)
|
||||
}
|
||||
|
||||
template<class T, typename Container, SubstitutedIntrusiveListNode<T, Container> T::*member>
|
||||
inline bool IntrusiveList<T, Container, member>::contains(const T& n) const
|
||||
inline bool IntrusiveList<T, Container, member>::contains(T const& n) const
|
||||
{
|
||||
auto& nnode = n.*member;
|
||||
return nnode.m_storage == &m_storage;
|
||||
@ -323,18 +327,18 @@ inline Container IntrusiveList<T, Container, member>::last() const
|
||||
}
|
||||
|
||||
template<class T, typename Container, SubstitutedIntrusiveListNode<T, Container> T::*member>
|
||||
inline const T* IntrusiveList<T, Container, member>::next(const T* current)
|
||||
inline T const* IntrusiveList<T, Container, member>::next(T const* current)
|
||||
{
|
||||
auto& nextnode = (current->*member).m_next;
|
||||
const T* nextstruct = nextnode ? node_to_value(*nextnode) : nullptr;
|
||||
T const* nextstruct = nextnode ? node_to_value(*nextnode) : nullptr;
|
||||
return nextstruct;
|
||||
}
|
||||
|
||||
template<class T, typename Container, SubstitutedIntrusiveListNode<T, Container> T::*member>
|
||||
inline const T* IntrusiveList<T, Container, member>::prev(const T* current)
|
||||
inline T const* IntrusiveList<T, Container, member>::prev(T const* current)
|
||||
{
|
||||
auto& prevnode = (current->*member).m_prev;
|
||||
const T* prevstruct = prevnode ? node_to_value(*prevnode) : nullptr;
|
||||
T const* prevstruct = prevnode ? node_to_value(*prevnode) : nullptr;
|
||||
return prevstruct;
|
||||
}
|
||||
|
||||
@ -429,6 +433,22 @@ public:
|
||||
[[nodiscard]] NonnullRefPtr<T> take_last() { return *IntrusiveList<T, RefPtr<T>, member>::take_last(); }
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
// Specialise IntrusiveList for NonnullLockRefPtr
|
||||
// By default, intrusive lists cannot contain null entries anyway, so switch to LockRefPtr
|
||||
// and just make the user-facing functions deref the pointers.
|
||||
|
||||
template<class T, SubstitutedIntrusiveListNode<T, NonnullLockRefPtr<T>> T::*member>
|
||||
class IntrusiveList<T, NonnullLockRefPtr<T>, member> : public IntrusiveList<T, LockRefPtr<T>, member> {
|
||||
public:
|
||||
[[nodiscard]] NonnullLockRefPtr<T> first() const { return *IntrusiveList<T, LockRefPtr<T>, member>::first(); }
|
||||
[[nodiscard]] NonnullLockRefPtr<T> last() const { return *IntrusiveList<T, LockRefPtr<T>, member>::last(); }
|
||||
|
||||
[[nodiscard]] NonnullLockRefPtr<T> take_first() { return *IntrusiveList<T, LockRefPtr<T>, member>::take_first(); }
|
||||
[[nodiscard]] NonnullLockRefPtr<T> take_last() { return *IntrusiveList<T, LockRefPtr<T>, member>::take_last(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
@ -8,14 +8,11 @@
|
||||
|
||||
#define NONNULLREFPTR_SCRUB_BYTE 0xe1
|
||||
|
||||
#ifdef KERNEL
|
||||
# include <Kernel/Library/ThreadSafeNonnullRefPtr.h>
|
||||
#else
|
||||
# include <AK/Assertions.h>
|
||||
# include <AK/Atomic.h>
|
||||
# include <AK/Format.h>
|
||||
# include <AK/Traits.h>
|
||||
# include <AK/Types.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
@ -98,9 +95,9 @@ public:
|
||||
{
|
||||
unref_if_not_null(m_ptr);
|
||||
m_ptr = nullptr;
|
||||
# ifdef SANITIZE_PTRS
|
||||
#ifdef SANITIZE_PTRS
|
||||
m_ptr = reinterpret_cast<T*>(explode_byte(NONNULLREFPTR_SCRUB_BYTE));
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
@ -163,7 +160,7 @@ public:
|
||||
{
|
||||
return as_nonnull_ptr();
|
||||
}
|
||||
ALWAYS_INLINE RETURNS_NONNULL const T* ptr() const
|
||||
ALWAYS_INLINE RETURNS_NONNULL T const* ptr() const
|
||||
{
|
||||
return as_nonnull_ptr();
|
||||
}
|
||||
@ -172,7 +169,7 @@ public:
|
||||
{
|
||||
return as_nonnull_ptr();
|
||||
}
|
||||
ALWAYS_INLINE RETURNS_NONNULL const T* operator->() const
|
||||
ALWAYS_INLINE RETURNS_NONNULL T const* operator->() const
|
||||
{
|
||||
return as_nonnull_ptr();
|
||||
}
|
||||
@ -181,7 +178,7 @@ public:
|
||||
{
|
||||
return *as_nonnull_ptr();
|
||||
}
|
||||
ALWAYS_INLINE const T& operator*() const
|
||||
ALWAYS_INLINE T const& operator*() const
|
||||
{
|
||||
return *as_nonnull_ptr();
|
||||
}
|
||||
@ -190,7 +187,7 @@ public:
|
||||
{
|
||||
return as_nonnull_ptr();
|
||||
}
|
||||
ALWAYS_INLINE RETURNS_NONNULL operator const T*() const
|
||||
ALWAYS_INLINE RETURNS_NONNULL operator T const*() const
|
||||
{
|
||||
return as_nonnull_ptr();
|
||||
}
|
||||
@ -199,7 +196,7 @@ public:
|
||||
{
|
||||
return *as_nonnull_ptr();
|
||||
}
|
||||
ALWAYS_INLINE operator const T&() const
|
||||
ALWAYS_INLINE operator T const&() const
|
||||
{
|
||||
return *as_nonnull_ptr();
|
||||
}
|
||||
@ -245,10 +242,10 @@ inline NonnullRefPtr<T> adopt_ref(T& object)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct Formatter<NonnullRefPtr<T>> : Formatter<const T*> {
|
||||
struct Formatter<NonnullRefPtr<T>> : Formatter<T const*> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, NonnullRefPtr<T> const& value)
|
||||
{
|
||||
return Formatter<const T*>::format(builder, value.ptr());
|
||||
return Formatter<T const*>::format(builder, value.ptr());
|
||||
}
|
||||
};
|
||||
|
||||
@ -275,7 +272,7 @@ inline NonnullRefPtr<T> make_ref_counted(Args&&... args)
|
||||
template<typename T>
|
||||
struct Traits<NonnullRefPtr<T>> : public GenericTraits<NonnullRefPtr<T>> {
|
||||
using PeekType = T*;
|
||||
using ConstPeekType = const T*;
|
||||
using ConstPeekType = T const*;
|
||||
static unsigned hash(NonnullRefPtr<T> const& p) { return ptr_hash(p.ptr()); }
|
||||
static bool equals(NonnullRefPtr<T> const& a, NonnullRefPtr<T> const& b) { return a.ptr() == b.ptr(); }
|
||||
};
|
||||
@ -283,5 +280,3 @@ struct Traits<NonnullRefPtr<T>> : public GenericTraits<NonnullRefPtr<T>> {
|
||||
using AK::adopt_ref;
|
||||
using AK::make_ref_counted;
|
||||
using AK::NonnullRefPtr;
|
||||
|
||||
#endif
|
||||
|
48
AK/RefPtr.h
48
AK/RefPtr.h
@ -8,18 +8,14 @@
|
||||
|
||||
#define REFPTR_SCRUB_BYTE 0xe0
|
||||
|
||||
#ifdef KERNEL
|
||||
# include <Kernel/Library/ThreadSafeRefPtr.h>
|
||||
#else
|
||||
|
||||
# include <AK/Assertions.h>
|
||||
# include <AK/Atomic.h>
|
||||
# include <AK/Error.h>
|
||||
# include <AK/Format.h>
|
||||
# include <AK/NonnullRefPtr.h>
|
||||
# include <AK/StdLibExtras.h>
|
||||
# include <AK/Traits.h>
|
||||
# include <AK/Types.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
@ -104,9 +100,9 @@ public:
|
||||
ALWAYS_INLINE ~RefPtr()
|
||||
{
|
||||
clear();
|
||||
# ifdef SANITIZE_PTRS
|
||||
#ifdef SANITIZE_PTRS
|
||||
m_ptr = reinterpret_cast<T*>(explode_byte(REFPTR_SCRUB_BYTE));
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
@ -236,14 +232,14 @@ public:
|
||||
}
|
||||
|
||||
ALWAYS_INLINE T* ptr() { return as_ptr(); }
|
||||
ALWAYS_INLINE const T* ptr() const { return as_ptr(); }
|
||||
ALWAYS_INLINE T const* ptr() const { return as_ptr(); }
|
||||
|
||||
ALWAYS_INLINE T* operator->()
|
||||
{
|
||||
return as_nonnull_ptr();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const T* operator->() const
|
||||
ALWAYS_INLINE T const* operator->() const
|
||||
{
|
||||
return as_nonnull_ptr();
|
||||
}
|
||||
@ -253,12 +249,12 @@ public:
|
||||
return *as_nonnull_ptr();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const T& operator*() const
|
||||
ALWAYS_INLINE T const& operator*() const
|
||||
{
|
||||
return *as_nonnull_ptr();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE operator const T*() const { return as_ptr(); }
|
||||
ALWAYS_INLINE operator T const*() const { return as_ptr(); }
|
||||
ALWAYS_INLINE operator T*() { return as_ptr(); }
|
||||
|
||||
ALWAYS_INLINE operator bool() { return !is_null(); }
|
||||
@ -282,8 +278,8 @@ public:
|
||||
template<typename U>
|
||||
bool operator!=(NonnullRefPtr<U>& other) { return as_ptr() != other.m_ptr; }
|
||||
|
||||
bool operator==(const T* other) const { return as_ptr() == other; }
|
||||
bool operator!=(const T* other) const { return as_ptr() != other; }
|
||||
bool operator==(T const* other) const { return as_ptr() == other; }
|
||||
bool operator!=(T const* other) const { return as_ptr() != other; }
|
||||
|
||||
bool operator==(T* other) { return as_ptr() == other; }
|
||||
bool operator!=(T* other) { return as_ptr() != other; }
|
||||
@ -306,17 +302,17 @@ private:
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Formatter<RefPtr<T>> : Formatter<const T*> {
|
||||
struct Formatter<RefPtr<T>> : Formatter<T const*> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, RefPtr<T> const& value)
|
||||
{
|
||||
return Formatter<const T*>::format(builder, value.ptr());
|
||||
return Formatter<T const*>::format(builder, value.ptr());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Traits<RefPtr<T>> : public GenericTraits<RefPtr<T>> {
|
||||
using PeekType = T*;
|
||||
using ConstPeekType = const T*;
|
||||
using ConstPeekType = T const*;
|
||||
static unsigned hash(RefPtr<T> const& p) { return ptr_hash(p.ptr()); }
|
||||
static bool equals(RefPtr<T> const& a, RefPtr<T> const& b) { return a.ptr() == b.ptr(); }
|
||||
};
|
||||
@ -324,13 +320,13 @@ struct Traits<RefPtr<T>> : public GenericTraits<RefPtr<T>> {
|
||||
template<typename T, typename U>
|
||||
inline NonnullRefPtr<T> static_ptr_cast(NonnullRefPtr<U> const& ptr)
|
||||
{
|
||||
return NonnullRefPtr<T>(static_cast<const T&>(*ptr));
|
||||
return NonnullRefPtr<T>(static_cast<T const&>(*ptr));
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
inline RefPtr<T> static_ptr_cast(RefPtr<U> const& ptr)
|
||||
{
|
||||
return RefPtr<T>(static_cast<const T*>(ptr.ptr()));
|
||||
return RefPtr<T>(static_cast<T const*>(ptr.ptr()));
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
@ -375,5 +371,3 @@ using AK::adopt_ref_if_nonnull;
|
||||
using AK::RefPtr;
|
||||
using AK::static_ptr_cast;
|
||||
using AK::try_make_ref_counted;
|
||||
|
||||
#endif
|
||||
|
@ -6,11 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef KERNEL
|
||||
# include <Kernel/Library/ThreadSafeWeakPtr.h>
|
||||
#else
|
||||
|
||||
# include <AK/Weakable.h>
|
||||
#include <AK/Weakable.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
@ -185,4 +181,3 @@ WeakPtr<T> make_weak_ptr_if_nonnull(T const* ptr)
|
||||
}
|
||||
|
||||
using AK::WeakPtr;
|
||||
#endif
|
||||
|
@ -6,15 +6,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef KERNEL
|
||||
# include <Kernel/Library/ThreadSafeWeakable.h>
|
||||
#else
|
||||
# include <AK/Assertions.h>
|
||||
# include <AK/Atomic.h>
|
||||
# include <AK/RefCounted.h>
|
||||
# include <AK/RefPtr.h>
|
||||
# include <AK/StdLibExtras.h>
|
||||
# include <sched.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <sched.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
@ -125,5 +122,3 @@ private:
|
||||
}
|
||||
|
||||
using AK::Weakable;
|
||||
|
||||
#endif
|
||||
|
@ -45,10 +45,10 @@ SpinlockProtected<Inode::AllInstancesList>& Inode::all_instances()
|
||||
return s_all_instances;
|
||||
}
|
||||
|
||||
RefPtr<Memory::SharedInodeVMObject> Inode::shared_vmobject() const
|
||||
LockRefPtr<Memory::SharedInodeVMObject> Inode::shared_vmobject() const
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
return RefPtr<Memory::SharedInodeVMObject>(nullptr);
|
||||
return LockRefPtr<Memory::SharedInodeVMObject>(nullptr);
|
||||
}
|
||||
|
||||
void Inode::will_be_destroyed()
|
||||
|
@ -42,12 +42,12 @@ u8 InterruptManagement::acquire_mapped_interrupt_number(u8 interrupt_number)
|
||||
return interrupt_number;
|
||||
}
|
||||
|
||||
Vector<RefPtr<IRQController>> const& InterruptManagement::controllers()
|
||||
Vector<LockRefPtr<IRQController>> const& InterruptManagement::controllers()
|
||||
{
|
||||
return m_interrupt_controllers;
|
||||
}
|
||||
|
||||
RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(u8)
|
||||
LockRefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(u8)
|
||||
{
|
||||
// TODO: Support more interrupt controllers
|
||||
VERIFY(m_interrupt_controllers.size() == 1);
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/Arch/aarch64/IRQController.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
@ -20,14 +20,14 @@ public:
|
||||
|
||||
static u8 acquire_mapped_interrupt_number(u8 original_irq);
|
||||
|
||||
Vector<RefPtr<IRQController>> const& controllers();
|
||||
RefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector);
|
||||
Vector<LockRefPtr<IRQController>> const& controllers();
|
||||
LockRefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector);
|
||||
|
||||
private:
|
||||
InterruptManagement() = default;
|
||||
void find_controllers();
|
||||
|
||||
Vector<RefPtr<IRQController>> m_interrupt_controllers;
|
||||
Vector<LockRefPtr<IRQController>> m_interrupt_controllers;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ void PageDirectory::deregister_page_directory(PageDirectory*)
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
RefPtr<PageDirectory> PageDirectory::find_current()
|
||||
LockRefPtr<PageDirectory> PageDirectory::find_current()
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
return nullptr;
|
||||
|
@ -107,7 +107,7 @@ extern "C" [[noreturn]] void init()
|
||||
|
||||
auto& framebuffer = RPi::Framebuffer::the();
|
||||
if (framebuffer.initialized()) {
|
||||
g_boot_console = &try_make_ref_counted<Graphics::BootFramebufferConsole>(framebuffer.gpu_buffer(), framebuffer.width(), framebuffer.width(), framebuffer.pitch()).value().leak_ref();
|
||||
g_boot_console = &try_make_lock_ref_counted<Graphics::BootFramebufferConsole>(framebuffer.gpu_buffer(), framebuffer.width(), framebuffer.width(), framebuffer.pitch()).value().leak_ref();
|
||||
draw_logo();
|
||||
}
|
||||
dmesgln("Starting SerenityOS...");
|
||||
|
@ -9,12 +9,12 @@
|
||||
#include <AK/Function.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Arch/x86/IRQController.h>
|
||||
#include <Kernel/Firmware/ACPI/Definitions.h>
|
||||
#include <Kernel/Interrupts/GenericInterruptHandler.h>
|
||||
#include <Kernel/Interrupts/IOAPIC.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
@ -52,8 +52,8 @@ public:
|
||||
virtual void switch_to_ioapic_mode();
|
||||
|
||||
bool smp_enabled() const { return m_smp_enabled; }
|
||||
RefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector);
|
||||
RefPtr<IRQController> get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector);
|
||||
LockRefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector);
|
||||
LockRefPtr<IRQController> get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector);
|
||||
|
||||
Vector<ISAInterruptOverrideMetadata> const& isa_overrides() const { return m_isa_interrupt_overrides; }
|
||||
|
||||
@ -71,7 +71,7 @@ private:
|
||||
PhysicalAddress search_for_madt();
|
||||
void locate_apic_data();
|
||||
bool m_smp_enabled { false };
|
||||
Vector<RefPtr<IRQController>> m_interrupt_controllers;
|
||||
Vector<LockRefPtr<IRQController>> m_interrupt_controllers;
|
||||
Vector<ISAInterruptOverrideMetadata> m_isa_interrupt_overrides;
|
||||
Vector<PCIInterruptOverrideMetadata> m_pci_interrupt_overrides;
|
||||
PhysicalAddress m_madt;
|
||||
|
@ -98,7 +98,7 @@ u8 InterruptManagement::get_irq_vector(u8 mapped_interrupt_vector)
|
||||
return mapped_interrupt_vector;
|
||||
}
|
||||
|
||||
RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector)
|
||||
LockRefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector)
|
||||
{
|
||||
for (auto& irq_controller : m_interrupt_controllers) {
|
||||
if (irq_controller->gsi_base() <= interrupt_vector && irq_controller->type() == controller_type)
|
||||
@ -107,7 +107,7 @@ RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(IRQCon
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(u8 interrupt_vector)
|
||||
LockRefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(u8 interrupt_vector)
|
||||
{
|
||||
if (m_interrupt_controllers.size() == 1 && m_interrupt_controllers[0]->type() == IRQControllerType::i8259) {
|
||||
return m_interrupt_controllers[0];
|
||||
@ -143,7 +143,7 @@ UNMAP_AFTER_INIT void InterruptManagement::switch_to_pic_mode()
|
||||
dmesgln("Interrupts: Switch to Legacy PIC mode");
|
||||
InterruptDisabler disabler;
|
||||
m_smp_enabled = false;
|
||||
m_interrupt_controllers[0] = adopt_ref(*new PIC());
|
||||
m_interrupt_controllers[0] = adopt_lock_ref(*new PIC());
|
||||
SpuriousInterruptHandler::initialize(7);
|
||||
SpuriousInterruptHandler::initialize(15);
|
||||
for (auto& irq_controller : m_interrupt_controllers) {
|
||||
@ -204,7 +204,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
|
||||
|
||||
int irq_controller_count = 0;
|
||||
if (madt->flags & PCAT_COMPAT_FLAG) {
|
||||
m_interrupt_controllers[0] = adopt_ref(*new PIC());
|
||||
m_interrupt_controllers[0] = adopt_lock_ref(*new PIC());
|
||||
irq_controller_count++;
|
||||
}
|
||||
size_t entry_index = 0;
|
||||
@ -216,7 +216,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
|
||||
auto* ioapic_entry = (const ACPI::Structures::MADTEntries::IOAPIC*)madt_entry;
|
||||
dbgln("IOAPIC found @ MADT entry {}, MMIO Registers @ {}", entry_index, PhysicalAddress(ioapic_entry->ioapic_address));
|
||||
m_interrupt_controllers.resize(1 + irq_controller_count);
|
||||
m_interrupt_controllers[irq_controller_count] = adopt_ref(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base));
|
||||
m_interrupt_controllers[irq_controller_count] = adopt_lock_ref(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base));
|
||||
irq_controller_count++;
|
||||
}
|
||||
if (madt_entry->type == (u8)ACPI::Structures::MADTEntryType::InterruptSourceOverride) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
#include <Kernel/Arch/Interrupts.h>
|
||||
@ -349,21 +350,21 @@ void page_fault_handler(TrapFrame* trap)
|
||||
constexpr FlatPtr nonnullrefptr_scrub_pattern = explode_byte(NONNULLREFPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr ownptr_scrub_pattern = explode_byte(OWNPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr nonnullownptr_scrub_pattern = explode_byte(NONNULLOWNPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr threadsaferefptr_scrub_pattern = explode_byte(THREADSAFEREFPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr threadsafenonnullrefptr_scrub_pattern = explode_byte(THREADSAFENONNULLREFPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr lockrefptr_scrub_pattern = explode_byte(LOCKREFPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr nonnulllockrefptr_scrub_pattern = explode_byte(NONNULLLOCKREFPTR_SCRUB_BYTE);
|
||||
|
||||
if ((fault_address & 0xffff0000) == (refptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed RefPtr", VirtualAddress(fault_address));
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed LockRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (nonnullrefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed NonnullRefPtr", VirtualAddress(fault_address));
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed NonnullLockRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (ownptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed OwnPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (nonnullownptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed NonnullOwnPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (threadsaferefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed ThreadSafeRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (threadsafenonnullrefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed ThreadSafeNonnullRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (lockrefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed LockRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (nonnulllockrefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed NonnullLockRefPtr", VirtualAddress(fault_address));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ void PageDirectory::deregister_page_directory(PageDirectory* directory)
|
||||
cr3_map().remove(directory->cr3());
|
||||
}
|
||||
|
||||
RefPtr<PageDirectory> PageDirectory::find_current()
|
||||
LockRefPtr<PageDirectory> PageDirectory::find_current()
|
||||
{
|
||||
SpinlockLocker lock(s_mm_lock);
|
||||
return cr3_map().find(read_cr3());
|
||||
|
@ -62,10 +62,10 @@ static constexpr u16 UHCI_PORTSC_NON_WRITE_CLEAR_BIT_MASK = 0x1FF5; // This is u
|
||||
static constexpr u8 UHCI_NUMBER_OF_ISOCHRONOUS_TDS = 128;
|
||||
static constexpr u16 UHCI_NUMBER_OF_FRAMES = 1024;
|
||||
|
||||
ErrorOr<NonnullRefPtr<UHCIController>> UHCIController::try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier)
|
||||
ErrorOr<NonnullLockRefPtr<UHCIController>> UHCIController::try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier)
|
||||
{
|
||||
// NOTE: This assumes that address is pointing to a valid UHCI controller.
|
||||
auto controller = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) UHCIController(pci_device_identifier)));
|
||||
auto controller = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) UHCIController(pci_device_identifier)));
|
||||
TRY(controller->initialize());
|
||||
return controller;
|
||||
}
|
||||
@ -510,7 +510,7 @@ size_t UHCIController::poll_transfer_queue(QueueHead& transfer_queue)
|
||||
|
||||
ErrorOr<void> UHCIController::spawn_port_process()
|
||||
{
|
||||
RefPtr<Thread> usb_hotplug_thread;
|
||||
LockRefPtr<Thread> usb_hotplug_thread;
|
||||
(void)Process::create_kernel_process(usb_hotplug_thread, TRY(KString::try_create("UHCI Hot Plug Task"sv)), [&] {
|
||||
for (;;) {
|
||||
if (m_root_hub)
|
||||
|
@ -33,7 +33,7 @@ class UHCIController final
|
||||
|
||||
public:
|
||||
static constexpr u8 NUMBER_OF_ROOT_PORTS = 2;
|
||||
static ErrorOr<NonnullRefPtr<UHCIController>> try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier);
|
||||
static ErrorOr<NonnullLockRefPtr<UHCIController>> try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier);
|
||||
virtual ~UHCIController() override;
|
||||
|
||||
virtual StringView purpose() const override { return "UHCI"sv; }
|
||||
|
@ -83,12 +83,12 @@ static USBHubDescriptor uhci_root_hub_hub_descriptor = {
|
||||
0x0, // Self-powered
|
||||
};
|
||||
|
||||
ErrorOr<NonnullOwnPtr<UHCIRootHub>> UHCIRootHub::try_create(NonnullRefPtr<UHCIController> uhci_controller)
|
||||
ErrorOr<NonnullOwnPtr<UHCIRootHub>> UHCIRootHub::try_create(NonnullLockRefPtr<UHCIController> uhci_controller)
|
||||
{
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) UHCIRootHub(move(uhci_controller)));
|
||||
}
|
||||
|
||||
UHCIRootHub::UHCIRootHub(NonnullRefPtr<UHCIController> uhci_controller)
|
||||
UHCIRootHub::UHCIRootHub(NonnullLockRefPtr<UHCIController> uhci_controller)
|
||||
: m_uhci_controller(move(uhci_controller))
|
||||
{
|
||||
}
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <Kernel/Bus/USB/USBHub.h>
|
||||
#include <Kernel/Bus/USB/USBTransfer.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
|
||||
namespace Kernel::USB {
|
||||
|
||||
@ -18,9 +18,9 @@ class UHCIController;
|
||||
|
||||
class UHCIRootHub {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<UHCIRootHub>> try_create(NonnullRefPtr<UHCIController>);
|
||||
static ErrorOr<NonnullOwnPtr<UHCIRootHub>> try_create(NonnullLockRefPtr<UHCIController>);
|
||||
|
||||
UHCIRootHub(NonnullRefPtr<UHCIController>);
|
||||
UHCIRootHub(NonnullLockRefPtr<UHCIController>);
|
||||
~UHCIRootHub() = default;
|
||||
|
||||
ErrorOr<void> setup(Badge<UHCIController>);
|
||||
@ -32,8 +32,8 @@ public:
|
||||
void check_for_port_updates() { m_hub->check_for_port_updates(); }
|
||||
|
||||
private:
|
||||
NonnullRefPtr<UHCIController> m_uhci_controller;
|
||||
RefPtr<Hub> m_hub;
|
||||
NonnullLockRefPtr<UHCIController> m_uhci_controller;
|
||||
LockRefPtr<Hub> m_hub;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
private:
|
||||
u8 m_next_device_index { 1 };
|
||||
|
||||
IntrusiveListNode<USBController, NonnullRefPtr<USBController>> m_controller_list_node;
|
||||
IntrusiveListNode<USBController, NonnullLockRefPtr<USBController>> m_controller_list_node;
|
||||
|
||||
public:
|
||||
using List = IntrusiveList<&USBController::m_controller_list_node>;
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
namespace Kernel::USB {
|
||||
|
||||
ErrorOr<NonnullRefPtr<Device>> Device::try_create(USBController const& controller, u8 port, DeviceSpeed speed)
|
||||
ErrorOr<NonnullLockRefPtr<Device>> Device::try_create(USBController const& controller, u8 port, DeviceSpeed speed)
|
||||
{
|
||||
auto pipe = TRY(Pipe::try_create_pipe(controller, Pipe::Type::Control, Pipe::Direction::Bidirectional, 0, 8, 0));
|
||||
auto device = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Device(controller, port, speed, move(pipe))));
|
||||
auto device = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Device(controller, port, speed, move(pipe))));
|
||||
auto sysfs_node = TRY(SysFSUSBDeviceInformation::create(*device));
|
||||
device->m_sysfs_device_info_node = move(sysfs_node);
|
||||
TRY(device->enumerate_device());
|
||||
@ -35,7 +35,7 @@ Device::Device(USBController const& controller, u8 port, DeviceSpeed speed, Nonn
|
||||
{
|
||||
}
|
||||
|
||||
Device::Device(NonnullRefPtr<USBController> controller, u8 address, u8 port, DeviceSpeed speed, NonnullOwnPtr<Pipe> default_pipe)
|
||||
Device::Device(NonnullLockRefPtr<USBController> controller, u8 address, u8 port, DeviceSpeed speed, NonnullOwnPtr<Pipe> default_pipe)
|
||||
: m_device_port(port)
|
||||
, m_device_speed(speed)
|
||||
, m_address(address)
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
LowSpeed
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<Device>> try_create(USBController const&, u8, DeviceSpeed);
|
||||
static ErrorOr<NonnullLockRefPtr<Device>> try_create(USBController const&, u8, DeviceSpeed);
|
||||
|
||||
Device(USBController const&, u8, DeviceSpeed, NonnullOwnPtr<Pipe> default_pipe);
|
||||
Device(Device const& device, NonnullOwnPtr<Pipe> default_pipe);
|
||||
@ -59,7 +59,7 @@ public:
|
||||
SysFSUSBDeviceInformation& sysfs_device_info_node(Badge<USB::Hub>) { return *m_sysfs_device_info_node; }
|
||||
|
||||
protected:
|
||||
Device(NonnullRefPtr<USBController> controller, u8 address, u8 port, DeviceSpeed speed, NonnullOwnPtr<Pipe> default_pipe);
|
||||
Device(NonnullLockRefPtr<USBController> controller, u8 address, u8 port, DeviceSpeed speed, NonnullOwnPtr<Pipe> default_pipe);
|
||||
|
||||
u8 m_device_port { 0 }; // What port is this device attached to. NOTE: This is 1-based.
|
||||
DeviceSpeed m_device_speed; // What speed is this device running at
|
||||
@ -71,14 +71,14 @@ protected:
|
||||
USBDeviceDescriptor m_device_descriptor {}; // Device Descriptor obtained from USB Device
|
||||
Vector<USBConfiguration> m_configurations; // Configurations for this device
|
||||
|
||||
NonnullRefPtr<USBController> m_controller;
|
||||
NonnullLockRefPtr<USBController> m_controller;
|
||||
NonnullOwnPtr<Pipe> m_default_pipe; // Default communication pipe (endpoint0) used during enumeration
|
||||
|
||||
private:
|
||||
IntrusiveListNode<Device, NonnullRefPtr<Device>> m_hub_child_node;
|
||||
IntrusiveListNode<Device, NonnullLockRefPtr<Device>> m_hub_child_node;
|
||||
|
||||
protected:
|
||||
RefPtr<SysFSUSBDeviceInformation> m_sysfs_device_info_node;
|
||||
LockRefPtr<SysFSUSBDeviceInformation> m_sysfs_device_info_node;
|
||||
|
||||
public:
|
||||
using List = IntrusiveList<&Device::m_hub_child_node>;
|
||||
|
@ -14,23 +14,23 @@
|
||||
|
||||
namespace Kernel::USB {
|
||||
|
||||
ErrorOr<NonnullRefPtr<Hub>> Hub::try_create_root_hub(NonnullRefPtr<USBController> controller, DeviceSpeed device_speed)
|
||||
ErrorOr<NonnullLockRefPtr<Hub>> Hub::try_create_root_hub(NonnullLockRefPtr<USBController> controller, DeviceSpeed device_speed)
|
||||
{
|
||||
// NOTE: Enumeration does not happen here, as the controller must know what the device address is at all times during enumeration to intercept requests.
|
||||
auto pipe = TRY(Pipe::try_create_pipe(controller, Pipe::Type::Control, Pipe::Direction::Bidirectional, 0, 8, 0));
|
||||
auto hub = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Hub(controller, device_speed, move(pipe))));
|
||||
auto hub = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Hub(controller, device_speed, move(pipe))));
|
||||
return hub;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Hub>> Hub::try_create_from_device(Device const& device)
|
||||
ErrorOr<NonnullLockRefPtr<Hub>> Hub::try_create_from_device(Device const& device)
|
||||
{
|
||||
auto pipe = TRY(Pipe::try_create_pipe(device.controller(), Pipe::Type::Control, Pipe::Direction::Bidirectional, 0, device.device_descriptor().max_packet_size, device.address()));
|
||||
auto hub = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Hub(device, move(pipe))));
|
||||
auto hub = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Hub(device, move(pipe))));
|
||||
TRY(hub->enumerate_and_power_on_hub());
|
||||
return hub;
|
||||
}
|
||||
|
||||
Hub::Hub(NonnullRefPtr<USBController> controller, DeviceSpeed device_speed, NonnullOwnPtr<Pipe> default_pipe)
|
||||
Hub::Hub(NonnullLockRefPtr<USBController> controller, DeviceSpeed device_speed, NonnullOwnPtr<Pipe> default_pipe)
|
||||
: Device(move(controller), 1 /* Port 1 */, device_speed, move(default_pipe))
|
||||
{
|
||||
}
|
||||
@ -266,7 +266,7 @@ void Hub::check_for_port_updates()
|
||||
} else {
|
||||
dbgln("USB Hub: Device detached on port {}!", port_number);
|
||||
|
||||
RefPtr<Device> device_to_remove = nullptr;
|
||||
LockRefPtr<Device> device_to_remove = nullptr;
|
||||
for (auto& child : m_children) {
|
||||
if (port_number == child.port()) {
|
||||
device_to_remove = &child;
|
||||
|
@ -79,8 +79,8 @@ static constexpr u16 PORT_STATUS_RESET_CHANGED = (1 << 4);
|
||||
|
||||
class Hub : public Device {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Hub>> try_create_root_hub(NonnullRefPtr<USBController>, DeviceSpeed);
|
||||
static ErrorOr<NonnullRefPtr<Hub>> try_create_from_device(Device const&);
|
||||
static ErrorOr<NonnullLockRefPtr<Hub>> try_create_root_hub(NonnullLockRefPtr<USBController>, DeviceSpeed);
|
||||
static ErrorOr<NonnullLockRefPtr<Hub>> try_create_from_device(Device const&);
|
||||
|
||||
virtual ~Hub() override = default;
|
||||
|
||||
@ -96,7 +96,7 @@ public:
|
||||
|
||||
private:
|
||||
// Root Hub constructor
|
||||
Hub(NonnullRefPtr<USBController>, DeviceSpeed, NonnullOwnPtr<Pipe> default_pipe);
|
||||
Hub(NonnullLockRefPtr<USBController>, DeviceSpeed, NonnullOwnPtr<Pipe> default_pipe);
|
||||
|
||||
Hub(Device const&, NonnullOwnPtr<Pipe> default_pipe);
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <Kernel/Bus/USB/USBController.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtrVector.h>
|
||||
|
||||
namespace Kernel::USB {
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
private:
|
||||
friend class Device;
|
||||
|
||||
NonnullRefPtr<USBController> m_controller;
|
||||
NonnullLockRefPtr<USBController> m_controller;
|
||||
|
||||
Type m_type;
|
||||
Direction m_direction;
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
namespace Kernel::USB {
|
||||
|
||||
ErrorOr<NonnullRefPtr<Transfer>> Transfer::try_create(Pipe& pipe, u16 length, Memory::Region& dma_buffer)
|
||||
ErrorOr<NonnullLockRefPtr<Transfer>> Transfer::try_create(Pipe& pipe, u16 length, Memory::Region& dma_buffer)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) Transfer(pipe, length, dma_buffer));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) Transfer(pipe, length, dma_buffer));
|
||||
}
|
||||
|
||||
Transfer::Transfer(Pipe& pipe, u16 len, Memory::Region& dma_buffer)
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <Kernel/Bus/USB/PacketTypes.h>
|
||||
#include <Kernel/Bus/USB/USBPipe.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Memory/AnonymousVMObject.h>
|
||||
#include <Kernel/Memory/PhysicalPage.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
@ -20,7 +20,7 @@ namespace Kernel::USB {
|
||||
|
||||
class Transfer final : public AtomicRefCounted<Transfer> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Transfer>> try_create(Pipe&, u16 length, Memory::Region& dma_buffer);
|
||||
static ErrorOr<NonnullLockRefPtr<Transfer>> try_create(Pipe&, u16 length, Memory::Region& dma_buffer);
|
||||
|
||||
Transfer() = delete;
|
||||
~Transfer();
|
||||
|
@ -14,9 +14,9 @@ namespace Kernel::VirtIO {
|
||||
|
||||
unsigned Console::next_device_id = 0;
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<Console> Console::must_create(PCI::DeviceIdentifier const& pci_device_identifier)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<Console> Console::must_create(PCI::DeviceIdentifier const& pci_device_identifier)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new Console(pci_device_identifier)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new Console(pci_device_identifier)).release_nonnull();
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void Console::initialize()
|
||||
|
@ -18,7 +18,7 @@ class Console
|
||||
friend VirtIO::ConsolePort;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<Console> must_create(PCI::DeviceIdentifier const&);
|
||||
static NonnullLockRefPtr<Console> must_create(PCI::DeviceIdentifier const&);
|
||||
virtual ~Console() override = default;
|
||||
|
||||
virtual StringView purpose() const override { return class_name(); }
|
||||
@ -64,7 +64,7 @@ private:
|
||||
virtual bool handle_device_config_change() override;
|
||||
virtual void handle_queue_update(u16 queue_index) override;
|
||||
|
||||
Vector<RefPtr<ConsolePort>> m_ports;
|
||||
Vector<LockRefPtr<ConsolePort>> m_ports;
|
||||
void setup_multiport();
|
||||
void process_control_message(ControlMessage message);
|
||||
void write_control_message(ControlMessage message);
|
||||
|
@ -12,11 +12,11 @@ namespace Kernel::VirtIO {
|
||||
|
||||
unsigned ConsolePort::next_device_id = 0;
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConsolePort>> ConsolePort::try_create(unsigned port, Console& console)
|
||||
ErrorOr<NonnullLockRefPtr<ConsolePort>> ConsolePort::try_create(unsigned port, Console& console)
|
||||
{
|
||||
auto receive_buffer = TRY(Memory::RingBuffer::try_create("VirtIO::ConsolePort Receive"sv, RINGBUFFER_SIZE));
|
||||
auto transmit_buffer = TRY(Memory::RingBuffer::try_create("VirtIO::ConsolePort Transmit"sv, RINGBUFFER_SIZE));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ConsolePort(port, console, move(receive_buffer), move(transmit_buffer)));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ConsolePort(port, console, move(receive_buffer), move(transmit_buffer)));
|
||||
}
|
||||
|
||||
ConsolePort::ConsolePort(unsigned port, VirtIO::Console& console, NonnullOwnPtr<Memory::RingBuffer> receive_buffer, NonnullOwnPtr<Memory::RingBuffer> transmit_buffer)
|
||||
@ -161,7 +161,7 @@ ErrorOr<size_t> ConsolePort::write(OpenFileDescription& desc, u64, UserOrKernelB
|
||||
return total_bytes_copied;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> ConsolePort::open(int options)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> ConsolePort::open(int options)
|
||||
{
|
||||
if (!m_open)
|
||||
m_console.send_open_control_message(m_port, true);
|
||||
|
@ -24,7 +24,7 @@ class Console;
|
||||
class ConsolePort
|
||||
: public CharacterDevice {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<ConsolePort>> try_create(unsigned port, VirtIO::Console&);
|
||||
static ErrorOr<NonnullLockRefPtr<ConsolePort>> try_create(unsigned port, VirtIO::Console&);
|
||||
|
||||
void handle_queue_update(Badge<VirtIO::Console>, u16 queue_index);
|
||||
|
||||
@ -44,7 +44,7 @@ private:
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, 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;
|
||||
virtual ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(int options) override;
|
||||
|
||||
static unsigned next_device_id;
|
||||
u16 m_receive_queue {};
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
namespace Kernel::VirtIO {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<RNG> RNG::must_create(PCI::DeviceIdentifier const& device_identifier)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<RNG> RNG::must_create(PCI::DeviceIdentifier const& device_identifier)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new RNG(device_identifier)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new RNG(device_identifier)).release_nonnull();
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void RNG::initialize()
|
||||
|
@ -19,7 +19,7 @@ class RNG final
|
||||
: public AtomicRefCounted<RNG>
|
||||
, public VirtIO::Device {
|
||||
public:
|
||||
static NonnullRefPtr<RNG> must_create(PCI::DeviceIdentifier const&);
|
||||
static NonnullLockRefPtr<RNG> must_create(PCI::DeviceIdentifier const&);
|
||||
virtual StringView purpose() const override { return class_name(); }
|
||||
virtual ~RNG() override = default;
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace Kernel {
|
||||
return region.name().starts_with("LibJS:"sv) || region.name().starts_with("malloc:"sv);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Coredump>> Coredump::try_create(NonnullRefPtr<Process> process, StringView output_path)
|
||||
ErrorOr<NonnullOwnPtr<Coredump>> Coredump::try_create(NonnullLockRefPtr<Process> process, StringView output_path)
|
||||
{
|
||||
if (!process->is_dumpable()) {
|
||||
dbgln("Refusing to generate coredump for non-dumpable process {}", process->pid().value());
|
||||
@ -41,7 +41,7 @@ ErrorOr<NonnullOwnPtr<Coredump>> Coredump::try_create(NonnullRefPtr<Process> pro
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) Coredump(move(process), move(description)));
|
||||
}
|
||||
|
||||
Coredump::Coredump(NonnullRefPtr<Process> process, NonnullRefPtr<OpenFileDescription> description)
|
||||
Coredump::Coredump(NonnullLockRefPtr<Process> process, NonnullLockRefPtr<OpenFileDescription> description)
|
||||
: m_process(move(process))
|
||||
, m_description(move(description))
|
||||
{
|
||||
@ -59,7 +59,7 @@ Coredump::Coredump(NonnullRefPtr<Process> process, NonnullRefPtr<OpenFileDescrip
|
||||
++m_num_program_headers; // +1 for NOTE segment
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> Coredump::try_create_target_file(Process const& process, StringView output_path)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> Coredump::try_create_target_file(Process const& process, StringView output_path)
|
||||
{
|
||||
auto output_directory = KLexicalPath::dirname(output_path);
|
||||
auto dump_directory = TRY(VirtualFileSystem::the().open_directory(output_directory, VirtualFileSystem::the().root_custody()));
|
||||
|
@ -7,22 +7,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class Coredump {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<Coredump>> try_create(NonnullRefPtr<Process>, StringView output_path);
|
||||
static ErrorOr<NonnullOwnPtr<Coredump>> try_create(NonnullLockRefPtr<Process>, StringView output_path);
|
||||
|
||||
~Coredump() = default;
|
||||
ErrorOr<void> write();
|
||||
|
||||
private:
|
||||
Coredump(NonnullRefPtr<Process>, NonnullRefPtr<OpenFileDescription>);
|
||||
static ErrorOr<NonnullRefPtr<OpenFileDescription>> try_create_target_file(Process const&, StringView output_path);
|
||||
Coredump(NonnullLockRefPtr<Process>, NonnullLockRefPtr<OpenFileDescription>);
|
||||
static ErrorOr<NonnullLockRefPtr<OpenFileDescription>> try_create_target_file(Process const&, StringView output_path);
|
||||
|
||||
ErrorOr<void> write_elf_header();
|
||||
ErrorOr<void> write_program_headers(size_t notes_size);
|
||||
@ -35,8 +35,8 @@ private:
|
||||
ErrorOr<void> create_notes_regions_data(auto&) const;
|
||||
ErrorOr<void> create_notes_metadata_data(auto&) const;
|
||||
|
||||
NonnullRefPtr<Process> m_process;
|
||||
NonnullRefPtr<OpenFileDescription> m_description;
|
||||
NonnullLockRefPtr<Process> m_process;
|
||||
NonnullLockRefPtr<OpenFileDescription> m_description;
|
||||
size_t m_num_program_headers { 0 };
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@ auto AsyncDeviceRequest::get_request_result() const -> RequestResult
|
||||
return m_result;
|
||||
}
|
||||
|
||||
void AsyncDeviceRequest::add_sub_request(NonnullRefPtr<AsyncDeviceRequest> sub_request)
|
||||
void AsyncDeviceRequest::add_sub_request(NonnullLockRefPtr<AsyncDeviceRequest> sub_request)
|
||||
{
|
||||
// Sub-requests cannot be for the same device
|
||||
VERIFY(&m_device != &sub_request->m_device);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Thread.h>
|
||||
@ -58,7 +58,7 @@ public:
|
||||
virtual StringView name() const = 0;
|
||||
virtual void start() = 0;
|
||||
|
||||
void add_sub_request(NonnullRefPtr<AsyncDeviceRequest>);
|
||||
void add_sub_request(NonnullLockRefPtr<AsyncDeviceRequest>);
|
||||
|
||||
[[nodiscard]] RequestWaitResult wait(Time* = nullptr);
|
||||
|
||||
@ -142,14 +142,14 @@ private:
|
||||
|
||||
AsyncDeviceRequest* m_parent_request { nullptr };
|
||||
RequestResult m_result { Pending };
|
||||
IntrusiveListNode<AsyncDeviceRequest, RefPtr<AsyncDeviceRequest>> m_list_node;
|
||||
IntrusiveListNode<AsyncDeviceRequest, LockRefPtr<AsyncDeviceRequest>> m_list_node;
|
||||
|
||||
using AsyncDeviceSubRequestList = IntrusiveList<&AsyncDeviceRequest::m_list_node>;
|
||||
|
||||
AsyncDeviceSubRequestList m_sub_requests_pending;
|
||||
AsyncDeviceSubRequestList m_sub_requests_complete;
|
||||
WaitQueue m_queue;
|
||||
NonnullRefPtr<Process> m_process;
|
||||
NonnullLockRefPtr<Process> m_process;
|
||||
void* m_private { nullptr };
|
||||
mutable Spinlock m_lock { LockRank::None };
|
||||
};
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Devices/Device.h>
|
||||
#include <Kernel/Library/LockWeakable.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
static Kernel::Spinlock g_console_lock { LockRank::None };
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<ConsoleDevice> ConsoleDevice::must_create()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<ConsoleDevice> ConsoleDevice::must_create()
|
||||
{
|
||||
auto device_or_error = DeviceManagement::try_create_device<ConsoleDevice>();
|
||||
VERIFY(!device_or_error.is_error());
|
||||
|
@ -16,7 +16,7 @@ class ConsoleDevice final : public CharacterDevice {
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<ConsoleDevice> must_create();
|
||||
static NonnullLockRefPtr<ConsoleDevice> must_create();
|
||||
|
||||
virtual ~ConsoleDevice() override;
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <Kernel/Devices/AsyncDeviceRequest.h>
|
||||
#include <Kernel/FileSystem/DeviceFileTypes.h>
|
||||
#include <Kernel/FileSystem/File.h>
|
||||
#include <Kernel/FileSystem/SysFS/Registry.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/DeviceComponent.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/SymbolicLinkDeviceComponent.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
|
||||
namespace Kernel {
|
||||
@ -53,9 +53,9 @@ public:
|
||||
void process_next_queued_request(Badge<AsyncDeviceRequest>, AsyncDeviceRequest const&);
|
||||
|
||||
template<typename AsyncRequestType, typename... Args>
|
||||
ErrorOr<NonnullRefPtr<AsyncRequestType>> try_make_request(Args&&... args)
|
||||
ErrorOr<NonnullLockRefPtr<AsyncRequestType>> try_make_request(Args&&... args)
|
||||
{
|
||||
auto request = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) AsyncRequestType(*this, forward<Args>(args)...)));
|
||||
auto request = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) AsyncRequestType(*this, forward<Args>(args)...)));
|
||||
SpinlockLocker lock(m_requests_lock);
|
||||
bool was_empty = m_requests.is_empty();
|
||||
m_requests.append(request);
|
||||
@ -89,15 +89,15 @@ private:
|
||||
State m_state { State::Normal };
|
||||
|
||||
Spinlock m_requests_lock { LockRank::None };
|
||||
DoublyLinkedList<RefPtr<AsyncDeviceRequest>> m_requests;
|
||||
DoublyLinkedList<LockRefPtr<AsyncDeviceRequest>> m_requests;
|
||||
|
||||
protected:
|
||||
// FIXME: This pointer will be eventually removed after all nodes in /sys/dev/block/ and
|
||||
// /sys/dev/char/ are symlinks.
|
||||
RefPtr<SysFSDeviceComponent> m_sysfs_component;
|
||||
LockRefPtr<SysFSDeviceComponent> m_sysfs_component;
|
||||
|
||||
RefPtr<SysFSSymbolicLinkDeviceComponent> m_symlink_sysfs_component;
|
||||
RefPtr<SysFSDirectory> m_sysfs_device_directory;
|
||||
LockRefPtr<SysFSSymbolicLinkDeviceComponent> m_symlink_sysfs_component;
|
||||
LockRefPtr<SysFSDirectory> m_sysfs_device_directory;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<DeviceControlDevice> DeviceControlDevice::must_create()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<DeviceControlDevice> DeviceControlDevice::must_create()
|
||||
{
|
||||
auto device_control_device_or_error = DeviceManagement::try_create_device<DeviceControlDevice>();
|
||||
// FIXME: Find a way to propagate errors
|
||||
|
@ -14,7 +14,7 @@ class DeviceControlDevice final : public CharacterDevice {
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<DeviceControlDevice> must_create();
|
||||
static NonnullLockRefPtr<DeviceControlDevice> must_create();
|
||||
virtual ~DeviceControlDevice() override;
|
||||
|
||||
private:
|
||||
|
@ -8,9 +8,7 @@
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/API/DeviceEvent.h>
|
||||
@ -21,6 +19,8 @@
|
||||
#include <Kernel/Devices/Device.h>
|
||||
#include <Kernel/Devices/DeviceControlDevice.h>
|
||||
#include <Kernel/Devices/NullDevice.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtrVector.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
|
||||
namespace Kernel {
|
||||
@ -54,7 +54,7 @@ public:
|
||||
ConsoleDevice& console_device();
|
||||
|
||||
template<typename DeviceType, typename... Args>
|
||||
static inline ErrorOr<NonnullRefPtr<DeviceType>> try_create_device(Args&&... args) requires(requires(Args... args) { DeviceType::try_create(args...); })
|
||||
static inline ErrorOr<NonnullLockRefPtr<DeviceType>> try_create_device(Args&&... args) requires(requires(Args... args) { DeviceType::try_create(args...); })
|
||||
{
|
||||
auto device = TRY(DeviceType::try_create(forward<Args>(args)...));
|
||||
device->after_inserting();
|
||||
@ -62,17 +62,17 @@ public:
|
||||
}
|
||||
|
||||
template<typename DeviceType, typename... Args>
|
||||
static inline ErrorOr<NonnullRefPtr<DeviceType>> try_create_device(Args&&... args)
|
||||
static inline ErrorOr<NonnullLockRefPtr<DeviceType>> try_create_device(Args&&... args)
|
||||
{
|
||||
auto device = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DeviceType(forward<Args>(args)...)));
|
||||
auto device = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DeviceType(forward<Args>(args)...)));
|
||||
device->after_inserting();
|
||||
return device;
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<NullDevice> m_null_device;
|
||||
RefPtr<ConsoleDevice> m_console_device;
|
||||
RefPtr<DeviceControlDevice> m_device_control_device;
|
||||
LockRefPtr<NullDevice> m_null_device;
|
||||
LockRefPtr<ConsoleDevice> m_console_device;
|
||||
LockRefPtr<DeviceControlDevice> m_device_control_device;
|
||||
// FIXME: Once we have a singleton for managing many sound cards, remove this from here
|
||||
SpinlockProtected<HashMap<u64, Device*>> m_devices { LockRank::None };
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<FullDevice> FullDevice::must_create()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<FullDevice> FullDevice::must_create()
|
||||
{
|
||||
auto full_device_or_error = DeviceManagement::try_create_device<FullDevice>();
|
||||
// FIXME: Find a way to propagate errors
|
||||
|
@ -14,7 +14,7 @@ class FullDevice final : public CharacterDevice {
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<FullDevice> must_create();
|
||||
static NonnullLockRefPtr<FullDevice> must_create();
|
||||
virtual ~FullDevice() override;
|
||||
|
||||
private:
|
||||
|
@ -9,12 +9,12 @@
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/CircularQueue.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/API/KeyCode.h>
|
||||
#include <Kernel/API/MousePacket.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtrVector.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
#include <Kernel/Locking/SpinlockProtected.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
@ -61,8 +61,8 @@ private:
|
||||
size_t m_mouse_minor_number { 0 };
|
||||
size_t m_keyboard_minor_number { 0 };
|
||||
KeyboardClient* m_client { nullptr };
|
||||
RefPtr<I8042Controller> m_i8042_controller;
|
||||
NonnullRefPtrVector<HIDDevice> m_hid_devices;
|
||||
LockRefPtr<I8042Controller> m_i8042_controller;
|
||||
NonnullLockRefPtrVector<HIDDevice> m_hid_devices;
|
||||
Spinlock m_client_lock { LockRank::None };
|
||||
};
|
||||
|
||||
|
@ -13,16 +13,16 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<I8042Controller> I8042Controller::initialize()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<I8042Controller> I8042Controller::initialize()
|
||||
{
|
||||
return adopt_ref(*new I8042Controller());
|
||||
return adopt_lock_ref(*new I8042Controller());
|
||||
}
|
||||
|
||||
RefPtr<MouseDevice> I8042Controller::mouse() const
|
||||
LockRefPtr<MouseDevice> I8042Controller::mouse() const
|
||||
{
|
||||
return m_mouse_device;
|
||||
}
|
||||
RefPtr<KeyboardDevice> I8042Controller::keyboard() const
|
||||
LockRefPtr<KeyboardDevice> I8042Controller::keyboard() const
|
||||
{
|
||||
return m_keyboard_device;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ protected:
|
||||
{
|
||||
}
|
||||
|
||||
NonnullRefPtr<I8042Controller> m_i8042_controller;
|
||||
NonnullLockRefPtr<I8042Controller> m_i8042_controller;
|
||||
};
|
||||
|
||||
class PS2KeyboardDevice;
|
||||
@ -88,7 +88,7 @@ class I8042Controller final : public AtomicRefCounted<I8042Controller> {
|
||||
friend class PS2MouseDevice;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<I8042Controller> initialize();
|
||||
static NonnullLockRefPtr<I8042Controller> initialize();
|
||||
|
||||
ErrorOr<void> detect_devices();
|
||||
|
||||
@ -132,8 +132,8 @@ public:
|
||||
|
||||
bool irq_process_input_buffer(HIDDevice::Type);
|
||||
|
||||
RefPtr<MouseDevice> mouse() const;
|
||||
RefPtr<KeyboardDevice> keyboard() const;
|
||||
LockRefPtr<MouseDevice> mouse() const;
|
||||
LockRefPtr<KeyboardDevice> keyboard() const;
|
||||
|
||||
// Note: This function exists only for the initialization process of the controller
|
||||
bool check_existence_via_probing(Badge<HIDManagement>);
|
||||
@ -157,8 +157,8 @@ private:
|
||||
bool m_first_port_available { false };
|
||||
bool m_second_port_available { false };
|
||||
bool m_is_dual_channel { false };
|
||||
RefPtr<MouseDevice> m_mouse_device;
|
||||
RefPtr<KeyboardDevice> m_keyboard_device;
|
||||
LockRefPtr<MouseDevice> m_mouse_device;
|
||||
LockRefPtr<KeyboardDevice> m_keyboard_device;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ bool PS2KeyboardDevice::handle_irq(RegisterState const&)
|
||||
return m_i8042_controller->irq_process_input_buffer(HIDDevice::Type::Keyboard);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2KeyboardDevice>> PS2KeyboardDevice::try_to_initialize(I8042Controller const& ps2_controller)
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<PS2KeyboardDevice>> PS2KeyboardDevice::try_to_initialize(I8042Controller const& ps2_controller)
|
||||
{
|
||||
auto keyboard_device = TRY(DeviceManagement::try_create_device<PS2KeyboardDevice>(ps2_controller));
|
||||
|
||||
|
@ -23,7 +23,7 @@ class PS2KeyboardDevice final : public IRQHandler
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<PS2KeyboardDevice>> try_to_initialize(I8042Controller const&);
|
||||
static ErrorOr<NonnullLockRefPtr<PS2KeyboardDevice>> try_to_initialize(I8042Controller const&);
|
||||
virtual ~PS2KeyboardDevice() override;
|
||||
ErrorOr<void> initialize();
|
||||
|
||||
|
@ -175,7 +175,7 @@ ErrorOr<void> PS2MouseDevice::set_sample_rate(u8 rate)
|
||||
return {};
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2MouseDevice>> PS2MouseDevice::try_to_initialize(I8042Controller const& ps2_controller)
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<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(I8042Controller const&);
|
||||
static ErrorOr<NonnullLockRefPtr<PS2MouseDevice>> try_to_initialize(I8042Controller const&);
|
||||
ErrorOr<void> initialize();
|
||||
|
||||
virtual ~PS2MouseDevice() override;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<VMWareMouseDevice>> VMWareMouseDevice::try_to_initialize(I8042Controller const& ps2_controller)
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<VMWareMouseDevice>> VMWareMouseDevice::try_to_initialize(I8042Controller const& ps2_controller)
|
||||
{
|
||||
// FIXME: return the correct error
|
||||
if (!VMWareBackdoor::the())
|
||||
|
@ -18,7 +18,7 @@ namespace Kernel {
|
||||
class VMWareMouseDevice final : public PS2MouseDevice {
|
||||
public:
|
||||
friend class DeviceManagement;
|
||||
static ErrorOr<NonnullRefPtr<VMWareMouseDevice>> try_to_initialize(I8042Controller const&);
|
||||
static ErrorOr<NonnullLockRefPtr<VMWareMouseDevice>> try_to_initialize(I8042Controller const&);
|
||||
virtual ~VMWareMouseDevice() override;
|
||||
|
||||
// ^I8042Device
|
||||
|
@ -19,7 +19,7 @@ namespace Kernel {
|
||||
HashMap<ProcessID, KCOVInstance*>* KCOVDevice::proc_instance;
|
||||
HashMap<ThreadID, KCOVInstance*>* KCOVDevice::thread_instance;
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<KCOVDevice> KCOVDevice::must_create()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<KCOVDevice> KCOVDevice::must_create()
|
||||
{
|
||||
auto kcov_device_or_error = DeviceManagement::try_create_device<KCOVDevice>();
|
||||
// FIXME: Find a way to propagate errors
|
||||
@ -65,7 +65,7 @@ void KCOVDevice::free_process()
|
||||
delete kcov_instance;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> KCOVDevice::open(int options)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> KCOVDevice::open(int options)
|
||||
{
|
||||
auto pid = Process::current().pid();
|
||||
if (proc_instance->get(pid).has_value())
|
||||
|
@ -17,13 +17,13 @@ public:
|
||||
static HashMap<ProcessID, KCOVInstance*>* proc_instance;
|
||||
static HashMap<ThreadID, KCOVInstance*>* thread_instance;
|
||||
|
||||
static NonnullRefPtr<KCOVDevice> must_create();
|
||||
static NonnullLockRefPtr<KCOVDevice> must_create();
|
||||
static void free_thread();
|
||||
static void free_process();
|
||||
|
||||
// ^File
|
||||
ErrorOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override;
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(int options) override;
|
||||
|
||||
protected:
|
||||
KCOVDevice();
|
||||
|
@ -53,7 +53,7 @@ private:
|
||||
u64 m_buffer_size_in_entries { 0 };
|
||||
size_t m_buffer_size_in_bytes { 0 };
|
||||
kcov_pc_t* m_buffer { nullptr };
|
||||
RefPtr<Memory::AnonymousVMObject> m_vmobject;
|
||||
LockRefPtr<Memory::AnonymousVMObject> m_vmobject;
|
||||
|
||||
// Here to ensure it's not garbage collected at the end of open()
|
||||
OwnPtr<Memory::Region> m_kernel_region;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<MemoryDevice> MemoryDevice::must_create()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<MemoryDevice> MemoryDevice::must_create()
|
||||
{
|
||||
auto memory_device_or_error = DeviceManagement::try_create_device<MemoryDevice>();
|
||||
// FIXME: Find a way to propagate errors
|
||||
|
@ -16,7 +16,7 @@ class MemoryDevice final : public CharacterDevice {
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<MemoryDevice> must_create();
|
||||
static NonnullLockRefPtr<MemoryDevice> must_create();
|
||||
~MemoryDevice();
|
||||
|
||||
virtual ErrorOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<NullDevice> NullDevice::must_initialize()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<NullDevice> NullDevice::must_initialize()
|
||||
{
|
||||
auto null_device_or_error = DeviceManagement::try_create_device<NullDevice>();
|
||||
// FIXME: Find a way to propagate errors
|
||||
|
@ -16,7 +16,7 @@ class NullDevice final : public CharacterDevice {
|
||||
public:
|
||||
virtual ~NullDevice() override;
|
||||
|
||||
static NonnullRefPtr<NullDevice> must_initialize();
|
||||
static NonnullLockRefPtr<NullDevice> must_initialize();
|
||||
|
||||
private:
|
||||
NullDevice();
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<RandomDevice> RandomDevice::must_create()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<RandomDevice> RandomDevice::must_create()
|
||||
{
|
||||
auto random_device_or_error = DeviceManagement::try_create_device<RandomDevice>();
|
||||
// FIXME: Find a way to propagate errors
|
||||
|
@ -14,7 +14,7 @@ class RandomDevice final : public CharacterDevice {
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<RandomDevice> must_create();
|
||||
static NonnullLockRefPtr<RandomDevice> must_create();
|
||||
virtual ~RandomDevice() override;
|
||||
|
||||
private:
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SelfTTYDevice> SelfTTYDevice::must_create()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SelfTTYDevice> SelfTTYDevice::must_create()
|
||||
{
|
||||
auto self_tty_device_or_error = DeviceManagement::try_create_device<SelfTTYDevice>();
|
||||
// FIXME: Find a way to propagate errors
|
||||
@ -19,14 +19,14 @@ UNMAP_AFTER_INIT NonnullRefPtr<SelfTTYDevice> SelfTTYDevice::must_create()
|
||||
return self_tty_device_or_error.release_value();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> SelfTTYDevice::open(int options)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> SelfTTYDevice::open(int options)
|
||||
{
|
||||
// Note: If for some odd reason we try to open this device (early on boot?)
|
||||
// while there's no current Process assigned, don't fail and return an error.
|
||||
if (!Process::has_current())
|
||||
return Error::from_errno(ESRCH);
|
||||
auto& current_process = Process::current();
|
||||
RefPtr<TTY> tty = current_process.tty();
|
||||
LockRefPtr<TTY> tty = current_process.tty();
|
||||
if (!tty)
|
||||
return Error::from_errno(ENXIO);
|
||||
auto description = TRY(OpenFileDescription::try_create(*tty));
|
||||
|
@ -14,14 +14,14 @@ class SelfTTYDevice final : public CharacterDevice {
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<SelfTTYDevice> must_create();
|
||||
static NonnullLockRefPtr<SelfTTYDevice> must_create();
|
||||
virtual ~SelfTTYDevice() override;
|
||||
|
||||
private:
|
||||
SelfTTYDevice();
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(int options) override;
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
|
@ -17,11 +17,11 @@ namespace Kernel {
|
||||
#define SERIAL_COM3_ADDR 0x3E8
|
||||
#define SERIAL_COM4_ADDR 0x2E8
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SerialDevice> SerialDevice::must_create(size_t com_number)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SerialDevice> SerialDevice::must_create(size_t com_number)
|
||||
{
|
||||
// FIXME: This way of blindly doing release_value is really not a good thing, find
|
||||
// a way to propagate errors back.
|
||||
RefPtr<SerialDevice> serial_device;
|
||||
LockRefPtr<SerialDevice> serial_device;
|
||||
switch (com_number) {
|
||||
case 0: {
|
||||
serial_device = DeviceManagement::try_create_device<SerialDevice>(IOAddress(SERIAL_COM1_ADDR), 64).release_value();
|
||||
|
@ -15,7 +15,7 @@ class SerialDevice final : public CharacterDevice {
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<SerialDevice> must_create(size_t com_number);
|
||||
static NonnullLockRefPtr<SerialDevice> must_create(size_t com_number);
|
||||
|
||||
virtual ~SerialDevice() override;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<ZeroDevice> ZeroDevice::must_create()
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<ZeroDevice> ZeroDevice::must_create()
|
||||
{
|
||||
auto zero_device_or_error = DeviceManagement::try_create_device<ZeroDevice>();
|
||||
// FIXME: Find a way to propagate errors
|
||||
|
@ -14,7 +14,7 @@ class ZeroDevice final : public CharacterDevice {
|
||||
friend class DeviceManagement;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<ZeroDevice> must_create();
|
||||
static NonnullLockRefPtr<ZeroDevice> must_create();
|
||||
virtual ~ZeroDevice() override;
|
||||
|
||||
private:
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
AnonymousFile::AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
AnonymousFile::AnonymousFile(NonnullLockRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
: m_vmobject(move(vmobject))
|
||||
{
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ namespace Kernel {
|
||||
|
||||
class AnonymousFile final : public File {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<AnonymousFile>> try_create(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
static ErrorOr<NonnullLockRefPtr<AnonymousFile>> try_create(NonnullLockRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) AnonymousFile(move(vmobject)));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) AnonymousFile(move(vmobject)));
|
||||
}
|
||||
|
||||
virtual ~AnonymousFile() override;
|
||||
@ -30,9 +30,9 @@ private:
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, 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>);
|
||||
explicit AnonymousFile(NonnullLockRefPtr<Memory::AnonymousVMObject>);
|
||||
|
||||
NonnullRefPtr<Memory::AnonymousVMObject> m_vmobject;
|
||||
NonnullLockRefPtr<Memory::AnonymousVMObject> m_vmobject;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -20,20 +20,20 @@ SpinlockProtected<Custody::AllCustodiesList>& Custody::all_instances()
|
||||
return s_all_instances;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> Custody::try_create(Custody* parent, StringView name, Inode& inode, int mount_flags)
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> Custody::try_create(Custody* parent, StringView name, Inode& inode, int mount_flags)
|
||||
{
|
||||
return all_instances().with([&](auto& all_custodies) -> ErrorOr<NonnullRefPtr<Custody>> {
|
||||
return all_instances().with([&](auto& all_custodies) -> ErrorOr<NonnullLockRefPtr<Custody>> {
|
||||
for (Custody& custody : all_custodies) {
|
||||
if (custody.parent() == parent
|
||||
&& custody.name() == name
|
||||
&& &custody.inode() == &inode
|
||||
&& custody.mount_flags() == mount_flags) {
|
||||
return NonnullRefPtr { custody };
|
||||
return NonnullLockRefPtr { custody };
|
||||
}
|
||||
}
|
||||
|
||||
auto name_kstring = TRY(KString::try_create(name));
|
||||
auto custody = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Custody(parent, move(name_kstring), inode, mount_flags)));
|
||||
auto custody = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Custody(parent, move(name_kstring), inode, mount_flags)));
|
||||
all_custodies.prepend(*custody);
|
||||
return custody;
|
||||
});
|
||||
|
@ -8,17 +8,17 @@
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/KString.h>
|
||||
#include <Kernel/Library/ListedRefCounted.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Locking/SpinlockProtected.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class Custody : public ListedRefCounted<Custody, LockType::Spinlock> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Custody>> try_create(Custody* parent, StringView name, Inode&, int mount_flags);
|
||||
static ErrorOr<NonnullLockRefPtr<Custody>> try_create(Custody* parent, StringView name, Inode&, int mount_flags);
|
||||
|
||||
~Custody();
|
||||
|
||||
@ -35,9 +35,9 @@ public:
|
||||
private:
|
||||
Custody(Custody* parent, NonnullOwnPtr<KString> name, Inode&, int mount_flags);
|
||||
|
||||
RefPtr<Custody> m_parent;
|
||||
LockRefPtr<Custody> m_parent;
|
||||
NonnullOwnPtr<KString> m_name;
|
||||
NonnullRefPtr<Inode> m_inode;
|
||||
NonnullLockRefPtr<Inode> m_inode;
|
||||
int m_mount_flags { 0 };
|
||||
|
||||
mutable IntrusiveListNode<Custody> m_all_custodies_list_node;
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> DevPtsFS::try_create()
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> DevPtsFS::try_create()
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevPtsFS));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFS));
|
||||
}
|
||||
|
||||
DevPtsFS::DevPtsFS() = default;
|
||||
@ -22,7 +22,7 @@ DevPtsFS::~DevPtsFS() = default;
|
||||
|
||||
ErrorOr<void> DevPtsFS::initialize()
|
||||
{
|
||||
m_root_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevPtsFSInode(*this, 1, nullptr)));
|
||||
m_root_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFSInode(*this, 1, nullptr)));
|
||||
m_root_inode->m_metadata.inode = { fsid(), 1 };
|
||||
m_root_inode->m_metadata.mode = 0040555;
|
||||
m_root_inode->m_metadata.uid = 0;
|
||||
@ -48,7 +48,7 @@ Inode& DevPtsFS::root_inode()
|
||||
return *m_root_inode;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevPtsFS::get_inode(InodeIdentifier inode_id) const
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevPtsFS::get_inode(InodeIdentifier inode_id) const
|
||||
{
|
||||
if (inode_id.index() == 1)
|
||||
return *m_root_inode;
|
||||
@ -57,7 +57,7 @@ ErrorOr<NonnullRefPtr<Inode>> DevPtsFS::get_inode(InodeIdentifier inode_id) cons
|
||||
auto* device = DeviceManagement::the().get_device(201, pty_index);
|
||||
VERIFY(device);
|
||||
|
||||
auto inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device))));
|
||||
auto inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device))));
|
||||
inode->m_metadata.inode = inode_id;
|
||||
inode->m_metadata.size = 0;
|
||||
inode->m_metadata.uid = device->uid();
|
||||
@ -117,7 +117,7 @@ ErrorOr<void> DevPtsFSInode::traverse_as_directory(Function<ErrorOr<void>(FileSy
|
||||
});
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevPtsFSInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevPtsFSInode::lookup(StringView name)
|
||||
{
|
||||
VERIFY(identifier().index() == 1);
|
||||
|
||||
@ -128,7 +128,7 @@ ErrorOr<NonnullRefPtr<Inode>> DevPtsFSInode::lookup(StringView name)
|
||||
if (!pty_index.has_value())
|
||||
return ENOENT;
|
||||
|
||||
return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr<NonnullRefPtr<Inode>> {
|
||||
return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr<NonnullLockRefPtr<Inode>> {
|
||||
for (SlavePTY& slave_pty : list) {
|
||||
if (slave_pty.index() != pty_index.value())
|
||||
continue;
|
||||
@ -148,7 +148,7 @@ ErrorOr<void> DevPtsFSInode::add_child(Inode&, StringView, mode_t)
|
||||
return EROFS;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevPtsFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevPtsFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
{
|
||||
return EROFS;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class DevPtsFS final : public FileSystem {
|
||||
|
||||
public:
|
||||
virtual ~DevPtsFS() override;
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create();
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
|
||||
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
virtual StringView class_name() const override { return "DevPtsFS"sv; }
|
||||
@ -29,9 +29,9 @@ public:
|
||||
|
||||
private:
|
||||
DevPtsFS();
|
||||
ErrorOr<NonnullRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
|
||||
RefPtr<DevPtsFSInode> m_root_inode;
|
||||
LockRefPtr<DevPtsFSInode> m_root_inode;
|
||||
};
|
||||
|
||||
class DevPtsFSInode final : public Inode {
|
||||
@ -50,16 +50,16 @@ private:
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() 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<NonnullLockRefPtr<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;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
virtual ErrorOr<void> chown(UserID, GroupID) override;
|
||||
|
||||
WeakPtr<SlavePTY> m_pty;
|
||||
LockWeakPtr<SlavePTY> m_pty;
|
||||
InodeMetadata m_metadata;
|
||||
};
|
||||
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> DevTmpFS::try_create()
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> DevTmpFS::try_create()
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFS));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFS));
|
||||
}
|
||||
|
||||
DevTmpFS::DevTmpFS() = default;
|
||||
@ -30,7 +30,7 @@ DevTmpFS::~DevTmpFS() = default;
|
||||
|
||||
ErrorOr<void> DevTmpFS::initialize()
|
||||
{
|
||||
m_root_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSRootDirectoryInode(*this)));
|
||||
m_root_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFSRootDirectoryInode(*this)));
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ ErrorOr<void> DevTmpFSInode::traverse_as_directory(Function<ErrorOr<void>(FileSy
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevTmpFSInode::lookup(StringView)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevTmpFSInode::lookup(StringView)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
@ -76,7 +76,7 @@ ErrorOr<size_t> DevTmpFSInode::write_bytes(off_t, size_t, UserOrKernelBuffer con
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevTmpFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevTmpFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
@ -214,7 +214,7 @@ ErrorOr<void> DevTmpFSDirectoryInode::traverse_as_directory(Function<ErrorOr<voi
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevTmpFSDirectoryInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevTmpFSDirectoryInode::lookup(StringView name)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
for (auto& node : m_nodes) {
|
||||
@ -237,7 +237,7 @@ ErrorOr<void> DevTmpFSDirectoryInode::remove_child(StringView name)
|
||||
return Error::from_errno(ENOENT);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevTmpFSDirectoryInode::create_child(StringView name, mode_t mode, dev_t device_mode, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevTmpFSDirectoryInode::create_child(StringView name, mode_t mode, dev_t device_mode, UserID, GroupID)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
for (auto& node : m_nodes) {
|
||||
@ -249,7 +249,7 @@ ErrorOr<NonnullRefPtr<Inode>> DevTmpFSDirectoryInode::create_child(StringView na
|
||||
metadata.mode = mode;
|
||||
if (metadata.is_directory()) {
|
||||
auto name_kstring = TRY(KString::try_create(name));
|
||||
auto new_directory_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSDirectoryInode(fs(), move(name_kstring))));
|
||||
auto new_directory_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFSDirectoryInode(fs(), move(name_kstring))));
|
||||
TRY(new_directory_inode->chmod(mode));
|
||||
m_nodes.append(*new_directory_inode);
|
||||
return new_directory_inode;
|
||||
@ -258,14 +258,14 @@ ErrorOr<NonnullRefPtr<Inode>> DevTmpFSDirectoryInode::create_child(StringView na
|
||||
auto name_kstring = TRY(KString::try_create(name));
|
||||
auto major = major_from_encoded_device(device_mode);
|
||||
auto minor = minor_from_encoded_device(device_mode);
|
||||
auto new_device_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSDeviceInode(fs(), major, minor, is_block_device(mode), move(name_kstring))));
|
||||
auto new_device_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFSDeviceInode(fs(), major, minor, is_block_device(mode), move(name_kstring))));
|
||||
TRY(new_device_inode->chmod(mode));
|
||||
m_nodes.append(*new_device_inode);
|
||||
return new_device_inode;
|
||||
}
|
||||
if (metadata.is_symlink()) {
|
||||
auto name_kstring = TRY(KString::try_create(name));
|
||||
auto new_link_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSLinkInode(fs(), move(name_kstring))));
|
||||
auto new_link_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFSLinkInode(fs(), move(name_kstring))));
|
||||
TRY(new_link_inode->chmod(mode));
|
||||
m_nodes.append(*new_link_inode);
|
||||
return new_link_inode;
|
||||
@ -307,7 +307,7 @@ ErrorOr<size_t> DevTmpFSDeviceInode::read_bytes(off_t offset, size_t count, User
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(!!description);
|
||||
RefPtr<Device> device = DeviceManagement::the().get_device(m_major_number, m_minor_number);
|
||||
LockRefPtr<Device> device = DeviceManagement::the().get_device(m_major_number, m_minor_number);
|
||||
if (!device)
|
||||
return Error::from_errno(ENODEV);
|
||||
if (!device->can_read(*description, offset))
|
||||
@ -322,7 +322,7 @@ ErrorOr<size_t> DevTmpFSDeviceInode::write_bytes(off_t offset, size_t count, Use
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(!!description);
|
||||
RefPtr<Device> device = DeviceManagement::the().get_device(m_major_number, m_minor_number);
|
||||
LockRefPtr<Device> device = DeviceManagement::the().get_device(m_major_number, m_minor_number);
|
||||
if (!device)
|
||||
return Error::from_errno(ENODEV);
|
||||
if (!device->can_write(*description, offset))
|
||||
|
@ -20,7 +20,7 @@ class DevTmpFS final : public FileSystem {
|
||||
|
||||
public:
|
||||
virtual ~DevTmpFS() override;
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create();
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
|
||||
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
virtual StringView class_name() const override { return "DevTmpFS"sv; }
|
||||
@ -30,7 +30,7 @@ private:
|
||||
DevTmpFS();
|
||||
size_t allocate_inode_index();
|
||||
|
||||
RefPtr<DevTmpFSRootDirectoryInode> m_root_inode;
|
||||
LockRefPtr<DevTmpFSRootDirectoryInode> m_root_inode;
|
||||
InodeIndex m_next_inode_index { 0 };
|
||||
};
|
||||
|
||||
@ -50,11 +50,11 @@ protected:
|
||||
DevTmpFSInode(DevTmpFS&, MajorNumber, MinorNumber);
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<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, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<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;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
@ -77,7 +77,7 @@ protected:
|
||||
virtual Type node_type() const = 0;
|
||||
|
||||
private:
|
||||
IntrusiveListNode<DevTmpFSInode, RefPtr<DevTmpFSInode>> m_list_node;
|
||||
IntrusiveListNode<DevTmpFSInode, LockRefPtr<DevTmpFSInode>> m_list_node;
|
||||
};
|
||||
|
||||
class DevTmpFSDeviceInode final : public DevTmpFSInode {
|
||||
@ -135,10 +135,10 @@ protected:
|
||||
// ^DevTmpFSInode
|
||||
virtual Type node_type() const override { return Type::Directory; }
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
DevTmpFSDirectoryInode(DevTmpFS&, NonnullOwnPtr<KString> name);
|
||||
// ^Inode
|
||||
OwnPtr<KString> m_name;
|
||||
|
@ -49,9 +49,9 @@ static u8 to_ext2_file_type(mode_t mode)
|
||||
return EXT2_FT_UNKNOWN;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> Ext2FS::try_create(OpenFileDescription& file_description)
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> Ext2FS::try_create(OpenFileDescription& file_description)
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Ext2FS(file_description)));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Ext2FS(file_description)));
|
||||
}
|
||||
|
||||
Ext2FS::Ext2FS(OpenFileDescription& file_description)
|
||||
@ -686,7 +686,7 @@ void Ext2FS::flush_writes()
|
||||
// The problem is that they are quite heavy objects, and use a lot of heap memory
|
||||
// for their (child name lookup) and (block list) caches.
|
||||
|
||||
m_inode_cache.remove_all_matching([](InodeIndex, RefPtr<Ext2FSInode> const& cached_inode) {
|
||||
m_inode_cache.remove_all_matching([](InodeIndex, LockRefPtr<Ext2FSInode> const& cached_inode) {
|
||||
// NOTE: If we're asked to look up an inode by number (via get_inode) and it turns out
|
||||
// to not exist, we remember the fact that it doesn't exist by caching a nullptr.
|
||||
// This seems like a reasonable time to uncache ideas about unknown inodes, so do that.
|
||||
@ -763,7 +763,7 @@ ErrorOr<void> Ext2FSInode::flush_metadata()
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
{
|
||||
MutexLocker locker(m_lock);
|
||||
VERIFY(inode.fsid() == fsid());
|
||||
@ -773,7 +773,7 @@ ErrorOr<NonnullRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
if (it != m_inode_cache.end()) {
|
||||
if (!it->value)
|
||||
return ENOENT;
|
||||
return NonnullRefPtr<Inode> { *it->value };
|
||||
return NonnullLockRefPtr<Inode> { *it->value };
|
||||
}
|
||||
}
|
||||
|
||||
@ -789,7 +789,7 @@ ErrorOr<NonnullRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
if (!find_block_containing_inode(inode.index(), block_index, offset))
|
||||
return EINVAL;
|
||||
|
||||
auto new_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Ext2FSInode(const_cast<Ext2FS&>(*this), inode.index())));
|
||||
auto new_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Ext2FSInode(const_cast<Ext2FS&>(*this), inode.index())));
|
||||
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<u8*>(&new_inode->m_raw_inode));
|
||||
TRY(read_block(block_index, &buffer, sizeof(ext2_inode), offset));
|
||||
@ -1116,7 +1116,7 @@ ErrorOr<void> Ext2FSInode::write_directory(Vector<Ext2FSDirectoryEntry>& entries
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FSInode::create_child(StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FSInode::create_child(StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
{
|
||||
if (::is_directory(mode))
|
||||
return fs().create_directory(*this, name, mode, uid, gid);
|
||||
@ -1434,7 +1434,7 @@ ErrorOr<void> Ext2FS::set_block_allocation_state(BlockIndex block_index, bool ne
|
||||
return update_bitmap_block(bgd.bg_block_bitmap, bit_index, new_state, m_super_block.s_free_blocks_count, bgd.bg_free_blocks_count);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FS::create_directory(Ext2FSInode& parent_inode, StringView name, mode_t mode, UserID uid, GroupID gid)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FS::create_directory(Ext2FSInode& parent_inode, StringView name, mode_t mode, UserID uid, GroupID gid)
|
||||
{
|
||||
MutexLocker locker(m_lock);
|
||||
VERIFY(is_directory(mode));
|
||||
@ -1459,7 +1459,7 @@ ErrorOr<NonnullRefPtr<Inode>> Ext2FS::create_directory(Ext2FSInode& parent_inode
|
||||
return inode;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode, StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode, StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
{
|
||||
if (name.length() > EXT2_NAME_LEN)
|
||||
return ENAMETOOLONG;
|
||||
@ -1517,7 +1517,7 @@ ErrorOr<void> Ext2FSInode::populate_lookup_cache() const
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FSInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FSInode::lookup(StringView name)
|
||||
{
|
||||
VERIFY(is_directory());
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): Looking up '{}'", identifier(), name);
|
||||
|
@ -38,10 +38,10 @@ private:
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() 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<NonnullLockRefPtr<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;
|
||||
virtual ErrorOr<void> set_atime(time_t) override;
|
||||
@ -86,7 +86,7 @@ public:
|
||||
FileSize64bits = 1 << 1,
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
|
||||
virtual ~Ext2FS() override;
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
@ -126,9 +126,9 @@ private:
|
||||
|
||||
virtual StringView class_name() const override { return "Ext2FS"sv; }
|
||||
virtual Ext2FSInode& root_inode() override;
|
||||
ErrorOr<NonnullRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
ErrorOr<NonnullRefPtr<Inode>> create_inode(Ext2FSInode& parent_inode, StringView name, mode_t, dev_t, UserID, GroupID);
|
||||
ErrorOr<NonnullRefPtr<Inode>> create_directory(Ext2FSInode& parent_inode, StringView name, mode_t, UserID, GroupID);
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> create_inode(Ext2FSInode& parent_inode, StringView name, mode_t, dev_t, UserID, GroupID);
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> create_directory(Ext2FSInode& parent_inode, StringView name, mode_t, UserID, GroupID);
|
||||
virtual void flush_writes() override;
|
||||
|
||||
BlockIndex first_block_index() const;
|
||||
@ -159,7 +159,7 @@ private:
|
||||
mutable ext2_super_block m_super_block {};
|
||||
mutable OwnPtr<KBuffer> m_cached_group_descriptor_table;
|
||||
|
||||
mutable HashMap<InodeIndex, RefPtr<Ext2FSInode>> m_inode_cache;
|
||||
mutable HashMap<InodeIndex, LockRefPtr<Ext2FSInode>> m_inode_cache;
|
||||
|
||||
bool m_super_block_dirty { false };
|
||||
bool m_block_group_descriptors_dirty { false };
|
||||
@ -180,7 +180,7 @@ private:
|
||||
ErrorOr<void> update_bitmap_block(BlockIndex bitmap_block, size_t bit_index, bool new_state, u32& super_block_counter, u16& group_descriptor_counter);
|
||||
|
||||
Vector<OwnPtr<CachedBitmap>> m_cached_bitmaps;
|
||||
RefPtr<Ext2FSInode> m_root_inode;
|
||||
LockRefPtr<Ext2FSInode> m_root_inode;
|
||||
};
|
||||
|
||||
inline Ext2FS& Ext2FSInode::fs()
|
||||
|
@ -16,13 +16,13 @@ namespace Kernel {
|
||||
|
||||
static Atomic<int> s_next_fifo_id = 1;
|
||||
|
||||
ErrorOr<NonnullRefPtr<FIFO>> FIFO::try_create(UserID uid)
|
||||
ErrorOr<NonnullLockRefPtr<FIFO>> FIFO::try_create(UserID uid)
|
||||
{
|
||||
auto buffer = TRY(DoubleBuffer::try_create("FIFO: Buffer"sv));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) FIFO(uid, move(buffer)));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) FIFO(uid, move(buffer)));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> FIFO::open_direction(FIFO::Direction direction)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> FIFO::open_direction(FIFO::Direction direction)
|
||||
{
|
||||
auto description = TRY(OpenFileDescription::try_create(*this));
|
||||
attach(direction);
|
||||
@ -30,7 +30,7 @@ ErrorOr<NonnullRefPtr<OpenFileDescription>> FIFO::open_direction(FIFO::Direction
|
||||
return description;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> FIFO::open_direction_blocking(FIFO::Direction direction)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> FIFO::open_direction_blocking(FIFO::Direction direction)
|
||||
{
|
||||
MutexLocker locker(m_open_lock);
|
||||
|
||||
|
@ -24,13 +24,13 @@ public:
|
||||
Writer
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<FIFO>> try_create(UserID);
|
||||
static ErrorOr<NonnullLockRefPtr<FIFO>> try_create(UserID);
|
||||
virtual ~FIFO() override;
|
||||
|
||||
UserID uid() const { return m_uid; }
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open_direction(Direction);
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open_direction_blocking(Direction);
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open_direction(Direction);
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open_direction_blocking(Direction);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
|
||||
|
@ -15,7 +15,7 @@ namespace Kernel {
|
||||
File::File() = default;
|
||||
File::~File() = default;
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> File::open(int options)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> File::open(int options)
|
||||
{
|
||||
auto description = OpenFileDescription::try_create(*this);
|
||||
if (!description.is_error()) {
|
||||
|
@ -8,11 +8,11 @@
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/LockWeakable.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
#include <Kernel/UserOrKernelBuffer.h>
|
||||
#include <Kernel/VirtualAddress.h>
|
||||
@ -72,13 +72,13 @@ public:
|
||||
|
||||
class File
|
||||
: public AtomicRefCounted<File>
|
||||
, public Weakable<File> {
|
||||
, public LockWeakable<File> {
|
||||
public:
|
||||
virtual bool unref() const { return AtomicRefCounted<File>::unref(); }
|
||||
virtual void will_be_destroyed() { }
|
||||
virtual ~File();
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options);
|
||||
virtual ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(int options);
|
||||
virtual ErrorOr<void> close();
|
||||
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const = 0;
|
||||
|
@ -26,7 +26,7 @@ protected:
|
||||
private:
|
||||
virtual bool is_file_backed() const override { return true; }
|
||||
|
||||
mutable NonnullRefPtr<OpenFileDescription> m_file_description;
|
||||
mutable NonnullLockRefPtr<OpenFileDescription> m_file_description;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ void FileSystem::sync()
|
||||
{
|
||||
Inode::sync_all();
|
||||
|
||||
NonnullRefPtrVector<FileSystem, 32> file_systems;
|
||||
NonnullLockRefPtrVector<FileSystem, 32> file_systems;
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
for (auto& it : all_file_systems())
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
#include <Kernel/UserOrKernelBuffer.h>
|
||||
|
@ -8,15 +8,15 @@
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/Endian.h>
|
||||
#include <AK/HashFunctions.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringHash.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/FileSystem/BlockBasedFileSystem.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/KBuffer.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
#include <Kernel/UserOrKernelBuffer.h>
|
||||
|
||||
@ -28,7 +28,7 @@ constexpr u32 logical_sector_size = 2048;
|
||||
constexpr u32 max_cached_directory_entries = 128;
|
||||
|
||||
struct DirectoryState {
|
||||
RefPtr<ISO9660FS::DirectoryEntry> entry;
|
||||
LockRefPtr<ISO9660FS::DirectoryEntry> entry;
|
||||
u32 offset { 0 };
|
||||
};
|
||||
|
||||
@ -168,9 +168,9 @@ private:
|
||||
Vector<DirectoryState> m_directory_stack;
|
||||
};
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> ISO9660FS::try_create(OpenFileDescription& description)
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> ISO9660FS::try_create(OpenFileDescription& description)
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ISO9660FS(description)));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) ISO9660FS(description)));
|
||||
}
|
||||
|
||||
ISO9660FS::ISO9660FS(OpenFileDescription& description)
|
||||
@ -360,7 +360,7 @@ ErrorOr<void> ISO9660FS::visit_directory_record(ISO::DirectoryRecordHeader const
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ISO9660FS::DirectoryEntry>> ISO9660FS::directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record)
|
||||
ErrorOr<NonnullLockRefPtr<ISO9660FS::DirectoryEntry>> ISO9660FS::directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record)
|
||||
{
|
||||
u32 extent_location = LittleEndian { record->extent_location.little };
|
||||
u32 data_length = LittleEndian { record->data_length.little };
|
||||
@ -458,9 +458,9 @@ ErrorOr<void> ISO9660Inode::traverse_as_directory(Function<ErrorOr<void>(FileSys
|
||||
});
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ISO9660Inode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ISO9660Inode::lookup(StringView name)
|
||||
{
|
||||
RefPtr<Inode> inode;
|
||||
LockRefPtr<Inode> inode;
|
||||
Array<u8, max_file_identifier_length> file_identifier_buffer;
|
||||
|
||||
TRY(fs().visit_directory_record(m_record, [&](ISO::DirectoryRecordHeader const* record) {
|
||||
@ -498,7 +498,7 @@ ErrorOr<size_t> ISO9660Inode::write_bytes(off_t, size_t, UserOrKernelBuffer cons
|
||||
return EROFS;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ISO9660Inode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ISO9660Inode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
{
|
||||
return EROFS;
|
||||
}
|
||||
@ -553,9 +553,9 @@ ISO9660Inode::ISO9660Inode(ISO9660FS& fs, ISO::DirectoryRecordHeader const& reco
|
||||
|
||||
ISO9660Inode::~ISO9660Inode() = default;
|
||||
|
||||
ErrorOr<NonnullRefPtr<ISO9660Inode>> ISO9660Inode::try_create_from_directory_record(ISO9660FS& fs, ISO::DirectoryRecordHeader const& record, StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<ISO9660Inode>> ISO9660Inode::try_create_from_directory_record(ISO9660FS& fs, ISO::DirectoryRecordHeader const& record, StringView name)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ISO9660Inode(fs, record, name));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ISO9660Inode(fs, record, name));
|
||||
}
|
||||
|
||||
void ISO9660Inode::create_metadata()
|
||||
|
@ -9,13 +9,13 @@
|
||||
#include <AK/EnumBits.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RecursionDecision.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/FileSystem/BlockBasedFileSystem.h>
|
||||
#include <Kernel/FileSystem/Inode.h>
|
||||
#include <Kernel/KBuffer.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
@ -291,9 +291,9 @@ public:
|
||||
// We need it as an OwnPtr to default-construct this struct.
|
||||
OwnPtr<KBuffer> blocks;
|
||||
|
||||
static ErrorOr<NonnullRefPtr<DirectoryEntry>> try_create(u32 extent, u32 length, OwnPtr<KBuffer> blocks)
|
||||
static ErrorOr<NonnullLockRefPtr<DirectoryEntry>> try_create(u32 extent, u32 length, OwnPtr<KBuffer> blocks)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) DirectoryEntry(extent, length, move(blocks)));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) DirectoryEntry(extent, length, move(blocks)));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -305,7 +305,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
|
||||
virtual ~ISO9660FS() override;
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
@ -317,7 +317,7 @@ public:
|
||||
|
||||
virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override;
|
||||
|
||||
ErrorOr<NonnullRefPtr<DirectoryEntry>> directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record);
|
||||
ErrorOr<NonnullLockRefPtr<DirectoryEntry>> directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record);
|
||||
|
||||
private:
|
||||
ISO9660FS(OpenFileDescription&);
|
||||
@ -331,10 +331,10 @@ private:
|
||||
ErrorOr<void> visit_directory_record(ISO::DirectoryRecordHeader const& record, Function<ErrorOr<RecursionDecision>(ISO::DirectoryRecordHeader const*)> const& visitor) const;
|
||||
|
||||
OwnPtr<ISO::PrimaryVolumeDescriptor> m_primary_volume;
|
||||
RefPtr<ISO9660Inode> m_root_inode;
|
||||
LockRefPtr<ISO9660Inode> m_root_inode;
|
||||
|
||||
mutable u32 m_cached_inode_count { 0 };
|
||||
HashMap<u32, NonnullRefPtr<DirectoryEntry>> m_directory_entry_cache;
|
||||
HashMap<u32, NonnullLockRefPtr<DirectoryEntry>> m_directory_entry_cache;
|
||||
};
|
||||
|
||||
class ISO9660Inode final : public Inode {
|
||||
@ -350,10 +350,10 @@ public:
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() 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<NonnullLockRefPtr<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;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
@ -370,7 +370,7 @@ private:
|
||||
static constexpr size_t max_file_identifier_length = 256 - sizeof(ISO::DirectoryRecordHeader);
|
||||
|
||||
ISO9660Inode(ISO9660FS&, ISO::DirectoryRecordHeader const& record, StringView name);
|
||||
static ErrorOr<NonnullRefPtr<ISO9660Inode>> try_create_from_directory_record(ISO9660FS&, ISO::DirectoryRecordHeader const& record, StringView name);
|
||||
static ErrorOr<NonnullLockRefPtr<ISO9660Inode>> try_create_from_directory_record(ISO9660FS&, ISO::DirectoryRecordHeader const& record, StringView name);
|
||||
|
||||
static InodeIndex get_inode_index(ISO::DirectoryRecordHeader const& record, StringView name);
|
||||
static StringView get_normalized_filename(ISO::DirectoryRecordHeader const& record, Bytes buffer);
|
||||
|
@ -6,7 +6,6 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/API/InodeWatcherEvent.h>
|
||||
@ -16,6 +15,7 @@
|
||||
#include <Kernel/FileSystem/OpenFileDescription.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/KBufferBuilder.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtrVector.h>
|
||||
#include <Kernel/Memory/SharedInodeVMObject.h>
|
||||
#include <Kernel/Net/LocalSocket.h>
|
||||
#include <Kernel/Process.h>
|
||||
@ -31,7 +31,7 @@ SpinlockProtected<Inode::AllInstancesList>& Inode::all_instances()
|
||||
|
||||
void Inode::sync_all()
|
||||
{
|
||||
NonnullRefPtrVector<Inode, 32> inodes;
|
||||
NonnullLockRefPtrVector<Inode, 32> inodes;
|
||||
Inode::all_instances().with([&](auto& all_inodes) {
|
||||
for (auto& inode : all_inodes) {
|
||||
if (inode.is_metadata_dirty())
|
||||
@ -76,7 +76,7 @@ ErrorOr<NonnullOwnPtr<KBuffer>> Inode::read_entire(OpenFileDescription* descript
|
||||
return entire_file.release_nonnull();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> Inode::resolve_as_link(Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> Inode::resolve_as_link(Custody& base, LockRefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const
|
||||
{
|
||||
// The default implementation simply treats the stored
|
||||
// contents as a path and resolves that. That is, it
|
||||
@ -138,7 +138,7 @@ ErrorOr<void> Inode::set_shared_vmobject(Memory::SharedInodeVMObject& vmobject)
|
||||
return {};
|
||||
}
|
||||
|
||||
RefPtr<LocalSocket> Inode::bound_socket() const
|
||||
LockRefPtr<LocalSocket> Inode::bound_socket() const
|
||||
{
|
||||
return m_bound_socket;
|
||||
}
|
||||
@ -178,7 +178,7 @@ void Inode::unregister_watcher(Badge<InodeWatcher>, InodeWatcher& watcher)
|
||||
});
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<FIFO>> Inode::fifo()
|
||||
ErrorOr<NonnullLockRefPtr<FIFO>> Inode::fifo()
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(metadata().is_fifo());
|
||||
@ -187,7 +187,7 @@ ErrorOr<NonnullRefPtr<FIFO>> Inode::fifo()
|
||||
if (!m_fifo)
|
||||
m_fifo = TRY(FIFO::try_create(metadata().uid));
|
||||
|
||||
return NonnullRefPtr { *m_fifo };
|
||||
return NonnullLockRefPtr { *m_fifo };
|
||||
}
|
||||
|
||||
void Inode::set_metadata_dirty(bool metadata_dirty)
|
||||
@ -264,7 +264,7 @@ ErrorOr<void> Inode::prepare_to_write_data()
|
||||
return {};
|
||||
}
|
||||
|
||||
RefPtr<Memory::SharedInodeVMObject> Inode::shared_vmobject() const
|
||||
LockRefPtr<Memory::SharedInodeVMObject> Inode::shared_vmobject() const
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
return m_shared_vmobject.strong_ref();
|
||||
|
@ -11,13 +11,13 @@
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <Kernel/FileSystem/FIFO.h>
|
||||
#include <Kernel/FileSystem/FileSystem.h>
|
||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||
#include <Kernel/FileSystem/InodeMetadata.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/ListedRefCounted.h>
|
||||
#include <Kernel/Library/LockWeakPtr.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
#include <Kernel/Memory/SharedInodeVMObject.h>
|
||||
|
||||
@ -29,7 +29,7 @@ enum class ShouldBlock {
|
||||
};
|
||||
|
||||
class Inode : public ListedRefCounted<Inode, LockType::Spinlock>
|
||||
, public Weakable<Inode> {
|
||||
, public LockWeakable<Inode> {
|
||||
friend class VirtualFileSystem;
|
||||
friend class FileSystem;
|
||||
friend class InodeFile;
|
||||
@ -61,19 +61,19 @@ public:
|
||||
virtual void did_seek(OpenFileDescription&, off_t) { }
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const = 0;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const = 0;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) = 0;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) = 0;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) = 0;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) = 0;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) = 0;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) = 0;
|
||||
virtual ErrorOr<void> remove_child(StringView name) = 0;
|
||||
virtual ErrorOr<void> chmod(mode_t) = 0;
|
||||
virtual ErrorOr<void> chown(UserID, GroupID) = 0;
|
||||
virtual ErrorOr<void> truncate(u64) { return {}; }
|
||||
virtual ErrorOr<NonnullRefPtr<Custody>> resolve_as_link(Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Custody>> resolve_as_link(Custody& base, LockRefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const;
|
||||
|
||||
virtual ErrorOr<int> get_block_address(int) { return ENOTSUP; }
|
||||
|
||||
RefPtr<LocalSocket> bound_socket() const;
|
||||
LockRefPtr<LocalSocket> bound_socket() const;
|
||||
bool bind_socket(LocalSocket&);
|
||||
bool unbind_socket();
|
||||
|
||||
@ -90,7 +90,7 @@ public:
|
||||
void will_be_destroyed();
|
||||
|
||||
ErrorOr<void> set_shared_vmobject(Memory::SharedInodeVMObject&);
|
||||
RefPtr<Memory::SharedInodeVMObject> shared_vmobject() const;
|
||||
LockRefPtr<Memory::SharedInodeVMObject> shared_vmobject() const;
|
||||
|
||||
static void sync_all();
|
||||
void sync();
|
||||
@ -100,7 +100,7 @@ public:
|
||||
ErrorOr<void> register_watcher(Badge<InodeWatcher>, InodeWatcher&);
|
||||
void unregister_watcher(Badge<InodeWatcher>, InodeWatcher&);
|
||||
|
||||
ErrorOr<NonnullRefPtr<FIFO>> fifo();
|
||||
ErrorOr<NonnullLockRefPtr<FIFO>> fifo();
|
||||
|
||||
bool can_apply_flock(flock const&) const;
|
||||
ErrorOr<void> apply_flock(Process const&, OpenFileDescription const&, Userspace<flock const*>, ShouldBlock);
|
||||
@ -125,11 +125,11 @@ private:
|
||||
|
||||
FileSystem& m_file_system;
|
||||
InodeIndex m_index { 0 };
|
||||
WeakPtr<Memory::SharedInodeVMObject> m_shared_vmobject;
|
||||
RefPtr<LocalSocket> m_bound_socket;
|
||||
LockWeakPtr<Memory::SharedInodeVMObject> m_shared_vmobject;
|
||||
LockRefPtr<LocalSocket> m_bound_socket;
|
||||
SpinlockProtected<HashTable<InodeWatcher*>> m_watchers { LockRank::None };
|
||||
bool m_metadata_dirty { false };
|
||||
RefPtr<FIFO> m_fifo;
|
||||
LockRefPtr<FIFO> m_fifo;
|
||||
IntrusiveListNode<Inode> m_inode_list_node;
|
||||
|
||||
struct Flock {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
InodeFile::InodeFile(NonnullRefPtr<Inode>&& inode)
|
||||
InodeFile::InodeFile(NonnullLockRefPtr<Inode>&& inode)
|
||||
: m_inode(move(inode))
|
||||
{
|
||||
}
|
||||
@ -87,7 +87,7 @@ ErrorOr<void> InodeFile::ioctl(OpenFileDescription& description, unsigned reques
|
||||
ErrorOr<Memory::Region*> InodeFile::mmap(Process& process, OpenFileDescription& description, Memory::VirtualRange const& range, u64 offset, int prot, bool shared)
|
||||
{
|
||||
// FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec.
|
||||
RefPtr<Memory::InodeVMObject> vmobject;
|
||||
LockRefPtr<Memory::InodeVMObject> vmobject;
|
||||
if (shared)
|
||||
vmobject = TRY(Memory::SharedInodeVMObject::try_create_with_inode(inode()));
|
||||
else
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user