Changeset 48409 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Sep 10, 2013 1:22:32 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r48399 r48409 3061 3061 static int atapiRequestSenseSS(PAHCIREQ, PAHCIPort, size_t, size_t *); 3062 3062 static int atapiPassthroughSS(PAHCIREQ, PAHCIPort, size_t, size_t *); 3063 static int atapiReadDVDStructureSS(PAHCIREQ, PAHCIPort, size_t, size_t *); 3063 3064 3064 3065 /** … … 3083 3084 ATAFN_SS_ATAPI_REQUEST_SENSE, 3084 3085 ATAFN_SS_ATAPI_PASSTHROUGH, 3086 ATAFN_SS_ATAPI_READ_DVD_STRUCTURE, 3085 3087 ATAFN_SS_MAX 3086 3088 } ATAPIFN; … … 3107 3109 atapiReadTrackInformationSS, 3108 3110 atapiRequestSenseSS, 3109 atapiPassthroughSS 3111 atapiPassthroughSS, 3112 atapiReadDVDStructureSS 3110 3113 }; 3111 3114 … … 4064 4067 4065 4068 return VINF_SUCCESS; 4069 } 4070 4071 /** @todo: Revise ASAP. */ 4072 /* Keep in sync with DevATA.cpp! */ 4073 static int atapiReadDVDStructureSS(PAHCIREQ pAhciReq, PAHCIPort pAhciPort, size_t cbData, size_t *pcbData) 4074 { 4075 uint8_t aBuf[25]; /* Counted a maximum of 20 bytes but better be on the safe side. */ 4076 uint8_t *buf = aBuf; 4077 int media = pAhciReq->aATAPICmd[1]; 4078 int format = pAhciReq->aATAPICmd[7]; 4079 4080 uint16_t max_len = ataBE2H_U16(&pAhciReq->aATAPICmd[8]); 4081 4082 memset(buf, 0, max_len); 4083 4084 switch (format) { 4085 case 0x00: 4086 case 0x01: 4087 case 0x02: 4088 case 0x03: 4089 case 0x04: 4090 case 0x05: 4091 case 0x06: 4092 case 0x07: 4093 case 0x08: 4094 case 0x09: 4095 case 0x0a: 4096 case 0x0b: 4097 case 0x0c: 4098 case 0x0d: 4099 case 0x0e: 4100 case 0x0f: 4101 case 0x10: 4102 case 0x11: 4103 case 0x30: 4104 case 0x31: 4105 case 0xff: 4106 if (media == 0) 4107 { 4108 int uASC = SCSI_ASC_NONE; 4109 4110 switch (format) 4111 { 4112 case 0x0: /* Physical format information */ 4113 { 4114 int layer = pAhciReq->aATAPICmd[6]; 4115 uint64_t total_sectors; 4116 4117 if (layer != 0) 4118 { 4119 uASC = -SCSI_ASC_INV_FIELD_IN_CMD_PACKET; 4120 break; 4121 } 4122 4123 total_sectors = pAhciPort->cTotalSectors; 4124 total_sectors >>= 2; 4125 if (total_sectors == 0) 4126 { 4127 uASC = -SCSI_ASC_MEDIUM_NOT_PRESENT; 4128 break; 4129 } 4130 4131 buf[4] = 1; /* DVD-ROM, part version 1 */ 4132 buf[5] = 0xf; /* 120mm disc, minimum rate unspecified */ 4133 buf[6] = 1; /* one layer, read-only (per MMC-2 spec) */ 4134 buf[7] = 0; /* default densities */ 4135 4136 /* FIXME: 0x30000 per spec? */ 4137 ataH2BE_U32(buf + 8, 0); /* start sector */ 4138 ataH2BE_U32(buf + 12, total_sectors - 1); /* end sector */ 4139 ataH2BE_U32(buf + 16, total_sectors - 1); /* l0 end sector */ 4140 4141 /* Size of buffer, not including 2 byte size field */ 4142 ataH2BE_U32(&buf[0], 2048 + 2); 4143 4144 /* 2k data + 4 byte header */ 4145 uASC = (2048 + 4); 4146 } 4147 break; 4148 case 0x01: /* DVD copyright information */ 4149 buf[4] = 0; /* no copyright data */ 4150 buf[5] = 0; /* no region restrictions */ 4151 4152 /* Size of buffer, not including 2 byte size field */ 4153 ataH2BE_U16(buf, 4 + 2); 4154 4155 /* 4 byte header + 4 byte data */ 4156 uASC = (4 + 4); 4157 4158 case 0x03: /* BCA information - invalid field for no BCA info */ 4159 uASC = -SCSI_ASC_INV_FIELD_IN_CMD_PACKET; 4160 break; 4161 4162 case 0x04: /* DVD disc manufacturing information */ 4163 /* Size of buffer, not including 2 byte size field */ 4164 ataH2BE_U16(buf, 2048 + 2); 4165 4166 /* 2k data + 4 byte header */ 4167 uASC = (2048 + 4); 4168 break; 4169 case 0xff: 4170 /* 4171 * This lists all the command capabilities above. Add new ones 4172 * in order and update the length and buffer return values. 4173 */ 4174 4175 buf[4] = 0x00; /* Physical format */ 4176 buf[5] = 0x40; /* Not writable, is readable */ 4177 ataH2BE_U16((buf + 6), 2048 + 4); 4178 4179 buf[8] = 0x01; /* Copyright info */ 4180 buf[9] = 0x40; /* Not writable, is readable */ 4181 ataH2BE_U16((buf + 10), 4 + 4); 4182 4183 buf[12] = 0x03; /* BCA info */ 4184 buf[13] = 0x40; /* Not writable, is readable */ 4185 ataH2BE_U16((buf + 14), 188 + 4); 4186 4187 buf[16] = 0x04; /* Manufacturing info */ 4188 buf[17] = 0x40; /* Not writable, is readable */ 4189 ataH2BE_U16((buf + 18), 2048 + 4); 4190 4191 /* Size of buffer, not including 2 byte size field */ 4192 ataH2BE_U16(buf, 16 + 2); 4193 4194 /* data written + 4 byte header */ 4195 uASC = (16 + 4); 4196 break; 4197 default: /* TODO: formats beyond DVD-ROM requires */ 4198 uASC = -SCSI_ASC_INV_FIELD_IN_CMD_PACKET; 4199 } 4200 4201 if (uASC < 0) 4202 { 4203 atapiCmdErrorSimple(pAhciPort, pAhciReq, SCSI_SENSE_ILLEGAL_REQUEST, -uASC); 4204 return false; 4205 } 4206 break; 4207 } 4208 /* TODO: BD support, fall through for now */ 4209 4210 /* Generic disk structures */ 4211 case 0x80: /* TODO: AACS volume identifier */ 4212 case 0x81: /* TODO: AACS media serial number */ 4213 case 0x82: /* TODO: AACS media identifier */ 4214 case 0x83: /* TODO: AACS media key block */ 4215 case 0x90: /* TODO: List of recognized format layers */ 4216 case 0xc0: /* TODO: Write protection status */ 4217 default: 4218 atapiCmdErrorSimple(pAhciPort, pAhciReq, SCSI_SENSE_ILLEGAL_REQUEST, 4219 SCSI_ASC_INV_FIELD_IN_CMD_PACKET); 4220 return false; 4221 } 4222 4223 /* Copy the buffer into the scatter gather list. */ 4224 *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], 4225 RT_MIN(cbData, max_len)); 4226 4227 atapiCmdOK(pAhciPort, pAhciReq); 4228 return false; 4066 4229 } 4067 4230 … … 4499 4662 cbMax = pbPacket[4]; 4500 4663 atapiDoTransfer(pAhciPort, pAhciReq, cbMax, ATAFN_SS_ATAPI_INQUIRY); 4664 break; 4665 case SCSI_READ_DVD_STRUCTURE: 4666 cbMax = ataBE2H_U16(pbPacket + 8); 4667 atapiDoTransfer(pAhciPort, pAhciReq, cbMax, ATAFN_SS_ATAPI_READ_DVD_STRUCTURE); 4501 4668 break; 4502 4669 default:
Note:
See TracChangeset
for help on using the changeset viewer.