2018-10-16 09:01:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-18 11:05:00 +00:00
|
|
|
#include <AK/Types.h>
|
|
|
|
|
2018-10-16 09:01:38 +00:00
|
|
|
#define PACKED __attribute__ ((packed))
|
|
|
|
#define NORETURN __attribute__ ((noreturn))
|
2018-10-22 10:55:59 +00:00
|
|
|
#define ALWAYS_INLINE __attribute__ ((always_inline))
|
2018-10-16 09:01:38 +00:00
|
|
|
#define PURE __attribute__ ((pure))
|
|
|
|
#define PUBLIC
|
|
|
|
#define PRIVATE static
|
|
|
|
|
|
|
|
typedef unsigned char BYTE;
|
|
|
|
typedef unsigned short WORD;
|
|
|
|
typedef unsigned int DWORD;
|
|
|
|
|
|
|
|
typedef DWORD __u32;
|
|
|
|
typedef WORD __u16;
|
|
|
|
typedef BYTE __u8;
|
|
|
|
typedef int __s32;
|
|
|
|
typedef short __s16;
|
|
|
|
|
|
|
|
typedef DWORD uid_t;
|
|
|
|
typedef DWORD gid_t;
|
|
|
|
typedef int pid_t;
|
|
|
|
typedef DWORD time_t;
|
2018-10-25 15:29:49 +00:00
|
|
|
typedef DWORD suseconds_t;
|
2018-10-16 09:01:38 +00:00
|
|
|
typedef DWORD size_t;
|
2018-10-16 09:06:35 +00:00
|
|
|
|
2018-10-25 15:29:49 +00:00
|
|
|
struct timeval {
|
|
|
|
time_t tv_sec;
|
|
|
|
suseconds_t tv_usec;
|
|
|
|
};
|
|
|
|
|
2018-10-26 12:56:21 +00:00
|
|
|
#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];
|
|
|
|
};
|
|
|
|
|
2018-10-26 22:25:08 +00:00
|
|
|
typedef dword ino_t;
|
|
|
|
typedef signed_dword off_t;
|
|
|
|
|
|
|
|
typedef dword dev_t;
|
|
|
|
typedef dword mode_t;
|
|
|
|
typedef dword nlink_t;
|
|
|
|
typedef dword blksize_t;
|
|
|
|
typedef dword blkcnt_t;
|
|
|
|
typedef dword time_t;
|
|
|
|
typedef dword suseconds_t;
|
|
|
|
|
2018-10-16 09:06:35 +00:00
|
|
|
struct FarPtr {
|
|
|
|
DWORD offset { 0 };
|
|
|
|
WORD selector { 0 };
|
|
|
|
} PACKED;
|
2018-10-18 11:05:00 +00:00
|
|
|
|
|
|
|
class PhysicalAddress {
|
|
|
|
public:
|
|
|
|
PhysicalAddress() { }
|
|
|
|
explicit PhysicalAddress(dword address) : m_address(address) { }
|
|
|
|
|
|
|
|
dword get() const { return m_address; }
|
|
|
|
void set(dword address) { m_address = address; }
|
|
|
|
void mask(dword m) { m_address &= m; }
|
|
|
|
|
2018-11-01 22:04:34 +00:00
|
|
|
bool is_null() const { return m_address == 0; }
|
|
|
|
|
2018-10-18 11:05:00 +00:00
|
|
|
byte* asPtr() { return reinterpret_cast<byte*>(m_address); }
|
|
|
|
const byte* asPtr() const { return reinterpret_cast<const byte*>(m_address); }
|
|
|
|
|
|
|
|
dword pageBase() const { return m_address & 0xfffff000; }
|
|
|
|
|
2018-11-02 23:31:42 +00:00
|
|
|
bool operator==(const PhysicalAddress& other) const { return m_address == other.m_address; }
|
|
|
|
|
2018-10-18 11:05:00 +00:00
|
|
|
private:
|
|
|
|
dword m_address { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
class LinearAddress {
|
|
|
|
public:
|
|
|
|
LinearAddress() { }
|
|
|
|
explicit LinearAddress(dword address) : m_address(address) { }
|
|
|
|
|
2018-10-27 12:56:52 +00:00
|
|
|
bool isNull() const { return m_address == 0; }
|
|
|
|
|
2018-10-18 11:05:00 +00:00
|
|
|
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; }
|
|
|
|
|
2018-10-26 22:14:24 +00:00
|
|
|
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; }
|
2018-10-18 11:05:00 +00:00
|
|
|
bool operator==(const LinearAddress& other) const { return m_address == other.m_address; }
|
|
|
|
|
|
|
|
byte* asPtr() { return reinterpret_cast<byte*>(m_address); }
|
|
|
|
const byte* asPtr() const { return reinterpret_cast<const byte*>(m_address); }
|
|
|
|
|
|
|
|
dword pageBase() const { return m_address & 0xfffff000; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
dword m_address { 0 };
|
|
|
|
};
|