📄 idechannel.java
字号:
public static final int WIN_FORMAT = 0x50; /* * 0x51->0x5F Reserved */ public static final int WIN_INIT = 0x60; /* * 0x61->0x5F Reserved */ public static final int WIN_SEEK = 0x70; /* 0x70-0x7F Reserved */ public static final int CFA_TRANSLATE_SECTOR = 0x87; /* CFA Translate Sector */ public static final int WIN_DIAGNOSE = 0x90; public static final int WIN_SPECIFY = 0x91; /* set drive geometry translation */ public static final int WIN_DOWNLOAD_MICROCODE = 0x92; public static final int WIN_STANDBYNOW2 = 0x94; public static final int WIN_STANDBY2 = 0x96; public static final int WIN_SETIDLE2 = 0x97; public static final int WIN_CHECKPOWERMODE2 = 0x98; public static final int WIN_SLEEPNOW2 = 0x99; /* * 0x9A VENDOR */ public static final int WIN_PACKETCMD = 0xA0; /* Send a packet command. */ public static final int WIN_PIDENTIFY = 0xA1; /* identify ATAPI device */ public static final int WIN_QUEUED_SERVICE = 0xA2; public static final int WIN_SMART = 0xB0; /* self-monitoring and reporting */ public static final int CFA_ERASE_SECTORS = 0xC0; public static final int WIN_MULTREAD = 0xC4; /* read sectors using multiple mode */ public static final int WIN_MULTWRITE = 0xC5; /* write sectors using multiple mod e */ public static final int WIN_SETMULT = 0xC6; /* enable/disable multiple mode */ public static final int WIN_READDMA_QUEUED = 0xC7; /* read sectors using Queued DMA tr ansfers */ public static final int WIN_READDMA = 0xC8; /* read sectors using DMA transfers */ public static final int WIN_READDMA_ONCE = 0xC9; /* 28-Bit - without retries */ public static final int WIN_WRITEDMA = 0xCA; /* write sectors using DMA transfer s */ public static final int WIN_WRITEDMA_ONCE = 0xCB; /* 28-Bit - without retries */ public static final int WIN_WRITEDMA_QUEUED = 0xCC; /* write sectors using Queued DMA t ransfers */ public static final int CFA_WRITE_MULTI_WO_ERASE = 0xCD; /* CFA Write multiple without erase */ public static final int WIN_GETMEDIASTATUS = 0xDA; public static final int WIN_ACKMEDIACHANGE = 0xDB; /* ATA-1, ATA-2 vendor */ public static final int WIN_POSTBOOT = 0xDC; public static final int WIN_PREBOOT = 0xDD; public static final int WIN_DOORLOCK = 0xDE; /* lock door on removable drives */ public static final int WIN_DOORUNLOCK = 0xDF; /* unlock door on removable drives */ public static final int WIN_STANDBYNOW1 = 0xE0; public static final int WIN_IDLEIMMEDIATE = 0xE1; /* force drive to become "ready" */ public static final int WIN_STANDBY = 0xE2; /* Set device in Standby Mode */ public static final int WIN_SETIDLE1 = 0xE3; public static final int WIN_READ_BUFFER = 0xE4; /* force read only 1 sector */ public static final int WIN_CHECKPOWERMODE1 = 0xE5; public static final int WIN_SLEEPNOW1 = 0xE6; public static final int WIN_FLUSH_CACHE = 0xE7; public static final int WIN_WRITE_BUFFER = 0xE8; /* force write only 1 sector */ public static final int WIN_WRITE_SAME = 0xE9; /* read ata-2 to use */ /* SET_FEATURES 0x22 or 0xDD */ public static final int WIN_FLUSH_CACHE_EXT = 0xEA; /* 48-Bit */ public static final int WIN_IDENTIFY = 0xEC; /* ask drive to identify itself */ public static final int WIN_MEDIAEJECT = 0xED; public static final int WIN_IDENTIFY_DMA = 0xEE; /* same as WIN_IDENTIFY, but DMA */ public static final int WIN_SETFEATURES = 0xEF; /* set special drive features */ public static final int EXABYTE_ENABLE_NEST = 0xF0; public static final int WIN_SECURITY_SET_PASS = 0xF1; public static final int WIN_SECURITY_UNLOCK = 0xF2; public static final int WIN_SECURITY_ERASE_PREPARE = 0xF3; public static final int WIN_SECURITY_ERASE_UNIT = 0xF4; public static final int WIN_SECURITY_FREEZE_LOCK = 0xF5; public static final int WIN_SECURITY_DISABLE = 0xF6; public static final int WIN_READ_NATIVE_MAX = 0xF8; /* return the native maximum address */ public static final int WIN_SET_MAX = 0xF9; public static final int DISABLE_SEAGATE = 0xFB; /* set to 1 set disable mult support */ public static final int MAX_MULT_SECTORS = 16; /* ATAPI defines */ public static final int ATAPI_PACKET_SIZE = 12;/* The generic packet command opcodes for CD/DVD Logical Units, * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ public static final int GPCMD_BLANK = 0xa1; public static final int GPCMD_CLOSE_TRACK = 0x5b; public static final int GPCMD_FLUSH_CACHE = 0x35; public static final int GPCMD_FORMAT_UNIT = 0x04; public static final int GPCMD_GET_CONFIGURATION = 0x46; public static final int GPCMD_GET_EVENT_STATUS_NOTIFICATION = 0x4a; public static final int GPCMD_GET_PERFORMANCE = 0xac; public static final int GPCMD_INQUIRY = 0x12; public static final int GPCMD_LOAD_UNLOAD = 0xa6; public static final int GPCMD_MECHANISM_STATUS = 0xbd; public static final int GPCMD_MODE_SELECT_10 = 0x55; public static final int GPCMD_MODE_SENSE_10 = 0x5a; public static final int GPCMD_PAUSE_RESUME = 0x4b; public static final int GPCMD_PLAY_AUDIO_10 = 0x45; public static final int GPCMD_PLAY_AUDIO_MSF = 0x47; public static final int GPCMD_PLAY_AUDIO_TI = 0x48; public static final int GPCMD_PLAY_CD = 0xbc; public static final int GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1e; public static final int GPCMD_READ_10 = 0x28; public static final int GPCMD_READ_12 = 0xa8; public static final int GPCMD_READ_CDVD_CAPACITY = 0x25; public static final int GPCMD_READ_CD = 0xbe; public static final int GPCMD_READ_CD_MSF = 0xb9; public static final int GPCMD_READ_DISC_INFO = 0x51; public static final int GPCMD_READ_DVD_STRUCTURE = 0xad; public static final int GPCMD_READ_FORMAT_CAPACITIES = 0x23; public static final int GPCMD_READ_HEADER = 0x44; public static final int GPCMD_READ_TRACK_RZONE_INFO = 0x52; public static final int GPCMD_READ_SUBCHANNEL = 0x42; public static final int GPCMD_READ_TOC_PMA_ATIP = 0x43;; public static final int GPCMD_REPAIR_RZONE_TRACK = 0x58; public static final int GPCMD_REPORT_KEY = 0xa4; public static final int GPCMD_REQUEST_SENSE = 0x03; public static final int GPCMD_RESERVE_RZONE_TRACK = 0x53; public static final int GPCMD_SCAN = 0xba; public static final int GPCMD_SEEK = 0x2b; public static final int GPCMD_SEND_DVD_STRUCTURE = 0xad; public static final int GPCMD_SEND_EVENT = 0xa2; public static final int GPCMD_SEND_KEY = 0xa3; public static final int GPCMD_SEND_OPC = 0x54; public static final int GPCMD_SET_READ_AHEAD = 0xa7; public static final int GPCMD_SET_STREAMING = 0xb6; public static final int GPCMD_START_STOP_UNIT = 0x1b; public static final int GPCMD_STOP_PLAY_SCAN = 0x4e; public static final int GPCMD_TEST_UNIT_READY = 0x00; public static final int GPCMD_VERIFY_10 = 0x2f; public static final int GPCMD_WRITE_10 = 0x2a; public static final int GPCMD_WRITE_AND_VERIFY_10 = 0x2e;/* This is listed as optional in ATAPI 2.6, but is (curiously) * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji * Table 377 as an MMC command for SCSi devices though... Most ATAPI * drives support it. */ public static final int GPCMD_SET_SPEED = 0xbb;/* This seems to be a SCSI specific CD-ROM opcode * to play data at track/index */ public static final int GPCMD_PLAYAUDIO_TI = 0x48;/* * From MS Media Status Notification Support Specification. For * older drives only. */ public static final int GPCMD_GET_MEDIA_STATUS = 0xda;/* Mode page codes for mode sense/set */ public static final int GPMODE_R_W_ERROR_PAGE = 0x01; public static final int GPMODE_WRITE_PARMS_PAGE = 0x05; public static final int GPMODE_AUDIO_CTL_PAGE = 0x0e; public static final int GPMODE_POWER_PAGE = 0x1a; public static final int GPMODE_FAULT_FAIL_PAGE = 0x1c; public static final int GPMODE_TO_PROTECT_PAGE = 0x1d; public static final int GPMODE_CAPABILITIES_PAGE = 0x2a; public static final int GPMODE_ALL_PAGES = 0x3f;/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor * of MODE_SENSE_POWER_PAGE */ public static final int GPMODE_CDROM_PAGE = 0x0d; public static final int ATAPI_INT_REASON_CD = 0x01; /* 0 = data transfer */ public static final int ATAPI_INT_REASON_IO = 0x02; /* 1 = transfer to the host */ public static final int ATAPI_INT_REASON_REL = 0x04; public static final int ATAPI_INT_REASON_TAG = 0xf8;/* same constants as bochs */ public static final int ASC_ILLEGAL_OPCODE = 0x20; public static final int ASC_LOGICAL_BLOCK_OOR = 0x21; public static final int ASC_INV_FIELD_IN_CMD_PACKET = 0x24; public static final int ASC_MEDIUM_NOT_PRESENT = 0x3a; public static final int ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39; public static final int SENSE_NONE = 0; public static final int SENSE_NOT_READY = 2; public static final int SENSE_ILLEGAL_REQUEST = 5; public static final int SENSE_UNIT_ATTENTION = 6; public static final int ETF_TRANSFER_STOP = 1; public static final int ETF_SECTOR_WRITE = 2; public static final int ETF_SECTOR_READ = 3; public static final int ETF_ATAPI_COMMAND = 4; public static final int ETF_ATAPI_COMMAND_REPLY_END = 5; public static final int ETF_DUMMY_TRANSFER_STOP = 6; public static final int IDF_NONE = 0; public static final int IDF_WRITE_DMA_CB = 1; public static final int IDF_READ_DMA_CB = 2; public static final int IDF_ATAPI_READ_DMA_CB = 3; public static final String HD_VERSION = "0.01"; private int cylinders, heads, sectors; public byte status, command, error, feature, select; public byte hcyl, lcyl; public byte sector; public int nSector; public int endTransferFunction; public boolean isCDROM; public boolean atapiDMA; public int requiredNumberOfSectors; public int multSectors; public int driveSerial; //lba48 support public byte hobFeature; public byte hobNSector; public byte hobSector; public byte hobLCyl; public byte hobHCyl; public boolean lba48; public byte[] ioBuffer; private int ioBufferSize; private int ioBufferIndex; public byte[] dataBuffer; public int dataBufferOffset; public int dataBufferEnd; public boolean identifySet; public byte[] identifyData; public byte senseKey; public byte asc; public int elementaryTransferSize; public int packetTransferSize; public int lba; public int cdSectorSize; //public long numberOfSectors; //forwarded through to blockdevice, prevents need for cdrom callback public BlockDevice drive; public BMDMAIORegion bmdma; public IDEState(BlockDevice drive) { this.drive = drive; if (drive != null) { //this.numberOfSectors = drive.getTotalSectors(); this.cylinders = drive.cylinders(); this.heads = drive.heads(); this.sectors = drive.sectors(); if (drive.type() == BlockDevice.TYPE_CDROM) { this.isCDROM = true; } } ioBuffer = new byte[MAX_MULT_SECTORS*512 + 4]; identifyData = new byte[512]; identifySet = false; lba48 = false; this.driveSerial = nextDriveSerial++; this.reset(); } public void setDrive(BlockDevice drive) { this.drive = drive; } public void dumpState(DataOutput output) throws IOException { output.writeInt(cylinders); output.writeInt(heads); output.writeInt(sectors); output.writeByte(status); output.writeByte(command); output.writeByte(error); output.writeByte(feature); output.writeByte(select); output.writeByte(hcyl); output.writeByte(lcyl); output.writeByte(sector); output.writeInt(nSector); output.writeInt(endTransferFunction); output.writeBoolean(isCDROM); output.writeBoolean(atapiDMA); output.writeInt(requiredNumberOfSectors); output.writeInt(multSectors); output.writeInt(driveSerial); output.writeByte(hobFeature); output.writeByte(hobNSector); output.writeByte(hobSector); output.writeByte(hobLCyl); output.writeByte(hobHCyl); output.writeBoolean(lba48); output.writeInt(ioBuffer.length); output.write(ioBuffer); output.writeInt(ioBufferSize); output.writeInt(ioBufferIndex); output.writeInt(dataBuffer.length); output.write(dataBuffer); output.writeInt(dataBufferOffset); output.writeInt(dataBufferEnd); output.writeBoolean(identifySet); output.writeInt(identifyData.length); output.write(identifyData); output.writeByte(senseKey); output.writeByte(asc); output.writeInt(elementaryTransferSize); output.writeInt(packetTransferSize); output.writeInt(lba); output.writeInt(cdSectorSize); } public void loadState(DataInput input) throws IOException { cylinders = input.readInt(); heads = input.readInt(); sectors = input.readInt(); status = input.readByte(); command = input.readByte(); error = input.readByte(); feature = input.readByte(); select = input.readByte(); hcyl = input.readByte(); lcyl = input.readByte(); sector = input.readByte(); nSector = input.readInt(); endTransferFunction = input.readInt(); isCDROM = input.readBoolean(); atapiDMA = input.readBoolean(); requiredNumberOfSectors = input.readInt(); multSectors = input.readInt(); driveSerial = input.readInt(); hobFeature = input.readByte(); hobNSector = input.readByte(); hobSector = input.readByte(); hobLCyl = input.readByte(); hobHCyl = input.readByte(); lba48 = input.readBoolean(); int len = input.readInt(); ioBuffer = new byte[len]; input.readFully(ioBuffer,0,len); ioBufferSize = input.readInt(); ioBufferIndex = input.readInt(); len = input.readInt(); dataBuffer = new byte[len]; input.readFully(dataBuffer,0,len); dataBufferOffset = input.readInt(); dataBufferEnd = input.readInt(); identifySet = input.readBoolean(); len = input.readInt(); identifyData = new byte[len]; input.readFully(identifyData,0,len); senseKey = input.readByte(); asc = input.readByte(); elementaryTransferSize = input.readInt(); packetTransferSize = input.readInt(); lba = input.readInt(); cdSectorSize = input.readInt(); bmdma.setIDEDevice(this); } public boolean initialised() { return true;} public int dmaCallback(int ideDMAFunction, int address, int size) { switch (ideDMAFunction) { case IDF_ATAPI_READ_DMA_CB: return atapiCommandReadDMACallback(address, size); default: System.err.println("Need DMA Callback Function " + ideDMAFunction); return 0; } } public void setSignature() { this.select &= 0xf0; /* clear head */ /* put signature */ this.nSector = 1; this.sector = 1; if (this.isCDROM) { this.lcyl = (byte)0x14; this.hcyl = (byte)0xeb; } else if (this.drive != null) { this.lcyl = 0; this.hcyl = 0; } else { this.lcyl = (byte)0xff; this.hcyl = (byte)0xff; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -