mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 18:01:07 +00:00
[FREELDR] Whitespace improvements - no code changes
This commit is contained in:
parent
31aca248a1
commit
8c55fdd17c
|
@ -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;
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Note: much of this code was based on knowledge and/or code developed
|
* Note: much of this code was based on knowledge and/or code developed
|
||||||
* by the Xbox Linux group: http://www.xbox-linux.org
|
* by the Xbox Linux group: http://www.xbox-linux.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
|
@ -25,53 +25,53 @@ 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
|
||||||
XboxMemInit(VOID)
|
XboxMemInit(VOID)
|
||||||
{
|
{
|
||||||
UCHAR ControlRegion[TEST_SIZE];
|
UCHAR ControlRegion[TEST_SIZE];
|
||||||
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 */
|
||||||
|
|
||||||
InstalledMemoryMb = 64;
|
InstalledMemoryMb = 64;
|
||||||
memset(ControlRegion, TEST_PATTERN1, TEST_SIZE);
|
memset(ControlRegion, TEST_PATTERN1, TEST_SIZE);
|
||||||
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
|
||||||
{
|
{
|
||||||
InstalledMemoryMb = 128;
|
InstalledMemoryMb = 128;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set hardware for amount of memory detected */
|
/* Set hardware for amount of memory detected */
|
||||||
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, InstalledMemoryMb * 1024 * 1024 - 1);
|
WRITE_PORT_ULONG((ULONG*) 0xcfc, InstalledMemoryMb * 1024 * 1024 - 1);
|
||||||
|
|
||||||
AvailableMemoryMb = InstalledMemoryMb;
|
AvailableMemoryMb = InstalledMemoryMb;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREELDR_MEMORY_DESCRIPTOR XboxMemoryMap[2];
|
FREELDR_MEMORY_DESCRIPTOR XboxMemoryMap[2];
|
||||||
|
@ -79,40 +79,41 @@ FREELDR_MEMORY_DESCRIPTOR XboxMemoryMap[2];
|
||||||
PFREELDR_MEMORY_DESCRIPTOR
|
PFREELDR_MEMORY_DESCRIPTOR
|
||||||
XboxMemGetMemoryMap(ULONG *MemoryMapSize)
|
XboxMemGetMemoryMap(ULONG *MemoryMapSize)
|
||||||
{
|
{
|
||||||
/* Synthesize memory map */
|
/* Synthesize memory map */
|
||||||
/* Available RAM block */
|
|
||||||
XboxMemoryMap[0].BasePage = 0;
|
|
||||||
XboxMemoryMap[0].PageCount = AvailableMemoryMb * 1024 * 1024 / MM_PAGE_SIZE;
|
|
||||||
XboxMemoryMap[0].MemoryType = LoaderFree;
|
|
||||||
|
|
||||||
/* Video memory */
|
/* Available RAM block */
|
||||||
XboxMemoryMap[1].BasePage = AvailableMemoryMb * 1024 * 1024 / MM_PAGE_SIZE;
|
XboxMemoryMap[0].BasePage = 0;
|
||||||
XboxMemoryMap[1].PageCount = (InstalledMemoryMb - AvailableMemoryMb) * 1024 * 1024 / MM_PAGE_SIZE;
|
XboxMemoryMap[0].PageCount = AvailableMemoryMb * 1024 * 1024 / MM_PAGE_SIZE;
|
||||||
XboxMemoryMap[1].MemoryType = LoaderFirmwarePermanent;
|
XboxMemoryMap[0].MemoryType = LoaderFree;
|
||||||
|
|
||||||
*MemoryMapSize = 2;
|
/* Video memory */
|
||||||
return XboxMemoryMap;
|
XboxMemoryMap[1].BasePage = AvailableMemoryMb * 1024 * 1024 / MM_PAGE_SIZE;
|
||||||
|
XboxMemoryMap[1].PageCount = (InstalledMemoryMb - AvailableMemoryMb) * 1024 * 1024 / MM_PAGE_SIZE;
|
||||||
|
XboxMemoryMap[1].MemoryType = LoaderFirmwarePermanent;
|
||||||
|
|
||||||
|
*MemoryMapSize = 2;
|
||||||
|
return XboxMemoryMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 */
|
||||||
|
|
Loading…
Reference in a new issue