Compare commits
7 Commits
793c0368f2
...
1941885cfd
Author | SHA1 | Date |
---|---|---|
Bananymous | 1941885cfd | |
Bananymous | 88a86a9927 | |
Bananymous | 48e030bca3 | |
Bananymous | 6f118c1be1 | |
Bananymous | 7316eb87b8 | |
Bananymous | 5376236ab6 | |
Bananymous | 0af80d48ee |
|
@ -84,7 +84,7 @@ namespace BAN
|
|||
return Span<S>(reinterpret_cast<S*>(m_data), m_size / sizeof(S));
|
||||
}
|
||||
|
||||
ByteSpanGeneral slice(size_type offset, size_type length = size_type(-1)) const
|
||||
[[nodiscard]] ByteSpanGeneral slice(size_type offset, size_type length = size_type(-1)) const
|
||||
{
|
||||
ASSERT(m_data);
|
||||
ASSERT(m_size >= offset);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <BAN/Formatter.h>
|
||||
#include <BAN/NoCopyMove.h>
|
||||
#include <BAN/Variant.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -97,6 +98,7 @@ namespace BAN
|
|||
template<typename T>
|
||||
class [[nodiscard]] ErrorOr
|
||||
{
|
||||
BAN_NON_COPYABLE(ErrorOr);
|
||||
public:
|
||||
ErrorOr(const T& value)
|
||||
: m_data(value)
|
||||
|
@ -110,6 +112,14 @@ namespace BAN
|
|||
ErrorOr(Error&& error)
|
||||
: m_data(move(error))
|
||||
{}
|
||||
ErrorOr(ErrorOr&& other)
|
||||
: m_data(move(other.m_data))
|
||||
{}
|
||||
ErrorOr& operator=(ErrorOr&& other)
|
||||
{
|
||||
m_data = move(other.m_data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_error() const { return m_data.template has<Error>(); }
|
||||
const Error& error() const { return m_data.template get<Error>(); }
|
||||
|
|
|
@ -10,14 +10,11 @@ namespace BAN::Formatter
|
|||
|
||||
struct ValueFormat;
|
||||
|
||||
template<typename F>
|
||||
inline void print(F putc, const char* format);
|
||||
|
||||
template<typename F, typename Arg, typename... Args>
|
||||
inline void print(F putc, const char* format, Arg&& arg, Args&&... args);
|
||||
|
||||
template<typename F, typename... Args>
|
||||
inline void println(F putc, const char* format, Args&&... args);
|
||||
concept PrintableArguments = requires(F putc, Args&&... args, const ValueFormat& format)
|
||||
{
|
||||
(print_argument(putc, BAN::forward<Args>(args), format), ...);
|
||||
};
|
||||
|
||||
template<typename F, typename T>
|
||||
inline void print_argument(F putc, T value, const ValueFormat& format);
|
||||
|
@ -53,7 +50,7 @@ namespace BAN::Formatter
|
|||
}
|
||||
}
|
||||
|
||||
template<typename F, typename Arg, typename... Args>
|
||||
template<typename F, typename Arg, typename... Args> requires PrintableArguments<F, Arg, Args...>
|
||||
inline void print(F putc, const char* format, Arg&& arg, Args&&... args)
|
||||
{
|
||||
while (*format && *format != '{')
|
||||
|
|
|
@ -19,6 +19,12 @@ namespace BAN
|
|||
, value(forward<Args>(args)...)
|
||||
{}
|
||||
|
||||
template<typename... Args>
|
||||
Entry(Key&& key, Args&&... args) requires is_constructible_v<T, Args...>
|
||||
: key(BAN::move(key))
|
||||
, value(forward<Args>(args)...)
|
||||
{}
|
||||
|
||||
Key key;
|
||||
T value;
|
||||
};
|
||||
|
|
|
@ -272,6 +272,9 @@ namespace Kernel
|
|||
|
||||
PageTable::~PageTable()
|
||||
{
|
||||
if (m_highest_paging_struct == 0)
|
||||
return;
|
||||
|
||||
uint64_t* pdpt = reinterpret_cast<uint64_t*>(P2V(m_highest_paging_struct));
|
||||
|
||||
for (uint32_t pdpte = 0; pdpte < 3; pdpte++)
|
||||
|
|
|
@ -576,6 +576,9 @@ namespace Kernel
|
|||
|
||||
PageTable::~PageTable()
|
||||
{
|
||||
if (m_highest_paging_struct == 0)
|
||||
return;
|
||||
|
||||
// NOTE: we only loop until 256 since after that is hhdm
|
||||
const uint64_t* pml4 = P2V(m_highest_paging_struct);
|
||||
for (uint64_t pml4e = 0; pml4e < 256; pml4e++)
|
||||
|
|
|
@ -22,6 +22,9 @@ namespace Kernel
|
|||
|
||||
class PageTable
|
||||
{
|
||||
BAN_NON_COPYABLE(PageTable);
|
||||
BAN_NON_MOVABLE(PageTable);
|
||||
|
||||
public:
|
||||
using flags_t = uint16_t;
|
||||
enum Flags : flags_t
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Kernel
|
|||
static Process* create_kernel(entry_t, void*);
|
||||
static BAN::ErrorOr<Process*> create_userspace(const Credentials&, BAN::StringView path, BAN::Span<BAN::StringView> arguments);
|
||||
~Process();
|
||||
void cleanup_function();
|
||||
void cleanup_function(Thread*);
|
||||
|
||||
void register_to_scheduler();
|
||||
void exit(int status, int signal);
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace Kernel
|
|||
{
|
||||
ASSERT(m_threads.empty());
|
||||
ASSERT(m_mapped_regions.empty());
|
||||
ASSERT(&PageTable::current() != m_page_table.ptr());
|
||||
ASSERT(!m_page_table);
|
||||
}
|
||||
|
||||
void Process::add_thread(Thread* thread)
|
||||
|
@ -217,7 +217,7 @@ namespace Kernel
|
|||
MUST(m_threads.push_back(thread));
|
||||
}
|
||||
|
||||
void Process::cleanup_function()
|
||||
void Process::cleanup_function(Thread* thread)
|
||||
{
|
||||
{
|
||||
SpinLockGuard _(s_process_lock);
|
||||
|
@ -238,6 +238,8 @@ namespace Kernel
|
|||
|
||||
// NOTE: We must unmap ranges while the page table is still alive
|
||||
m_mapped_regions.clear();
|
||||
|
||||
thread->give_keep_alive_page_table(BAN::move(m_page_table));
|
||||
}
|
||||
|
||||
bool Process::on_thread_exit(Thread& thread)
|
||||
|
|
|
@ -242,7 +242,7 @@ namespace Kernel
|
|||
|
||||
ASSERT(thread->m_process == process);
|
||||
|
||||
process->cleanup_function();
|
||||
process->cleanup_function(thread);
|
||||
|
||||
thread->m_delete_process = true;
|
||||
|
||||
|
|
|
@ -174,6 +174,8 @@ namespace Kernel
|
|||
|
||||
BAN::ErrorOr<void> USBSCSIDevice::write_sectors_impl(uint64_t first_lba, uint64_t sector_count, BAN::ConstByteSpan buffer)
|
||||
{
|
||||
return BAN::Error::from_errno(ENOTSUP);
|
||||
|
||||
dprintln_if(DEBUG_USB_MASS_STORAGE, "write_blocks({}, {})", first_lba, sector_count);
|
||||
|
||||
const size_t max_blocks_per_write = m_max_packet_size / m_block_size;
|
||||
|
|
Loading…
Reference in New Issue