Add enum for feature profiles. Add feature to string conversion routines.

This commit is contained in:
rocky
2005-02-08 04:14:28 +00:00
parent b80ab25c6f
commit a1c206fe3b
5 changed files with 404 additions and 537 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: mmc2.c,v 1.3 2005/02/07 03:36:02 rocky Exp $
$Id: mmc2.c,v 1.4 2005/02/08 04:14:28 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -67,250 +67,115 @@ main(int argc, const char *argv[])
uint8_t i_feature_additional = p[3];
i_feature = CDIO_MMC_GET_LEN16(p);
switch( i_feature )
{
uint8_t *q;
case CDIO_MMC_FEATURE_PROFILE_LIST:
printf("Profile List Feature\n");
for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) {
int i_profile=CDIO_MMC_GET_LEN16(q);
switch (i_profile) {
case CDIO_MMC_FEATURE_PROF_NON_REMOVABLE:
printf("\tRe-writable disk, capable of changing behavior");
break;
case CDIO_MMC_FEATURE_PROF_REMOVABLE:
printf("\tdisk Re-writable; with removable media");
break;
case CDIO_MMC_FEATURE_PROF_MO_ERASABLE:
printf("\tErasable Magneto-Optical disk with sector erase capability");
break;
case CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE:
printf("\tWrite Once Magneto-Optical write once");
break;
case CDIO_MMC_FEATURE_PROF_AS_MO:
printf("\tAdvance Storage Magneto-Optical");
break;
case CDIO_MMC_FEATURE_PROF_CD_ROM:
printf("\tRead only Compact Disc capable");
break;
case CDIO_MMC_FEATURE_PROF_CD_R:
printf("\tWrite once Compact Disc capable");
break;
case CDIO_MMC_FEATURE_PROF_CD_RW:
printf("\tCD-RW Re-writable Compact Disc capable");
break;
case CDIO_MMC_FEATURE_PROF_DVD_ROM:
printf("\tRead only DVD");
break;
case CDIO_MMC_FEATURE_PROF_DVD_R_SEQ:
printf("\tRe-recordable DVD using Sequential recording");
break;
case CDIO_MMC_FEATURE_PROF_DVD_RAM:
printf("\tRe-writable DVD");
break;
case CDIO_MMC_FEATURE_PROF_DVD_RW_RO:
printf("\tRe-recordable DVD using Restricted Overwrite");
break;
case CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ:
printf("\tRe-recordable DVD using Sequential recording");
break;
case CDIO_MMC_FEATURE_PROF_DVD_PRW:
printf("\tDVD+RW - DVD ReWritable");
break;
case CDIO_MMC_FEATURE_PROF_DVD_PR:
printf("\tDVD+R - DVD Recordable");
break;
case CDIO_MMC_FEATURE_PROF_DDCD_ROM:
printf("\tRead only DDCD");
break;
case CDIO_MMC_FEATURE_PROF_DDCD_R:
printf("\tDDCD-R Write only DDCD");
break;
case CDIO_MMC_FEATURE_PROF_DDCD_RW:
printf("\tRe-Write only DDCD");
break;
case CDIO_MMC_FEATURE_PROF_NON_CONFORM:
printf("\tThe Logical Unit does not conform to any Profile.");
break;
default:
printf("\tUnknown Profile %x", i_profile);
break;
}
if (q[2] & 1) {
printf(" - on");
{
uint8_t *q;
const char *feature_str = mmc_feature2str(i_feature);
printf("%s Feature\n", feature_str);
switch( i_feature )
{
case CDIO_MMC_FEATURE_PROFILE_LIST:
for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) {
int i_profile=CDIO_MMC_GET_LEN16(q);
const char *feature_profile_str =
mmc_feature_profile2str(i_profile);
printf( "\t%s", feature_profile_str );
if (q[2] & 1) {
printf(" - on");
}
printf("\n");
}
printf("\n");
}
printf("\n");
break;
case CDIO_MMC_FEATURE_CORE:
{
uint8_t *q = p+4;
uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q);
printf("Core Feature\n");
switch(i_interface_standard) {
case 0:
printf("\tunspecified interface\n");
break;
case CDIO_MMC_FEATURE_CORE:
{
uint8_t *q = p+4;
uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q);
switch(i_interface_standard) {
case 0:
printf("\tunspecified interface\n");
break;
case 1:
printf("\tSCSI interface\n");
break;
case 2:
printf("\tATAPI interface\n");
break;
case 3:
printf("\tIEEE 1394 interface\n");
break;
case 4:
printf("\tIEEE 1394A interface\n");
break;
case 5:
printf("\tFibre Channel interface\n");
}
printf("\n");
break;
case 1:
printf("\tSCSI interface\n");
}
case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM:
switch(p[4] >> 5) {
case 0:
printf("\tCaddy/Slot type loading mechanism\n");
break;
case 2:
printf("\tATAPI interface\n");
case 1:
printf("\tTray type loading mechanism\n");
break;
case 3:
printf("\tIEEE 1394 interface\n");
case 2:
printf("\tPop-up type loading mechanism\n");
break;
case 4:
printf("\tIEEE 1394A interface\n");
printf("\tEmbedded changer with individually changeable discs\n");
break;
case 5:
printf("\tFibre Channel interface\n");
printf("\tEmbedded changer using a magazine mechanism\n");
break;
default:
printf("\tUnknown changer mechanism\n");
}
printf("\tcan%s eject the medium or magazine via the normal "
"START/STOP command\n",
(p[4] & 8) ? "": "not");
printf("\tcan%s be locked into the Logical Unit\n",
(p[4] & 1) ? "": "not");
printf("\n");
break;
case CDIO_MMC_FEATURE_CD_READ:
printf("CD Read Feature\n");
printf("\tC2 Error pointers are %ssupported\n",
(p[4] & 2) ? "": "not ");
printf("\tCD-Text is %ssupported\n",
(p[4] & 1) ? "": "not ");
printf("\n");
break;
case CDIO_MMC_FEATURE_CDDA_EXT_PLAY:
printf("\tSCAN command is %ssupported\n",
(p[4] & 4) ? "": "not ");
printf("\taudio channels can %sbe muted separately\n",
(p[4] & 2) ? "": "not ");
printf("\taudio channels can %shave separate volume levels\n",
(p[4] & 1) ? "": "not ");
{
uint8_t *q = p+6;
uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q);
printf("\t%d volume levels can be set\n", i_vol_levels);
}
printf("\n");
break;
case CDIO_MMC_FEATURE_LU_SN: {
uint8_t i_serial = *(p+3);
char serial[257] = { '\0', };
memcpy(serial, p+4, i_serial);
printf("\t%s\n\n", serial);
break;
}
case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM:
printf("Removable Medium Feature\n");
switch(p[4] >> 5) {
case 0:
printf("\tCaddy/Slot type loading mechanism\n");
default:
printf("\n");
break;
case 1:
printf("\tTray type loading mechanism\n");
break;
case 2:
printf("\tPop-up type loading mechanism\n");
break;
case 4:
printf("\tEmbedded changer with individually changeable discs\n");
break;
case 5:
printf("\tEmbedded changer using a magazine mechanism\n");
break;
default:
printf("\tUnknown changer mechanism\n");
}
printf("\tcan%s eject the medium or magazine via the normal "
"START/STOP command\n",
(p[4] & 8) ? "": "not");
printf("\tcan%s be locked into the Logical Unit\n",
(p[4] & 1) ? "": "not");
printf("\n");
break;
case CDIO_MMC_FEATURE_WRITE_PROTECT:
printf("Write Protect Feature\n");
break;
case CDIO_MMC_FEATURE_RANDOM_READABLE:
printf("Random Readable Feature\n");
break;
case CDIO_MMC_FEATURE_MULTI_READ:
printf("Multi-Read Feature\n");
break;
case CDIO_MMC_FEATURE_CD_READ:
printf("CD Read Feature\n");
printf("\tC2 Error pointers are %ssupported\n",
(p[4] & 2) ? "": "not ");
printf("\tCD-Text is %ssupported\n",
(p[4] & 1) ? "": "not ");
printf("\n");
break;
case CDIO_MMC_FEATURE_DVD_READ:
printf("DVD Read Feature\n");
break;
case CDIO_MMC_FEATURE_RANDOM_WRITABLE:
printf("Random Writable Feature\n");
break;
case CDIO_MMC_FEATURE_INCR_WRITE:
printf("Incremental Streaming Writable Feature\n");
break;
case CDIO_MMC_FEATURE_SECTOR_ERASE:
printf("Sector Erasable Feature\n");
break;
case CDIO_MMC_FEATURE_FORMATABLE:
printf("Formattable Feature\n");
break;
case CDIO_MMC_FEATURE_DEFECT_MGMT:
printf("Management Ability of the Logical Unit/media system "
"to provide an apparently defect-free space.\n");
break;
case CDIO_MMC_FEATURE_WRITE_ONCE:
printf("Write Once Feature\n");
break;
case CDIO_MMC_FEATURE_RESTRICT_OVERW:
printf("Restricted Overwrite Feature\n");
break;
case CDIO_MMC_FEATURE_CD_RW_CAV:
printf("CD-RW CAV Write Feature\n");
break;
case CDIO_MMC_FEATURE_MRW:
printf("MRW Feature\n");
break;
case CDIO_MMC_FEATURE_DVD_PRW:
printf("DVD+RW Feature\n");
break;
case CDIO_MMC_FEATURE_DVD_PR:
printf("DVD+R Feature\n");
break;
case CDIO_MMC_FEATURE_CD_TAO:
printf("CD Track at Once Feature\n");
break;
case CDIO_MMC_FEATURE_CD_SAO:
printf("CD Mastering (Session at Once) Feature\n");
break;
case CDIO_MMC_FEATURE_POWER_MGMT:
printf("Initiator and device directed power management\n");
break;
case CDIO_MMC_FEATURE_CDDA_EXT_PLAY:
printf("CD Audio External Play Feature\n");
printf("\tSCAN command is %ssupported\n",
(p[4] & 4) ? "": "not ");
printf("\taudio channels can %sbe muted separately\n",
(p[4] & 2) ? "": "not ");
printf("\taudio channels can %shave separate volume levels\n",
(p[4] & 1) ? "": "not ");
{
uint8_t *q = p+6;
uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q);
printf("\t%d volume levels can be set\n", i_vol_levels);
}
printf("\n");
break;
case CDIO_MMC_FEATURE_MCODE_UPGRADE:
printf("Ability for the device to accept new microcode via "
"the interface\n");
break;
case CDIO_MMC_FEATURE_TIME_OUT:
printf("Ability to respond to all commands within a "
"specific time\n");
break;
case CDIO_MMC_FEATURE_DVD_CSS:
printf("Ability to perform DVD CSS/CPPM authentication and"
" RPC\n");
break;
case CDIO_MMC_FEATURE_RT_STREAMING:
printf("Ability to read and write using Initiator requested performance parameters\n");
break;
case CDIO_MMC_FEATURE_LU_SN: {
uint8_t i_serial = *(p+3);
char serial[257] = { '\0', };
printf("The Logical Unit has a unique identifier:\n");
memcpy(serial, p+4, i_serial);
printf("\t%s\n\n", serial);
break;
}
default:
if ( 0 != (i_feature & 0xFF00) ) {
printf("Vendor-specific feature code %x\n", i_feature);
} else {
printf("Unknown feature code %x\n", i_feature);
}
}
p += i_feature_additional + 4;
p += i_feature_additional + 4;
}
}
} else {
printf("Didn't get all feature codes\n");