Avoid conflict with C++17 features std::byte by using uint8 type instead of byte

This commit is contained in:
Mounir IDRASSI
2024-06-12 12:30:04 +02:00
parent bf9f3ec4f0
commit 455a4f2176
132 changed files with 1032 additions and 1035 deletions
+29 -29
View File
@@ -19,7 +19,7 @@
#include "BootStrings.h"
byte SectorBuffer[TC_LB_SIZE];
uint8 SectorBuffer[TC_LB_SIZE];
#ifdef TC_BOOT_DEBUG_ENABLED
static bool SectorBufferInUse = false;
@@ -41,9 +41,9 @@ void ReleaseSectorBuffer ()
#endif
bool IsLbaSupported (byte drive)
bool IsLbaSupported (uint8 drive)
{
static byte CachedDrive = TC_INVALID_BIOS_DRIVE;
static uint8 CachedDrive = TC_INVALID_BIOS_DRIVE;
static bool CachedStatus;
uint16 result = 0;
@@ -68,7 +68,7 @@ ret:
}
void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs)
void PrintDiskError (BiosResult error, bool write, uint8 drive, const uint64 *sector, const ChsAddress *chs)
{
PrintEndl();
Print (write ? "Write" : "Read"); Print (" error:");
@@ -109,17 +109,17 @@ void PrintSectorCountInMB (const uint64 &sectorCount)
}
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent)
{
CheckStack();
byte cylinderLow = (byte) chs.Cylinder;
byte sector = chs.Sector;
sector |= byte (chs.Cylinder >> 2) & 0xc0;
byte function = write ? 0x03 : 0x02;
uint8 cylinderLow = (uint8) chs.Cylinder;
uint8 sector = chs.Sector;
sector |= uint8 (chs.Cylinder >> 2) & 0xc0;
uint8 function = write ? 0x03 : 0x02;
BiosResult result;
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
uint8 tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
do
{
@@ -159,20 +159,20 @@ BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffs
#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent)
{
uint16 codeSeg;
__asm mov codeSeg, cs
return ReadWriteSectors (write, codeSeg, (uint16) buffer, drive, chs, sectorCount, silent);
}
BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
BiosResult ReadSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent)
{
return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent);
}
#if 0
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
BiosResult WriteSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent)
{
return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent);
}
@@ -180,7 +180,7 @@ BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte s
#endif
static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
CheckStack();
@@ -202,10 +202,10 @@ static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte d
dapPacket.SectorCount = sectorCount;
dapPacket.Sector = sector;
byte function = write ? 0x43 : 0x42;
uint8 function = write ? 0x43 : 0x42;
BiosResult result;
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
uint8 tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
do
{
@@ -237,7 +237,7 @@ static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte d
}
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
BiosLbaPacket dapPacket;
dapPacket.Buffer = (uint32) buffer;
@@ -245,20 +245,20 @@ BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64
}
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
BiosLbaPacket dapPacket;
dapPacket.Buffer = ((uint32) bufferSegment << 16) | bufferOffset;
return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent);
}
BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, sector, sectorCount, silent);
}
BiosResult ReadSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
BiosResult ReadSectors (uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
BiosResult result;
uint16 codeSeg;
@@ -274,17 +274,17 @@ BiosResult ReadSectors (byte *buffer, byte drive, const uint64 &sector, uint16 s
}
BiosResult WriteSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
BiosResult WriteSectors (uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
return ReadWriteSectors (true, buffer, drive, sector, sectorCount, silent);
}
BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent)
BiosResult GetDriveGeometry (uint8 drive, DriveGeometry &geometry, bool silent)
{
CheckStack();
byte maxCylinderLow, maxHead, maxSector;
uint8 maxCylinderLow, maxHead, maxSector;
BiosResult result;
__asm
{
@@ -329,9 +329,9 @@ void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba
void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs)
{
chs.Sector = (byte) ((lba.LowPart % geometry.Sectors) + 1);
chs.Sector = (uint8) ((lba.LowPart % geometry.Sectors) + 1);
uint32 ch = lba.LowPart / geometry.Sectors;
chs.Head = (byte) (ch % geometry.Heads);
chs.Head = (uint8) (ch % geometry.Heads);
chs.Cylinder = (uint16) (ch / geometry.Heads);
}
@@ -349,7 +349,7 @@ void PartitionEntryMBRToPartition (const PartitionEntryMBR &partEntry, Partition
}
BiosResult ReadWriteMBR (bool write, byte drive, bool silent)
BiosResult ReadWriteMBR (bool write, uint8 drive, bool silent)
{
uint64 mbrSector;
mbrSector.HighPart = 0;
@@ -362,7 +362,7 @@ BiosResult ReadWriteMBR (bool write, byte drive, bool silent)
}
BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent)
BiosResult GetDrivePartitions (uint8 drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent)
{
Partition *followingPartition;
Partition tmpPartition;
@@ -419,7 +419,7 @@ BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t par
MBR *extMbr = (MBR *) SectorBuffer;
while (partitionArrayPos < partitionArrayCapacity &&
(result = ReadSectors ((byte *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess
(result = ReadSectors ((uint8 *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess
&& extMbr->Signature == 0xaa55)
{
if (extMbr->Partitions[0].SectorCountLBA > 0)
@@ -478,7 +478,7 @@ BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t par
}
bool GetActivePartition (byte drive)
bool GetActivePartition (uint8 drive)
{
size_t partCount;