ReactOS 0.4.16-dev-122-g325d74c
hwide.h File Reference
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for hwide.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _IDENTIFY_DATA
 
struct  _DEVICE_UNIT
 

Macros

#define IDX_IO1_i_Data   0x00
 
#define IDX_IO1_i_Error   0x01
 
#define IDX_IO1_i_BlockCount   0x02
 
#define IDX_IO1_i_BlockNumber   0x03
 
#define IDX_IO1_i_CylinderLow   0x04
 
#define IDX_IO1_i_CylinderHigh   0x05
 
#define IDX_IO1_i_DriveSelect   0x06
 
#define IDX_IO1_i_Status   0x07
 
#define IDX_IO2_i_AltStatus   0x206
 
#define IDX_IO2_i_DriveAddress   0x207
 
#define IDX_IO1_o_Data   0x00
 
#define IDX_IO1_o_Feature   0x01
 
#define IDX_IO1_o_BlockCount   0x02
 
#define IDX_IO1_o_BlockNumber   0x03
 
#define IDX_IO1_o_CylinderLow   0x04
 
#define IDX_IO1_o_CylinderHigh   0x05
 
#define IDX_IO1_o_DriveSelect   0x06
 
#define IDX_IO1_o_Command   0x07
 
#define IDX_IO2_o_Control   0x206
 
#define IDX_ATAPI_IO1_i_Data   0x00
 
#define IDX_ATAPI_IO1_i_Error   0x01
 
#define IDX_ATAPI_IO1_i_InterruptReason   0x02
 
#define IDX_ATAPI_IO1_i_Unused1   0x03
 
#define IDX_ATAPI_IO1_i_ByteCountLow   0x04
 
#define IDX_ATAPI_IO1_i_ByteCountHigh   0x05
 
#define IDX_ATAPI_IO1_i_DriveSelect   0x06
 
#define IDX_ATAPI_IO1_i_Status   0x07
 
#define IDX_ATAPI_IO1_o_Data   0x00
 
#define IDX_ATAPI_IO1_o_Feature   0x01
 
#define IDX_ATAPI_IO1_o_Unused0   0x02
 
#define IDX_ATAPI_IO1_o_Unused1   0x03
 
#define IDX_ATAPI_IO1_o_ByteCountLow   0x04
 
#define IDX_ATAPI_IO1_o_ByteCountHigh   0x05
 
#define IDX_ATAPI_IO1_o_DriveSelect   0x06
 
#define IDX_ATAPI_IO1_o_Command   0x07
 
#define IDE_STATUS_SUCCESS   0x00
 
#define IDE_STATUS_ERROR   0x01
 
#define IDE_STATUS_INDEX   0x02
 
#define IDE_STATUS_CORRECTED_ERROR   0x04
 
#define IDE_STATUS_DRQ   0x08
 
#define IDE_STATUS_DSC   0x10
 
#define IDE_STATUS_DMA   0x20 /* DMA ready */
 
#define IDE_STATUS_DWF   0x20 /* drive write fault */
 
#define IDE_STATUS_DRDY   0x40
 
#define IDE_STATUS_IDLE   0x50
 
#define IDE_STATUS_BUSY   0x80
 
#define IDE_STATUS_WRONG   0xff
 
#define IDE_STATUS_MASK   0xff
 
#define IDE_DRIVE_SELECT   0xA0
 
#define IDE_DRIVE_1   0x00
 
#define IDE_DRIVE_2   0x10
 
#define IDE_DRIVE_SELECT_1   (IDE_DRIVE_SELECT | IDE_DRIVE_1)
 
#define IDE_DRIVE_SELECT_2   (IDE_DRIVE_SELECT | IDE_DRIVE_2)
 
#define IDE_DRIVE_MASK   (IDE_DRIVE_SELECT_1 | IDE_DRIVE_SELECT_2)
 
#define IDE_USE_LBA   0x40
 
#define IDE_DC_DISABLE_INTERRUPTS   0x02
 
#define IDE_DC_RESET_CONTROLLER   0x04
 
#define IDE_DC_A_4BIT   0x80
 
#define IDE_DC_USE_HOB   0x80
 
#define IDE_DC_REENABLE_CONTROLLER   0x00
 
#define IDE_ERROR_ICRC   0x80
 
#define IDE_ERROR_BAD_BLOCK   0x80
 
#define IDE_ERROR_DATA_ERROR   0x40
 
#define IDE_ERROR_MEDIA_CHANGE   0x20
 
#define IDE_ERROR_ID_NOT_FOUND   0x10
 
#define IDE_ERROR_MEDIA_CHANGE_REQ   0x08
 
#define IDE_ERROR_COMMAND_ABORTED   0x04
 
#define IDE_ERROR_END_OF_MEDIA   0x02
 
#define IDE_ERROR_NO_MEDIA   0x02
 
#define IDE_ERROR_ILLEGAL_LENGTH   0x01
 
#define ATA_PIO   0x00
 
#define IDENTIFY_DATA_SIZE   sizeof(IDENTIFY_DATA)
 
#define ATAPI_MAGIC_LSB   0x14
 
#define ATAPI_MAGIC_MSB   0xEB
 
#define MAXIMUM_CDROM_SIZE   804
 
#define ATA_DEVICE_ATAPI   (1 << 0)
 
#define ATA_DEVICE_NO_MEDIA   (1 << 1)
 
#define ATA_DEVICE_NOT_READY   (1 << 2)
 
#define ATA_DEVICE_LBA48   (1 << 3)
 
#define ATA_DEVICE_LBA   (1 << 4)
 
#define ATA_DEVICE_CHS   (1 << 5)
 

Typedefs

typedef struct _IDENTIFY_DATA IDENTIFY_DATA
 
typedef struct _IDENTIFY_DATAPIDENTIFY_DATA
 
typedef struct _DEVICE_UNIT DEVICE_UNIT
 
typedef struct _DEVICE_UNITPDEVICE_UNIT
 

Functions

BOOLEAN AtaInit (OUT PUCHAR DetectedCount)
 
VOID AtaFree ()
 
PDEVICE_UNIT AtaGetDevice (IN UCHAR UnitNumber)
 
BOOLEAN AtaAtapiReadLogicalSectorsLBA (IN OUT PDEVICE_UNIT DeviceUnit, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
 

Macro Definition Documentation

◆ ATA_DEVICE_ATAPI

#define ATA_DEVICE_ATAPI   (1 << 0)

Definition at line 303 of file hwide.h.

◆ ATA_DEVICE_CHS

#define ATA_DEVICE_CHS   (1 << 5)

Definition at line 308 of file hwide.h.

◆ ATA_DEVICE_LBA

#define ATA_DEVICE_LBA   (1 << 4)

Definition at line 307 of file hwide.h.

◆ ATA_DEVICE_LBA48

#define ATA_DEVICE_LBA48   (1 << 3)

Definition at line 306 of file hwide.h.

◆ ATA_DEVICE_NO_MEDIA

#define ATA_DEVICE_NO_MEDIA   (1 << 1)

Definition at line 304 of file hwide.h.

◆ ATA_DEVICE_NOT_READY

#define ATA_DEVICE_NOT_READY   (1 << 2)

Definition at line 305 of file hwide.h.

◆ ATA_PIO

#define ATA_PIO   0x00

Definition at line 161 of file hwide.h.

◆ ATAPI_MAGIC_LSB

#define ATAPI_MAGIC_LSB   0x14

Definition at line 286 of file hwide.h.

◆ ATAPI_MAGIC_MSB

#define ATAPI_MAGIC_MSB   0xEB

Definition at line 287 of file hwide.h.

◆ IDE_DC_A_4BIT

#define IDE_DC_A_4BIT   0x80

Definition at line 140 of file hwide.h.

◆ IDE_DC_DISABLE_INTERRUPTS

#define IDE_DC_DISABLE_INTERRUPTS   0x02

Definition at line 138 of file hwide.h.

◆ IDE_DC_REENABLE_CONTROLLER

#define IDE_DC_REENABLE_CONTROLLER   0x00

Definition at line 142 of file hwide.h.

◆ IDE_DC_RESET_CONTROLLER

#define IDE_DC_RESET_CONTROLLER   0x04

Definition at line 139 of file hwide.h.

◆ IDE_DC_USE_HOB

#define IDE_DC_USE_HOB   0x80

Definition at line 141 of file hwide.h.

◆ IDE_DRIVE_1

#define IDE_DRIVE_1   0x00

Definition at line 128 of file hwide.h.

◆ IDE_DRIVE_2

#define IDE_DRIVE_2   0x10

Definition at line 129 of file hwide.h.

◆ IDE_DRIVE_MASK

#define IDE_DRIVE_MASK   (IDE_DRIVE_SELECT_1 | IDE_DRIVE_SELECT_2)

Definition at line 132 of file hwide.h.

◆ IDE_DRIVE_SELECT

#define IDE_DRIVE_SELECT   0xA0

Definition at line 127 of file hwide.h.

◆ IDE_DRIVE_SELECT_1

#define IDE_DRIVE_SELECT_1   (IDE_DRIVE_SELECT | IDE_DRIVE_1)

Definition at line 130 of file hwide.h.

◆ IDE_DRIVE_SELECT_2

#define IDE_DRIVE_SELECT_2   (IDE_DRIVE_SELECT | IDE_DRIVE_2)

Definition at line 131 of file hwide.h.

◆ IDE_ERROR_BAD_BLOCK

#define IDE_ERROR_BAD_BLOCK   0x80

Definition at line 148 of file hwide.h.

◆ IDE_ERROR_COMMAND_ABORTED

#define IDE_ERROR_COMMAND_ABORTED   0x04

Definition at line 153 of file hwide.h.

◆ IDE_ERROR_DATA_ERROR

#define IDE_ERROR_DATA_ERROR   0x40

Definition at line 149 of file hwide.h.

◆ IDE_ERROR_END_OF_MEDIA

#define IDE_ERROR_END_OF_MEDIA   0x02

Definition at line 154 of file hwide.h.

◆ IDE_ERROR_ICRC

#define IDE_ERROR_ICRC   0x80

Definition at line 147 of file hwide.h.

◆ IDE_ERROR_ID_NOT_FOUND

#define IDE_ERROR_ID_NOT_FOUND   0x10

Definition at line 151 of file hwide.h.

◆ IDE_ERROR_ILLEGAL_LENGTH

#define IDE_ERROR_ILLEGAL_LENGTH   0x01

Definition at line 156 of file hwide.h.

◆ IDE_ERROR_MEDIA_CHANGE

#define IDE_ERROR_MEDIA_CHANGE   0x20

Definition at line 150 of file hwide.h.

◆ IDE_ERROR_MEDIA_CHANGE_REQ

#define IDE_ERROR_MEDIA_CHANGE_REQ   0x08

Definition at line 152 of file hwide.h.

◆ IDE_ERROR_NO_MEDIA

#define IDE_ERROR_NO_MEDIA   0x02

Definition at line 155 of file hwide.h.

◆ IDE_STATUS_BUSY

#define IDE_STATUS_BUSY   0x80

Definition at line 119 of file hwide.h.

◆ IDE_STATUS_CORRECTED_ERROR

#define IDE_STATUS_CORRECTED_ERROR   0x04

Definition at line 112 of file hwide.h.

◆ IDE_STATUS_DMA

#define IDE_STATUS_DMA   0x20 /* DMA ready */

Definition at line 115 of file hwide.h.

◆ IDE_STATUS_DRDY

#define IDE_STATUS_DRDY   0x40

Definition at line 117 of file hwide.h.

◆ IDE_STATUS_DRQ

#define IDE_STATUS_DRQ   0x08

Definition at line 113 of file hwide.h.

◆ IDE_STATUS_DSC

#define IDE_STATUS_DSC   0x10

Definition at line 114 of file hwide.h.

◆ IDE_STATUS_DWF

#define IDE_STATUS_DWF   0x20 /* drive write fault */

Definition at line 116 of file hwide.h.

◆ IDE_STATUS_ERROR

#define IDE_STATUS_ERROR   0x01

Definition at line 110 of file hwide.h.

◆ IDE_STATUS_IDLE

#define IDE_STATUS_IDLE   0x50

Definition at line 118 of file hwide.h.

◆ IDE_STATUS_INDEX

#define IDE_STATUS_INDEX   0x02

Definition at line 111 of file hwide.h.

◆ IDE_STATUS_MASK

#define IDE_STATUS_MASK   0xff

Definition at line 122 of file hwide.h.

◆ IDE_STATUS_SUCCESS

#define IDE_STATUS_SUCCESS   0x00

Definition at line 109 of file hwide.h.

◆ IDE_STATUS_WRONG

#define IDE_STATUS_WRONG   0xff

Definition at line 121 of file hwide.h.

◆ IDE_USE_LBA

#define IDE_USE_LBA   0x40

Definition at line 133 of file hwide.h.

◆ IDENTIFY_DATA_SIZE

#define IDENTIFY_DATA_SIZE   sizeof(IDENTIFY_DATA)

Definition at line 284 of file hwide.h.

◆ IDX_ATAPI_IO1_i_ByteCountHigh

#define IDX_ATAPI_IO1_i_ByteCountHigh   0x05

Definition at line 92 of file hwide.h.

◆ IDX_ATAPI_IO1_i_ByteCountLow

#define IDX_ATAPI_IO1_i_ByteCountLow   0x04

Definition at line 91 of file hwide.h.

◆ IDX_ATAPI_IO1_i_Data

#define IDX_ATAPI_IO1_i_Data   0x00

Definition at line 87 of file hwide.h.

◆ IDX_ATAPI_IO1_i_DriveSelect

#define IDX_ATAPI_IO1_i_DriveSelect   0x06

Definition at line 93 of file hwide.h.

◆ IDX_ATAPI_IO1_i_Error

#define IDX_ATAPI_IO1_i_Error   0x01

Definition at line 88 of file hwide.h.

◆ IDX_ATAPI_IO1_i_InterruptReason

#define IDX_ATAPI_IO1_i_InterruptReason   0x02

Definition at line 89 of file hwide.h.

◆ IDX_ATAPI_IO1_i_Status

#define IDX_ATAPI_IO1_i_Status   0x07

Definition at line 94 of file hwide.h.

◆ IDX_ATAPI_IO1_i_Unused1

#define IDX_ATAPI_IO1_i_Unused1   0x03

Definition at line 90 of file hwide.h.

◆ IDX_ATAPI_IO1_o_ByteCountHigh

#define IDX_ATAPI_IO1_o_ByteCountHigh   0x05

Definition at line 101 of file hwide.h.

◆ IDX_ATAPI_IO1_o_ByteCountLow

#define IDX_ATAPI_IO1_o_ByteCountLow   0x04

Definition at line 100 of file hwide.h.

◆ IDX_ATAPI_IO1_o_Command

#define IDX_ATAPI_IO1_o_Command   0x07

Definition at line 103 of file hwide.h.

◆ IDX_ATAPI_IO1_o_Data

#define IDX_ATAPI_IO1_o_Data   0x00

Definition at line 96 of file hwide.h.

◆ IDX_ATAPI_IO1_o_DriveSelect

#define IDX_ATAPI_IO1_o_DriveSelect   0x06

Definition at line 102 of file hwide.h.

◆ IDX_ATAPI_IO1_o_Feature

#define IDX_ATAPI_IO1_o_Feature   0x01

Definition at line 97 of file hwide.h.

◆ IDX_ATAPI_IO1_o_Unused0

#define IDX_ATAPI_IO1_o_Unused0   0x02

Definition at line 98 of file hwide.h.

◆ IDX_ATAPI_IO1_o_Unused1

#define IDX_ATAPI_IO1_o_Unused1   0x03

Definition at line 99 of file hwide.h.

◆ IDX_IO1_i_BlockCount

#define IDX_IO1_i_BlockCount   0x02

Definition at line 43 of file hwide.h.

◆ IDX_IO1_i_BlockNumber

#define IDX_IO1_i_BlockNumber   0x03

Definition at line 44 of file hwide.h.

◆ IDX_IO1_i_CylinderHigh

#define IDX_IO1_i_CylinderHigh   0x05

Definition at line 46 of file hwide.h.

◆ IDX_IO1_i_CylinderLow

#define IDX_IO1_i_CylinderLow   0x04

Definition at line 45 of file hwide.h.

◆ IDX_IO1_i_Data

#define IDX_IO1_i_Data   0x00

Definition at line 41 of file hwide.h.

◆ IDX_IO1_i_DriveSelect

#define IDX_IO1_i_DriveSelect   0x06

Definition at line 47 of file hwide.h.

◆ IDX_IO1_i_Error

#define IDX_IO1_i_Error   0x01

Definition at line 42 of file hwide.h.

◆ IDX_IO1_i_Status

#define IDX_IO1_i_Status   0x07

Definition at line 48 of file hwide.h.

◆ IDX_IO1_o_BlockCount

#define IDX_IO1_o_BlockCount   0x02

Definition at line 55 of file hwide.h.

◆ IDX_IO1_o_BlockNumber

#define IDX_IO1_o_BlockNumber   0x03

Definition at line 56 of file hwide.h.

◆ IDX_IO1_o_Command

#define IDX_IO1_o_Command   0x07

Definition at line 60 of file hwide.h.

◆ IDX_IO1_o_CylinderHigh

#define IDX_IO1_o_CylinderHigh   0x05

Definition at line 58 of file hwide.h.

◆ IDX_IO1_o_CylinderLow

#define IDX_IO1_o_CylinderLow   0x04

Definition at line 57 of file hwide.h.

◆ IDX_IO1_o_Data

#define IDX_IO1_o_Data   0x00

Definition at line 53 of file hwide.h.

◆ IDX_IO1_o_DriveSelect

#define IDX_IO1_o_DriveSelect   0x06

Definition at line 59 of file hwide.h.

◆ IDX_IO1_o_Feature

#define IDX_IO1_o_Feature   0x01

Definition at line 54 of file hwide.h.

◆ IDX_IO2_i_AltStatus

#define IDX_IO2_i_AltStatus   0x206

Definition at line 50 of file hwide.h.

◆ IDX_IO2_i_DriveAddress

#define IDX_IO2_i_DriveAddress   0x207

Definition at line 51 of file hwide.h.

◆ IDX_IO2_o_Control

#define IDX_IO2_o_Control   0x206

Definition at line 62 of file hwide.h.

◆ MAXIMUM_CDROM_SIZE

#define MAXIMUM_CDROM_SIZE   804

Definition at line 288 of file hwide.h.

Typedef Documentation

◆ DEVICE_UNIT

◆ IDENTIFY_DATA

◆ PDEVICE_UNIT

◆ PIDENTIFY_DATA

Function Documentation

◆ AtaAtapiReadLogicalSectorsLBA()

BOOLEAN AtaAtapiReadLogicalSectorsLBA ( IN OUT PDEVICE_UNIT  DeviceUnit,
IN ULONGLONG  SectorNumber,
IN ULONG  SectorCount,
OUT PVOID  Buffer 
)

Definition at line 187 of file hwide.c.

192{
193 UCHAR RetryCount;
195
196 if (DeviceUnit == NULL || SectorCount == 0)
197 return FALSE;
198
199 if (DeviceUnit->Flags & ATA_DEVICE_ATAPI)
200 {
201 if ((DeviceUnit->Flags & ATA_DEVICE_NO_MEDIA) || (DeviceUnit->Flags & ATA_DEVICE_NOT_READY))
202 {
203 /* Retry 4 times */
204 for (RetryCount = 0; RetryCount < 4; ++RetryCount)
205 {
206 /* Make the device ready */
207 if (AtapiReadyCheck(DeviceUnit))
208 break;
209 }
210 if (RetryCount >= 4)
211 {
212 ERR("AtaAtapiReadLogicalSectorsLBA(): Device not ready.\n");
213 return FALSE;
214 }
215 }
216 if (SectorNumber + SectorCount > DeviceUnit->TotalSectors + 1)
217 {
218 ERR("AtaAtapiReadLogicalSectorsLBA(): Attempt to read more than there is to read.\n");
219 return FALSE;
220 }
221
222 while (SectorCount > 0)
223 {
224 /* Read a single sector */
225 Success = AtapiReadLogicalSectorLBA(DeviceUnit, SectorNumber, Buffer);
226 if (!Success)
227 return FALSE;
228
229 --SectorCount;
230 ++SectorNumber;
231 Buffer = (PVOID)((ULONG_PTR)Buffer + DeviceUnit->SectorSize);
232 }
233 }
234 else
235 {
236 /* Retry 3 times */
237 for (RetryCount = 0; RetryCount < 3; ++RetryCount)
238 {
239 /* Read a multiple sectors */
240 Success = AtaReadLogicalSectorsLBA(DeviceUnit, SectorNumber, SectorCount, Buffer);
241 if (Success)
242 return TRUE;
243 }
244 return FALSE;
245 }
246
247 return TRUE;
248}
unsigned char BOOLEAN
#define ERR(fmt,...)
Definition: precomp.h:57
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ Success
Definition: eventcreate.c:712
static BOOLEAN AtapiReadyCheck(IN OUT PDEVICE_UNIT DeviceUnit)
Definition: hwide.c:554
static BOOLEAN AtapiReadLogicalSectorLBA(IN PDEVICE_UNIT DeviceUnit, IN ULONGLONG SectorNumber, OUT PVOID Buffer)
Definition: hwide.c:423
static BOOLEAN AtaReadLogicalSectorsLBA(IN PDEVICE_UNIT DeviceUnit, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: hwide.c:252
#define ATA_DEVICE_NOT_READY
Definition: hwide.h:305
#define ATA_DEVICE_ATAPI
Definition: hwide.h:303
#define ATA_DEVICE_NO_MEDIA
Definition: hwide.h:304
ULONG SectorCount
Definition: part_xbox.c:31
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by Pc98DiskReadLogicalSectorsLBA(), and XboxDiskReadLogicalSectors().

◆ AtaFree()

VOID AtaFree ( )

◆ AtaGetDevice()

PDEVICE_UNIT AtaGetDevice ( IN UCHAR  UnitNumber)

Definition at line 178 of file hwide.c.

179{
180 if (UnitNumber < RTL_NUMBER_OF(Units))
181 return Units[UnitNumber];
182 else
183 return NULL;
184}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static PDEVICE_UNIT Units[MAX_CHANNELS *MAX_DEVICES]
Definition: hwide.c:55

Referenced by InitIdeDrive(), Pc98DiskReadLogicalSectorsLBA(), and XboxDiskInit().

◆ AtaInit()

BOOLEAN AtaInit ( OUT PUCHAR  DetectedCount)

Definition at line 139 of file hwide.c.

140{
141 UCHAR Channel, DeviceNumber;
142 PDEVICE_UNIT DeviceUnit = NULL;
143
144 TRACE("AtaInit()\n");
145
146 *DetectedCount = 0;
147
148 RtlZeroMemory(&Units, sizeof(Units));
149
150 /* Detect and enumerate ATA/ATAPI devices */
151 for (Channel = 0; Channel < MAX_CHANNELS; ++Channel)
152 {
154 {
155 if (IdentifyDevice(Channel, DeviceNumber, &DeviceUnit))
156 {
157 Units[(*DetectedCount)++] = DeviceUnit;
158 }
159 }
160 }
161
162 return (*DetectedCount > 0);
163}
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1230
static BOOLEAN IdentifyDevice(IN UCHAR Channel, IN UCHAR DeviceNumber, OUT PDEVICE_UNIT *DeviceUnit)
Definition: hwide.c:750
#define MAX_DEVICES
Definition: hwide.c:53
#define MAX_CHANNELS
Definition: hwide.c:52
#define TRACE(s)
Definition: solgame.cpp:4
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by Pc98InitializeBootDevices(), and XboxDiskInit().