Compare commits

..

No commits in common. "beab3454b5e741cbd5b7ac7f5d5ab2ebc85efaef" and "c2927de1913f2bdfa6ccc079e92739fba270abec" have entirely different histories.

15 changed files with 20 additions and 32 deletions

View File

@ -1,7 +1,6 @@
#include "arch/Serial.h" #include "arch/Serial.h"
#include <luna/Result.h> #include "arch/CPU.h"
#include <luna/Format.h> #include <luna/Format.h>
#include <stdarg.h>
namespace Serial namespace Serial
{ {

View File

@ -1,14 +1,12 @@
#include "arch/CPU.h"
#include "arch/x86_64/CPU.h" #include "arch/x86_64/CPU.h"
#include "Log.h" #include "Log.h"
#include "arch/Serial.h"
#include "arch/Timer.h" #include "arch/Timer.h"
#include "arch/x86_64/IO.h" #include "arch/x86_64/IO.h"
#include <cpuid.h> #include <cpuid.h>
#include <luna/String.h> #include <luna/String.h>
#include <luna/SystemError.h> #include <luna/SystemError.h>
#include <luna/Types.h> #include <luna/Types.h>
#include <luna/Check.h>
#include <luna/Result.h>
extern "C" void enable_sse(); extern "C" void enable_sse();
extern "C" void enable_write_protect(); extern "C" void enable_write_protect();

View File

@ -1,3 +1,4 @@
#include "arch/CPU.h"
#include <luna/Types.h> #include <luna/Types.h>
struct Registers // Saved CPU registers for x86-64 struct Registers // Saved CPU registers for x86-64

View File

@ -2,7 +2,6 @@
#include "memory/MemoryManager.h" #include "memory/MemoryManager.h"
#include <luna/String.h> #include <luna/String.h>
#include <luna/SystemError.h> #include <luna/SystemError.h>
#include <luna/Result.h>
#pragma GCC push_options #pragma GCC push_options
#pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wconversion"

View File

@ -1,11 +1,11 @@
#include "boot/Init.h" #include "boot/Init.h"
#include "Log.h" #include "Log.h"
#include "arch/CPU.h" #include "arch/CPU.h"
#include "arch/Serial.h"
#include "boot/bootboot.h" #include "boot/bootboot.h"
#include "memory/MemoryManager.h" #include "memory/MemoryManager.h"
#include "video/Framebuffer.h" #include "video/Framebuffer.h"
#include <luna/String.h> #include <luna/String.h>
#include <luna/Result.h>
extern const BOOTBOOT bootboot; extern const BOOTBOOT bootboot;

View File

@ -5,7 +5,6 @@
#include "config.h" #include "config.h"
#include "memory/MemoryManager.h" #include "memory/MemoryManager.h"
#include <luna/Units.h> #include <luna/Units.h>
#include <luna/Result.h>
Result<void> init() Result<void> init()
{ {

View File

@ -1,6 +1,4 @@
#include "memory/MemoryMap.h" #include "memory/MemoryMap.h"
#include <luna/Result.h>
#include <luna/SystemError.h>
extern const BOOTBOOT bootboot; extern const BOOTBOOT bootboot;

View File

@ -3,8 +3,6 @@
#include "video/Framebuffer.h" #include "video/Framebuffer.h"
#include <luna/Format.h> #include <luna/Format.h>
#include <luna/String.h> #include <luna/String.h>
#include <luna/Result.h>
#include <stdarg.h>
extern const BOOTBOOT bootboot; extern const BOOTBOOT bootboot;

View File

@ -17,7 +17,7 @@ set(SOURCES
add_library(luna-freestanding ${FREESTANDING_SOURCES}) add_library(luna-freestanding ${FREESTANDING_SOURCES})
target_compile_definitions(luna-freestanding PRIVATE USE_FREESTANDING) target_compile_definitions(luna-freestanding PRIVATE USE_FREESTANDING)
target_compile_options(luna-freestanding PRIVATE -Wall -Wextra -Werror -Wvla) target_compile_options(luna-freestanding PRIVATE -Wall -Wextra -Werror -Wvla)
target_compile_options(luna-freestanding PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self -Wcast-align -Wsign-conversion) target_compile_options(luna-freestanding PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self)
target_compile_options(luna-freestanding PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef) target_compile_options(luna-freestanding PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
target_compile_options(luna-freestanding PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion) target_compile_options(luna-freestanding PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
target_compile_options(luna-freestanding PRIVATE -fno-rtti -ffreestanding -fno-exceptions) target_compile_options(luna-freestanding PRIVATE -fno-rtti -ffreestanding -fno-exceptions)

View File

@ -43,6 +43,6 @@ class Bitmap
return b ? 0xff : 0; return b ? 0xff : 0;
} }
u8* m_location = nullptr; char* m_location = nullptr;
usize m_size_in_bytes = 0; usize m_size_in_bytes = 0;
}; };

View File

@ -6,13 +6,13 @@ Bitmap::Bitmap()
{ {
} }
Bitmap::Bitmap(void* location, usize size_in_bytes) : m_location((u8*)location), m_size_in_bytes(size_in_bytes) Bitmap::Bitmap(void* location, usize size_in_bytes) : m_location((char*)location), m_size_in_bytes(size_in_bytes)
{ {
} }
void Bitmap::initialize(void* location, usize size_in_bytes) void Bitmap::initialize(void* location, usize size_in_bytes)
{ {
m_location = (u8*)location; m_location = (char*)location;
m_size_in_bytes = size_in_bytes; m_size_in_bytes = size_in_bytes;
} }
@ -26,7 +26,7 @@ void* Bitmap::move(void* new_location, usize new_location_size_in_bytes)
void* old_location = (void*)m_location; void* old_location = (void*)m_location;
m_location = (u8*)new_location; m_location = (char*)new_location;
m_size_in_bytes = new_location_size_in_bytes; m_size_in_bytes = new_location_size_in_bytes;
return old_location; return old_location;
@ -37,7 +37,7 @@ void Bitmap::set(usize index, bool value)
expect(initialized(), "Bitmap was never initialized"); expect(initialized(), "Bitmap was never initialized");
expect(index < size(), "Bitmap access out of range"); expect(index < size(), "Bitmap access out of range");
u64 byte_index = index / 8; u64 byte_index = index / 8;
u8 bit_mask = (u8)(0b10000000 >> (index % 8)); u8 bit_mask = 0b10000000 >> (index % 8);
m_location[byte_index] &= (u8)(~bit_mask); m_location[byte_index] &= (u8)(~bit_mask);
if (value) { m_location[byte_index] |= bit_mask; } if (value) { m_location[byte_index] |= bit_mask; }
} }
@ -47,7 +47,7 @@ bool Bitmap::get(usize index) const
expect(initialized(), "Bitmap was never initialized"); expect(initialized(), "Bitmap was never initialized");
expect(index < size(), "Bitmap access out of range"); expect(index < size(), "Bitmap access out of range");
usize byte_index = index / 8; usize byte_index = index / 8;
u8 bit_mask = (u8)(0b10000000 >> (index % 8)); usize bit_mask = 0b10000000 >> (index % 8);
return (m_location[byte_index] & bit_mask) > 0; return (m_location[byte_index] & bit_mask) > 0;
} }

View File

@ -1,9 +1,6 @@
#include <luna/CType.h> #include <luna/CType.h>
#include <luna/Format.h> #include <luna/Format.h>
#include <luna/NumberParsing.h> #include <luna/NumberParsing.h>
#include <luna/Result.h>
#include <stddef.h>
#include <stdarg.h>
extern "C" usize strlen(const char*); extern "C" usize strlen(const char*);
@ -290,7 +287,7 @@ static Result<void> va_output_integer(char specifier, conv_state& vstate, format
v = -v; v = -v;
negative = true; negative = true;
} }
return output_integer(specifier, vstate, state, (unsigned char)v, negative); return output_integer(specifier, vstate, state, v, negative);
} }
else else
{ {
@ -308,7 +305,7 @@ static Result<void> va_output_integer(char specifier, conv_state& vstate, format
v = -v; v = -v;
negative = true; negative = true;
} }
return output_integer(specifier, vstate, state, (unsigned short)v, negative); return output_integer(specifier, vstate, state, v, negative);
} }
else else
{ {
@ -326,7 +323,7 @@ static Result<void> va_output_integer(char specifier, conv_state& vstate, format
v = -v; v = -v;
negative = true; negative = true;
} }
return output_integer(specifier, vstate, state, (unsigned long long)v, negative); return output_integer(specifier, vstate, state, v, negative);
} }
else else
{ {
@ -344,7 +341,7 @@ static Result<void> va_output_integer(char specifier, conv_state& vstate, format
v = -v; v = -v;
negative = true; negative = true;
} }
return output_integer(specifier, vstate, state, (unsigned long)v, negative); return output_integer(specifier, vstate, state, v, negative);
} }
else else
{ {
@ -362,7 +359,7 @@ static Result<void> va_output_integer(char specifier, conv_state& vstate, format
v = -v; v = -v;
negative = true; negative = true;
} }
return output_integer(specifier, vstate, state, (unsigned int)v, negative); return output_integer(specifier, vstate, state, v, negative);
} }
else else
{ {

View File

@ -38,7 +38,7 @@ usize _strtou(const char* str, const char** endptr, int base)
while (is_valid_digit_for_base(base, *str)) while (is_valid_digit_for_base(base, *str))
{ {
val = ((usize)base * val) + (usize)parse_digit_unchecked(*str); val = (base * val) + parse_digit_unchecked(*str);
str++; str++;
} }

View File

@ -31,7 +31,7 @@ extern "C"
{ {
if (dest == src) return dest; if (dest == src) return dest;
if (dest > src) if (dest > src)
for (long i = (long)n - 1; i >= 0; i++) { *((u8*)dest + i) = *((const u8*)src + i); } for (long i = n - 1; i >= 0; i++) { *((u8*)dest + i) = *((const u8*)src + i); }
else else
for (long i = 0; i < (long)n; i++) { *((u8*)dest + i) = *((const u8*)src + i); } for (long i = 0; i < (long)n; i++) { *((u8*)dest + i) = *((const u8*)src + i); }
return dest; return dest;
@ -42,6 +42,6 @@ extern "C"
const char* i = str; const char* i = str;
for (; *i; ++i) for (; *i; ++i)
; ;
return (usize)(i - str); return (i - str);
} }
} }

View File

@ -1,8 +1,7 @@
#include <luna/Format.h> #include <luna/Format.h>
#include <luna/Units.h> #include <luna/Units.h>
#include <luna/Result.h>
Result<usize> to_dynamic_unit(usize value, char* buffer, usize max) Result<usize> to_dynamic_unit(usize value, char* buffer, size_t max)
{ {
if (value < 1024) { return string_format(buffer, max, "%u bytes", value); } if (value < 1024) { return string_format(buffer, max, "%u bytes", value); }