mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-25 22:14:37 +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);
|
||||
uint8_t *S5Address = (uint8_t *)(Address) + 36;
|
||||
ACPI::ACPI::ACPIHeader *Header = (ACPI::ACPI::ACPIHeader *)Address;
|
||||
uint64_t Length = Header->Length;
|
||||
size_t Length = Header->Length;
|
||||
while (Length-- > 0)
|
||||
{
|
||||
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 */
|
||||
#define arith64_u64 unsigned long long int
|
||||
#define arith64_s64 signed long long int
|
||||
@ -6,28 +10,28 @@
|
||||
|
||||
typedef union
|
||||
{
|
||||
arith64_u64 u64;
|
||||
arith64_s64 s64;
|
||||
struct
|
||||
{
|
||||
arith64_u64 u64;
|
||||
arith64_s64 s64;
|
||||
struct
|
||||
{
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
arith64_u32 hi;
|
||||
arith64_u32 lo;
|
||||
arith64_u32 hi;
|
||||
arith64_u32 lo;
|
||||
#else
|
||||
arith64_u32 lo;
|
||||
arith64_u32 hi;
|
||||
arith64_u32 lo;
|
||||
arith64_u32 hi;
|
||||
#endif
|
||||
} u32;
|
||||
struct
|
||||
{
|
||||
} u32;
|
||||
struct
|
||||
{
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
arith64_s32 hi;
|
||||
arith64_s32 lo;
|
||||
arith64_s32 hi;
|
||||
arith64_s32 lo;
|
||||
#else
|
||||
arith64_s32 lo;
|
||||
arith64_s32 hi;
|
||||
arith64_s32 lo;
|
||||
arith64_s32 hi;
|
||||
#endif
|
||||
} s32;
|
||||
} s32;
|
||||
} arith64_word;
|
||||
|
||||
#define arith64_hi(n) (arith64_word){.u64 = n}.u32.hi
|
||||
@ -37,234 +41,234 @@ typedef union
|
||||
|
||||
arith64_s64 __absvdi2(arith64_s64 a)
|
||||
{
|
||||
return arith64_abs(a);
|
||||
return arith64_abs(a);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
w.u32.hi = w.u32.lo << (b - 32);
|
||||
w.u32.lo = 0;
|
||||
}
|
||||
else if (b)
|
||||
{
|
||||
w.u32.hi = (w.u32.lo >> (32 - b)) | (w.u32.hi << b);
|
||||
w.u32.lo <<= b;
|
||||
}
|
||||
return w.s64;
|
||||
if (b >= 32)
|
||||
{
|
||||
w.u32.hi = w.u32.lo << (b - 32);
|
||||
w.u32.lo = 0;
|
||||
}
|
||||
else if (b)
|
||||
{
|
||||
w.u32.hi = (w.u32.lo >> (32 - b)) | (w.u32.hi << b);
|
||||
w.u32.lo <<= b;
|
||||
}
|
||||
return w.s64;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
w.s32.lo = w.s32.hi >> (b - 32);
|
||||
w.s32.hi >>= 31; // 0xFFFFFFFF or 0
|
||||
}
|
||||
else if (b)
|
||||
{
|
||||
w.u32.lo = (w.u32.hi << (32 - b)) | (w.u32.lo >> b);
|
||||
w.s32.hi >>= b;
|
||||
}
|
||||
return w.s64;
|
||||
if (b >= 32)
|
||||
{
|
||||
w.s32.lo = w.s32.hi >> (b - 32);
|
||||
w.s32.hi >>= 31; // 0xFFFFFFFF or 0
|
||||
}
|
||||
else if (b)
|
||||
{
|
||||
w.u32.lo = (w.u32.hi << (32 - b)) | (w.u32.lo >> b);
|
||||
w.s32.hi >>= b;
|
||||
}
|
||||
return w.s64;
|
||||
}
|
||||
|
||||
int __clzsi2(arith64_u32 a)
|
||||
{
|
||||
int b, n = 0;
|
||||
b = !(a & 0xffff0000) << 4;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xff000000) << 3;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xf0000000) << 2;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xc0000000) << 1;
|
||||
n += b;
|
||||
a <<= b;
|
||||
return n + !(a & 0x80000000);
|
||||
int b, n = 0;
|
||||
b = !(a & 0xffff0000) << 4;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xff000000) << 3;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xf0000000) << 2;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xc0000000) << 1;
|
||||
n += b;
|
||||
a <<= b;
|
||||
return n + !(a & 0x80000000);
|
||||
}
|
||||
|
||||
int __clzdi2(arith64_u64 a)
|
||||
{
|
||||
int b, n = 0;
|
||||
b = !(a & 0xffffffff00000000ULL) << 5;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xffff000000000000ULL) << 4;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xff00000000000000ULL) << 3;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xf000000000000000ULL) << 2;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xc000000000000000ULL) << 1;
|
||||
n += b;
|
||||
a <<= b;
|
||||
return n + !(a & 0x8000000000000000ULL);
|
||||
int b, n = 0;
|
||||
b = !(a & 0xffffffff00000000ULL) << 5;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xffff000000000000ULL) << 4;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xff00000000000000ULL) << 3;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xf000000000000000ULL) << 2;
|
||||
n += b;
|
||||
a <<= b;
|
||||
b = !(a & 0xc000000000000000ULL) << 1;
|
||||
n += b;
|
||||
a <<= b;
|
||||
return n + !(a & 0x8000000000000000ULL);
|
||||
}
|
||||
|
||||
int __ctzsi2(arith64_u32 a)
|
||||
{
|
||||
int b, n = 0;
|
||||
b = !(a & 0x0000ffff) << 4;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x000000ff) << 3;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x0000000f) << 2;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x00000003) << 1;
|
||||
n += b;
|
||||
a >>= b;
|
||||
return n + !(a & 0x00000001);
|
||||
int b, n = 0;
|
||||
b = !(a & 0x0000ffff) << 4;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x000000ff) << 3;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x0000000f) << 2;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x00000003) << 1;
|
||||
n += b;
|
||||
a >>= b;
|
||||
return n + !(a & 0x00000001);
|
||||
}
|
||||
|
||||
int __ctzdi2(arith64_u64 a)
|
||||
{
|
||||
int b, n = 0;
|
||||
b = !(a & 0x00000000ffffffffULL) << 5;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x000000000000ffffULL) << 4;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x00000000000000ffULL) << 3;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x000000000000000fULL) << 2;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x0000000000000003ULL) << 1;
|
||||
n += b;
|
||||
a >>= b;
|
||||
return n + !(a & 0x0000000000000001ULL);
|
||||
int b, n = 0;
|
||||
b = !(a & 0x00000000ffffffffULL) << 5;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x000000000000ffffULL) << 4;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x00000000000000ffULL) << 3;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x000000000000000fULL) << 2;
|
||||
n += b;
|
||||
a >>= b;
|
||||
b = !(a & 0x0000000000000003ULL) << 1;
|
||||
n += b;
|
||||
a >>= b;
|
||||
return n + !(a & 0x0000000000000001ULL);
|
||||
}
|
||||
|
||||
arith64_u64 __divmoddi4(arith64_u64 a, arith64_u64 b, arith64_u64 *c)
|
||||
{
|
||||
if (b > a)
|
||||
{
|
||||
if (c)
|
||||
*c = a;
|
||||
return 0;
|
||||
}
|
||||
if (!arith64_hi(b))
|
||||
{
|
||||
if (b == 0)
|
||||
{
|
||||
volatile char x = 0;
|
||||
x = 1 / x;
|
||||
}
|
||||
if (b == 1)
|
||||
{
|
||||
if (c)
|
||||
*c = 0;
|
||||
return a;
|
||||
}
|
||||
if (!arith64_hi(a))
|
||||
{
|
||||
if (c)
|
||||
*c = arith64_lo(a) % arith64_lo(b);
|
||||
return arith64_lo(a) / arith64_lo(b);
|
||||
}
|
||||
}
|
||||
if (b > a)
|
||||
{
|
||||
if (c)
|
||||
*c = a;
|
||||
return 0;
|
||||
}
|
||||
if (!arith64_hi(b))
|
||||
{
|
||||
if (b == 0)
|
||||
{
|
||||
volatile char x = 0;
|
||||
x = 1 / x;
|
||||
}
|
||||
if (b == 1)
|
||||
{
|
||||
if (c)
|
||||
*c = 0;
|
||||
return a;
|
||||
}
|
||||
if (!arith64_hi(a))
|
||||
{
|
||||
if (c)
|
||||
*c = arith64_lo(a) % arith64_lo(b);
|
||||
return arith64_lo(a) / arith64_lo(b);
|
||||
}
|
||||
}
|
||||
|
||||
char bits = __clzdi2(b) - __clzdi2(a) + 1;
|
||||
arith64_u64 rem = a >> bits;
|
||||
a <<= 64 - bits;
|
||||
arith64_u64 wrap = 0;
|
||||
while (bits-- > 0)
|
||||
{
|
||||
rem = (rem << 1) | (a >> 63);
|
||||
a = (a << 1) | (wrap & 1);
|
||||
wrap = ((arith64_s64)(b - rem - 1) >> 63);
|
||||
rem -= b & wrap;
|
||||
}
|
||||
if (c)
|
||||
*c = rem;
|
||||
return (a << 1) | (wrap & 1);
|
||||
char bits = __clzdi2(b) - __clzdi2(a) + 1;
|
||||
arith64_u64 rem = a >> bits;
|
||||
a <<= 64 - bits;
|
||||
arith64_u64 wrap = 0;
|
||||
while (bits-- > 0)
|
||||
{
|
||||
rem = (rem << 1) | (a >> 63);
|
||||
a = (a << 1) | (wrap & 1);
|
||||
wrap = ((arith64_s64)(b - rem - 1) >> 63);
|
||||
rem -= b & wrap;
|
||||
}
|
||||
if (c)
|
||||
*c = rem;
|
||||
return (a << 1) | (wrap & 1);
|
||||
}
|
||||
|
||||
arith64_s64 __divdi3(arith64_s64 a, arith64_s64 b)
|
||||
{
|
||||
arith64_u64 q = __divmoddi4(arith64_abs(a), arith64_abs(b), (void *)0);
|
||||
return arith64_neg(q, a ^ b);
|
||||
arith64_u64 q = __divmoddi4(arith64_abs(a), arith64_abs(b), (void *)0);
|
||||
return arith64_neg(q, a ^ b);
|
||||
}
|
||||
|
||||
int __ffsdi2(arith64_u64 a) { return a ? __ctzdi2(a) + 1 : 0; }
|
||||
|
||||
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)
|
||||
{
|
||||
w.u32.lo = w.u32.hi >> (b - 32);
|
||||
w.u32.hi = 0;
|
||||
}
|
||||
else if (b)
|
||||
{
|
||||
w.u32.lo = (w.u32.hi << (32 - b)) | (w.u32.lo >> b);
|
||||
w.u32.hi >>= b;
|
||||
}
|
||||
return w.u64;
|
||||
if (b >= 32)
|
||||
{
|
||||
w.u32.lo = w.u32.hi >> (b - 32);
|
||||
w.u32.hi = 0;
|
||||
}
|
||||
else if (b)
|
||||
{
|
||||
w.u32.lo = (w.u32.hi << (32 - b)) | (w.u32.lo >> b);
|
||||
w.u32.hi >>= b;
|
||||
}
|
||||
return w.u64;
|
||||
}
|
||||
|
||||
arith64_s64 __moddi3(arith64_s64 a, arith64_s64 b)
|
||||
{
|
||||
arith64_u64 r;
|
||||
__divmoddi4(arith64_abs(a), arith64_abs(b), &r);
|
||||
return arith64_neg(r, a);
|
||||
arith64_u64 r;
|
||||
__divmoddi4(arith64_abs(a), arith64_abs(b), &r);
|
||||
return arith64_neg(r, a);
|
||||
}
|
||||
|
||||
int __popcountsi2(arith64_u32 a)
|
||||
{
|
||||
|
||||
a = a - ((a >> 1) & 0x55555555);
|
||||
a = ((a >> 2) & 0x33333333) + (a & 0x33333333);
|
||||
a = (a + (a >> 4)) & 0x0F0F0F0F;
|
||||
a = (a + (a >> 16));
|
||||
a = a - ((a >> 1) & 0x55555555);
|
||||
a = ((a >> 2) & 0x33333333) + (a & 0x33333333);
|
||||
a = (a + (a >> 4)) & 0x0F0F0F0F;
|
||||
a = (a + (a >> 16));
|
||||
|
||||
return (a + (a >> 8)) & 63;
|
||||
return (a + (a >> 8)) & 63;
|
||||
}
|
||||
|
||||
int __popcountdi2(arith64_u64 a)
|
||||
{
|
||||
|
||||
a = a - ((a >> 1) & 0x5555555555555555ULL);
|
||||
a = ((a >> 2) & 0x3333333333333333ULL) + (a & 0x3333333333333333ULL);
|
||||
a = (a + (a >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
|
||||
a = (a + (a >> 32));
|
||||
a = (a + (a >> 16));
|
||||
a = a - ((a >> 1) & 0x5555555555555555ULL);
|
||||
a = ((a >> 2) & 0x3333333333333333ULL) + (a & 0x3333333333333333ULL);
|
||||
a = (a + (a >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
|
||||
a = (a + (a >> 32));
|
||||
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 __umoddi3(arith64_u64 a, arith64_u64 b)
|
||||
{
|
||||
arith64_u64 r;
|
||||
__divmoddi4(a, b, &r);
|
||||
return r;
|
||||
arith64_u64 r;
|
||||
__divmoddi4(a, b, &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 */
|
||||
@ -291,37 +295,83 @@ typedef unsigned long long uint64_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef struct
|
||||
{
|
||||
uint64_t value;
|
||||
uint64_t value;
|
||||
} atomic_uint64_t;
|
||||
|
||||
uint64_t __atomic_load_8(const atomic_uint64_t *p)
|
||||
{
|
||||
uint64_t value;
|
||||
__asm__ volatile("lock cmpxchg8b %1"
|
||||
: "=A"(value)
|
||||
: "m"(*p)
|
||||
: "memory");
|
||||
return value;
|
||||
uint64_t value;
|
||||
__asm__ volatile("lock cmpxchg8b %1"
|
||||
: "=A"(value)
|
||||
: "m"(*p)
|
||||
: "memory");
|
||||
return value;
|
||||
}
|
||||
|
||||
void __atomic_store_8(atomic_uint64_t *p, uint64_t value)
|
||||
{
|
||||
__asm__ volatile("lock cmpxchg8b %0"
|
||||
: "=m"(p->value)
|
||||
: "a"((uint32_t)value), "d"((uint32_t)(value >> 32)), "m"(*p)
|
||||
: "memory");
|
||||
__asm__ volatile("lock cmpxchg8b %0"
|
||||
: "=m"(p->value)
|
||||
: "a"((uint32_t)value), "d"((uint32_t)(value >> 32)), "m"(*p)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
/* FIXME: __fixsfsi is not implemented correctly(?) */
|
||||
int __fixsfsi(float a) { return (int)a; }
|
||||
int __fixsfsi(float a)
|
||||
{
|
||||
return (int)a;
|
||||
}
|
||||
|
||||
int __ltsf2(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; }
|
||||
int __ltsf2(float a, float b)
|
||||
{
|
||||
return -(a < b);
|
||||
}
|
||||
|
||||
int __nesf2(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;
|
||||
}
|
||||
multiboot_mmap_entry entry = mmap->entries[i];
|
||||
mb2binfo.Memory.Size += entry.len;
|
||||
mb2binfo.Memory.Size += (size_t)entry.len;
|
||||
switch (entry.type)
|
||||
{
|
||||
case MULTIBOOT_MEMORY_AVAILABLE:
|
||||
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;
|
||||
break;
|
||||
case MULTIBOOT_MEMORY_RESERVED:
|
||||
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;
|
||||
break;
|
||||
case MULTIBOOT_MEMORY_ACPI_RECLAIMABLE:
|
||||
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;
|
||||
break;
|
||||
case MULTIBOOT_MEMORY_NVS:
|
||||
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;
|
||||
break;
|
||||
case MULTIBOOT_MEMORY_BADRAM:
|
||||
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;
|
||||
break;
|
||||
default:
|
||||
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;
|
||||
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;
|
||||
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.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);
|
||||
break;
|
||||
}
|
||||
|
@ -68,13 +68,13 @@ namespace PIC
|
||||
if (IRQ < 8)
|
||||
{
|
||||
Port = MasterDataPort;
|
||||
Value = MasterMask & ~(1 << IRQ);
|
||||
Value = (uint8_t)(MasterMask & ~(1 << IRQ));
|
||||
MasterMask = Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Port = SlaveDataPort;
|
||||
Value = SlaveMask & ~(1 << (IRQ - 8));
|
||||
Value = (uint8_t)(SlaveMask & ~(1 << (IRQ - 8)));
|
||||
SlaveMask = Value;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ namespace PIC
|
||||
|
||||
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 High = (uint8_t)((Divisor >> 8) & 0xFF);
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace Memory
|
||||
{
|
||||
// 0x1000 aligned
|
||||
uintptr_t Address = (uintptr_t)VirtualAddress;
|
||||
Address &= 0xFFFFFFFFFFFFF000;
|
||||
Address &= 0xFFFFF000;
|
||||
|
||||
PageMapIndexer Index = PageMapIndexer(Address);
|
||||
PageDirectoryEntry PDE = this->Table->Entries[Index.PDEIndex];
|
||||
@ -51,7 +51,7 @@ namespace Memory
|
||||
{
|
||||
// 0x1000 aligned
|
||||
uintptr_t Address = (uintptr_t)VirtualAddress;
|
||||
Address &= 0xFFFFFFFFFFFFF000;
|
||||
Address &= 0xFFFFF000;
|
||||
|
||||
PageMapIndexer Index = PageMapIndexer(Address);
|
||||
PageDirectoryEntry PDE = this->Table->Entries[Index.PDEIndex];
|
||||
@ -90,7 +90,7 @@ namespace Memory
|
||||
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex];
|
||||
if (Type == MapType::FourMB)
|
||||
{
|
||||
PDE->raw |= Flags;
|
||||
PDE->raw |= (uintptr_t)Flags;
|
||||
PDE->PageSize = true;
|
||||
PDE->SetAddress((uintptr_t)PhysicalAddress >> 12);
|
||||
debug("Mapped 4MB page at %p to %p", VirtualAddress, PhysicalAddress);
|
||||
@ -107,11 +107,11 @@ namespace Memory
|
||||
}
|
||||
else
|
||||
PTEPtr = (PageTableEntryPtr *)(PDE->GetAddress() << 12);
|
||||
PDE->raw |= DirectoryFlags;
|
||||
PDE->raw |= (uintptr_t)DirectoryFlags;
|
||||
|
||||
PageTableEntry *PTE = &PTEPtr->Entries[Index.PTEIndex];
|
||||
PTE->Present = true;
|
||||
PTE->raw |= Flags;
|
||||
PTE->raw |= (uintptr_t)Flags;
|
||||
PTE->SetAddress((uintptr_t)PhysicalAddress >> 12);
|
||||
|
||||
#if defined(a64)
|
||||
|
@ -278,7 +278,7 @@ namespace ACPI
|
||||
uint8_t PM1_CNT_LEN = 0;
|
||||
|
||||
ACPI *acpi;
|
||||
void OnInterruptReceived(CPU::x64::TrapFrame *Frame);
|
||||
void OnInterruptReceived(CPU::x32::TrapFrame *Frame);
|
||||
|
||||
public:
|
||||
bool ACPIShutdownSupported = false;
|
||||
|
@ -41,7 +41,7 @@ std::atomic_bool CPUEnabled = false;
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
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()
|
||||
{
|
||||
|
107
Core/CPU.cpp
107
Core/CPU.cpp
@ -201,14 +201,14 @@ namespace CPU
|
||||
|
||||
void InitializeFeatures(long Core)
|
||||
{
|
||||
#if defined(a64)
|
||||
static int BSP = 0;
|
||||
bool PGESupport = false;
|
||||
bool SSESupport = false;
|
||||
#if defined(a64)
|
||||
bool UMIPSupport = false;
|
||||
bool SMEPSupport = false;
|
||||
bool SMAPSupport = false;
|
||||
|
||||
static int BSP = 0;
|
||||
x64::CR0 cr0 = x64::readcr0();
|
||||
x64::CR4 cr4 = x64::readcr4();
|
||||
|
||||
@ -335,6 +335,105 @@ namespace CPU
|
||||
if (SSEEnableAfter)
|
||||
SSEEnabled = true;
|
||||
#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)
|
||||
#endif
|
||||
}
|
||||
@ -358,10 +457,6 @@ namespace CPU
|
||||
|
||||
uint64_t CheckSIMD()
|
||||
{
|
||||
#if defined(a32)
|
||||
return SIMD_NONE; /* TODO: Support x86 SIMD on x32 */
|
||||
#endif
|
||||
|
||||
if (unlikely(!SSEEnabled))
|
||||
return SIMD_NONE;
|
||||
|
||||
|
@ -662,9 +662,9 @@ namespace CrashHandler
|
||||
else
|
||||
{
|
||||
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);
|
||||
EHDumpData((void *)Address, Length);
|
||||
EHDumpData((void *)Address, (unsigned long)Length);
|
||||
}
|
||||
}
|
||||
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");
|
||||
Display->SetBuffer(SBIdx);
|
||||
uint64_t Length = KernelAllocator.GetTotalMemory();
|
||||
uint64_t ProgressLength = Length;
|
||||
uint64_t TotalMemLength = KernelAllocator.GetTotalMemory();
|
||||
uint64_t ProgressLength = TotalMemLength;
|
||||
UniversalAsynchronousReceiverTransmitter::UART uart(port);
|
||||
Memory::Virtual vma;
|
||||
uint8_t *Address = reinterpret_cast<uint8_t *>(0x0);
|
||||
int Progress = 0;
|
||||
for (size_t i = 0; i < Length; i++)
|
||||
for (size_t i = 0; i < TotalMemLength; i++)
|
||||
{
|
||||
if (vma.Check(Address))
|
||||
uart.Write(*Address);
|
||||
|
@ -83,7 +83,7 @@ namespace CrashHandler
|
||||
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("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)
|
||||
#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.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",
|
||||
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.Reserved0, data.efer.Reserved1, data.efer.Reserved2);
|
||||
#endif // a64
|
||||
#endif
|
||||
|
||||
switch (data.Frame->InterruptNumber)
|
||||
|
@ -113,7 +113,7 @@ namespace Disk
|
||||
}
|
||||
partition.StartLBA = GPTPartition.FirstLBA;
|
||||
partition.EndLBA = GPTPartition.LastLBA;
|
||||
partition.Sectors = partition.EndLBA - partition.StartLBA;
|
||||
partition.Sectors = (size_t)(partition.EndLBA - partition.StartLBA);
|
||||
partition.Port = ItrPort;
|
||||
partition.Flags = Present;
|
||||
partition.Style = GPT;
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
debug("Searching for conflicting drivers...");
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -38,7 +38,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
|
||||
|
@ -37,7 +37,7 @@ namespace Driver
|
||||
|
||||
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)
|
||||
{
|
||||
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,
|
||||
(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);
|
||||
itrfb++;
|
||||
|
||||
|
@ -55,11 +55,11 @@ namespace Memory
|
||||
if (Offset > node->Length)
|
||||
return -1;
|
||||
node->Offset = Offset;
|
||||
NewOffset = node->Offset;
|
||||
NewOffset = (long)node->Offset;
|
||||
}
|
||||
else if (Whence == SEEK_CUR)
|
||||
{
|
||||
NewOffset = node->Offset + Offset;
|
||||
NewOffset = (long)(node->Offset + Offset);
|
||||
if ((size_t)NewOffset > node->Length || NewOffset < 0)
|
||||
return -1;
|
||||
node->Offset = NewOffset;
|
||||
|
@ -377,7 +377,7 @@ namespace Memory
|
||||
TotalMemory = 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;
|
||||
size_t BitmapAddressSize = 0;
|
||||
|
||||
|
@ -789,7 +789,7 @@ namespace PCI
|
||||
}
|
||||
#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 FunctionAddress = DeviceAddress + Offset;
|
||||
@ -805,7 +805,7 @@ namespace PCI
|
||||
#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 DeviceAddress = BusAddress + Offset;
|
||||
@ -819,7 +819,7 @@ namespace PCI
|
||||
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 BusAddress = BaseAddress + Offset;
|
||||
|
@ -127,7 +127,7 @@ namespace Random
|
||||
|
||||
if (RDRANDFlag)
|
||||
{
|
||||
uint64_t RDRANDValue = 0;
|
||||
uintptr_t RDRANDValue = 0;
|
||||
asmv("1: rdrand %0; jnc 1b"
|
||||
: "=r"(RDRANDValue));
|
||||
return RDRANDValue;
|
||||
|
@ -55,16 +55,26 @@ namespace SymbolResolver
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(a64)
|
||||
Elf64_Shdr *ElfSections = (Elf64_Shdr *)(Sections);
|
||||
Elf64_Sym *ElfSymbols = nullptr;
|
||||
#elif defined(a32)
|
||||
Elf32_Shdr *ElfSections = (Elf32_Shdr *)(Sections);
|
||||
Elf32_Sym *ElfSymbols = nullptr;
|
||||
#endif
|
||||
char *strtab = nullptr;
|
||||
|
||||
for (uint64_t i = 0; i < Num; i++)
|
||||
switch (ElfSections[i].sh_type)
|
||||
{
|
||||
case SHT_SYMTAB:
|
||||
#if defined(a64)
|
||||
ElfSymbols = (Elf64_Sym *)(Sections + ElfSections[i].sh_offset);
|
||||
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)
|
||||
this->TotalEntries = 0x10000 - 1;
|
||||
|
||||
@ -94,7 +104,11 @@ namespace SymbolResolver
|
||||
for (Index = i + 1; Index < this->TotalEntries; Index++)
|
||||
if (ElfSymbols[Index].st_value < ElfSymbols[MinimumIndex].st_value)
|
||||
MinimumIndex = Index;
|
||||
#if defined(a64)
|
||||
Elf64_Sym tmp = ElfSymbols[MinimumIndex];
|
||||
#elif defined(a32)
|
||||
Elf32_Sym tmp = ElfSymbols[MinimumIndex];
|
||||
#endif
|
||||
ElfSymbols[MinimumIndex] = ElfSymbols[i];
|
||||
ElfSymbols[i] = tmp;
|
||||
}
|
||||
@ -114,7 +128,7 @@ namespace SymbolResolver
|
||||
}
|
||||
|
||||
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].FunctionName = &strtab[ElfSymbols[i].st_name];
|
||||
@ -134,7 +148,11 @@ namespace SymbolResolver
|
||||
|
||||
this->Image = (void *)ImageAddress;
|
||||
debug("Solving symbols for address: %#llx", ImageAddress);
|
||||
#if defined(a64)
|
||||
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
|
||||
#elif defined(a32)
|
||||
Elf32_Ehdr *Header = (Elf32_Ehdr *)ImageAddress;
|
||||
#endif
|
||||
if (Header->e_ident[0] != 0x7F &&
|
||||
Header->e_ident[1] != 'E' &&
|
||||
Header->e_ident[2] != 'L' &&
|
||||
@ -143,16 +161,26 @@ namespace SymbolResolver
|
||||
error("Invalid ELF header");
|
||||
return;
|
||||
}
|
||||
#if defined(a64)
|
||||
Elf64_Shdr *ElfSections = (Elf64_Shdr *)(ImageAddress + Header->e_shoff);
|
||||
Elf64_Sym *ElfSymbols = nullptr;
|
||||
#elif defined(a32)
|
||||
Elf32_Shdr *ElfSections = (Elf32_Shdr *)(ImageAddress + Header->e_shoff);
|
||||
Elf32_Sym *ElfSymbols = nullptr;
|
||||
#endif
|
||||
char *strtab = nullptr;
|
||||
|
||||
for (uint16_t i = 0; i < Header->e_shnum; i++)
|
||||
switch (ElfSections[i].sh_type)
|
||||
{
|
||||
case SHT_SYMTAB:
|
||||
#if defined(a64)
|
||||
ElfSymbols = (Elf64_Sym *)(ImageAddress + ElfSections[i].sh_offset);
|
||||
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)
|
||||
this->TotalEntries = 0x10000 - 1;
|
||||
|
||||
@ -182,7 +210,11 @@ namespace SymbolResolver
|
||||
for (Index = i + 1; Index < this->TotalEntries; Index++)
|
||||
if (ElfSymbols[Index].st_value < ElfSymbols[MinimumIndex].st_value)
|
||||
MinimumIndex = Index;
|
||||
#if defined(a64)
|
||||
Elf64_Sym tmp = ElfSymbols[MinimumIndex];
|
||||
#elif defined(a32)
|
||||
Elf32_Sym tmp = ElfSymbols[MinimumIndex];
|
||||
#endif
|
||||
ElfSymbols[MinimumIndex] = ElfSymbols[i];
|
||||
ElfSymbols[i] = tmp;
|
||||
}
|
||||
@ -194,7 +226,7 @@ namespace SymbolResolver
|
||||
}
|
||||
|
||||
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].FunctionName = &strtab[ElfSymbols[i].st_name];
|
||||
|
@ -34,25 +34,35 @@ namespace Time
|
||||
{
|
||||
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;
|
||||
while (mminq(&((HPET *)hpet)->MainCounterValue) < Target)
|
||||
CPU::Pause();
|
||||
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
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t HighPrecisionEventTimer::GetCounter()
|
||||
{
|
||||
#if defined(a86)
|
||||
#if defined(a64)
|
||||
return mminq(&((HPET *)hpet)->MainCounterValue);
|
||||
#elif defined(a32)
|
||||
return mminl(&((HPET *)hpet)->MainCounterValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t HighPrecisionEventTimer::CalculateTarget(uint64_t Target, Units Unit)
|
||||
{
|
||||
#if defined(a86)
|
||||
#if defined(a64)
|
||||
return mminq(&((HPET *)hpet)->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||
#elif defined(a32)
|
||||
return mminl(&((HPET *)hpet)->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -75,10 +85,16 @@ namespace Time
|
||||
Memory::PTFlag::RW | Memory::PTFlag::PCD);
|
||||
this->hpet = (HPET *)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->MainCounterValue, 0);
|
||||
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();
|
||||
#endif
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace Video
|
||||
Font *Display::GetCurrentFont() { return CurrentFont; }
|
||||
void Display::SetCurrentFont(Font *Font) { CurrentFont = Font; }
|
||||
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)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ namespace Execute
|
||||
VirtualFileSystem::File &ExFile,
|
||||
Tasking::PCB *Process)
|
||||
{
|
||||
#if defined(a64)
|
||||
debug("Executable");
|
||||
ELFBaseLoad ELFBase = {};
|
||||
/* This should be deleted inside BaseLoad.cpp */
|
||||
@ -221,5 +222,8 @@ namespace Execute
|
||||
|
||||
ELFBase.Success = true;
|
||||
return ELFBase;
|
||||
#elif defined(a32)
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ namespace Execute
|
||||
|
||||
Elf64_Sym *ELFLookupSymbol(Elf64_Ehdr *Header, const char *Name)
|
||||
{
|
||||
#if defined(a64)
|
||||
Elf64_Shdr *SymbolTable = nullptr;
|
||||
Elf64_Shdr *StringTable = nullptr;
|
||||
Elf64_Sym *Symbol = nullptr;
|
||||
@ -84,11 +85,14 @@ namespace Execute
|
||||
if (strcmp(String, Name) == 0)
|
||||
return Symbol;
|
||||
}
|
||||
#elif defined(a32)
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uintptr_t ELFGetSymbolValue(Elf64_Ehdr *Header, uint64_t Table, uint64_t Index)
|
||||
{
|
||||
#if defined(a64)
|
||||
if (Table == SHN_UNDEF || Index == SHN_UNDEF)
|
||||
return 0;
|
||||
Elf64_Shdr *SymbolTable = GetELFSection(Header, Table);
|
||||
@ -129,10 +133,14 @@ namespace Execute
|
||||
Elf64_Shdr *Target = GetELFSection(Header, Symbol->st_shndx);
|
||||
return (uintptr_t)Header + Symbol->st_value + Target->sh_offset;
|
||||
}
|
||||
#elif defined(a32)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
Elf64_Dyn *ELFGetDynamicTag(void *ElfFile, enum DynamicArrayTags Tag)
|
||||
{
|
||||
#if defined(a64)
|
||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)ElfFile;
|
||||
|
||||
Elf64_Phdr ItrPhdr;
|
||||
@ -159,10 +167,14 @@ namespace Execute
|
||||
}
|
||||
debug("Dynamic tag %d not found.", Tag);
|
||||
return nullptr;
|
||||
#elif defined(a32)
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
MmImage ELFCreateMemoryImage(Memory::MemMgr *mem, Memory::Virtual &pV, void *ElfFile, size_t Length)
|
||||
{
|
||||
#if defined(a64)
|
||||
void *MemoryImage = nullptr;
|
||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)ElfFile;
|
||||
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));
|
||||
}
|
||||
return {MemoryImage, (void *)FirstProgramHeaderVirtualAddress};
|
||||
#elif defined(a32)
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
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. */
|
||||
VirtualFileSystem::File File = vfs->Open(Interpreter);
|
||||
|
||||
#if defined(a64)
|
||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)File.node->Address;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -306,5 +322,9 @@ namespace Execute
|
||||
debug("Interpreter entry point: %#lx (%#lx + %#lx)", (uintptr_t)MemoryImage.Physical + ELFHeader->e_entry,
|
||||
(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,
|
||||
Tasking::PCB *Process)
|
||||
{
|
||||
#if defined(a64)
|
||||
UNUSED(ExFile);
|
||||
debug("Relocatable");
|
||||
/* 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;
|
||||
#elif defined(a32)
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,9 @@ namespace Execute
|
||||
sl.MemoryImage = r_cst(uint64_t, ELFCreateMemoryImage(mem, ncpV, LibFile, Length).Physical);
|
||||
debug("MemoryImage: %#lx", sl.MemoryImage);
|
||||
|
||||
uintptr_t BaseAddress = UINTPTR_MAX;
|
||||
{
|
||||
uintptr_t BaseAddress = UINTPTR_MAX;
|
||||
#if defined(a64)
|
||||
Elf64_Phdr ItrProgramHeader;
|
||||
|
||||
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);
|
||||
debug("memcpy: %#lx => %#lx (%ld bytes)", (uint8_t *)LibFile + ItrProgramHeader.p_offset, (uintptr_t)MAddr, ItrProgramHeader.p_filesz);
|
||||
break;
|
||||
#elif defined(a32)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(a64)
|
||||
struct Elf64_Dyn *JmpRel = ELFGetDynamicTag((void *)LibFile, DT_JMPREL);
|
||||
struct Elf64_Dyn *SymTab = ELFGetDynamicTag((void *)LibFile, DT_SYMTAB);
|
||||
struct Elf64_Dyn *StrTab = ELFGetDynamicTag((void *)LibFile, DT_STRTAB);
|
||||
@ -230,6 +234,9 @@ namespace Execute
|
||||
|
||||
Libs.push_back(sl);
|
||||
return true;
|
||||
#elif defined(a32)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SearchLibrary(char *Identifier)
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
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))
|
||||
return;
|
||||
@ -31,7 +31,7 @@ namespace GraphicalUserInterface
|
||||
// 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))
|
||||
return;
|
||||
@ -42,7 +42,7 @@ namespace GraphicalUserInterface
|
||||
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))
|
||||
return 0;
|
||||
@ -59,8 +59,8 @@ namespace GraphicalUserInterface
|
||||
|
||||
Ofast void DrawOverBitmap(ScreenBitmap *DestinationBitmap,
|
||||
ScreenBitmap *SourceBitmap,
|
||||
long Top,
|
||||
long Left, bool IgnoreZero)
|
||||
int64_t Top,
|
||||
int64_t Left, bool IgnoreZero)
|
||||
{
|
||||
if (unlikely(!SourceBitmap) || unlikely(!SourceBitmap->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)),
|
||||
(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 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)
|
||||
{
|
||||
|
@ -152,8 +152,8 @@ namespace GraphicalUserInterface
|
||||
{
|
||||
if (MouseArray[1].Left)
|
||||
{
|
||||
wnd->GetPositionPtr()->Width += Mouse.X - MouseArray[0].X;
|
||||
wnd->GetPositionPtr()->Height += Mouse.Y - MouseArray[0].Y;
|
||||
wnd->GetPositionPtr()->Width += (size_t)(Mouse.X - MouseArray[0].X);
|
||||
wnd->GetPositionPtr()->Height += (size_t)(Mouse.Y - MouseArray[0].Y);
|
||||
|
||||
if (wnd->GetPositionPtr()->Width < 200)
|
||||
{
|
||||
@ -398,8 +398,8 @@ namespace GraphicalUserInterface
|
||||
TopBarTextPos.Top += 4;
|
||||
|
||||
// Title bar text
|
||||
long CharCursorX = TopBarTextPos.Left;
|
||||
long CharCursorY = TopBarTextPos.Top;
|
||||
int64_t CharCursorX = TopBarTextPos.Left;
|
||||
int64_t CharCursorY = TopBarTextPos.Top;
|
||||
for (uint64_t i = 0; i < strlen(wnd->GetTitle()); i++)
|
||||
PaintChar(this->CurrentFont, this->OverlayBuffer, wnd->GetTitle()[i], 0xFFFFFF, &CharCursorX, &CharCursorY);
|
||||
|
||||
@ -646,7 +646,7 @@ namespace GraphicalUserInterface
|
||||
this->CursorBuffer->Height = 25;
|
||||
this->CursorBuffer->BitsPerPixel = Display->GetBitsPerPixel();
|
||||
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));
|
||||
memset(this->CursorBuffer->Data, 0, this->CursorBuffer->Size);
|
||||
|
||||
|
@ -66,8 +66,8 @@ namespace GraphicalUserInterface
|
||||
|
||||
void WidgetCollection::OnPaint(Event *e)
|
||||
{
|
||||
static long LastWidth = 0;
|
||||
static long LastHeight = 0;
|
||||
static int64_t LastWidth = 0;
|
||||
static int64_t LastHeight = 0;
|
||||
|
||||
if (LastWidth != ((Window *)this->ParentWindow)->GetPosition().Width ||
|
||||
LastHeight != ((Window *)this->ParentWindow)->GetPosition().Height)
|
||||
@ -84,7 +84,7 @@ namespace GraphicalUserInterface
|
||||
this->Buffer->Height = LastHeight;
|
||||
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
|
||||
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));
|
||||
memset(this->Buffer->Data, 0, this->Buffer->Size);
|
||||
|
||||
|
@ -125,7 +125,7 @@ namespace GraphicalUserInterface
|
||||
this->Buffer->Height = ((Window *)this->ParentWindow)->GetPosition().Height;
|
||||
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
|
||||
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));
|
||||
memset(this->Buffer->Data, 0, this->Buffer->Size);
|
||||
|
||||
|
@ -79,7 +79,7 @@ namespace GraphicalUserInterface
|
||||
if (!this->Maximized)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ EXTERNC void KPrint(const char *Format, ...)
|
||||
uint64_t Nanoseconds = TimeManager->GetNanosecondsSinceClassCreation();
|
||||
if (Nanoseconds != 0)
|
||||
{
|
||||
printf("\eCCCCCC[\e00AEFF%lu.%07lu\eCCCCCC] ",
|
||||
printf("\eCCCCCC[\e00AEFF%llu.%07llu\eCCCCCC] ",
|
||||
Nanoseconds / 10000000,
|
||||
Nanoseconds % 10000000);
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ void TaskMgr()
|
||||
continue;
|
||||
int Status = Proc->Status;
|
||||
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);
|
||||
|
||||
foreach (auto Thd in Proc->Threads)
|
||||
@ -185,7 +185,7 @@ void TaskMgr()
|
||||
Thd->Info.UserTime, Thd->Registers.rip,
|
||||
Thd->Parent->ELFSymbolTable ? Thd->Parent->ELFSymbolTable->GetSymbolFromAddress(Thd->Registers.rip) : "unknown");
|
||||
#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,
|
||||
Thd->Info.UserTime, Thd->Registers.eip,
|
||||
Thd->Parent->ELFSymbolTable ? Thd->Parent->ELFSymbolTable->GetSymbolFromAddress(Thd->Registers.eip) : "unknown");
|
||||
@ -283,7 +283,7 @@ void BootLogoAnimationThread()
|
||||
char BootAnimPath[16];
|
||||
while (FrameCount < 27)
|
||||
{
|
||||
sprintf(BootAnimPath, "%d.tga", FrameCount);
|
||||
sprintf(BootAnimPath, "%ld.tga", FrameCount);
|
||||
File ba = bootanim_vfs->Open(BootAnimPath);
|
||||
if (!ba.IsOK())
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ void md5Finalize(MD5Context *ctx)
|
||||
}
|
||||
input[14] = (uint32_t)(ctx->size * 8);
|
||||
#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
|
||||
input[15] = (uint32_t)((ctx->size * 8) >> 32);
|
||||
#endif
|
||||
|
4
Makefile
4
Makefile
@ -83,8 +83,8 @@ LDFLAGS += -TArchitecture/amd64/linker.ld \
|
||||
else ifeq ($(OSARCH), i386)
|
||||
|
||||
CFLAGS += -fno-pic -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -march=pentium -pipe -msoft-float \
|
||||
-fno-builtin -Da32 -Da86
|
||||
-mno-red-zone -march=pentium -pipe -fno-builtin \
|
||||
-Da32 -Da86
|
||||
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
||||
LDFLAGS += -TArchitecture/i386/linker.ld \
|
||||
-fno-pic -fno-pie \
|
||||
|
@ -188,7 +188,7 @@ namespace NetworkARP
|
||||
delete Header, Header = nullptr;
|
||||
}
|
||||
|
||||
bool ARP::OnEthernetPacketReceived(uint8_t *Data, uint64_t Length)
|
||||
bool ARP::OnEthernetPacketReceived(uint8_t *Data, size_t Length)
|
||||
{
|
||||
UNUSED(Length);
|
||||
netdbg("Received packet");
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#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;
|
||||
uint64_t Checksum = 0;
|
||||
|
@ -153,7 +153,7 @@ namespace NetworkDHCP
|
||||
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(Length);
|
||||
|
@ -43,7 +43,7 @@ namespace NetworkEthernet
|
||||
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());
|
||||
size_t PacketLength = sizeof(EthernetHeader) + Length;
|
||||
@ -60,7 +60,7 @@ namespace NetworkEthernet
|
||||
kfree(Packet);
|
||||
}
|
||||
|
||||
void Ethernet::Receive(uint8_t *Data, uint64_t Length)
|
||||
void Ethernet::Receive(uint8_t *Data, size_t Length)
|
||||
{
|
||||
EthernetPacket *Packet = (EthernetPacket *)Data;
|
||||
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)
|
||||
this->Receive(Data, Length);
|
||||
|
@ -62,7 +62,7 @@ namespace NetworkICMPv6
|
||||
ICMPv6::ICMPv6(NetworkInterfaceManager::DeviceInterface *Interface) { this->Interface = Interface; }
|
||||
ICMPv6::~ICMPv6() {}
|
||||
|
||||
void ICMPv6::Send(uint8_t *Data, uint64_t Length)
|
||||
void ICMPv6::Send(uint8_t *Data, size_t Length)
|
||||
{
|
||||
UNUSED(Data);
|
||||
UNUSED(Length);
|
||||
|
@ -34,7 +34,7 @@ namespace NetworkIPv4
|
||||
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());
|
||||
IPv4Packet *Packet = (IPv4Packet *)kmalloc(Length + sizeof(IPv4Header));
|
||||
@ -68,7 +68,7 @@ namespace NetworkIPv4
|
||||
|
||||
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;
|
||||
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)
|
||||
{
|
||||
uint64_t TotalLength = Packet->Header.TotalLength;
|
||||
size_t TotalLength = Packet->Header.TotalLength;
|
||||
if (TotalLength > Length)
|
||||
TotalLength = Length;
|
||||
|
||||
@ -127,7 +127,7 @@ namespace NetworkIPv4
|
||||
|
||||
IPv4Events::~IPv4Events()
|
||||
{
|
||||
for (uint64_t i = 0; i < RegisteredEvents.size(); i++)
|
||||
for (size_t i = 0; i < RegisteredEvents.size(); i++)
|
||||
if (RegisteredEvents[i] == this)
|
||||
{
|
||||
RegisteredEvents.remove(i);
|
||||
|
@ -210,7 +210,7 @@ namespace NetworkInterfaceManager
|
||||
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));
|
||||
memcpy(DataToBeSent, Data, Length);
|
||||
@ -226,7 +226,7 @@ namespace NetworkInterfaceManager
|
||||
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)
|
||||
re->OnInterfaceReceived(Interface, Data, Length);
|
||||
|
@ -88,8 +88,8 @@ namespace NetDbg
|
||||
|
||||
NETWORK_DEBUG() : NetworkInterfaceManager::Events(nullptr) { netdbg("NetworkDebugger initialized."); }
|
||||
~NETWORK_DEBUG() { netdbg("NetworkDebugger destroyed."); }
|
||||
void OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, uint64_t Length) { DumpData("Received", Data, Length); }
|
||||
void OnInterfaceSent(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, uint64_t Length) { DumpData("Sent", 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, size_t Length) { DumpData("Sent", Data, Length); }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
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(Length);
|
||||
@ -68,7 +68,7 @@ namespace NetworkNTP
|
||||
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);
|
||||
return s_cst(int, UnixTimestamp);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace NetworkUDP
|
||||
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);
|
||||
uint16_t TotalLength = s_cst(uint16_t, Length + sizeof(UDPHeader));
|
||||
@ -97,7 +97,7 @@ namespace NetworkUDP
|
||||
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());
|
||||
if (Length < sizeof(UDPHeader))
|
||||
|
@ -268,9 +268,9 @@ namespace Recovery
|
||||
uint64_t MemReserved = 0;
|
||||
while (true)
|
||||
{
|
||||
sprintf(TicksText, "%016ld / %016ld", TaskManager->GetSchedulerTicks(), TaskManager->GetLastTaskTicks());
|
||||
sprintf(TicksText, "%016lld / %016lld", TaskManager->GetSchedulerTicks(), TaskManager->GetLastTaskTicks());
|
||||
wdgDbgWin->SetText(SchedLblHnd, TicksText);
|
||||
sprintf(TicksText, "CPU Scheduled Core: %ld", TaskManager->GetLastCore());
|
||||
sprintf(TicksText, "CPU Scheduled Core: %lld", TaskManager->GetLastCore());
|
||||
wdgDbgWin->SetText(wdgDbgCurrentCPUSchedCoreLbl, TicksText);
|
||||
static int RefreshMemCounter = 0;
|
||||
if (RefreshMemCounter-- == 0)
|
||||
@ -279,7 +279,7 @@ namespace Recovery
|
||||
MemTotal = KernelAllocator.GetTotalMemory();
|
||||
MemReserved = KernelAllocator.GetReservedMemory();
|
||||
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);
|
||||
RefreshMemCounter = 25;
|
||||
}
|
||||
@ -292,9 +292,9 @@ namespace Recovery
|
||||
static int 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);
|
||||
sprintf(TicksText, "%016ld / %016ld / %016ld", PWWi, PCi, mmi);
|
||||
sprintf(TicksText, "%016lld / %016lld / %016lld", PWWi, PCi, mmi);
|
||||
wdgDbgWin->SetText(GUI2LblHnd, TicksText);
|
||||
RefreshGUIDbgCounter = 5;
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ static uint64_t sys_file_read(SyscallsFrame *Frame, void *KernelPrivate, uint64_
|
||||
return 0;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ static uint64_t sys_file_write(SyscallsFrame *Frame, void *KernelPrivate, uint64
|
||||
return 0;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ static uint64_t sys_file_seek(SyscallsFrame *Frame, void *KernelPrivate, uint64_
|
||||
if (KPObj->node->Operator->Seek == nullptr)
|
||||
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);
|
||||
return ret;
|
||||
UNUSED(Frame);
|
||||
@ -458,7 +458,7 @@ static int sys_spawn(SyscallsFrame *Frame)
|
||||
|
||||
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)
|
||||
return (int)thread->ID;
|
||||
return SYSCALL_ERROR;
|
||||
|
@ -676,21 +676,25 @@ namespace Tasking
|
||||
SafeFunction bool Task::FindNewProcess(void *CPUDataPointer)
|
||||
{
|
||||
fixme("unimplemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
SafeFunction bool Task::GetNextAvailableThread(void *CPUDataPointer)
|
||||
{
|
||||
fixme("unimplemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
SafeFunction bool Task::GetNextAvailableProcess(void *CPUDataPointer)
|
||||
{
|
||||
fixme("unimplemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
SafeFunction bool Task::SchedulerSearchProcessThread(void *CPUDataPointer)
|
||||
{
|
||||
fixme("unimplemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
SafeFunction void Task::Schedule(void *Frame)
|
||||
|
@ -25,9 +25,9 @@ namespace Tasking
|
||||
{
|
||||
Token Security::CreateToken()
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
Token ret = 0;
|
||||
Retry:
|
||||
ret = Random::rand64();
|
||||
ret = (Token)Random::rand64();
|
||||
foreach (auto t in Tokens)
|
||||
if (t.token == ret)
|
||||
goto Retry;
|
||||
|
@ -71,7 +71,7 @@ void TestMemoryAllocation()
|
||||
uint64_t prq1 = (uint64_t)KernelAllocator.RequestPage();
|
||||
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());
|
||||
|
||||
uint64_t prq2 = (uint64_t)KernelAllocator.RequestPage();
|
||||
@ -86,7 +86,7 @@ void TestMemoryAllocation()
|
||||
uint64_t prq1 = (uint64_t)KernelAllocator.RequestPages(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);
|
||||
|
||||
uint64_t prq2 = (uint64_t)KernelAllocator.RequestPages(10);
|
||||
@ -98,13 +98,13 @@ void TestMemoryAllocation()
|
||||
|
||||
debug("Multiple Fixed Malloc Test");
|
||||
{
|
||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq1);
|
||||
|
||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||
kfree(kmalloc(0x10000));
|
||||
|
||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq2);
|
||||
|
||||
debug(" Result:\t\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||
@ -113,13 +113,13 @@ void TestMemoryAllocation()
|
||||
|
||||
debug("Multiple Dynamic Malloc Test");
|
||||
{
|
||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq1);
|
||||
|
||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||
kfree(kmalloc(i));
|
||||
|
||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq2);
|
||||
|
||||
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||
@ -128,16 +128,16 @@ void TestMemoryAllocation()
|
||||
|
||||
debug("New/Delete Test");
|
||||
{
|
||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||
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();
|
||||
delete t;
|
||||
}
|
||||
|
||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq2);
|
||||
|
||||
debug(" Result: \t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||
@ -146,16 +146,16 @@ void TestMemoryAllocation()
|
||||
|
||||
debug("New/Delete Fixed Array Test");
|
||||
{
|
||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||
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];
|
||||
delete[] t;
|
||||
}
|
||||
|
||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq2);
|
||||
|
||||
debug(" Result: \t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||
@ -164,10 +164,10 @@ void TestMemoryAllocation()
|
||||
|
||||
debug("New/Delete Dynamic Array Test");
|
||||
{
|
||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq1);
|
||||
|
||||
for (uint64_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
continue;
|
||||
@ -175,7 +175,7 @@ void TestMemoryAllocation()
|
||||
delete[] t;
|
||||
}
|
||||
|
||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq2);
|
||||
|
||||
debug(" Result:\t1-[%#lx]; 2-[%#lx]\n", (void *)prq1, (void *)prq2);
|
||||
@ -184,16 +184,16 @@ void TestMemoryAllocation()
|
||||
|
||||
debug("calloc Test");
|
||||
{
|
||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||
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);
|
||||
kfree(t);
|
||||
}
|
||||
|
||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq2);
|
||||
|
||||
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||
@ -202,17 +202,17 @@ void TestMemoryAllocation()
|
||||
|
||||
debug("realloc Test");
|
||||
{
|
||||
uint64_t prq1 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
|
||||
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);
|
||||
t = (char *)krealloc(t, 256);
|
||||
kfree(t);
|
||||
}
|
||||
|
||||
uint64_t prq2 = (uint64_t)kmalloc(0x1000);
|
||||
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
|
||||
kfree((void *)prq2);
|
||||
|
||||
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
|
||||
|
@ -43,7 +43,7 @@ __constructor void TestRandom()
|
||||
#if defined(a86)
|
||||
if (RDRANDFlag)
|
||||
{
|
||||
uint64_t RDSEEDValue = 0;
|
||||
uintptr_t RDSEEDValue = 0;
|
||||
asmv("1: rdseed %0; jnc 1b"
|
||||
: "=r"(RDSEEDValue));
|
||||
debug("RDSEED: %ld", RDSEEDValue);
|
||||
|
@ -52,7 +52,7 @@ struct BootInfo
|
||||
void *BaseAddress;
|
||||
__UINT32_TYPE__ Width;
|
||||
__UINT32_TYPE__ Height;
|
||||
__UINT64_TYPE__ Pitch;
|
||||
__SIZE_TYPE__ Pitch;
|
||||
__UINT16_TYPE__ BitsPerPixel;
|
||||
__UINT8_TYPE__ RedMaskSize;
|
||||
__UINT8_TYPE__ RedMaskShift;
|
||||
@ -61,7 +61,7 @@ struct BootInfo
|
||||
__UINT8_TYPE__ BlueMaskSize;
|
||||
__UINT8_TYPE__ BlueMaskShift;
|
||||
void *ExtendedDisplayIdentificationData;
|
||||
__UINT64_TYPE__ EDIDSize;
|
||||
__SIZE_TYPE__ EDIDSize;
|
||||
} Framebuffer[MAX_FRAMEBUFFERS];
|
||||
|
||||
struct MemoryInfo
|
||||
@ -69,11 +69,11 @@ struct BootInfo
|
||||
struct MemoryEntryInfo
|
||||
{
|
||||
void *BaseAddress;
|
||||
__UINT64_TYPE__ Length;
|
||||
__SIZE_TYPE__ Length;
|
||||
enum MemoryType Type;
|
||||
} Entry[MAX_MEMORY_ENTRIES];
|
||||
__UINT64_TYPE__ Entries;
|
||||
__UINT64_TYPE__ Size;
|
||||
__SIZE_TYPE__ Entries;
|
||||
__SIZE_TYPE__ Size;
|
||||
} Memory;
|
||||
|
||||
struct ModuleInfo
|
||||
@ -81,7 +81,7 @@ struct BootInfo
|
||||
void *Address;
|
||||
char Path[256];
|
||||
char CommandLine[256];
|
||||
__UINT64_TYPE__ Size;
|
||||
__SIZE_TYPE__ Size;
|
||||
} Modules[MAX_MODULES];
|
||||
|
||||
struct RSDPInfo
|
||||
@ -132,7 +132,7 @@ struct BootInfo
|
||||
void *VirtualBase;
|
||||
void *FileBase;
|
||||
char CommandLine[256];
|
||||
__UINT64_TYPE__ Size;
|
||||
__SIZE_TYPE__ Size;
|
||||
|
||||
struct KernelSymbolInfo
|
||||
{
|
||||
|
@ -413,7 +413,7 @@ namespace CPU
|
||||
|
||||
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"
|
||||
:
|
||||
: "c"(msr), "a"(Low), "d"(High)
|
||||
|
@ -101,8 +101,8 @@ namespace Disk
|
||||
{
|
||||
public:
|
||||
char Label[72] = "Unidentified Partition";
|
||||
size_t StartLBA = 0xdeadbeef;
|
||||
size_t EndLBA = 0xdeadbeef;
|
||||
uint64_t StartLBA = 0xdeadbeef;
|
||||
uint64_t EndLBA = 0xdeadbeef;
|
||||
size_t Sectors = 0xdeadbeef;
|
||||
size_t Flags = 0xdeadbeef;
|
||||
unsigned char Port = 0;
|
||||
|
@ -118,7 +118,7 @@ namespace Video
|
||||
Font *GetCurrentFont();
|
||||
void SetCurrentFont(Font *Font);
|
||||
uint16_t GetBitsPerPixel();
|
||||
uint64_t GetPitch();
|
||||
size_t GetPitch();
|
||||
|
||||
/**
|
||||
* @brief Create a new buffer
|
||||
|
@ -48,7 +48,7 @@ namespace Driver
|
||||
struct DriverFile
|
||||
{
|
||||
bool Enabled = false;
|
||||
unsigned long DriverUID = 0;
|
||||
size_t DriverUID = 0;
|
||||
void *Address = nullptr;
|
||||
void *InterruptCallback = nullptr;
|
||||
Memory::MemMgr *MemTrk = nullptr;
|
||||
|
@ -120,7 +120,7 @@ namespace VirtualFileSystem
|
||||
uint64_t UserIdentifier = 0, GroupIdentifier = 0;
|
||||
uintptr_t Address = 0;
|
||||
size_t Length = 0;
|
||||
uint64_t Offset = 0;
|
||||
size_t Offset = 0;
|
||||
Node *Parent = nullptr;
|
||||
FileSystemOperations *Operator = nullptr;
|
||||
/* For root node:
|
||||
|
@ -42,8 +42,8 @@ namespace GraphicalUserInterface
|
||||
{
|
||||
int64_t Width;
|
||||
int64_t Height;
|
||||
uint64_t Size;
|
||||
uint64_t Pitch;
|
||||
size_t Size;
|
||||
size_t Pitch;
|
||||
uint64_t BitsPerPixel;
|
||||
uint8_t *Data;
|
||||
};
|
||||
@ -52,8 +52,8 @@ namespace GraphicalUserInterface
|
||||
{
|
||||
int64_t Left;
|
||||
int64_t Top;
|
||||
int64_t Width;
|
||||
int64_t Height;
|
||||
size_t Width;
|
||||
size_t Height;
|
||||
|
||||
bool Contains(int64_t X, int64_t Y)
|
||||
{
|
||||
@ -89,8 +89,8 @@ namespace GraphicalUserInterface
|
||||
{
|
||||
struct
|
||||
{
|
||||
int64_t Width;
|
||||
int64_t Height;
|
||||
size_t Width;
|
||||
size_t Height;
|
||||
} Resize;
|
||||
|
||||
struct
|
||||
@ -178,18 +178,18 @@ namespace GraphicalUserInterface
|
||||
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,
|
||||
ScreenBitmap *SourceBitmap,
|
||||
long Top,
|
||||
long Left,
|
||||
int64_t Top,
|
||||
int64_t Left,
|
||||
bool IgnoreZero = true);
|
||||
void PutRect(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);
|
||||
void PutBorderWithShadow(ScreenBitmap *Bitmap, Rect rect, uint32_t Color);
|
||||
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);
|
||||
|
||||
class WidgetCollection
|
||||
@ -212,7 +212,7 @@ namespace GraphicalUserInterface
|
||||
Rect rect;
|
||||
char Text[512];
|
||||
uint32_t Color;
|
||||
long CharCursorX, CharCursorY;
|
||||
int64_t CharCursorX, CharCursorY;
|
||||
};
|
||||
|
||||
struct PanelObject
|
||||
@ -235,7 +235,7 @@ namespace GraphicalUserInterface
|
||||
uint32_t PressedColor;
|
||||
uint32_t BorderColor;
|
||||
uint32_t ShadowColor;
|
||||
long CharCursorX, CharCursorY;
|
||||
int64_t CharCursorX, CharCursorY;
|
||||
bool Shadow;
|
||||
bool Hover;
|
||||
bool Pressed;
|
||||
|
@ -174,6 +174,7 @@ extern "C"
|
||||
: "memory");
|
||||
}
|
||||
|
||||
#if defined(a64)
|
||||
static inline void mmoutq(void *Address, uint64_t Value)
|
||||
{
|
||||
asmv("mov %1, %0"
|
||||
@ -181,6 +182,7 @@ extern "C"
|
||||
: "r"(Value)
|
||||
: "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline uint8_t mminb(void *Address)
|
||||
{
|
||||
@ -212,6 +214,7 @@ extern "C"
|
||||
return Result;
|
||||
}
|
||||
|
||||
#if defined(a64)
|
||||
static inline uint64_t mminq(void *Address)
|
||||
{
|
||||
uint64_t Result;
|
||||
@ -221,6 +224,7 @@ extern "C"
|
||||
: "memory");
|
||||
return Result;
|
||||
}
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -180,9 +180,9 @@ namespace Memory
|
||||
|
||||
union __packed PageTableEntry
|
||||
{
|
||||
#if defined(a64)
|
||||
struct
|
||||
{
|
||||
#if defined(a64)
|
||||
uintptr_t Present : 1; // 0
|
||||
uintptr_t ReadWrite : 1; // 1
|
||||
uintptr_t UserSupervisor : 1; // 2
|
||||
@ -197,10 +197,7 @@ namespace Memory
|
||||
uintptr_t Available1 : 7; // 52-58
|
||||
uintptr_t ProtectionKey : 4; // 59-62
|
||||
uintptr_t ExecuteDisable : 1; // 63
|
||||
};
|
||||
#elif defined(a32)
|
||||
struct
|
||||
{
|
||||
uintptr_t Present : 1; // 0
|
||||
uintptr_t ReadWrite : 1; // 1
|
||||
uintptr_t UserSupervisor : 1; // 2
|
||||
@ -212,9 +209,9 @@ namespace Memory
|
||||
uintptr_t Global : 1; // 8
|
||||
uintptr_t Available0 : 3; // 9-11
|
||||
uintptr_t Address : 20; // 12-31
|
||||
};
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
};
|
||||
uintptr_t raw;
|
||||
|
||||
/** @brief Set Address */
|
||||
@ -241,7 +238,7 @@ namespace Memory
|
||||
#if defined(a64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#elif defined(a32)
|
||||
return (this->raw & 0x003FFFFF000) >> 12;
|
||||
return ((uintptr_t)(this->raw & 0x003FFFFF000) >> 12);
|
||||
#elif defined(aa64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#endif
|
||||
@ -356,7 +353,7 @@ namespace Memory
|
||||
#if defined(a64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#elif defined(a32)
|
||||
return (this->raw & 0x003FFFFF000) >> 12;
|
||||
return ((uintptr_t)(this->raw & 0x003FFFFF000) >> 12);
|
||||
#elif defined(aa64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#endif
|
||||
@ -370,6 +367,7 @@ namespace Memory
|
||||
|
||||
union __packed PageDirectoryPointerTableEntry
|
||||
{
|
||||
#if defined(a64)
|
||||
struct
|
||||
{
|
||||
uintptr_t Present : 1; // 0
|
||||
@ -405,7 +403,8 @@ namespace Memory
|
||||
uintptr_t ProtectionKey : 4; // 59-62
|
||||
uintptr_t ExecuteDisable : 1; // 63
|
||||
} OneGB;
|
||||
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
uintptr_t raw;
|
||||
|
||||
/** @brief Set PageDirectoryEntryPtr address */
|
||||
@ -415,10 +414,6 @@ namespace Memory
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
this->raw &= 0xFFF0000000000FFF;
|
||||
this->raw |= (_Address << 12);
|
||||
#elif defined(a32)
|
||||
_Address &= 0x000FFFFF;
|
||||
this->raw &= 0xFFC00003;
|
||||
this->raw |= (_Address << 12);
|
||||
#elif defined(aa64)
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
this->raw &= 0xFFF0000000000FFF;
|
||||
@ -432,7 +427,7 @@ namespace Memory
|
||||
#if defined(a64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#elif defined(a32)
|
||||
return (this->raw & 0x003FFFFF000) >> 12;
|
||||
return 0;
|
||||
#elif defined(aa64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#endif
|
||||
@ -446,6 +441,7 @@ namespace Memory
|
||||
|
||||
union __packed PageMapLevel4
|
||||
{
|
||||
#if defined(a64)
|
||||
struct
|
||||
{
|
||||
uintptr_t Present : 1; // 0
|
||||
@ -461,6 +457,8 @@ namespace Memory
|
||||
uintptr_t Available2 : 11; // 52-62
|
||||
uintptr_t ExecuteDisable : 1; // 63
|
||||
};
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
uintptr_t raw;
|
||||
|
||||
/** @brief Set PageDirectoryPointerTableEntryPtr address */
|
||||
@ -470,10 +468,6 @@ namespace Memory
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
this->raw &= 0xFFF0000000000FFF;
|
||||
this->raw |= (_Address << 12);
|
||||
#elif defined(a32)
|
||||
_Address &= 0x000FFFFF;
|
||||
this->raw &= 0xFFC00003;
|
||||
this->raw |= (_Address << 12);
|
||||
#elif defined(aa64)
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
this->raw &= 0xFFF0000000000FFF;
|
||||
@ -487,7 +481,7 @@ namespace Memory
|
||||
#if defined(a64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#elif defined(a32)
|
||||
return (this->raw & 0x003FFFFF000) >> 12;
|
||||
return 0;
|
||||
#elif defined(aa64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#endif
|
||||
@ -501,6 +495,7 @@ namespace Memory
|
||||
|
||||
union __packed PageMapLevel5
|
||||
{
|
||||
#if defined(a64)
|
||||
struct
|
||||
{
|
||||
uintptr_t Present : 1; // 0
|
||||
@ -516,6 +511,8 @@ namespace Memory
|
||||
uintptr_t Available2 : 11; // 52-62
|
||||
uintptr_t ExecuteDisable : 1; // 63
|
||||
};
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
uintptr_t raw;
|
||||
|
||||
/** @brief Set PageMapLevel4Ptr address */
|
||||
@ -525,10 +522,6 @@ namespace Memory
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
this->raw &= 0xFFF0000000000FFF;
|
||||
this->raw |= (_Address << 12);
|
||||
#elif defined(a32)
|
||||
_Address &= 0x000FFFFF;
|
||||
this->raw &= 0xFFC00003;
|
||||
this->raw |= (_Address << 12);
|
||||
#elif defined(aa64)
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
this->raw &= 0xFFF0000000000FFF;
|
||||
@ -542,7 +535,7 @@ namespace Memory
|
||||
#if defined(a64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#elif defined(a32)
|
||||
return (this->raw & 0x003FFFFF000) >> 12;
|
||||
return 0;
|
||||
#elif defined(aa64)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
#endif
|
||||
|
@ -80,7 +80,7 @@ namespace NetworkARP
|
||||
DiscoveredAddress *ManageDiscoveredAddresses(DAType Type, InternetProtocol IP, MediaAccessControl MAC);
|
||||
DiscoveredAddress *Search(InternetProtocol TargetIP);
|
||||
DiscoveredAddress *Update(InternetProtocol TargetIP, MediaAccessControl TargetMAC);
|
||||
bool OnEthernetPacketReceived(uint8_t *Data, uint64_t Length);
|
||||
bool OnEthernetPacketReceived(uint8_t *Data, size_t Length);
|
||||
|
||||
public:
|
||||
ARP(NetworkEthernet::Ethernet *Ethernet);
|
||||
|
@ -160,7 +160,7 @@ namespace NetworkDHCP
|
||||
|
||||
void CreatePacket(DHCPHeader *Packet, uint8_t MessageType, uint32_t RequestIP);
|
||||
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:
|
||||
/** @brief IP address (Little-endian) */
|
||||
|
@ -61,7 +61,7 @@ namespace NetworkEthernet
|
||||
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(Length);
|
||||
@ -74,8 +74,8 @@ namespace NetworkEthernet
|
||||
{
|
||||
private:
|
||||
NetworkInterfaceManager::DeviceInterface *Interface;
|
||||
void Receive(uint8_t *Data, uint64_t Length);
|
||||
void OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, uint64_t Length);
|
||||
void Receive(uint8_t *Data, size_t Length);
|
||||
void OnInterfaceReceived(NetworkInterfaceManager::DeviceInterface *Interface, uint8_t *Data, size_t Length);
|
||||
|
||||
public:
|
||||
/** @brief Get driver interface
|
||||
@ -101,7 +101,7 @@ namespace NetworkEthernet
|
||||
* @param Data The data to send.
|
||||
* @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();
|
||||
void Send(uint8_t *Data, uint64_t Length);
|
||||
void Send(uint8_t *Data, size_t Length);
|
||||
void Receive(uint8_t *Data);
|
||||
};
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ namespace NetworkIPv4
|
||||
NetworkARP::ARP *ARP;
|
||||
NetworkEthernet::Ethernet *Ethernet;
|
||||
|
||||
virtual bool OnEthernetPacketReceived(uint8_t *Data, uint64_t Length);
|
||||
virtual bool OnEthernetPacketReceived(uint8_t *Data, size_t Length);
|
||||
|
||||
public:
|
||||
InternetProtocol GatewayIP;
|
||||
@ -107,7 +107,7 @@ namespace NetworkIPv4
|
||||
* @param Protocol The protocol of the packet.
|
||||
* @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
|
||||
@ -122,7 +122,7 @@ namespace NetworkIPv4
|
||||
public:
|
||||
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(DestinationIP);
|
||||
|
@ -70,7 +70,7 @@ namespace NetworkInterfaceManager
|
||||
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(Data);
|
||||
@ -78,7 +78,7 @@ namespace NetworkInterfaceManager
|
||||
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(Data);
|
||||
@ -104,8 +104,8 @@ namespace NetworkInterfaceManager
|
||||
|
||||
void StartService();
|
||||
|
||||
void Send(DeviceInterface *Interface, uint8_t *Data, uint64_t Length);
|
||||
void Receive(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, size_t Length);
|
||||
|
||||
void DrvSend(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;
|
||||
};
|
||||
|
||||
uint16_t CalculateChecksum(uint16_t *Data, uint64_t Length);
|
||||
uint16_t CalculateChecksum(uint16_t *Data, size_t Length);
|
||||
|
||||
#endif // !__FENNIX_KERNEL_NETWORK_H__
|
||||
|
@ -148,7 +148,7 @@ namespace NetworkNTP
|
||||
bool TimeReceived = false;
|
||||
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:
|
||||
NTP(NetworkUDP::Socket *Socket);
|
||||
|
@ -48,7 +48,7 @@ namespace NetworkUDP
|
||||
~UDPEvents();
|
||||
|
||||
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(Data);
|
||||
@ -72,10 +72,10 @@ namespace NetworkUDP
|
||||
virtual Socket *Connect(InternetProtocol IP, uint16_t Port);
|
||||
virtual Socket *Listen(uint16_t Port);
|
||||
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 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
|
||||
|
@ -226,9 +226,9 @@ namespace PCI
|
||||
|
||||
public:
|
||||
std::vector<PCIDeviceHeader *> &GetDevices() { return Devices; }
|
||||
void EnumerateFunction(uintptr_t DeviceAddress, uint64_t Function);
|
||||
void EnumerateDevice(uintptr_t BusAddress, uint64_t Device);
|
||||
void EnumerateBus(uintptr_t BaseAddress, uint64_t Bus);
|
||||
void EnumerateFunction(uintptr_t DeviceAddress, uintptr_t Function);
|
||||
void EnumerateDevice(uintptr_t BusAddress, uintptr_t Device);
|
||||
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(int VendorID, int DeviceID);
|
||||
|
||||
|
@ -32,6 +32,8 @@ struct CPUArchData
|
||||
CPU::x64::FXState *FPU;
|
||||
/* TODO */
|
||||
#elif defined(a32)
|
||||
CPU::x32::FXState *FPU;
|
||||
/* TODO */
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace SymbolResolver
|
||||
void *Image;
|
||||
|
||||
public:
|
||||
size_t GetTotalEntries() { return this->TotalEntries; }
|
||||
int64_t GetTotalEntries() { return this->TotalEntries; }
|
||||
void *GetImage() { return this->Image; }
|
||||
const char *GetSymbolFromAddress(uintptr_t Address);
|
||||
void AddSymbol(uintptr_t Address, const char *Name);
|
||||
|
@ -52,15 +52,15 @@ namespace Time
|
||||
private:
|
||||
struct HPET
|
||||
{
|
||||
uint64_t GeneralCapabilities;
|
||||
uint64_t Reserved0;
|
||||
uint64_t GeneralConfiguration;
|
||||
uint64_t Reserved1;
|
||||
uint64_t GeneralIntStatus;
|
||||
uint64_t Reserved2;
|
||||
uint64_t Reserved3[24];
|
||||
uint64_t MainCounterValue;
|
||||
uint64_t Reserved4;
|
||||
uintptr_t GeneralCapabilities;
|
||||
uintptr_t Reserved0;
|
||||
uintptr_t GeneralConfiguration;
|
||||
uintptr_t Reserved1;
|
||||
uintptr_t GeneralIntStatus;
|
||||
uintptr_t Reserved2;
|
||||
uintptr_t Reserved3[24];
|
||||
uintptr_t MainCounterValue;
|
||||
uintptr_t Reserved4;
|
||||
};
|
||||
|
||||
uint32_t clk = 0;
|
||||
|
@ -353,7 +353,7 @@ namespace std
|
||||
if (Pos >= this->Length)
|
||||
return;
|
||||
|
||||
if ((int64_t)Count < 0)
|
||||
if ((int64_t)Count <= 0)
|
||||
return;
|
||||
|
||||
if (Pos + Count > this->Length)
|
||||
@ -377,7 +377,7 @@ namespace std
|
||||
if (Pos >= this->Length)
|
||||
return;
|
||||
|
||||
if ((int64_t)Count < 0)
|
||||
if ((int64_t)Count <= 0)
|
||||
return;
|
||||
|
||||
if (Pos + Count > this->Length)
|
||||
|
Loading…
x
Reference in New Issue
Block a user