Kernel: Get rid of Kernel/types.h, separate LinearAddress/PhysicalAddress.
This commit is contained in:
parent
6306cf5c27
commit
a58d7fd8bb
Notes:
sideshowbarker
2024-07-19 14:48:17 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a58d7fd8bb0
27 changed files with 119 additions and 121 deletions
Kernel
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace CMOS {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Kernel/Devices/Device.h>
|
||||
#include <Kernel/LinearAddress.h>
|
||||
|
||||
class BlockDevice : public Device {
|
||||
public:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "IDEDiskDevice.h"
|
||||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
#include "Process.h"
|
||||
#include "StdLib.h"
|
||||
#include "IO.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
#include "i386.h"
|
||||
#include "IO.h"
|
||||
#include "PIC.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:
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace IO {
|
||||
|
||||
|
|
36
Kernel/LinearAddress.h
Normal file
36
Kernel/LinearAddress.h
Normal file
|
@ -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());
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
#include "i386.h"
|
||||
#include "IO.h"
|
||||
#include "PIC.h"
|
||||
|
|
25
Kernel/PhysicalAddress.h
Normal file
25
Kernel/PhysicalAddress.h
Normal file
|
@ -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 };
|
||||
};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
#include "Process.h"
|
||||
#include "kmalloc.h"
|
||||
#include "StdLib.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>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include <Kernel/UnixTypes.h>
|
||||
|
||||
namespace RTC {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
#include "Assertions.h"
|
||||
#include "kmalloc.h"
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <Kernel/types.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Kernel/Assertions.h>
|
||||
#include <Kernel/types.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
#include <AK/Retained.h>
|
||||
|
||||
class PhysicalPage {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
#include "kmalloc.h"
|
||||
#include "i386.h"
|
||||
#include "Assertions.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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
#include "kmalloc.h"
|
||||
#include "i386.h"
|
||||
#include "i8253.h"
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include <AK/Types.h>
|
||||
|
||||
struct system_t
|
||||
{
|
||||
|
|
101
Kernel/types.h
101
Kernel/types.h
|
@ -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());
|
||||
}
|
Loading…
Add table
Reference in a new issue