mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Updated types
This commit is contained in:
@ -6,7 +6,7 @@ class Bitmap
|
||||
public:
|
||||
size_t Size;
|
||||
uint8_t *Buffer;
|
||||
bool operator[](uint64_t index);
|
||||
bool Set(uint64_t index, bool value);
|
||||
bool Get(uint64_t index);
|
||||
bool operator[](uintptr_t index);
|
||||
bool Set(uintptr_t index, bool value);
|
||||
bool Get(uintptr_t index);
|
||||
};
|
||||
|
@ -86,16 +86,16 @@ namespace Disk
|
||||
{
|
||||
public:
|
||||
char Label[72] = "Unidentified Partition";
|
||||
uint64_t StartLBA = 0xdeadbeef;
|
||||
uint64_t EndLBA = 0xdeadbeef;
|
||||
uint64_t Sectors = 0xdeadbeef;
|
||||
uint64_t Flags = 0xdeadbeef;
|
||||
size_t StartLBA = 0xdeadbeef;
|
||||
size_t EndLBA = 0xdeadbeef;
|
||||
size_t Sectors = 0xdeadbeef;
|
||||
size_t Flags = 0xdeadbeef;
|
||||
unsigned char Port = 0;
|
||||
PartitionStyle Style = PartitionStyle::Unknown;
|
||||
size_t Index = 0;
|
||||
|
||||
uint64_t Read(uint64_t Offset, uint64_t Count, uint8_t *Buffer) { return 0; }
|
||||
uint64_t Write(uint64_t Offset, uint64_t Count, uint8_t *Buffer) { return 0; }
|
||||
size_t Read(size_t Offset, size_t Count, uint8_t *Buffer) { return 0; }
|
||||
size_t Write(size_t Offset, size_t Count, uint8_t *Buffer) { return 0; }
|
||||
Partition() {}
|
||||
~Partition() {}
|
||||
};
|
||||
@ -109,10 +109,10 @@ namespace Disk
|
||||
PartitionStyle Style = PartitionStyle::Unknown;
|
||||
Vector<Partition *> Partitions;
|
||||
bool MechanicalDisk = false;
|
||||
uint64_t UniqueIdentifier = 0xdeadbeef;
|
||||
size_t UniqueIdentifier = 0xdeadbeef;
|
||||
|
||||
uint64_t Read(uint64_t Offset, uint64_t Count, uint8_t *Buffer) { return 0; }
|
||||
uint64_t Write(uint64_t Offset, uint64_t Count, uint8_t *Buffer) { return 0; }
|
||||
size_t Read(size_t Offset, size_t Count, uint8_t *Buffer) { return 0; }
|
||||
size_t Write(size_t Offset, size_t Count, uint8_t *Buffer) { return 0; }
|
||||
Drive()
|
||||
{ // TODO: Allocate buffer
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ namespace Video
|
||||
|
||||
struct FontInfo
|
||||
{
|
||||
uint64_t *StartAddress;
|
||||
uint64_t *EndAddress;
|
||||
uintptr_t *StartAddress;
|
||||
uintptr_t *EndAddress;
|
||||
PSF1_FONT *PSF1Font;
|
||||
PSF2_FONT *PSF2Font;
|
||||
uint32_t Width, Height;
|
||||
@ -72,7 +72,7 @@ namespace Video
|
||||
|
||||
public:
|
||||
FontInfo GetInfo() { return Info; }
|
||||
Font(uint64_t *Start, uint64_t *End, FontType Type);
|
||||
Font(uintptr_t *Start, uintptr_t *End, FontType Type);
|
||||
~Font();
|
||||
};
|
||||
|
||||
@ -80,7 +80,7 @@ namespace Video
|
||||
{
|
||||
void *Buffer = nullptr;
|
||||
uint32_t Width, Height;
|
||||
uint64_t Size;
|
||||
size_t Size;
|
||||
uint32_t Color;
|
||||
uint32_t CursorX, CursorY;
|
||||
long Checksum;
|
||||
@ -107,7 +107,7 @@ namespace Video
|
||||
debug("No width and height specified, using %ldx%lld", Width, Height);
|
||||
}
|
||||
|
||||
uint64_t Size = this->framebuffer.Pitch * Height;
|
||||
size_t Size = this->framebuffer.Pitch * Height;
|
||||
if (!this->Buffers[Index])
|
||||
{
|
||||
if (this->Buffers[Index]->Checksum != 0xDEAD5C9EE7)
|
||||
@ -160,7 +160,7 @@ namespace Video
|
||||
X = this->Buffers[Index]->Width - 1;
|
||||
if (Y >= this->Buffers[Index]->Height)
|
||||
Y = this->Buffers[Index]->Height - 1;
|
||||
uint32_t *Pixel = (uint32_t *)((uint64_t)this->Buffers[Index]->Buffer + (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8));
|
||||
uint32_t *Pixel = (uint32_t *)((uintptr_t)this->Buffers[Index]->Buffer + (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8));
|
||||
*Pixel = Color;
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ namespace Video
|
||||
{
|
||||
if (X >= this->Buffers[Index]->Width || Y >= this->Buffers[Index]->Height)
|
||||
return 0;
|
||||
uint32_t *Pixel = (uint32_t *)((uint64_t)this->Buffers[Index]->Buffer + (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8));
|
||||
uint32_t *Pixel = (uint32_t *)((uintptr_t)this->Buffers[Index]->Buffer + (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8));
|
||||
return *Pixel;
|
||||
}
|
||||
|
||||
|
@ -58,17 +58,17 @@ namespace Driver
|
||||
unsigned long DriverUIDs = 0;
|
||||
|
||||
DriverCode CallDriverEntryPoint(void *fex, void *KAPIAddress);
|
||||
DriverCode DriverLoadBindPCI(void *DrvExtHdr, uint64_t DriverAddress, uint64_t Size, bool IsElf = false);
|
||||
DriverCode DriverLoadBindInterrupt(void *DrvExtHdr, uint64_t DriverAddress, uint64_t Size, bool IsElf = false);
|
||||
DriverCode DriverLoadBindInput(void *DrvExtHdr, uint64_t DriverAddress, uint64_t Size, bool IsElf = false);
|
||||
DriverCode DriverLoadBindProcess(void *DrvExtHdr, uint64_t DriverAddress, uint64_t Size, bool IsElf = false);
|
||||
DriverCode DriverLoadBindPCI(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf = false);
|
||||
DriverCode DriverLoadBindInterrupt(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf = false);
|
||||
DriverCode DriverLoadBindInput(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf = false);
|
||||
DriverCode DriverLoadBindProcess(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf = false);
|
||||
|
||||
public:
|
||||
Vector<DriverFile *> GetDrivers() { return Drivers; }
|
||||
void UnloadAllDrivers();
|
||||
bool UnloadDriver(unsigned long DUID);
|
||||
int IOCB(unsigned long DUID, /* KernelCallback */ void *KCB);
|
||||
DriverCode LoadDriver(uint64_t DriverAddress, uint64_t Size);
|
||||
DriverCode LoadDriver(uintptr_t DriverAddress, size_t Size);
|
||||
DriverCode StartDrivers();
|
||||
Driver();
|
||||
~Driver();
|
||||
|
@ -20,24 +20,24 @@ namespace FileSystem
|
||||
|
||||
struct FileSystemNode;
|
||||
|
||||
typedef uint64_t (*OperationMount)(const char *, unsigned long, const void *);
|
||||
typedef uint64_t (*OperationUmount)(int);
|
||||
typedef uint64_t (*OperationRead)(FileSystemNode *Node, uint64_t Offset, uint64_t Size, uint8_t *Buffer);
|
||||
typedef uint64_t (*OperationWrite)(FileSystemNode *Node, uint64_t Offset, uint64_t Size, uint8_t *Buffer);
|
||||
typedef size_t (*OperationMount)(const char *, unsigned long, const void *);
|
||||
typedef size_t (*OperationUmount)(int);
|
||||
typedef size_t (*OperationRead)(FileSystemNode *Node, size_t Offset, size_t Size, uint8_t *Buffer);
|
||||
typedef size_t (*OperationWrite)(FileSystemNode *Node, size_t Offset, size_t Size, uint8_t *Buffer);
|
||||
typedef void (*OperationOpen)(FileSystemNode *Node, uint8_t Mode, uint8_t Flags);
|
||||
typedef void (*OperationClose)(FileSystemNode *Node);
|
||||
typedef uint64_t (*OperationSync)(void);
|
||||
typedef size_t (*OperationSync)(void);
|
||||
typedef void (*OperationCreate)(FileSystemNode *Node, char *Name, uint16_t NameLength);
|
||||
typedef void (*OperationMkdir)(FileSystemNode *Node, char *Name, uint16_t NameLength);
|
||||
|
||||
#define MountFSFunction(name) uint64_t name(const char *unknown0, unsigned long unknown1, const uint8_t *unknown2)
|
||||
#define UMountFSFunction(name) uint64_t name(int unknown0)
|
||||
#define MountFSFunction(name) size_t name(const char *unknown0, unsigned long unknown1, const uint8_t *unknown2)
|
||||
#define UMountFSFunction(name) size_t name(int unknown0)
|
||||
|
||||
#define ReadFSFunction(name) uint64_t name(FileSystem::FileSystemNode *Node, uint64_t Offset, uint64_t Size, uint8_t *Buffer)
|
||||
#define WriteFSFunction(name) uint64_t name(FileSystem::FileSystemNode *Node, uint64_t Offset, uint64_t Size, uint8_t *Buffer)
|
||||
#define ReadFSFunction(name) size_t name(FileSystem::FileSystemNode *Node, size_t Offset, size_t Size, uint8_t *Buffer)
|
||||
#define WriteFSFunction(name) size_t name(FileSystem::FileSystemNode *Node, size_t Offset, size_t Size, uint8_t *Buffer)
|
||||
#define OpenFSFunction(name) void name(FileSystem::FileSystemNode *Node, uint8_t Mode, uint8_t Flags)
|
||||
#define CloseFSFunction(name) void name(FileSystem::FileSystemNode *Node)
|
||||
#define SyncFSFunction(name) uint64_t name(void)
|
||||
#define SyncFSFunction(name) size_t name(void)
|
||||
#define CreateFSFunction(name) void name(FileSystem::FileSystemNode *Node, char *Name, uint16_t NameLength)
|
||||
#define MkdirFSFunction(name) void name(FileSystem::FileSystemNode *Node, char *Name, uint16_t NameLength)
|
||||
|
||||
@ -108,10 +108,10 @@ namespace FileSystem
|
||||
uint64_t IndexNode = 0;
|
||||
uint64_t Mask = 0;
|
||||
uint64_t Mode = 0;
|
||||
uint64_t Flags = NodeFlags::FS_ERROR;
|
||||
int Flags = NodeFlags::FS_ERROR;
|
||||
uint64_t UserIdentifier = 0, GroupIdentifier = 0;
|
||||
uint64_t Address = 0;
|
||||
uint64_t Length = 0;
|
||||
uintptr_t Address = 0;
|
||||
size_t Length = 0;
|
||||
FileSystemNode *Parent = nullptr;
|
||||
FileSystemOperations *Operator = nullptr;
|
||||
/* For root node:
|
||||
@ -153,8 +153,8 @@ namespace FileSystem
|
||||
FILE *Mount(FileSystemOperations *Operator, const char *Path);
|
||||
FileStatus Unmount(FILE *File);
|
||||
FILE *Open(const char *Path, FileSystemNode *Parent = nullptr);
|
||||
uint64_t Read(FILE *File, uint64_t Offset, uint8_t *Buffer, uint64_t Size);
|
||||
uint64_t Write(FILE *File, uint64_t Offset, uint8_t *Buffer, uint64_t Size);
|
||||
size_t Read(FILE *File, size_t Offset, uint8_t *Buffer, size_t Size);
|
||||
size_t Write(FILE *File, size_t Offset, uint8_t *Buffer, size_t Size);
|
||||
FileStatus Close(FILE *File);
|
||||
FileSystemNode *CreateRoot(FileSystemOperations *Operator, const char *RootName);
|
||||
FileSystemNode *Create(FileSystemNode *Parent, const char *Path);
|
||||
|
@ -23,7 +23,7 @@ namespace FileSystem
|
||||
uint32_t length;
|
||||
};
|
||||
|
||||
Initrd(uint64_t Address);
|
||||
Initrd(uintptr_t Address);
|
||||
~Initrd();
|
||||
};
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ namespace FileSystem
|
||||
class FB
|
||||
{
|
||||
public:
|
||||
void SetFrameBufferData(uint64_t Address, uint64_t Size, uint32_t Width, uint32_t Height, uint32_t PixelsPerScanLine);
|
||||
void SetFrameBufferData(uintptr_t Address, size_t Size, uint32_t Width, uint32_t Height, uint32_t PixelsPerScanLine);
|
||||
FB();
|
||||
~FB();
|
||||
};
|
||||
|
@ -44,7 +44,7 @@ namespace FileSystem
|
||||
private:
|
||||
uint32_t getsize(const char *s)
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
uint32_t ret = 0;
|
||||
while (*s)
|
||||
{
|
||||
ret *= 8;
|
||||
@ -63,7 +63,7 @@ namespace FileSystem
|
||||
}
|
||||
|
||||
public:
|
||||
USTAR(uint64_t Address, Virtual *vfs);
|
||||
USTAR(uintptr_t Address, Virtual *vfs);
|
||||
~USTAR();
|
||||
};
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ extern "C"
|
||||
{
|
||||
asmv("" ::
|
||||
: "memory");
|
||||
uint8_t Result = *(volatile uint8_t *)Address;
|
||||
uint8_t Result = *(volatile uint8_t *)(uintptr_t)Address;
|
||||
asmv("" ::
|
||||
: "memory");
|
||||
return Result;
|
||||
@ -71,7 +71,7 @@ extern "C"
|
||||
{
|
||||
asmv("" ::
|
||||
: "memory");
|
||||
uint16_t Result = *(volatile uint16_t *)Address;
|
||||
uint16_t Result = *(volatile uint16_t *)(uintptr_t)Address;
|
||||
asmv("" ::
|
||||
: "memory");
|
||||
return Result;
|
||||
@ -81,7 +81,7 @@ extern "C"
|
||||
{
|
||||
asmv("" ::
|
||||
: "memory");
|
||||
uint32_t Result = *(volatile uint32_t *)Address;
|
||||
uint32_t Result = *(volatile uint32_t *)(uintptr_t)Address;
|
||||
asmv("" ::
|
||||
: "memory");
|
||||
return Result;
|
||||
@ -91,7 +91,7 @@ extern "C"
|
||||
{
|
||||
asmv("" ::
|
||||
: "memory");
|
||||
uint64_t Result = *(volatile uint64_t *)Address;
|
||||
uint64_t Result = *(volatile uint64_t *)(uintptr_t)Address;
|
||||
asmv("" ::
|
||||
: "memory");
|
||||
return Result;
|
||||
|
@ -13,7 +13,7 @@ class LockClass
|
||||
uint64_t LockData = 0x0;
|
||||
const char *CurrentHolder = "(nul)";
|
||||
const char *AttemptingToGet = "(nul)";
|
||||
uint64_t Count = 0;
|
||||
size_t Count = 0;
|
||||
long Core = 0;
|
||||
};
|
||||
void DeadLock(SpinLockData Lock);
|
||||
|
@ -11,7 +11,7 @@ START_EXTERNC
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t size; // Size of input in bytes
|
||||
size_t size; // Size of input in bytes
|
||||
uint32_t buffer[4]; // Current accumulation of hash
|
||||
uint8_t input[64]; // Input to be used in the next step
|
||||
uint8_t digest[16]; // Result of algorithm
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern uint64_t _kernel_start, _kernel_end;
|
||||
extern uint64_t _kernel_text_end, _kernel_data_end, _kernel_rodata_end;
|
||||
extern uintptr_t _kernel_start, _kernel_end;
|
||||
extern uintptr_t _kernel_text_end, _kernel_data_end, _kernel_rodata_end;
|
||||
|
||||
// kilobyte
|
||||
#define TO_KB(d) (d / 1024)
|
||||
@ -177,7 +177,7 @@ namespace Memory
|
||||
uint64_t raw;
|
||||
|
||||
/** @brief Set Address */
|
||||
void SetAddress(uint64_t _Address)
|
||||
void SetAddress(uintptr_t _Address)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
@ -195,7 +195,7 @@ namespace Memory
|
||||
}
|
||||
|
||||
/** @brief Get Address */
|
||||
uint64_t GetAddress()
|
||||
uintptr_t GetAddress()
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
@ -232,7 +232,7 @@ namespace Memory
|
||||
uint64_t raw;
|
||||
|
||||
/** @brief Set PageTableEntryPtr address */
|
||||
void SetAddress(uint64_t _Address)
|
||||
void SetAddress(uintptr_t _Address)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
@ -250,7 +250,7 @@ namespace Memory
|
||||
}
|
||||
|
||||
/** @brief Get PageTableEntryPtr address */
|
||||
uint64_t GetAddress()
|
||||
uintptr_t GetAddress()
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
@ -287,7 +287,7 @@ namespace Memory
|
||||
uint64_t raw;
|
||||
|
||||
/** @brief Set PageDirectoryEntryPtr address */
|
||||
void SetAddress(uint64_t _Address)
|
||||
void SetAddress(uintptr_t _Address)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
@ -305,7 +305,7 @@ namespace Memory
|
||||
}
|
||||
|
||||
/** @brief Get PageDirectoryEntryPtr address */
|
||||
uint64_t GetAddress()
|
||||
uintptr_t GetAddress()
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
@ -342,7 +342,7 @@ namespace Memory
|
||||
uint64_t raw;
|
||||
|
||||
/** @brief Set PageDirectoryPointerTableEntryPtr address */
|
||||
void SetAddress(uint64_t _Address)
|
||||
void SetAddress(uintptr_t _Address)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
_Address &= 0x000000FFFFFFFFFF;
|
||||
@ -360,7 +360,7 @@ namespace Memory
|
||||
}
|
||||
|
||||
/** @brief Get PageDirectoryPointerTableEntryPtr address */
|
||||
uint64_t GetAddress()
|
||||
uintptr_t GetAddress()
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
return (this->raw & 0x000FFFFFFFFFF000) >> 12;
|
||||
@ -400,9 +400,9 @@ namespace Memory
|
||||
Bitmap PageBitmap;
|
||||
|
||||
void ReservePage(void *Address);
|
||||
void ReservePages(void *Address, uint64_t PageCount);
|
||||
void ReservePages(void *Address, size_t PageCount);
|
||||
void UnreservePage(void *Address);
|
||||
void UnreservePages(void *Address, uint64_t PageCount);
|
||||
void UnreservePages(void *Address, size_t PageCount);
|
||||
|
||||
public:
|
||||
Bitmap GetPageBitmap() { return PageBitmap; }
|
||||
@ -447,7 +447,7 @@ namespace Memory
|
||||
* @return true if swap was successful
|
||||
* @return false if swap was unsuccessful
|
||||
*/
|
||||
bool SwapPages(void *Address, uint64_t PageCount);
|
||||
bool SwapPages(void *Address, size_t PageCount);
|
||||
/**
|
||||
* @brief Unswap page
|
||||
*
|
||||
@ -464,7 +464,7 @@ namespace Memory
|
||||
* @return true if unswap was successful
|
||||
* @return false if unswap was unsuccessful
|
||||
*/
|
||||
bool UnswapPages(void *Address, uint64_t PageCount);
|
||||
bool UnswapPages(void *Address, size_t PageCount);
|
||||
|
||||
/**
|
||||
* @brief Lock page
|
||||
@ -478,7 +478,7 @@ namespace Memory
|
||||
* @param Address Address of the pages
|
||||
* @param PageCount Number of pages
|
||||
*/
|
||||
void LockPages(void *Address, uint64_t PageCount);
|
||||
void LockPages(void *Address, size_t PageCount);
|
||||
|
||||
/**
|
||||
* @brief Request page
|
||||
@ -492,7 +492,7 @@ namespace Memory
|
||||
* @param PageCount Number of pages
|
||||
* @return void* Allocated pages address
|
||||
*/
|
||||
void *RequestPages(uint64_t Count);
|
||||
void *RequestPages(size_t Count);
|
||||
/**
|
||||
* @brief Free page
|
||||
*
|
||||
@ -505,7 +505,7 @@ namespace Memory
|
||||
* @param Address Address of the pages
|
||||
* @param PageCount Number of pages
|
||||
*/
|
||||
void FreePages(void *Address, uint64_t Count);
|
||||
void FreePages(void *Address, size_t Count);
|
||||
/** @brief Do not use. */
|
||||
void Init(BootInfo *Info);
|
||||
/** @brief Do not use. */
|
||||
@ -524,11 +524,11 @@ namespace Memory
|
||||
class PageMapIndexer
|
||||
{
|
||||
public:
|
||||
uint64_t PMLIndex = 0;
|
||||
uint64_t PDPTEIndex = 0;
|
||||
uint64_t PDEIndex = 0;
|
||||
uint64_t PTEIndex = 0;
|
||||
PageMapIndexer(uint64_t VirtualAddress);
|
||||
uintptr_t PMLIndex = 0;
|
||||
uintptr_t PDPTEIndex = 0;
|
||||
uintptr_t PDEIndex = 0;
|
||||
uintptr_t PTEIndex = 0;
|
||||
PageMapIndexer(uintptr_t VirtualAddress);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -558,7 +558,7 @@ namespace Memory
|
||||
* @param PageCount Number of pages.
|
||||
* @param Flags Flags of the page. Check PTFlag enum.
|
||||
*/
|
||||
void Map(void *VirtualAddress, void *PhysicalAddress, uint64_t PageCount, uint64_t Flags);
|
||||
void Map(void *VirtualAddress, void *PhysicalAddress, size_t PageCount, uint64_t Flags);
|
||||
|
||||
/**
|
||||
* @brief Unmap page.
|
||||
@ -573,7 +573,7 @@ namespace Memory
|
||||
* @param VirtualAddress First virtual address of the page.
|
||||
* @param PageCount Number of pages.
|
||||
*/
|
||||
void Unmap(void *VirtualAddress, uint64_t PageCount);
|
||||
void Unmap(void *VirtualAddress, size_t PageCount);
|
||||
|
||||
/**
|
||||
* @brief Remap page.
|
||||
@ -619,7 +619,7 @@ namespace Memory
|
||||
/** @brief For general info */
|
||||
void *GetStackPhysicalTop() { return StackPhyiscalTop; }
|
||||
/** @brief Called by exception handler */
|
||||
bool Expand(uint64_t FaultAddress);
|
||||
bool Expand(uintptr_t FaultAddress);
|
||||
/**
|
||||
* @brief Construct a new Stack Guard object
|
||||
* @param User Stack for user mode?
|
||||
@ -640,7 +640,7 @@ namespace Memory
|
||||
struct AllocatedPages
|
||||
{
|
||||
void *Address;
|
||||
uint64_t PageCount;
|
||||
size_t PageCount;
|
||||
};
|
||||
|
||||
Vector<AllocatedPages> AllocatedPagesList;
|
||||
@ -648,8 +648,8 @@ namespace Memory
|
||||
public:
|
||||
uint64_t GetAllocatedMemorySize();
|
||||
|
||||
void *RequestPages(uint64_t Count);
|
||||
void FreePages(void *Address, uint64_t Count);
|
||||
void *RequestPages(size_t Count);
|
||||
void FreePages(void *Address, size_t Count);
|
||||
|
||||
Tracker(PageTable4 *PageTable = nullptr);
|
||||
~Tracker();
|
||||
@ -686,9 +686,9 @@ extern Memory::PageTable4 *UserspaceKernelOnlyPageTable;
|
||||
|
||||
extern void *KPT;
|
||||
|
||||
EXTERNC void *HeapMalloc(uint64_t Size);
|
||||
EXTERNC void *HeapCalloc(uint64_t n, uint64_t Size);
|
||||
EXTERNC void *HeapRealloc(void *Address, uint64_t Size);
|
||||
EXTERNC void *HeapMalloc(size_t Size);
|
||||
EXTERNC void *HeapCalloc(size_t n, size_t Size);
|
||||
EXTERNC void *HeapRealloc(void *Address, size_t Size);
|
||||
EXTERNC void HeapFree(void *Address);
|
||||
|
||||
#define kmalloc(Size) HeapMalloc(Size)
|
||||
|
@ -129,7 +129,7 @@ namespace PCI
|
||||
|
||||
struct DeviceConfig
|
||||
{
|
||||
uint64_t BaseAddress;
|
||||
uintptr_t BaseAddress;
|
||||
uint16_t PCISegGroup;
|
||||
uint8_t StartBus;
|
||||
uint8_t EndBus;
|
||||
@ -143,9 +143,9 @@ namespace PCI
|
||||
|
||||
public:
|
||||
Vector<PCIDeviceHeader *> &GetDevices() { return Devices; }
|
||||
void EnumerateFunction(uint64_t DeviceAddress, uint64_t Function);
|
||||
void EnumerateDevice(uint64_t BusAddress, uint64_t Device);
|
||||
void EnumerateBus(uint64_t BaseAddress, uint64_t Bus);
|
||||
void EnumerateFunction(uintptr_t DeviceAddress, uint64_t Function);
|
||||
void EnumerateDevice(uintptr_t BusAddress, uint64_t Device);
|
||||
void EnumerateBus(uintptr_t BaseAddress, uint64_t Bus);
|
||||
Vector<PCIDeviceHeader *> FindPCIDevice(uint8_t Class, uint8_t Subclass, uint8_t ProgIF);
|
||||
Vector<PCIDeviceHeader *> FindPCIDevice(int VendorID, int DeviceID);
|
||||
|
||||
|
@ -23,9 +23,9 @@ struct CPUData
|
||||
/** @brief Used by syscall handler */
|
||||
uint8_t *SystemCallStack; /* gs+0x0 */
|
||||
/** @brief Used by syscall handler */
|
||||
uint64_t TempStack; /* gs+0x8 */
|
||||
uintptr_t TempStack; /* gs+0x8 */
|
||||
/** @brief Used by CPU */
|
||||
uint64_t Stack;
|
||||
uintptr_t Stack;
|
||||
/** @brief CPU ID. */
|
||||
long ID;
|
||||
/** @brief Local CPU error code. */
|
||||
|
@ -8,17 +8,17 @@ namespace SymbolResolver
|
||||
private:
|
||||
struct SymbolTable
|
||||
{
|
||||
uint64_t Address;
|
||||
uintptr_t Address;
|
||||
char *FunctionName;
|
||||
};
|
||||
|
||||
SymbolTable SymTable[0x10000];
|
||||
uint64_t TotalEntries = 0;
|
||||
uintptr_t TotalEntries = 0;
|
||||
|
||||
public:
|
||||
Symbols(uint64_t ImageAddress);
|
||||
Symbols(uintptr_t ImageAddress);
|
||||
~Symbols();
|
||||
const char *GetSymbolFromAddress(uint64_t Address);
|
||||
const char *GetSymbolFromAddress(uintptr_t Address);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,14 @@ typedef struct SyscallsFrame
|
||||
uint64_t rbp, rdi, rsi, rdx, rcx, rbx, rax;
|
||||
uint64_t InterruptNumber, ErrorCode, rip, cs, rflags, rsp, ss;
|
||||
#elif defined(__i386__)
|
||||
uint64_t ebp, edi, esi, edx, ecx, ebx, eax;
|
||||
uint64_t InterruptNumber, ErrorCode, eip, cs, eflags, esp, ss;
|
||||
uint32_t ebp, edi, esi, edx, ecx, ebx, eax;
|
||||
uint32_t InterruptNumber, ErrorCode, eip, cs, eflags, esp, ss;
|
||||
#elif defined(__aarch64__)
|
||||
#endif
|
||||
} SyscallsFrame;
|
||||
|
||||
uint64_t HandleNativeSyscalls(SyscallsFrame *Frame);
|
||||
uint64_t HandleLinuxSyscalls(SyscallsFrame *Frame);
|
||||
uintptr_t HandleNativeSyscalls(SyscallsFrame *Frame);
|
||||
uintptr_t HandleLinuxSyscalls(SyscallsFrame *Frame);
|
||||
|
||||
/**
|
||||
* @brief Initialize syscalls for the current CPU. (Function is available on x32, x64 & aarch64)
|
||||
|
@ -15,10 +15,10 @@
|
||||
namespace Tasking
|
||||
{
|
||||
typedef unsigned long IP;
|
||||
typedef unsigned long IPOffset;
|
||||
typedef __UINTPTR_TYPE__ IPOffset;
|
||||
typedef unsigned long UPID;
|
||||
typedef unsigned long UTID;
|
||||
typedef unsigned long Token;
|
||||
typedef __UINTPTR_TYPE__ Token;
|
||||
|
||||
enum TaskArchitecture
|
||||
{
|
||||
@ -165,7 +165,7 @@ namespace Tasking
|
||||
TaskInfo Info;
|
||||
Vector<TCB *> Threads;
|
||||
Vector<PCB *> Children;
|
||||
HashMap<InterProcessCommunication::IPCPort, uint64_t> *IPCHandles;
|
||||
HashMap<InterProcessCommunication::IPCPort, uintptr_t> *IPCHandles;
|
||||
Memory::PageTable4 *PageTable;
|
||||
SymbolResolver::Symbols *ELFSymbolTable;
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ typedef __builtin_va_list va_list;
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v, l) __builtin_va_arg(v, l)
|
||||
|
||||
#define ALIGN_UP(x, align) ((__typeof__(x))(((uint64_t)(x) + ((align)-1)) & (~((align)-1))))
|
||||
#define ALIGN_UP(x, align) ((__typeof__(x))(((uintptr_t)(x) + ((align)-1)) & (~((align)-1))))
|
||||
#define ALIGN_DOWN(x, align) ((__typeof__(x))((x) & (~((align)-1))))
|
||||
|
||||
#define offsetof(type, member) __builtin_offsetof(type, member)
|
||||
@ -107,6 +107,7 @@ typedef __INT8_TYPE__ int8_t;
|
||||
typedef __INT16_TYPE__ int16_t;
|
||||
typedef __INT32_TYPE__ int32_t;
|
||||
typedef __INT64_TYPE__ int64_t;
|
||||
|
||||
typedef __UINT8_TYPE__ uint8_t;
|
||||
typedef __UINT16_TYPE__ uint16_t;
|
||||
typedef __UINT32_TYPE__ uint32_t;
|
||||
@ -116,6 +117,7 @@ typedef __INT_LEAST8_TYPE__ int_least8_t;
|
||||
typedef __INT_LEAST16_TYPE__ int_least16_t;
|
||||
typedef __INT_LEAST32_TYPE__ int_least32_t;
|
||||
typedef __INT_LEAST64_TYPE__ int_least64_t;
|
||||
|
||||
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
|
||||
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
|
||||
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
|
||||
@ -125,6 +127,7 @@ typedef __INT_FAST8_TYPE__ int_fast8_t;
|
||||
typedef __INT_FAST16_TYPE__ int_fast16_t;
|
||||
typedef __INT_FAST32_TYPE__ int_fast32_t;
|
||||
typedef __INT_FAST64_TYPE__ int_fast64_t;
|
||||
|
||||
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
|
||||
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
|
||||
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
|
||||
@ -138,6 +141,11 @@ typedef __UINTMAX_TYPE__ uintmax_t;
|
||||
|
||||
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
// typedef __WCHAR_TYPE__ wchar_t;
|
||||
typedef __WINT_TYPE__ wint_t;
|
||||
typedef __SIG_ATOMIC_TYPE__ sig_atomic_t;
|
||||
// TODO: ssize_t
|
||||
typedef intptr_t ssize_t;
|
||||
|
||||
#define INT8_MAX __INT8_MAX__
|
||||
#define INT8_MIN (-INT8_MAX - 1)
|
||||
|
@ -6,8 +6,8 @@ template <class T>
|
||||
class Vector
|
||||
{
|
||||
private:
|
||||
uint64_t VectorSize = 0;
|
||||
uint64_t VectorCapacity = 0;
|
||||
size_t VectorSize = 0;
|
||||
size_t VectorCapacity = 0;
|
||||
T *VectorBuffer = nullptr;
|
||||
|
||||
public:
|
||||
@ -23,7 +23,7 @@ public:
|
||||
VectorBuffer = 0;
|
||||
}
|
||||
|
||||
__no_instrument_function Vector(uint64_t Size)
|
||||
__no_instrument_function Vector(size_t Size)
|
||||
{
|
||||
VectorCapacity = Size;
|
||||
VectorSize = Size;
|
||||
@ -33,7 +33,7 @@ public:
|
||||
VectorBuffer = new T[Size];
|
||||
}
|
||||
|
||||
__no_instrument_function Vector(uint64_t Size, const T &Initial)
|
||||
__no_instrument_function Vector(size_t Size, const T &Initial)
|
||||
{
|
||||
VectorSize = Size;
|
||||
VectorCapacity = Size;
|
||||
@ -41,7 +41,7 @@ public:
|
||||
debug("VECTOR INIT: Vector( %lld %llx )", Size, Initial);
|
||||
#endif
|
||||
VectorBuffer = new T[Size];
|
||||
for (uint64_t i = 0; i < Size; i++)
|
||||
for (size_t i = 0; i < Size; i++)
|
||||
VectorBuffer[i] = Initial;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public:
|
||||
debug("VECTOR INIT: Vector( <vector> )->Size: %lld", VectorSize);
|
||||
#endif
|
||||
VectorBuffer = new T[VectorSize];
|
||||
for (uint64_t i = 0; i < VectorSize; i++)
|
||||
for (size_t i = 0; i < VectorSize; i++)
|
||||
VectorBuffer[i] = Vector.VectorBuffer[i];
|
||||
}
|
||||
|
||||
@ -65,21 +65,21 @@ public:
|
||||
delete[] VectorBuffer;
|
||||
}
|
||||
|
||||
__no_instrument_function void remove(uint64_t Position)
|
||||
__no_instrument_function void remove(size_t Position)
|
||||
{
|
||||
if (Position >= VectorSize)
|
||||
return;
|
||||
memset(&*(VectorBuffer + Position), 0, sizeof(T));
|
||||
for (uint64_t i = 0; i < VectorSize - 1; i++)
|
||||
for (size_t i = 0; i < VectorSize - 1; i++)
|
||||
{
|
||||
*(VectorBuffer + Position + i) = *(VectorBuffer + Position + i + 1);
|
||||
}
|
||||
VectorSize--;
|
||||
}
|
||||
|
||||
__no_instrument_function uint64_t capacity() const { return VectorCapacity; }
|
||||
__no_instrument_function size_t capacity() const { return VectorCapacity; }
|
||||
|
||||
__no_instrument_function uint64_t size() const { return VectorSize; }
|
||||
__no_instrument_function size_t size() const { return VectorSize; }
|
||||
|
||||
__no_instrument_function bool empty() const;
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
{
|
||||
if (VectorSize <= 1)
|
||||
return;
|
||||
for (uint64_t i = 0, j = VectorSize - 1; i < j; i++, j--)
|
||||
for (size_t i = 0, j = VectorSize - 1; i < j; i++, j--)
|
||||
{
|
||||
T c = *(VectorBuffer + i);
|
||||
*(VectorBuffer + i) = *(VectorBuffer + j);
|
||||
@ -112,7 +112,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
__no_instrument_function void reserve(uint64_t Capacity)
|
||||
__no_instrument_function void reserve(size_t Capacity)
|
||||
{
|
||||
if (VectorBuffer == 0)
|
||||
{
|
||||
@ -122,25 +122,25 @@ public:
|
||||
#ifdef DEBUG_MEM_ALLOCATION
|
||||
debug("VECTOR ALLOCATION: reverse( %lld )", Capacity);
|
||||
#endif
|
||||
T *Newbuffer = new T[Capacity];
|
||||
uint64_t _Size = Capacity < VectorSize ? Capacity : VectorSize;
|
||||
for (uint64_t i = 0; i < _Size; i++)
|
||||
Newbuffer[i] = VectorBuffer[i];
|
||||
T *NewBuffer = new T[Capacity];
|
||||
size_t _Size = Capacity < VectorSize ? Capacity : VectorSize;
|
||||
for (size_t i = 0; i < _Size; i++)
|
||||
NewBuffer[i] = VectorBuffer[i];
|
||||
VectorCapacity = Capacity;
|
||||
#ifdef DEBUG_MEM_ALLOCATION
|
||||
debug("VECTOR ALLOCATION: reverse( <Capacity> )->Buffer:~%lld", VectorBuffer);
|
||||
#endif
|
||||
delete[] VectorBuffer;
|
||||
VectorBuffer = Newbuffer;
|
||||
VectorBuffer = NewBuffer;
|
||||
}
|
||||
|
||||
__no_instrument_function void resize(uint64_t Size)
|
||||
__no_instrument_function void resize(size_t Size)
|
||||
{
|
||||
reserve(Size);
|
||||
VectorSize = Size;
|
||||
}
|
||||
|
||||
__no_instrument_function T &operator[](uint64_t Index) { return VectorBuffer[Index]; }
|
||||
__no_instrument_function T &operator[](size_t Index) { return VectorBuffer[Index]; }
|
||||
|
||||
__no_instrument_function Vector<T> &operator=(const Vector<T> &Vector)
|
||||
{
|
||||
@ -151,7 +151,7 @@ public:
|
||||
debug("VECTOR ALLOCATION: operator=( <vector> )->Size:%lld", VectorSize);
|
||||
#endif
|
||||
VectorBuffer = new T[VectorSize];
|
||||
for (uint64_t i = 0; i < VectorSize; i++)
|
||||
for (size_t i = 0; i < VectorSize; i++)
|
||||
VectorBuffer[i] = Vector.VectorBuffer[i];
|
||||
return *this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user