types.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #pragma once
  2. #include <AK/Types.h>
  3. #define PACKED __attribute__ ((packed))
  4. #define NORETURN __attribute__ ((noreturn))
  5. #define ALWAYS_INLINE __attribute__ ((always_inline))
  6. #define PURE __attribute__ ((pure))
  7. #define PUBLIC
  8. #define PRIVATE static
  9. typedef unsigned char BYTE;
  10. typedef unsigned short WORD;
  11. typedef unsigned int DWORD;
  12. typedef DWORD __u32;
  13. typedef WORD __u16;
  14. typedef BYTE __u8;
  15. typedef int __s32;
  16. typedef short __s16;
  17. typedef DWORD uid_t;
  18. typedef DWORD gid_t;
  19. typedef int pid_t;
  20. typedef DWORD time_t;
  21. typedef DWORD suseconds_t;
  22. typedef DWORD size_t;
  23. struct timeval {
  24. time_t tv_sec;
  25. suseconds_t tv_usec;
  26. };
  27. #define UTSNAME_ENTRY_LEN 65
  28. struct utsname {
  29. char sysname[UTSNAME_ENTRY_LEN];
  30. char nodename[UTSNAME_ENTRY_LEN];
  31. char release[UTSNAME_ENTRY_LEN];
  32. char version[UTSNAME_ENTRY_LEN];
  33. char machine[UTSNAME_ENTRY_LEN];
  34. };
  35. typedef dword ino_t;
  36. typedef signed_dword off_t;
  37. typedef dword dev_t;
  38. typedef dword mode_t;
  39. typedef dword nlink_t;
  40. typedef dword blksize_t;
  41. typedef dword blkcnt_t;
  42. typedef dword time_t;
  43. typedef dword suseconds_t;
  44. struct FarPtr {
  45. DWORD offset { 0 };
  46. WORD selector { 0 };
  47. } PACKED;
  48. class PhysicalAddress {
  49. public:
  50. PhysicalAddress() { }
  51. explicit PhysicalAddress(dword address) : m_address(address) { }
  52. dword get() const { return m_address; }
  53. void set(dword address) { m_address = address; }
  54. void mask(dword m) { m_address &= m; }
  55. bool is_null() const { return m_address == 0; }
  56. byte* asPtr() { return reinterpret_cast<byte*>(m_address); }
  57. const byte* asPtr() const { return reinterpret_cast<const byte*>(m_address); }
  58. dword pageBase() const { return m_address & 0xfffff000; }
  59. private:
  60. dword m_address { 0 };
  61. };
  62. class LinearAddress {
  63. public:
  64. LinearAddress() { }
  65. explicit LinearAddress(dword address) : m_address(address) { }
  66. bool isNull() const { return m_address == 0; }
  67. LinearAddress offset(dword o) const { return LinearAddress(m_address + o); }
  68. dword get() const { return m_address; }
  69. void set(dword address) { m_address = address; }
  70. void mask(dword m) { m_address &= m; }
  71. bool operator<=(const LinearAddress& other) const { return m_address <= other.m_address; }
  72. bool operator>=(const LinearAddress& other) const { return m_address >= other.m_address; }
  73. bool operator>(const LinearAddress& other) const { return m_address > other.m_address; }
  74. bool operator<(const LinearAddress& other) const { return m_address < other.m_address; }
  75. bool operator==(const LinearAddress& other) const { return m_address == other.m_address; }
  76. byte* asPtr() { return reinterpret_cast<byte*>(m_address); }
  77. const byte* asPtr() const { return reinterpret_cast<const byte*>(m_address); }
  78. dword pageBase() const { return m_address & 0xfffff000; }
  79. private:
  80. dword m_address { 0 };
  81. };