[FREELDR] Whitespace improvements - no code changes

This commit is contained in:
Stanislav Motylkov 2019-07-15 22:40:10 +03:00 committed by Hermès BÉLUSCA - MAÏTO
parent 31aca248a1
commit 8c55fdd17c
2 changed files with 57 additions and 56 deletions

View file

@ -433,21 +433,21 @@ XboxDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG Sect
ULONG StartSector; ULONG StartSector;
UCHAR Count; UCHAR Count;
if (DriveNumber < 0x80 || 2 <= (DriveNumber & 0x0f)) if (DriveNumber < 0x80 || (DriveNumber & 0x0f) >= 2)
{ {
/* Xbox has only 1 IDE controller and no floppy */ /* Xbox has only 1 IDE controller and no floppy */
WARN("Invalid drive number\n"); WARN("Invalid drive number\n");
return FALSE; return FALSE;
} }
if (UINT64_C(0) != ((SectorNumber + SectorCount) & UINT64_C(0xfffffffff0000000))) if (((SectorNumber + SectorCount) & UINT64_C(0xfffffffff0000000)) != UINT64_C(0))
{ {
FIXME("48bit LBA required but not implemented\n"); FIXME("48bit LBA required but not implemented\n");
return FALSE; return FALSE;
} }
StartSector = (ULONG) SectorNumber; StartSector = (ULONG) SectorNumber;
while (0 < SectorCount) while (SectorCount > 0)
{ {
Count = (SectorCount <= 255 ? (UCHAR)SectorCount : 255); Count = (SectorCount <= 255 ? (UCHAR)SectorCount : 255);
if (!XboxDiskPolledRead(XBOX_IDE_COMMAND_PORT, if (!XboxDiskPolledRead(XBOX_IDE_COMMAND_PORT,
@ -457,7 +457,7 @@ XboxDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG Sect
(StartSector >> 8) & 0xff, (StartSector >> 8) & 0xff,
(StartSector >> 16) & 0xff, (StartSector >> 16) & 0xff,
((StartSector >> 24) & 0x0f) | IDE_DH_LBA | ((StartSector >> 24) & 0x0f) | IDE_DH_LBA |
(0 == (DriveNumber & 0x0f) ? IDE_DH_DRV0 : IDE_DH_DRV1), ((DriveNumber & 0x0f) == 0 ? IDE_DH_DRV0 : IDE_DH_DRV1),
IDE_CMD_READ, IDE_CMD_READ,
Buffer)) Buffer))
{ {
@ -512,7 +512,7 @@ XboxDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
0, 0,
0, 0,
0, 0,
(0 == (DriveNumber & 0x0f) ? IDE_DH_DRV0 : IDE_DH_DRV1), ((DriveNumber & 0x0f) == 0 ? IDE_DH_DRV0 : IDE_DH_DRV1),
(Atapi ? IDE_CMD_IDENT_ATAPI_DRV : IDE_CMD_IDENT_ATA_DRV), (Atapi ? IDE_CMD_IDENT_ATAPI_DRV : IDE_CMD_IDENT_ATA_DRV),
(PUCHAR) &DrvParms)) (PUCHAR) &DrvParms))
{ {
@ -524,7 +524,7 @@ XboxDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Geometry->Heads = DrvParms.LogicalHeads; Geometry->Heads = DrvParms.LogicalHeads;
Geometry->Sectors = DrvParms.SectorsPerTrack; Geometry->Sectors = DrvParms.SectorsPerTrack;
if (! Atapi && 0 != (DrvParms.Capabilities & IDE_DRID_LBA_SUPPORTED)) if (!Atapi && (DrvParms.Capabilities & IDE_DRID_LBA_SUPPORTED) != 0)
{ {
/* LBA ATA drives always have a sector size of 512 */ /* LBA ATA drives always have a sector size of 512 */
Geometry->BytesPerSector = 512; Geometry->BytesPerSector = 512;

View file

@ -25,7 +25,7 @@ static ULONG InstalledMemoryMb = 0;
static ULONG AvailableMemoryMb = 0; static ULONG AvailableMemoryMb = 0;
#define TEST_SIZE 0x200 #define TEST_SIZE 0x200
#define TEST_PATTERN1 0xaa #define TEST_PATTERN1 0xAA
#define TEST_PATTERN2 0x55 #define TEST_PATTERN2 0x55
VOID VOID
@ -35,8 +35,8 @@ XboxMemInit(VOID)
PVOID MembaseTop = (PVOID)(64 * 1024 * 1024); PVOID MembaseTop = (PVOID)(64 * 1024 * 1024);
PVOID MembaseLow = (PVOID)0; PVOID MembaseLow = (PVOID)0;
(*(PULONG)(0xfd000000 + 0x100200)) = 0x03070103 ; (*(PULONG)(0xfd000000 + 0x100200)) = 0x03070103;
(*(PULONG)(0xfd000000 + 0x100204)) = 0x11448000 ; (*(PULONG)(0xfd000000 + 0x100204)) = 0x11448000;
WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84)); WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
WRITE_PORT_ULONG((ULONG*) 0xcfc, 0x7ffffff); /* Prep hardware for 128 Mb */ WRITE_PORT_ULONG((ULONG*) 0xcfc, 0x7ffffff); /* Prep hardware for 128 Mb */
@ -46,18 +46,18 @@ XboxMemInit(VOID)
memset(MembaseTop, TEST_PATTERN1, TEST_SIZE); memset(MembaseTop, TEST_PATTERN1, TEST_SIZE);
__wbinvd(); __wbinvd();
if (0 == memcmp(MembaseTop, ControlRegion, TEST_SIZE)) if (memcmp(MembaseTop, ControlRegion, TEST_SIZE) == 0)
{ {
/* Looks like there is memory .. maybe a 128MB box */ /* Looks like there is memory .. maybe a 128MB box */
memset(ControlRegion, TEST_PATTERN2, TEST_SIZE); memset(ControlRegion, TEST_PATTERN2, TEST_SIZE);
memset(MembaseTop, TEST_PATTERN2, TEST_SIZE); memset(MembaseTop, TEST_PATTERN2, TEST_SIZE);
__wbinvd(); __wbinvd();
if (0 == memcmp(MembaseTop, ControlRegion, TEST_SIZE)) if (memcmp(MembaseTop, ControlRegion, TEST_SIZE) == 0)
{ {
/* Definitely looks like there is memory */ /* Definitely looks like there is memory */
if (0 == memcmp(MembaseLow, ControlRegion, TEST_SIZE)) if (memcmp(MembaseLow, ControlRegion, TEST_SIZE) == 0)
{ {
/* Hell, we find the Test-string at 0x0 too ! */ /* Hell, we find the Test-string at 0x0 too! */
InstalledMemoryMb = 64; InstalledMemoryMb = 64;
} }
else else
@ -80,6 +80,7 @@ PFREELDR_MEMORY_DESCRIPTOR
XboxMemGetMemoryMap(ULONG *MemoryMapSize) XboxMemGetMemoryMap(ULONG *MemoryMapSize)
{ {
/* Synthesize memory map */ /* Synthesize memory map */
/* Available RAM block */ /* Available RAM block */
XboxMemoryMap[0].BasePage = 0; XboxMemoryMap[0].BasePage = 0;
XboxMemoryMap[0].PageCount = AvailableMemoryMb * 1024 * 1024 / MM_PAGE_SIZE; XboxMemoryMap[0].PageCount = AvailableMemoryMb * 1024 * 1024 / MM_PAGE_SIZE;
@ -97,13 +98,13 @@ XboxMemGetMemoryMap(ULONG *MemoryMapSize)
PVOID PVOID
XboxMemReserveMemory(ULONG MbToReserve) XboxMemReserveMemory(ULONG MbToReserve)
{ {
if (0 == InstalledMemoryMb) if (InstalledMemoryMb == 0)
{ {
/* Hmm, seems we're not initialized yet */ /* Hmm, seems we're not initialized yet */
XboxMemInit(); XboxMemInit();
} }
if (AvailableMemoryMb < MbToReserve) if (MbToReserve > AvailableMemoryMb)
{ {
/* Can't satisfy the request */ /* Can't satisfy the request */
return NULL; return NULL;
@ -112,7 +113,7 @@ XboxMemReserveMemory(ULONG MbToReserve)
AvailableMemoryMb -= MbToReserve; AvailableMemoryMb -= MbToReserve;
/* Top of available memory points to the space just reserved */ /* Top of available memory points to the space just reserved */
return (PVOID) (AvailableMemoryMb * 1024 * 1024); return (PVOID)(AvailableMemoryMb * 1024 * 1024);
} }
/* EOF */ /* EOF */