Add newlines at end-of-file
This commit is contained in:
parent
aab3a0a840
commit
5854e5e530
@ -134,4 +134,4 @@ namespace ELFLoader
|
||||
|
||||
return ELFData { segments, elf_header.e_entry };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,4 +75,4 @@ struct ELFData
|
||||
namespace ELFLoader
|
||||
{
|
||||
Result<ELFData> load(const TarStream::Entry& elf_entry, const TarStream& stream);
|
||||
};
|
||||
};
|
||||
|
@ -15,4 +15,4 @@ void InitRD::initialize()
|
||||
.expect_value("Unable to map the initial ramdisk into virtual memory");
|
||||
|
||||
g_initrd.initialize((void*)virtual_initrd_address, bootboot.initrd_size);
|
||||
}
|
||||
}
|
||||
|
@ -6,4 +6,4 @@ extern TarStream g_initrd;
|
||||
namespace InitRD
|
||||
{
|
||||
void initialize();
|
||||
}
|
||||
}
|
||||
|
@ -127,4 +127,4 @@ static bool g_check_already_failed = false;
|
||||
CPU::print_stack_trace();
|
||||
}
|
||||
CPU::efficient_halt();
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,4 @@ bool log_text_console_enabled();
|
||||
#define kdbgln(...) log(LogLevel::Debug, __VA_ARGS__)
|
||||
#define kinfoln(...) log(LogLevel::Info, __VA_ARGS__)
|
||||
#define kwarnln(...) log(LogLevel::Warn, __VA_ARGS__)
|
||||
#define kerrorln(...) log(LogLevel::Error, __VA_ARGS__)
|
||||
#define kerrorln(...) log(LogLevel::Error, __VA_ARGS__)
|
||||
|
@ -27,4 +27,4 @@ namespace CPU
|
||||
void print_stack_trace_at(Registers* regs);
|
||||
|
||||
void pause();
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,4 @@ namespace MMU
|
||||
void setup_initial_page_directory();
|
||||
|
||||
PageDirectory* kernel_page_directory();
|
||||
}
|
||||
}
|
||||
|
@ -30,4 +30,4 @@ namespace Serial
|
||||
va_end(ap);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ namespace Serial
|
||||
void print(const char* str);
|
||||
void println(const char* str);
|
||||
usize printf(const char* str, ...) _format(1, 2);
|
||||
}
|
||||
}
|
||||
|
@ -137,4 +137,4 @@ bool should_invoke_scheduler()
|
||||
{
|
||||
// FIXME: Modulo is SLOW. We're calling this every tick.
|
||||
return (timer_ticks % ARCH_TIMER_FREQ) == 0;
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,4 @@ namespace Timer
|
||||
void init();
|
||||
}
|
||||
|
||||
bool should_invoke_scheduler();
|
||||
bool should_invoke_scheduler();
|
||||
|
@ -284,4 +284,4 @@ namespace CPU
|
||||
extern "C" void switch_task(Registers* regs)
|
||||
{
|
||||
Scheduler::switch_task(regs);
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,4 @@ struct [[gnu::packed]] TSS
|
||||
|
||||
static_assert(sizeof(TSS) == 104UL);
|
||||
|
||||
extern TSS task_state_segment;
|
||||
extern TSS task_state_segment;
|
||||
|
@ -37,4 +37,4 @@ namespace IO
|
||||
{
|
||||
asm volatile("outl %0, %1" : : "a"(value), "Nd"(port));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ namespace IO
|
||||
void outb(u16 port, u8 value);
|
||||
void outw(u16 port, u16 value);
|
||||
void outl(u16 port, u32 value);
|
||||
}
|
||||
}
|
||||
|
@ -274,4 +274,4 @@ namespace MMU
|
||||
{
|
||||
return g_kernel_directory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,4 +40,4 @@ struct alignas(ARCH_PAGE_SIZE) PageDirectory
|
||||
};
|
||||
|
||||
static_assert(sizeof(PageTableEntry) == 8UL);
|
||||
static_assert(sizeof(PageDirectory) == ARCH_PAGE_SIZE);
|
||||
static_assert(sizeof(PageDirectory) == ARCH_PAGE_SIZE);
|
||||
|
@ -12,4 +12,4 @@ void Serial::putchar(u8 c)
|
||||
{
|
||||
serial_wait();
|
||||
IO::outb(COM1, c);
|
||||
}
|
||||
}
|
||||
|
@ -55,4 +55,4 @@ void switch_context(Thread* old_thread, Thread* new_thread, Registers* regs)
|
||||
if (!old_thread->is_idle()) memcpy(&old_thread->regs, regs, sizeof(Registers));
|
||||
|
||||
memcpy(regs, &new_thread->regs, sizeof(Registers));
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ void Timer::arch_init()
|
||||
IO::outb(PIT_CHANNEL_0, (u8)(divisor & 0xFF));
|
||||
IO::outb(0x80, 0); // short delay
|
||||
IO::outb(PIT_CHANNEL_0, (u8)((divisor & 0xFF00) >> 8));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <luna/Types.h>
|
||||
|
||||
const usize ARCH_TIMER_FREQ = 5;
|
||||
const usize ARCH_TIMER_FREQ = 5;
|
||||
|
@ -91,4 +91,4 @@ void setup_gdt()
|
||||
setup_tss();
|
||||
load_gdt(&gdtr);
|
||||
load_tr(0x2b);
|
||||
}
|
||||
}
|
||||
|
@ -115,4 +115,4 @@ void setup_idt()
|
||||
idtr.limit = 0x0FFF;
|
||||
idtr.offset = (u64)idt;
|
||||
asm volatile("lidt %0" : : "m"(idtr));
|
||||
}
|
||||
}
|
||||
|
@ -50,4 +50,4 @@ void pic_eoi(unsigned char irq)
|
||||
void pic_eoi(Registers* regs)
|
||||
{
|
||||
pic_eoi((unsigned char)(regs->error)); // On IRQs, the error code is the IRQ number
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +33,4 @@ void Init::early_init()
|
||||
InitRD::initialize();
|
||||
|
||||
MemoryManager::protect_kernel_sections().expect_release_value("We should succeed to protect sections");
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ namespace Init
|
||||
{
|
||||
void early_init();
|
||||
void check_magic();
|
||||
}
|
||||
}
|
||||
|
@ -90,4 +90,4 @@ extern "C" [[noreturn]] void _start()
|
||||
auto rc = init();
|
||||
if (rc.has_error()) kerrorln("Runtime error: %s", rc.error_string());
|
||||
CPU::idle_loop();
|
||||
}
|
||||
}
|
||||
|
@ -419,4 +419,4 @@ void operator delete(void* p, usize) noexcept
|
||||
void operator delete[](void* p, usize) noexcept
|
||||
{
|
||||
kfree(p);
|
||||
}
|
||||
}
|
||||
|
@ -7,4 +7,4 @@ Result<void*> kcalloc(usize nmemb, usize size);
|
||||
Result<void*> krealloc(void* ptr, usize size);
|
||||
Result<void> kfree(void* ptr);
|
||||
|
||||
void dump_heap_usage();
|
||||
void dump_heap_usage();
|
||||
|
@ -120,4 +120,4 @@ namespace KernelVM
|
||||
{
|
||||
return KERNEL_VM_RANGE_SIZE - g_used_vm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,4 @@ namespace KernelVM
|
||||
|
||||
usize free();
|
||||
usize used();
|
||||
}
|
||||
}
|
||||
|
@ -357,4 +357,4 @@ namespace MemoryManager
|
||||
{
|
||||
return free_mem + used_mem + reserved_mem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,4 +35,4 @@ namespace MemoryManager
|
||||
usize used();
|
||||
usize reserved();
|
||||
usize total();
|
||||
}
|
||||
}
|
||||
|
@ -84,4 +84,4 @@ MemoryMapEntry MemoryMapIterator::highest()
|
||||
}
|
||||
|
||||
return at(highest_index).value();
|
||||
}
|
||||
}
|
||||
|
@ -61,4 +61,4 @@ class MemoryMapIterator
|
||||
const usize m_mmap_entries;
|
||||
const MMapEnt* m_base_ent;
|
||||
usize m_cur_ent;
|
||||
};
|
||||
};
|
||||
|
@ -206,4 +206,4 @@ void kernel_sleep(u64 ms)
|
||||
g_current->state = ThreadState::Dying;
|
||||
kernel_yield();
|
||||
unreachable();
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ namespace Scheduler
|
||||
|
||||
extern "C" void kernel_yield();
|
||||
void kernel_sleep(u64 ms);
|
||||
[[noreturn]] void kernel_exit();
|
||||
[[noreturn]] void kernel_exit();
|
||||
|
@ -25,4 +25,4 @@ void Spinlock::unlock()
|
||||
{
|
||||
kwarnln("Spinlock::unlock() called on an unlocked lock with value %d", expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,4 +88,4 @@ template <typename T> class LockedValue
|
||||
private:
|
||||
T m_value;
|
||||
Spinlock m_lock;
|
||||
};
|
||||
};
|
||||
|
@ -18,4 +18,4 @@ Result<Thread*> new_thread()
|
||||
thread->id = g_next_id++;
|
||||
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
|
@ -60,4 +60,4 @@ bool is_in_kernel(Registers* regs);
|
||||
|
||||
Result<Thread*> new_thread();
|
||||
|
||||
extern LinkedList<Thread> g_threads;
|
||||
extern LinkedList<Thread> g_threads;
|
||||
|
@ -516,4 +516,4 @@ u8 font[] = { 0x00, 0x00, 0x00, 0x00, 0x7e, 0x42, 0x42, 0x42,
|
||||
0x00, 0x00, 0x24, 0x24, 0x00, 0x42, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x3c, 0x00, /* 255 */
|
||||
0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
|
||||
0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x00, 0x00, 0x00 /* Special box character, 256 */ };
|
||||
0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x00, 0x00, 0x00 /* Special box character, 256 */ };
|
||||
|
@ -80,4 +80,4 @@ namespace Framebuffer
|
||||
{
|
||||
return g_fb_scanline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,4 @@ namespace Framebuffer
|
||||
u32 width();
|
||||
u32 height();
|
||||
u32 scanline();
|
||||
}
|
||||
}
|
||||
|
@ -199,4 +199,4 @@ namespace TextConsole
|
||||
va_end(ap);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,4 +18,4 @@ namespace TextConsole
|
||||
Result<void> println(const char* str);
|
||||
void wprintln(const wchar_t* str);
|
||||
Result<usize> printf(const char* format, ...) _format(1, 2);
|
||||
}
|
||||
}
|
||||
|
@ -50,4 +50,4 @@ static_assert(get_blocks_from_size(0, 256) == 0);
|
||||
template <typename T, typename Offset> constexpr T* offset_ptr(T* ptr, Offset offset)
|
||||
{
|
||||
return (T*)((char*)ptr + offset);
|
||||
}
|
||||
}
|
||||
|
@ -44,4 +44,4 @@ template <typename T> void destroy(T* item)
|
||||
template <typename T> void destroy_array(T* item)
|
||||
{
|
||||
delete[] item;
|
||||
}
|
||||
}
|
||||
|
@ -115,4 +115,4 @@ template <typename T> class Atomic
|
||||
|
||||
private:
|
||||
T m_value;
|
||||
};
|
||||
};
|
||||
|
@ -2,4 +2,4 @@
|
||||
|
||||
#define _weak __attribute__((weak))
|
||||
#define _format(n, m) __attribute__((format(printf, n, m)))
|
||||
#define _align(x) __attribute__((aligned(x)))
|
||||
#define _align(x) __attribute__((aligned(x)))
|
||||
|
@ -9,4 +9,4 @@ template <class T> struct Badge
|
||||
Badge(Badge<T>&&) = delete;
|
||||
|
||||
friend T;
|
||||
};
|
||||
};
|
||||
|
@ -45,4 +45,4 @@ class Bitmap
|
||||
|
||||
u8* m_location = nullptr;
|
||||
usize m_size_in_bytes = 0;
|
||||
};
|
||||
};
|
||||
|
@ -16,4 +16,4 @@ extern "C"
|
||||
|
||||
// Copies len bytes from src into dest and adds a null terminator.
|
||||
void nullcpy(char* dest, const char* src, usize len);
|
||||
}
|
||||
}
|
||||
|
@ -93,4 +93,4 @@ inline constexpr int _toupper(int c)
|
||||
#define isblank _isblank
|
||||
#define tolower _tolower
|
||||
#define toupper _toupper
|
||||
#endif
|
||||
#endif
|
||||
|
@ -4,4 +4,4 @@
|
||||
|
||||
extern void debug_log_impl(const char* format, va_list ap);
|
||||
|
||||
void dbgln(const char* format, ...) _format(1, 2);
|
||||
void dbgln(const char* format, ...) _format(1, 2);
|
||||
|
@ -16,4 +16,4 @@ usize pure_cstyle_format(const char* format, pure_callback_t callback, void* arg
|
||||
usize vstring_format(char* buf, usize max, const char* format, va_list ap);
|
||||
|
||||
// Convenience function which outputs into a fixed-size buffer (not unlike snprintf)
|
||||
usize string_format(char* buf, usize max, const char* format, ...) _format(3, 4);
|
||||
usize string_format(char* buf, usize max, const char* format, ...) _format(3, 4);
|
||||
|
@ -220,4 +220,4 @@ template <typename T> class LinkedList
|
||||
}
|
||||
|
||||
usize m_count = 0;
|
||||
};
|
||||
};
|
||||
|
@ -3,4 +3,4 @@
|
||||
template <typename T> inline T&& move(T& lvalue)
|
||||
{
|
||||
return (T &&) lvalue;
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ isize scan_signed_integer(const char** str);
|
||||
usize parse_unsigned_integer(const char* str, const char** endptr, int base);
|
||||
|
||||
// Parse a signed integer, similar to strtoll().
|
||||
isize parse_signed_integer(const char* str, const char** endptr, int base);
|
||||
isize parse_signed_integer(const char* str, const char** endptr, int base);
|
||||
|
@ -174,4 +174,4 @@ template <typename T> inline Option<T*> nonnull_or_empty_option(T* ptr)
|
||||
if (ptr == nullptr) return {};
|
||||
else
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
@ -62,4 +62,4 @@ template <typename T> Result<OwnedPtr<T>> adopt_owned_if_nonnull(T* ptr)
|
||||
if (ptr) return OwnedPtr<T> { ptr };
|
||||
else
|
||||
return err(ENOMEM);
|
||||
}
|
||||
}
|
||||
|
@ -29,4 +29,4 @@ class OwnedStringView
|
||||
private:
|
||||
char* m_string { nullptr };
|
||||
usize m_length { 0 };
|
||||
};
|
||||
};
|
||||
|
@ -10,4 +10,4 @@ inline void* operator new[](usize, void* p) noexcept
|
||||
return p;
|
||||
}
|
||||
inline void operator delete(void*, void*) noexcept {};
|
||||
inline void operator delete[](void*, void*) noexcept {};
|
||||
inline void operator delete[](void*, void*) noexcept {};
|
||||
|
@ -251,4 +251,4 @@ template <typename T> inline Result<T*> nonnull_or_error(T* ptr, int error)
|
||||
if (ptr == nullptr) return err(error);
|
||||
else
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
@ -53,4 +53,4 @@ template <typename T> bool mul_will_overflow(T a, T b)
|
||||
#else
|
||||
return safe_mul(a, b).has_error();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ template <typename Callback> class ScopeGuard
|
||||
template <typename Callback> [[nodiscard]] ScopeGuard<Callback> make_scope_guard(const Callback& callback)
|
||||
{
|
||||
return { callback };
|
||||
}
|
||||
}
|
||||
|
@ -133,4 +133,4 @@ template <typename T> Result<SharedPtr<T>> adopt_shared_from_owned(OwnedPtr<T>&&
|
||||
guard.deactivate();
|
||||
|
||||
return shared_ptr;
|
||||
}
|
||||
}
|
||||
|
@ -21,4 +21,4 @@ struct Stack
|
||||
private:
|
||||
u64 m_base;
|
||||
usize m_bytes;
|
||||
};
|
||||
};
|
||||
|
@ -60,4 +60,4 @@
|
||||
|
||||
const char* error_string(int error);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -67,4 +67,4 @@ class TarStream
|
||||
void* m_pos;
|
||||
usize m_size;
|
||||
usize m_offset = 0;
|
||||
};
|
||||
};
|
||||
|
@ -46,4 +46,4 @@ template <class T> struct __remove_ref_impl<T&&>
|
||||
|
||||
template <class T> using RemoveReference = __remove_ref_impl<T>::type;
|
||||
|
||||
template <class T> using RemoveCVReference = RemoveCV<RemoveReference<T>>;
|
||||
template <class T> using RemoveCVReference = RemoveCV<RemoveReference<T>>;
|
||||
|
@ -22,4 +22,4 @@ static_assert(sizeof(i32) == 4UL);
|
||||
static_assert(sizeof(i64) == 8UL);
|
||||
|
||||
static_assert(sizeof(usize) == sizeof(void*));
|
||||
static_assert(sizeof(isize) == sizeof(void*));
|
||||
static_assert(sizeof(isize) == sizeof(void*));
|
||||
|
@ -3,4 +3,4 @@
|
||||
#include <luna/Result.h>
|
||||
|
||||
usize to_dynamic_unit_cstr(usize value, char* buffer, usize max);
|
||||
Result<OwnedStringView> to_dynamic_unit(usize value);
|
||||
Result<OwnedStringView> to_dynamic_unit(usize value);
|
||||
|
@ -62,4 +62,4 @@ class Utf8Encoder
|
||||
public:
|
||||
// Does not null-terminate. Returns the number of bytes written.
|
||||
Result<usize> encode(wchar_t c, char buf[4]);
|
||||
};
|
||||
};
|
||||
|
@ -27,4 +27,4 @@ void raw_free(void* ptr)
|
||||
void operator delete(void* ptr, usize size, std::align_val_t) noexcept
|
||||
{
|
||||
operator delete(ptr, size);
|
||||
}
|
||||
}
|
||||
|
@ -85,4 +85,4 @@ void Bitmap::clear_region(usize start, usize bits, bool value)
|
||||
set(start, value);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,4 +81,4 @@ extern "C"
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,4 +3,4 @@
|
||||
_weak [[noreturn]] bool __check_failed(const char*, const char*, const char*, const char*)
|
||||
{
|
||||
__builtin_trap();
|
||||
}
|
||||
}
|
||||
|
@ -6,4 +6,4 @@ void dbgln(const char* format, ...)
|
||||
va_start(ap, format);
|
||||
debug_log_impl(format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
@ -693,4 +693,4 @@ usize string_format(char* buf, usize max, const char* format, ...)
|
||||
va_end(ap);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -46,4 +46,4 @@ Result<OwnedStringView> OwnedStringView::from_string_literal(const char* str)
|
||||
char* dup = strdup(str);
|
||||
if (!dup) return err(ENOMEM);
|
||||
return OwnedStringView { dup };
|
||||
}
|
||||
}
|
||||
|
@ -7,4 +7,4 @@ Stack::Stack(u64 base, usize bytes) : m_base(base), m_bytes(bytes)
|
||||
u64 Stack::top()
|
||||
{
|
||||
return (m_base + m_bytes) - sizeof(void*);
|
||||
}
|
||||
}
|
||||
|
@ -59,4 +59,4 @@ const char* error_string(int error)
|
||||
case EFIXME: return "Functionality not yet implemented";
|
||||
default: return "Unknown error";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,4 +106,4 @@ Result<OwnedStringView> TarStream::read_contents_as_string(const Entry& entry, u
|
||||
buf[nread] = 0;
|
||||
|
||||
return OwnedStringView { buf };
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ Result<OwnedStringView> to_dynamic_unit(usize value)
|
||||
to_dynamic_unit_cstr(value, buf, 64);
|
||||
|
||||
return OwnedStringView { buf };
|
||||
}
|
||||
}
|
||||
|
@ -241,4 +241,4 @@ Result<usize> Utf8Encoder::encode(wchar_t c, char buf[4])
|
||||
TRY(encode_wide_char_as_utf8(c, buf, len));
|
||||
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user