mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Added disk class driver skeleton.
svn path=/trunk/; revision=2091
This commit is contained in:
parent
c0eef82d19
commit
e604d7b0fe
6 changed files with 773 additions and 0 deletions
4
reactos/drivers/storage/disk/.cvsignore
Normal file
4
reactos/drivers/storage/disk/.cvsignore
Normal file
|
@ -0,0 +1,4 @@
|
|||
base.tmp
|
||||
junk.tmp
|
||||
temp.exp
|
||||
disk.coff
|
398
reactos/drivers/storage/disk/disk.c
Normal file
398
reactos/drivers/storage/disk/disk.c
Normal file
|
@ -0,0 +1,398 @@
|
|||
/* $Id: disk.c,v 1.1 2001/07/24 10:21:15 ekohl Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
//#include "ide.h"
|
||||
//#include "partitio.h"
|
||||
|
||||
#define VERSION "V0.0.1"
|
||||
|
||||
|
||||
static NTSTATUS DiskCreateDevices(VOID);
|
||||
static BOOLEAN DiskFindDiskDrives(PDEVICE_OBJECT PortDeviceObject, ULONG PortNumber);
|
||||
|
||||
|
||||
/*
|
||||
* DiskOpenClose
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* Answer requests for Open/Close calls: a null operation
|
||||
*
|
||||
* RUN LEVEL:
|
||||
* PASSIVE_LEVEL
|
||||
*
|
||||
* ARGUMENTS:
|
||||
* Standard dispatch arguments
|
||||
*
|
||||
* RETURNS:
|
||||
* NTSTATUS
|
||||
*/
|
||||
#if 0
|
||||
static NTSTATUS STDCALL
|
||||
DiskOpenClose(IN PDEVICE_OBJECT pDO,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = FILE_OPENED;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
DiskClassReadWrite(IN PDEVICE_OBJECT pDO,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
DiskClassDeviceControl(IN PDEVICE_OBJECT pDO,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
DiskClassShutdownFlush(IN PDEVICE_OBJECT pDO,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
// DriverEntry
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This function initializes the driver, locates and claims
|
||||
// hardware resources, and creates various NT objects needed
|
||||
// to process I/O requests.
|
||||
//
|
||||
// RUN LEVEL:
|
||||
// PASSIVE_LEVEL
|
||||
//
|
||||
// ARGUMENTS:
|
||||
// IN PDRIVER_OBJECT DriverObject System allocated Driver Object
|
||||
// for this driver
|
||||
// IN PUNICODE_STRING RegistryPath Name of registry driver service
|
||||
// key
|
||||
//
|
||||
// RETURNS:
|
||||
// NTSTATUS
|
||||
|
||||
NTSTATUS STDCALL
|
||||
DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
DbgPrint("Disk Class Driver %s\n", VERSION);
|
||||
|
||||
/* Export other driver entry points... */
|
||||
// DriverObject->DriverStartIo = IDEStartIo;
|
||||
// DriverObject->MajorFunction[IRP_MJ_CREATE] = DiskClassOpenClose;
|
||||
// DriverObject->MajorFunction[IRP_MJ_CLOSE] = DiskClassOpenClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_READ] = DiskClassReadWrite;
|
||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = DiskClassReadWrite;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DiskClassDeviceControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = DiskClassShutdownFlush;
|
||||
DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = DiskClassShutdownFlush;
|
||||
|
||||
Status = DiskCreateDevices();
|
||||
DPRINT("Status 0x%08X\n", Status);
|
||||
|
||||
DPRINT("Returning from DriverEntry\n");
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
DiskCreateDevices(VOID)
|
||||
{
|
||||
WCHAR NameBuffer[80];
|
||||
UNICODE_STRING PortName;
|
||||
ULONG PortNumber = 0;
|
||||
PDEVICE_OBJECT PortDeviceObject;
|
||||
PFILE_OBJECT FileObject;
|
||||
BOOLEAN DiskFound = FALSE;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT1("DiskCreateDevices() called.\n");
|
||||
|
||||
/* look for ScsiPortX scsi port devices */
|
||||
do
|
||||
{
|
||||
swprintf(NameBuffer,
|
||||
L"\\Device\\ScsiPort%ld",
|
||||
PortNumber);
|
||||
RtlInitUnicodeString(&PortName,
|
||||
NameBuffer);
|
||||
DPRINT1("Checking scsi port %ld\n", PortNumber);
|
||||
Status = IoGetDeviceObjectPointer(&PortName,
|
||||
FILE_READ_ATTRIBUTES,
|
||||
&FileObject,
|
||||
&PortDeviceObject);
|
||||
DPRINT1("Status 0x%08lX\n", Status);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("ScsiPort%ld found.\n", PortNumber);
|
||||
|
||||
/* Check scsi port for attached disk drives */
|
||||
DiskFound = DiskFindDiskDrives(PortDeviceObject, PortNumber);
|
||||
}
|
||||
PortNumber++;
|
||||
}
|
||||
while (NT_SUCCESS(Status));
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static BOOLEAN
|
||||
DiskFindDiskDrives(PDEVICE_OBJECT PortDeviceObject,
|
||||
ULONG PortNumber)
|
||||
{
|
||||
DPRINT1("DiskFindDiskDevices() called.\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// IDECreateDevice
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Creates a device by calling IoCreateDevice and a sylbolic link for Win32
|
||||
//
|
||||
// RUN LEVEL:
|
||||
// PASSIVE_LEVEL
|
||||
//
|
||||
// ARGUMENTS:
|
||||
// IN PDRIVER_OBJECT DriverObject The system supplied driver object
|
||||
// OUT PDEVICE_OBJECT *DeviceObject The created device object
|
||||
// IN PCONTROLLER_OBJECT ControllerObject The Controller for the device
|
||||
// IN BOOLEAN LBASupported Does the drive support LBA addressing?
|
||||
// IN BOOLEAN DMASupported Does the drive support DMA?
|
||||
// IN int SectorsPerLogCyl Sectors per cylinder
|
||||
// IN int SectorsPerLogTrk Sectors per track
|
||||
// IN DWORD Offset First valid sector for this device
|
||||
// IN DWORD Size Count of valid sectors for this device
|
||||
//
|
||||
// RETURNS:
|
||||
// NTSTATUS
|
||||
//
|
||||
#if 0
|
||||
NTSTATUS
|
||||
IDECreateDevice(IN PDRIVER_OBJECT DriverObject,
|
||||
OUT PDEVICE_OBJECT *DeviceObject,
|
||||
IN PCONTROLLER_OBJECT ControllerObject,
|
||||
IN int UnitNumber,
|
||||
IN ULONG DiskNumber,
|
||||
IN ULONG PartitionNumber,
|
||||
IN PIDE_DRIVE_IDENTIFY DrvParms,
|
||||
IN DWORD Offset,
|
||||
IN DWORD Size)
|
||||
{
|
||||
WCHAR NameBuffer[IDE_MAX_NAME_LENGTH];
|
||||
WCHAR ArcNameBuffer[IDE_MAX_NAME_LENGTH + 15];
|
||||
UNICODE_STRING DeviceName;
|
||||
UNICODE_STRING ArcName;
|
||||
NTSTATUS RC;
|
||||
PIDE_DEVICE_EXTENSION DeviceExtension;
|
||||
|
||||
// Create a unicode device name
|
||||
swprintf(NameBuffer,
|
||||
L"\\Device\\Harddisk%d\\Partition%d",
|
||||
DiskNumber,
|
||||
PartitionNumber);
|
||||
RtlInitUnicodeString(&DeviceName,
|
||||
NameBuffer);
|
||||
|
||||
// Create the device
|
||||
RC = IoCreateDevice(DriverObject, sizeof(IDE_DEVICE_EXTENSION),
|
||||
&DeviceName, FILE_DEVICE_DISK, 0, TRUE, DeviceObject);
|
||||
if (!NT_SUCCESS(RC))
|
||||
{
|
||||
DPRINT("IoCreateDevice call failed\n",0);
|
||||
return RC;
|
||||
}
|
||||
|
||||
// Set the buffering strategy here...
|
||||
(*DeviceObject)->Flags |= DO_DIRECT_IO;
|
||||
(*DeviceObject)->AlignmentRequirement = FILE_WORD_ALIGNMENT;
|
||||
|
||||
// Fill out Device extension data
|
||||
DeviceExtension = (PIDE_DEVICE_EXTENSION) (*DeviceObject)->DeviceExtension;
|
||||
DeviceExtension->DeviceObject = (*DeviceObject);
|
||||
DeviceExtension->ControllerObject = ControllerObject;
|
||||
DeviceExtension->UnitNumber = UnitNumber;
|
||||
DeviceExtension->LBASupported =
|
||||
(DrvParms->Capabilities & IDE_DRID_LBA_SUPPORTED) ? 1 : 0;
|
||||
DeviceExtension->DMASupported =
|
||||
(DrvParms->Capabilities & IDE_DRID_DMA_SUPPORTED) ? 1 : 0;
|
||||
// FIXME: deal with bizarre sector sizes
|
||||
DeviceExtension->BytesPerSector = 512 /* DrvParms->BytesPerSector */;
|
||||
DeviceExtension->SectorsPerLogCyl = DrvParms->LogicalHeads *
|
||||
DrvParms->SectorsPerTrack;
|
||||
DeviceExtension->SectorsPerLogTrk = DrvParms->SectorsPerTrack;
|
||||
DeviceExtension->LogicalHeads = DrvParms->LogicalHeads;
|
||||
DeviceExtension->Offset = Offset;
|
||||
DeviceExtension->Size = Size;
|
||||
DPRINT("%wZ: offset %d size %d \n",
|
||||
&DeviceName,
|
||||
DeviceExtension->Offset,
|
||||
DeviceExtension->Size);
|
||||
|
||||
// Initialize the DPC object here
|
||||
IoInitializeDpcRequest(*DeviceObject, IDEDpcForIsr);
|
||||
|
||||
if (PartitionNumber != 0)
|
||||
{
|
||||
DbgPrint("%wZ %dMB\n", &DeviceName, Size / 2048);
|
||||
}
|
||||
|
||||
/* assign arc name */
|
||||
if (PartitionNumber == 0)
|
||||
{
|
||||
swprintf(ArcNameBuffer,
|
||||
L"\\ArcName\\multi(0)disk(0)rdisk(%d)",
|
||||
DiskNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
swprintf(ArcNameBuffer,
|
||||
L"\\ArcName\\multi(0)disk(0)rdisk(%d)partition(%d)",
|
||||
DiskNumber,
|
||||
PartitionNumber);
|
||||
}
|
||||
RtlInitUnicodeString (&ArcName,
|
||||
ArcNameBuffer);
|
||||
DPRINT("%wZ ==> %wZ\n", &ArcName, &DeviceName);
|
||||
RC = IoAssignArcName (&ArcName,
|
||||
&DeviceName);
|
||||
if (!NT_SUCCESS(RC))
|
||||
{
|
||||
DPRINT("IoAssignArcName (%wZ) failed (Status %x)\n",
|
||||
&ArcName, RC);
|
||||
}
|
||||
|
||||
|
||||
return RC;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// IDEDispatchDeviceControl
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Answer requests for device control calls
|
||||
//
|
||||
// RUN LEVEL:
|
||||
// PASSIVE_LEVEL
|
||||
//
|
||||
// ARGUMENTS:
|
||||
// Standard dispatch arguments
|
||||
//
|
||||
// RETURNS:
|
||||
// NTSTATUS
|
||||
//
|
||||
#if 0
|
||||
static NTSTATUS STDCALL
|
||||
IDEDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
NTSTATUS RC;
|
||||
ULONG ControlCode, InputLength, OutputLength;
|
||||
PIO_STACK_LOCATION IrpStack;
|
||||
PIDE_DEVICE_EXTENSION DeviceExtension;
|
||||
|
||||
RC = STATUS_SUCCESS;
|
||||
IrpStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
ControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
|
||||
InputLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
|
||||
OutputLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
|
||||
DeviceExtension = (PIDE_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
|
||||
|
||||
// A huge switch statement in a Windows program?! who would have thought?
|
||||
switch (ControlCode)
|
||||
{
|
||||
case IOCTL_DISK_GET_DRIVE_GEOMETRY:
|
||||
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(DISK_GEOMETRY))
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
PDISK_GEOMETRY Geometry;
|
||||
|
||||
Geometry = (PDISK_GEOMETRY) Irp->AssociatedIrp.SystemBuffer;
|
||||
Geometry->MediaType = FixedMedia;
|
||||
// FIXME: should report for RawDevice even on partition
|
||||
Geometry->Cylinders.QuadPart = DeviceExtension->Size /
|
||||
DeviceExtension->SectorsPerLogCyl;
|
||||
Geometry->TracksPerCylinder = DeviceExtension->SectorsPerLogTrk /
|
||||
DeviceExtension->SectorsPerLogCyl;
|
||||
Geometry->SectorsPerTrack = DeviceExtension->SectorsPerLogTrk;
|
||||
Geometry->BytesPerSector = DeviceExtension->BytesPerSector;
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
|
||||
}
|
||||
break;
|
||||
|
||||
case IOCTL_DISK_GET_PARTITION_INFO:
|
||||
case IOCTL_DISK_SET_PARTITION_INFO:
|
||||
case IOCTL_DISK_GET_DRIVE_LAYOUT:
|
||||
case IOCTL_DISK_SET_DRIVE_LAYOUT:
|
||||
case IOCTL_DISK_VERIFY:
|
||||
case IOCTL_DISK_FORMAT_TRACKS:
|
||||
case IOCTL_DISK_PERFORMANCE:
|
||||
case IOCTL_DISK_IS_WRITABLE:
|
||||
case IOCTL_DISK_LOGGING:
|
||||
case IOCTL_DISK_FORMAT_TRACKS_EX:
|
||||
case IOCTL_DISK_HISTOGRAM_STRUCTURE:
|
||||
case IOCTL_DISK_HISTOGRAM_DATA:
|
||||
case IOCTL_DISK_HISTOGRAM_RESET:
|
||||
case IOCTL_DISK_REQUEST_STRUCTURE:
|
||||
case IOCTL_DISK_REQUEST_DATA:
|
||||
|
||||
// If we get here, something went wrong. inform the requestor
|
||||
default:
|
||||
RC = STATUS_INVALID_DEVICE_REQUEST;
|
||||
Irp->IoStatus.Status = RC;
|
||||
Irp->IoStatus.Information = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return RC;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* EOF */
|
250
reactos/drivers/storage/disk/disk.h
Normal file
250
reactos/drivers/storage/disk/disk.h
Normal file
|
@ -0,0 +1,250 @@
|
|||
//
|
||||
// IDE.H - defines and typedefs for the IDE Driver module.
|
||||
//
|
||||
|
||||
#ifndef __IDE_H
|
||||
#define __IDE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IDE_MAXIMUM_DEVICES 8
|
||||
|
||||
#define IDE_MAX_NAME_LENGTH 50
|
||||
|
||||
#define IDE_SECTOR_BUF_SZ 512
|
||||
#define IDE_MAX_SECTORS_PER_XFER 256
|
||||
#define IDE_MAX_RESET_RETRIES 10000
|
||||
#define IDE_MAX_POLL_RETRIES 100000
|
||||
#define IDE_MAX_WRITE_RETRIES 1000
|
||||
#define IDE_MAX_BUSY_RETRIES 100
|
||||
//#define IDE_MAX_BUSY_RETRIES 100000
|
||||
#define IDE_MAX_DRQ_RETRIES 10000
|
||||
//#define IDE_MAX_CMD_RETRIES 1
|
||||
#define IDE_MAX_CMD_RETRIES 0
|
||||
#define IDE_CMD_TIMEOUT 5
|
||||
#define IDE_RESET_PULSE_LENGTH 500 /* maybe a little too long */
|
||||
#define IDE_RESET_BUSY_TIMEOUT 31
|
||||
#define IDE_RESET_DRDY_TIMEOUT 120
|
||||
|
||||
// Control Block offsets and masks
|
||||
#define IDE_REG_ALT_STATUS 0x0000
|
||||
#define IDE_REG_DEV_CNTRL 0x0000 /* device control register */
|
||||
#define IDE_DC_SRST 0x04 /* drive reset (both drives) */
|
||||
#define IDE_DC_nIEN 0x02 /* IRQ enable (active low) */
|
||||
#define IDE_REG_DRV_ADDR 0x0001
|
||||
|
||||
// Command Block offsets and masks
|
||||
#define IDE_REG_DATA_PORT 0x0000
|
||||
#define IDE_REG_ERROR 0x0001 /* error register */
|
||||
#define IDE_ER_AMNF 0x01 /* addr mark not found */
|
||||
#define IDE_ER_TK0NF 0x02 /* track 0 not found */
|
||||
#define IDE_ER_ABRT 0x04 /* command aborted */
|
||||
#define IDE_ER_MCR 0x08 /* media change requested */
|
||||
#define IDE_ER_IDNF 0x10 /* ID not found */
|
||||
#define IDE_ER_MC 0x20 /* Media changed */
|
||||
#define IDE_ER_UNC 0x40 /* Uncorrectable data error */
|
||||
#define IDE_REG_PRECOMP 0x0001
|
||||
#define IDE_REG_SECTOR_CNT 0x0002
|
||||
#define IDE_REG_SECTOR_NUM 0x0003
|
||||
#define IDE_REG_CYL_LOW 0x0004
|
||||
#define IDE_REG_CYL_HIGH 0x0005
|
||||
#define IDE_REG_DRV_HEAD 0x0006
|
||||
#define IDE_DH_FIXED 0xA0
|
||||
#define IDE_DH_LBA 0x40
|
||||
#define IDE_DH_HDMASK 0x0F
|
||||
#define IDE_DH_DRV0 0x00
|
||||
#define IDE_DH_DRV1 0x10
|
||||
#define IDE_REG_STATUS 0x0007
|
||||
#define IDE_SR_BUSY 0x80
|
||||
#define IDE_SR_DRDY 0x40
|
||||
#define IDE_SR_DRQ 0x08
|
||||
#define IDE_SR_ERR 0x01
|
||||
#define IDE_REG_COMMAND 0x0007
|
||||
#define IDE_CMD_READ 0x20
|
||||
#define IDE_CMD_READ_RETRY 0x21
|
||||
#define IDE_CMD_WRITE 0x30
|
||||
#define IDE_CMD_WRITE_RETRY 0x31
|
||||
#define IDE_CMD_IDENT_DRV 0xEC
|
||||
|
||||
//
|
||||
// Access macros for command registers
|
||||
// Each macro takes an address of the command port block, and data
|
||||
//
|
||||
#define IDEReadError(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_ERROR)))
|
||||
#define IDEWritePrecomp(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_PRECOMP), (Data)))
|
||||
#define IDEReadSectorCount(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_CNT)))
|
||||
#define IDEWriteSectorCount(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_CNT), (Data)))
|
||||
#define IDEReadSectorNum(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_NUM)))
|
||||
#define IDEWriteSectorNum(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_NUM), (Data)))
|
||||
#define IDEReadCylinderLow(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_LOW)))
|
||||
#define IDEWriteCylinderLow(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_LOW), (Data)))
|
||||
#define IDEReadCylinderHigh(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_HIGH)))
|
||||
#define IDEWriteCylinderHigh(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_HIGH), (Data)))
|
||||
#define IDEReadDriveHead(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DRV_HEAD)))
|
||||
#define IDEWriteDriveHead(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DRV_HEAD), (Data)))
|
||||
#define IDEReadStatus(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_STATUS)))
|
||||
#define IDEWriteCommand(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_COMMAND), (Data)))
|
||||
|
||||
|
||||
//
|
||||
// Data block read and write commands
|
||||
//
|
||||
#define IDEReadBlock(Address, Buffer, Count) \
|
||||
(READ_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
|
||||
#define IDEWriteBlock(Address, Buffer, Count) \
|
||||
(WRITE_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
|
||||
|
||||
//
|
||||
// Access macros for control registers
|
||||
// Each macro takes an address of the control port blank and data
|
||||
//
|
||||
#define IDEWriteDriveControl(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DEV_CNTRL), (Data)))
|
||||
|
||||
// IDE_DEVICE_EXTENSION
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Extension to be placed in each device object
|
||||
//
|
||||
// ACCESS:
|
||||
// Allocated from NON-PAGED POOL
|
||||
// Available at any IRQL
|
||||
//
|
||||
|
||||
typedef struct _IDE_DEVICE_EXTENSION {
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PCONTROLLER_OBJECT ControllerObject;
|
||||
struct _IDE_DEVICE_EXTESION *DiskExtension;
|
||||
int UnitNumber;
|
||||
BOOLEAN LBASupported;
|
||||
BOOLEAN DMASupported;
|
||||
int BytesPerSector;
|
||||
int LogicalHeads;
|
||||
int SectorsPerLogCyl;
|
||||
int SectorsPerLogTrk;
|
||||
int Offset;
|
||||
int Size;
|
||||
|
||||
int Operation;
|
||||
ULONG BytesRequested;
|
||||
ULONG BytesToTransfer;
|
||||
ULONG BytesRemaining;
|
||||
ULONG StartingSector;
|
||||
int SectorsTransferred;
|
||||
BYTE *TargetAddress;
|
||||
|
||||
} IDE_DEVICE_EXTENSION, *PIDE_DEVICE_EXTENSION;
|
||||
|
||||
// IDE_TIMER_STATES
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// An enumeration containing the states in the timer DFA
|
||||
//
|
||||
|
||||
typedef enum _IDE_TIMER_STATES {
|
||||
IDETimerIdle,
|
||||
IDETimerCmdWait,
|
||||
IDETimerResetWaitForBusyNegate,
|
||||
IDETimerResetWaitForDrdyAssert
|
||||
} IDE_TIMER_STATES;
|
||||
|
||||
// IDE_CONTROLLER_EXTENSION
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Driver-defined structure used to hold miscellaneous controller information.
|
||||
//
|
||||
// ACCESS:
|
||||
// Allocated from NON-PAGED POOL
|
||||
// Available at any IRQL
|
||||
//
|
||||
|
||||
typedef struct _IDE_CONTROLLER_EXTENSION {
|
||||
KSPIN_LOCK SpinLock;
|
||||
int Number;
|
||||
int Vector;
|
||||
int CommandPortBase;
|
||||
int ControlPortBase;
|
||||
BOOLEAN DMASupported;
|
||||
BOOLEAN ControllerInterruptBug;
|
||||
PKINTERRUPT Interrupt;
|
||||
|
||||
BOOLEAN OperationInProgress;
|
||||
BYTE DeviceStatus;
|
||||
PIDE_DEVICE_EXTENSION DeviceForOperation;
|
||||
PIRP CurrentIrp;
|
||||
int Retries;
|
||||
|
||||
IDE_TIMER_STATES TimerState;
|
||||
LONG TimerCount;
|
||||
PDEVICE_OBJECT TimerDevice;
|
||||
|
||||
} IDE_CONTROLLER_EXTENSION, *PIDE_CONTROLLER_EXTENSION;
|
||||
|
||||
// IDE_DRIVE_IDENTIFY
|
||||
|
||||
typedef struct _IDE_DRIVE_IDENTIFY {
|
||||
WORD ConfigBits; /*00*/
|
||||
WORD LogicalCyls; /*01*/
|
||||
WORD Reserved02; /*02*/
|
||||
WORD LogicalHeads; /*03*/
|
||||
WORD BytesPerTrack; /*04*/
|
||||
WORD BytesPerSector; /*05*/
|
||||
WORD SectorsPerTrack; /*06*/
|
||||
BYTE InterSectorGap; /*07*/
|
||||
BYTE InterSectorGapSize;
|
||||
BYTE Reserved08H; /*08*/
|
||||
BYTE BytesInPLO;
|
||||
WORD VendorUniqueCnt; /*09*/
|
||||
char SerialNumber[20]; /*10*/
|
||||
WORD ControllerType; /*20*/
|
||||
WORD BufferSize; /*21*/
|
||||
WORD ECCByteCnt; /*22*/
|
||||
char FirmwareRev[8]; /*23*/
|
||||
char ModelNumber[40]; /*27*/
|
||||
WORD RWMultImplemented; /*47*/
|
||||
WORD Reserved48; /*48*/
|
||||
WORD Capabilities; /*49*/
|
||||
#define IDE_DRID_STBY_SUPPORTED 0x2000
|
||||
#define IDE_DRID_IORDY_SUPPORTED 0x0800
|
||||
#define IDE_DRID_IORDY_DISABLE 0x0400
|
||||
#define IDE_DRID_LBA_SUPPORTED 0x0200
|
||||
#define IDE_DRID_DMA_SUPPORTED 0x0100
|
||||
WORD Reserved50; /*50*/
|
||||
WORD MinPIOTransTime; /*51*/
|
||||
WORD MinDMATransTime; /*52*/
|
||||
WORD TMFieldsValid; /*53*/
|
||||
WORD TMCylinders; /*54*/
|
||||
WORD TMHeads; /*55*/
|
||||
WORD TMSectorsPerTrk; /*56*/
|
||||
WORD TMCapacityLo; /*57*/
|
||||
WORD TMCapacityHi; /*58*/
|
||||
WORD Reserved59; /*59*/
|
||||
WORD TMSectorCountLo; /*60*/
|
||||
WORD TMSectorCountHi; /*61*/
|
||||
WORD Reserved62[194]; /*62*/
|
||||
} IDE_DRIVE_IDENTIFY, *PIDE_DRIVE_IDENTIFY;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __IDE_H */
|
||||
|
||||
|
39
reactos/drivers/storage/disk/disk.rc
Normal file
39
reactos/drivers/storage/disk/disk.rc
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
#include <defines.h>
|
||||
#include <reactos/resource.h>
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
|
||||
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", RES_STR_COMPANY_NAME
|
||||
VALUE "FileDescription", "Disk Class Driver\0"
|
||||
VALUE "FileVersion", "0.0.1\0"
|
||||
VALUE "InternalName", "disk\0"
|
||||
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
|
||||
VALUE "OriginalFilename", "disk.sys\0"
|
||||
VALUE "ProductName", RES_STR_PRODUCT_NAME
|
||||
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
41
reactos/drivers/storage/disk/makefile
Normal file
41
reactos/drivers/storage/disk/makefile
Normal file
|
@ -0,0 +1,41 @@
|
|||
# $Id: makefile,v 1.1 2001/07/24 10:21:15 ekohl Exp $
|
||||
#
|
||||
# disk.sys makefile
|
||||
#
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET=disk
|
||||
|
||||
OBJECTS = $(TARGET).o $(TARGET).coff
|
||||
|
||||
LIBS = $(PATH_TO_TOP)/ntoskrnl/ntoskrnl.a ../class2/class2.a
|
||||
|
||||
CFLAGS = -D__NTDRIVER__ -I.
|
||||
|
||||
all: $(TARGET).sys.unstripped $(TARGET).sys
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) *.o *.sym $(TARGET).coff junk.tmp base.tmp temp.exp $(TARGET).sys $(TARGET).sys.unstripped
|
||||
|
||||
.phony: clean
|
||||
|
||||
install: $(FLOPPY_DIR)/drivers/$(TARGET).sys
|
||||
|
||||
$(FLOPPY_DIR)/drivers/$(TARGET).sys: $(TARGET).sys
|
||||
$(CP) $(TARGET).sys $(FLOPPY_DIR)/drivers/$(TARGET).sys
|
||||
|
||||
dist: $(PATH_TO_TOP)/$(DIST_DIR)/drivers/$(TARGET).sys
|
||||
|
||||
$(PATH_TO_TOP)/$(DIST_DIR)/drivers/$(TARGET).sys: $(TARGET).sys
|
||||
$(CP) $(TARGET).sys $(PATH_TO_TOP)/$(DIST_DIR)/drivers/$(TARGET).sys
|
||||
|
||||
$(TARGET).sys $(TARGET).sys.unstripped: $(OBJECTS) $(LIBS)
|
||||
|
||||
WITH_DEBUGGING=yes
|
||||
WARNINGS_ARE_ERRORS = yes
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
#EOF
|
41
reactos/drivers/storage/disk/partitio.h
Normal file
41
reactos/drivers/storage/disk/partitio.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
*** Partition.h - defines and structs for harddrive partition info
|
||||
***
|
||||
*** 05/30/98 RJJ Created
|
||||
**/
|
||||
|
||||
#ifndef __PARTITION_H
|
||||
#define __PARTITION_H
|
||||
|
||||
#define PARTITION_MAGIC 0xaa55
|
||||
#define PART_MAGIC_OFFSET 0x01fe
|
||||
#define PARTITION_OFFSET 0x01be
|
||||
#define PARTITION_TBL_SIZE 4
|
||||
#define PTCHSToLBA(c, h, s, scnt, hcnt) ((s) & 0x3f) + \
|
||||
(scnt) * ( (h) + (hcnt) * ((c) | (((s) & 0xc0) << 2)))
|
||||
#define PTLBAToCHS(lba, c, h, s, scnt, hcnt) ( \
|
||||
(s) = (lba) % (scnt) + 1, \
|
||||
(lba) /= (scnt), \
|
||||
(h) = (lba) % (hcnt), \
|
||||
(lba) /= (heads), \
|
||||
(c) = (lba) & 0xff, \
|
||||
(s) |= ((lba) >> 2) & 0xc0)
|
||||
|
||||
|
||||
typedef struct Partition {
|
||||
unsigned char BootFlags;
|
||||
unsigned char StartingHead;
|
||||
unsigned char StartingSector;
|
||||
unsigned char StartingCylinder;
|
||||
unsigned char PartitionType;
|
||||
unsigned char EndingHead;
|
||||
unsigned char EndingSector;
|
||||
unsigned char EndingCylinder;
|
||||
unsigned int StartingBlock;
|
||||
unsigned int SectorCount;
|
||||
|
||||
} PARTITION;
|
||||
|
||||
#endif // PARTITION_H
|
||||
|
||||
|
Loading…
Reference in a new issue