mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-27 15:04:33 +00:00
Fix type sizes
This commit is contained in:
parent
06e34ab57f
commit
816e5461c9
@ -184,7 +184,7 @@ namespace ACPI
|
|||||||
uint64_t Address = ((IsCanonical(acpi->FADT->X_Dsdt) && acpi->XSDTSupported) ? acpi->FADT->X_Dsdt : acpi->FADT->Dsdt);
|
uint64_t Address = ((IsCanonical(acpi->FADT->X_Dsdt) && acpi->XSDTSupported) ? acpi->FADT->X_Dsdt : acpi->FADT->Dsdt);
|
||||||
uint8_t *S5Address = (uint8_t *)(Address) + 36;
|
uint8_t *S5Address = (uint8_t *)(Address) + 36;
|
||||||
ACPI::ACPI::ACPIHeader *Header = (ACPI::ACPI::ACPIHeader *)Address;
|
ACPI::ACPI::ACPIHeader *Header = (ACPI::ACPI::ACPIHeader *)Address;
|
||||||
uint64_t Length = Header->Length;
|
size_t Length = Header->Length;
|
||||||
while (Length-- > 0)
|
while (Length-- > 0)
|
||||||
{
|
{
|
||||||
if (!memcmp(S5Address, "_S5_", 4))
|
if (!memcmp(S5Address, "_S5_", 4))
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
|
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||||
|
|
||||||
/* Source: https://github.com/glitchub/arith64 */
|
/* Source: https://github.com/glitchub/arith64 */
|
||||||
#define arith64_u64 unsigned long long int
|
#define arith64_u64 unsigned long long int
|
||||||
#define arith64_s64 signed long long int
|
#define arith64_s64 signed long long int
|
||||||
@ -6,28 +10,28 @@
|
|||||||
|
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
arith64_u64 u64;
|
arith64_u64 u64;
|
||||||
arith64_s64 s64;
|
arith64_s64 s64;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
arith64_u32 hi;
|
arith64_u32 hi;
|
||||||
arith64_u32 lo;
|
arith64_u32 lo;
|
||||||
#else
|
#else
|
||||||
arith64_u32 lo;
|
arith64_u32 lo;
|
||||||
arith64_u32 hi;
|
arith64_u32 hi;
|
||||||
#endif
|
#endif
|
||||||
} u32;
|
} u32;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
arith64_s32 hi;
|
arith64_s32 hi;
|
||||||
arith64_s32 lo;
|
arith64_s32 lo;
|
||||||
#else
|
#else
|
||||||
arith64_s32 lo;
|
arith64_s32 lo;
|
||||||
arith64_s32 hi;
|
arith64_s32 hi;
|
||||||
#endif
|
#endif
|
||||||
} s32;
|
} s32;
|
||||||
} arith64_word;
|
} arith64_word;
|
||||||
|
|
||||||
#define arith64_hi(n) (arith64_word){.u64 = n}.u32.hi
|
#define arith64_hi(n) (arith64_word){.u64 = n}.u32.hi
|
||||||
@ -37,234 +41,234 @@ typedef union
|
|||||||
|
|
||||||
arith64_s64 __absvdi2(arith64_s64 a)
|
arith64_s64 __absvdi2(arith64_s64 a)
|
||||||
{
|
{
|
||||||
return arith64_abs(a);
|
return arith64_abs(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
arith64_s64 __ashldi3(arith64_s64 a, int b)
|
arith64_s64 __ashldi3(arith64_s64 a, int b)
|
||||||
{
|
{
|
||||||
arith64_word w = {.s64 = a};
|
arith64_word w = {.s64 = a};
|
||||||
|
|
||||||
b &= 63;
|
b &= 63;
|
||||||
|
|
||||||
if (b >= 32)
|
if (b >= 32)
|
||||||
{
|
{
|
||||||
w.u32.hi = w.u32.lo << (b - 32);
|
w.u32.hi = w.u32.lo << (b - 32);
|
||||||
w.u32.lo = 0;
|
w.u32.lo = 0;
|
||||||
}
|
}
|
||||||
else if (b)
|
else if (b)
|
||||||
{
|
{
|
||||||
w.u32.hi = (w.u32.lo >> (32 - b)) | (w.u32.hi << b);
|
w.u32.hi = (w.u32.lo >> (32 - b)) | (w.u32.hi << b);
|
||||||
w.u32.lo <<= b;
|
w.u32.lo <<= b;
|
||||||
}
|
}
|
||||||
return w.s64;
|
return w.s64;
|
||||||
}
|
}
|
||||||
|
|
||||||
arith64_s64 __ashrdi3(arith64_s64 a, int b)
|
arith64_s64 __ashrdi3(arith64_s64 a, int b)
|
||||||
{
|
{
|
||||||
arith64_word w = {.s64 = a};
|
arith64_word w = {.s64 = a};
|
||||||
|
|
||||||
b &= 63;
|
b &= 63;
|
||||||
|
|
||||||
if (b >= 32)
|
if (b >= 32)
|
||||||
{
|
{
|
||||||
w.s32.lo = w.s32.hi >> (b - 32);
|
w.s32.lo = w.s32.hi >> (b - 32);
|
||||||
w.s32.hi >>= 31; // 0xFFFFFFFF or 0
|
w.s32.hi >>= 31; // 0xFFFFFFFF or 0
|
||||||
}
|
}
|
||||||
else if (b)
|
else if (b)
|
||||||
{
|
{
|
||||||
w.u32.lo = (w.u32.hi << (32 - b)) | (w.u32.lo >> b);
|
w.u32.lo = (w.u32.hi << (32 - b)) | (w.u32.lo >> b);
|
||||||
w.s32.hi >>= b;
|
w.s32.hi >>= b;
|
||||||
}
|
}
|
||||||
return w.s64;
|
return w.s64;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __clzsi2(arith64_u32 a)
|
int __clzsi2(arith64_u32 a)
|
||||||
{
|
{
|
||||||
int b, n = 0;
|
int b, n = 0;
|
||||||
b = !(a & 0xffff0000) << 4;
|
b = !(a & 0xffff0000) << 4;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
b = !(a & 0xff000000) << 3;
|
b = !(a & 0xff000000) << 3;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
b = !(a & 0xf0000000) << 2;
|
b = !(a & 0xf0000000) << 2;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
b = !(a & 0xc0000000) << 1;
|
b = !(a & 0xc0000000) << 1;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
return n + !(a & 0x80000000);
|
return n + !(a & 0x80000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __clzdi2(arith64_u64 a)
|
int __clzdi2(arith64_u64 a)
|
||||||
{
|
{
|
||||||
int b, n = 0;
|
int b, n = 0;
|
||||||
b = !(a & 0xffffffff00000000ULL) << 5;
|
b = !(a & 0xffffffff00000000ULL) << 5;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
b = !(a & 0xffff000000000000ULL) << 4;
|
b = !(a & 0xffff000000000000ULL) << 4;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
b = !(a & 0xff00000000000000ULL) << 3;
|
b = !(a & 0xff00000000000000ULL) << 3;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
b = !(a & 0xf000000000000000ULL) << 2;
|
b = !(a & 0xf000000000000000ULL) << 2;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
b = !(a & 0xc000000000000000ULL) << 1;
|
b = !(a & 0xc000000000000000ULL) << 1;
|
||||||
n += b;
|
n += b;
|
||||||
a <<= b;
|
a <<= b;
|
||||||
return n + !(a & 0x8000000000000000ULL);
|
return n + !(a & 0x8000000000000000ULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __ctzsi2(arith64_u32 a)
|
int __ctzsi2(arith64_u32 a)
|
||||||
{
|
{
|
||||||
int b, n = 0;
|
int b, n = 0;
|
||||||
b = !(a & 0x0000ffff) << 4;
|
b = !(a & 0x0000ffff) << 4;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
b = !(a & 0x000000ff) << 3;
|
b = !(a & 0x000000ff) << 3;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
b = !(a & 0x0000000f) << 2;
|
b = !(a & 0x0000000f) << 2;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
b = !(a & 0x00000003) << 1;
|
b = !(a & 0x00000003) << 1;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
return n + !(a & 0x00000001);
|
return n + !(a & 0x00000001);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __ctzdi2(arith64_u64 a)
|
int __ctzdi2(arith64_u64 a)
|
||||||
{
|
{
|
||||||
int b, n = 0;
|
int b, n = 0;
|
||||||
b = !(a & 0x00000000ffffffffULL) << 5;
|
b = !(a & 0x00000000ffffffffULL) << 5;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
b = !(a & 0x000000000000ffffULL) << 4;
|
b = !(a & 0x000000000000ffffULL) << 4;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
b = !(a & 0x00000000000000ffULL) << 3;
|
b = !(a & 0x00000000000000ffULL) << 3;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
b = !(a & 0x000000000000000fULL) << 2;
|
b = !(a & 0x000000000000000fULL) << 2;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
b = !(a & 0x0000000000000003ULL) << 1;
|
b = !(a & 0x0000000000000003ULL) << 1;
|
||||||
n += b;
|
n += b;
|
||||||
a >>= b;
|
a >>= b;
|
||||||
return n + !(a & 0x0000000000000001ULL);
|
return n + !(a & 0x0000000000000001ULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
arith64_u64 __divmoddi4(arith64_u64 a, arith64_u64 b, arith64_u64 *c)
|
arith64_u64 __divmoddi4(arith64_u64 a, arith64_u64 b, arith64_u64 *c)
|
||||||
{
|
{
|
||||||
if (b > a)
|
if (b > a)
|
||||||
{
|
{
|
||||||
if (c)
|
if (c)
|
||||||
*c = a;
|
*c = a;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!arith64_hi(b))
|
if (!arith64_hi(b))
|
||||||
{
|
{
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
{
|
{
|
||||||
volatile char x = 0;
|
volatile char x = 0;
|
||||||
x = 1 / x;
|
x = 1 / x;
|
||||||
}
|
}
|
||||||
if (b == 1)
|
if (b == 1)
|
||||||
{
|
{
|
||||||
if (c)
|
if (c)
|
||||||
*c = 0;
|
*c = 0;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
if (!arith64_hi(a))
|
if (!arith64_hi(a))
|
||||||
{
|
{
|
||||||
if (c)
|
if (c)
|
||||||
*c = arith64_lo(a) % arith64_lo(b);
|
*c = arith64_lo(a) % arith64_lo(b);
|
||||||
return arith64_lo(a) / arith64_lo(b);
|
return arith64_lo(a) / arith64_lo(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char bits = __clzdi2(b) - __clzdi2(a) + 1;
|
char bits = __clzdi2(b) - __clzdi2(a) + 1;
|
||||||
arith64_u64 rem = a >> bits;
|
arith64_u64 rem = a >> bits;
|
||||||
a <<= 64 - bits;
|
a <<= 64 - bits;
|
||||||
arith64_u64 wrap = 0;
|
arith64_u64 wrap = 0;
|
||||||
while (bits-- > 0)
|
while (bits-- > 0)
|
||||||
{
|
{
|
||||||
rem = (rem << 1) | (a >> 63);
|
rem = (rem << 1) | (a >> 63);
|
||||||
a = (a << 1) | (wrap & 1);
|
a = (a << 1) | (wrap & 1);
|
||||||
wrap = ((arith64_s64)(b - rem - 1) >> 63);
|
wrap = ((arith64_s64)(b - rem - 1) >> 63);
|
||||||
rem -= b & wrap;
|
rem -= b & wrap;
|
||||||
}
|
}
|
||||||
if (c)
|
if (c)
|
||||||
*c = rem;
|
*c = rem;
|
||||||
return (a << 1) | (wrap & 1);
|
return (a << 1) | (wrap & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
arith64_s64 __divdi3(arith64_s64 a, arith64_s64 b)
|
arith64_s64 __divdi3(arith64_s64 a, arith64_s64 b)
|
||||||
{
|
{
|
||||||
arith64_u64 q = __divmoddi4(arith64_abs(a), arith64_abs(b), (void *)0);
|
arith64_u64 q = __divmoddi4(arith64_abs(a), arith64_abs(b), (void *)0);
|
||||||
return arith64_neg(q, a ^ b);
|
return arith64_neg(q, a ^ b);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __ffsdi2(arith64_u64 a) { return a ? __ctzdi2(a) + 1 : 0; }
|
int __ffsdi2(arith64_u64 a) { return a ? __ctzdi2(a) + 1 : 0; }
|
||||||
|
|
||||||
arith64_u64 __lshrdi3(arith64_u64 a, int b)
|
arith64_u64 __lshrdi3(arith64_u64 a, int b)
|
||||||
{
|
{
|
||||||
arith64_word w = {.u64 = a};
|
arith64_word w = {.u64 = a};
|
||||||
|
|
||||||
b &= 63;
|
b &= 63;
|
||||||
|
|
||||||
if (b >= 32)
|
if (b >= 32)
|
||||||
{
|
{
|
||||||
w.u32.lo = w.u32.hi >> (b - 32);
|
w.u32.lo = w.u32.hi >> (b - 32);
|
||||||
w.u32.hi = 0;
|
w.u32.hi = 0;
|
||||||
}
|
}
|
||||||
else if (b)
|
else if (b)
|
||||||
{
|
{
|
||||||
w.u32.lo = (w.u32.hi << (32 - b)) | (w.u32.lo >> b);
|
w.u32.lo = (w.u32.hi << (32 - b)) | (w.u32.lo >> b);
|
||||||
w.u32.hi >>= b;
|
w.u32.hi >>= b;
|
||||||
}
|
}
|
||||||
return w.u64;
|
return w.u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
arith64_s64 __moddi3(arith64_s64 a, arith64_s64 b)
|
arith64_s64 __moddi3(arith64_s64 a, arith64_s64 b)
|
||||||
{
|
{
|
||||||
arith64_u64 r;
|
arith64_u64 r;
|
||||||
__divmoddi4(arith64_abs(a), arith64_abs(b), &r);
|
__divmoddi4(arith64_abs(a), arith64_abs(b), &r);
|
||||||
return arith64_neg(r, a);
|
return arith64_neg(r, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __popcountsi2(arith64_u32 a)
|
int __popcountsi2(arith64_u32 a)
|
||||||
{
|
{
|
||||||
|
|
||||||
a = a - ((a >> 1) & 0x55555555);
|
a = a - ((a >> 1) & 0x55555555);
|
||||||
a = ((a >> 2) & 0x33333333) + (a & 0x33333333);
|
a = ((a >> 2) & 0x33333333) + (a & 0x33333333);
|
||||||
a = (a + (a >> 4)) & 0x0F0F0F0F;
|
a = (a + (a >> 4)) & 0x0F0F0F0F;
|
||||||
a = (a + (a >> 16));
|
a = (a + (a >> 16));
|
||||||
|
|
||||||
return (a + (a >> 8)) & 63;
|
return (a + (a >> 8)) & 63;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __popcountdi2(arith64_u64 a)
|
int __popcountdi2(arith64_u64 a)
|
||||||
{
|
{
|
||||||
|
|
||||||
a = a - ((a >> 1) & 0x5555555555555555ULL);
|
a = a - ((a >> 1) & 0x5555555555555555ULL);
|
||||||
a = ((a >> 2) & 0x3333333333333333ULL) + (a & 0x3333333333333333ULL);
|
a = ((a >> 2) & 0x3333333333333333ULL) + (a & 0x3333333333333333ULL);
|
||||||
a = (a + (a >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
|
a = (a + (a >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
|
||||||
a = (a + (a >> 32));
|
a = (a + (a >> 32));
|
||||||
a = (a + (a >> 16));
|
a = (a + (a >> 16));
|
||||||
|
|
||||||
return (a + (a >> 8)) & 127;
|
return (a + (a >> 8)) & 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
arith64_u64 __udivdi3(arith64_u64 a, arith64_u64 b) { return __divmoddi4(a, b, (void *)0); }
|
arith64_u64 __udivdi3(arith64_u64 a, arith64_u64 b) { return __divmoddi4(a, b, (void *)0); }
|
||||||
|
|
||||||
arith64_u64 __umoddi3(arith64_u64 a, arith64_u64 b)
|
arith64_u64 __umoddi3(arith64_u64 a, arith64_u64 b)
|
||||||
{
|
{
|
||||||
arith64_u64 r;
|
arith64_u64 r;
|
||||||
__divmoddi4(a, b, &r);
|
__divmoddi4(a, b, &r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Good documentation: https://splichal.eu/scripts/sphinx/gccint/_build/html/the-gcc-low-level-runtime-library/routines-for-floating-point-emulation.html */
|
/* Good documentation: https://splichal.eu/scripts/sphinx/gccint/_build/html/the-gcc-low-level-runtime-library/routines-for-floating-point-emulation.html */
|
||||||
@ -291,37 +295,83 @@ typedef unsigned long long uint64_t;
|
|||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
} atomic_uint64_t;
|
} atomic_uint64_t;
|
||||||
|
|
||||||
uint64_t __atomic_load_8(const atomic_uint64_t *p)
|
uint64_t __atomic_load_8(const atomic_uint64_t *p)
|
||||||
{
|
{
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
__asm__ volatile("lock cmpxchg8b %1"
|
__asm__ volatile("lock cmpxchg8b %1"
|
||||||
: "=A"(value)
|
: "=A"(value)
|
||||||
: "m"(*p)
|
: "m"(*p)
|
||||||
: "memory");
|
: "memory");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __atomic_store_8(atomic_uint64_t *p, uint64_t value)
|
void __atomic_store_8(atomic_uint64_t *p, uint64_t value)
|
||||||
{
|
{
|
||||||
__asm__ volatile("lock cmpxchg8b %0"
|
__asm__ volatile("lock cmpxchg8b %0"
|
||||||
: "=m"(p->value)
|
: "=m"(p->value)
|
||||||
: "a"((uint32_t)value), "d"((uint32_t)(value >> 32)), "m"(*p)
|
: "a"((uint32_t)value), "d"((uint32_t)(value >> 32)), "m"(*p)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: __fixsfsi is not implemented correctly(?) */
|
int __fixsfsi(float a)
|
||||||
int __fixsfsi(float a) { return (int)a; }
|
{
|
||||||
|
return (int)a;
|
||||||
|
}
|
||||||
|
|
||||||
int __ltsf2(float a, float b) { return a < b; }
|
int __ltsf2(float a, float b)
|
||||||
int __eqsf2(float a, float b) { return a == b; }
|
{
|
||||||
float __divsf3(float a, float b) { return a / b; }
|
return -(a < b);
|
||||||
double __extendsfdf2(float a) { return (double)a; }
|
}
|
||||||
float __truncdfsf2(double a) { return (float)a; }
|
|
||||||
float __subsf3(float a, float b) { return a - b; }
|
int __nesf2(float a, float b)
|
||||||
float __floatsisf(int a) { return (float)a; }
|
{
|
||||||
int __fixunssfsi(float a) { return (int)a; }
|
return a == b;
|
||||||
float __mulsf3(float a, float b) { return a * b; }
|
}
|
||||||
float __addsf3(float a, float b) { return a + b; }
|
|
||||||
|
int __eqsf2(float a, float b)
|
||||||
|
{
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
float __divsf3(float a, float b)
|
||||||
|
{
|
||||||
|
return (a / b);
|
||||||
|
}
|
||||||
|
|
||||||
|
double __extendsfdf2(float a)
|
||||||
|
{
|
||||||
|
return (double)a;
|
||||||
|
}
|
||||||
|
|
||||||
|
float __truncdfsf2(double a)
|
||||||
|
{
|
||||||
|
return (float)a;
|
||||||
|
}
|
||||||
|
|
||||||
|
float __subsf3(float a, float b)
|
||||||
|
{
|
||||||
|
return (a - b);
|
||||||
|
}
|
||||||
|
|
||||||
|
float __floatsisf(int a)
|
||||||
|
{
|
||||||
|
return (float)a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __fixunssfsi(float a)
|
||||||
|
{
|
||||||
|
return (int)a;
|
||||||
|
}
|
||||||
|
|
||||||
|
float __mulsf3(float a, float b)
|
||||||
|
{
|
||||||
|
return (a * b);
|
||||||
|
}
|
||||||
|
|
||||||
|
float __addsf3(float a, float b)
|
||||||
|
{
|
||||||
|
return (a + b);
|
||||||
|
}
|
||||||
|
@ -120,37 +120,37 @@ EXTERNC void multiboot_main(uintptr_t Magic, uintptr_t Info)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
multiboot_mmap_entry entry = mmap->entries[i];
|
multiboot_mmap_entry entry = mmap->entries[i];
|
||||||
mb2binfo.Memory.Size += entry.len;
|
mb2binfo.Memory.Size += (size_t)entry.len;
|
||||||
switch (entry.type)
|
switch (entry.type)
|
||||||
{
|
{
|
||||||
case MULTIBOOT_MEMORY_AVAILABLE:
|
case MULTIBOOT_MEMORY_AVAILABLE:
|
||||||
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
||||||
mb2binfo.Memory.Entry[i].Length = entry.len;
|
mb2binfo.Memory.Entry[i].Length = (size_t)entry.len;
|
||||||
mb2binfo.Memory.Entry[i].Type = Usable;
|
mb2binfo.Memory.Entry[i].Type = Usable;
|
||||||
break;
|
break;
|
||||||
case MULTIBOOT_MEMORY_RESERVED:
|
case MULTIBOOT_MEMORY_RESERVED:
|
||||||
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
||||||
mb2binfo.Memory.Entry[i].Length = entry.len;
|
mb2binfo.Memory.Entry[i].Length = (size_t)entry.len;
|
||||||
mb2binfo.Memory.Entry[i].Type = Reserved;
|
mb2binfo.Memory.Entry[i].Type = Reserved;
|
||||||
break;
|
break;
|
||||||
case MULTIBOOT_MEMORY_ACPI_RECLAIMABLE:
|
case MULTIBOOT_MEMORY_ACPI_RECLAIMABLE:
|
||||||
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
||||||
mb2binfo.Memory.Entry[i].Length = entry.len;
|
mb2binfo.Memory.Entry[i].Length = (size_t)entry.len;
|
||||||
mb2binfo.Memory.Entry[i].Type = ACPIReclaimable;
|
mb2binfo.Memory.Entry[i].Type = ACPIReclaimable;
|
||||||
break;
|
break;
|
||||||
case MULTIBOOT_MEMORY_NVS:
|
case MULTIBOOT_MEMORY_NVS:
|
||||||
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
||||||
mb2binfo.Memory.Entry[i].Length = entry.len;
|
mb2binfo.Memory.Entry[i].Length = (size_t)entry.len;
|
||||||
mb2binfo.Memory.Entry[i].Type = ACPINVS;
|
mb2binfo.Memory.Entry[i].Type = ACPINVS;
|
||||||
break;
|
break;
|
||||||
case MULTIBOOT_MEMORY_BADRAM:
|
case MULTIBOOT_MEMORY_BADRAM:
|
||||||
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
||||||
mb2binfo.Memory.Entry[i].Length = entry.len;
|
mb2binfo.Memory.Entry[i].Length = (size_t)entry.len;
|
||||||
mb2binfo.Memory.Entry[i].Type = BadMemory;
|
mb2binfo.Memory.Entry[i].Type = BadMemory;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
mb2binfo.Memory.Entry[i].BaseAddress = (void *)entry.addr;
|
||||||
mb2binfo.Memory.Entry[i].Length = entry.len;
|
mb2binfo.Memory.Entry[i].Length = (size_t)entry.len;
|
||||||
mb2binfo.Memory.Entry[i].Type = Unknown;
|
mb2binfo.Memory.Entry[i].Type = Unknown;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ EXTERNC void multiboot_main(uintptr_t Magic, uintptr_t Info)
|
|||||||
multiboot_tag_load_base_addr *load_base_addr = (multiboot_tag_load_base_addr *)Tag;
|
multiboot_tag_load_base_addr *load_base_addr = (multiboot_tag_load_base_addr *)Tag;
|
||||||
mb2binfo.Kernel.PhysicalBase = (void *)(uint64_t)load_base_addr->load_base_addr;
|
mb2binfo.Kernel.PhysicalBase = (void *)(uint64_t)load_base_addr->load_base_addr;
|
||||||
mb2binfo.Kernel.VirtualBase = (void *)(uint64_t)(load_base_addr->load_base_addr + 0xFFFFFFFF80000000);
|
mb2binfo.Kernel.VirtualBase = (void *)(uint64_t)(load_base_addr->load_base_addr + 0xFFFFFFFF80000000);
|
||||||
mb2binfo.Kernel.Size = ((uint64_t)&_kernel_end - (uint64_t)&_kernel_start) + ((uint64_t)&_bootstrap_end - (uint64_t)&_bootstrap_start);
|
mb2binfo.Kernel.Size = (size_t)(((uint64_t)&_kernel_end - (uint64_t)&_kernel_start) + ((uint64_t)&_bootstrap_end - (uint64_t)&_bootstrap_start));
|
||||||
debug("Kernel base: %p (physical) %p (virtual)", mb2binfo.Kernel.PhysicalBase, mb2binfo.Kernel.VirtualBase);
|
debug("Kernel base: %p (physical) %p (virtual)", mb2binfo.Kernel.PhysicalBase, mb2binfo.Kernel.VirtualBase);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -68,13 +68,13 @@ namespace PIC
|
|||||||
if (IRQ < 8)
|
if (IRQ < 8)
|
||||||
{
|
{
|
||||||
Port = MasterDataPort;
|
Port = MasterDataPort;
|
||||||
Value = MasterMask & ~(1 << IRQ);
|
Value = (uint8_t)(MasterMask & ~(1 << IRQ));
|
||||||
MasterMask = Value;
|
MasterMask = Value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Port = SlaveDataPort;
|
Port = SlaveDataPort;
|
||||||
Value = SlaveMask & ~(1 << (IRQ - 8));
|
Value = (uint8_t)(SlaveMask & ~(1 << (IRQ - 8)));
|
||||||
SlaveMask = Value;
|
SlaveMask = Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ namespace PIC
|
|||||||
|
|
||||||
void PIT::PrepareSleep(uint32_t Milliseconds)
|
void PIT::PrepareSleep(uint32_t Milliseconds)
|
||||||
{
|
{
|
||||||
uint16_t Divisor = 1193182 / Frequency;
|
uint16_t Divisor = (uint16_t)(1193182 / Frequency);
|
||||||
uint8_t Low = (uint8_t)(Divisor & 0xFF);
|
uint8_t Low = (uint8_t)(Divisor & 0xFF);
|
||||||
uint8_t High = (uint8_t)((Divisor >> 8) & 0xFF);
|
uint8_t High = (uint8_t)((Divisor >> 8) & 0xFF);
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace Memory
|
|||||||
{
|
{
|
||||||
// 0x1000 aligned
|
// 0x1000 aligned
|
||||||
uintptr_t Address = (uintptr_t)VirtualAddress;
|
uintptr_t Address = (uintptr_t)VirtualAddress;
|
||||||
Address &= 0xFFFFFFFFFFFFF000;
|
Address &= 0xFFFFF000;
|
||||||
|
|
||||||
PageMapIndexer Index = PageMapIndexer(Address);
|
PageMapIndexer Index = PageMapIndexer(Address);
|
||||||
PageDirectoryEntry PDE = this->Table->Entries[Index.PDEIndex];
|
PageDirectoryEntry PDE = this->Table->Entries[Index.PDEIndex];
|
||||||
@ -51,7 +51,7 @@ namespace Memory
|
|||||||
{
|
{
|
||||||
// 0x1000 aligned
|
// 0x1000 aligned
|
||||||
uintptr_t Address = (uintptr_t)VirtualAddress;
|
uintptr_t Address = (uintptr_t)VirtualAddress;
|
||||||
Address &= 0xFFFFFFFFFFFFF000;
|
Address &= 0xFFFFF000;
|
||||||
|
|
||||||
PageMapIndexer Index = PageMapIndexer(Address);
|
PageMapIndexer Index = PageMapIndexer(Address);
|
||||||
PageDirectoryEntry PDE = this->Table->Entries[Index.PDEIndex];
|
PageDirectoryEntry PDE = this->Table->Entries[Index.PDEIndex];
|
||||||
@ -90,7 +90,7 @@ namespace Memory
|
|||||||
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex];
|
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex];
|
||||||
if (Type == MapType::FourMB)
|
if (Type == MapType::FourMB)
|
||||||
{
|
{
|
||||||
PDE->raw |= Flags;
|
PDE->raw |= (uintptr_t)Flags;
|
||||||
PDE->PageSize = true;
|
PDE->PageSize = true;
|
||||||
PDE->SetAddress((uintptr_t)PhysicalAddress >> 12);
|
PDE->SetAddress((uintptr_t)PhysicalAddress >> 12);
|
||||||
debug("Mapped 4MB page at %p to %p", VirtualAddress, PhysicalAddress);
|
debug("Mapped 4MB page at %p to %p", VirtualAddress, PhysicalAddress);
|
||||||
@ -107,11 +107,11 @@ namespace Memory
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
PTEPtr = (PageTableEntryPtr *)(PDE->GetAddress() << 12);
|
PTEPtr = (PageTableEntryPtr *)(PDE->GetAddress() << 12);
|
||||||
PDE->raw |= DirectoryFlags;
|
PDE->raw |= (uintptr_t)DirectoryFlags;
|
||||||
|
|
||||||
PageTableEntry *PTE = &PTEPtr->Entries[Index.PTEIndex];
|
PageTableEntry *PTE = &PTEPtr->Entries[Index.PTEIndex];
|
||||||
PTE->Present = true;
|
PTE->Present = true;
|
||||||
PTE->raw |= Flags;
|
PTE->raw |= (uintptr_t)Flags;
|
||||||
PTE->SetAddress((uintptr_t)PhysicalAddress >> 12);
|
PTE->SetAddress((uintptr_t)PhysicalAddress >> 12);
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(a64)
|
||||||
|
@ -278,7 +278,7 @@ namespace ACPI
|
|||||||
uint8_t PM1_CNT_LEN = 0;
|
uint8_t PM1_CNT_LEN = 0;
|
||||||
|
|
||||||
ACPI *acpi;
|
ACPI *acpi;
|
||||||
void OnInterruptReceived(CPU::x64::TrapFrame *Frame);
|
void OnInterruptReceived(CPU::x32::TrapFrame *Frame);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool ACPIShutdownSupported = false;
|
bool ACPIShutdownSupported = false;
|
||||||
|
@ -41,7 +41,7 @@ std::atomic_bool CPUEnabled = false;
|
|||||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||||
static __aligned(0x1000) CPUData CPUs[MAX_CPU] = {0};
|
static __aligned(0x1000) CPUData CPUs[MAX_CPU] = {0};
|
||||||
|
|
||||||
SafeFunction CPUData *GetCPU(uint64_t id) { return &CPUs[id]; }
|
SafeFunction CPUData *GetCPU(long id) { return &CPUs[id]; }
|
||||||
|
|
||||||
SafeFunction CPUData *GetCurrentCPU()
|
SafeFunction CPUData *GetCurrentCPU()
|
||||||
{
|
{
|
||||||
|
107
Core/CPU.cpp
107
Core/CPU.cpp
@ -201,14 +201,14 @@ namespace CPU
|
|||||||
|
|
||||||
void InitializeFeatures(long Core)
|
void InitializeFeatures(long Core)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
static int BSP = 0;
|
||||||
bool PGESupport = false;
|
bool PGESupport = false;
|
||||||
bool SSESupport = false;
|
bool SSESupport = false;
|
||||||
|
#if defined(a64)
|
||||||
bool UMIPSupport = false;
|
bool UMIPSupport = false;
|
||||||
bool SMEPSupport = false;
|
bool SMEPSupport = false;
|
||||||
bool SMAPSupport = false;
|
bool SMAPSupport = false;
|
||||||
|
|
||||||
static int BSP = 0;
|
|
||||||
x64::CR0 cr0 = x64::readcr0();
|
x64::CR0 cr0 = x64::readcr0();
|
||||||
x64::CR4 cr4 = x64::readcr4();
|
x64::CR4 cr4 = x64::readcr4();
|
||||||
|
|
||||||
@ -335,6 +335,105 @@ namespace CPU
|
|||||||
if (SSEEnableAfter)
|
if (SSEEnableAfter)
|
||||||
SSEEnabled = true;
|
SSEEnabled = true;
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
|
|
||||||
|
x32::CR0 cr0 = x32::readcr0();
|
||||||
|
x32::CR4 cr4 = x32::readcr4();
|
||||||
|
|
||||||
|
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
|
||||||
|
{
|
||||||
|
CPU::x86::AMD::CPUID0x00000001 cpuid1;
|
||||||
|
cpuid1.Get();
|
||||||
|
|
||||||
|
PGESupport = cpuid1.EDX.PGE;
|
||||||
|
SSESupport = cpuid1.EDX.SSE;
|
||||||
|
}
|
||||||
|
else if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
|
||||||
|
{
|
||||||
|
CPU::x86::Intel::CPUID0x00000001 cpuid1;
|
||||||
|
cpuid1.Get();
|
||||||
|
PGESupport = cpuid1.EDX.PGE;
|
||||||
|
SSESupport = cpuid1.EDX.SSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.SIMD == false)
|
||||||
|
{
|
||||||
|
debug("Disabling SSE support...");
|
||||||
|
SSESupport = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PGESupport)
|
||||||
|
{
|
||||||
|
debug("Enabling global pages support...");
|
||||||
|
if (!BSP)
|
||||||
|
KPrint("Global Pages is supported.");
|
||||||
|
cr4.PGE = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SSEEnableAfter = false;
|
||||||
|
|
||||||
|
/* Not sure if my code is not working properly or something else is the issue. */
|
||||||
|
if ((strcmp(Hypervisor(), x86_CPUID_VENDOR_TCG) != 0 &&
|
||||||
|
strcmp(Hypervisor(), x86_CPUID_VENDOR_VIRTUALBOX) != 0) &&
|
||||||
|
SSESupport)
|
||||||
|
{
|
||||||
|
debug("Enabling FPU...");
|
||||||
|
bool FPU = false;
|
||||||
|
{
|
||||||
|
x32::CR0 _cr0;
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"mov %%cr0, %0\n\t"
|
||||||
|
"and $0xfffffff8, %0\n\t"
|
||||||
|
"mov %0, %%cr0\n\t"
|
||||||
|
"fninit\n\t"
|
||||||
|
"fwait\n\t"
|
||||||
|
"mov %%cr0, %0\n\t"
|
||||||
|
: "=r"(_cr0.raw)
|
||||||
|
:
|
||||||
|
: "memory");
|
||||||
|
if ((_cr0.EM) == 0)
|
||||||
|
{
|
||||||
|
FPU = true;
|
||||||
|
debug("FPU is supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FPU)
|
||||||
|
KPrint("FPU is supported.");
|
||||||
|
|
||||||
|
debug("Enabling SSE support...");
|
||||||
|
if (!BSP)
|
||||||
|
KPrint("SSE is supported.");
|
||||||
|
cr0.EM = 0;
|
||||||
|
cr0.MP = 1;
|
||||||
|
cr4.OSFXSR = 1;
|
||||||
|
cr4.OSXMMEXCPT = 1;
|
||||||
|
|
||||||
|
CPUData *CoreData = GetCPU(Core);
|
||||||
|
CoreData->Data.FPU = (CPU::x32::FXState *)KernelAllocator.RequestPages(TO_PAGES(sizeof(CPU::x32::FXState) + 1));
|
||||||
|
memset(CoreData->Data.FPU, 0, FROM_PAGES(TO_PAGES(sizeof(CPU::x32::FXState))));
|
||||||
|
CoreData->Data.FPU->mxcsr = 0b0001111110000000;
|
||||||
|
CoreData->Data.FPU->mxcsrmask = 0b1111111110111111;
|
||||||
|
CoreData->Data.FPU->fcw = 0b0000001100111111;
|
||||||
|
CPU::x32::fxrstor(CoreData->Data.FPU);
|
||||||
|
|
||||||
|
SSEEnableAfter = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cr0.NW = 0;
|
||||||
|
cr0.CD = 0;
|
||||||
|
cr0.WP = 1;
|
||||||
|
|
||||||
|
x32::writecr0(cr0);
|
||||||
|
debug("Writing CR4...");
|
||||||
|
x32::writecr4(cr4);
|
||||||
|
debug("Wrote CR4.");
|
||||||
|
|
||||||
|
debug("Enabling PAT support...");
|
||||||
|
x32::wrmsr(x32::MSR_CR_PAT, 0x6 | (0x0 << 8) | (0x1 << 16));
|
||||||
|
if (!BSP++)
|
||||||
|
trace("Features for BSP initialized.");
|
||||||
|
if (SSEEnableAfter)
|
||||||
|
SSEEnabled = true;
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -358,10 +457,6 @@ namespace CPU
|
|||||||
|
|
||||||
uint64_t CheckSIMD()
|
uint64_t CheckSIMD()
|
||||||
{
|
{
|
||||||
#if defined(a32)
|
|
||||||
return SIMD_NONE; /* TODO: Support x86 SIMD on x32 */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (unlikely(!SSEEnabled))
|
if (unlikely(!SSEEnabled))
|
||||||
return SIMD_NONE;
|
return SIMD_NONE;
|
||||||
|
|
||||||
|
@ -662,9 +662,9 @@ namespace CrashHandler
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint64_t Address = strtoul(addr, NULL, 16);
|
uint64_t Address = strtoul(addr, NULL, 16);
|
||||||
uint64_t Length = strtoul(len, NULL, 10);
|
size_t Length = strtoul(len, NULL, 10);
|
||||||
debug("Dumping %ld bytes from %#lx\n", Length, Address);
|
debug("Dumping %ld bytes from %#lx\n", Length, Address);
|
||||||
EHDumpData((void *)Address, Length);
|
EHDumpData((void *)Address, (unsigned long)Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strncmp(Input, "uartmemdmp", 10) == 0)
|
else if (strncmp(Input, "uartmemdmp", 10) == 0)
|
||||||
@ -705,13 +705,13 @@ namespace CrashHandler
|
|||||||
}
|
}
|
||||||
EHPrint("\eF8F8F8Dumping memory to UART port %c (%#lx) and %s inaccessible pages.\n", cPort[0], port, cBoolSkip[0] == '1' ? "skipping" : "zeroing");
|
EHPrint("\eF8F8F8Dumping memory to UART port %c (%#lx) and %s inaccessible pages.\n", cPort[0], port, cBoolSkip[0] == '1' ? "skipping" : "zeroing");
|
||||||
Display->SetBuffer(SBIdx);
|
Display->SetBuffer(SBIdx);
|
||||||
uint64_t Length = KernelAllocator.GetTotalMemory();
|
uint64_t TotalMemLength = KernelAllocator.GetTotalMemory();
|
||||||
uint64_t ProgressLength = Length;
|
uint64_t ProgressLength = TotalMemLength;
|
||||||
UniversalAsynchronousReceiverTransmitter::UART uart(port);
|
UniversalAsynchronousReceiverTransmitter::UART uart(port);
|
||||||
Memory::Virtual vma;
|
Memory::Virtual vma;
|
||||||
uint8_t *Address = reinterpret_cast<uint8_t *>(0x0);
|
uint8_t *Address = reinterpret_cast<uint8_t *>(0x0);
|
||||||
int Progress = 0;
|
int Progress = 0;
|
||||||
for (size_t i = 0; i < Length; i++)
|
for (size_t i = 0; i < TotalMemLength; i++)
|
||||||
{
|
{
|
||||||
if (vma.Check(Address))
|
if (vma.Check(Address))
|
||||||
uart.Write(*Address);
|
uart.Write(*Address);
|
||||||
|
@ -83,7 +83,7 @@ namespace CrashHandler
|
|||||||
data.Frame->ss, data.Frame->cs, ds);
|
data.Frame->ss, data.Frame->cs, ds);
|
||||||
EHPrint("EAX=%#llx EBX=%#llx ECX=%#llx EDX=%#llx\n", data.Frame->eax, data.Frame->ebx, data.Frame->ecx, data.Frame->edx);
|
EHPrint("EAX=%#llx EBX=%#llx ECX=%#llx EDX=%#llx\n", data.Frame->eax, data.Frame->ebx, data.Frame->ecx, data.Frame->edx);
|
||||||
EHPrint("ESI=%#llx EDI=%#llx EBP=%#llx ESP=%#llx\n", data.Frame->esi, data.Frame->edi, data.Frame->ebp, data.Frame->esp);
|
EHPrint("ESI=%#llx EDI=%#llx EBP=%#llx ESP=%#llx\n", data.Frame->esi, data.Frame->edi, data.Frame->ebp, data.Frame->esp);
|
||||||
EHPrint("EIP=%#llx EFL=%#llx INT=%#llx ERR=%#llx EFER=%#llx\n", data.Frame->eip, data.Frame->eflags.raw, data.Frame->InterruptNumber, data.Frame->ErrorCode, data.efer.raw);
|
EHPrint("EIP=%#llx EFL=%#llx INT=%#llx ERR=%#llx\n", data.Frame->eip, data.Frame->eflags.raw, data.Frame->InterruptNumber, data.Frame->ErrorCode);
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -144,10 +144,12 @@ namespace CrashHandler
|
|||||||
data.dr7.ConditionsDR2 ? "True " : "False", data.dr7.SizeDR2 ? "True " : "False", data.dr7.ConditionsDR3 ? "True " : "False", data.dr7.SizeDR3 ? "True " : "False",
|
data.dr7.ConditionsDR2 ? "True " : "False", data.dr7.SizeDR2 ? "True " : "False", data.dr7.ConditionsDR3 ? "True " : "False", data.dr7.SizeDR3 ? "True " : "False",
|
||||||
data.dr7.Reserved);
|
data.dr7.Reserved);
|
||||||
|
|
||||||
|
#ifdef a64
|
||||||
EHPrint("\e009FF0EFER: SCE:%s LME:%s LMA:%s NXE:%s\n SVME:%s LMSLE:%s FFXSR:%s TCE:%s\n R0:%#x R1:%#x R2:%#x\n",
|
EHPrint("\e009FF0EFER: SCE:%s LME:%s LMA:%s NXE:%s\n SVME:%s LMSLE:%s FFXSR:%s TCE:%s\n R0:%#x R1:%#x R2:%#x\n",
|
||||||
data.efer.SCE ? "True " : "False", data.efer.LME ? "True " : "False", data.efer.LMA ? "True " : "False", data.efer.NXE ? "True " : "False",
|
data.efer.SCE ? "True " : "False", data.efer.LME ? "True " : "False", data.efer.LMA ? "True " : "False", data.efer.NXE ? "True " : "False",
|
||||||
data.efer.SVME ? "True " : "False", data.efer.LMSLE ? "True " : "False", data.efer.FFXSR ? "True " : "False", data.efer.TCE ? "True " : "False",
|
data.efer.SVME ? "True " : "False", data.efer.LMSLE ? "True " : "False", data.efer.FFXSR ? "True " : "False", data.efer.TCE ? "True " : "False",
|
||||||
data.efer.Reserved0, data.efer.Reserved1, data.efer.Reserved2);
|
data.efer.Reserved0, data.efer.Reserved1, data.efer.Reserved2);
|
||||||
|
#endif // a64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (data.Frame->InterruptNumber)
|
switch (data.Frame->InterruptNumber)
|
||||||
|
@ -113,7 +113,7 @@ namespace Disk
|
|||||||
}
|
}
|
||||||
partition.StartLBA = GPTPartition.FirstLBA;
|
partition.StartLBA = GPTPartition.FirstLBA;
|
||||||
partition.EndLBA = GPTPartition.LastLBA;
|
partition.EndLBA = GPTPartition.LastLBA;
|
||||||
partition.Sectors = partition.EndLBA - partition.StartLBA;
|
partition.Sectors = (size_t)(partition.EndLBA - partition.StartLBA);
|
||||||
partition.Port = ItrPort;
|
partition.Port = ItrPort;
|
||||||
partition.Flags = Present;
|
partition.Flags = Present;
|
||||||
partition.Style = GPT;
|
partition.Style = GPT;
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -38,7 +38,7 @@ namespace Driver
|
|||||||
debug("Searching for conflicting drivers...");
|
debug("Searching for conflicting drivers...");
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -38,7 +38,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -38,7 +38,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -38,7 +38,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -38,7 +38,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -37,7 +37,7 @@ namespace Driver
|
|||||||
|
|
||||||
if (fexExtended->Driver.OverrideOnConflict)
|
if (fexExtended->Driver.OverrideOnConflict)
|
||||||
{
|
{
|
||||||
std::vector<uint64_t> DriversToRemove = std::vector<uint64_t>();
|
std::vector<size_t> DriversToRemove = std::vector<size_t>();
|
||||||
foreach (auto Drv in Drivers)
|
foreach (auto Drv in Drivers)
|
||||||
{
|
{
|
||||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||||
|
@ -116,7 +116,7 @@ NIF void MapFramebuffer(PageTable *PT)
|
|||||||
|
|
||||||
va.OptimizedMap((void *)bInfo.Framebuffer[itrfb].BaseAddress,
|
va.OptimizedMap((void *)bInfo.Framebuffer[itrfb].BaseAddress,
|
||||||
(void *)bInfo.Framebuffer[itrfb].BaseAddress,
|
(void *)bInfo.Framebuffer[itrfb].BaseAddress,
|
||||||
bInfo.Framebuffer[itrfb].Pitch * bInfo.Framebuffer[itrfb].Height,
|
(size_t)(bInfo.Framebuffer[itrfb].Pitch * bInfo.Framebuffer[itrfb].Height),
|
||||||
PTFlag::RW | PTFlag::US | PTFlag::G);
|
PTFlag::RW | PTFlag::US | PTFlag::G);
|
||||||
itrfb++;
|
itrfb++;
|
||||||
|
|
||||||
|
@ -55,11 +55,11 @@ namespace Memory
|
|||||||
if (Offset > node->Length)
|
if (Offset > node->Length)
|
||||||
return -1;
|
return -1;
|
||||||
node->Offset = Offset;
|
node->Offset = Offset;
|
||||||
NewOffset = node->Offset;
|
NewOffset = (long)node->Offset;
|
||||||
}
|
}
|
||||||
else if (Whence == SEEK_CUR)
|
else if (Whence == SEEK_CUR)
|
||||||
{
|
{
|
||||||
NewOffset = node->Offset + Offset;
|
NewOffset = (long)(node->Offset + Offset);
|
||||||
if ((size_t)NewOffset > node->Length || NewOffset < 0)
|
if ((size_t)NewOffset > node->Length || NewOffset < 0)
|
||||||
return -1;
|
return -1;
|
||||||
node->Offset = NewOffset;
|
node->Offset = NewOffset;
|
||||||
|
@ -377,7 +377,7 @@ namespace Memory
|
|||||||
TotalMemory = MemorySize;
|
TotalMemory = MemorySize;
|
||||||
FreeMemory = MemorySize;
|
FreeMemory = MemorySize;
|
||||||
|
|
||||||
size_t BitmapSize = (MemorySize / PAGE_SIZE) / 8 + 1;
|
size_t BitmapSize = (size_t)(MemorySize / PAGE_SIZE) / 8 + 1;
|
||||||
uintptr_t BitmapAddress = 0x0;
|
uintptr_t BitmapAddress = 0x0;
|
||||||
size_t BitmapAddressSize = 0;
|
size_t BitmapAddressSize = 0;
|
||||||
|
|
||||||
|
@ -789,7 +789,7 @@ namespace PCI
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void PCI::EnumerateFunction(uintptr_t DeviceAddress, uint64_t Function)
|
void PCI::EnumerateFunction(uintptr_t DeviceAddress, uintptr_t Function)
|
||||||
{
|
{
|
||||||
uintptr_t Offset = Function << 12;
|
uintptr_t Offset = Function << 12;
|
||||||
uintptr_t FunctionAddress = DeviceAddress + Offset;
|
uintptr_t FunctionAddress = DeviceAddress + Offset;
|
||||||
@ -805,7 +805,7 @@ namespace PCI
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCI::EnumerateDevice(uintptr_t BusAddress, uint64_t Device)
|
void PCI::EnumerateDevice(uintptr_t BusAddress, uintptr_t Device)
|
||||||
{
|
{
|
||||||
uintptr_t Offset = Device << 15;
|
uintptr_t Offset = Device << 15;
|
||||||
uintptr_t DeviceAddress = BusAddress + Offset;
|
uintptr_t DeviceAddress = BusAddress + Offset;
|
||||||
@ -819,7 +819,7 @@ namespace PCI
|
|||||||
EnumerateFunction(DeviceAddress, Function);
|
EnumerateFunction(DeviceAddress, Function);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCI::EnumerateBus(uintptr_t BaseAddress, uint64_t Bus)
|
void PCI::EnumerateBus(uintptr_t BaseAddress, uintptr_t Bus)
|
||||||
{
|
{
|
||||||
uintptr_t Offset = Bus << 20;
|
uintptr_t Offset = Bus << 20;
|
||||||
uintptr_t BusAddress = BaseAddress + Offset;
|
uintptr_t BusAddress = BaseAddress + Offset;
|
||||||
|
@ -127,7 +127,7 @@ namespace Random
|
|||||||
|
|
||||||
if (RDRANDFlag)
|
if (RDRANDFlag)
|
||||||
{
|
{
|
||||||
uint64_t RDRANDValue = 0;
|
uintptr_t RDRANDValue = 0;
|
||||||
asmv("1: rdrand %0; jnc 1b"
|
asmv("1: rdrand %0; jnc 1b"
|
||||||
: "=r"(RDRANDValue));
|
: "=r"(RDRANDValue));
|
||||||
return RDRANDValue;
|
return RDRANDValue;
|
||||||
|
@ -55,16 +55,26 @@ namespace SymbolResolver
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(a64)
|
||||||
Elf64_Shdr *ElfSections = (Elf64_Shdr *)(Sections);
|
Elf64_Shdr *ElfSections = (Elf64_Shdr *)(Sections);
|
||||||
Elf64_Sym *ElfSymbols = nullptr;
|
Elf64_Sym *ElfSymbols = nullptr;
|
||||||
|
#elif defined(a32)
|
||||||
|
Elf32_Shdr *ElfSections = (Elf32_Shdr *)(Sections);
|
||||||
|
Elf32_Sym *ElfSymbols = nullptr;
|
||||||
|
#endif
|
||||||
char *strtab = nullptr;
|
char *strtab = nullptr;
|
||||||
|
|
||||||
for (uint64_t i = 0; i < Num; i++)
|
for (uint64_t i = 0; i < Num; i++)
|
||||||
switch (ElfSections[i].sh_type)
|
switch (ElfSections[i].sh_type)
|
||||||
{
|
{
|
||||||
case SHT_SYMTAB:
|
case SHT_SYMTAB:
|
||||||
|
#if defined(a64)
|
||||||
ElfSymbols = (Elf64_Sym *)(Sections + ElfSections[i].sh_offset);
|
ElfSymbols = (Elf64_Sym *)(Sections + ElfSections[i].sh_offset);
|
||||||
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf64_Sym);
|
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf64_Sym);
|
||||||
|
#elif defined(a32)
|
||||||
|
ElfSymbols = (Elf32_Sym *)(Sections + ElfSections[i].sh_offset);
|
||||||
|
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf32_Sym);
|
||||||
|
#endif
|
||||||
if (this->TotalEntries >= 0x10000)
|
if (this->TotalEntries >= 0x10000)
|
||||||
this->TotalEntries = 0x10000 - 1;
|
this->TotalEntries = 0x10000 - 1;
|
||||||
|
|
||||||
@ -94,7 +104,11 @@ namespace SymbolResolver
|
|||||||
for (Index = i + 1; Index < this->TotalEntries; Index++)
|
for (Index = i + 1; Index < this->TotalEntries; Index++)
|
||||||
if (ElfSymbols[Index].st_value < ElfSymbols[MinimumIndex].st_value)
|
if (ElfSymbols[Index].st_value < ElfSymbols[MinimumIndex].st_value)
|
||||||
MinimumIndex = Index;
|
MinimumIndex = Index;
|
||||||
|
#if defined(a64)
|
||||||
Elf64_Sym tmp = ElfSymbols[MinimumIndex];
|
Elf64_Sym tmp = ElfSymbols[MinimumIndex];
|
||||||
|
#elif defined(a32)
|
||||||
|
Elf32_Sym tmp = ElfSymbols[MinimumIndex];
|
||||||
|
#endif
|
||||||
ElfSymbols[MinimumIndex] = ElfSymbols[i];
|
ElfSymbols[MinimumIndex] = ElfSymbols[i];
|
||||||
ElfSymbols[i] = tmp;
|
ElfSymbols[i] = tmp;
|
||||||
}
|
}
|
||||||
@ -114,7 +128,7 @@ namespace SymbolResolver
|
|||||||
}
|
}
|
||||||
|
|
||||||
trace("Symbol table loaded, %d entries (%ldKB)", this->TotalEntries, TO_KB(this->TotalEntries * sizeof(SymbolTable)));
|
trace("Symbol table loaded, %d entries (%ldKB)", this->TotalEntries, TO_KB(this->TotalEntries * sizeof(SymbolTable)));
|
||||||
for (uintptr_t i = 0, g = this->TotalEntries; i < g; i++)
|
for (int64_t i = 0, g = this->TotalEntries; i < g; i++)
|
||||||
{
|
{
|
||||||
this->SymTable[i].Address = ElfSymbols[i].st_value;
|
this->SymTable[i].Address = ElfSymbols[i].st_value;
|
||||||
this->SymTable[i].FunctionName = &strtab[ElfSymbols[i].st_name];
|
this->SymTable[i].FunctionName = &strtab[ElfSymbols[i].st_name];
|
||||||
@ -134,7 +148,11 @@ namespace SymbolResolver
|
|||||||
|
|
||||||
this->Image = (void *)ImageAddress;
|
this->Image = (void *)ImageAddress;
|
||||||
debug("Solving symbols for address: %#llx", ImageAddress);
|
debug("Solving symbols for address: %#llx", ImageAddress);
|
||||||
|
#if defined(a64)
|
||||||
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
|
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
|
||||||
|
#elif defined(a32)
|
||||||
|
Elf32_Ehdr *Header = (Elf32_Ehdr *)ImageAddress;
|
||||||
|
#endif
|
||||||
if (Header->e_ident[0] != 0x7F &&
|
if (Header->e_ident[0] != 0x7F &&
|
||||||
Header->e_ident[1] != 'E' &&
|
Header->e_ident[1] != 'E' &&
|
||||||
Header->e_ident[2] != 'L' &&
|
Header->e_ident[2] != 'L' &&
|
||||||
@ -143,16 +161,26 @@ namespace SymbolResolver
|
|||||||
error("Invalid ELF header");
|
error("Invalid ELF header");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if defined(a64)
|
||||||
Elf64_Shdr *ElfSections = (Elf64_Shdr *)(ImageAddress + Header->e_shoff);
|
Elf64_Shdr *ElfSections = (Elf64_Shdr *)(ImageAddress + Header->e_shoff);
|
||||||
Elf64_Sym *ElfSymbols = nullptr;
|
Elf64_Sym *ElfSymbols = nullptr;
|
||||||
|
#elif defined(a32)
|
||||||
|
Elf32_Shdr *ElfSections = (Elf32_Shdr *)(ImageAddress + Header->e_shoff);
|
||||||
|
Elf32_Sym *ElfSymbols = nullptr;
|
||||||
|
#endif
|
||||||
char *strtab = nullptr;
|
char *strtab = nullptr;
|
||||||
|
|
||||||
for (uint16_t i = 0; i < Header->e_shnum; i++)
|
for (uint16_t i = 0; i < Header->e_shnum; i++)
|
||||||
switch (ElfSections[i].sh_type)
|
switch (ElfSections[i].sh_type)
|
||||||
{
|
{
|
||||||
case SHT_SYMTAB:
|
case SHT_SYMTAB:
|
||||||
|
#if defined(a64)
|
||||||
ElfSymbols = (Elf64_Sym *)(ImageAddress + ElfSections[i].sh_offset);
|
ElfSymbols = (Elf64_Sym *)(ImageAddress + ElfSections[i].sh_offset);
|
||||||
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf64_Sym);
|
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf64_Sym);
|
||||||
|
#elif defined(a32)
|
||||||
|
ElfSymbols = (Elf32_Sym *)(ImageAddress + ElfSections[i].sh_offset);
|
||||||
|
this->TotalEntries = ElfSections[i].sh_size / sizeof(Elf32_Sym);
|
||||||
|
#endif
|
||||||
if (this->TotalEntries >= 0x10000)
|
if (this->TotalEntries >= 0x10000)
|
||||||
this->TotalEntries = 0x10000 - 1;
|
this->TotalEntries = 0x10000 - 1;
|
||||||
|
|
||||||
@ -182,7 +210,11 @@ namespace SymbolResolver
|
|||||||
for (Index = i + 1; Index < this->TotalEntries; Index++)
|
for (Index = i + 1; Index < this->TotalEntries; Index++)
|
||||||
if (ElfSymbols[Index].st_value < ElfSymbols[MinimumIndex].st_value)
|
if (ElfSymbols[Index].st_value < ElfSymbols[MinimumIndex].st_value)
|
||||||
MinimumIndex = Index;
|
MinimumIndex = Index;
|
||||||
|
#if defined(a64)
|
||||||
Elf64_Sym tmp = ElfSymbols[MinimumIndex];
|
Elf64_Sym tmp = ElfSymbols[MinimumIndex];
|
||||||
|
#elif defined(a32)
|
||||||
|
Elf32_Sym tmp = ElfSymbols[MinimumIndex];
|
||||||
|
#endif
|
||||||
ElfSymbols[MinimumIndex] = ElfSymbols[i];
|
ElfSymbols[MinimumIndex] = ElfSymbols[i];
|
||||||
ElfSymbols[i] = tmp;
|
ElfSymbols[i] = tmp;
|
||||||
}
|
}
|
||||||
@ -194,7 +226,7 @@ namespace SymbolResolver
|
|||||||
}
|
}
|
||||||
|
|
||||||
trace("Symbol table loaded, %d entries (%ldKB)", this->TotalEntries, TO_KB(this->TotalEntries * sizeof(SymbolTable)));
|
trace("Symbol table loaded, %d entries (%ldKB)", this->TotalEntries, TO_KB(this->TotalEntries * sizeof(SymbolTable)));
|
||||||
for (uintptr_t i = 0, g = this->TotalEntries; i < g; i++)
|
for (int64_t i = 0, g = this->TotalEntries; i < g; i++)
|
||||||
{
|
{
|
||||||
this->SymTable[i].Address = ElfSymbols[i].st_value;
|
this->SymTable[i].Address = ElfSymbols[i].st_value;
|
||||||
this->SymTable[i].FunctionName = &strtab[ElfSymbols[i].st_name];
|
this->SymTable[i].FunctionName = &strtab[ElfSymbols[i].st_name];
|
||||||
|
@ -34,25 +34,35 @@ namespace Time
|
|||||||
{
|
{
|
||||||
bool HighPrecisionEventTimer::Sleep(uint64_t Duration, Units Unit)
|
bool HighPrecisionEventTimer::Sleep(uint64_t Duration, Units Unit)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(a64)
|
||||||
uint64_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
uint64_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
||||||
while (mminq(&((HPET *)hpet)->MainCounterValue) < Target)
|
while (mminq(&((HPET *)hpet)->MainCounterValue) < Target)
|
||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
return true;
|
return true;
|
||||||
|
#elif defined(a32)
|
||||||
|
uint64_t Target = mminl(&((HPET *)hpet)->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
||||||
|
while (mminl(&((HPET *)hpet)->MainCounterValue) < Target)
|
||||||
|
CPU::Pause();
|
||||||
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HighPrecisionEventTimer::GetCounter()
|
uint64_t HighPrecisionEventTimer::GetCounter()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(a64)
|
||||||
return mminq(&((HPET *)hpet)->MainCounterValue);
|
return mminq(&((HPET *)hpet)->MainCounterValue);
|
||||||
|
#elif defined(a32)
|
||||||
|
return mminl(&((HPET *)hpet)->MainCounterValue);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HighPrecisionEventTimer::CalculateTarget(uint64_t Target, Units Unit)
|
uint64_t HighPrecisionEventTimer::CalculateTarget(uint64_t Target, Units Unit)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(a64)
|
||||||
return mminq(&((HPET *)hpet)->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
return mminq(&((HPET *)hpet)->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||||
|
#elif defined(a32)
|
||||||
|
return mminl(&((HPET *)hpet)->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,10 +85,16 @@ namespace Time
|
|||||||
Memory::PTFlag::RW | Memory::PTFlag::PCD);
|
Memory::PTFlag::RW | Memory::PTFlag::PCD);
|
||||||
this->hpet = (HPET *)HPET_HDR->Address.Address;
|
this->hpet = (HPET *)HPET_HDR->Address.Address;
|
||||||
trace("%s timer is at address %016p", HPET_HDR->Header.OEMID, (void *)HPET_HDR->Address.Address);
|
trace("%s timer is at address %016p", HPET_HDR->Header.OEMID, (void *)HPET_HDR->Address.Address);
|
||||||
clk = s_cst(uint32_t, this->hpet->GeneralCapabilities >> 32);
|
clk = s_cst(uint32_t, (uint64_t)this->hpet->GeneralCapabilities >> 32);
|
||||||
|
#ifdef a64
|
||||||
mmoutq(&this->hpet->GeneralConfiguration, 0);
|
mmoutq(&this->hpet->GeneralConfiguration, 0);
|
||||||
mmoutq(&this->hpet->MainCounterValue, 0);
|
mmoutq(&this->hpet->MainCounterValue, 0);
|
||||||
mmoutq(&this->hpet->GeneralConfiguration, 1);
|
mmoutq(&this->hpet->GeneralConfiguration, 1);
|
||||||
|
#else
|
||||||
|
mmoutl(&this->hpet->GeneralConfiguration, 0);
|
||||||
|
mmoutl(&this->hpet->MainCounterValue, 0);
|
||||||
|
mmoutl(&this->hpet->GeneralConfiguration, 1);
|
||||||
|
#endif
|
||||||
ClassCreationTime = this->GetCounter();
|
ClassCreationTime = this->GetCounter();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace Video
|
|||||||
Font *Display::GetCurrentFont() { return CurrentFont; }
|
Font *Display::GetCurrentFont() { return CurrentFont; }
|
||||||
void Display::SetCurrentFont(Font *Font) { CurrentFont = Font; }
|
void Display::SetCurrentFont(Font *Font) { CurrentFont = Font; }
|
||||||
uint16_t Display::GetBitsPerPixel() { return this->framebuffer.BitsPerPixel; }
|
uint16_t Display::GetBitsPerPixel() { return this->framebuffer.BitsPerPixel; }
|
||||||
uint64_t Display::GetPitch() { return this->framebuffer.Pitch; }
|
size_t Display::GetPitch() { return this->framebuffer.Pitch; }
|
||||||
|
|
||||||
void Display::CreateBuffer(uint32_t Width, uint32_t Height, int Index)
|
void Display::CreateBuffer(uint32_t Width, uint32_t Height, int Index)
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,7 @@ namespace Execute
|
|||||||
VirtualFileSystem::File &ExFile,
|
VirtualFileSystem::File &ExFile,
|
||||||
Tasking::PCB *Process)
|
Tasking::PCB *Process)
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
debug("Executable");
|
debug("Executable");
|
||||||
ELFBaseLoad ELFBase = {};
|
ELFBaseLoad ELFBase = {};
|
||||||
/* This should be deleted inside BaseLoad.cpp */
|
/* This should be deleted inside BaseLoad.cpp */
|
||||||
@ -221,5 +222,8 @@ namespace Execute
|
|||||||
|
|
||||||
ELFBase.Success = true;
|
ELFBase.Success = true;
|
||||||
return ELFBase;
|
return ELFBase;
|
||||||
|
#elif defined(a32)
|
||||||
|
return {};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ namespace Execute
|
|||||||
|
|
||||||
Elf64_Sym *ELFLookupSymbol(Elf64_Ehdr *Header, const char *Name)
|
Elf64_Sym *ELFLookupSymbol(Elf64_Ehdr *Header, const char *Name)
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
Elf64_Shdr *SymbolTable = nullptr;
|
Elf64_Shdr *SymbolTable = nullptr;
|
||||||
Elf64_Shdr *StringTable = nullptr;
|
Elf64_Shdr *StringTable = nullptr;
|
||||||
Elf64_Sym *Symbol = nullptr;
|
Elf64_Sym *Symbol = nullptr;
|
||||||
@ -84,11 +85,14 @@ namespace Execute
|
|||||||
if (strcmp(String, Name) == 0)
|
if (strcmp(String, Name) == 0)
|
||||||
return Symbol;
|
return Symbol;
|
||||||
}
|
}
|
||||||
|
#elif defined(a32)
|
||||||
|
#endif
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t ELFGetSymbolValue(Elf64_Ehdr *Header, uint64_t Table, uint64_t Index)
|
uintptr_t ELFGetSymbolValue(Elf64_Ehdr *Header, uint64_t Table, uint64_t Index)
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
if (Table == SHN_UNDEF || Index == SHN_UNDEF)
|
if (Table == SHN_UNDEF || Index == SHN_UNDEF)
|
||||||
return 0;
|
return 0;
|
||||||
Elf64_Shdr *SymbolTable = GetELFSection(Header, Table);
|
Elf64_Shdr *SymbolTable = GetELFSection(Header, Table);
|
||||||
@ -129,10 +133,14 @@ namespace Execute
|
|||||||
Elf64_Shdr *Target = GetELFSection(Header, Symbol->st_shndx);
|
Elf64_Shdr *Target = GetELFSection(Header, Symbol->st_shndx);
|
||||||
return (uintptr_t)Header + Symbol->st_value + Target->sh_offset;
|
return (uintptr_t)Header + Symbol->st_value + Target->sh_offset;
|
||||||
}
|
}
|
||||||
|
#elif defined(a32)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Elf64_Dyn *ELFGetDynamicTag(void *ElfFile, enum DynamicArrayTags Tag)
|
Elf64_Dyn *ELFGetDynamicTag(void *ElfFile, enum DynamicArrayTags Tag)
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)ElfFile;
|
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)ElfFile;
|
||||||
|
|
||||||
Elf64_Phdr ItrPhdr;
|
Elf64_Phdr ItrPhdr;
|
||||||
@ -159,10 +167,14 @@ namespace Execute
|
|||||||
}
|
}
|
||||||
debug("Dynamic tag %d not found.", Tag);
|
debug("Dynamic tag %d not found.", Tag);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
#elif defined(a32)
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MmImage ELFCreateMemoryImage(Memory::MemMgr *mem, Memory::Virtual &pV, void *ElfFile, size_t Length)
|
MmImage ELFCreateMemoryImage(Memory::MemMgr *mem, Memory::Virtual &pV, void *ElfFile, size_t Length)
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
void *MemoryImage = nullptr;
|
void *MemoryImage = nullptr;
|
||||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)ElfFile;
|
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)ElfFile;
|
||||||
bool IsPIC = ELFHeader->e_type == ET_DYN;
|
bool IsPIC = ELFHeader->e_type == ET_DYN;
|
||||||
@ -222,6 +234,9 @@ namespace Execute
|
|||||||
debug("Remapped: %#lx -> %#lx", (uintptr_t)FirstProgramHeaderVirtualAddress + (i * PAGE_SIZE), (uintptr_t)MemoryImage + (i * PAGE_SIZE));
|
debug("Remapped: %#lx -> %#lx", (uintptr_t)FirstProgramHeaderVirtualAddress + (i * PAGE_SIZE), (uintptr_t)MemoryImage + (i * PAGE_SIZE));
|
||||||
}
|
}
|
||||||
return {MemoryImage, (void *)FirstProgramHeaderVirtualAddress};
|
return {MemoryImage, (void *)FirstProgramHeaderVirtualAddress};
|
||||||
|
#elif defined(a32)
|
||||||
|
return {};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t LoadELFInterpreter(Memory::MemMgr *mem, Memory::Virtual &pV, const char *Interpreter)
|
uintptr_t LoadELFInterpreter(Memory::MemMgr *mem, Memory::Virtual &pV, const char *Interpreter)
|
||||||
@ -235,6 +250,7 @@ namespace Execute
|
|||||||
/* No need to check if it's valid, the GetBinaryType() call above does that. */
|
/* No need to check if it's valid, the GetBinaryType() call above does that. */
|
||||||
VirtualFileSystem::File File = vfs->Open(Interpreter);
|
VirtualFileSystem::File File = vfs->Open(Interpreter);
|
||||||
|
|
||||||
|
#if defined(a64)
|
||||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)File.node->Address;
|
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)File.node->Address;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -306,5 +322,9 @@ namespace Execute
|
|||||||
debug("Interpreter entry point: %#lx (%#lx + %#lx)", (uintptr_t)MemoryImage.Physical + ELFHeader->e_entry,
|
debug("Interpreter entry point: %#lx (%#lx + %#lx)", (uintptr_t)MemoryImage.Physical + ELFHeader->e_entry,
|
||||||
(uintptr_t)MemoryImage.Physical, ELFHeader->e_entry);
|
(uintptr_t)MemoryImage.Physical, ELFHeader->e_entry);
|
||||||
return (uintptr_t)MemoryImage.Physical + ELFHeader->e_entry;
|
return (uintptr_t)MemoryImage.Physical + ELFHeader->e_entry;
|
||||||
|
#elif defined(a32)
|
||||||
|
vfs->Close(File);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ namespace Execute
|
|||||||
VirtualFileSystem::File &ExFile,
|
VirtualFileSystem::File &ExFile,
|
||||||
Tasking::PCB *Process)
|
Tasking::PCB *Process)
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
UNUSED(ExFile);
|
UNUSED(ExFile);
|
||||||
debug("Relocatable");
|
debug("Relocatable");
|
||||||
/* TODO: I have to fully implement this, but for now I will leave it as it is now. */
|
/* TODO: I have to fully implement this, but for now I will leave it as it is now. */
|
||||||
@ -105,5 +106,8 @@ namespace Execute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ELFBase;
|
return ELFBase;
|
||||||
|
#elif defined(a32)
|
||||||
|
return {};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,9 @@ namespace Execute
|
|||||||
sl.MemoryImage = r_cst(uint64_t, ELFCreateMemoryImage(mem, ncpV, LibFile, Length).Physical);
|
sl.MemoryImage = r_cst(uint64_t, ELFCreateMemoryImage(mem, ncpV, LibFile, Length).Physical);
|
||||||
debug("MemoryImage: %#lx", sl.MemoryImage);
|
debug("MemoryImage: %#lx", sl.MemoryImage);
|
||||||
|
|
||||||
|
uintptr_t BaseAddress = UINTPTR_MAX;
|
||||||
{
|
{
|
||||||
uintptr_t BaseAddress = UINTPTR_MAX;
|
#if defined(a64)
|
||||||
Elf64_Phdr ItrProgramHeader;
|
Elf64_Phdr ItrProgramHeader;
|
||||||
|
|
||||||
for (Elf64_Half i = 0; i < ((Elf64_Ehdr *)LibFile)->e_phnum; i++)
|
for (Elf64_Half i = 0; i < ((Elf64_Ehdr *)LibFile)->e_phnum; i++)
|
||||||
@ -128,8 +129,11 @@ namespace Execute
|
|||||||
memcpy((void *)MAddr, (uint8_t *)LibFile + ItrProgramHeader.p_offset, ItrProgramHeader.p_filesz);
|
memcpy((void *)MAddr, (uint8_t *)LibFile + ItrProgramHeader.p_offset, ItrProgramHeader.p_filesz);
|
||||||
debug("memcpy: %#lx => %#lx (%ld bytes)", (uint8_t *)LibFile + ItrProgramHeader.p_offset, (uintptr_t)MAddr, ItrProgramHeader.p_filesz);
|
debug("memcpy: %#lx => %#lx (%ld bytes)", (uint8_t *)LibFile + ItrProgramHeader.p_offset, (uintptr_t)MAddr, ItrProgramHeader.p_filesz);
|
||||||
break;
|
break;
|
||||||
|
#elif defined(a32)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(a64)
|
||||||
struct Elf64_Dyn *JmpRel = ELFGetDynamicTag((void *)LibFile, DT_JMPREL);
|
struct Elf64_Dyn *JmpRel = ELFGetDynamicTag((void *)LibFile, DT_JMPREL);
|
||||||
struct Elf64_Dyn *SymTab = ELFGetDynamicTag((void *)LibFile, DT_SYMTAB);
|
struct Elf64_Dyn *SymTab = ELFGetDynamicTag((void *)LibFile, DT_SYMTAB);
|
||||||
struct Elf64_Dyn *StrTab = ELFGetDynamicTag((void *)LibFile, DT_STRTAB);
|
struct Elf64_Dyn *StrTab = ELFGetDynamicTag((void *)LibFile, DT_STRTAB);
|
||||||
@ -230,6 +234,9 @@ namespace Execute
|
|||||||
|
|
||||||
Libs.push_back(sl);
|
Libs.push_back(sl);
|
||||||
return true;
|
return true;
|
||||||
|
#elif defined(a32)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchLibrary(char *Identifier)
|
void SearchLibrary(char *Identifier)
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
namespace GraphicalUserInterface
|
namespace GraphicalUserInterface
|
||||||
{
|
{
|
||||||
Ofast inline void InlineSetPixel(ScreenBitmap *Bitmap, long X, long Y, uint32_t Color)
|
Ofast inline void InlineSetPixel(ScreenBitmap *Bitmap, int64_t X, int64_t Y, uint32_t Color)
|
||||||
{
|
{
|
||||||
if (unlikely(X < 0 || Y < 0 || X >= Bitmap->Width || Y >= Bitmap->Height))
|
if (unlikely(X < 0 || Y < 0 || X >= Bitmap->Width || Y >= Bitmap->Height))
|
||||||
return;
|
return;
|
||||||
@ -31,7 +31,7 @@ namespace GraphicalUserInterface
|
|||||||
// Bitmap->Data[Y * Bitmap->Width + X] = Color;
|
// Bitmap->Data[Y * Bitmap->Width + X] = Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPixel(ScreenBitmap *Bitmap, long X, long Y, uint32_t Color)
|
void SetPixel(ScreenBitmap *Bitmap, int64_t X, int64_t Y, uint32_t Color)
|
||||||
{
|
{
|
||||||
if (unlikely(!Bitmap))
|
if (unlikely(!Bitmap))
|
||||||
return;
|
return;
|
||||||
@ -42,7 +42,7 @@ namespace GraphicalUserInterface
|
|||||||
InlineSetPixel(Bitmap, X, Y, Color);
|
InlineSetPixel(Bitmap, X, Y, Color);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GetPixel(ScreenBitmap *Bitmap, long X, long Y)
|
uint32_t GetPixel(ScreenBitmap *Bitmap, int64_t X, int64_t Y)
|
||||||
{
|
{
|
||||||
if (unlikely(!Bitmap))
|
if (unlikely(!Bitmap))
|
||||||
return 0;
|
return 0;
|
||||||
@ -59,8 +59,8 @@ namespace GraphicalUserInterface
|
|||||||
|
|
||||||
Ofast void DrawOverBitmap(ScreenBitmap *DestinationBitmap,
|
Ofast void DrawOverBitmap(ScreenBitmap *DestinationBitmap,
|
||||||
ScreenBitmap *SourceBitmap,
|
ScreenBitmap *SourceBitmap,
|
||||||
long Top,
|
int64_t Top,
|
||||||
long Left, bool IgnoreZero)
|
int64_t Left, bool IgnoreZero)
|
||||||
{
|
{
|
||||||
if (unlikely(!SourceBitmap) || unlikely(!SourceBitmap->Data) ||
|
if (unlikely(!SourceBitmap) || unlikely(!SourceBitmap->Data) ||
|
||||||
unlikely(!DestinationBitmap) || unlikely(!DestinationBitmap->Data))
|
unlikely(!DestinationBitmap) || unlikely(!DestinationBitmap->Data))
|
||||||
@ -89,7 +89,7 @@ namespace GraphicalUserInterface
|
|||||||
{
|
{
|
||||||
memcpy((void *)((uintptr_t)DestinationBitmap->Data + (Top + j) * DestinationBitmap->Width * (DestinationBitmap->BitsPerPixel / 8) + Left * (DestinationBitmap->BitsPerPixel / 8)),
|
memcpy((void *)((uintptr_t)DestinationBitmap->Data + (Top + j) * DestinationBitmap->Width * (DestinationBitmap->BitsPerPixel / 8) + Left * (DestinationBitmap->BitsPerPixel / 8)),
|
||||||
(void *)((uintptr_t)SourceBitmap->Data + j * SourceBitmap->Width * (SourceBitmap->BitsPerPixel / 8)),
|
(void *)((uintptr_t)SourceBitmap->Data + j * SourceBitmap->Width * (SourceBitmap->BitsPerPixel / 8)),
|
||||||
SourceBitmap->Width * (SourceBitmap->BitsPerPixel / 8));
|
(size_t)(SourceBitmap->Width * (SourceBitmap->BitsPerPixel / 8)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ namespace GraphicalUserInterface
|
|||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wstrict-overflow"
|
#pragma GCC diagnostic ignored "-Wstrict-overflow"
|
||||||
void PaintChar(Video::Font *font, ScreenBitmap *Bitmap, char c, uint32_t Color, long *CharCursorX, long *CharCursorY)
|
void PaintChar(Video::Font *font, ScreenBitmap *Bitmap, char c, uint32_t Color, int64_t *CharCursorX, int64_t *CharCursorY)
|
||||||
{
|
{
|
||||||
switch (font->GetInfo().Type)
|
switch (font->GetInfo().Type)
|
||||||
{
|
{
|
||||||
|
@ -152,8 +152,8 @@ namespace GraphicalUserInterface
|
|||||||
{
|
{
|
||||||
if (MouseArray[1].Left)
|
if (MouseArray[1].Left)
|
||||||
{
|
{
|
||||||
wnd->GetPositionPtr()->Width += Mouse.X - MouseArray[0].X;
|
wnd->GetPositionPtr()->Width += (size_t)(Mouse.X - MouseArray[0].X);
|
||||||
wnd->GetPositionPtr()->Height += Mouse.Y - MouseArray[0].Y;
|
wnd->GetPositionPtr()->Height += (size_t)(Mouse.Y - MouseArray[0].Y);
|
||||||
|
|
||||||
if (wnd->GetPositionPtr()->Width < 200)
|
if (wnd->GetPositionPtr()->Width < 200)
|
||||||
{
|
{
|
||||||
@ -398,8 +398,8 @@ namespace GraphicalUserInterface
|
|||||||
TopBarTextPos.Top += 4;
|
TopBarTextPos.Top += 4;
|
||||||
|
|
||||||
// Title bar text
|
// Title bar text
|
||||||
long CharCursorX = TopBarTextPos.Left;
|
int64_t CharCursorX = TopBarTextPos.Left;
|
||||||
long CharCursorY = TopBarTextPos.Top;
|
int64_t CharCursorY = TopBarTextPos.Top;
|
||||||
for (uint64_t i = 0; i < strlen(wnd->GetTitle()); i++)
|
for (uint64_t i = 0; i < strlen(wnd->GetTitle()); i++)
|
||||||
PaintChar(this->CurrentFont, this->OverlayBuffer, wnd->GetTitle()[i], 0xFFFFFF, &CharCursorX, &CharCursorY);
|
PaintChar(this->CurrentFont, this->OverlayBuffer, wnd->GetTitle()[i], 0xFFFFFF, &CharCursorX, &CharCursorY);
|
||||||
|
|
||||||
@ -646,7 +646,7 @@ namespace GraphicalUserInterface
|
|||||||
this->CursorBuffer->Height = 25;
|
this->CursorBuffer->Height = 25;
|
||||||
this->CursorBuffer->BitsPerPixel = Display->GetBitsPerPixel();
|
this->CursorBuffer->BitsPerPixel = Display->GetBitsPerPixel();
|
||||||
this->CursorBuffer->Pitch = Display->GetPitch();
|
this->CursorBuffer->Pitch = Display->GetPitch();
|
||||||
this->CursorBuffer->Size = this->CursorBuffer->Width * this->CursorBuffer->Height * (this->CursorBuffer->BitsPerPixel / 8);
|
this->CursorBuffer->Size = (size_t)(this->CursorBuffer->Width * this->CursorBuffer->Height * (this->CursorBuffer->BitsPerPixel / 8));
|
||||||
this->CursorBuffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->CursorBuffer->Size + 1));
|
this->CursorBuffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->CursorBuffer->Size + 1));
|
||||||
memset(this->CursorBuffer->Data, 0, this->CursorBuffer->Size);
|
memset(this->CursorBuffer->Data, 0, this->CursorBuffer->Size);
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ namespace GraphicalUserInterface
|
|||||||
|
|
||||||
void WidgetCollection::OnPaint(Event *e)
|
void WidgetCollection::OnPaint(Event *e)
|
||||||
{
|
{
|
||||||
static long LastWidth = 0;
|
static int64_t LastWidth = 0;
|
||||||
static long LastHeight = 0;
|
static int64_t LastHeight = 0;
|
||||||
|
|
||||||
if (LastWidth != ((Window *)this->ParentWindow)->GetPosition().Width ||
|
if (LastWidth != ((Window *)this->ParentWindow)->GetPosition().Width ||
|
||||||
LastHeight != ((Window *)this->ParentWindow)->GetPosition().Height)
|
LastHeight != ((Window *)this->ParentWindow)->GetPosition().Height)
|
||||||
@ -84,7 +84,7 @@ namespace GraphicalUserInterface
|
|||||||
this->Buffer->Height = LastHeight;
|
this->Buffer->Height = LastHeight;
|
||||||
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
|
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
|
||||||
this->Buffer->Pitch = Display->GetPitch();
|
this->Buffer->Pitch = Display->GetPitch();
|
||||||
this->Buffer->Size = this->Buffer->Pitch * LastHeight;
|
this->Buffer->Size = this->Buffer->Pitch * (size_t)LastHeight;
|
||||||
this->Buffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->Buffer->Size + 1));
|
this->Buffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->Buffer->Size + 1));
|
||||||
memset(this->Buffer->Data, 0, this->Buffer->Size);
|
memset(this->Buffer->Data, 0, this->Buffer->Size);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ namespace GraphicalUserInterface
|
|||||||
this->Buffer->Height = ((Window *)this->ParentWindow)->GetPosition().Height;
|
this->Buffer->Height = ((Window *)this->ParentWindow)->GetPosition().Height;
|
||||||
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
|
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
|
||||||
this->Buffer->Pitch = Display->GetPitch();
|
this->Buffer->Pitch = Display->GetPitch();
|
||||||
this->Buffer->Size = this->Buffer->Pitch * ((Window *)this->ParentWindow)->GetPosition().Height;
|
this->Buffer->Size = (size_t)(this->Buffer->Pitch * ((Window *)this->ParentWindow)->GetPosition().Height);
|
||||||
this->Buffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->Buffer->Size + 1));
|
this->Buffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->Buffer->Size + 1));
|
||||||
memset(this->Buffer->Data, 0, this->Buffer->Size);
|
memset(this->Buffer->Data, 0, this->Buffer->Size);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ namespace GraphicalUserInterface
|
|||||||
if (!this->Maximized)
|
if (!this->Maximized)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
sprintf(buf, "Left:\eAA11FF%ld\eFFFFFF Top:\eAA11FF%ld\eFFFFFF W:\eAA11FF%ld\eFFFFFF H:\eAA11FF%ld\eFFFFFF", this->Position.Left, this->Position.Top, this->Position.Width, this->Position.Height);
|
sprintf(buf, "Left:\eAA11FF%lld\eFFFFFF Top:\eAA11FF%lld\eFFFFFF W:\eAA11FF%ld\eFFFFFF H:\eAA11FF%ld\eFFFFFF", this->Position.Left, this->Position.Top, this->Position.Width, this->Position.Height);
|
||||||
// Display->DrawString(buf, this->Position.Left + 20, this->Position.Top + 25, 200);
|
// Display->DrawString(buf, this->Position.Left + 20, this->Position.Top + 25, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ EXTERNC void KPrint(const char *Format, ...)
|
|||||||
uint64_t Nanoseconds = TimeManager->GetNanosecondsSinceClassCreation();
|
uint64_t Nanoseconds = TimeManager->GetNanosecondsSinceClassCreation();
|
||||||
if (Nanoseconds != 0)
|
if (Nanoseconds != 0)
|
||||||
{
|
{
|
||||||
printf("\eCCCCCC[\e00AEFF%lu.%07lu\eCCCCCC] ",
|
printf("\eCCCCCC[\e00AEFF%llu.%07llu\eCCCCCC] ",
|
||||||
Nanoseconds / 10000000,
|
Nanoseconds / 10000000,
|
||||||
Nanoseconds % 10000000);
|
Nanoseconds % 10000000);
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ void TaskMgr()
|
|||||||
continue;
|
continue;
|
||||||
int Status = Proc->Status;
|
int Status = Proc->Status;
|
||||||
uint64_t ProcessCpuUsage = GetUsage(OldSystemTime, &Proc->Info);
|
uint64_t ProcessCpuUsage = GetUsage(OldSystemTime, &Proc->Info);
|
||||||
printf("\e%s-> \eAABBCC%s \e00AAAA%s %ld%% (KT: %ld UT: %ld)\n",
|
printf("\e%s-> \eAABBCC%s \e00AAAA%s %lld%% (KT: %lld UT: %lld)\n",
|
||||||
Statuses[Status], Proc->Name, StatusesSign[Status], ProcessCpuUsage, Proc->Info.KernelTime, Proc->Info.UserTime);
|
Statuses[Status], Proc->Name, StatusesSign[Status], ProcessCpuUsage, Proc->Info.KernelTime, Proc->Info.UserTime);
|
||||||
|
|
||||||
foreach (auto Thd in Proc->Threads)
|
foreach (auto Thd in Proc->Threads)
|
||||||
@ -185,7 +185,7 @@ void TaskMgr()
|
|||||||
Thd->Info.UserTime, Thd->Registers.rip,
|
Thd->Info.UserTime, Thd->Registers.rip,
|
||||||
Thd->Parent->ELFSymbolTable ? Thd->Parent->ELFSymbolTable->GetSymbolFromAddress(Thd->Registers.rip) : "unknown");
|
Thd->Parent->ELFSymbolTable ? Thd->Parent->ELFSymbolTable->GetSymbolFromAddress(Thd->Registers.rip) : "unknown");
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
printf(" \e%s-> \eAABBCC%s \e00AAAA%s %ld%% (KT: %ld UT: %ld, IP: \e24FF2B%#lx \eEDFF24%s\e00AAAA)\n\eAABBCC",
|
printf(" \e%s-> \eAABBCC%s \e00AAAA%s %lld%% (KT: %lld UT: %lld, IP: \e24FF2B%#lx \eEDFF24%s\e00AAAA)\n\eAABBCC",
|
||||||
Statuses[Status], Thd->Name, StatusesSign[Status], ThreadCpuUsage, Thd->Info.KernelTime,
|
Statuses[Status], Thd->Name, StatusesSign[Status], ThreadCpuUsage, Thd->Info.KernelTime,
|
||||||
Thd->Info.UserTime, Thd->Registers.eip,
|
Thd->Info.UserTime, Thd->Registers.eip,
|
||||||
Thd->Parent->ELFSymbolTable ? Thd->Parent->ELFSymbolTable->GetSymbolFromAddress(Thd->Registers.eip) : "unknown");
|
Thd->Parent->ELFSymbolTable ? Thd->Parent->ELFSymbolTable->GetSymbolFromAddress(Thd->Registers.eip) : "unknown");
|
||||||
@ -283,7 +283,7 @@ void BootLogoAnimationThread()
|
|||||||
char BootAnimPath[16];
|
char BootAnimPath[16];
|
||||||
while (FrameCount < 27)
|
while (FrameCount < 27)
|
||||||
{
|
{
|
||||||
sprintf(BootAnimPath, "%d.tga", FrameCount);
|
sprintf(BootAnimPath, "%ld.tga", FrameCount);
|
||||||
File ba = bootanim_vfs->Open(BootAnimPath);
|
File ba = bootanim_vfs->Open(BootAnimPath);
|
||||||
if (!ba.IsOK())
|
if (!ba.IsOK())
|
||||||
{
|
{
|
||||||
|
@ -135,7 +135,7 @@ void md5Finalize(MD5Context *ctx)
|
|||||||
}
|
}
|
||||||
input[14] = (uint32_t)(ctx->size * 8);
|
input[14] = (uint32_t)(ctx->size * 8);
|
||||||
#ifdef a32
|
#ifdef a32
|
||||||
input[15] = (uint32_t)((ctx->size >> 32) | (ctx->size << 32)) >> 32;
|
input[15] = (uint32_t)((uint64_t)(((uint64_t)ctx->size >> 32) | ((uint64_t)ctx->size << 32)) >> 32);
|
||||||
#else
|
#else
|
||||||
input[15] = (uint32_t)((ctx->size * 8) >> 32);
|
input[15] = (uint32_t)((ctx->size * 8) >> 32);
|
||||||
#endif
|
#endif
|
||||||
|
4
Makefile
4
Makefile
@ -83,8 +83,8 @@ LDFLAGS += -TArchitecture/amd64/linker.ld \
|
|||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
|
|
||||||
CFLAGS += -fno-pic -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fno-pic -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -march=pentium -pipe -msoft-float \
|
-mno-red-zone -march=pentium -pipe -fno-builtin \
|
||||||
-fno-builtin -Da32 -Da86
|
-Da32 -Da86
|
||||||
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
||||||
LDFLAGS += -TArchitecture/i386/linker.ld \
|
LDFLAGS += -TArchitecture/i386/linker.ld \
|
||||||
-fno-pic -fno-pie \
|
-fno-pic -fno-pie \
|
||||||
|
@ -188,7 +188,7 @@ namespace NetworkARP
|
|||||||
delete Header, Header = nullptr;
|
delete Header, Header = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ARP::OnEthernetPacketReceived(uint8_t *Data, uint64_t Length)
|
bool ARP::OnEthernetPacketReceived(uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(Length);
|
UNUSED(Length);
|
||||||
netdbg("Received packet");
|
netdbg("Received packet");
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <net/net.hpp>
|
#include <net/net.hpp>
|
||||||
|
|
||||||
uint16_t CalculateChecksum(uint16_t *Data, uint64_t Length)
|
uint16_t CalculateChecksum(uint16_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
uint16_t *Data16 = (uint16_t *)Data;
|
uint16_t *Data16 = (uint16_t *)Data;
|
||||||
uint64_t Checksum = 0;
|
uint64_t Checksum = 0;
|
||||||
|
@ -153,7 +153,7 @@ namespace NetworkDHCP
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHCP::OnUDPPacketReceived(NetworkUDP::Socket *Socket, uint8_t *Data, uint64_t Length)
|
void DHCP::OnUDPPacketReceived(NetworkUDP::Socket *Socket, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(Socket);
|
UNUSED(Socket);
|
||||||
UNUSED(Length);
|
UNUSED(Length);
|
||||||
|
@ -43,7 +43,7 @@ namespace NetworkEthernet
|
|||||||
debug("Ethernet interface %#lx destroyed.", this);
|
debug("Ethernet interface %#lx destroyed.", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ethernet::Send(MediaAccessControl MAC, FrameType Type, uint8_t *Data, uint64_t Length)
|
void Ethernet::Send(MediaAccessControl MAC, FrameType Type, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
netdbg("Sending frame type %#x to %s", Type, MAC.ToString());
|
netdbg("Sending frame type %#x to %s", Type, MAC.ToString());
|
||||||
size_t PacketLength = sizeof(EthernetHeader) + Length;
|
size_t PacketLength = sizeof(EthernetHeader) + Length;
|
||||||
@ -60,7 +60,7 @@ namespace NetworkEthernet
|
|||||||
kfree(Packet);
|
kfree(Packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ethernet::Receive(uint8_t *Data, uint64_t Length)
|
void Ethernet::Receive(uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
EthernetPacket *Packet = (EthernetPacket *)Data;
|
EthernetPacket *Packet = (EthernetPacket *)Data;
|
||||||
size_t PacketLength = Length - sizeof(EthernetHeader);
|
size_t PacketLength = Length - sizeof(EthernetHeader);
|
||||||
@ -124,7 +124,7 @@ namespace NetworkEthernet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ethernet::OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, uint64_t Length)
|
void Ethernet::OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
if (Interface == this->Interface)
|
if (Interface == this->Interface)
|
||||||
this->Receive(Data, Length);
|
this->Receive(Data, Length);
|
||||||
|
@ -62,7 +62,7 @@ namespace NetworkICMPv6
|
|||||||
ICMPv6::ICMPv6(NetworkInterfaceManager::DeviceInterface *Interface) { this->Interface = Interface; }
|
ICMPv6::ICMPv6(NetworkInterfaceManager::DeviceInterface *Interface) { this->Interface = Interface; }
|
||||||
ICMPv6::~ICMPv6() {}
|
ICMPv6::~ICMPv6() {}
|
||||||
|
|
||||||
void ICMPv6::Send(uint8_t *Data, uint64_t Length)
|
void ICMPv6::Send(uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(Data);
|
UNUSED(Data);
|
||||||
UNUSED(Length);
|
UNUSED(Length);
|
||||||
|
@ -34,7 +34,7 @@ namespace NetworkIPv4
|
|||||||
debug("IPv4 interface %#lx destroyed.", this);
|
debug("IPv4 interface %#lx destroyed.", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPv4::Send(uint8_t *Data, uint64_t Length, uint8_t Protocol, InternetProtocol DestinationIP)
|
void IPv4::Send(uint8_t *Data, size_t Length, uint8_t Protocol, InternetProtocol DestinationIP)
|
||||||
{
|
{
|
||||||
netdbg("Sending %ld bytes to %s", Length, DestinationIP.v4.ToStringLittleEndian());
|
netdbg("Sending %ld bytes to %s", Length, DestinationIP.v4.ToStringLittleEndian());
|
||||||
IPv4Packet *Packet = (IPv4Packet *)kmalloc(Length + sizeof(IPv4Header));
|
IPv4Packet *Packet = (IPv4Packet *)kmalloc(Length + sizeof(IPv4Header));
|
||||||
@ -68,7 +68,7 @@ namespace NetworkIPv4
|
|||||||
|
|
||||||
std::vector<IPv4Events *> RegisteredEvents;
|
std::vector<IPv4Events *> RegisteredEvents;
|
||||||
|
|
||||||
bool IPv4::OnEthernetPacketReceived(uint8_t *Data, uint64_t Length)
|
bool IPv4::OnEthernetPacketReceived(uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
IPv4Packet *Packet = (IPv4Packet *)Data;
|
IPv4Packet *Packet = (IPv4Packet *)Data;
|
||||||
netdbg("Received %d bytes [Protocol %ld]", Length, Packet->Header.Protocol);
|
netdbg("Received %d bytes [Protocol %ld]", Length, Packet->Header.Protocol);
|
||||||
@ -82,7 +82,7 @@ namespace NetworkIPv4
|
|||||||
|
|
||||||
if (b32(Packet->Header.DestinationIP) == Ethernet->GetInterface()->IP.v4.ToHex() || b32(Packet->Header.DestinationIP) == 0xFFFFFFFF || Ethernet->GetInterface()->IP.v4.ToHex() == 0)
|
if (b32(Packet->Header.DestinationIP) == Ethernet->GetInterface()->IP.v4.ToHex() || b32(Packet->Header.DestinationIP) == 0xFFFFFFFF || Ethernet->GetInterface()->IP.v4.ToHex() == 0)
|
||||||
{
|
{
|
||||||
uint64_t TotalLength = Packet->Header.TotalLength;
|
size_t TotalLength = Packet->Header.TotalLength;
|
||||||
if (TotalLength > Length)
|
if (TotalLength > Length)
|
||||||
TotalLength = Length;
|
TotalLength = Length;
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ namespace NetworkIPv4
|
|||||||
|
|
||||||
IPv4Events::~IPv4Events()
|
IPv4Events::~IPv4Events()
|
||||||
{
|
{
|
||||||
for (uint64_t i = 0; i < RegisteredEvents.size(); i++)
|
for (size_t i = 0; i < RegisteredEvents.size(); i++)
|
||||||
if (RegisteredEvents[i] == this)
|
if (RegisteredEvents[i] == this)
|
||||||
{
|
{
|
||||||
RegisteredEvents.remove(i);
|
RegisteredEvents.remove(i);
|
||||||
|
@ -210,7 +210,7 @@ namespace NetworkInterfaceManager
|
|||||||
NIManager->Receive(inf, Data, Size);
|
NIManager->Receive(inf, Data, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkInterface::Send(DeviceInterface *Interface, uint8_t *Data, uint64_t Length)
|
void NetworkInterface::Send(DeviceInterface *Interface, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
void *DataToBeSent = mem->RequestPages(TO_PAGES(Length + 1));
|
void *DataToBeSent = mem->RequestPages(TO_PAGES(Length + 1));
|
||||||
memcpy(DataToBeSent, Data, Length);
|
memcpy(DataToBeSent, Data, Length);
|
||||||
@ -226,7 +226,7 @@ namespace NetworkInterfaceManager
|
|||||||
var->OnInterfaceSent(Interface, Data, Length);
|
var->OnInterfaceSent(Interface, Data, Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkInterface::Receive(DeviceInterface *Interface, uint8_t *Data, uint64_t Length)
|
void NetworkInterface::Receive(DeviceInterface *Interface, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
foreach (auto re in RegisteredEvents)
|
foreach (auto re in RegisteredEvents)
|
||||||
re->OnInterfaceReceived(Interface, Data, Length);
|
re->OnInterfaceReceived(Interface, Data, Length);
|
||||||
|
@ -88,8 +88,8 @@ namespace NetDbg
|
|||||||
|
|
||||||
NETWORK_DEBUG() : NetworkInterfaceManager::Events(nullptr) { netdbg("NetworkDebugger initialized."); }
|
NETWORK_DEBUG() : NetworkInterfaceManager::Events(nullptr) { netdbg("NetworkDebugger initialized."); }
|
||||||
~NETWORK_DEBUG() { netdbg("NetworkDebugger destroyed."); }
|
~NETWORK_DEBUG() { netdbg("NetworkDebugger destroyed."); }
|
||||||
void OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, uint64_t Length) { DumpData("Received", Data, Length); }
|
void OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, size_t Length) { DumpData("Received", Data, Length); }
|
||||||
void OnInterfaceSent(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, uint64_t Length) { DumpData("Sent", Data, Length); }
|
void OnInterfaceSent(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, size_t Length) { DumpData("Sent", Data, Length); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
namespace NetworkNTP
|
namespace NetworkNTP
|
||||||
{
|
{
|
||||||
void NTP::OnUDPPacketReceived(NetworkUDP::Socket *Socket, uint8_t *Data, uint64_t Length)
|
void NTP::OnUDPPacketReceived(NetworkUDP::Socket *Socket, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(Socket);
|
UNUSED(Socket);
|
||||||
UNUSED(Length);
|
UNUSED(Length);
|
||||||
@ -68,7 +68,7 @@ namespace NetworkNTP
|
|||||||
TaskManager->Sleep(1000);
|
TaskManager->Sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
long UnixTimestamp = b32(this->NTPPacket.TransmitTimestamp[0]) - 2208988800;
|
uint64_t UnixTimestamp = (b32(this->NTPPacket.TransmitTimestamp[0])) - 2208988800;
|
||||||
debug("Unix time: %d", UnixTimestamp);
|
debug("Unix time: %d", UnixTimestamp);
|
||||||
return s_cst(int, UnixTimestamp);
|
return s_cst(int, UnixTimestamp);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace NetworkUDP
|
|||||||
fixme("Not implemented.");
|
fixme("Not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDP::Send(Socket *Socket, uint8_t *Data, uint64_t Length)
|
void UDP::Send(Socket *Socket, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
netdbg("Sending %d bytes to %s", Length, Socket->RemoteIP.v4.ToStringLittleEndian(), Socket->RemotePort);
|
netdbg("Sending %d bytes to %s", Length, Socket->RemoteIP.v4.ToStringLittleEndian(), Socket->RemotePort);
|
||||||
uint16_t TotalLength = s_cst(uint16_t, Length + sizeof(UDPHeader));
|
uint16_t TotalLength = s_cst(uint16_t, Length + sizeof(UDPHeader));
|
||||||
@ -97,7 +97,7 @@ namespace NetworkUDP
|
|||||||
Socket->EventHandler = EventHandler;
|
Socket->EventHandler = EventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UDP::OnIPv4PacketReceived(InternetProtocol SourceIP, InternetProtocol DestinationIP, uint8_t *Data, uint64_t Length)
|
bool UDP::OnIPv4PacketReceived(InternetProtocol SourceIP, InternetProtocol DestinationIP, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
netdbg("Received %d bytes from %s", Length, SourceIP.v4.ToStringLittleEndian());
|
netdbg("Received %d bytes from %s", Length, SourceIP.v4.ToStringLittleEndian());
|
||||||
if (Length < sizeof(UDPHeader))
|
if (Length < sizeof(UDPHeader))
|
||||||
|
@ -268,9 +268,9 @@ namespace Recovery
|
|||||||
uint64_t MemReserved = 0;
|
uint64_t MemReserved = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
sprintf(TicksText, "%016ld / %016ld", TaskManager->GetSchedulerTicks(), TaskManager->GetLastTaskTicks());
|
sprintf(TicksText, "%016lld / %016lld", TaskManager->GetSchedulerTicks(), TaskManager->GetLastTaskTicks());
|
||||||
wdgDbgWin->SetText(SchedLblHnd, TicksText);
|
wdgDbgWin->SetText(SchedLblHnd, TicksText);
|
||||||
sprintf(TicksText, "CPU Scheduled Core: %ld", TaskManager->GetLastCore());
|
sprintf(TicksText, "CPU Scheduled Core: %lld", TaskManager->GetLastCore());
|
||||||
wdgDbgWin->SetText(wdgDbgCurrentCPUSchedCoreLbl, TicksText);
|
wdgDbgWin->SetText(wdgDbgCurrentCPUSchedCoreLbl, TicksText);
|
||||||
static int RefreshMemCounter = 0;
|
static int RefreshMemCounter = 0;
|
||||||
if (RefreshMemCounter-- == 0)
|
if (RefreshMemCounter-- == 0)
|
||||||
@ -279,7 +279,7 @@ namespace Recovery
|
|||||||
MemTotal = KernelAllocator.GetTotalMemory();
|
MemTotal = KernelAllocator.GetTotalMemory();
|
||||||
MemReserved = KernelAllocator.GetReservedMemory();
|
MemReserved = KernelAllocator.GetReservedMemory();
|
||||||
uint64_t MemPercent = (MemUsed * 100) / MemTotal;
|
uint64_t MemPercent = (MemUsed * 100) / MemTotal;
|
||||||
sprintf(TicksText, "%ldMB / %ldGB (%ldMB reserved) %ld%% (%ld bytes allocated)", TO_MB(MemUsed), TO_GB(MemTotal), TO_MB(MemReserved), MemPercent, MemUsed);
|
sprintf(TicksText, "%lldMB / %lldGB (%lldMB reserved) %lld%% (%lld bytes allocated)", TO_MB(MemUsed), TO_GB(MemTotal), TO_MB(MemReserved), MemPercent, MemUsed);
|
||||||
wdgDbgWin->SetText(MemLblHnd, TicksText);
|
wdgDbgWin->SetText(MemLblHnd, TicksText);
|
||||||
RefreshMemCounter = 25;
|
RefreshMemCounter = 25;
|
||||||
}
|
}
|
||||||
@ -292,9 +292,9 @@ namespace Recovery
|
|||||||
static int RefreshGUIDbgCounter = 0;
|
static int RefreshGUIDbgCounter = 0;
|
||||||
if (RefreshGUIDbgCounter-- == 0)
|
if (RefreshGUIDbgCounter-- == 0)
|
||||||
{
|
{
|
||||||
sprintf(TicksText, "%016ld / %016ld / %016ld", FIi, PDi, PWi);
|
sprintf(TicksText, "%016lld / %016lld / %016lld", FIi, PDi, PWi);
|
||||||
wdgDbgWin->SetText(GUI1LblHnd, TicksText);
|
wdgDbgWin->SetText(GUI1LblHnd, TicksText);
|
||||||
sprintf(TicksText, "%016ld / %016ld / %016ld", PWWi, PCi, mmi);
|
sprintf(TicksText, "%016lld / %016lld / %016lld", PWWi, PCi, mmi);
|
||||||
wdgDbgWin->SetText(GUI2LblHnd, TicksText);
|
wdgDbgWin->SetText(GUI2LblHnd, TicksText);
|
||||||
RefreshGUIDbgCounter = 5;
|
RefreshGUIDbgCounter = 5;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ static uint64_t sys_file_read(SyscallsFrame *Frame, void *KernelPrivate, uint64_
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
debug("(KernelPrivate: %#lx, Offset: %#lx, Buffer: %#lx, Size: %#lx)", KernelPrivate, Offset, Buffer, Size);
|
debug("(KernelPrivate: %#lx, Offset: %#lx, Buffer: %#lx, Size: %#lx)", KernelPrivate, Offset, Buffer, Size);
|
||||||
return vfs->Read(*(VirtualFileSystem::File *)KernelPrivate, Offset, Buffer, Size);
|
return vfs->Read(*(VirtualFileSystem::File *)KernelPrivate, (size_t)Offset, Buffer, (size_t)Size);
|
||||||
UNUSED(Frame);
|
UNUSED(Frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ static uint64_t sys_file_write(SyscallsFrame *Frame, void *KernelPrivate, uint64
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
debug("(KernelPrivate: %#lx, Offset: %#lx, Buffer: %#lx, Size: %#lx)", KernelPrivate, Offset, Buffer, Size);
|
debug("(KernelPrivate: %#lx, Offset: %#lx, Buffer: %#lx, Size: %#lx)", KernelPrivate, Offset, Buffer, Size);
|
||||||
return vfs->Write(*(VirtualFileSystem::File *)KernelPrivate, Offset, Buffer, Size);
|
return vfs->Write(*(VirtualFileSystem::File *)KernelPrivate, (size_t)Offset, Buffer, (size_t)Size);
|
||||||
UNUSED(Frame);
|
UNUSED(Frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ static uint64_t sys_file_seek(SyscallsFrame *Frame, void *KernelPrivate, uint64_
|
|||||||
if (KPObj->node->Operator->Seek == nullptr)
|
if (KPObj->node->Operator->Seek == nullptr)
|
||||||
return SYSCALL_INTERNAL_ERROR;
|
return SYSCALL_INTERNAL_ERROR;
|
||||||
|
|
||||||
uint64_t ret = KPObj->node->Operator->Seek(KPObj->node, Offset, (uint8_t)Whence);
|
uint64_t ret = KPObj->node->Operator->Seek(KPObj->node, (size_t)Offset, (uint8_t)Whence);
|
||||||
debug("Seek %s %ld", KPObj->Name, ret);
|
debug("Seek %s %ld", KPObj->Name, ret);
|
||||||
return ret;
|
return ret;
|
||||||
UNUSED(Frame);
|
UNUSED(Frame);
|
||||||
@ -458,7 +458,7 @@ static int sys_spawn(SyscallsFrame *Frame)
|
|||||||
|
|
||||||
static int sys_spawn_thread(SyscallsFrame *Frame, uint64_t InstructionPointer)
|
static int sys_spawn_thread(SyscallsFrame *Frame, uint64_t InstructionPointer)
|
||||||
{
|
{
|
||||||
Tasking::TCB *thread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), InstructionPointer);
|
Tasking::TCB *thread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)InstructionPointer);
|
||||||
if (thread)
|
if (thread)
|
||||||
return (int)thread->ID;
|
return (int)thread->ID;
|
||||||
return SYSCALL_ERROR;
|
return SYSCALL_ERROR;
|
||||||
|
@ -676,21 +676,25 @@ namespace Tasking
|
|||||||
SafeFunction bool Task::FindNewProcess(void *CPUDataPointer)
|
SafeFunction bool Task::FindNewProcess(void *CPUDataPointer)
|
||||||
{
|
{
|
||||||
fixme("unimplemented");
|
fixme("unimplemented");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeFunction bool Task::GetNextAvailableThread(void *CPUDataPointer)
|
SafeFunction bool Task::GetNextAvailableThread(void *CPUDataPointer)
|
||||||
{
|
{
|
||||||
fixme("unimplemented");
|
fixme("unimplemented");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeFunction bool Task::GetNextAvailableProcess(void *CPUDataPointer)
|
SafeFunction bool Task::GetNextAvailableProcess(void *CPUDataPointer)
|
||||||
{
|
{
|
||||||
fixme("unimplemented");
|
fixme("unimplemented");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeFunction bool Task::SchedulerSearchProcessThread(void *CPUDataPointer)
|
SafeFunction bool Task::SchedulerSearchProcessThread(void *CPUDataPointer)
|
||||||
{
|
{
|
||||||
fixme("unimplemented");
|
fixme("unimplemented");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeFunction void Task::Schedule(void *Frame)
|
SafeFunction void Task::Schedule(void *Frame)
|
||||||
|
@ -25,9 +25,9 @@ namespace Tasking
|
|||||||
{
|
{
|
||||||
Token Security::CreateToken()
|
Token Security::CreateToken()
|
||||||
{
|
{
|
||||||
uint64_t ret = 0;
|
Token ret = 0;
|
||||||
Retry:
|
Retry:
|
||||||
ret = Random::rand64();
|
ret = (Token)Random::rand64();
|
||||||
foreach (auto t in Tokens)
|
foreach (auto t in Tokens)
|
||||||
if (t.token == ret)
|
if (t.token == ret)
|
||||||
goto Retry;
|
goto Retry;
|
||||||
|
@ -71,7 +71,7 @@ void TestMemoryAllocation()
|
|||||||
uint64_t prq1 = (uint64_t)KernelAllocator.RequestPage();
|
uint64_t prq1 = (uint64_t)KernelAllocator.RequestPage();
|
||||||
KernelAllocator.FreePage((void *)prq1);
|
KernelAllocator.FreePage((void *)prq1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
KernelAllocator.FreePage(KernelAllocator.RequestPage());
|
KernelAllocator.FreePage(KernelAllocator.RequestPage());
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)KernelAllocator.RequestPage();
|
uint64_t prq2 = (uint64_t)KernelAllocator.RequestPage();
|
||||||
@ -86,7 +86,7 @@ void TestMemoryAllocation()
|
|||||||
uint64_t prq1 = (uint64_t)KernelAllocator.RequestPages(10);
|
uint64_t prq1 = (uint64_t)KernelAllocator.RequestPages(10);
|
||||||
KernelAllocator.FreePages((void *)prq1, 10);
|
KernelAllocator.FreePages((void *)prq1, 10);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
KernelAllocator.FreePages(KernelAllocator.RequestPages(20), 20);
|
KernelAllocator.FreePages(KernelAllocator.RequestPages(20), 20);
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)KernelAllocator.RequestPages(10);
|
uint64_t prq2 = (uint64_t)KernelAllocator.RequestPages(10);
|
||||||
@ -98,13 +98,13 @@ void TestMemoryAllocation()
|
|||||||
|
|
||||||
debug("Multiple Fixed Malloc Test");
|
debug("Multiple Fixed Malloc Test");
|
||||||
{
|
{
|
||||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq1);
|
kfree((void *)prq1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
kfree(kmalloc(0x10000));
|
kfree(kmalloc(0x10000));
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq2);
|
kfree((void *)prq2);
|
||||||
|
|
||||||
debug(" Result:\t\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
debug(" Result:\t\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||||
@ -113,13 +113,13 @@ void TestMemoryAllocation()
|
|||||||
|
|
||||||
debug("Multiple Dynamic Malloc Test");
|
debug("Multiple Dynamic Malloc Test");
|
||||||
{
|
{
|
||||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq1);
|
kfree((void *)prq1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
kfree(kmalloc(i));
|
kfree(kmalloc(i));
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq2);
|
kfree((void *)prq2);
|
||||||
|
|
||||||
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||||
@ -128,16 +128,16 @@ void TestMemoryAllocation()
|
|||||||
|
|
||||||
debug("New/Delete Test");
|
debug("New/Delete Test");
|
||||||
{
|
{
|
||||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq1);
|
kfree((void *)prq1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
{
|
{
|
||||||
test_mem_new_delete *t = new test_mem_new_delete();
|
test_mem_new_delete *t = new test_mem_new_delete();
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq2);
|
kfree((void *)prq2);
|
||||||
|
|
||||||
debug(" Result: \t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
debug(" Result: \t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||||
@ -146,16 +146,16 @@ void TestMemoryAllocation()
|
|||||||
|
|
||||||
debug("New/Delete Fixed Array Test");
|
debug("New/Delete Fixed Array Test");
|
||||||
{
|
{
|
||||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq1);
|
kfree((void *)prq1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
{
|
{
|
||||||
char *t = new char[128];
|
char *t = new char[128];
|
||||||
delete[] t;
|
delete[] t;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq2);
|
kfree((void *)prq2);
|
||||||
|
|
||||||
debug(" Result: \t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
debug(" Result: \t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||||
@ -164,10 +164,10 @@ void TestMemoryAllocation()
|
|||||||
|
|
||||||
debug("New/Delete Dynamic Array Test");
|
debug("New/Delete Dynamic Array Test");
|
||||||
{
|
{
|
||||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq1);
|
kfree((void *)prq1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
continue;
|
continue;
|
||||||
@ -175,7 +175,7 @@ void TestMemoryAllocation()
|
|||||||
delete[] t;
|
delete[] t;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq2);
|
kfree((void *)prq2);
|
||||||
|
|
||||||
debug(" Result:\t1-[%#lx]; 2-[%#lx]\n", (void *)prq1, (void *)prq2);
|
debug(" Result:\t1-[%#lx]; 2-[%#lx]\n", (void *)prq1, (void *)prq2);
|
||||||
@ -184,16 +184,16 @@ void TestMemoryAllocation()
|
|||||||
|
|
||||||
debug("calloc Test");
|
debug("calloc Test");
|
||||||
{
|
{
|
||||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq1);
|
kfree((void *)prq1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
{
|
{
|
||||||
char *t = (char *)kcalloc(128, 1);
|
char *t = (char *)kcalloc(128, 1);
|
||||||
kfree(t);
|
kfree(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq2);
|
kfree((void *)prq2);
|
||||||
|
|
||||||
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||||
@ -202,17 +202,17 @@ void TestMemoryAllocation()
|
|||||||
|
|
||||||
debug("realloc Test");
|
debug("realloc Test");
|
||||||
{
|
{
|
||||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq1);
|
kfree((void *)prq1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||||
{
|
{
|
||||||
char *t = (char *)kmalloc(128);
|
char *t = (char *)kmalloc(128);
|
||||||
t = (char *)krealloc(t, 256);
|
t = (char *)krealloc(t, 256);
|
||||||
kfree(t);
|
kfree(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||||
kfree((void *)prq2);
|
kfree((void *)prq2);
|
||||||
|
|
||||||
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||||
|
@ -43,7 +43,7 @@ __constructor void TestRandom()
|
|||||||
#if defined(a86)
|
#if defined(a86)
|
||||||
if (RDRANDFlag)
|
if (RDRANDFlag)
|
||||||
{
|
{
|
||||||
uint64_t RDSEEDValue = 0;
|
uintptr_t RDSEEDValue = 0;
|
||||||
asmv("1: rdseed %0; jnc 1b"
|
asmv("1: rdseed %0; jnc 1b"
|
||||||
: "=r"(RDSEEDValue));
|
: "=r"(RDSEEDValue));
|
||||||
debug("RDSEED: %ld", RDSEEDValue);
|
debug("RDSEED: %ld", RDSEEDValue);
|
||||||
|
@ -52,7 +52,7 @@ struct BootInfo
|
|||||||
void *BaseAddress;
|
void *BaseAddress;
|
||||||
__UINT32_TYPE__ Width;
|
__UINT32_TYPE__ Width;
|
||||||
__UINT32_TYPE__ Height;
|
__UINT32_TYPE__ Height;
|
||||||
__UINT64_TYPE__ Pitch;
|
__SIZE_TYPE__ Pitch;
|
||||||
__UINT16_TYPE__ BitsPerPixel;
|
__UINT16_TYPE__ BitsPerPixel;
|
||||||
__UINT8_TYPE__ RedMaskSize;
|
__UINT8_TYPE__ RedMaskSize;
|
||||||
__UINT8_TYPE__ RedMaskShift;
|
__UINT8_TYPE__ RedMaskShift;
|
||||||
@ -61,7 +61,7 @@ struct BootInfo
|
|||||||
__UINT8_TYPE__ BlueMaskSize;
|
__UINT8_TYPE__ BlueMaskSize;
|
||||||
__UINT8_TYPE__ BlueMaskShift;
|
__UINT8_TYPE__ BlueMaskShift;
|
||||||
void *ExtendedDisplayIdentificationData;
|
void *ExtendedDisplayIdentificationData;
|
||||||
__UINT64_TYPE__ EDIDSize;
|
__SIZE_TYPE__ EDIDSize;
|
||||||
} Framebuffer[MAX_FRAMEBUFFERS];
|
} Framebuffer[MAX_FRAMEBUFFERS];
|
||||||
|
|
||||||
struct MemoryInfo
|
struct MemoryInfo
|
||||||
@ -69,11 +69,11 @@ struct BootInfo
|
|||||||
struct MemoryEntryInfo
|
struct MemoryEntryInfo
|
||||||
{
|
{
|
||||||
void *BaseAddress;
|
void *BaseAddress;
|
||||||
__UINT64_TYPE__ Length;
|
__SIZE_TYPE__ Length;
|
||||||
enum MemoryType Type;
|
enum MemoryType Type;
|
||||||
} Entry[MAX_MEMORY_ENTRIES];
|
} Entry[MAX_MEMORY_ENTRIES];
|
||||||
__UINT64_TYPE__ Entries;
|
__SIZE_TYPE__ Entries;
|
||||||
__UINT64_TYPE__ Size;
|
__SIZE_TYPE__ Size;
|
||||||
} Memory;
|
} Memory;
|
||||||
|
|
||||||
struct ModuleInfo
|
struct ModuleInfo
|
||||||
@ -81,7 +81,7 @@ struct BootInfo
|
|||||||
void *Address;
|
void *Address;
|
||||||
char Path[256];
|
char Path[256];
|
||||||
char CommandLine[256];
|
char CommandLine[256];
|
||||||
__UINT64_TYPE__ Size;
|
__SIZE_TYPE__ Size;
|
||||||
} Modules[MAX_MODULES];
|
} Modules[MAX_MODULES];
|
||||||
|
|
||||||
struct RSDPInfo
|
struct RSDPInfo
|
||||||
@ -132,7 +132,7 @@ struct BootInfo
|
|||||||
void *VirtualBase;
|
void *VirtualBase;
|
||||||
void *FileBase;
|
void *FileBase;
|
||||||
char CommandLine[256];
|
char CommandLine[256];
|
||||||
__UINT64_TYPE__ Size;
|
__SIZE_TYPE__ Size;
|
||||||
|
|
||||||
struct KernelSymbolInfo
|
struct KernelSymbolInfo
|
||||||
{
|
{
|
||||||
|
@ -413,7 +413,7 @@ namespace CPU
|
|||||||
|
|
||||||
SafeFunction static inline void wrmsr(uint32_t msr, uint64_t Value)
|
SafeFunction static inline void wrmsr(uint32_t msr, uint64_t Value)
|
||||||
{
|
{
|
||||||
uint32_t Low = Value, High = Value >> 32;
|
uint32_t Low = (uint32_t)Value, High = (uint32_t)(Value >> 32);
|
||||||
asmv("wrmsr"
|
asmv("wrmsr"
|
||||||
:
|
:
|
||||||
: "c"(msr), "a"(Low), "d"(High)
|
: "c"(msr), "a"(Low), "d"(High)
|
||||||
|
@ -101,8 +101,8 @@ namespace Disk
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char Label[72] = "Unidentified Partition";
|
char Label[72] = "Unidentified Partition";
|
||||||
size_t StartLBA = 0xdeadbeef;
|
uint64_t StartLBA = 0xdeadbeef;
|
||||||
size_t EndLBA = 0xdeadbeef;
|
uint64_t EndLBA = 0xdeadbeef;
|
||||||
size_t Sectors = 0xdeadbeef;
|
size_t Sectors = 0xdeadbeef;
|
||||||
size_t Flags = 0xdeadbeef;
|
size_t Flags = 0xdeadbeef;
|
||||||
unsigned char Port = 0;
|
unsigned char Port = 0;
|
||||||
|
@ -118,7 +118,7 @@ namespace Video
|
|||||||
Font *GetCurrentFont();
|
Font *GetCurrentFont();
|
||||||
void SetCurrentFont(Font *Font);
|
void SetCurrentFont(Font *Font);
|
||||||
uint16_t GetBitsPerPixel();
|
uint16_t GetBitsPerPixel();
|
||||||
uint64_t GetPitch();
|
size_t GetPitch();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create a new buffer
|
* @brief Create a new buffer
|
||||||
|
@ -48,7 +48,7 @@ namespace Driver
|
|||||||
struct DriverFile
|
struct DriverFile
|
||||||
{
|
{
|
||||||
bool Enabled = false;
|
bool Enabled = false;
|
||||||
unsigned long DriverUID = 0;
|
size_t DriverUID = 0;
|
||||||
void *Address = nullptr;
|
void *Address = nullptr;
|
||||||
void *InterruptCallback = nullptr;
|
void *InterruptCallback = nullptr;
|
||||||
Memory::MemMgr *MemTrk = nullptr;
|
Memory::MemMgr *MemTrk = nullptr;
|
||||||
|
@ -120,7 +120,7 @@ namespace VirtualFileSystem
|
|||||||
uint64_t UserIdentifier = 0, GroupIdentifier = 0;
|
uint64_t UserIdentifier = 0, GroupIdentifier = 0;
|
||||||
uintptr_t Address = 0;
|
uintptr_t Address = 0;
|
||||||
size_t Length = 0;
|
size_t Length = 0;
|
||||||
uint64_t Offset = 0;
|
size_t Offset = 0;
|
||||||
Node *Parent = nullptr;
|
Node *Parent = nullptr;
|
||||||
FileSystemOperations *Operator = nullptr;
|
FileSystemOperations *Operator = nullptr;
|
||||||
/* For root node:
|
/* For root node:
|
||||||
|
@ -42,8 +42,8 @@ namespace GraphicalUserInterface
|
|||||||
{
|
{
|
||||||
int64_t Width;
|
int64_t Width;
|
||||||
int64_t Height;
|
int64_t Height;
|
||||||
uint64_t Size;
|
size_t Size;
|
||||||
uint64_t Pitch;
|
size_t Pitch;
|
||||||
uint64_t BitsPerPixel;
|
uint64_t BitsPerPixel;
|
||||||
uint8_t *Data;
|
uint8_t *Data;
|
||||||
};
|
};
|
||||||
@ -52,8 +52,8 @@ namespace GraphicalUserInterface
|
|||||||
{
|
{
|
||||||
int64_t Left;
|
int64_t Left;
|
||||||
int64_t Top;
|
int64_t Top;
|
||||||
int64_t Width;
|
size_t Width;
|
||||||
int64_t Height;
|
size_t Height;
|
||||||
|
|
||||||
bool Contains(int64_t X, int64_t Y)
|
bool Contains(int64_t X, int64_t Y)
|
||||||
{
|
{
|
||||||
@ -89,8 +89,8 @@ namespace GraphicalUserInterface
|
|||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int64_t Width;
|
size_t Width;
|
||||||
int64_t Height;
|
size_t Height;
|
||||||
} Resize;
|
} Resize;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
@ -178,18 +178,18 @@ namespace GraphicalUserInterface
|
|||||||
virtual void OnPaintChildrenAll(Event *e) {}
|
virtual void OnPaintChildrenAll(Event *e) {}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void SetPixel(ScreenBitmap *Bitmap, long X, long Y, uint32_t Color);
|
void SetPixel(ScreenBitmap *Bitmap, int64_t X, int64_t Y, uint32_t Color);
|
||||||
void DrawOverBitmap(ScreenBitmap *DestinationBitmap,
|
void DrawOverBitmap(ScreenBitmap *DestinationBitmap,
|
||||||
ScreenBitmap *SourceBitmap,
|
ScreenBitmap *SourceBitmap,
|
||||||
long Top,
|
int64_t Top,
|
||||||
long Left,
|
int64_t Left,
|
||||||
bool IgnoreZero = true);
|
bool IgnoreZero = true);
|
||||||
void PutRect(ScreenBitmap *Bitmap, Rect rect, uint32_t Color);
|
void PutRect(ScreenBitmap *Bitmap, Rect rect, uint32_t Color);
|
||||||
void PutBorder(ScreenBitmap *Bitmap, Rect rect, uint32_t Color);
|
void PutBorder(ScreenBitmap *Bitmap, Rect rect, uint32_t Color);
|
||||||
uint32_t BlendColors(uint32_t c1, uint32_t c2, float t);
|
uint32_t BlendColors(uint32_t c1, uint32_t c2, float t);
|
||||||
void PutBorderWithShadow(ScreenBitmap *Bitmap, Rect rect, uint32_t Color);
|
void PutBorderWithShadow(ScreenBitmap *Bitmap, Rect rect, uint32_t Color);
|
||||||
void DrawShadow(ScreenBitmap *Bitmap, Rect rect);
|
void DrawShadow(ScreenBitmap *Bitmap, Rect rect);
|
||||||
void PaintChar(Video::Font *font, ScreenBitmap *Bitmap, char c, uint32_t Color, long *CharCursorX, long *CharCursorY);
|
void PaintChar(Video::Font *font, ScreenBitmap *Bitmap, char c, uint32_t Color, int64_t *CharCursorX, int64_t *CharCursorY);
|
||||||
void DrawString(ScreenBitmap *Bitmap, Rect rect, const char *Text, uint32_t Color);
|
void DrawString(ScreenBitmap *Bitmap, Rect rect, const char *Text, uint32_t Color);
|
||||||
|
|
||||||
class WidgetCollection
|
class WidgetCollection
|
||||||
@ -212,7 +212,7 @@ namespace GraphicalUserInterface
|
|||||||
Rect rect;
|
Rect rect;
|
||||||
char Text[512];
|
char Text[512];
|
||||||
uint32_t Color;
|
uint32_t Color;
|
||||||
long CharCursorX, CharCursorY;
|
int64_t CharCursorX, CharCursorY;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PanelObject
|
struct PanelObject
|
||||||
@ -235,7 +235,7 @@ namespace GraphicalUserInterface
|
|||||||
uint32_t PressedColor;
|
uint32_t PressedColor;
|
||||||
uint32_t BorderColor;
|
uint32_t BorderColor;
|
||||||
uint32_t ShadowColor;
|
uint32_t ShadowColor;
|
||||||
long CharCursorX, CharCursorY;
|
int64_t CharCursorX, CharCursorY;
|
||||||
bool Shadow;
|
bool Shadow;
|
||||||
bool Hover;
|
bool Hover;
|
||||||
bool Pressed;
|
bool Pressed;
|
||||||
|
@ -174,6 +174,7 @@ extern "C"
|
|||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(a64)
|
||||||
static inline void mmoutq(void *Address, uint64_t Value)
|
static inline void mmoutq(void *Address, uint64_t Value)
|
||||||
{
|
{
|
||||||
asmv("mov %1, %0"
|
asmv("mov %1, %0"
|
||||||
@ -181,6 +182,7 @@ extern "C"
|
|||||||
: "r"(Value)
|
: "r"(Value)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline uint8_t mminb(void *Address)
|
static inline uint8_t mminb(void *Address)
|
||||||
{
|
{
|
||||||
@ -212,6 +214,7 @@ extern "C"
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(a64)
|
||||||
static inline uint64_t mminq(void *Address)
|
static inline uint64_t mminq(void *Address)
|
||||||
{
|
{
|
||||||
uint64_t Result;
|
uint64_t Result;
|
||||||
@ -221,6 +224,7 @@ extern "C"
|
|||||||
: "memory");
|
: "memory");
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -180,9 +180,9 @@ namespace Memory
|
|||||||
|
|
||||||
union __packed PageTableEntry
|
union __packed PageTableEntry
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
uintptr_t Present : 1; // 0
|
uintptr_t Present : 1; // 0
|
||||||
uintptr_t ReadWrite : 1; // 1
|
uintptr_t ReadWrite : 1; // 1
|
||||||
uintptr_t UserSupervisor : 1; // 2
|
uintptr_t UserSupervisor : 1; // 2
|
||||||
@ -197,10 +197,7 @@ namespace Memory
|
|||||||
uintptr_t Available1 : 7; // 52-58
|
uintptr_t Available1 : 7; // 52-58
|
||||||
uintptr_t ProtectionKey : 4; // 59-62
|
uintptr_t ProtectionKey : 4; // 59-62
|
||||||
uintptr_t ExecuteDisable : 1; // 63
|
uintptr_t ExecuteDisable : 1; // 63
|
||||||
};
|
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
struct
|
|
||||||
{
|
|
||||||
uintptr_t Present : 1; // 0
|
uintptr_t Present : 1; // 0
|
||||||
uintptr_t ReadWrite : 1; // 1
|
uintptr_t ReadWrite : 1; // 1
|
||||||
uintptr_t UserSupervisor : 1; // 2
|
uintptr_t UserSupervisor : 1; // 2
|
||||||
@ -212,9 +209,9 @@ namespace Memory
|
|||||||
uintptr_t Global : 1; // 8
|
uintptr_t Global : 1; // 8
|
||||||
uintptr_t Available0 : 3; // 9-11
|
uintptr_t Available0 : 3; // 9-11
|
||||||
uintptr_t Address : 20; // 12-31
|
uintptr_t Address : 20; // 12-31
|
||||||
};
|
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
#endif
|
#endif
|
||||||
|
};
|
||||||
uintptr_t raw;
|
uintptr_t raw;
|
||||||
|
|
||||||
/** @brief Set Address */
|
/** @brief Set Address */
|
||||||
@ -241,7 +238,7 @@ namespace Memory
|
|||||||
#if defined(a64)
|
#if defined(a64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
return (this->raw & 0x003FFFFF000) >> 12;
|
return ((uintptr_t)(this->raw & 0x003FFFFF000) >> 12);
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#endif
|
#endif
|
||||||
@ -356,7 +353,7 @@ namespace Memory
|
|||||||
#if defined(a64)
|
#if defined(a64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
return (this->raw & 0x003FFFFF000) >> 12;
|
return ((uintptr_t)(this->raw & 0x003FFFFF000) >> 12);
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#endif
|
#endif
|
||||||
@ -370,6 +367,7 @@ namespace Memory
|
|||||||
|
|
||||||
union __packed PageDirectoryPointerTableEntry
|
union __packed PageDirectoryPointerTableEntry
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uintptr_t Present : 1; // 0
|
uintptr_t Present : 1; // 0
|
||||||
@ -405,7 +403,8 @@ namespace Memory
|
|||||||
uintptr_t ProtectionKey : 4; // 59-62
|
uintptr_t ProtectionKey : 4; // 59-62
|
||||||
uintptr_t ExecuteDisable : 1; // 63
|
uintptr_t ExecuteDisable : 1; // 63
|
||||||
} OneGB;
|
} OneGB;
|
||||||
|
#elif defined(aa64)
|
||||||
|
#endif
|
||||||
uintptr_t raw;
|
uintptr_t raw;
|
||||||
|
|
||||||
/** @brief Set PageDirectoryEntryPtr address */
|
/** @brief Set PageDirectoryEntryPtr address */
|
||||||
@ -415,10 +414,6 @@ namespace Memory
|
|||||||
_Address &= 0x000000FFFFFFFFFF;
|
_Address &= 0x000000FFFFFFFFFF;
|
||||||
this->raw &= 0xFFF0000000000FFF;
|
this->raw &= 0xFFF0000000000FFF;
|
||||||
this->raw |= (_Address << 12);
|
this->raw |= (_Address << 12);
|
||||||
#elif defined(a32)
|
|
||||||
_Address &= 0x000FFFFF;
|
|
||||||
this->raw &= 0xFFC00003;
|
|
||||||
this->raw |= (_Address << 12);
|
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
_Address &= 0x000000FFFFFFFFFF;
|
_Address &= 0x000000FFFFFFFFFF;
|
||||||
this->raw &= 0xFFF0000000000FFF;
|
this->raw &= 0xFFF0000000000FFF;
|
||||||
@ -432,7 +427,7 @@ namespace Memory
|
|||||||
#if defined(a64)
|
#if defined(a64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
return (this->raw & 0x003FFFFF000) >> 12;
|
return 0;
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#endif
|
#endif
|
||||||
@ -446,6 +441,7 @@ namespace Memory
|
|||||||
|
|
||||||
union __packed PageMapLevel4
|
union __packed PageMapLevel4
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uintptr_t Present : 1; // 0
|
uintptr_t Present : 1; // 0
|
||||||
@ -461,6 +457,8 @@ namespace Memory
|
|||||||
uintptr_t Available2 : 11; // 52-62
|
uintptr_t Available2 : 11; // 52-62
|
||||||
uintptr_t ExecuteDisable : 1; // 63
|
uintptr_t ExecuteDisable : 1; // 63
|
||||||
};
|
};
|
||||||
|
#elif defined(aa64)
|
||||||
|
#endif
|
||||||
uintptr_t raw;
|
uintptr_t raw;
|
||||||
|
|
||||||
/** @brief Set PageDirectoryPointerTableEntryPtr address */
|
/** @brief Set PageDirectoryPointerTableEntryPtr address */
|
||||||
@ -470,10 +468,6 @@ namespace Memory
|
|||||||
_Address &= 0x000000FFFFFFFFFF;
|
_Address &= 0x000000FFFFFFFFFF;
|
||||||
this->raw &= 0xFFF0000000000FFF;
|
this->raw &= 0xFFF0000000000FFF;
|
||||||
this->raw |= (_Address << 12);
|
this->raw |= (_Address << 12);
|
||||||
#elif defined(a32)
|
|
||||||
_Address &= 0x000FFFFF;
|
|
||||||
this->raw &= 0xFFC00003;
|
|
||||||
this->raw |= (_Address << 12);
|
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
_Address &= 0x000000FFFFFFFFFF;
|
_Address &= 0x000000FFFFFFFFFF;
|
||||||
this->raw &= 0xFFF0000000000FFF;
|
this->raw &= 0xFFF0000000000FFF;
|
||||||
@ -487,7 +481,7 @@ namespace Memory
|
|||||||
#if defined(a64)
|
#if defined(a64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
return (this->raw & 0x003FFFFF000) >> 12;
|
return 0;
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#endif
|
#endif
|
||||||
@ -501,6 +495,7 @@ namespace Memory
|
|||||||
|
|
||||||
union __packed PageMapLevel5
|
union __packed PageMapLevel5
|
||||||
{
|
{
|
||||||
|
#if defined(a64)
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uintptr_t Present : 1; // 0
|
uintptr_t Present : 1; // 0
|
||||||
@ -516,6 +511,8 @@ namespace Memory
|
|||||||
uintptr_t Available2 : 11; // 52-62
|
uintptr_t Available2 : 11; // 52-62
|
||||||
uintptr_t ExecuteDisable : 1; // 63
|
uintptr_t ExecuteDisable : 1; // 63
|
||||||
};
|
};
|
||||||
|
#elif defined(aa64)
|
||||||
|
#endif
|
||||||
uintptr_t raw;
|
uintptr_t raw;
|
||||||
|
|
||||||
/** @brief Set PageMapLevel4Ptr address */
|
/** @brief Set PageMapLevel4Ptr address */
|
||||||
@ -525,10 +522,6 @@ namespace Memory
|
|||||||
_Address &= 0x000000FFFFFFFFFF;
|
_Address &= 0x000000FFFFFFFFFF;
|
||||||
this->raw &= 0xFFF0000000000FFF;
|
this->raw &= 0xFFF0000000000FFF;
|
||||||
this->raw |= (_Address << 12);
|
this->raw |= (_Address << 12);
|
||||||
#elif defined(a32)
|
|
||||||
_Address &= 0x000FFFFF;
|
|
||||||
this->raw &= 0xFFC00003;
|
|
||||||
this->raw |= (_Address << 12);
|
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
_Address &= 0x000000FFFFFFFFFF;
|
_Address &= 0x000000FFFFFFFFFF;
|
||||||
this->raw &= 0xFFF0000000000FFF;
|
this->raw &= 0xFFF0000000000FFF;
|
||||||
@ -542,7 +535,7 @@ namespace Memory
|
|||||||
#if defined(a64)
|
#if defined(a64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
return (this->raw & 0x003FFFFF000) >> 12;
|
return 0;
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,7 +80,7 @@ namespace NetworkARP
|
|||||||
DiscoveredAddress *ManageDiscoveredAddresses(DAType Type, InternetProtocol IP, MediaAccessControl MAC);
|
DiscoveredAddress *ManageDiscoveredAddresses(DAType Type, InternetProtocol IP, MediaAccessControl MAC);
|
||||||
DiscoveredAddress *Search(InternetProtocol TargetIP);
|
DiscoveredAddress *Search(InternetProtocol TargetIP);
|
||||||
DiscoveredAddress *Update(InternetProtocol TargetIP, MediaAccessControl TargetMAC);
|
DiscoveredAddress *Update(InternetProtocol TargetIP, MediaAccessControl TargetMAC);
|
||||||
bool OnEthernetPacketReceived(uint8_t *Data, uint64_t Length);
|
bool OnEthernetPacketReceived(uint8_t *Data, size_t Length);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ARP(NetworkEthernet::Ethernet *Ethernet);
|
ARP(NetworkEthernet::Ethernet *Ethernet);
|
||||||
|
@ -160,7 +160,7 @@ namespace NetworkDHCP
|
|||||||
|
|
||||||
void CreatePacket(DHCPHeader *Packet, uint8_t MessageType, uint32_t RequestIP);
|
void CreatePacket(DHCPHeader *Packet, uint8_t MessageType, uint32_t RequestIP);
|
||||||
void *GetOption(DHCPHeader *Packet, uint8_t Type);
|
void *GetOption(DHCPHeader *Packet, uint8_t Type);
|
||||||
void OnUDPPacketReceived(NetworkUDP::Socket *Socket, uint8_t *Data, uint64_t Length);
|
void OnUDPPacketReceived(NetworkUDP::Socket *Socket, uint8_t *Data, size_t Length);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** @brief IP address (Little-endian) */
|
/** @brief IP address (Little-endian) */
|
||||||
|
@ -61,7 +61,7 @@ namespace NetworkEthernet
|
|||||||
netdbg("Event not handled. [%p]", Packet);
|
netdbg("Event not handled. [%p]", Packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool OnEthernetPacketReceived(uint8_t *Data, uint64_t Length)
|
virtual bool OnEthernetPacketReceived(uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(Data);
|
UNUSED(Data);
|
||||||
UNUSED(Length);
|
UNUSED(Length);
|
||||||
@ -74,8 +74,8 @@ namespace NetworkEthernet
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
NetworkInterfaceManager::DeviceInterface *Interface;
|
NetworkInterfaceManager::DeviceInterface *Interface;
|
||||||
void Receive(uint8_t *Data, uint64_t Length);
|
void Receive(uint8_t *Data, size_t Length);
|
||||||
void OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, uint64_t Length);
|
void OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, size_t Length);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** @brief Get driver interface
|
/** @brief Get driver interface
|
||||||
@ -101,7 +101,7 @@ namespace NetworkEthernet
|
|||||||
* @param Data The data to send.
|
* @param Data The data to send.
|
||||||
* @param Length The length of the data.
|
* @param Length The length of the data.
|
||||||
*/
|
*/
|
||||||
void Send(MediaAccessControl MAC, FrameType Type, uint8_t *Data, uint64_t Length);
|
void Send(MediaAccessControl MAC, FrameType Type, uint8_t *Data, size_t Length);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace NetworkICMPv6
|
|||||||
|
|
||||||
ICMPv6(NetworkInterfaceManager::DeviceInterface *Interface);
|
ICMPv6(NetworkInterfaceManager::DeviceInterface *Interface);
|
||||||
~ICMPv6();
|
~ICMPv6();
|
||||||
void Send(uint8_t *Data, uint64_t Length);
|
void Send(uint8_t *Data, size_t Length);
|
||||||
void Receive(uint8_t *Data);
|
void Receive(uint8_t *Data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ namespace NetworkIPv4
|
|||||||
NetworkARP::ARP *ARP;
|
NetworkARP::ARP *ARP;
|
||||||
NetworkEthernet::Ethernet *Ethernet;
|
NetworkEthernet::Ethernet *Ethernet;
|
||||||
|
|
||||||
virtual bool OnEthernetPacketReceived(uint8_t *Data, uint64_t Length);
|
virtual bool OnEthernetPacketReceived(uint8_t *Data, size_t Length);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InternetProtocol GatewayIP;
|
InternetProtocol GatewayIP;
|
||||||
@ -107,7 +107,7 @@ namespace NetworkIPv4
|
|||||||
* @param Protocol The protocol of the packet.
|
* @param Protocol The protocol of the packet.
|
||||||
* @param DestinationIP The IP address of the destination. (Big-endian)
|
* @param DestinationIP The IP address of the destination. (Big-endian)
|
||||||
*/
|
*/
|
||||||
void Send(uint8_t *Data, uint64_t Length, uint8_t Protocol, InternetProtocol DestinationIP);
|
void Send(uint8_t *Data, size_t Length, uint8_t Protocol, InternetProtocol DestinationIP);
|
||||||
};
|
};
|
||||||
|
|
||||||
class IPv4Events
|
class IPv4Events
|
||||||
@ -122,7 +122,7 @@ namespace NetworkIPv4
|
|||||||
public:
|
public:
|
||||||
uint8_t GetProtocol() { return Protocol; }
|
uint8_t GetProtocol() { return Protocol; }
|
||||||
|
|
||||||
virtual bool OnIPv4PacketReceived(InternetProtocol SourceIP, InternetProtocol DestinationIP, uint8_t *Data, uint64_t Length)
|
virtual bool OnIPv4PacketReceived(InternetProtocol SourceIP, InternetProtocol DestinationIP, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(SourceIP);
|
UNUSED(SourceIP);
|
||||||
UNUSED(DestinationIP);
|
UNUSED(DestinationIP);
|
||||||
|
@ -70,7 +70,7 @@ namespace NetworkInterfaceManager
|
|||||||
netdbg("Event for %s not handled.", Interface->Name);
|
netdbg("Event for %s not handled.", Interface->Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnInterfaceReceived(DeviceInterface *Interface, uint8_t *Data, uint64_t Length)
|
virtual void OnInterfaceReceived(DeviceInterface *Interface, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(Interface);
|
UNUSED(Interface);
|
||||||
UNUSED(Data);
|
UNUSED(Data);
|
||||||
@ -78,7 +78,7 @@ namespace NetworkInterfaceManager
|
|||||||
netdbg("Event for %s not handled.", Interface->Name);
|
netdbg("Event for %s not handled.", Interface->Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnInterfaceSent(DeviceInterface *Interface, uint8_t *Data, uint64_t Length)
|
virtual void OnInterfaceSent(DeviceInterface *Interface, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(Interface);
|
UNUSED(Interface);
|
||||||
UNUSED(Data);
|
UNUSED(Data);
|
||||||
@ -104,8 +104,8 @@ namespace NetworkInterfaceManager
|
|||||||
|
|
||||||
void StartService();
|
void StartService();
|
||||||
|
|
||||||
void Send(DeviceInterface *Interface, uint8_t *Data, uint64_t Length);
|
void Send(DeviceInterface *Interface, uint8_t *Data, size_t Length);
|
||||||
void Receive(DeviceInterface *Interface, uint8_t *Data, uint64_t Length);
|
void Receive(DeviceInterface *Interface, uint8_t *Data, size_t Length);
|
||||||
|
|
||||||
void DrvSend(unsigned int DriverID, unsigned char *Data, unsigned short Size);
|
void DrvSend(unsigned int DriverID, unsigned char *Data, unsigned short Size);
|
||||||
void DrvReceive(unsigned int DriverID, unsigned char *Data, unsigned short Size);
|
void DrvReceive(unsigned int DriverID, unsigned char *Data, unsigned short Size);
|
||||||
|
@ -227,6 +227,6 @@ struct InternetProtocol
|
|||||||
} v6;
|
} v6;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint16_t CalculateChecksum(uint16_t *Data, uint64_t Length);
|
uint16_t CalculateChecksum(uint16_t *Data, size_t Length);
|
||||||
|
|
||||||
#endif // !__FENNIX_KERNEL_NETWORK_H__
|
#endif // !__FENNIX_KERNEL_NETWORK_H__
|
||||||
|
@ -148,7 +148,7 @@ namespace NetworkNTP
|
|||||||
bool TimeReceived = false;
|
bool TimeReceived = false;
|
||||||
NTPHeader NTPPacket;
|
NTPHeader NTPPacket;
|
||||||
|
|
||||||
virtual void OnUDPPacketReceived(NetworkUDP::Socket *Socket, uint8_t *Data, uint64_t Length);
|
virtual void OnUDPPacketReceived(NetworkUDP::Socket *Socket, uint8_t *Data, size_t Length);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NTP(NetworkUDP::Socket *Socket);
|
NTP(NetworkUDP::Socket *Socket);
|
||||||
|
@ -48,7 +48,7 @@ namespace NetworkUDP
|
|||||||
~UDPEvents();
|
~UDPEvents();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void OnUDPPacketReceived(Socket *Socket, uint8_t *Data, uint64_t Length)
|
virtual void OnUDPPacketReceived(Socket *Socket, uint8_t *Data, size_t Length)
|
||||||
{
|
{
|
||||||
UNUSED(Socket);
|
UNUSED(Socket);
|
||||||
UNUSED(Data);
|
UNUSED(Data);
|
||||||
@ -72,10 +72,10 @@ namespace NetworkUDP
|
|||||||
virtual Socket *Connect(InternetProtocol IP, uint16_t Port);
|
virtual Socket *Connect(InternetProtocol IP, uint16_t Port);
|
||||||
virtual Socket *Listen(uint16_t Port);
|
virtual Socket *Listen(uint16_t Port);
|
||||||
virtual void Disconnect(Socket *Socket);
|
virtual void Disconnect(Socket *Socket);
|
||||||
virtual void Send(Socket *Socket, uint8_t *Data, uint64_t Length);
|
virtual void Send(Socket *Socket, uint8_t *Data, size_t Length);
|
||||||
virtual void Bind(Socket *Socket, UDPEvents *EventHandler);
|
virtual void Bind(Socket *Socket, UDPEvents *EventHandler);
|
||||||
|
|
||||||
virtual bool OnIPv4PacketReceived(InternetProtocol SourceIP, InternetProtocol DestinationIP, uint8_t *Data, uint64_t Length);
|
virtual bool OnIPv4PacketReceived(InternetProtocol SourceIP, InternetProtocol DestinationIP, uint8_t *Data, size_t Length);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Socket
|
class Socket
|
||||||
|
@ -226,9 +226,9 @@ namespace PCI
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<PCIDeviceHeader *> &GetDevices() { return Devices; }
|
std::vector<PCIDeviceHeader *> &GetDevices() { return Devices; }
|
||||||
void EnumerateFunction(uintptr_t DeviceAddress, uint64_t Function);
|
void EnumerateFunction(uintptr_t DeviceAddress, uintptr_t Function);
|
||||||
void EnumerateDevice(uintptr_t BusAddress, uint64_t Device);
|
void EnumerateDevice(uintptr_t BusAddress, uintptr_t Device);
|
||||||
void EnumerateBus(uintptr_t BaseAddress, uint64_t Bus);
|
void EnumerateBus(uintptr_t BaseAddress, uintptr_t Bus);
|
||||||
std::vector<PCIDeviceHeader *> FindPCIDevice(uint8_t Class, uint8_t Subclass, uint8_t ProgIF);
|
std::vector<PCIDeviceHeader *> FindPCIDevice(uint8_t Class, uint8_t Subclass, uint8_t ProgIF);
|
||||||
std::vector<PCIDeviceHeader *> FindPCIDevice(int VendorID, int DeviceID);
|
std::vector<PCIDeviceHeader *> FindPCIDevice(int VendorID, int DeviceID);
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ struct CPUArchData
|
|||||||
CPU::x64::FXState *FPU;
|
CPU::x64::FXState *FPU;
|
||||||
/* TODO */
|
/* TODO */
|
||||||
#elif defined(a32)
|
#elif defined(a32)
|
||||||
|
CPU::x32::FXState *FPU;
|
||||||
|
/* TODO */
|
||||||
#elif defined(aa64)
|
#elif defined(aa64)
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace SymbolResolver
|
|||||||
void *Image;
|
void *Image;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
size_t GetTotalEntries() { return this->TotalEntries; }
|
int64_t GetTotalEntries() { return this->TotalEntries; }
|
||||||
void *GetImage() { return this->Image; }
|
void *GetImage() { return this->Image; }
|
||||||
const char *GetSymbolFromAddress(uintptr_t Address);
|
const char *GetSymbolFromAddress(uintptr_t Address);
|
||||||
void AddSymbol(uintptr_t Address, const char *Name);
|
void AddSymbol(uintptr_t Address, const char *Name);
|
||||||
|
@ -52,15 +52,15 @@ namespace Time
|
|||||||
private:
|
private:
|
||||||
struct HPET
|
struct HPET
|
||||||
{
|
{
|
||||||
uint64_t GeneralCapabilities;
|
uintptr_t GeneralCapabilities;
|
||||||
uint64_t Reserved0;
|
uintptr_t Reserved0;
|
||||||
uint64_t GeneralConfiguration;
|
uintptr_t GeneralConfiguration;
|
||||||
uint64_t Reserved1;
|
uintptr_t Reserved1;
|
||||||
uint64_t GeneralIntStatus;
|
uintptr_t GeneralIntStatus;
|
||||||
uint64_t Reserved2;
|
uintptr_t Reserved2;
|
||||||
uint64_t Reserved3[24];
|
uintptr_t Reserved3[24];
|
||||||
uint64_t MainCounterValue;
|
uintptr_t MainCounterValue;
|
||||||
uint64_t Reserved4;
|
uintptr_t Reserved4;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t clk = 0;
|
uint32_t clk = 0;
|
||||||
|
@ -353,7 +353,7 @@ namespace std
|
|||||||
if (Pos >= this->Length)
|
if (Pos >= this->Length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((int64_t)Count < 0)
|
if ((int64_t)Count <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Pos + Count > this->Length)
|
if (Pos + Count > this->Length)
|
||||||
@ -377,7 +377,7 @@ namespace std
|
|||||||
if (Pos >= this->Length)
|
if (Pos >= this->Length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((int64_t)Count < 0)
|
if ((int64_t)Count <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Pos + Count > this->Length)
|
if (Pos + Count > this->Length)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user