diff options
-rw-r--r-- | Kernel/CMOS.h | 2 | ||||
-rw-r--r-- | Kernel/Devices/BXVGADevice.h | 2 | ||||
-rw-r--r-- | Kernel/Devices/BlockDevice.h | 1 | ||||
-rw-r--r-- | Kernel/Devices/IDEDiskDevice.cpp | 2 | ||||
-rw-r--r-- | Kernel/Devices/KeyboardDevice.cpp | 2 | ||||
-rw-r--r-- | Kernel/ELF/ELFImage.h | 1 | ||||
-rw-r--r-- | Kernel/FileDescriptor.h | 3 | ||||
-rw-r--r-- | Kernel/IO.h | 2 | ||||
-rw-r--r-- | Kernel/LinearAddress.h | 36 | ||||
-rw-r--r-- | Kernel/PIC.cpp | 2 | ||||
-rw-r--r-- | Kernel/PhysicalAddress.h | 25 | ||||
-rw-r--r-- | Kernel/Process.cpp | 2 | ||||
-rw-r--r-- | Kernel/Process.h | 2 | ||||
-rw-r--r-- | Kernel/RTC.h | 2 | ||||
-rw-r--r-- | Kernel/StdLib.cpp | 2 | ||||
-rw-r--r-- | Kernel/StdLib.h | 2 | ||||
-rw-r--r-- | Kernel/Thread.h | 2 | ||||
-rw-r--r-- | Kernel/UnixTypes.h | 32 | ||||
-rw-r--r-- | Kernel/VM/MemoryManager.h | 3 | ||||
-rw-r--r-- | Kernel/VM/PhysicalPage.h | 2 | ||||
-rw-r--r-- | Kernel/VM/VMObject.h | 2 | ||||
-rw-r--r-- | Kernel/i386.cpp | 2 | ||||
-rw-r--r-- | Kernel/i386.h | 2 | ||||
-rw-r--r-- | Kernel/init.cpp | 2 | ||||
-rw-r--r-- | Kernel/kmalloc.cpp | 2 | ||||
-rw-r--r-- | Kernel/system.h | 2 | ||||
-rw-r--r-- | Kernel/types.h | 101 |
27 files changed, 119 insertions, 121 deletions
diff --git a/Kernel/CMOS.h b/Kernel/CMOS.h index 37beea6222..e173c0b672 100644 --- a/Kernel/CMOS.h +++ b/Kernel/CMOS.h @@ -1,6 +1,6 @@ #pragma once -#include "types.h" +#include <AK/Types.h> namespace CMOS { diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h index 0025ac07a5..f7c80c63c2 100644 --- a/Kernel/Devices/BXVGADevice.h +++ b/Kernel/Devices/BXVGADevice.h @@ -3,7 +3,7 @@ #include <AK/Types.h> #include <AK/AKString.h> #include <SharedGraphics/Size.h> -#include <Kernel/types.h> +#include <Kernel/PhysicalAddress.h> #include <Kernel/Devices/BlockDevice.h> class BXVGADevice final : public BlockDevice { diff --git a/Kernel/Devices/BlockDevice.h b/Kernel/Devices/BlockDevice.h index 1161f7cbf8..2d9edfddc0 100644 --- a/Kernel/Devices/BlockDevice.h +++ b/Kernel/Devices/BlockDevice.h @@ -1,6 +1,7 @@ #pragma once #include <Kernel/Devices/Device.h> +#include <Kernel/LinearAddress.h> class BlockDevice : public Device { public: diff --git a/Kernel/Devices/IDEDiskDevice.cpp b/Kernel/Devices/IDEDiskDevice.cpp index 1b0eb27061..89d971b551 100644 --- a/Kernel/Devices/IDEDiskDevice.cpp +++ b/Kernel/Devices/IDEDiskDevice.cpp @@ -1,5 +1,5 @@ #include "IDEDiskDevice.h" -#include "types.h" +#include <AK/Types.h> #include "Process.h" #include "StdLib.h" #include "IO.h" diff --git a/Kernel/Devices/KeyboardDevice.cpp b/Kernel/Devices/KeyboardDevice.cpp index e5b57b7f84..1284d71b4b 100644 --- a/Kernel/Devices/KeyboardDevice.cpp +++ b/Kernel/Devices/KeyboardDevice.cpp @@ -1,4 +1,4 @@ -#include "types.h" +#include <AK/Types.h> #include "i386.h" #include "IO.h" #include "PIC.h" diff --git a/Kernel/ELF/ELFImage.h b/Kernel/ELF/ELFImage.h index 74fe4d90b1..7ad336fa9d 100644 --- a/Kernel/ELF/ELFImage.h +++ b/Kernel/ELF/ELFImage.h @@ -4,7 +4,6 @@ #include <AK/HashMap.h> #include <AK/AKString.h> #include <Kernel/ELF/exec_elf.h> -#include <Kernel/types.h> class ELFImage { public: diff --git a/Kernel/FileDescriptor.h b/Kernel/FileDescriptor.h index 80b3827c64..566015221d 100644 --- a/Kernel/FileDescriptor.h +++ b/Kernel/FileDescriptor.h @@ -2,7 +2,8 @@ #include <Kernel/FileSystem/VirtualFileSystem.h> #include <Kernel/FileSystem/InodeMetadata.h> -#include "FIFO.h" +#include <Kernel/LinearAddress.h> +#include <Kernel/FIFO.h> #include <AK/ByteBuffer.h> #include <AK/CircularQueue.h> #include <AK/Retainable.h> diff --git a/Kernel/IO.h b/Kernel/IO.h index 5761383375..cf99ca5ee6 100644 --- a/Kernel/IO.h +++ b/Kernel/IO.h @@ -1,6 +1,6 @@ #pragma once -#include "types.h" +#include <AK/Types.h> namespace IO { diff --git a/Kernel/LinearAddress.h b/Kernel/LinearAddress.h new file mode 100644 index 0000000000..c3064a9af4 --- /dev/null +++ b/Kernel/LinearAddress.h @@ -0,0 +1,36 @@ +#pragma once + +#include <AK/Types.h> + +class LinearAddress { +public: + LinearAddress() { } + explicit LinearAddress(dword address) : m_address(address) { } + + bool is_null() const { return m_address == 0; } + + LinearAddress offset(dword o) const { return LinearAddress(m_address + o); } + dword get() const { return m_address; } + void set(dword address) { m_address = address; } + void mask(dword m) { m_address &= m; } + + bool operator<=(const LinearAddress& other) const { return m_address <= other.m_address; } + bool operator>=(const LinearAddress& other) const { return m_address >= other.m_address; } + bool operator>(const LinearAddress& other) const { return m_address > other.m_address; } + bool operator<(const LinearAddress& other) const { return m_address < other.m_address; } + bool operator==(const LinearAddress& other) const { return m_address == other.m_address; } + bool operator!=(const LinearAddress& other) const { return m_address != other.m_address; } + + byte* as_ptr() { return reinterpret_cast<byte*>(m_address); } + const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); } + + dword page_base() const { return m_address & 0xfffff000; } + +private: + dword m_address { 0 }; +}; + +inline LinearAddress operator-(const LinearAddress& a, const LinearAddress& b) +{ + return LinearAddress(a.get() - b.get()); +} diff --git a/Kernel/PIC.cpp b/Kernel/PIC.cpp index ea0cf0a19d..31094849c7 100644 --- a/Kernel/PIC.cpp +++ b/Kernel/PIC.cpp @@ -1,4 +1,4 @@ -#include "types.h" +#include <AK/Types.h> #include "i386.h" #include "IO.h" #include "PIC.h" diff --git a/Kernel/PhysicalAddress.h b/Kernel/PhysicalAddress.h new file mode 100644 index 0000000000..1f8ff12b4f --- /dev/null +++ b/Kernel/PhysicalAddress.h @@ -0,0 +1,25 @@ +#pragma once + +class PhysicalAddress { +public: + PhysicalAddress() { } + explicit PhysicalAddress(dword address) : m_address(address) { } + + PhysicalAddress offset(dword o) const { return PhysicalAddress(m_address + o); } + dword get() const { return m_address; } + void set(dword address) { m_address = address; } + void mask(dword m) { m_address &= m; } + + bool is_null() const { return m_address == 0; } + + byte* as_ptr() { return reinterpret_cast<byte*>(m_address); } + const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); } + + dword page_base() const { return m_address & 0xfffff000; } + + bool operator==(const PhysicalAddress& other) const { return m_address == other.m_address; } + +private: + dword m_address { 0 }; +}; + diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 4a00c7cf4d..24a4531488 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1,4 +1,4 @@ -#include "types.h" +#include <AK/Types.h> #include "Process.h" #include "kmalloc.h" #include "StdLib.h" diff --git a/Kernel/Process.h b/Kernel/Process.h index fd0b589029..b6dd1df8ed 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -1,6 +1,6 @@ #pragma once -#include "types.h" +#include <AK/Types.h> #include <Kernel/TTY/TTY.h> #include "Syscall.h" #include <Kernel/FileSystem/VirtualFileSystem.h> diff --git a/Kernel/RTC.h b/Kernel/RTC.h index 54d9c9af50..7fe25b3392 100644 --- a/Kernel/RTC.h +++ b/Kernel/RTC.h @@ -1,6 +1,6 @@ #pragma once -#include "types.h" +#include <Kernel/UnixTypes.h> namespace RTC { diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp index 20c07f9341..41aa2c65df 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -1,4 +1,4 @@ -#include "types.h" +#include <AK/Types.h> #include "Assertions.h" #include "kmalloc.h" #include <AK/StdLibExtras.h> diff --git a/Kernel/StdLib.h b/Kernel/StdLib.h index 88a40eed6e..3f32de4797 100644 --- a/Kernel/StdLib.h +++ b/Kernel/StdLib.h @@ -1,6 +1,6 @@ #pragma once -#include <Kernel/types.h> +#include <AK/Types.h> extern "C" { diff --git a/Kernel/Thread.h b/Kernel/Thread.h index fec389c8b6..e6a0b99c81 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -3,6 +3,8 @@ #include <Kernel/i386.h> #include <Kernel/TSS.h> #include <Kernel/KResult.h> +#include <Kernel/LinearAddress.h> +#include <Kernel/UnixTypes.h> #include <AK/AKString.h> #include <AK/InlineLinkedList.h> #include <AK/RetainPtr.h> diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h index c3e9e6f89b..a941f6c340 100644 --- a/Kernel/UnixTypes.h +++ b/Kernel/UnixTypes.h @@ -1,5 +1,7 @@ #pragma once +#include <AK/Types.h> + #define WNOHANG 1 #define R_OK 4 @@ -222,6 +224,7 @@ typedef dword uid_t; typedef dword gid_t; typedef dword clock_t; typedef dword socklen_t; +typedef int pid_t; struct tms { clock_t tms_utime; @@ -359,3 +362,32 @@ struct sockaddr_in { struct in_addr sin_addr; char sin_zero[8]; }; + +typedef dword __u32; +typedef word __u16; +typedef byte __u8; +typedef int __s32; +typedef short __s16; + +typedef dword useconds_t; +typedef signed_dword suseconds_t; + +struct timeval { + time_t tv_sec; + suseconds_t tv_usec; +}; + +#define UTSNAME_ENTRY_LEN 65 + +struct utsname { + char sysname[UTSNAME_ENTRY_LEN]; + char nodename[UTSNAME_ENTRY_LEN]; + char release[UTSNAME_ENTRY_LEN]; + char version[UTSNAME_ENTRY_LEN]; + char machine[UTSNAME_ENTRY_LEN]; +}; + +struct [[gnu::packed]] FarPtr { + dword offset { 0 }; + word selector { 0 }; +}; diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h index b33ae2605f..d4b6a31089 100644 --- a/Kernel/VM/MemoryManager.h +++ b/Kernel/VM/MemoryManager.h @@ -1,6 +1,6 @@ #pragma once -#include "types.h" +#include <AK/Types.h> #include "i386.h" #include <AK/Bitmap.h> #include <AK/ByteBuffer.h> @@ -11,6 +11,7 @@ #include <AK/AKString.h> #include <AK/Badge.h> #include <AK/Weakable.h> +#include <Kernel/LinearAddress.h> #include <Kernel/VM/PhysicalPage.h> #include <Kernel/VM/Region.h> #include <Kernel/VM/VMObject.h> diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h index f3b15378dc..2d9cd88677 100644 --- a/Kernel/VM/PhysicalPage.h +++ b/Kernel/VM/PhysicalPage.h @@ -1,7 +1,7 @@ #pragma once #include <Kernel/Assertions.h> -#include <Kernel/types.h> +#include <Kernel/PhysicalAddress.h> #include <AK/Retained.h> class PhysicalPage { diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index f376fa25a4..658b8f622b 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -7,6 +7,8 @@ #include <AK/Vector.h> #include <AK/AKString.h> #include <Kernel/Lock.h> +#include <Kernel/PhysicalAddress.h> +#include <Kernel/UnixTypes.h> class Inode; class PhysicalPage; diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp index 717b717bd4..865c7a6755 100644 --- a/Kernel/i386.cpp +++ b/Kernel/i386.cpp @@ -1,4 +1,4 @@ -#include "types.h" +#include <AK/Types.h> #include "kmalloc.h" #include "i386.h" #include "Assertions.h" diff --git a/Kernel/i386.h b/Kernel/i386.h index 3b827fd660..abbecd961e 100644 --- a/Kernel/i386.h +++ b/Kernel/i386.h @@ -1,7 +1,7 @@ #pragma once -#include "types.h" #include "kprintf.h" +#include <Kernel/LinearAddress.h> #define PAGE_SIZE 4096 #define PAGE_MASK 0xfffff000 diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 831c6bc5a3..965c6efe0f 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -1,4 +1,4 @@ -#include "types.h" +#include <AK/Types.h> #include "kmalloc.h" #include "i386.h" #include "i8253.h" diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp index 81bdd46737..e52d80c607 100644 --- a/Kernel/kmalloc.cpp +++ b/Kernel/kmalloc.cpp @@ -3,7 +3,7 @@ * just to get going. Don't ever let anyone see this shit. :^) */ -#include <Kernel/types.h> +#include <AK/Types.h> #include <Kernel/kmalloc.h> #include <Kernel/StdLib.h> #include <Kernel/i386.h> diff --git a/Kernel/system.h b/Kernel/system.h index bd4572f95d..76ba1f5630 100644 --- a/Kernel/system.h +++ b/Kernel/system.h @@ -1,6 +1,6 @@ #pragma once -#include "types.h" +#include <AK/Types.h> struct system_t { diff --git a/Kernel/types.h b/Kernel/types.h deleted file mode 100644 index 5f517a7736..0000000000 --- a/Kernel/types.h +++ /dev/null @@ -1,101 +0,0 @@ -#pragma once - -#include <AK/Types.h> - -typedef dword __u32; -typedef word __u16; -typedef byte __u8; -typedef int __s32; -typedef short __s16; - -typedef dword uid_t; -typedef dword gid_t; -typedef signed_word pid_t; -typedef dword time_t; -typedef dword useconds_t; -typedef signed_dword suseconds_t; - -struct timeval { - time_t tv_sec; - suseconds_t tv_usec; -}; - -#define UTSNAME_ENTRY_LEN 65 - -struct utsname { - char sysname[UTSNAME_ENTRY_LEN]; - char nodename[UTSNAME_ENTRY_LEN]; - char release[UTSNAME_ENTRY_LEN]; - char version[UTSNAME_ENTRY_LEN]; - char machine[UTSNAME_ENTRY_LEN]; -}; - -typedef dword ino_t; -typedef signed_dword off_t; - -typedef dword dev_t; -typedef word mode_t; -typedef dword nlink_t; -typedef dword blksize_t; -typedef dword blkcnt_t; - -struct [[gnu::packed]] FarPtr { - dword offset { 0 }; - word selector { 0 }; -}; - -class PhysicalAddress { -public: - PhysicalAddress() { } - explicit PhysicalAddress(dword address) : m_address(address) { } - - PhysicalAddress offset(dword o) const { return PhysicalAddress(m_address + o); } - dword get() const { return m_address; } - void set(dword address) { m_address = address; } - void mask(dword m) { m_address &= m; } - - bool is_null() const { return m_address == 0; } - - byte* as_ptr() { return reinterpret_cast<byte*>(m_address); } - const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); } - - dword page_base() const { return m_address & 0xfffff000; } - - bool operator==(const PhysicalAddress& other) const { return m_address == other.m_address; } - -private: - dword m_address { 0 }; -}; - -class LinearAddress { -public: - LinearAddress() { } - explicit LinearAddress(dword address) : m_address(address) { } - - bool is_null() const { return m_address == 0; } - - LinearAddress offset(dword o) const { return LinearAddress(m_address + o); } - dword get() const { return m_address; } - void set(dword address) { m_address = address; } - void mask(dword m) { m_address &= m; } - - bool operator<=(const LinearAddress& other) const { return m_address <= other.m_address; } - bool operator>=(const LinearAddress& other) const { return m_address >= other.m_address; } - bool operator>(const LinearAddress& other) const { return m_address > other.m_address; } - bool operator<(const LinearAddress& other) const { return m_address < other.m_address; } - bool operator==(const LinearAddress& other) const { return m_address == other.m_address; } - bool operator!=(const LinearAddress& other) const { return m_address != other.m_address; } - - byte* as_ptr() { return reinterpret_cast<byte*>(m_address); } - const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); } - - dword page_base() const { return m_address & 0xfffff000; } - -private: - dword m_address { 0 }; -}; - -inline LinearAddress operator-(const LinearAddress& a, const LinearAddress& b) -{ - return LinearAddress(a.get() - b.get()); -} |