Fix type sizes

This commit is contained in:
Alex
2023-05-13 07:40:07 +03:00
parent 06e34ab57f
commit 816e5461c9
85 changed files with 655 additions and 422 deletions

View File

@ -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
{

View File

@ -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)

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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:

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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) */

View File

@ -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);
};
}

View File

@ -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);
};
}

View File

@ -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);

View File

@ -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);

View File

@ -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__

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -32,6 +32,8 @@ struct CPUArchData
CPU::x64::FXState *FPU;
/* TODO */
#elif defined(a32)
CPU::x32::FXState *FPU;
/* TODO */
#elif defined(aa64)
#endif
};

View File

@ -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);

View File

@ -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;