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
Notes: sideshowbarker 2024-07-19 06:36:47 +09:00
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" {

View File

@ -27,7 +27,7 @@
#include <AK/StringView.h>
#include <Kernel/ACPI/DMIDecoder.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/StdLib.h>
namespace Kernel {

View File

@ -30,8 +30,8 @@
#include <AK/Types.h>
#include <AK/Vector.h>
#include <Kernel/VM/Region.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VirtualAddress.h>
namespace Kernel {

View File

@ -29,7 +29,7 @@
#include <AK/RefCounted.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {

View File

@ -31,7 +31,7 @@
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h>
#include <Kernel/VM/PhysicalPage.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {
namespace ACPI {

View File

@ -28,7 +28,7 @@
#include <Kernel/ACPI/MultiProcessorParser.h>
#include <Kernel/Interrupts/IOAPIC.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/StdLib.h>
//#define MULTIPROCESSOR_DEBUG

View File

@ -28,8 +28,8 @@
#include <AK/Types.h>
#include <Kernel/VM/Region.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VirtualAddress.h>
namespace Kernel {
namespace MultiProcessor {

View File

@ -30,8 +30,8 @@
#include <Kernel/PCI/Access.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/TypedMapping.h>
#include <LibBareMetal/IO.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/IO.h>
#include <Kernel/StdLib.h>
namespace Kernel {
namespace ACPI {

View File

@ -31,8 +31,8 @@
#include <Kernel/ACPI/Initialize.h>
#include <Kernel/FileSystem/File.h>
#include <Kernel/VM/Region.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VirtualAddress.h>
namespace Kernel {
namespace ACPI {

View File

@ -39,7 +39,7 @@
#include <Kernel/KSyms.h>
#include <Kernel/Process.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
#include <LibC/mallocdefs.h>
//#define PAGE_FAULT_DEBUG

View File

@ -28,8 +28,8 @@
#include <AK/Badge.h>
#include <AK/Noncopyable.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VirtualAddress.h>
#define PAGE_SIZE 4096
#define GENERIC_INTERRUPT_HANDLERS_COUNT 128

View File

@ -25,7 +25,7 @@
*/
#include <Kernel/CMOS.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace CMOS {

View File

@ -7,8 +7,9 @@ set(KERNEL_SOURCES
Arch/i386/CPU.cpp
CMOS.cpp
CommandLine.cpp
Devices/BlockDevice.cpp
Console.cpp
Devices/BXVGADevice.cpp
Devices/BlockDevice.cpp
Devices/CharacterDevice.cpp
Devices/Device.cpp
Devices/DiskPartition.cpp
@ -33,8 +34,8 @@ set(KERNEL_SOURCES
FileSystem/DevPtsFS.cpp
FileSystem/Ext2FileSystem.cpp
FileSystem/FIFO.cpp
FileSystem/FileBackedFileSystem.cpp
FileSystem/File.cpp
FileSystem/FileBackedFileSystem.cpp
FileSystem/FileDescription.cpp
FileSystem/FileSystem.cpp
FileSystem/Inode.cpp
@ -43,14 +44,13 @@ set(KERNEL_SOURCES
FileSystem/ProcFS.cpp
FileSystem/TmpFS.cpp
FileSystem/VirtualFileSystem.cpp
Heap/kmalloc.cpp
Heap/SlabAllocator.cpp
init.cpp
Heap/kmalloc.cpp
Interrupts/APIC.cpp
Interrupts/GenericInterruptHandler.cpp
Interrupts/InterruptManagement.cpp
Interrupts/IOAPIC.cpp
Interrupts/IRQHandler.cpp
Interrupts/InterruptManagement.cpp
Interrupts/PIC.cpp
Interrupts/SharedIRQHandler.cpp
Interrupts/SpuriousInterruptHandler.cpp
@ -64,41 +64,42 @@ set(KERNEL_SOURCES
Net/LoopbackAdapter.cpp
Net/NetworkAdapter.cpp
Net/NetworkTask.cpp
Net/Routing.cpp
Net/RTL8139NetworkAdapter.cpp
Net/Routing.cpp
Net/Socket.cpp
Net/TCPSocket.cpp
Net/UDPSocket.cpp
PCI/Access.cpp
PCI/Device.cpp
PCI/Initializer.cpp
PCI/IOAccess.cpp
PCI/Initializer.cpp
PCI/MMIOAccess.cpp
PerformanceEventBuffer.cpp
Process.cpp
Profiling.cpp
Ptrace.cpp
Random.cpp
RTC.cpp
Random.cpp
Scheduler.cpp
SharedBuffer.cpp
StdLib.cpp
Syscall.cpp
Tasks/FinalizerTask.cpp
Tasks/SyncTask.cpp
Thread.cpp
ThreadTracer.cpp
Time/HardwareTimer.cpp
Time/HPETComparator.cpp
Time/HPET.cpp
Time/PIT.cpp
TimerQueue.cpp
Time/RTC.cpp
Time/TimeManagement.cpp
TTY/MasterPTY.cpp
TTY/PTYMultiplexer.cpp
TTY/SlavePTY.cpp
TTY/TTY.cpp
TTY/VirtualConsole.cpp
Tasks/FinalizerTask.cpp
Tasks/SyncTask.cpp
Thread.cpp
ThreadTracer.cpp
Time/HPET.cpp
Time/HPETComparator.cpp
Time/HardwareTimer.cpp
Time/PIT.cpp
Time/RTC.cpp
Time/TimeManagement.cpp
TimerQueue.cpp
VM/AnonymousVMObject.cpp
VM/ContiguousVMObject.cpp
VM/InodeVMObject.cpp
@ -114,6 +115,8 @@ set(KERNEL_SOURCES
VM/SharedInodeVMObject.cpp
VM/VMObject.cpp
WaitQueue.cpp
init.cpp
kprintf.cpp
)
set(AK_SOURCES
@ -135,17 +138,10 @@ set(ELF_SOURCES
../Libraries/LibELF/Validation.cpp
)
set(BARE_METAL_SOURCES
../Libraries/LibBareMetal/Output/Console.cpp
../Libraries/LibBareMetal/Output/kprintf.cpp
../Libraries/LibBareMetal/StdLib.cpp
)
set(SOURCES
${KERNEL_SOURCES}
${AK_SOURCES}
${ELF_SOURCES}
${BARE_METAL_SOURCES}
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKERNEL")

View File

@ -24,9 +24,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <LibBareMetal/IO.h>
#include <LibBareMetal/Output/Console.h>
#include <LibBareMetal/Output/kstdio.h>
#include <Kernel/Console.h>
#include <Kernel/IO.h>
#include <Kernel/kstdio.h>
// Bytes output to 0xE9 end up on the Bochs console. It's very handy.
#define CONSOLE_OUT_TO_E9
@ -45,9 +45,7 @@ bool Console::is_initialized()
}
Console::Console()
#if defined(KERNEL)
: CharacterDevice(5, 1)
#endif
{
s_the = this;
}
@ -56,7 +54,6 @@ Console::~Console()
{
}
#if defined(KERNEL)
bool Console::can_read(const Kernel::FileDescription&, size_t) const
{
return false;
@ -79,7 +76,6 @@ ssize_t Console::write(Kernel::FileDescription&, size_t, const u8* data, ssize_t
put_char(data[i]);
return size;
}
#endif
void Console::put_char(char ch)
{

View File

@ -28,9 +28,7 @@
#include <AK/CircularQueue.h>
#include <AK/Vector.h>
#if defined(KERNEL)
# include <Kernel/Devices/CharacterDevice.h>
#endif
#include <Kernel/Devices/CharacterDevice.h>
class ConsoleImplementation {
public:
@ -38,31 +36,22 @@ public:
virtual void on_sysconsole_receive(u8) = 0;
};
#if defined(KERNEL)
class Console final : public Kernel::CharacterDevice {
AK_MAKE_ETERNAL
#elif defined(BOOTSTRAPPER)
class Console {
#endif
public:
static Console& the();
static bool is_initialized();
Console();
#if defined(KERNEL)
virtual ~Console() override;
#elif defined(BOOTSTRAPPER)
virtual ~Console();
#endif
#if defined(KERNEL)
// ^CharacterDevice
virtual bool can_read(const Kernel::FileDescription&, size_t) const override;
virtual bool can_write(const Kernel::FileDescription&, size_t) const override { return true; }
virtual ssize_t read(Kernel::FileDescription&, size_t, u8*, ssize_t) override;
virtual ssize_t write(Kernel::FileDescription&, size_t, const u8*, ssize_t) override;
virtual const char* class_name() const override { return "Console"; }
#endif
void set_implementation(ConsoleImplementation* implementation)
{
m_implementation = implementation;

View File

@ -30,7 +30,7 @@
#include <Kernel/Process.h>
#include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
#include <LibC/errno_numbers.h>
#include <LibC/sys/ioctl_numbers.h>

View File

@ -29,7 +29,7 @@
#include <AK/String.h>
#include <AK/Types.h>
#include <Kernel/Devices/BlockDevice.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {

View File

@ -31,7 +31,7 @@
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Devices/KeyboardDevice.h>
#include <Kernel/TTY/VirtualConsole.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
//#define KEYBOARD_DEBUG

View File

@ -29,7 +29,7 @@
#include <AK/String.h>
#include <AK/Types.h>
#include <Kernel/Devices/BlockDevice.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {

View File

@ -31,7 +31,7 @@
#include <Kernel/FileSystem/ProcFS.h>
#include <Kernel/Process.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {

View File

@ -43,8 +43,8 @@
#include <Kernel/PCI/Device.h>
#include <Kernel/VM/PhysicalPage.h>
#include <Kernel/WaitQueue.h>
#include <LibBareMetal/IO.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/IO.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {

View File

@ -27,7 +27,7 @@
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Devices/PCSpeaker.h>
#include <Kernel/Time/PIT.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
void PCSpeaker::tone_on(int frequency)
{

View File

@ -27,7 +27,7 @@
#include <AK/Memory.h>
#include <Kernel/Devices/PS2MouseDevice.h>
#include <Kernel/Devices/VMWareBackdoor.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {

View File

@ -30,7 +30,7 @@
#include <Kernel/Thread.h>
#include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
//#define SB16_DEBUG

View File

@ -30,7 +30,7 @@
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/VM/PhysicalPage.h>
#include <Kernel/WaitQueue.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {

View File

@ -25,7 +25,7 @@
*/
#include <Kernel/Devices/SerialDevice.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {

View File

@ -30,7 +30,7 @@
#include <Kernel/CommandLine.h>
#include <Kernel/Devices/VMWareBackdoor.h>
#include <Kernel/MousePacket.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {

View File

@ -33,7 +33,7 @@
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/UnixTypes.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/VirtualAddress.h>
namespace Kernel {

View File

@ -34,7 +34,7 @@
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/KBuffer.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/VirtualAddress.h>
namespace Kernel {

View File

@ -54,8 +54,8 @@
#include <Kernel/TTY/TTY.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/PurgeableVMObject.h>
#include <LibBareMetal/Output/Console.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/Console.h>
#include <Kernel/StdLib.h>
#include <LibC/errno_numbers.h>
namespace Kernel {

View File

@ -38,7 +38,7 @@
#include <Kernel/KSyms.h>
#include <Kernel/Process.h>
#include <Kernel/Scheduler.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/StdLib.h>
#define SANITIZE_KMALLOC

View File

@ -30,10 +30,7 @@
#include <AK/LogStream.h>
#include <AK/String.h>
#include <AK/Types.h>
#if defined(KERNEL)
# include <Kernel/Arch/i386/CPU.h>
#endif
#include <Kernel/Arch/i386/CPU.h>
namespace IO {
@ -104,7 +101,7 @@ inline void delay(size_t microseconds)
class IOAddress {
public:
IOAddress() {}
IOAddress() { }
explicit IOAddress(u16 address)
: m_address(address)
{

View File

@ -31,7 +31,7 @@
#include <Kernel/Interrupts/APIC.h>
#include <Kernel/Interrupts/SpuriousInterruptHandler.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
#define IRQ_APIC_SPURIOUS 0x7f

View File

@ -37,7 +37,7 @@
#include <Kernel/Interrupts/UnhandledInterruptHandler.h>
#include <Kernel/Syscall.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
#define PCAT_COMPAT_FLAG 0x1

View File

@ -29,7 +29,7 @@
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Interrupts/GenericInterruptHandler.h>
#include <Kernel/Interrupts/PIC.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {

View File

@ -26,7 +26,7 @@
#include <Kernel/Net/E1000NetworkAdapter.h>
#include <Kernel/Thread.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
//#define E1000_DEBUG

View File

@ -32,7 +32,7 @@
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/PCI/Device.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {

View File

@ -30,7 +30,7 @@
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/Process.h>
#include <Kernel/UnixTypes.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/StdLib.h>
#include <LibC/errno_numbers.h>
//#define DEBUG_LOCAL_SOCKET

View File

@ -33,7 +33,7 @@
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/Random.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/StdLib.h>
namespace Kernel {

View File

@ -25,7 +25,7 @@
*/
#include <Kernel/Net/RTL8139NetworkAdapter.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
//#define RTL8139_DEBUG

View File

@ -30,7 +30,7 @@
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/PCI/Device.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {

View File

@ -25,7 +25,7 @@
*/
#include <Kernel/PCI/IOAccess.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {
namespace PCI {

View File

@ -31,7 +31,7 @@
#include <Kernel/PCI/IOAccess.h>
#include <Kernel/PCI/Initializer.h>
#include <Kernel/PCI/MMIOAccess.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {
namespace PCI {

View File

@ -73,9 +73,9 @@
#include <Kernel/VM/ProcessPagingScope.h>
#include <Kernel/VM/PurgeableVMObject.h>
#include <Kernel/VM/SharedInodeVMObject.h>
#include <LibBareMetal/IO.h>
#include <LibBareMetal/Output/Console.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/IO.h>
#include <Kernel/Console.h>
#include <Kernel/StdLib.h>
#include <LibC/errno_numbers.h>
#include <LibC/limits.h>
#include <LibC/signal_numbers.h>

View File

@ -39,7 +39,7 @@
#include <Kernel/Thread.h>
#include <Kernel/UnixTypes.h>
#include <Kernel/VM/RangeAllocator.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/StdLib.h>
#include <LibC/signal_numbers.h>
namespace ELF {

View File

@ -27,26 +27,20 @@
#include <AK/Assertions.h>
#include <AK/String.h>
#include <AK/Types.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Heap/kmalloc.h>
#include <Kernel/StdLib.h>
#include <Kernel/VM/MemoryManager.h>
#ifdef KERNEL
# include <Kernel/Arch/i386/CPU.h>
# include <Kernel/Heap/kmalloc.h>
# include <Kernel/VM/MemoryManager.h>
#endif
#ifdef KERNEL
String copy_string_from_user(const char* user_str, size_t user_str_size)
{
Kernel::SmapDisabler disabler;
size_t length = strnlen(user_str, user_str_size);
return String(user_str, length);
}
#endif
extern "C" {
#ifdef KERNEL
void copy_to_user(void* dest_ptr, const void* src_ptr, size_t n)
{
ASSERT(Kernel::is_user_range(VirtualAddress(dest_ptr), n));
@ -62,7 +56,6 @@ void copy_from_user(void* dest_ptr, const void* src_ptr, size_t n)
Kernel::SmapDisabler disabler;
memcpy(dest_ptr, src_ptr, n);
}
#endif
void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
{
@ -117,14 +110,12 @@ char* strncpy(char* dest, const char* src, size_t n)
return dest;
}
#ifdef KERNEL
void memset_user(void* dest_ptr, int c, size_t n)
{
ASSERT(Kernel::is_user_range(VirtualAddress(dest_ptr), n));
Kernel::SmapDisabler disabler;
memset(dest_ptr, c, n);
}
#endif
void* memset(void* dest_ptr, int c, size_t n)
{
@ -243,12 +234,10 @@ char* strstr(const char* haystack, const char* needle)
ASSERT_NOT_REACHED();
}
#ifdef KERNEL
void* realloc(void* p, size_t s)
{
return krealloc(p, s);
}
#endif
void free(void* p)
{

View File

@ -26,31 +26,21 @@
#pragma once
#include <AK/Types.h>
#if defined(KERNEL)
namespace AK {
class String;
}
#include <AK/Forward.h>
namespace Syscall {
struct StringArgument;
}
AK::String copy_string_from_user(const char*, size_t);
#endif
String copy_string_from_user(const char*, size_t);
extern "C" {
static_assert(sizeof(size_t) == 4);
#if defined(KERNEL)
void copy_to_user(void*, const void*, size_t);
void copy_from_user(void*, const void*, size_t);
void memset_user(void*, int, size_t);
#endif
void* memcpy(void*, const void*, size_t);
char* strcpy(char*, const char*);
@ -70,8 +60,6 @@ inline u16 ntohs(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); }
inline u16 htons(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); }
}
#if defined(KERNEL)
template<typename T>
inline void copy_from_user(T* dest, const T* src)
{
@ -83,5 +71,3 @@ inline void copy_to_user(T* dest, const T* src)
{
copy_to_user(dest, src, sizeof(T));
}
#endif

View File

@ -29,8 +29,8 @@
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Devices/KeyboardDevice.h>
#include <Kernel/Heap/kmalloc.h>
#include <LibBareMetal/IO.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/IO.h>
#include <Kernel/StdLib.h>
namespace Kernel {

View File

@ -28,7 +28,7 @@
#include <Kernel/Devices/KeyboardDevice.h>
#include <Kernel/TTY/TTY.h>
#include <LibBareMetal/Output/Console.h>
#include <Kernel/Console.h>
namespace Kernel {

View File

@ -31,8 +31,8 @@
#include <AK/OwnPtr.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VM/Region.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
namespace Kernel {

View File

@ -30,7 +30,7 @@
#include <Kernel/Thread.h>
#include <Kernel/Time/PIT.h>
#include <Kernel/Time/TimeManagement.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
#define IRQ_TIMER 0
namespace Kernel {

View File

@ -28,7 +28,7 @@
#include <Kernel/CMOS.h>
#include <Kernel/Time/RTC.h>
#include <Kernel/Time/TimeManagement.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
namespace Kernel {
#define IRQ_TIMER 8

View File

@ -27,7 +27,7 @@
#pragma once
#include <Kernel/VM/VMObject.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {

View File

@ -27,7 +27,7 @@
#pragma once
#include <Kernel/VM/VMObject.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {

View File

@ -39,7 +39,7 @@
#include <Kernel/VM/PhysicalRegion.h>
#include <Kernel/VM/PurgeableVMObject.h>
#include <Kernel/VM/SharedInodeVMObject.h>
#include <LibBareMetal/StdLib.h>
#include <Kernel/StdLib.h>
//#define MM_DEBUG
//#define PAGE_FAULT_DEBUG

View File

@ -29,7 +29,7 @@
#include <AK/NonnullRefPtr.h>
#include <Kernel/Assertions.h>
#include <Kernel/Heap/SlabAllocator.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {

View File

@ -29,7 +29,7 @@
#include <AK/String.h>
#include <AK/Traits.h>
#include <AK/Vector.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/VirtualAddress.h>
namespace Kernel {

View File

@ -26,16 +26,13 @@
#include <AK/PrintfImplementation.h>
#include <AK/Types.h>
#include <LibBareMetal/IO.h>
#include <LibBareMetal/Output/Console.h>
#include <LibBareMetal/Output/kstdio.h>
#include <Kernel/Console.h>
#include <Kernel/IO.h>
#include <Kernel/Process.h>
#include <Kernel/kstdio.h>
#include <LibC/stdarg.h>
#if defined(KERNEL)
# include <Kernel/Process.h>
#endif
static bool serial_debug;
void set_serial_debug(bool on_or_off)

View File

@ -38,13 +38,7 @@ void set_serial_debug(bool on_or_off);
int get_serial_debug();
}
#if defined(KERNEL) || defined(BOOTSTRAPPER)
# define printf dbgprintf
#endif
#ifndef __serenity__
# define dbgprintf printf
#endif
#define printf dbgprintf
#ifdef __cplusplus

View File

@ -26,7 +26,7 @@
#pragma once
#if defined(KERNEL) || defined(BOOTSTRAPPER)
#if defined(KERNEL)
# define __BEGIN_DECLS
# define __END_DECLS
#else

View File

@ -27,7 +27,7 @@
#pragma once
#include <AK/Assertions.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/VirtualAddress.h>
#include <LibELF/exec_elf.h>
namespace ELF {

View File

@ -30,7 +30,7 @@
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/String.h>
#include <LibBareMetal/Memory/VirtualAddress.h>
#include <Kernel/VirtualAddress.h>
#include <LibELF/exec_elf.h>
namespace ELF {

View File

@ -35,7 +35,7 @@
#include <LibELF/Image.h>
#ifdef KERNEL
# include <LibBareMetal/Memory/VirtualAddress.h>
# include <Kernel/VirtualAddress.h>
namespace Kernel {
class Region;
}

View File

@ -28,7 +28,7 @@
#include <AK/Function.h>
#include <AK/String.h>
#include <Kernel/Syscall.h>
#include <LibBareMetal/IO.h>
#include <Kernel/IO.h>
#include <LibCore/ArgsParser.h>
#include <stdio.h>
#include <stdlib.h>