1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 30*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 31*7c478bd9Sstevel@tonic-gate #include <libintl.h> 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #include "msgs.h" 34*7c478bd9Sstevel@tonic-gate #include "mmc.h" 35*7c478bd9Sstevel@tonic-gate #include "misc_scsi.h" 36*7c478bd9Sstevel@tonic-gate #include "device.h" 37*7c478bd9Sstevel@tonic-gate #include "main.h" 38*7c478bd9Sstevel@tonic-gate #include "util.h" 39*7c478bd9Sstevel@tonic-gate #include "toshiba.h" 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate void 42*7c478bd9Sstevel@tonic-gate info(void) 43*7c478bd9Sstevel@tonic-gate { 44*7c478bd9Sstevel@tonic-gate uchar_t *toc, *p; 45*7c478bd9Sstevel@tonic-gate int ret, toc_size; 46*7c478bd9Sstevel@tonic-gate char *msg; 47*7c478bd9Sstevel@tonic-gate struct track_info *ti; 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate msg = gettext("Cannot read Table of contents\n"); 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate get_media_type(target->d_fd); 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate (void) printf(gettext("\nDevice : %.8s %.16s\n"), 54*7c478bd9Sstevel@tonic-gate &target->d_inq[8], &target->d_inq[16]); 55*7c478bd9Sstevel@tonic-gate (void) printf(gettext("Firmware : Rev. %.4s (%.12s)\n"), 56*7c478bd9Sstevel@tonic-gate &target->d_inq[32], &target->d_inq[36]); 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate if (check_device(target, CHECK_DEVICE_NOT_READY)) { 59*7c478bd9Sstevel@tonic-gate (void) check_device(target, CHECK_NO_MEDIA | 60*7c478bd9Sstevel@tonic-gate EXIT_IF_CHECK_FAILED); 61*7c478bd9Sstevel@tonic-gate (void) check_device(target, CHECK_DEVICE_NOT_READY | 62*7c478bd9Sstevel@tonic-gate EXIT_IF_CHECK_FAILED); 63*7c478bd9Sstevel@tonic-gate } 64*7c478bd9Sstevel@tonic-gate if (!check_device(target, CHECK_MEDIA_IS_NOT_BLANK)) { 65*7c478bd9Sstevel@tonic-gate (void) printf(gettext("Media is blank\n")); 66*7c478bd9Sstevel@tonic-gate exit(0); 67*7c478bd9Sstevel@tonic-gate } 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate /* Find out the number of entries in the toc */ 70*7c478bd9Sstevel@tonic-gate toc = (uchar_t *)my_zalloc(12); 71*7c478bd9Sstevel@tonic-gate if (!read_toc(target->d_fd, 0, 1, 4, toc)) { 72*7c478bd9Sstevel@tonic-gate err_msg(msg); 73*7c478bd9Sstevel@tonic-gate } else { 74*7c478bd9Sstevel@tonic-gate toc_size = 256*toc[0] + toc[1] + 2; 75*7c478bd9Sstevel@tonic-gate free(toc); 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate /* allocate enough space for each track entry */ 78*7c478bd9Sstevel@tonic-gate toc = (uchar_t *)my_zalloc(toc_size); 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate if (!read_toc(target->d_fd, 0, 1, toc_size, toc)) { 81*7c478bd9Sstevel@tonic-gate err_msg(msg); 82*7c478bd9Sstevel@tonic-gate exit(1); 83*7c478bd9Sstevel@tonic-gate } 84*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* l10n_NOTE : Preserve column numbers of '|' character */ 87*7c478bd9Sstevel@tonic-gate (void) printf(gettext("Track No. |Type |Start address\n")); 88*7c478bd9Sstevel@tonic-gate (void) printf("----------+--------+-------------\n"); 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate /* look at each track and display it's type. */ 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate for (p = &toc[4]; p < (toc + toc_size); p += 8) { 94*7c478bd9Sstevel@tonic-gate if (p[2] != 0xAA) 95*7c478bd9Sstevel@tonic-gate (void) printf(" %-3d |", p[2]); 96*7c478bd9Sstevel@tonic-gate else 97*7c478bd9Sstevel@tonic-gate (void) printf("Leadout |"); 98*7c478bd9Sstevel@tonic-gate (void) printf("%s |", (p[1] & 4) ? gettext("Data ") : 99*7c478bd9Sstevel@tonic-gate gettext("Audio")); 100*7c478bd9Sstevel@tonic-gate (void) printf("%u\n", read_scsi32(&p[4])); 101*7c478bd9Sstevel@tonic-gate } 102*7c478bd9Sstevel@tonic-gate } 103*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 104*7c478bd9Sstevel@tonic-gate ret = read_toc(target->d_fd, 1, 0, 12, toc); 105*7c478bd9Sstevel@tonic-gate if ((ret == 0) || (toc[1] != 0x0a)) 106*7c478bd9Sstevel@tonic-gate /* For ATAPI drives or old Toshiba drives */ 107*7c478bd9Sstevel@tonic-gate ret = read_toc_as_per_8020(target->d_fd, 1, 0, 12, toc); 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate if (ret && (toc[1] == 0x0a)) { 110*7c478bd9Sstevel@tonic-gate (void) printf(gettext("Last session start address: %u\n"), 111*7c478bd9Sstevel@tonic-gate read_scsi32(&toc[8])); 112*7c478bd9Sstevel@tonic-gate } 113*7c478bd9Sstevel@tonic-gate free(toc); 114*7c478bd9Sstevel@tonic-gate ti = (struct track_info *)my_zalloc(sizeof (struct track_info)); 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate if (build_track_info(target, -1, ti) && (ti->ti_flags & TI_NWA_VALID)) { 117*7c478bd9Sstevel@tonic-gate (void) printf(gettext("Next writable address: %u\n"), 118*7c478bd9Sstevel@tonic-gate ti->ti_nwa); 119*7c478bd9Sstevel@tonic-gate } 120*7c478bd9Sstevel@tonic-gate free(ti); 121*7c478bd9Sstevel@tonic-gate exit(0); 122*7c478bd9Sstevel@tonic-gate } 123