1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:37:35 +00:00

Kernel: Absorb LibBareMetal back into the kernel

This was supposed to be the foundation for some kind of pre-kernel
environment, but nobody is working on it right now, so let's move
everything back into the kernel and remove all the confusion.
This commit is contained in:
Andreas Kling 2020-05-16 12:00:04 +02:00
parent c12cfdea87
commit 21d5f4ada1
75 changed files with 140 additions and 203 deletions

View file

@ -30,8 +30,6 @@
# if defined(KERNEL)
# include <Kernel/Assertions.h>
# elif defined(BOOTSTRAPPER)
# include <Bootstrapper/Output/Assertions.h>
# else
# include <assert.h>
# ifndef __serenity__

View file

@ -148,7 +148,7 @@ inline void JsonValue::serialize(Builder& builder) const
case Type::Bool:
builder.append(m_value.as_bool ? "true" : "false");
break;
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
case Type::Double:
builder.appendf("%g", m_value.as_double);
break;

View file

@ -100,7 +100,7 @@ bool JsonValue::equals(const JsonValue& other) const
if (is_string() && other.is_string() && as_string() == other.as_string())
return true;
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
if (is_number() && other.is_number() && to_number<double>() == other.to_number<double>()) {
return true;
}
@ -158,7 +158,7 @@ JsonValue::JsonValue(const char* cstring)
{
}
#if !defined(BOOTSTRAPPER) && !defined(KERNEL)
#if !defined(KERNEL)
JsonValue::JsonValue(double value)
: m_type(Type::Double)
{

View file

@ -43,7 +43,7 @@ public:
UnsignedInt32,
Int64,
UnsignedInt64,
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
Double,
#endif
Bool,
@ -68,7 +68,7 @@ public:
JsonValue(i64);
JsonValue(u64);
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
JsonValue(double);
#endif
JsonValue(bool);
@ -172,7 +172,7 @@ public:
return *m_value.as_array;
}
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
double as_double() const
{
ASSERT(is_double());
@ -193,7 +193,7 @@ public:
bool is_u32() const { return m_type == Type::UnsignedInt32; }
bool is_i64() const { return m_type == Type::Int64; }
bool is_u64() const { return m_type == Type::UnsignedInt64; }
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
bool is_double() const
{
return m_type == Type::Double;
@ -211,7 +211,7 @@ public:
case Type::UnsignedInt32:
case Type::Int64:
case Type::UnsignedInt64:
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
case Type::Double:
#endif
return true;
@ -223,7 +223,7 @@ public:
template<typename T>
T to_number(T default_value = 0) const
{
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
if (is_double())
return (T)as_double();
#endif
@ -250,7 +250,7 @@ private:
StringImpl* as_string { nullptr };
JsonArray* as_array;
JsonObject* as_object;
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
double as_double;
#endif
i32 as_i32;

View file

@ -34,8 +34,8 @@
# include <Kernel/Thread.h>
#endif
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#include <stdio.h>
#if !defined(KERNEL)
# include <stdio.h>
#endif
namespace AK {
@ -106,7 +106,7 @@ const LogStream& operator<<(const LogStream& stream, const void* value)
return stream << buffer;
}
#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if defined(__serenity__) && !defined(KERNEL)
static TriState got_process_name = TriState::Unknown;
static char process_name_buffer[256];
#endif
@ -114,7 +114,7 @@ static char process_name_buffer[256];
DebugLogStream dbg()
{
DebugLogStream stream;
#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if defined(__serenity__) && !defined(KERNEL)
if (got_process_name == TriState::Unknown) {
if (get_process_name(process_name_buffer, sizeof(process_name_buffer)) == 0)
got_process_name = TriState::True;
@ -124,19 +124,16 @@ DebugLogStream dbg()
if (got_process_name == TriState::True)
stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: ";
#endif
#if defined(__serenity__) && defined(KERNEL) && !defined(BOOTSTRAPPER)
#if defined(__serenity__) && defined(KERNEL)
if (Kernel::Thread::current)
stream << "\033[34;1m[" << *Kernel::Thread::current << "]\033[0m: ";
else
stream << "\033[36;1m[Kernel]\033[0m: ";
#endif
#if defined(BOOTSTRAPPER) && !defined(__serenity__) && !defined(KERNEL)
stream << "\033[36;1m[Bootstrapper]\033[0m: ";
#endif
return stream;
}
#if defined(KERNEL)
#ifdef KERNEL
KernelLogStream klog()
{
KernelLogStream stream;
@ -146,14 +143,14 @@ KernelLogStream klog()
stream << "\033[36;1m[Kernel]\033[0m: ";
return stream;
}
#elif !defined(BOOTSTRAPPER)
#else
DebugLogStream klog()
{
return dbg();
}
#endif
#if defined(KERNEL)
#ifdef KERNEL
KernelLogStream::~KernelLogStream()
{
char newline = '\n';
@ -167,7 +164,7 @@ DebugLogStream::~DebugLogStream()
write(&newline, 1);
}
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#ifndef KERNEL
StdLogStream::~StdLogStream()
{
char newline = '\n';

View file

@ -30,7 +30,7 @@
#include <AK/Types.h>
#include <AK/kstdio.h>
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
# include <AK/ScopedValueRollback.h>
# include <AK/StringView.h>
# include <errno.h>
@ -42,7 +42,7 @@ namespace AK {
class LogStream {
public:
LogStream()
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
: m_errno_restorer(errno)
#endif
{
@ -52,7 +52,7 @@ public:
virtual void write(const char*, int) const = 0;
private:
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
ScopedValueRollback<int> m_errno_restorer;
#endif
};
@ -68,7 +68,7 @@ public:
}
};
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
class StdLogStream final : public LogStream {
public:
StdLogStream(int fd)
@ -86,7 +86,7 @@ inline StdLogStream out() { return StdLogStream(STDOUT_FILENO); }
inline StdLogStream warn() { return StdLogStream(STDERR_FILENO); }
#endif
#if !defined(BOOTSTRAPPER) && defined(KERNEL)
#ifdef KERNEL
class KernelLogStream final : public LogStream {
public:
KernelLogStream() {}
@ -121,7 +121,7 @@ const LogStream& operator<<(const LogStream&, long long);
const LogStream& operator<<(const LogStream&, unsigned long);
const LogStream& operator<<(const LogStream&, unsigned long long);
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
const LogStream& operator<<(const LogStream&, double);
const LogStream& operator<<(const LogStream&, float);
#endif
@ -141,9 +141,9 @@ inline const LogStream& operator<<(const LogStream& stream, bool value)
DebugLogStream dbg();
#if defined(KERNEL)
#ifdef KERNEL
KernelLogStream klog();
#elif !defined(BOOTSTRAPPER)
#else
DebugLogStream klog();
#endif
@ -153,7 +153,7 @@ using AK::dbg;
using AK::klog;
using AK::LogStream;
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if !defined(KERNEL)
using AK::out;
using AK::warn;
#endif

View file

@ -28,20 +28,20 @@
#include <AK/Types.h>
#if defined(KERNEL) || defined(BOOTSTRAPPER)
# include <LibBareMetal/StdLib.h>
#if defined(KERNEL)
# include <Kernel/StdLib.h>
#else
# include <stdlib.h>
# include <string.h>
#endif
#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if defined(__serenity__) && !defined(KERNEL)
extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
#endif
ALWAYS_INLINE void fast_u32_copy(u32* dest, const u32* src, size_t count)
{
#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER)
#if defined(__serenity__) && !defined(KERNEL)
if (count >= 256) {
mmx_memcpy(dest, src, count * sizeof(count));
return;

View file

@ -388,7 +388,7 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm
ret += print_hex(putch, bufptr, va_arg(ap, u64), false, false, left_pad, zero_pad, 16);
break;
#if !defined(BOOTSTRAPPER) && !defined(KERNEL)
#if !defined(KERNEL)
case 'g':
case 'f':
ret += print_double(putch, bufptr, va_arg(ap, double), left_pad, zero_pad, field_width, fraction_length);

View file

@ -42,8 +42,6 @@
#if defined(KERNEL)
# include <Kernel/Heap/kmalloc.h>
#elif defined(BOOTSTRAPPER)
# include <Bootstrapper/Memory/malloc.h>
#else
# include <stdlib.h>

View file

@ -27,8 +27,8 @@
#pragma once
#ifdef __serenity__
# if defined(KERNEL) || defined(BOOTSTRAPPER)
# include <LibBareMetal/Output/kstdio.h>
# ifdef KERNEL
# include <Kernel/kstdio.h>
# else
# include <AK/Types.h>
extern "C" {