ReactOS  0.4.15-dev-1068-g467feb9
xboxdisk.c File Reference
#include <freeldr.h>
#include <hwide.h>
#include <debug.h>
Include dependency graph for xboxdisk.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (DISK)
 
VOID XboxDiskInit (BOOLEAN Init)
 
static PDEVICE_UNIT XboxDiskDriveNumberToDeviceUnit (UCHAR DriveNumber)
 
BOOLEAN XboxDiskReadLogicalSectors (IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
 
BOOLEAN XboxDiskGetDriveGeometry (UCHAR DriveNumber, PGEOMETRY Geometry)
 
ULONG XboxDiskGetCacheableBlockCount (UCHAR DriveNumber)
 

Variables

static PDEVICE_UNIT HardDrive = NULL
 
static PDEVICE_UNIT CdDrive = NULL
 
static BOOLEAN AtaInitialized = FALSE
 

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( DISK  )

◆ XboxDiskDriveNumberToDeviceUnit()

static PDEVICE_UNIT XboxDiskDriveNumberToDeviceUnit ( UCHAR  DriveNumber)
inlinestatic

Definition at line 63 of file xboxdisk.c.

64 {
65  /* Xbox has only 1 IDE controller and no floppy */
66  if (DriveNumber < 0x80 || (DriveNumber & 0x0F) >= 2)
67  return NULL;
68 
69  if (!AtaInitialized)
71 
72  /* HDD */
73  if ((DriveNumber == 0x80) && HardDrive)
74  return HardDrive;
75 
76  /* CD */
77  if (((DriveNumber & 0xF0) > 0x80) && CdDrive)
78  return CdDrive;
79 
80  return NULL;
81 }
#define TRUE
Definition: types.h:120
static BOOLEAN AtaInitialized
Definition: xboxdisk.c:21
static PDEVICE_UNIT CdDrive
Definition: xboxdisk.c:20
smooth NULL
Definition: ftsmooth.c:416
static PDEVICE_UNIT HardDrive
Definition: xboxdisk.c:19
VOID XboxDiskInit(BOOLEAN Init)
Definition: xboxdisk.c:26

Referenced by XboxDiskGetCacheableBlockCount(), XboxDiskGetDriveGeometry(), and XboxDiskReadLogicalSectors().

◆ XboxDiskGetCacheableBlockCount()

ULONG XboxDiskGetCacheableBlockCount ( UCHAR  DriveNumber)

Definition at line 122 of file xboxdisk.c.

123 {
124  PDEVICE_UNIT DeviceUnit;
125 
126  DeviceUnit = XboxDiskDriveNumberToDeviceUnit(DriveNumber);
127  if (!DeviceUnit)
128  return 1; // Unknown count.
129 
130  /*
131  * If LBA is supported then the block size will be 64 sectors (32k).
132  * If not then the block size is the size of one track.
133  */
134  if (DeviceUnit->Flags & ATA_DEVICE_LBA)
135  return 64;
136  else
137  return DeviceUnit->Sectors;
138 }
#define ATA_DEVICE_LBA
Definition: hwide.h:307
ULONG Sectors
Definition: hwide.h:296
static PDEVICE_UNIT XboxDiskDriveNumberToDeviceUnit(UCHAR DriveNumber)
Definition: xboxdisk.c:63
USHORT Flags
Definition: hwide.h:299

Referenced by MachInit().

◆ XboxDiskGetDriveGeometry()

BOOLEAN XboxDiskGetDriveGeometry ( UCHAR  DriveNumber,
PGEOMETRY  Geometry 
)

Definition at line 103 of file xboxdisk.c.

104 {
105  PDEVICE_UNIT DeviceUnit;
106 
107  TRACE("XboxDiskGetDriveGeometry(0x%x)\n", DriveNumber);
108 
109  DeviceUnit = XboxDiskDriveNumberToDeviceUnit(DriveNumber);
110  if (!DeviceUnit)
111  return FALSE;
112 
113  Geometry->Cylinders = DeviceUnit->Cylinders;
114  Geometry->Heads = DeviceUnit->Heads;
115  Geometry->Sectors = DeviceUnit->Sectors;
116  Geometry->BytesPerSector = DeviceUnit->SectorSize;
117 
118  return TRUE;
119 }
ULONG Cylinders
Definition: hwide.h:294
#define TRUE
Definition: types.h:120
ULONG Cylinders
Definition: disk.h:26
ULONG SectorSize
Definition: hwide.h:297
ULONG Heads
Definition: hwide.h:295
ULONG Sectors
Definition: hwide.h:296
#define FALSE
Definition: types.h:117
static PDEVICE_UNIT XboxDiskDriveNumberToDeviceUnit(UCHAR DriveNumber)
Definition: xboxdisk.c:63
ULONG Sectors
Definition: disk.h:28
#define TRACE(s)
Definition: solgame.cpp:4
ULONG BytesPerSector
Definition: disk.h:29
ULONG Heads
Definition: disk.h:27

Referenced by MachInit(), and XboxGetHarddiskConfigurationData().

◆ XboxDiskInit()

VOID XboxDiskInit ( BOOLEAN  Init)

Definition at line 26 of file xboxdisk.c.

27 {
28  UCHAR DetectedCount;
29  UCHAR UnitNumber;
30  PDEVICE_UNIT DeviceUnit = NULL;
31 
32  if (Init & !AtaInitialized)
33  {
34  /* Find first HDD and CD */
35  AtaInit(&DetectedCount);
36  for (UnitNumber = 0; UnitNumber <= DetectedCount; UnitNumber++)
37  {
38  DeviceUnit = AtaGetDevice(UnitNumber);
39  if (DeviceUnit)
40  {
41  if (DeviceUnit->Flags & ATA_DEVICE_ATAPI)
42  {
43  if (!CdDrive)
44  CdDrive = DeviceUnit;
45  }
46  else
47  {
48  if (!HardDrive)
49  HardDrive = DeviceUnit;
50  }
51  }
52  }
54  }
55  else
56  {
57  AtaFree();
58  }
59 }
#define TRUE
Definition: types.h:120
VOID AtaFree(VOID)
Definition: hwide.c:166
BOOLEAN AtaInit(OUT PUCHAR DetectedCount)
Definition: hwide.c:139
static BOOLEAN AtaInitialized
Definition: xboxdisk.c:21
static PDEVICE_UNIT CdDrive
Definition: xboxdisk.c:20
smooth NULL
Definition: ftsmooth.c:416
USHORT Flags
Definition: hwide.h:299
unsigned char UCHAR
Definition: xmlstorage.h:181
#define ATA_DEVICE_ATAPI
Definition: hwide.h:303
PDEVICE_UNIT AtaGetDevice(IN UCHAR UnitNumber)
Definition: hwide.c:178
static PDEVICE_UNIT HardDrive
Definition: xboxdisk.c:19

Referenced by XboxDiskDriveNumberToDeviceUnit(), and XboxPrepareForReactOS().

◆ XboxDiskReadLogicalSectors()

BOOLEAN XboxDiskReadLogicalSectors ( IN UCHAR  DriveNumber,
IN ULONGLONG  SectorNumber,
IN ULONG  SectorCount,
OUT PVOID  Buffer 
)

Definition at line 84 of file xboxdisk.c.

89 {
90  PDEVICE_UNIT DeviceUnit;
91 
92  TRACE("XboxDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n",
93  DriveNumber, SectorNumber, SectorCount, Buffer);
94 
95  DeviceUnit = XboxDiskDriveNumberToDeviceUnit(DriveNumber);
96  if (!DeviceUnit)
97  return FALSE;
98 
99  return AtaAtapiReadLogicalSectorsLBA(DeviceUnit, SectorNumber, SectorCount, Buffer);
100 }
#define FALSE
Definition: types.h:117
static PDEVICE_UNIT XboxDiskDriveNumberToDeviceUnit(UCHAR DriveNumber)
Definition: xboxdisk.c:63
BOOLEAN AtaAtapiReadLogicalSectorsLBA(IN OUT PDEVICE_UNIT DeviceUnit, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: hwide.c:187
Definition: bufpool.h:45
#define TRACE(s)
Definition: solgame.cpp:4
ULONG SectorCount
Definition: part_xbox.c:31

Referenced by MachInit().

Variable Documentation

◆ AtaInitialized

BOOLEAN AtaInitialized = FALSE
static

Definition at line 21 of file xboxdisk.c.

Referenced by XboxDiskDriveNumberToDeviceUnit(), and XboxDiskInit().

◆ CdDrive

PDEVICE_UNIT CdDrive = NULL
static

Definition at line 20 of file xboxdisk.c.

Referenced by XboxDiskDriveNumberToDeviceUnit(), and XboxDiskInit().

◆ HardDrive

PDEVICE_UNIT HardDrive = NULL
static

Definition at line 19 of file xboxdisk.c.

Referenced by XboxDiskDriveNumberToDeviceUnit(), and XboxDiskInit().