All: Cleanup all files
Add newline to end of files and remove whitespace from end of lines
This commit is contained in:
parent
3441f63298
commit
dfe5a2d665
|
@ -249,11 +249,11 @@ namespace BAN
|
||||||
return {};
|
return {};
|
||||||
if (has_sso() && fits_in_sso(new_size))
|
if (has_sso() && fits_in_sso(new_size))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
char* new_data = (char*)allocator(new_size + 1);
|
char* new_data = (char*)allocator(new_size + 1);
|
||||||
if (new_data == nullptr)
|
if (new_data == nullptr)
|
||||||
return Error::from_errno(ENOMEM);
|
return Error::from_errno(ENOMEM);
|
||||||
|
|
||||||
if (m_size)
|
if (m_size)
|
||||||
memcpy(new_data, data(), m_size + 1);
|
memcpy(new_data, data(), m_size + 1);
|
||||||
|
|
||||||
|
|
|
@ -193,4 +193,4 @@ namespace BAN
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace BAN
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::Time from_unix_time(uint64_t unix_time)
|
BAN::Time from_unix_time(uint64_t unix_time)
|
||||||
{
|
{
|
||||||
BAN::Time time {};
|
BAN::Time time {};
|
||||||
|
|
||||||
time.second = unix_time % 60; unix_time /= 60;
|
time.second = unix_time % 60; unix_time /= 60;
|
||||||
|
@ -68,4 +68,4 @@ namespace BAN
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace BAN
|
||||||
const Span<T> span() const { return Span(m_data, size()); }
|
const Span<T> span() const { return Span(m_data, size()); }
|
||||||
|
|
||||||
constexpr size_type size() const;
|
constexpr size_type size() const;
|
||||||
|
|
||||||
const T* data() const { return m_data; }
|
const T* data() const { return m_data; }
|
||||||
T* data() { return m_data; }
|
T* data() { return m_data; }
|
||||||
|
|
||||||
|
@ -109,4 +109,4 @@ namespace BAN
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,4 +39,4 @@ namespace BAN
|
||||||
T m_value;
|
T m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace BAN
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type* data() { return m_data; }
|
value_type* data() { return m_data; }
|
||||||
const value_type* data() const { return m_data; }
|
const value_type* data() const { return m_data; }
|
||||||
|
|
||||||
size_type size() const { return m_size; }
|
size_type size() const { return m_size; }
|
||||||
|
|
||||||
|
@ -137,4 +137,4 @@ namespace BAN
|
||||||
using ByteSpan = ByteSpanGeneral<false>;
|
using ByteSpan = ByteSpanGeneral<false>;
|
||||||
using ConstByteSpan = ByteSpanGeneral<true>;
|
using ConstByteSpan = ByteSpanGeneral<true>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace BAN
|
||||||
size_type size() const { return m_size; }
|
size_type size() const { return m_size; }
|
||||||
bool empty() const { return size() == 0; }
|
bool empty() const { return size() == 0; }
|
||||||
bool full() const { return size() == capacity(); }
|
bool full() const { return size() == capacity(); }
|
||||||
|
|
||||||
static constexpr size_type capacity() { return S; }
|
static constexpr size_type capacity() { return S; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -110,4 +110,4 @@ namespace BAN
|
||||||
return (T*)(m_storage + index * sizeof(T));
|
return (T*)(m_storage + index * sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,4 +77,4 @@ namespace BAN
|
||||||
T raw;
|
T raw;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ namespace BAN::Formatter
|
||||||
|
|
||||||
if (sign)
|
if (sign)
|
||||||
*(--ptr) = '-';
|
*(--ptr) = '-';
|
||||||
|
|
||||||
print(putc, ptr);
|
print(putc, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +205,10 @@ namespace BAN::Formatter
|
||||||
frac_part = -frac_part;
|
frac_part = -frac_part;
|
||||||
|
|
||||||
print_integer(putc, int_part, format);
|
print_integer(putc, int_part, format);
|
||||||
|
|
||||||
if (format.percision > 0)
|
if (format.percision > 0)
|
||||||
putc('.');
|
putc('.');
|
||||||
|
|
||||||
for (int i = 0; i < format.percision; i++)
|
for (int i = 0; i < format.percision; i++)
|
||||||
{
|
{
|
||||||
frac_part *= format.base;
|
frac_part *= format.base;
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace BAN
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
if (*this)
|
if (*this)
|
||||||
|
@ -145,4 +145,4 @@ namespace BAN
|
||||||
alignas(CallableBase) uint8_t m_storage[m_size] { 0 };
|
alignas(CallableBase) uint8_t m_storage[m_size] { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,4 @@ namespace BAN
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace BAN
|
||||||
ErrorOr<void> rebucket(size_type);
|
ErrorOr<void> rebucket(size_type);
|
||||||
LinkedList<Entry>& get_bucket(const Key&);
|
LinkedList<Entry>& get_bucket(const Key&);
|
||||||
const LinkedList<Entry>& get_bucket(const Key&) const;
|
const LinkedList<Entry>& get_bucket(const Key&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<LinkedList<Entry>> m_buckets;
|
Vector<LinkedList<Entry>> m_buckets;
|
||||||
size_type m_size = 0;
|
size_type m_size = 0;
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace BAN
|
||||||
using size_type = size_t;
|
using size_type = size_t;
|
||||||
using iterator = IteratorDouble<T, Vector, LinkedList, HashSet>;
|
using iterator = IteratorDouble<T, Vector, LinkedList, HashSet>;
|
||||||
using const_iterator = ConstIteratorDouble<T, Vector, LinkedList, HashSet>;
|
using const_iterator = ConstIteratorDouble<T, Vector, LinkedList, HashSet>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HashSet() = default;
|
HashSet() = default;
|
||||||
HashSet(const HashSet&);
|
HashSet(const HashSet&);
|
||||||
|
@ -206,4 +206,4 @@ namespace BAN
|
||||||
template<typename T, typename HASH = hash<T>>
|
template<typename T, typename HASH = hash<T>>
|
||||||
using HashSetUnstable = HashSet<T, HASH, false>;
|
using HashSetUnstable = HashSet<T, HASH, false>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,4 @@ namespace BAN
|
||||||
Break
|
Break
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ namespace BAN
|
||||||
{
|
{
|
||||||
Node* node = (Node*)BAN::allocator(sizeof(Node));
|
Node* node = (Node*)BAN::allocator(sizeof(Node));
|
||||||
if (node == nullptr)
|
if (node == nullptr)
|
||||||
return Error::from_errno(ENOMEM);
|
return Error::from_errno(ENOMEM);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,4 +396,4 @@ namespace BAN
|
||||||
return m_current;
|
return m_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,4 +119,4 @@ namespace BAN::Math
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace BAN
|
||||||
Optional<T>::Optional(const T& value)
|
Optional<T>::Optional(const T& value)
|
||||||
: m_has_value(true)
|
: m_has_value(true)
|
||||||
{
|
{
|
||||||
new (m_storage) T(value);
|
new (m_storage) T(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -192,4 +192,4 @@ namespace BAN
|
||||||
m_has_value = false;
|
m_has_value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,4 +225,4 @@ namespace BAN
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,4 @@ namespace BAN
|
||||||
bool m_enabled { true };
|
bool m_enabled { true };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace BAN::sort
|
||||||
|
|
||||||
if (parent == 0)
|
if (parent == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
parent--;
|
parent--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,4 +131,4 @@ namespace BAN
|
||||||
return Span(m_data + start, length);
|
return Span(m_data + start, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace BAN
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
size_type size() const;
|
size_type size() const;
|
||||||
|
|
||||||
const char* data() const;
|
const char* data() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -34,4 +34,4 @@ namespace BAN::Formatter
|
||||||
print(putc, "{} {} {} {2}:{2}:{2} GMT+0 {4}", week_days[time.week_day], months[time.month], time.day, time.hour, time.minute, time.second, time.year);
|
print(putc, "{} {} {} {2}:{2}:{2} GMT+0 {4}", week_days[time.week_day], months[time.month], time.day, time.hour, time.minute, time.second, time.year);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,4 +102,4 @@ namespace BAN
|
||||||
template<typename T> struct equal { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs == rhs; } };
|
template<typename T> struct equal { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs == rhs; } };
|
||||||
template<typename T> struct greater { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs > rhs; } };
|
template<typename T> struct greater { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs > rhs; } };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace BAN::UTF8
|
||||||
for (uint32_t i = 1; i < length; i++)
|
for (uint32_t i = 1; i < length; i++)
|
||||||
if ((bytes[i] & 0xC0) != 0x80)
|
if ((bytes[i] & 0xC0) != 0x80)
|
||||||
return UTF8::invalid;
|
return UTF8::invalid;
|
||||||
|
|
||||||
switch (length)
|
switch (length)
|
||||||
{
|
{
|
||||||
case 1: return ((bytes[0] & 0x80) != 0x00) ? UTF8::invalid : bytes[0];
|
case 1: return ((bytes[0] & 0x80) != 0x00) ? UTF8::invalid : bytes[0];
|
||||||
|
@ -78,4 +78,4 @@ namespace BAN::UTF8
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace BAN
|
||||||
T* operator->()
|
T* operator->()
|
||||||
{
|
{
|
||||||
ASSERT(m_pointer);
|
ASSERT(m_pointer);
|
||||||
return m_pointer;
|
return m_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const T* operator->() const
|
const T* operator->() const
|
||||||
|
@ -95,4 +95,4 @@ namespace BAN
|
||||||
friend class UniqPtr;
|
friend class UniqPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,14 +140,14 @@ namespace BAN
|
||||||
Variant(T&& value) requires (can_have<T>() && !is_lvalue_reference_v<T>)
|
Variant(T&& value) requires (can_have<T>() && !is_lvalue_reference_v<T>)
|
||||||
: m_index(detail::index<T, Ts...>())
|
: m_index(detail::index<T, Ts...>())
|
||||||
{
|
{
|
||||||
new (m_storage) T(move(value));
|
new (m_storage) T(move(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Variant(const T& value) requires (can_have<T>() && !is_lvalue_reference_v<T>)
|
Variant(const T& value) requires (can_have<T>() && !is_lvalue_reference_v<T>)
|
||||||
: m_index(detail::index<T, Ts...>())
|
: m_index(detail::index<T, Ts...>())
|
||||||
{
|
{
|
||||||
new (m_storage) T(value);
|
new (m_storage) T(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Variant()
|
~Variant()
|
||||||
|
@ -292,4 +292,4 @@ namespace BAN
|
||||||
size_t m_index { invalid_index() };
|
size_t m_index { invalid_index() };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace BAN
|
||||||
ErrorOr<void> emplace(size_type, Args&&...);
|
ErrorOr<void> emplace(size_type, Args&&...);
|
||||||
ErrorOr<void> insert(size_type, T&&);
|
ErrorOr<void> insert(size_type, T&&);
|
||||||
ErrorOr<void> insert(size_type, const T&);
|
ErrorOr<void> insert(size_type, const T&);
|
||||||
|
|
||||||
iterator begin() { return iterator(m_data); }
|
iterator begin() { return iterator(m_data); }
|
||||||
iterator end() { return iterator(m_data + m_size); }
|
iterator end() { return iterator(m_data + m_size); }
|
||||||
const_iterator begin() const { return const_iterator(m_data); }
|
const_iterator begin() const { return const_iterator(m_data); }
|
||||||
|
|
|
@ -104,4 +104,4 @@ namespace BAN
|
||||||
friend class Weakable<T>;
|
friend class Weakable<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace LibELF
|
||||||
return BAN::Error::from_errno(EINVAL);
|
return BAN::Error::from_errno(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_data[EI_MAG0] != ELFMAG0 ||
|
if (m_data[EI_MAG0] != ELFMAG0 ||
|
||||||
m_data[EI_MAG1] != ELFMAG1 ||
|
m_data[EI_MAG1] != ELFMAG1 ||
|
||||||
m_data[EI_MAG2] != ELFMAG2 ||
|
m_data[EI_MAG2] != ELFMAG2 ||
|
||||||
m_data[EI_MAG3] != ELFMAG3)
|
m_data[EI_MAG3] != ELFMAG3)
|
||||||
|
@ -252,7 +252,7 @@ namespace LibELF
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
(void)header;
|
(void)header;
|
||||||
return true;
|
return true;
|
||||||
|
@ -375,7 +375,7 @@ namespace LibELF
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
(void)header;
|
(void)header;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace LibELF
|
||||||
size_t nread = TRY(m_inode->read(0, BAN::ByteSpan::from(m_file_header)));
|
size_t nread = TRY(m_inode->read(0, BAN::ByteSpan::from(m_file_header)));
|
||||||
ASSERT(nread == sizeof(m_file_header));
|
ASSERT(nread == sizeof(m_file_header));
|
||||||
|
|
||||||
if (m_file_header.e_ident[EI_MAG0] != ELFMAG0 ||
|
if (m_file_header.e_ident[EI_MAG0] != ELFMAG0 ||
|
||||||
m_file_header.e_ident[EI_MAG1] != ELFMAG1 ||
|
m_file_header.e_ident[EI_MAG1] != ELFMAG1 ||
|
||||||
m_file_header.e_ident[EI_MAG2] != ELFMAG2 ||
|
m_file_header.e_ident[EI_MAG2] != ELFMAG2 ||
|
||||||
m_file_header.e_ident[EI_MAG3] != ELFMAG3)
|
m_file_header.e_ident[EI_MAG3] != ELFMAG3)
|
||||||
|
@ -93,7 +93,7 @@ namespace LibELF
|
||||||
if (m_file_header.e_ident[EI_CLASS] != ELFCLASS64)
|
if (m_file_header.e_ident[EI_CLASS] != ELFCLASS64)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
dprintln("Not in native format");
|
dprintln("Not in native format");
|
||||||
return BAN::Error::from_errno(EINVAL);
|
return BAN::Error::from_errno(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,13 +240,13 @@ namespace LibELF
|
||||||
m_physical_page_count++;
|
m_physical_page_count++;
|
||||||
|
|
||||||
memset((void*)vaddr, 0x00, PAGE_SIZE);
|
memset((void*)vaddr, 0x00, PAGE_SIZE);
|
||||||
|
|
||||||
if (vaddr / PAGE_SIZE < BAN::Math::div_round_up<size_t>(program_header.p_vaddr + program_header.p_filesz, PAGE_SIZE))
|
if (vaddr / PAGE_SIZE < BAN::Math::div_round_up<size_t>(program_header.p_vaddr + program_header.p_filesz, PAGE_SIZE))
|
||||||
{
|
{
|
||||||
size_t vaddr_offset = 0;
|
size_t vaddr_offset = 0;
|
||||||
if (vaddr < program_header.p_vaddr)
|
if (vaddr < program_header.p_vaddr)
|
||||||
vaddr_offset = program_header.p_vaddr - vaddr;
|
vaddr_offset = program_header.p_vaddr - vaddr;
|
||||||
|
|
||||||
size_t file_offset = 0;
|
size_t file_offset = 0;
|
||||||
if (vaddr > program_header.p_vaddr)
|
if (vaddr > program_header.p_vaddr)
|
||||||
file_offset = vaddr - program_header.p_vaddr;
|
file_offset = vaddr - program_header.p_vaddr;
|
||||||
|
@ -267,7 +267,7 @@ namespace LibELF
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BAN::ErrorOr<BAN::UniqPtr<LoadableELF>> LoadableELF::clone(Kernel::PageTable& new_page_table)
|
BAN::ErrorOr<BAN::UniqPtr<LoadableELF>> LoadableELF::clone(Kernel::PageTable& new_page_table)
|
||||||
{
|
{
|
||||||
auto* elf_ptr = new LoadableELF(new_page_table, m_inode);
|
auto* elf_ptr = new LoadableELF(new_page_table, m_inode);
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace LibELF
|
||||||
{}
|
{}
|
||||||
//#endif
|
//#endif
|
||||||
BAN::ErrorOr<void> load();
|
BAN::ErrorOr<void> load();
|
||||||
|
|
||||||
bool parse_elf64_file_header(const Elf64FileHeader&);
|
bool parse_elf64_file_header(const Elf64FileHeader&);
|
||||||
bool parse_elf64_program_header(const Elf64ProgramHeader&);
|
bool parse_elf64_program_header(const Elf64ProgramHeader&);
|
||||||
bool parse_elf64_section_header(const Elf64SectionHeader&);
|
bool parse_elf64_section_header(const Elf64SectionHeader&);
|
||||||
|
@ -86,4 +86,4 @@ namespace LibELF
|
||||||
//#endif
|
//#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,4 +54,4 @@ namespace LibELF
|
||||||
bool m_loaded { false };
|
bool m_loaded { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,4 +183,4 @@ namespace LibELF
|
||||||
using ElfNativeProgramHeader = Elf64ProgramHeader;
|
using ElfNativeProgramHeader = Elf64ProgramHeader;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,4 +137,4 @@ namespace LibELF
|
||||||
PF_MASKPROC = 0xFF000000,
|
PF_MASKPROC = 0xFF000000,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ check_a20:
|
||||||
movb $0xFF, %ds:(%si)
|
movb $0xFF, %ds:(%si)
|
||||||
|
|
||||||
cmpb $0xFF, %es:(%di)
|
cmpb $0xFF, %es:(%di)
|
||||||
|
|
||||||
pop %ax
|
pop %ax
|
||||||
movb %al, %ds:(%si)
|
movb %al, %ds:(%si)
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ check_a20:
|
||||||
|
|
||||||
movw $0, %ax
|
movw $0, %ax
|
||||||
je .check_a20_done
|
je .check_a20_done
|
||||||
|
|
||||||
movw $1, %ax
|
movw $1, %ax
|
||||||
|
|
||||||
.check_a20_done:
|
.check_a20_done:
|
||||||
|
@ -68,7 +68,7 @@ enable_a20_ps2:
|
||||||
call .enable_a20_ps2_wait1
|
call .enable_a20_ps2_wait1
|
||||||
movb $0xD0, %al
|
movb $0xD0, %al
|
||||||
outb %al, $0x64
|
outb %al, $0x64
|
||||||
|
|
||||||
call .enable_a20_ps2_wait2
|
call .enable_a20_ps2_wait2
|
||||||
inb $0x60, %al
|
inb $0x60, %al
|
||||||
pushw %ax
|
pushw %ax
|
||||||
|
@ -77,7 +77,7 @@ enable_a20_ps2:
|
||||||
call .enable_a20_ps2_wait1
|
call .enable_a20_ps2_wait1
|
||||||
movb $0xD1, %al
|
movb $0xD1, %al
|
||||||
outb %al, $0x64
|
outb %al, $0x64
|
||||||
|
|
||||||
call .enable_a20_ps2_wait1
|
call .enable_a20_ps2_wait1
|
||||||
popw %ax
|
popw %ax
|
||||||
orw $2, %ax
|
orw $2, %ax
|
||||||
|
|
|
@ -418,7 +418,7 @@ find_root_partition:
|
||||||
decl %ecx
|
decl %ecx
|
||||||
subl %ecx, %eax
|
subl %ecx, %eax
|
||||||
sbbl $0, %ebx
|
sbbl $0, %ebx
|
||||||
|
|
||||||
# ecx: min(partition count, 0xFFFFFFFF)
|
# ecx: min(partition count, 0xFFFFFFFF)
|
||||||
movl $0xFFFFFFFF, %edx
|
movl $0xFFFFFFFF, %edx
|
||||||
movl %eax, %ecx
|
movl %eax, %ecx
|
||||||
|
|
|
@ -14,4 +14,4 @@ SECTIONS
|
||||||
|
|
||||||
. = ALIGN(512);
|
. = ALIGN(512);
|
||||||
.bss : { *(.bss) }
|
.bss : { *(.bss) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,4 +42,4 @@ int main(int argc, char** argv)
|
||||||
std::cout << "bootloader installed" << std::endl;
|
std::cout << "bootloader installed" << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Kernel::GDT
|
||||||
uint8_t flags : 4;
|
uint8_t flags : 4;
|
||||||
uint8_t base3;
|
uint8_t base3;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32_t low;
|
uint32_t low;
|
||||||
|
@ -101,7 +101,7 @@ namespace Kernel::GDT
|
||||||
{
|
{
|
||||||
s_tss = new TaskStateSegment();
|
s_tss = new TaskStateSegment();
|
||||||
ASSERT(s_tss);
|
ASSERT(s_tss);
|
||||||
|
|
||||||
memset(s_tss, 0x00, sizeof(TaskStateSegment));
|
memset(s_tss, 0x00, sizeof(TaskStateSegment));
|
||||||
s_tss->ss0 = 0x10;
|
s_tss->ss0 = 0x10;
|
||||||
s_tss->esp0 = (uintptr_t)g_boot_stack_top;
|
s_tss->esp0 = (uintptr_t)g_boot_stack_top;
|
||||||
|
@ -127,7 +127,7 @@ namespace Kernel::GDT
|
||||||
void initialize()
|
void initialize()
|
||||||
{
|
{
|
||||||
constexpr uint32_t descriptor_count = 6;
|
constexpr uint32_t descriptor_count = 6;
|
||||||
s_gdt = new SegmentDescriptor[descriptor_count];
|
s_gdt = new SegmentDescriptor[descriptor_count];
|
||||||
ASSERT(s_gdt);
|
ASSERT(s_gdt);
|
||||||
|
|
||||||
s_gdtr.address = (uint64_t)s_gdt;
|
s_gdtr.address = (uint64_t)s_gdt;
|
||||||
|
@ -144,4 +144,4 @@ namespace Kernel::GDT
|
||||||
flush_tss(0x28);
|
flush_tss(0x28);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace IDT
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintln("Spurious irq");
|
dprintln("Spurious irq");
|
||||||
return;
|
return;
|
||||||
found:
|
found:
|
||||||
if (s_irq_handlers[irq])
|
if (s_irq_handlers[irq])
|
||||||
s_irq_handlers[irq]();
|
s_irq_handlers[irq]();
|
||||||
|
@ -174,7 +174,7 @@ found:
|
||||||
"addl $16, %esp;"
|
"addl $16, %esp;"
|
||||||
"popw %es;"
|
"popw %es;"
|
||||||
"popw %ds;"
|
"popw %ds;"
|
||||||
|
|
||||||
// NOTE: following instructions are same as in 'popa', except we skip eax
|
// NOTE: following instructions are same as in 'popa', except we skip eax
|
||||||
// since it holds the return value of the syscall.
|
// since it holds the return value of the syscall.
|
||||||
"popl %edi;"
|
"popl %edi;"
|
||||||
|
@ -185,7 +185,7 @@ found:
|
||||||
"popl %edx;"
|
"popl %edx;"
|
||||||
"popl %ecx;"
|
"popl %ecx;"
|
||||||
"addl $4, %esp;"
|
"addl $4, %esp;"
|
||||||
|
|
||||||
"iret;"
|
"iret;"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -267,4 +267,4 @@ found:
|
||||||
flush_idt();
|
flush_idt();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
if (s_instance == nullptr)
|
if (s_instance == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Here we copy the s_instances paging structs since they are
|
// Here we copy the s_instances paging structs since they are
|
||||||
// global for every process
|
// global for every process
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace Kernel
|
||||||
|
|
||||||
uint64_t* pdpt = (uint64_t*)kmalloc(sizeof(uint64_t) * 4, 32);
|
uint64_t* pdpt = (uint64_t*)kmalloc(sizeof(uint64_t) * 4, 32);
|
||||||
ASSERT(pdpt);
|
ASSERT(pdpt);
|
||||||
|
|
||||||
for (uint32_t pdpte = 0; pdpte < 4; pdpte++)
|
for (uint32_t pdpte = 0; pdpte < 4; pdpte++)
|
||||||
{
|
{
|
||||||
if (!(global_pdpt[pdpte] & Flags::Present))
|
if (!(global_pdpt[pdpte] & Flags::Present))
|
||||||
|
|
|
@ -16,4 +16,4 @@ spinlock_lock_asm:
|
||||||
spinlock_unlock_asm:
|
spinlock_unlock_asm:
|
||||||
movl 4(%esp), %eax
|
movl 4(%esp), %eax
|
||||||
movl $0, (%eax)
|
movl $0, (%eax)
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -25,4 +25,4 @@ SECTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
g_kernel_end = .;
|
g_kernel_end = .;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Kernel::GDT
|
||||||
uint8_t flags : 4;
|
uint8_t flags : 4;
|
||||||
uint8_t base3;
|
uint8_t base3;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32_t low;
|
uint32_t low;
|
||||||
|
@ -81,7 +81,7 @@ namespace Kernel::GDT
|
||||||
{
|
{
|
||||||
memset(&s_tss, 0x00, sizeof(TaskStateSegment));
|
memset(&s_tss, 0x00, sizeof(TaskStateSegment));
|
||||||
s_tss.iopb = sizeof(TaskStateSegment);
|
s_tss.iopb = sizeof(TaskStateSegment);
|
||||||
|
|
||||||
uint64_t base = (uint64_t)&s_tss;
|
uint64_t base = (uint64_t)&s_tss;
|
||||||
|
|
||||||
write_entry(s_tss_offset, (uint32_t)base, sizeof(TaskStateSegment), 0x89, 0x0);
|
write_entry(s_tss_offset, (uint32_t)base, sizeof(TaskStateSegment), 0x89, 0x0);
|
||||||
|
@ -122,4 +122,4 @@ namespace Kernel::GDT
|
||||||
flush_tss();
|
flush_tss();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace Kernel::IDT
|
||||||
uint32_t reserved2 : 16;
|
uint32_t reserved2 : 16;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
static_assert(sizeof(PageFaultError) == 4);
|
static_assert(sizeof(PageFaultError) == 4);
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ namespace Kernel::IDT
|
||||||
break;
|
break;
|
||||||
case ISR::PageFault:
|
case ISR::PageFault:
|
||||||
signal = SIGSEGV;
|
signal = SIGSEGV;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dwarnln("Unhandled exception");
|
dwarnln("Unhandled exception");
|
||||||
signal = SIGABRT;
|
signal = SIGABRT;
|
||||||
|
@ -305,7 +305,7 @@ namespace Kernel::IDT
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(Thread::current().state() != Thread::State::Terminated);
|
ASSERT(Thread::current().state() != Thread::State::Terminated);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace Kernel
|
||||||
s_global_pml4e = V2P(allocate_zeroed_page_aligned_page());
|
s_global_pml4e = V2P(allocate_zeroed_page_aligned_page());
|
||||||
|
|
||||||
m_highest_paging_struct = V2P(allocate_zeroed_page_aligned_page());
|
m_highest_paging_struct = V2P(allocate_zeroed_page_aligned_page());
|
||||||
|
|
||||||
uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct);
|
uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct);
|
||||||
pml4[511] = s_global_pml4e;
|
pml4[511] = s_global_pml4e;
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ namespace Kernel
|
||||||
ASSERT(vaddr % PAGE_SIZE == 0);
|
ASSERT(vaddr % PAGE_SIZE == 0);
|
||||||
|
|
||||||
size_t page_count = range_page_count(vaddr, size);
|
size_t page_count = range_page_count(vaddr, size);
|
||||||
|
|
||||||
LockGuard _(m_lock);
|
LockGuard _(m_lock);
|
||||||
for (size_t page = 0; page < page_count; page++)
|
for (size_t page = 0; page < page_count; page++)
|
||||||
map_page_at(paddr + page * PAGE_SIZE, vaddr + page * PAGE_SIZE, flags);
|
map_page_at(paddr + page * PAGE_SIZE, vaddr + page * PAGE_SIZE, flags);
|
||||||
|
@ -453,7 +453,7 @@ namespace Kernel
|
||||||
uint64_t pdpte = (uc_vaddr >> 30) & 0x1FF;
|
uint64_t pdpte = (uc_vaddr >> 30) & 0x1FF;
|
||||||
uint64_t pde = (uc_vaddr >> 21) & 0x1FF;
|
uint64_t pde = (uc_vaddr >> 21) & 0x1FF;
|
||||||
uint64_t pte = (uc_vaddr >> 12) & 0x1FF;
|
uint64_t pte = (uc_vaddr >> 12) & 0x1FF;
|
||||||
|
|
||||||
LockGuard _(m_lock);
|
LockGuard _(m_lock);
|
||||||
|
|
||||||
uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct);
|
uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct);
|
||||||
|
@ -533,7 +533,7 @@ namespace Kernel
|
||||||
const uint16_t e_pdpte = (uc_vaddr_end >> 30) & 0x1FF;
|
const uint16_t e_pdpte = (uc_vaddr_end >> 30) & 0x1FF;
|
||||||
const uint16_t e_pde = (uc_vaddr_end >> 21) & 0x1FF;
|
const uint16_t e_pde = (uc_vaddr_end >> 21) & 0x1FF;
|
||||||
const uint16_t e_pte = (uc_vaddr_end >> 12) & 0x1FF;
|
const uint16_t e_pte = (uc_vaddr_end >> 12) & 0x1FF;
|
||||||
|
|
||||||
LockGuard _(m_lock);
|
LockGuard _(m_lock);
|
||||||
|
|
||||||
// Try to find free page that can be mapped without
|
// Try to find free page that can be mapped without
|
||||||
|
@ -714,7 +714,7 @@ namespace Kernel
|
||||||
|
|
||||||
if (!(pt[pte] & Flags::Used))
|
if (!(pt[pte] & Flags::Used))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (start == 0)
|
if (start == 0)
|
||||||
{
|
{
|
||||||
flags = parse_flags(pt[pte]);
|
flags = parse_flags(pt[pte]);
|
||||||
|
|
|
@ -192,4 +192,4 @@ syscall_asm:
|
||||||
addq $8, %rsp
|
addq $8, %rsp
|
||||||
popaq_no_rax
|
popaq_no_rax
|
||||||
addq $8, %rsp
|
addq $8, %rsp
|
||||||
iretq
|
iretq
|
||||||
|
|
|
@ -35,4 +35,4 @@ SECTIONS
|
||||||
*(.bss)
|
*(.bss)
|
||||||
}
|
}
|
||||||
g_kernel_end = .;
|
g_kernel_end = .;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ void __cxa_finalize(void *f)
|
||||||
* TODO:
|
* TODO:
|
||||||
* Note well, however, that deleting a function from here that contains a __dso_handle
|
* Note well, however, that deleting a function from here that contains a __dso_handle
|
||||||
* means that one link to a shared object file has been terminated. In other words,
|
* means that one link to a shared object file has been terminated. In other words,
|
||||||
* We should monitor this list (optional, of course), since it tells us how many links to
|
* We should monitor this list (optional, of course), since it tells us how many links to
|
||||||
* an object file exist at runtime in a particular application. This can be used to tell
|
* an object file exist at runtime in a particular application. This can be used to tell
|
||||||
* when a shared object is no longer in use. It is one of many methods, however.
|
* when a shared object is no longer in use. It is one of many methods, however.
|
||||||
**/
|
**/
|
||||||
//You may insert a prinf() here to tell you whether or not the function gets called. Testing
|
//You may insert a prinf() here to tell you whether or not the function gets called. Testing
|
||||||
|
@ -59,7 +59,7 @@ void __cxa_finalize(void *f)
|
||||||
/* ^^^ That if statement is a safeguard...
|
/* ^^^ That if statement is a safeguard...
|
||||||
* To make sure we don't call any entries that have already been called and unset at runtime.
|
* To make sure we don't call any entries that have already been called and unset at runtime.
|
||||||
* Those will contain a value of 0, and calling a function with value 0
|
* Those will contain a value of 0, and calling a function with value 0
|
||||||
* will cause undefined behaviour. Remember that linear address 0,
|
* will cause undefined behaviour. Remember that linear address 0,
|
||||||
* in a non-virtual address space (physical) contains the IVT and BDA.
|
* in a non-virtual address space (physical) contains the IVT and BDA.
|
||||||
*
|
*
|
||||||
* In a virtual environment, the kernel will receive a page fault, and then probably
|
* In a virtual environment, the kernel will receive a page fault, and then probably
|
||||||
|
@ -92,7 +92,7 @@ void __cxa_finalize(void *f)
|
||||||
**/
|
**/
|
||||||
if (__atexit_funcs[i].destructor_func == f)
|
if (__atexit_funcs[i].destructor_func == f)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Note that in the next line, not every destructor function is a class destructor.
|
* Note that in the next line, not every destructor function is a class destructor.
|
||||||
* It is perfectly legal to register a non class destructor function as a simple cleanup
|
* It is perfectly legal to register a non class destructor function as a simple cleanup
|
||||||
* function to be called on program termination, in which case, it would not NEED an
|
* function to be called on program termination, in which case, it would not NEED an
|
||||||
|
@ -113,7 +113,7 @@ void __cxa_finalize(void *f)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace __cxxabiv1
|
namespace __cxxabiv1
|
||||||
{
|
{
|
||||||
/* guard variables */
|
/* guard variables */
|
||||||
static Kernel::SpinLock s_spin_lock;
|
static Kernel::SpinLock s_spin_lock;
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace Kernel
|
||||||
|
|
||||||
SDTHeader* as_header() { return (SDTHeader*)vaddr; }
|
SDTHeader* as_header() { return (SDTHeader*)vaddr; }
|
||||||
};
|
};
|
||||||
BAN::Vector<MappedPage> m_mapped_headers;
|
BAN::Vector<MappedPage> m_mapped_headers;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ namespace BAN::Formatter
|
||||||
{
|
{
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void print_argument(F putc, const Kernel::ACPI::SDTHeader& header, const ValueFormat& format)
|
void print_argument(F putc, const Kernel::ACPI::SDTHeader& header, const ValueFormat& format)
|
||||||
{
|
{
|
||||||
putc(header.signature[0]);
|
putc(header.signature[0]);
|
||||||
putc(header.signature[1]);
|
putc(header.signature[1]);
|
||||||
putc(header.signature[2]);
|
putc(header.signature[2]);
|
||||||
|
|
|
@ -18,4 +18,4 @@ namespace Kernel::API
|
||||||
DirectoryEntry array[];
|
DirectoryEntry array[];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Kernel
|
||||||
BAN::Vector<Processor> m_processors;
|
BAN::Vector<Processor> m_processors;
|
||||||
Kernel::paddr_t m_local_apic_paddr = 0;
|
Kernel::paddr_t m_local_apic_paddr = 0;
|
||||||
Kernel::vaddr_t m_local_apic_vaddr = 0;
|
Kernel::vaddr_t m_local_apic_vaddr = 0;
|
||||||
BAN::Vector<IOAPIC> m_io_apics;
|
BAN::Vector<IOAPIC> m_io_apics;
|
||||||
uint8_t m_irq_overrides[0x100] {};
|
uint8_t m_irq_overrides[0x100] {};
|
||||||
uint8_t m_reserved_gsis[0x100 / 8] {};
|
uint8_t m_reserved_gsis[0x100 / 8] {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,38 +7,38 @@ namespace CPUID
|
||||||
|
|
||||||
enum Features : uint32_t
|
enum Features : uint32_t
|
||||||
{
|
{
|
||||||
ECX_SSE3 = (uint32_t)1 << 0,
|
ECX_SSE3 = (uint32_t)1 << 0,
|
||||||
ECX_PCLMULQDQ = (uint32_t)1 << 1,
|
ECX_PCLMULQDQ = (uint32_t)1 << 1,
|
||||||
ECX_DTES64 = (uint32_t)1 << 2,
|
ECX_DTES64 = (uint32_t)1 << 2,
|
||||||
ECX_MONITOR = (uint32_t)1 << 3,
|
ECX_MONITOR = (uint32_t)1 << 3,
|
||||||
ECX_DS_CPL = (uint32_t)1 << 4,
|
ECX_DS_CPL = (uint32_t)1 << 4,
|
||||||
ECX_VMX = (uint32_t)1 << 5,
|
ECX_VMX = (uint32_t)1 << 5,
|
||||||
ECX_SMX = (uint32_t)1 << 6,
|
ECX_SMX = (uint32_t)1 << 6,
|
||||||
ECX_EST = (uint32_t)1 << 7,
|
ECX_EST = (uint32_t)1 << 7,
|
||||||
ECX_TM2 = (uint32_t)1 << 8,
|
ECX_TM2 = (uint32_t)1 << 8,
|
||||||
ECX_SSSE3 = (uint32_t)1 << 9,
|
ECX_SSSE3 = (uint32_t)1 << 9,
|
||||||
ECX_CNTX_ID = (uint32_t)1 << 10,
|
ECX_CNTX_ID = (uint32_t)1 << 10,
|
||||||
ECX_SDBG = (uint32_t)1 << 11,
|
ECX_SDBG = (uint32_t)1 << 11,
|
||||||
ECX_FMA = (uint32_t)1 << 12,
|
ECX_FMA = (uint32_t)1 << 12,
|
||||||
ECX_CX16 = (uint32_t)1 << 13,
|
ECX_CX16 = (uint32_t)1 << 13,
|
||||||
ECX_XTPR = (uint32_t)1 << 14,
|
ECX_XTPR = (uint32_t)1 << 14,
|
||||||
ECX_PDCM = (uint32_t)1 << 15,
|
ECX_PDCM = (uint32_t)1 << 15,
|
||||||
ECX_PCID = (uint32_t)1 << 17,
|
ECX_PCID = (uint32_t)1 << 17,
|
||||||
ECX_DCA = (uint32_t)1 << 18,
|
ECX_DCA = (uint32_t)1 << 18,
|
||||||
ECX_SSE4_1 = (uint32_t)1 << 19,
|
ECX_SSE4_1 = (uint32_t)1 << 19,
|
||||||
ECX_SSE4_2 = (uint32_t)1 << 20,
|
ECX_SSE4_2 = (uint32_t)1 << 20,
|
||||||
ECX_X2APIC = (uint32_t)1 << 21,
|
ECX_X2APIC = (uint32_t)1 << 21,
|
||||||
ECX_MOVBE = (uint32_t)1 << 22,
|
ECX_MOVBE = (uint32_t)1 << 22,
|
||||||
ECX_POPCNT = (uint32_t)1 << 23,
|
ECX_POPCNT = (uint32_t)1 << 23,
|
||||||
ECX_TSC_DEADLINE = (uint32_t)1 << 24,
|
ECX_TSC_DEADLINE = (uint32_t)1 << 24,
|
||||||
ECX_AES = (uint32_t)1 << 25,
|
ECX_AES = (uint32_t)1 << 25,
|
||||||
ECX_XSAVE = (uint32_t)1 << 26,
|
ECX_XSAVE = (uint32_t)1 << 26,
|
||||||
ECX_OSXSAVE = (uint32_t)1 << 27,
|
ECX_OSXSAVE = (uint32_t)1 << 27,
|
||||||
ECX_AVX = (uint32_t)1 << 28,
|
ECX_AVX = (uint32_t)1 << 28,
|
||||||
ECX_F16C = (uint32_t)1 << 29,
|
ECX_F16C = (uint32_t)1 << 29,
|
||||||
ECX_RDRND = (uint32_t)1 << 30,
|
ECX_RDRND = (uint32_t)1 << 30,
|
||||||
ECX_HYPERVISOR = (uint32_t)1 << 31,
|
ECX_HYPERVISOR = (uint32_t)1 << 31,
|
||||||
|
|
||||||
EDX_FPU = (uint32_t)1 << 0,
|
EDX_FPU = (uint32_t)1 << 0,
|
||||||
EDX_VME = (uint32_t)1 << 1,
|
EDX_VME = (uint32_t)1 << 1,
|
||||||
EDX_DE = (uint32_t)1 << 2,
|
EDX_DE = (uint32_t)1 << 2,
|
||||||
|
@ -79,4 +79,4 @@ namespace CPUID
|
||||||
bool is_64_bit();
|
bool is_64_bit();
|
||||||
bool has_nxe();
|
bool has_nxe();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,4 @@ namespace Kernel
|
||||||
size_t m_flags;
|
size_t m_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,4 +61,4 @@ namespace Debug
|
||||||
static void lock();
|
static void lock();
|
||||||
static void unlock();
|
static void unlock();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,4 +52,4 @@ namespace Kernel
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,4 @@ namespace Kernel
|
||||||
friend class FramebufferMemoryRegion;
|
friend class FramebufferMemoryRegion;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,4 @@ namespace Kernel
|
||||||
const dev_t m_rdev;
|
const dev_t m_rdev;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,4 @@ namespace Kernel
|
||||||
const dev_t m_rdev;
|
const dev_t m_rdev;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,4 +33,4 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::StringView error_string(ErrorCode);
|
BAN::StringView error_string(ErrorCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Kernel
|
||||||
public:
|
public:
|
||||||
static void initialize();
|
static void initialize();
|
||||||
static DevFileSystem& get();
|
static DevFileSystem& get();
|
||||||
|
|
||||||
void initialize_device_updater();
|
void initialize_device_updater();
|
||||||
|
|
||||||
void add_device(BAN::RefPtr<Device>);
|
void add_device(BAN::RefPtr<Device>);
|
||||||
|
@ -39,4 +39,4 @@ namespace Kernel
|
||||||
volatile bool m_should_sync { false };
|
volatile bool m_should_sync { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,4 +259,4 @@ namespace Kernel::Ext2
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
m_used = false;
|
m_used = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size() const { return m_buffer.size(); }
|
size_t size() const { return m_buffer.size(); }
|
||||||
|
|
||||||
uint8_t* data() { return m_buffer.data(); }
|
uint8_t* data() { return m_buffer.data(); }
|
||||||
|
@ -44,7 +44,7 @@ namespace Kernel
|
||||||
bool& m_used;
|
bool& m_used;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BAN::ErrorOr<Ext2FS*> create(BAN::RefPtr<BlockDevice>);
|
static BAN::ErrorOr<Ext2FS*> create(BAN::RefPtr<BlockDevice>);
|
||||||
|
|
||||||
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_inode; }
|
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_inode; }
|
||||||
|
@ -120,4 +120,4 @@ namespace Kernel
|
||||||
friend class Ext2Inode;
|
friend class Ext2Inode;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Kernel
|
||||||
virtual BAN::ErrorOr<void> create_file_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
|
virtual BAN::ErrorOr<void> create_file_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
|
||||||
virtual BAN::ErrorOr<void> create_directory_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
|
virtual BAN::ErrorOr<void> create_directory_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
|
||||||
virtual BAN::ErrorOr<void> unlink_impl(BAN::StringView) override;
|
virtual BAN::ErrorOr<void> unlink_impl(BAN::StringView) override;
|
||||||
|
|
||||||
virtual BAN::ErrorOr<BAN::String> link_target_impl() override;
|
virtual BAN::ErrorOr<BAN::String> link_target_impl() override;
|
||||||
|
|
||||||
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
|
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
|
||||||
|
@ -81,4 +81,4 @@ namespace Kernel
|
||||||
friend class BAN::RefPtr<Ext2Inode>;
|
friend class BAN::RefPtr<Ext2Inode>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,4 @@ namespace Kernel
|
||||||
virtual BAN::RefPtr<Inode> root_inode() = 0;
|
virtual BAN::RefPtr<Inode> root_inode() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,4 +131,4 @@ namespace Kernel
|
||||||
friend class FileBackedRegion;
|
friend class FileBackedRegion;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,4 @@ namespace Kernel
|
||||||
uint32_t m_writing_count { 1 };
|
uint32_t m_writing_count { 1 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,4 @@ namespace Kernel
|
||||||
ProcFileSystem();
|
ProcFileSystem();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Kernel
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProcROInode(Process&, size_t (Process::*)(off_t, BAN::ByteSpan) const, TmpFileSystem&, const TmpInodeInfo&);
|
ProcROInode(Process&, size_t (Process::*)(off_t, BAN::ByteSpan) const, TmpFileSystem&, const TmpInodeInfo&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Process& m_process;
|
Process& m_process;
|
||||||
size_t (Process::*m_callback)(off_t, BAN::ByteSpan) const;
|
size_t (Process::*m_callback)(off_t, BAN::ByteSpan) const;
|
||||||
|
|
|
@ -177,4 +177,4 @@ namespace Kernel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,4 +44,4 @@ namespace Kernel
|
||||||
BAN::Vector<MountPoint> m_mount_points;
|
BAN::Vector<MountPoint> m_mount_points;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,4 +32,4 @@ namespace Kernel
|
||||||
uint32_t m_pitch = 0;
|
uint32_t m_pitch = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,4 +13,4 @@ namespace Kernel::GDT
|
||||||
void initialize();
|
void initialize();
|
||||||
void set_tss_stack(uintptr_t);
|
void set_tss_stack(uintptr_t);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,4 +10,4 @@ namespace Kernel::IDT
|
||||||
void initialize();
|
void initialize();
|
||||||
[[noreturn]] void force_triple_fault();
|
[[noreturn]] void force_triple_fault();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,4 +62,4 @@ namespace IO
|
||||||
outb(0x80, 0);
|
outb(0x80, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,4 +95,4 @@ namespace Kernel::Input
|
||||||
Key key_event_to_key(KeyEvent);
|
Key key_event_to_key(KeyEvent);
|
||||||
const char* key_to_utf8(Key key, uint16_t modifier);
|
const char* key_to_utf8(Key key, uint16_t modifier);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace Kernel::Input
|
||||||
MouseButtonEvent button_event;
|
MouseButtonEvent button_event;
|
||||||
MouseMoveEvent move_event;
|
MouseMoveEvent move_event;
|
||||||
MouseScrollEvent scroll_event;
|
MouseScrollEvent scroll_event;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,4 +53,4 @@ namespace Kernel
|
||||||
|
|
||||||
bool interrupts_enabled();
|
bool interrupts_enabled();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,4 @@ namespace Kernel
|
||||||
uint64_t ss;
|
uint64_t ss;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel
|
||||||
LockGuard(Lock& lock)
|
LockGuard(Lock& lock)
|
||||||
: m_lock(lock)
|
: m_lock(lock)
|
||||||
{
|
{
|
||||||
m_lock.lock();
|
m_lock.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
~LockGuard()
|
~LockGuard()
|
||||||
|
@ -27,4 +27,4 @@ namespace Kernel
|
||||||
Lock& m_lock;
|
Lock& m_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,4 +46,4 @@ namespace MMIO
|
||||||
return *(volatile uint64_t*)addr;
|
return *(volatile uint64_t*)addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
class DMARegion
|
class DMARegion
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -27,4 +27,4 @@ namespace Kernel
|
||||||
const paddr_t m_paddr;
|
const paddr_t m_paddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,4 +46,4 @@ namespace Kernel
|
||||||
BAN::RefPtr<SharedFileData> m_shared_data;
|
BAN::RefPtr<SharedFileData> m_shared_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
BAN_NON_COPYABLE(MemoryBackedRegion);
|
BAN_NON_COPYABLE(MemoryBackedRegion);
|
||||||
BAN_NON_MOVABLE(MemoryBackedRegion);
|
BAN_NON_MOVABLE(MemoryBackedRegion);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BAN::ErrorOr<BAN::UniqPtr<MemoryBackedRegion>> create(PageTable&, size_t size, AddressRange, Type, PageTable::flags_t);
|
static BAN::ErrorOr<BAN::UniqPtr<MemoryBackedRegion>> create(PageTable&, size_t size, AddressRange, Type, PageTable::flags_t);
|
||||||
~MemoryBackedRegion();
|
~MemoryBackedRegion();
|
||||||
|
@ -29,4 +29,4 @@ namespace Kernel
|
||||||
MemoryBackedRegion(PageTable&, size_t size, Type, PageTable::flags_t);
|
MemoryBackedRegion(PageTable&, size_t size, Type, PageTable::flags_t);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace Kernel
|
||||||
BAN::ErrorOr<bool> allocate_page_containing(vaddr_t address);
|
BAN::ErrorOr<bool> allocate_page_containing(vaddr_t address);
|
||||||
|
|
||||||
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> clone(PageTable& new_page_table) = 0;
|
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> clone(PageTable& new_page_table) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MemoryRegion(PageTable&, size_t size, Type type, PageTable::flags_t flags);
|
MemoryRegion(PageTable&, size_t size, Type type, PageTable::flags_t flags);
|
||||||
BAN::ErrorOr<void> initialize(AddressRange);
|
BAN::ErrorOr<void> initialize(AddressRange);
|
||||||
|
@ -64,4 +64,4 @@ namespace Kernel
|
||||||
size_t m_physical_page_count { 0 };
|
size_t m_physical_page_count { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using flags_t = uint16_t;
|
using flags_t = uint16_t;
|
||||||
enum Flags : flags_t
|
enum Flags : flags_t
|
||||||
{
|
{
|
||||||
Present = (1 << 0),
|
Present = (1 << 0),
|
||||||
ReadWrite = (1 << 1),
|
ReadWrite = (1 << 1),
|
||||||
|
@ -107,7 +107,7 @@ namespace Kernel
|
||||||
uint64_t get_page_data(vaddr_t) const;
|
uint64_t get_page_data(vaddr_t) const;
|
||||||
void initialize_kernel();
|
void initialize_kernel();
|
||||||
void map_kernel_memory();
|
void map_kernel_memory();
|
||||||
void prepare_fast_page();
|
void prepare_fast_page();
|
||||||
static void invalidate(vaddr_t);
|
static void invalidate(vaddr_t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -30,4 +30,4 @@ namespace Kernel
|
||||||
PageTable& m_temp;
|
PageTable& m_temp;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Kernel
|
||||||
private:
|
private:
|
||||||
unsigned long long* ull_bitmap_ptr() { return (unsigned long long*)m_vaddr; }
|
unsigned long long* ull_bitmap_ptr() { return (unsigned long long*)m_vaddr; }
|
||||||
const unsigned long long* ull_bitmap_ptr() const { return (const unsigned long long*)m_vaddr; }
|
const unsigned long long* ull_bitmap_ptr() const { return (const unsigned long long*)m_vaddr; }
|
||||||
|
|
||||||
paddr_t paddr_for_bit(unsigned long long) const;
|
paddr_t paddr_for_bit(unsigned long long) const;
|
||||||
unsigned long long bit_for_paddr(paddr_t paddr) const;
|
unsigned long long bit_for_paddr(paddr_t paddr) const;
|
||||||
|
|
||||||
|
@ -47,4 +47,4 @@ namespace Kernel
|
||||||
size_t m_free_pages { 0 };
|
size_t m_free_pages { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,4 @@ namespace Kernel
|
||||||
using vaddr_t = uintptr_t;
|
using vaddr_t = uintptr_t;
|
||||||
using paddr_t = uintptr_t;
|
using paddr_t = uintptr_t;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,4 +48,4 @@ namespace Kernel
|
||||||
PageTable::flags_t m_flags { 0 };
|
PageTable::flags_t m_flags { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <BAN/UniqPtr.h>
|
#include <BAN/UniqPtr.h>
|
||||||
|
#include <kernel/InterruptController.h>
|
||||||
#include <kernel/Networking/NetworkDriver.h>
|
#include <kernel/Networking/NetworkDriver.h>
|
||||||
#include <kernel/PCI.h>
|
#include <kernel/PCI.h>
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
class E1000 final : public NetworkDriver
|
class E1000 final : public NetworkDriver, public Interruptable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool probe(PCI::Device&);
|
static bool probe(PCI::Device&);
|
||||||
|
@ -23,9 +24,11 @@ namespace Kernel
|
||||||
virtual bool link_up() override { return m_link_up; }
|
virtual bool link_up() override { return m_link_up; }
|
||||||
virtual int link_speed() override;
|
virtual int link_speed() override;
|
||||||
|
|
||||||
|
virtual void handle_irq() override { ASSERT_NOT_REACHED(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
E1000() = default;
|
E1000(PCI::Device& pci_device) : m_pci_device(pci_device) {}
|
||||||
BAN::ErrorOr<void> initialize(PCI::Device&);
|
BAN::ErrorOr<void> initialize();
|
||||||
|
|
||||||
static void interrupt_handler();
|
static void interrupt_handler();
|
||||||
|
|
||||||
|
@ -40,11 +43,12 @@ namespace Kernel
|
||||||
void initialize_tx();
|
void initialize_tx();
|
||||||
|
|
||||||
void enable_link();
|
void enable_link();
|
||||||
void enable_interrupts();
|
BAN::ErrorOr<void> enable_interrupts();
|
||||||
|
|
||||||
void handle_receive();
|
void handle_receive();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
PCI::Device& m_pci_device;
|
||||||
BAN::UniqPtr<PCI::BarRegion> m_bar_region;
|
BAN::UniqPtr<PCI::BarRegion> m_bar_region;
|
||||||
bool m_has_eerprom { false };
|
bool m_has_eerprom { false };
|
||||||
uint8_t m_mac_address[6] {};
|
uint8_t m_mac_address[6] {};
|
||||||
|
|
|
@ -17,4 +17,4 @@ namespace Kernel
|
||||||
virtual int link_speed() = 0;
|
virtual int link_speed() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,4 +78,4 @@ namespace Kernel
|
||||||
BAN::Array<BAN::RefPtr<OpenFileDescription>, OPEN_MAX> m_open_files;
|
BAN::Array<BAN::RefPtr<OpenFileDescription>, OPEN_MAX> m_open_files;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace Kernel::PCI
|
||||||
public:
|
public:
|
||||||
static void initialize();
|
static void initialize();
|
||||||
static PCIManager& get();
|
static PCIManager& get();
|
||||||
|
|
||||||
const BAN::Vector<PCI::Device>& devices() const { return m_devices; }
|
const BAN::Vector<PCI::Device>& devices() const { return m_devices; }
|
||||||
|
|
||||||
static uint32_t read_config_dword(uint8_t bus, uint8_t dev, uint8_t func, uint8_t offset);
|
static uint32_t read_config_dword(uint8_t bus, uint8_t dev, uint8_t func, uint8_t offset);
|
||||||
|
@ -153,4 +153,4 @@ namespace Kernel::PCI
|
||||||
BAN::Vector<PCI::Device> m_devices;
|
BAN::Vector<PCI::Device> m_devices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,4 +26,4 @@ namespace Kernel::detail
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,4 +225,4 @@ namespace Kernel
|
||||||
friend class Thread;
|
friend class Thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,4 +76,4 @@ namespace Kernel
|
||||||
friend class Process;
|
friend class Process;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,4 +10,4 @@ namespace Kernel
|
||||||
void unblock();
|
void unblock();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
BAN_NON_COPYABLE(RecursivePrioritySpinLock);
|
BAN_NON_COPYABLE(RecursivePrioritySpinLock);
|
||||||
BAN_NON_MOVABLE(RecursivePrioritySpinLock);
|
BAN_NON_MOVABLE(RecursivePrioritySpinLock);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RecursivePrioritySpinLock() = default;
|
RecursivePrioritySpinLock() = default;
|
||||||
void lock();
|
void lock();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue